mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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 bf0e9a70c6)
This commit is contained in:
@@ -1383,7 +1383,8 @@ std::string ClangImporter::getBridgingHeaderContents(StringRef headerPath,
|
|||||||
invocation->getPreprocessorOpts().resetNonModularOptions();
|
invocation->getPreprocessorOpts().resetNonModularOptions();
|
||||||
|
|
||||||
clang::CompilerInstance rewriteInstance(
|
clang::CompilerInstance rewriteInstance(
|
||||||
Impl.Instance->getPCHContainerOperations());
|
Impl.Instance->getPCHContainerOperations(),
|
||||||
|
&Impl.Instance->getModuleCache());
|
||||||
rewriteInstance.setInvocation(invocation);
|
rewriteInstance.setInvocation(invocation);
|
||||||
rewriteInstance.createDiagnostics(new clang::IgnoringDiagConsumer);
|
rewriteInstance.createDiagnostics(new clang::IgnoringDiagConsumer);
|
||||||
|
|
||||||
@@ -1441,7 +1442,8 @@ ClangImporter::emitBridgingPCH(StringRef headerPath,
|
|||||||
invocation->getLangOpts()->NeededByPCHOrCompilationUsesPCH = true;
|
invocation->getLangOpts()->NeededByPCHOrCompilationUsesPCH = true;
|
||||||
|
|
||||||
clang::CompilerInstance emitInstance(
|
clang::CompilerInstance emitInstance(
|
||||||
Impl.Instance->getPCHContainerOperations());
|
Impl.Instance->getPCHContainerOperations(),
|
||||||
|
&Impl.Instance->getModuleCache());
|
||||||
emitInstance.setInvocation(std::move(invocation));
|
emitInstance.setInvocation(std::move(invocation));
|
||||||
emitInstance.createDiagnostics(&Impl.Instance->getDiagnosticClient(),
|
emitInstance.createDiagnostics(&Impl.Instance->getDiagnosticClient(),
|
||||||
/*ShouldOwnClient=*/false);
|
/*ShouldOwnClient=*/false);
|
||||||
|
|||||||
Reference in New Issue
Block a user