[clang][deps] NFC: Preserve the original frontend action
authorJan Svoboda <jan_svoboda@apple.com>
Mon, 14 Jun 2021 08:32:48 +0000 (10:32 +0200)
committerJan Svoboda <jan_svoboda@apple.com>
Mon, 14 Jun 2021 08:49:25 +0000 (10:49 +0200)
This patch stops adjusting the frontend action when `clang-scan-deps` is configured to use the full output format.

In a future patch, the dependency scanner needs to check whether the original compiler invocation builds a PCH. That's impossible when `-Eonly` et al. override `-emit-pch`.

The `-Eonly` flag is not needed - the dependency scanner explicitly sets up its own frontend action anyways.

Reviewed By: dexonsmith

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

clang/tools/clang-scan-deps/ClangScanDeps.cpp

index 2501ec3..ce8be72 100644 (file)
@@ -462,6 +462,10 @@ int main(int argc, const char **argv) {
       std::make_unique<tooling::ArgumentsAdjustingCompilations>(
           std::move(Compilations));
   ResourceDirectoryCache ResourceDirCache;
+
+  // FIXME: Adjust the resulting CompilerInvocation in DependencyScanningAction
+  // instead of parsing and adjusting the raw command-line. This will make it
+  // possible to remove some code specific to clang-cl and Windows.
   AdjustingCompilations->appendArgumentsAdjuster(
       [&ResourceDirCache](const tooling::CommandLineArguments &Args,
                           StringRef FileName) {
@@ -532,7 +536,7 @@ int main(int argc, const char **argv) {
 #else
         AdjustedArgs.push_back("/dev/null");
 #endif
-        if (!HasMT && !HasMQ) {
+        if (!HasMT && !HasMQ && Format == ScanningOutputFormat::Make) {
           // We're interested in source dependencies of an object file.
           std::string FileNameArg;
           if (!HasMD) {
@@ -553,8 +557,6 @@ int main(int argc, const char **argv) {
           }
         }
         AdjustedArgs.push_back("-Xclang");
-        AdjustedArgs.push_back("-Eonly");
-        AdjustedArgs.push_back("-Xclang");
         AdjustedArgs.push_back("-sys-header-deps");
         AdjustedArgs.push_back("-Wno-error");