[clang] 499d0b9 - [clang] createInvocationFromCommandLine -> createInvocation, delete former. NFC
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Fri May 6 07:22:06 PDT 2022
Author: Sam McCall
Date: 2022-05-06T16:21:48+02:00
New Revision: 499d0b96cb52c828e7fc4d58825b5e8b3f9931c5
URL: https://github.com/llvm/llvm-project/commit/499d0b96cb52c828e7fc4d58825b5e8b3f9931c5
DIFF: https://github.com/llvm/llvm-project/commit/499d0b96cb52c828e7fc4d58825b5e8b3f9931c5.diff
LOG: [clang] createInvocationFromCommandLine -> createInvocation, delete former. NFC
(Followup from 40c13720a4b977d4347bbde53c52a4d0703823c2)
Differential Revision: https://reviews.llvm.org/D125012
Added:
Modified:
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
Removed:
################################################################################
diff --git a/clang/include/clang/Frontend/Utils.h b/clang/include/clang/Frontend/Utils.h
index 47f795b388f7..1e8841429ffa 100644
--- a/clang/include/clang/Frontend/Utils.h
+++ b/clang/include/clang/Frontend/Utils.h
@@ -234,15 +234,6 @@ std::unique_ptr<CompilerInvocation>
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, bool ProbePrecompiled = true);
-
} // namespace clang
#endif // LLVM_CLANG_FRONTEND_UTILS_H
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 5f587cc1c023..1d0f472e9c6e 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -1729,8 +1729,11 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
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
index 2a98aab44ccb..49e814b31b43 100644
--- a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -104,12 +104,3 @@ clang::createInvocation(ArrayRef<const char *> ArgList,
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, bool ProbePrecompiled) {
- return createInvocation(
- Args, CreateInvocationOptions{Diags, VFS, ShouldRecoverOnErrors,
- ProbePrecompiled, CC1Args});
-}
diff --git a/clang/tools/c-index-test/core_main.cpp b/clang/tools/c-index-test/core_main.cpp
index 7037252ffa0e..c5f47baa8458 100644
--- 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 @@ static bool printSourceSymbols(const char *Executable,
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;
diff --git a/clang/tools/diagtool/ShowEnabledWarnings.cpp b/clang/tools/diagtool/ShowEnabledWarnings.cpp
index ae2d3e37e845..e5a7b2532824 100644
--- a/clang/tools/diagtool/ShowEnabledWarnings.cpp
+++ b/clang/tools/diagtool/ShowEnabledWarnings.cpp
@@ -59,15 +59,16 @@ createDiagnostics(unsigned int argc, char **argv) {
// 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;
diff --git a/clang/tools/libclang/Indexing.cpp b/clang/tools/libclang/Indexing.cpp
index 5e0c5e01d933..0534ccac290d 100644
--- a/clang/tools/libclang/Indexing.cpp
+++ b/clang/tools/libclang/Indexing.cpp
@@ -508,8 +508,10 @@ static CXErrorCode clang_indexSourceFile_Impl(
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;
diff --git a/clang/unittests/Frontend/ASTUnitTest.cpp b/clang/unittests/Frontend/ASTUnitTest.cpp
index eb3fdb48a2da..1bfc957f21bf 100644
--- a/clang/unittests/Frontend/ASTUnitTest.cpp
+++ b/clang/unittests/Frontend/ASTUnitTest.cpp
@@ -43,7 +43,9 @@ class ASTUnitTest : public ::testing::Test {
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 @@ TEST_F(ASTUnitTest, ModuleTextualHeader) {
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
index 8e74d170d4f4..a28d72e7d953 100644
--- a/clang/unittests/Frontend/CompilerInstanceTest.cpp
+++ b/clang/unittests/Frontend/CompilerInstanceTest.cpp
@@ -55,8 +55,10 @@ TEST(CompilerInstance, DefaultVFSOverlayFromInvocation) {
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";
diff --git a/clang/unittests/Serialization/ModuleCacheTest.cpp b/clang/unittests/Serialization/ModuleCacheTest.cpp
index 6cffbc2c1221..268b03717985 100644
--- 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 @@ TEST_F(ModuleCacheTest, CachedModuleNewPath) {
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 @@ TEST_F(ModuleCacheTest, CachedModuleNewPath) {
"-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 @@ TEST_F(ModuleCacheTest, CachedModuleNewPathAllowErrors) {
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 @@ TEST_F(ModuleCacheTest, CachedModuleNewPathAllowErrors) {
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());
diff --git a/clang/unittests/Tooling/Syntax/TokensTest.cpp b/clang/unittests/Tooling/Syntax/TokensTest.cpp
index 22134d9d0cfb..77f719ce28cd 100644
--- a/clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -125,7 +125,10 @@ class TokenCollectorTest : public ::testing::Test {
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(
diff --git a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp
index 92d0c07ce235..9bc5c28a50d5 100644
--- a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -134,7 +134,10 @@ SyntaxTreeTest::buildTree(StringRef Code, const TestClangConfig &ClangConfig) {
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
index a15e0d8c588e..385bb51eca5b 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -663,9 +663,11 @@ ClangModulesDeclVendor::Create(Target &target) {
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;
More information about the cfe-commits
mailing list