Skip to content

Commit a42bc62

Browse files
committed
ClangImporter: Share a module cache between CompilerInstances
Share an in-memory module cache between Clang compiler instances to maintain a consistent view of the implicitly-generated PCMs, protecting against filesystem races. This cache is more robust after r355778. Note that there are still potential races for PCHs; I'll fix that in a follow-up. rdar://problem/48545366 (cherry picked from commit bf0e9a7)
1 parent 9eed342 commit a42bc62

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,8 @@ std::string ClangImporter::getBridgingHeaderContents(StringRef headerPath,
13831383
invocation->getPreprocessorOpts().resetNonModularOptions();
13841384

13851385
clang::CompilerInstance rewriteInstance(
1386-
Impl.Instance->getPCHContainerOperations());
1386+
Impl.Instance->getPCHContainerOperations(),
1387+
&Impl.Instance->getModuleCache());
13871388
rewriteInstance.setInvocation(invocation);
13881389
rewriteInstance.createDiagnostics(new clang::IgnoringDiagConsumer);
13891390

@@ -1441,7 +1442,8 @@ ClangImporter::emitBridgingPCH(StringRef headerPath,
14411442
invocation->getLangOpts()->NeededByPCHOrCompilationUsesPCH = true;
14421443

14431444
clang::CompilerInstance emitInstance(
1444-
Impl.Instance->getPCHContainerOperations());
1445+
Impl.Instance->getPCHContainerOperations(),
1446+
&Impl.Instance->getModuleCache());
14451447
emitInstance.setInvocation(std::move(invocation));
14461448
emitInstance.createDiagnostics(&Impl.Instance->getDiagnosticClient(),
14471449
/*ShouldOwnClient=*/false);

0 commit comments

Comments
 (0)