@@ -1162,9 +1162,8 @@ bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
11621162 }
11631163
11641164 // Create the compiler instance to use for building the AST.
1165- std::unique_ptr<CompilerInstance> Clang (
1166- new CompilerInstance (std::move (PCHContainerOps)));
1167- Clang->setInvocation (CCInvocation);
1165+ auto Clang = std::make_unique<CompilerInstance>(CCInvocation,
1166+ std::move (PCHContainerOps));
11681167
11691168 // Clean up on error, disengage it if the function returns successfully.
11701169 auto CleanOnError = llvm::make_scope_exit ([&]() {
@@ -1487,7 +1486,6 @@ void ASTUnit::RealizeTopLevelDeclsFromPreamble() {
14871486void ASTUnit::transferASTDataFromCompilerInstance (CompilerInstance &CI) {
14881487 // Steal the created target, context, and preprocessor if they have been
14891488 // created.
1490- assert (CI.hasInvocation () && " missing invocation" );
14911489 LangOpts = std::make_unique<LangOptions>(CI.getInvocation ().getLangOpts ());
14921490 TheSema = CI.takeSema ();
14931491 Consumer = CI.takeASTConsumer ();
@@ -1601,14 +1599,13 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(
16011599 AST->getFileManager ().getVirtualFileSystem ());
16021600
16031601 // Create the compiler instance to use for building the AST.
1604- std::unique_ptr <CompilerInstance> Clang (
1605- new CompilerInstance ( std::move (PCHContainerOps) ));
1602+ auto Clang = std::make_unique <CompilerInstance>( std::move (CI),
1603+ std::move (PCHContainerOps));
16061604
16071605 // Recover resources if we crash before exiting this method.
16081606 llvm::CrashRecoveryContextCleanupRegistrar<CompilerInstance>
16091607 CICleanup (Clang.get ());
16101608
1611- Clang->setInvocation (std::move (CI));
16121609 AST->OriginalSourceFile =
16131610 std::string (Clang->getFrontendOpts ().Inputs [0 ].getFile ());
16141611
@@ -2232,15 +2229,14 @@ void ASTUnit::CodeComplete(
22322229 LangOpts.SpellChecking = false ;
22332230 CCInvocation->getDiagnosticOpts ().IgnoreWarnings = true ;
22342231
2235- std::unique_ptr <CompilerInstance> Clang (
2236- new CompilerInstance ( PCHContainerOps) );
2232+ auto Clang = std::make_unique <CompilerInstance>( std::move (CCInvocation),
2233+ PCHContainerOps);
22372234
22382235 // Recover resources if we crash before exiting this method.
22392236 llvm::CrashRecoveryContextCleanupRegistrar<CompilerInstance>
22402237 CICleanup (Clang.get ());
22412238
2242- auto &Inv = *CCInvocation;
2243- Clang->setInvocation (std::move (CCInvocation));
2239+ auto &Inv = Clang->getInvocation ();
22442240 OriginalSourceFile =
22452241 std::string (Clang->getFrontendOpts ().Inputs [0 ].getFile ());
22462242
@@ -2254,7 +2250,6 @@ void ASTUnit::CodeComplete(
22542250
22552251 // Create the target instance.
22562252 if (!Clang->createTarget ()) {
2257- Clang->setInvocation (nullptr );
22582253 return ;
22592254 }
22602255
0 commit comments