Index: cfe/trunk/include/clang/Frontend/CompilerInvocation.h =================================================================== --- cfe/trunk/include/clang/Frontend/CompilerInvocation.h +++ cfe/trunk/include/clang/Frontend/CompilerInvocation.h @@ -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 #include @@ -153,12 +154,8 @@ /// 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 CommandLineArgs, DiagnosticsEngine &Diags); /// Get the directory where the compiler headers Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp =================================================================== --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp @@ -3370,8 +3370,7 @@ } bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, - const char *const *ArgBegin, - const char *const *ArgEnd, + ArrayRef CommandLineArgs, DiagnosticsEngine &Diags) { bool Success = true; @@ -3379,9 +3378,8 @@ std::unique_ptr 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. Index: cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp =================================================================== --- cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp +++ cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp @@ -90,9 +90,7 @@ const ArgStringList &CCArgs = Cmd.getArguments(); auto CI = std::make_unique(); - if (!CompilerInvocation::CreateFromArgs( - *CI, const_cast(CCArgs.data()), - const_cast(CCArgs.data()) + CCArgs.size(), *Diags) && + if (!CompilerInvocation::CreateFromArgs(*CI, CCArgs, *Diags) && !ShouldRecoverOnErorrs) return nullptr; return CI; Index: cfe/trunk/lib/Tooling/Tooling.cpp =================================================================== --- cfe/trunk/lib/Tooling/Tooling.cpp +++ cfe/trunk/lib/Tooling/Tooling.cpp @@ -118,9 +118,7 @@ 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; Index: cfe/trunk/tools/arcmt-test/arcmt-test.cpp =================================================================== --- cfe/trunk/tools/arcmt-test/arcmt-test.cpp +++ cfe/trunk/tools/arcmt-test/arcmt-test.cpp @@ -121,7 +121,7 @@ } 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 @@ 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()) { Index: cfe/trunk/tools/clang-import-test/clang-import-test.cpp =================================================================== --- cfe/trunk/tools/clang-import-test/clang-import-test.cpp +++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp @@ -168,9 +168,7 @@ std::vector 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; Index: cfe/trunk/tools/driver/cc1_main.cpp =================================================================== --- cfe/trunk/tools/driver/cc1_main.cpp +++ cfe/trunk/tools/driver/cc1_main.cpp @@ -213,8 +213,8 @@ IntrusiveRefCntPtr 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( Index: cfe/trunk/unittests/AST/ExternalASTSourceTest.cpp =================================================================== --- cfe/trunk/unittests/AST/ExternalASTSourceTest.cpp +++ cfe/trunk/unittests/AST/ExternalASTSourceTest.cpp @@ -53,7 +53,6 @@ "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));