@@ -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 ([&]() {
@@ -1486,7 +1485,6 @@ void ASTUnit::RealizeTopLevelDeclsFromPreamble() {
14861485void ASTUnit::transferASTDataFromCompilerInstance (CompilerInstance &CI) {
14871486 // Steal the created target, context, and preprocessor if they have been
14881487 // created.
1489- assert (CI.hasInvocation () && " missing invocation" );
14901488 LangOpts = CI.getInvocation ().LangOpts ;
14911489 TheSema = CI.takeSema ();
14921490 Consumer = CI.takeASTConsumer ();
@@ -1596,14 +1594,13 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(
15961594 AST->getFileManager ().getVirtualFileSystem ());
15971595
15981596 // Create the compiler instance to use for building the AST.
1599- std::unique_ptr <CompilerInstance> Clang (
1600- new CompilerInstance ( std::move (PCHContainerOps) ));
1597+ auto Clang = std::make_unique <CompilerInstance>( std::move (CI),
1598+ std::move (PCHContainerOps));
16011599
16021600 // Recover resources if we crash before exiting this method.
16031601 llvm::CrashRecoveryContextCleanupRegistrar<CompilerInstance>
16041602 CICleanup (Clang.get ());
16051603
1606- Clang->setInvocation (std::move (CI));
16071604 AST->OriginalSourceFile =
16081605 std::string (Clang->getFrontendOpts ().Inputs [0 ].getFile ());
16091606
@@ -2227,15 +2224,14 @@ void ASTUnit::CodeComplete(
22272224 LangOpts.SpellChecking = false ;
22282225 CCInvocation->getDiagnosticOpts ().IgnoreWarnings = true ;
22292226
2230- std::unique_ptr <CompilerInstance> Clang (
2231- new CompilerInstance ( PCHContainerOps) );
2227+ auto Clang = std::make_unique <CompilerInstance>( std::move (CCInvocation),
2228+ PCHContainerOps);
22322229
22332230 // Recover resources if we crash before exiting this method.
22342231 llvm::CrashRecoveryContextCleanupRegistrar<CompilerInstance>
22352232 CICleanup (Clang.get ());
22362233
2237- auto &Inv = *CCInvocation;
2238- Clang->setInvocation (std::move (CCInvocation));
2234+ auto &Inv = Clang->getInvocation ();
22392235 OriginalSourceFile =
22402236 std::string (Clang->getFrontendOpts ().Inputs [0 ].getFile ());
22412237
@@ -2249,7 +2245,6 @@ void ASTUnit::CodeComplete(
22492245
22502246 // Create the target instance.
22512247 if (!Clang->createTarget ()) {
2252- Clang->setInvocation (nullptr );
22532248 return ;
22542249 }
22552250
0 commit comments