Skip to content

Commit d3767c2

Browse files
authored
Merge pull request #6604 from apple/jan_svoboda/scanner-cherry-pick
NFC: Dependency scanner cherry-picks
2 parents 538cb04 + 799f0e6 commit d3767c2

File tree

2 files changed

+10
-27
lines changed

2 files changed

+10
-27
lines changed

clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -78,27 +78,18 @@ class PrebuiltModuleListener : public ASTReaderListener {
7878
public:
7979
PrebuiltModuleListener(CompilerInstance &CI,
8080
PrebuiltModuleFilesT &PrebuiltModuleFiles,
81-
llvm::StringSet<> &InputFiles, bool VisitInputFiles,
8281
llvm::SmallVector<std::string> &NewModuleFiles)
8382
: CI(CI), PrebuiltModuleFiles(PrebuiltModuleFiles),
84-
InputFiles(InputFiles), VisitInputFiles(VisitInputFiles),
83+
8584
NewModuleFiles(NewModuleFiles) {}
8685

8786
bool needsImportVisitation() const override { return true; }
88-
bool needsInputFileVisitation() override { return VisitInputFiles; }
89-
bool needsSystemInputFileVisitation() override { return VisitInputFiles; }
9087

9188
void visitImport(StringRef ModuleName, StringRef Filename) override {
9289
if (PrebuiltModuleFiles.insert({ModuleName.str(), Filename.str()}).second)
9390
NewModuleFiles.push_back(Filename.str());
9491
}
9592

96-
bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden,
97-
bool isExplicitModule) override {
98-
InputFiles.insert(Filename);
99-
return true;
100-
}
101-
10293
bool readModuleCacheKey(StringRef ModuleName, StringRef Filename,
10394
StringRef CacheKey) override {
10495
CI.getFrontendOpts().ModuleCacheKeys.emplace_back(std::string(Filename),
@@ -110,22 +101,17 @@ class PrebuiltModuleListener : public ASTReaderListener {
110101
private:
111102
CompilerInstance &CI;
112103
PrebuiltModuleFilesT &PrebuiltModuleFiles;
113-
llvm::StringSet<> &InputFiles;
114-
bool VisitInputFiles;
115104
llvm::SmallVector<std::string> &NewModuleFiles;
116105
};
117106

118107
/// Visit the given prebuilt module and collect all of the modules it
119108
/// transitively imports and contributing input files.
120109
static void visitPrebuiltModule(StringRef PrebuiltModuleFilename,
121110
CompilerInstance &CI,
122-
PrebuiltModuleFilesT &ModuleFiles,
123-
llvm::StringSet<> &InputFiles,
124-
bool VisitInputFiles) {
111+
PrebuiltModuleFilesT &ModuleFiles) {
125112
// List of module files to be processed.
126113
llvm::SmallVector<std::string> Worklist{PrebuiltModuleFilename.str()};
127-
PrebuiltModuleListener Listener(CI, ModuleFiles, InputFiles, VisitInputFiles,
128-
Worklist);
114+
PrebuiltModuleListener Listener(CI, ModuleFiles, Worklist);
129115

130116
while (!Worklist.empty())
131117
ASTReader::readASTFileControlBlock(
@@ -338,16 +324,13 @@ class DependencyScanningAction : public tooling::ToolAction {
338324

339325
ScanInstance.createSourceManager(*FileMgr);
340326

341-
llvm::StringSet<> PrebuiltModulesInputFiles;
342327
// Store the list of prebuilt module files into header search options. This
343328
// will prevent the implicit build to create duplicate modules and will
344329
// force reuse of the existing prebuilt module files instead.
345330
if (!ScanInstance.getPreprocessorOpts().ImplicitPCHInclude.empty())
346331
visitPrebuiltModule(
347332
ScanInstance.getPreprocessorOpts().ImplicitPCHInclude, ScanInstance,
348-
ScanInstance.getHeaderSearchOpts().PrebuiltModuleFiles,
349-
PrebuiltModulesInputFiles,
350-
/*VisitInputFiles=*/getDepScanFS() != nullptr);
333+
ScanInstance.getHeaderSearchOpts().PrebuiltModuleFiles);
351334

352335
// Use the dependency scanning optimized file system if requested to do so.
353336
if (DepFS) {

clang/test/ClangScanDeps/modules-pch.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
// Scan dependencies of the PCH:
99
//
10-
// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_pch.json > %t/cdb.json
11-
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
10+
// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_pch.json > %t/cdb_pch.json
11+
// RUN: clang-scan-deps -compilation-database %t/cdb_pch.json -format experimental-full \
1212
// RUN: -module-files-dir %t/build > %t/result_pch.json
1313
// RUN: cat %t/result_pch.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK-PCH
1414
//
@@ -94,8 +94,8 @@
9494

9595
// Scan dependencies of the TU:
9696
//
97-
// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu.json > %t/cdb.json
98-
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
97+
// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu.json > %t/cdb_tu.json
98+
// RUN: clang-scan-deps -compilation-database %t/cdb_tu.json -format experimental-full \
9999
// RUN: -module-files-dir %t/build > %t/result_tu.json
100100
// RUN: cat %t/result_tu.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK-TU
101101
//
@@ -142,8 +142,8 @@
142142

143143
// Scan dependencies of the TU that has common modules with the PCH:
144144
//
145-
// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu_with_common.json > %t/cdb.json
146-
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
145+
// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu_with_common.json > %t/cdb_tu_with_common.json
146+
// RUN: clang-scan-deps -compilation-database %t/cdb_tu_with_common.json -format experimental-full \
147147
// RUN: -module-files-dir %t/build > %t/result_tu_with_common.json
148148
// RUN: cat %t/result_tu_with_common.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK-TU-WITH-COMMON
149149
//

0 commit comments

Comments
 (0)