[clang] 669771c - [clang][deps] NFC: Preserve the original frontend action

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 14 01:49:32 PDT 2021


Author: Jan Svoboda
Date: 2021-06-14T10:49:25+02:00
New Revision: 669771cfe75b48ac4c195ce9e8824319be973f4d

URL: https://github.com/llvm/llvm-project/commit/669771cfe75b48ac4c195ce9e8824319be973f4d
DIFF: https://github.com/llvm/llvm-project/commit/669771cfe75b48ac4c195ce9e8824319be973f4d.diff

LOG: [clang][deps] NFC: Preserve the original frontend action

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index 2501ec3470e1..ce8be72bc291 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -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");
 


        


More information about the cfe-commits mailing list