diff --git a/clang/include/clang/Frontend/Utils.h b/clang/include/clang/Frontend/Utils.h --- a/clang/include/clang/Frontend/Utils.h +++ b/clang/include/clang/Frontend/Utils.h @@ -229,15 +229,6 @@ createInvocation(ArrayRef Args, CreateInvocationOptions Opts = {}); -/// Deprecated version of createInvocation with individual optional args. -std::unique_ptr createInvocationFromCommandLine( - ArrayRef Args, - IntrusiveRefCntPtr Diags = - IntrusiveRefCntPtr(), - IntrusiveRefCntPtr VFS = nullptr, - bool ShouldRecoverOnErrors = false, - std::vector *CC1Args = nullptr); - } // namespace clang #endif // LLVM_CLANG_FRONTEND_UTILS_H diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -1729,8 +1729,11 @@ CaptureDroppedDiagnostics Capture(CaptureDiagnostics, *Diags, &StoredDiagnostics, nullptr); - CI = createInvocationFromCommandLine( - llvm::makeArrayRef(ArgBegin, ArgEnd), Diags, VFS); + CreateInvocationOptions CIOpts; + CIOpts.VFS = VFS; + CIOpts.Diags = Diags; + CI = createInvocation(llvm::makeArrayRef(ArgBegin, ArgEnd), + std::move(CIOpts)); if (!CI) return nullptr; } diff --git a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp --- a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp +++ b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp @@ -103,12 +103,3 @@ return nullptr; return CI; } - -std::unique_ptr clang::createInvocationFromCommandLine( - ArrayRef Args, IntrusiveRefCntPtr Diags, - IntrusiveRefCntPtr VFS, bool ShouldRecoverOnErrors, - std::vector *CC1Args) { - return createInvocation( - Args, - CreateInvocationOptions{Diags, VFS, ShouldRecoverOnErrors, CC1Args}); -} diff --git a/clang/tools/c-index-test/core_main.cpp b/clang/tools/c-index-test/core_main.cpp --- a/clang/tools/c-index-test/core_main.cpp +++ b/clang/tools/c-index-test/core_main.cpp @@ -13,6 +13,7 @@ #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/CompilerInvocation.h" #include "clang/Frontend/FrontendAction.h" +#include "clang/Frontend/Utils.h" #include "clang/Index/IndexDataConsumer.h" #include "clang/Index/IndexingAction.h" #include "clang/Index/USRGeneration.h" @@ -220,7 +221,9 @@ ArgsWithProgName.append(Args.begin(), Args.end()); IntrusiveRefCntPtr Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions)); - auto CInvok = createInvocationFromCommandLine(ArgsWithProgName, Diags); + CreateInvocationOptions CIOpts; + CIOpts.Diags = Diags; + auto CInvok = createInvocation(ArgsWithProgName, std::move(CIOpts)); if (!CInvok) return true; diff --git a/clang/tools/diagtool/ShowEnabledWarnings.cpp b/clang/tools/diagtool/ShowEnabledWarnings.cpp --- a/clang/tools/diagtool/ShowEnabledWarnings.cpp +++ b/clang/tools/diagtool/ShowEnabledWarnings.cpp @@ -59,15 +59,16 @@ // Buffer diagnostics from argument parsing so that we can output them using a // well formed diagnostic object. TextDiagnosticBuffer *DiagsBuffer = new TextDiagnosticBuffer; - IntrusiveRefCntPtr InterimDiags( - new DiagnosticsEngine(DiagIDs, new DiagnosticOptions(), DiagsBuffer)); // Try to build a CompilerInvocation. SmallVector Args; Args.push_back("diagtool"); Args.append(argv, argv + argc); + CreateInvocationOptions CIOpts; + CIOpts.Diags = + new DiagnosticsEngine(DiagIDs, new DiagnosticOptions(), DiagsBuffer); std::unique_ptr Invocation = - createInvocationFromCommandLine(Args, InterimDiags); + createInvocation(Args, std::move(CIOpts)); if (!Invocation) return nullptr; diff --git a/clang/tools/libclang/Indexing.cpp b/clang/tools/libclang/Indexing.cpp --- a/clang/tools/libclang/Indexing.cpp +++ b/clang/tools/libclang/Indexing.cpp @@ -508,8 +508,10 @@ if (source_filename) Args->push_back(source_filename); + CreateInvocationOptions CIOpts; + CIOpts.Diags = Diags; std::shared_ptr CInvok = - createInvocationFromCommandLine(*Args, Diags); + createInvocation(*Args, std::move(CIOpts)); if (!CInvok) return CXError_Failure; diff --git a/clang/unittests/Frontend/ASTUnitTest.cpp b/clang/unittests/Frontend/ASTUnitTest.cpp --- a/clang/unittests/Frontend/ASTUnitTest.cpp +++ b/clang/unittests/Frontend/ASTUnitTest.cpp @@ -43,7 +43,9 @@ Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions()); - CInvok = createInvocationFromCommandLine(Args, Diags); + CreateInvocationOptions CIOpts; + CIOpts.Diags = Diags; + CInvok = createInvocation(Args, std::move(CIOpts)); if (!CInvok) return nullptr; @@ -133,7 +135,9 @@ const char *Args[] = {"clang", "test.cpp", "-fmodule-map-file=m.modulemap", "-fmodule-name=M"}; Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions()); - CInvok = createInvocationFromCommandLine(Args, Diags); + CreateInvocationOptions CIOpts; + CIOpts.Diags = Diags; + CInvok = createInvocation(Args, std::move(CIOpts)); ASSERT_TRUE(CInvok); FileManager *FileMgr = new FileManager(FileSystemOptions(), InMemoryFs); diff --git a/clang/unittests/Frontend/CompilerInstanceTest.cpp b/clang/unittests/Frontend/CompilerInstanceTest.cpp --- a/clang/unittests/Frontend/CompilerInstanceTest.cpp +++ b/clang/unittests/Frontend/CompilerInstanceTest.cpp @@ -55,8 +55,10 @@ IntrusiveRefCntPtr Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions()); + CreateInvocationOptions CIOpts; + CIOpts.Diags = Diags; std::shared_ptr CInvok = - createInvocationFromCommandLine(Args, Diags); + createInvocation(Args, std::move(CIOpts)); if (!CInvok) FAIL() << "could not create compiler invocation"; diff --git a/clang/unittests/Serialization/ModuleCacheTest.cpp b/clang/unittests/Serialization/ModuleCacheTest.cpp --- a/clang/unittests/Serialization/ModuleCacheTest.cpp +++ b/clang/unittests/Serialization/ModuleCacheTest.cpp @@ -10,6 +10,7 @@ #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/CompilerInvocation.h" #include "clang/Frontend/FrontendActions.h" +#include "clang/Frontend/Utils.h" #include "clang/Lex/HeaderSearch.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/FileSystem.h" @@ -95,13 +96,15 @@ MCPArg.append(ModuleCachePath); IntrusiveRefCntPtr Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions()); + CreateInvocationOptions CIOpts; + CIOpts.Diags = Diags; // First run should pass with no errors const char *Args[] = {"clang", "-fmodules", "-Fframeworks", MCPArg.c_str(), "-working-directory", TestDir.c_str(), "test.m"}; std::shared_ptr Invocation = - createInvocationFromCommandLine(Args, Diags); + createInvocation(Args, CIOpts); ASSERT_TRUE(Invocation); CompilerInstance Instance; Instance.setDiagnostics(Diags.get()); @@ -124,7 +127,7 @@ "-Fframeworks", MCPArg.c_str(), "-working-directory", TestDir.c_str(), "test.m"}; std::shared_ptr Invocation2 = - createInvocationFromCommandLine(Args2, Diags); + createInvocation(Args2, CIOpts); ASSERT_TRUE(Invocation2); CompilerInstance Instance2(Instance.getPCHContainerOperations(), &Instance.getModuleCache()); @@ -142,13 +145,15 @@ MCPArg.append(ModuleCachePath); IntrusiveRefCntPtr Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions()); + CreateInvocationOptions CIOpts; + CIOpts.Diags = Diags; // First run should pass with no errors const char *Args[] = {"clang", "-fmodules", "-Fframeworks", MCPArg.c_str(), "-working-directory", TestDir.c_str(), "test.m"}; std::shared_ptr Invocation = - createInvocationFromCommandLine(Args, Diags); + createInvocation(Args, CIOpts); ASSERT_TRUE(Invocation); CompilerInstance Instance; Instance.setDiagnostics(Diags.get()); @@ -165,7 +170,7 @@ TestDir.c_str(), "-Xclang", "-fallow-pcm-with-compiler-errors", "test.m"}; std::shared_ptr Invocation2 = - createInvocationFromCommandLine(Args2, Diags); + createInvocation(Args2, CIOpts); ASSERT_TRUE(Invocation2); CompilerInstance Instance2(Instance.getPCHContainerOperations(), &Instance.getModuleCache()); diff --git a/clang/unittests/Tooling/Syntax/TokensTest.cpp b/clang/unittests/Tooling/Syntax/TokensTest.cpp --- a/clang/unittests/Tooling/Syntax/TokensTest.cpp +++ b/clang/unittests/Tooling/Syntax/TokensTest.cpp @@ -125,7 +125,10 @@ Diags->setClient(new IgnoringDiagConsumer); std::vector Args = {"tok-test", "-std=c++03", "-fsyntax-only", FileName}; - auto CI = createInvocationFromCommandLine(Args, Diags, FS); + CreateInvocationOptions CIOpts; + CIOpts.Diags = Diags; + CIOpts.VFS = FS; + auto CI = createInvocation(Args, std::move(CIOpts)); assert(CI); CI->getFrontendOpts().DisableFree = false; CI->getPreprocessorOpts().addRemappedFile( diff --git a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp --- a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp +++ b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp @@ -134,7 +134,10 @@ ArgsCStr.push_back(arg.c_str()); } - Invocation = createInvocationFromCommandLine(ArgsCStr, Diags, FS); + CreateInvocationOptions CIOpts; + CIOpts.Diags = Diags; + CIOpts.VFS = FS; + Invocation = createInvocation(ArgsCStr, std::move(CIOpts)); assert(Invocation); Invocation->getFrontendOpts().DisableFree = false; Invocation->getPreprocessorOpts().addRemappedFile( diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp @@ -663,9 +663,11 @@ llvm::make_range(compiler_invocation_arguments.begin(), compiler_invocation_arguments.end())); + CreateInvocationOptions CIOpts; + CIOpts.Diags = diagnostics_engine; std::shared_ptr invocation = - clang::createInvocationFromCommandLine(compiler_invocation_argument_cstrs, - diagnostics_engine); + clang::createInvocation(compiler_invocation_argument_cstrs, + std::move(CIOpts)); if (!invocation) return nullptr;