HomePhabricator

[clang][deps] Move invocation adjustments from `clang-scan-deps` to…

Authored by jansvoboda11 on Jun 14 2021, 3:06 AM.

Description

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

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.

Reviewed By: arphaman

Differential Revision: https://reviews.llvm.org/D104030