@@ -966,10 +966,8 @@ bool ClangImporter::canReadPCH(StringRef PCHFilename) {
966
966
// FIXME: The following attempts to do an initial ReadAST invocation to verify
967
967
// the PCH, without causing trouble for the existing CompilerInstance.
968
968
// Look into combining creating the ASTReader along with verification + update
969
- // if necessary, so that we can create and use one ASTReader in the common case
970
- // when there is no need for update.
971
- clang::CompilerInstance CI (Impl.Instance ->getPCHContainerOperations (),
972
- &Impl.Instance ->getModuleCache ());
969
+ // if necessary, so that we can create and use one ASTReader in the common
970
+ // case when there is no need for update.
973
971
auto invocation =
974
972
std::make_shared<clang::CompilerInvocation>(*Impl.Invocation );
975
973
invocation->getPreprocessorOpts ().DisablePCHOrModuleValidation =
@@ -985,7 +983,9 @@ bool ClangImporter::canReadPCH(StringRef PCHFilename) {
985
983
invocation->getPreprocessorOpts ().RemappedFileBuffers .clear ();
986
984
987
985
clang::DiagnosticOptions diagOpts;
988
- CI.setInvocation (std::move (invocation));
986
+ clang::CompilerInstance CI (std::move (invocation),
987
+ Impl.Instance ->getPCHContainerOperations (),
988
+ &Impl.Instance ->getModuleCache ());
989
989
CI.setTarget (&Impl.Instance ->getTarget ());
990
990
CI.setDiagnostics (&*clang::CompilerInstance::createDiagnostics (
991
991
Impl.Instance ->getVirtualFileSystem (), diagOpts));
@@ -1363,12 +1363,10 @@ ClangImporter::create(ASTContext &ctx,
1363
1363
std::make_unique<clang::ObjectFilePCHContainerWriter>());
1364
1364
PCHContainerOperations->registerReader (
1365
1365
std::make_unique<clang::ObjectFilePCHContainerReader>());
1366
- importer->Impl .Instance .reset (
1367
- new clang::CompilerInstance ( std::move (PCHContainerOperations)));
1366
+ importer->Impl .Instance .reset (new clang::CompilerInstance (
1367
+ importer-> Impl . Invocation , std::move (PCHContainerOperations)));
1368
1368
}
1369
1369
auto &instance = *importer->Impl .Instance ;
1370
- instance.setInvocation (importer->Impl .Invocation );
1371
-
1372
1370
if (tracker)
1373
1371
instance.addDependencyCollector (tracker->getClangCollector ());
1374
1372
@@ -1898,9 +1896,8 @@ std::string ClangImporter::getBridgingHeaderContents(
1898
1896
clang::FileManager &fileManager = Impl.Instance ->getFileManager ();
1899
1897
1900
1898
clang::CompilerInstance rewriteInstance (
1901
- Impl.Instance ->getPCHContainerOperations (),
1902
- &Impl.Instance ->getModuleCache ());
1903
- rewriteInstance.setInvocation (invocation);
1899
+ std::move (invocation), Impl.Instance ->getPCHContainerOperations (),
1900
+ &Impl.Instance ->getModuleCache ());
1904
1901
rewriteInstance.createDiagnostics (fileManager.getVirtualFileSystem (),
1905
1902
new clang::IgnoringDiagConsumer);
1906
1903
rewriteInstance.setFileManager (&fileManager);
@@ -2004,9 +2001,8 @@ ClangImporter::cloneCompilerInstanceForPrecompiling() {
2004
2001
clang::FileManager &fileManager = Impl.Instance ->getFileManager ();
2005
2002
2006
2003
auto clonedInstance = std::make_unique<clang::CompilerInstance>(
2007
- Impl.Instance ->getPCHContainerOperations (),
2008
- &Impl.Instance ->getModuleCache ());
2009
- clonedInstance->setInvocation (std::move (invocation));
2004
+ std::move (invocation), Impl.Instance ->getPCHContainerOperations (),
2005
+ &Impl.Instance ->getModuleCache ());
2010
2006
clonedInstance->createDiagnostics (fileManager.getVirtualFileSystem (),
2011
2007
&Impl.Instance ->getDiagnosticClient (),
2012
2008
/* ShouldOwnClient=*/ false );
0 commit comments