Skip to content

Commit a5adff9

Browse files
authored
Merge pull request #10877 from ahoppen/stable/dont-index-implicit-modules
2 parents 3f4e1e2 + 91c0899 commit a5adff9

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,15 @@ compileModuleImpl(CompilerInstance &ImportingInstance, SourceLocation ImportLoc,
13521352
HSOpts.ModulesHashContent = true;
13531353
FrontendOpts.Inputs = {Input};
13541354
FrontendOpts.MayEmitDiagnosticsAfterProcessingSourceFiles = false;
1355+
// Clear `IndexUnitOutputPath`. Otherwise the unit for the pcm will be named
1356+
// after the primary source file, and will be overwritten when that file's
1357+
// unit is finally written.
1358+
FrontendOpts.IndexUnitOutputPath = "";
1359+
if (FrontendOpts.IndexIgnorePcms) {
1360+
// If we shouldn't index pcms, disable indexing by clearing the index store
1361+
// path.
1362+
FrontendOpts.IndexStorePath = "";
1363+
}
13551364

13561365
// Don't free the remapped file buffers; they are owned by our caller.
13571366
PPOpts.RetainRemappedFileBuffers = true;

clang/lib/Index/IndexingAction.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,12 +683,17 @@ class WrappingIndexRecordAction : public WrapperFrontendAction,
683683
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
684684
StringRef InFile) override {
685685
auto OtherConsumer = WrapperFrontendAction::CreateASTConsumer(CI, InFile);
686-
if (!OtherConsumer)
687-
return nullptr;
686+
687+
if (CI.getFrontendOpts().IndexStorePath.empty()) {
688+
// We are not generating an index store. Nothing to do.
689+
return OtherConsumer;
690+
}
688691

689692
CreatedASTConsumer = true;
690693
std::vector<std::unique_ptr<ASTConsumer>> Consumers;
691-
Consumers.push_back(std::move(OtherConsumer));
694+
if (OtherConsumer) {
695+
Consumers.push_back(std::move(OtherConsumer));
696+
}
692697
Consumers.push_back(createIndexASTConsumer(CI));
693698
return std::make_unique<MultiplexConsumer>(std::move(Consumers));
694699
}

0 commit comments

Comments
 (0)