Skip to content

Commit bf0e9a7

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
1 parent 131cff7 commit bf0e9a7

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
@@ -1382,7 +1382,8 @@ std::string ClangImporter::getBridgingHeaderContents(StringRef headerPath,
13821382
invocation->getPreprocessorOpts().resetNonModularOptions();
13831383

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

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

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

0 commit comments

Comments
 (0)