sammccall created this revision. sammccall added a reviewer: kadircet. Herald added a subscriber: arphaman. Herald added a project: All. sammccall requested review of this revision. Herald added projects: clang, LLDB. Herald added subscribers: lldb-commits, cfe-commits.
(Followup from 40c13720a4b977d4347bbde53c52a4d0703823c2 <https://reviews.llvm.org/rG40c13720a4b977d4347bbde53c52a4d0703823c2>) Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D125012 Files: clang/include/clang/Frontend/Utils.h clang/lib/Frontend/ASTUnit.cpp clang/lib/Frontend/CreateInvocationFromCommandLine.cpp clang/tools/c-index-test/core_main.cpp clang/tools/diagtool/ShowEnabledWarnings.cpp clang/tools/libclang/Indexing.cpp clang/unittests/Frontend/ASTUnitTest.cpp clang/unittests/Frontend/CompilerInstanceTest.cpp clang/unittests/Serialization/ModuleCacheTest.cpp clang/unittests/Tooling/Syntax/TokensTest.cpp clang/unittests/Tooling/Syntax/TreeTestBase.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp +++ 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<clang::CompilerInvocation> invocation = - clang::createInvocationFromCommandLine(compiler_invocation_argument_cstrs, - diagnostics_engine); + clang::createInvocation(compiler_invocation_argument_cstrs, + std::move(CIOpts)); if (!invocation) return nullptr; Index: clang/unittests/Tooling/Syntax/TreeTestBase.cpp =================================================================== --- clang/unittests/Tooling/Syntax/TreeTestBase.cpp +++ 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( Index: clang/unittests/Tooling/Syntax/TokensTest.cpp =================================================================== --- clang/unittests/Tooling/Syntax/TokensTest.cpp +++ clang/unittests/Tooling/Syntax/TokensTest.cpp @@ -125,7 +125,10 @@ Diags->setClient(new IgnoringDiagConsumer); std::vector<const char *> 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( Index: clang/unittests/Serialization/ModuleCacheTest.cpp =================================================================== --- clang/unittests/Serialization/ModuleCacheTest.cpp +++ 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<DiagnosticsEngine> 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<CompilerInvocation> 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<CompilerInvocation> Invocation2 = - createInvocationFromCommandLine(Args2, Diags); + createInvocation(Args2, CIOpts); ASSERT_TRUE(Invocation2); CompilerInstance Instance2(Instance.getPCHContainerOperations(), &Instance.getModuleCache()); @@ -142,13 +145,15 @@ MCPArg.append(ModuleCachePath); IntrusiveRefCntPtr<DiagnosticsEngine> 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<CompilerInvocation> 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<CompilerInvocation> Invocation2 = - createInvocationFromCommandLine(Args2, Diags); + createInvocation(Args2, CIOpts); ASSERT_TRUE(Invocation2); CompilerInstance Instance2(Instance.getPCHContainerOperations(), &Instance.getModuleCache()); Index: clang/unittests/Frontend/CompilerInstanceTest.cpp =================================================================== --- clang/unittests/Frontend/CompilerInstanceTest.cpp +++ clang/unittests/Frontend/CompilerInstanceTest.cpp @@ -55,8 +55,10 @@ IntrusiveRefCntPtr<DiagnosticsEngine> Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions()); + CreateInvocationOptions CIOpts; + CIOpts.Diags = Diags; std::shared_ptr<CompilerInvocation> CInvok = - createInvocationFromCommandLine(Args, Diags); + createInvocation(Args, std::move(CIOpts)); if (!CInvok) FAIL() << "could not create compiler invocation"; Index: clang/unittests/Frontend/ASTUnitTest.cpp =================================================================== --- clang/unittests/Frontend/ASTUnitTest.cpp +++ 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); Index: clang/tools/libclang/Indexing.cpp =================================================================== --- clang/tools/libclang/Indexing.cpp +++ 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<CompilerInvocation> CInvok = - createInvocationFromCommandLine(*Args, Diags); + createInvocation(*Args, std::move(CIOpts)); if (!CInvok) return CXError_Failure; Index: clang/tools/diagtool/ShowEnabledWarnings.cpp =================================================================== --- clang/tools/diagtool/ShowEnabledWarnings.cpp +++ 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<DiagnosticsEngine> InterimDiags( - new DiagnosticsEngine(DiagIDs, new DiagnosticOptions(), DiagsBuffer)); // Try to build a CompilerInvocation. SmallVector<const char *, 4> Args; Args.push_back("diagtool"); Args.append(argv, argv + argc); + CreateInvocationOptions CIOpts; + CIOpts.Diags = + new DiagnosticsEngine(DiagIDs, new DiagnosticOptions(), DiagsBuffer); std::unique_ptr<CompilerInvocation> Invocation = - createInvocationFromCommandLine(Args, InterimDiags); + createInvocation(Args, std::move(CIOpts)); if (!Invocation) return nullptr; Index: clang/tools/c-index-test/core_main.cpp =================================================================== --- clang/tools/c-index-test/core_main.cpp +++ 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<DiagnosticsEngine> 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; Index: clang/lib/Frontend/CreateInvocationFromCommandLine.cpp =================================================================== --- clang/lib/Frontend/CreateInvocationFromCommandLine.cpp +++ clang/lib/Frontend/CreateInvocationFromCommandLine.cpp @@ -103,12 +103,3 @@ return nullptr; return CI; } - -std::unique_ptr<CompilerInvocation> clang::createInvocationFromCommandLine( - ArrayRef<const char *> Args, IntrusiveRefCntPtr<DiagnosticsEngine> Diags, - IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, bool ShouldRecoverOnErrors, - std::vector<std::string> *CC1Args) { - return createInvocation( - Args, - CreateInvocationOptions{Diags, VFS, ShouldRecoverOnErrors, CC1Args}); -} Index: clang/lib/Frontend/ASTUnit.cpp =================================================================== --- clang/lib/Frontend/ASTUnit.cpp +++ 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; } Index: clang/include/clang/Frontend/Utils.h =================================================================== --- clang/include/clang/Frontend/Utils.h +++ clang/include/clang/Frontend/Utils.h @@ -229,15 +229,6 @@ createInvocation(ArrayRef<const char *> Args, CreateInvocationOptions Opts = {}); -/// Deprecated version of createInvocation with individual optional args. -std::unique_ptr<CompilerInvocation> createInvocationFromCommandLine( - ArrayRef<const char *> Args, - IntrusiveRefCntPtr<DiagnosticsEngine> Diags = - IntrusiveRefCntPtr<DiagnosticsEngine>(), - IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr, - bool ShouldRecoverOnErrors = false, - std::vector<std::string> *CC1Args = nullptr); - } // namespace clang #endif // LLVM_CLANG_FRONTEND_UTILS_H
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits