This is an archive of the discontinued LLVM Phabricator instance.

[clang][deps] Move invocation adjustments from `clang-scan-deps` to `DependencyScanning` library
ClosedPublic

Authored by jansvoboda11 on Jun 10 2021, 7:21 AM.

Details

Summary

The clang-scan-deps tool has some logic that parses and modifies the original Clang command-line. The goal is to setup DependencyOutputOptions by injecting -M -MT <target> and prevent the creation of output files.

This patch moves the logic into the DependencyScanning library, and uses the parsed CompilerInvocation instead of the raw command-line. The code simpler and can be used from the C++ API as well.

The -o /dev/null arguments are not necessary, since the DependencyScanning library only runs a preprocessing action, so there's no way it'll produce an actual object file.

Related: The -M argument implies -w, which would appear on the command-line of modular dependencies even though it was not on the original TU command line (see D104036).

Some related tests were updated.

Diff Detail