diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp index af20f1a00dc63..401789d332cda 100644 --- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp +++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp @@ -74,27 +74,18 @@ class PrebuiltModuleListener : public ASTReaderListener { public: PrebuiltModuleListener(CompilerInstance &CI, PrebuiltModuleFilesT &PrebuiltModuleFiles, - llvm::StringSet<> &InputFiles, bool VisitInputFiles, llvm::SmallVector &NewModuleFiles) : CI(CI), PrebuiltModuleFiles(PrebuiltModuleFiles), - InputFiles(InputFiles), VisitInputFiles(VisitInputFiles), + NewModuleFiles(NewModuleFiles) {} bool needsImportVisitation() const override { return true; } - bool needsInputFileVisitation() override { return VisitInputFiles; } - bool needsSystemInputFileVisitation() override { return VisitInputFiles; } void visitImport(StringRef ModuleName, StringRef Filename) override { if (PrebuiltModuleFiles.insert({ModuleName.str(), Filename.str()}).second) NewModuleFiles.push_back(Filename.str()); } - bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, - bool isExplicitModule) override { - InputFiles.insert(Filename); - return true; - } - bool readModuleCacheKey(StringRef ModuleName, StringRef Filename, StringRef CacheKey) override { CI.getFrontendOpts().ModuleCacheKeys.emplace_back(std::string(Filename), @@ -106,8 +97,6 @@ class PrebuiltModuleListener : public ASTReaderListener { private: CompilerInstance &CI; PrebuiltModuleFilesT &PrebuiltModuleFiles; - llvm::StringSet<> &InputFiles; - bool VisitInputFiles; llvm::SmallVector &NewModuleFiles; }; @@ -115,13 +104,10 @@ class PrebuiltModuleListener : public ASTReaderListener { /// transitively imports and contributing input files. static void visitPrebuiltModule(StringRef PrebuiltModuleFilename, CompilerInstance &CI, - PrebuiltModuleFilesT &ModuleFiles, - llvm::StringSet<> &InputFiles, - bool VisitInputFiles) { + PrebuiltModuleFilesT &ModuleFiles) { // List of module files to be processed. llvm::SmallVector Worklist{PrebuiltModuleFilename.str()}; - PrebuiltModuleListener Listener(CI, ModuleFiles, InputFiles, VisitInputFiles, - Worklist); + PrebuiltModuleListener Listener(CI, ModuleFiles, Worklist); while (!Worklist.empty()) ASTReader::readASTFileControlBlock( @@ -375,16 +361,13 @@ class DependencyScanningAction : public tooling::ToolAction { ScanInstance.createSourceManager(*FileMgr); - llvm::StringSet<> PrebuiltModulesInputFiles; // Store the list of prebuilt module files into header search options. This // will prevent the implicit build to create duplicate modules and will // force reuse of the existing prebuilt module files instead. if (!ScanInstance.getPreprocessorOpts().ImplicitPCHInclude.empty()) visitPrebuiltModule( ScanInstance.getPreprocessorOpts().ImplicitPCHInclude, ScanInstance, - ScanInstance.getHeaderSearchOpts().PrebuiltModuleFiles, - PrebuiltModulesInputFiles, - /*VisitInputFiles=*/getDepScanFS() != nullptr); + ScanInstance.getHeaderSearchOpts().PrebuiltModuleFiles); // Use the dependency scanning optimized file system if requested to do so. if (DepFS) { diff --git a/clang/test/ClangScanDeps/modules-pch.c b/clang/test/ClangScanDeps/modules-pch.c index 1d46c89d57909..e2778dc7c4f6a 100644 --- a/clang/test/ClangScanDeps/modules-pch.c +++ b/clang/test/ClangScanDeps/modules-pch.c @@ -7,8 +7,8 @@ // Scan dependencies of the PCH: // -// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_pch.json > %t/cdb.json -// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \ +// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_pch.json > %t/cdb_pch.json +// RUN: clang-scan-deps -compilation-database %t/cdb_pch.json -format experimental-full \ // RUN: -module-files-dir %t/build > %t/result_pch.json // RUN: cat %t/result_pch.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK-PCH // @@ -94,8 +94,8 @@ // Scan dependencies of the TU: // -// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu.json > %t/cdb.json -// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \ +// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu.json > %t/cdb_tu.json +// RUN: clang-scan-deps -compilation-database %t/cdb_tu.json -format experimental-full \ // RUN: -module-files-dir %t/build > %t/result_tu.json // RUN: cat %t/result_tu.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK-TU // @@ -142,8 +142,8 @@ // Scan dependencies of the TU that has common modules with the PCH: // -// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu_with_common.json > %t/cdb.json -// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \ +// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu_with_common.json > %t/cdb_tu_with_common.json +// RUN: clang-scan-deps -compilation-database %t/cdb_tu_with_common.json -format experimental-full \ // RUN: -module-files-dir %t/build > %t/result_tu_with_common.json // RUN: cat %t/result_tu_with_common.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK-TU-WITH-COMMON //