r370122 - ArrayRef'ized CompilerInvocation::CreateFromArgs
Dmitri Gribenko via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 27 15:13:31 PDT 2019
Author: gribozavr
Date: Tue Aug 27 15:13:31 2019
New Revision: 370122
URL: http://llvm.org/viewvc/llvm-project?rev=370122&view=rev
Log:
ArrayRef'ized CompilerInvocation::CreateFromArgs
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66797
Modified:
cfe/trunk/include/clang/Frontend/CompilerInvocation.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
cfe/trunk/lib/Tooling/Tooling.cpp
cfe/trunk/tools/arcmt-test/arcmt-test.cpp
cfe/trunk/tools/clang-import-test/clang-import-test.cpp
cfe/trunk/tools/driver/cc1_main.cpp
cfe/trunk/unittests/AST/ExternalASTSourceTest.cpp
Modified: cfe/trunk/include/clang/Frontend/CompilerInvocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInvocation.h?rev=370122&r1=370121&r2=370122&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/CompilerInvocation.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInvocation.h Tue Aug 27 15:13:31 2019
@@ -21,6 +21,7 @@
#include "clang/Frontend/PreprocessorOutputOptions.h"
#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/ArrayRef.h"
#include <memory>
#include <string>
@@ -153,12 +154,8 @@ public:
/// one of the vaild-to-access (albeit arbitrary) states.
///
/// \param [out] Res - The resulting invocation.
- /// \param ArgBegin - The first element in the argument vector.
- /// \param ArgEnd - The last element in the argument vector.
- /// \param Diags - The diagnostic engine to use for errors.
static bool CreateFromArgs(CompilerInvocation &Res,
- const char* const *ArgBegin,
- const char* const *ArgEnd,
+ ArrayRef<const char *> CommandLineArgs,
DiagnosticsEngine &Diags);
/// Get the directory where the compiler headers
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=370122&r1=370121&r2=370122&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Aug 27 15:13:31 2019
@@ -3370,8 +3370,7 @@ static void ParseTargetArgs(TargetOption
}
bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
- const char *const *ArgBegin,
- const char *const *ArgEnd,
+ ArrayRef<const char *> CommandLineArgs,
DiagnosticsEngine &Diags) {
bool Success = true;
@@ -3379,9 +3378,8 @@ bool CompilerInvocation::CreateFromArgs(
std::unique_ptr<OptTable> Opts = createDriverOptTable();
const unsigned IncludedFlagsBitmask = options::CC1Option;
unsigned MissingArgIndex, MissingArgCount;
- InputArgList Args =
- Opts->ParseArgs(llvm::makeArrayRef(ArgBegin, ArgEnd), MissingArgIndex,
- MissingArgCount, IncludedFlagsBitmask);
+ InputArgList Args = Opts->ParseArgs(CommandLineArgs, MissingArgIndex,
+ MissingArgCount, IncludedFlagsBitmask);
LangOptions &LangOpts = *Res.getLangOpts();
// Check for missing argument error.
Modified: cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp?rev=370122&r1=370121&r2=370122&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp (original)
+++ cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp Tue Aug 27 15:13:31 2019
@@ -90,9 +90,7 @@ std::unique_ptr<CompilerInvocation> clan
const ArgStringList &CCArgs = Cmd.getArguments();
auto CI = std::make_unique<CompilerInvocation>();
- if (!CompilerInvocation::CreateFromArgs(
- *CI, const_cast<const char **>(CCArgs.data()),
- const_cast<const char **>(CCArgs.data()) + CCArgs.size(), *Diags) &&
+ if (!CompilerInvocation::CreateFromArgs(*CI, CCArgs, *Diags) &&
!ShouldRecoverOnErorrs)
return nullptr;
return CI;
Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=370122&r1=370121&r2=370122&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Tue Aug 27 15:13:31 2019
@@ -118,9 +118,7 @@ CompilerInvocation *newInvocation(
DiagnosticsEngine *Diagnostics, const llvm::opt::ArgStringList &CC1Args) {
assert(!CC1Args.empty() && "Must at least contain the program name!");
CompilerInvocation *Invocation = new CompilerInvocation;
- CompilerInvocation::CreateFromArgs(
- *Invocation, CC1Args.data() + 1, CC1Args.data() + CC1Args.size(),
- *Diagnostics);
+ CompilerInvocation::CreateFromArgs(*Invocation, CC1Args, *Diagnostics);
Invocation->getFrontendOpts().DisableFree = false;
Invocation->getCodeGenOpts().DisableFree = false;
return Invocation;
Modified: cfe/trunk/tools/arcmt-test/arcmt-test.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/arcmt-test/arcmt-test.cpp?rev=370122&r1=370121&r2=370122&view=diff
==============================================================================
--- cfe/trunk/tools/arcmt-test/arcmt-test.cpp (original)
+++ cfe/trunk/tools/arcmt-test/arcmt-test.cpp Tue Aug 27 15:13:31 2019
@@ -121,7 +121,7 @@ static bool checkForMigration(StringRef
}
CompilerInvocation CI;
- if (!CompilerInvocation::CreateFromArgs(CI, Args.begin(), Args.end(), *Diags))
+ if (!CompilerInvocation::CreateFromArgs(CI, Args, *Diags))
return true;
if (CI.getFrontendOpts().Inputs.empty()) {
@@ -160,8 +160,7 @@ static bool performTransformations(Strin
new DiagnosticsEngine(DiagID, &*DiagOpts, &*DiagClient));
CompilerInvocation origCI;
- if (!CompilerInvocation::CreateFromArgs(origCI, Args.begin(), Args.end(),
- *TopDiags))
+ if (!CompilerInvocation::CreateFromArgs(origCI, Args, *TopDiags))
return true;
if (origCI.getFrontendOpts().Inputs.empty()) {
Modified: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/clang-import-test.cpp?rev=370122&r1=370121&r2=370122&view=diff
==============================================================================
--- cfe/trunk/tools/clang-import-test/clang-import-test.cpp (original)
+++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp Tue Aug 27 15:13:31 2019
@@ -168,9 +168,7 @@ std::unique_ptr<CompilerInstance> BuildC
std::vector<const char *> ClangArgv(ClangArgs.size());
std::transform(ClangArgs.begin(), ClangArgs.end(), ClangArgv.begin(),
[](const std::string &s) -> const char * { return s.data(); });
- CompilerInvocation::CreateFromArgs(*Inv, ClangArgv.data(),
- &ClangArgv.data()[ClangArgv.size()],
- Ins->getDiagnostics());
+ CompilerInvocation::CreateFromArgs(*Inv, ClangArgv, Ins->getDiagnostics());
{
using namespace driver::types;
Modified: cfe/trunk/tools/driver/cc1_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1_main.cpp?rev=370122&r1=370121&r2=370122&view=diff
==============================================================================
--- cfe/trunk/tools/driver/cc1_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1_main.cpp Tue Aug 27 15:13:31 2019
@@ -213,8 +213,8 @@ int cc1_main(ArrayRef<const char *> Argv
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
TextDiagnosticBuffer *DiagsBuffer = new TextDiagnosticBuffer;
DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagsBuffer);
- bool Success = CompilerInvocation::CreateFromArgs(
- Clang->getInvocation(), Argv.begin(), Argv.end(), Diags);
+ bool Success =
+ CompilerInvocation::CreateFromArgs(Clang->getInvocation(), Argv, Diags);
if (Clang->getFrontendOpts().TimeTrace) {
llvm::timeTraceProfilerInitialize(
Modified: cfe/trunk/unittests/AST/ExternalASTSourceTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ExternalASTSourceTest.cpp?rev=370122&r1=370121&r2=370122&view=diff
==============================================================================
--- cfe/trunk/unittests/AST/ExternalASTSourceTest.cpp (original)
+++ cfe/trunk/unittests/AST/ExternalASTSourceTest.cpp Tue Aug 27 15:13:31 2019
@@ -53,7 +53,6 @@ bool testExternalASTSource(ExternalASTSo
"test.cc", MemoryBuffer::getMemBuffer(FileContents).release());
const char *Args[] = { "test.cc" };
CompilerInvocation::CreateFromArgs(*Invocation, Args,
- Args + array_lengthof(Args),
Compiler.getDiagnostics());
Compiler.setInvocation(std::move(Invocation));
More information about the cfe-commits
mailing list