r240349 - Update for LLVM API change to return by InputArgList directly (rather than by pointer) from ParseArgs
David Blaikie
dblaikie at gmail.com
Mon Jun 22 15:07:28 PDT 2015
Author: dblaikie
Date: Mon Jun 22 17:07:27 2015
New Revision: 240349
URL: http://llvm.org/viewvc/llvm-project?rev=240349&view=rev
Log:
Update for LLVM API change to return by InputArgList directly (rather than by pointer) from ParseArgs
Modified:
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/tools/driver/cc1as_main.cpp
cfe/trunk/tools/driver/driver.cpp
Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=240349&r1=240348&r2=240349&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Mon Jun 22 17:07:27 2015
@@ -262,7 +262,7 @@ public:
/// ParseArgStrings - Parse the given list of strings into an
/// ArgList.
- llvm::opt::InputArgList *ParseArgStrings(ArrayRef<const char *> Args);
+ llvm::opt::InputArgList ParseArgStrings(ArrayRef<const char *> Args);
/// BuildInputs - Construct the list of inputs and their types from
/// the given arguments.
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=240349&r1=240348&r2=240349&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Jun 22 17:07:27 2015
@@ -106,7 +106,7 @@ void Driver::ParseDriverMode(ArrayRef<co
}
}
-InputArgList *Driver::ParseArgStrings(ArrayRef<const char *> ArgStrings) {
+InputArgList Driver::ParseArgStrings(ArrayRef<const char *> ArgStrings) {
llvm::PrettyStackTraceString CrashInfo("Command line argument parsing");
unsigned IncludedFlagsBitmask;
@@ -115,32 +115,31 @@ InputArgList *Driver::ParseArgStrings(Ar
getIncludeExcludeOptionFlagMasks();
unsigned MissingArgIndex, MissingArgCount;
- InputArgList *Args =
+ InputArgList Args =
getOpts().ParseArgs(ArgStrings, MissingArgIndex, MissingArgCount,
IncludedFlagsBitmask, ExcludedFlagsBitmask);
// Check for missing argument error.
if (MissingArgCount)
Diag(clang::diag::err_drv_missing_argument)
- << Args->getArgString(MissingArgIndex) << MissingArgCount;
+ << Args.getArgString(MissingArgIndex) << MissingArgCount;
// Check for unsupported options.
- for (const Arg *A : *Args) {
+ for (const Arg *A : Args) {
if (A->getOption().hasFlag(options::Unsupported)) {
- Diag(clang::diag::err_drv_unsupported_opt) << A->getAsString(*Args);
+ Diag(clang::diag::err_drv_unsupported_opt) << A->getAsString(Args);
continue;
}
// Warn about -mcpu= without an argument.
if (A->getOption().matches(options::OPT_mcpu_EQ) &&
A->containsValue("")) {
- Diag(clang::diag::warn_drv_empty_joined_argument) <<
- A->getAsString(*Args);
+ Diag(clang::diag::warn_drv_empty_joined_argument) << A->getAsString(Args);
}
}
- for (const Arg *A : Args->filtered(options::OPT_UNKNOWN))
- Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(*Args);
+ for (const Arg *A : Args.filtered(options::OPT_UNKNOWN))
+ Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(Args);
return Args;
}
@@ -312,13 +311,13 @@ Compilation *Driver::BuildCompilation(Ar
// FIXME: This stuff needs to go into the Compilation, not the driver.
bool CCCPrintActions;
- InputArgList *Args = ParseArgStrings(ArgList.slice(1));
+ InputArgList Args = ParseArgStrings(ArgList.slice(1));
// -no-canonical-prefixes is used very early in main.
- Args->ClaimAllArgs(options::OPT_no_canonical_prefixes);
+ Args.ClaimAllArgs(options::OPT_no_canonical_prefixes);
// Ignore -pipe.
- Args->ClaimAllArgs(options::OPT_pipe);
+ Args.ClaimAllArgs(options::OPT_pipe);
// Extract -ccc args.
//
@@ -326,12 +325,12 @@ Compilation *Driver::BuildCompilation(Ar
// should be outside in the client; the parts that aren't should have proper
// options, either by introducing new ones or by overloading gcc ones like -V
// or -b.
- CCCPrintActions = Args->hasArg(options::OPT_ccc_print_phases);
- CCCPrintBindings = Args->hasArg(options::OPT_ccc_print_bindings);
- if (const Arg *A = Args->getLastArg(options::OPT_ccc_gcc_name))
+ CCCPrintActions = Args.hasArg(options::OPT_ccc_print_phases);
+ CCCPrintBindings = Args.hasArg(options::OPT_ccc_print_bindings);
+ if (const Arg *A = Args.getLastArg(options::OPT_ccc_gcc_name))
CCCGenericGCCName = A->getValue();
- CCCUsePCH = Args->hasFlag(options::OPT_ccc_pch_is_pch,
- options::OPT_ccc_pch_is_pth);
+ CCCUsePCH =
+ Args.hasFlag(options::OPT_ccc_pch_is_pch, options::OPT_ccc_pch_is_pth);
// FIXME: DefaultTargetTriple is used by the target-prefixed calls to as/ld
// and getToolChain is const.
if (IsCLMode()) {
@@ -341,39 +340,42 @@ Compilation *Driver::BuildCompilation(Ar
T.setEnvironment(llvm::Triple::MSVC);
DefaultTargetTriple = T.str();
}
- if (const Arg *A = Args->getLastArg(options::OPT_target))
+ if (const Arg *A = Args.getLastArg(options::OPT_target))
DefaultTargetTriple = A->getValue();
- if (const Arg *A = Args->getLastArg(options::OPT_ccc_install_dir))
+ if (const Arg *A = Args.getLastArg(options::OPT_ccc_install_dir))
Dir = InstalledDir = A->getValue();
- for (const Arg *A : Args->filtered(options::OPT_B)) {
+ for (const Arg *A : Args.filtered(options::OPT_B)) {
A->claim();
PrefixDirs.push_back(A->getValue(0));
}
- if (const Arg *A = Args->getLastArg(options::OPT__sysroot_EQ))
+ if (const Arg *A = Args.getLastArg(options::OPT__sysroot_EQ))
SysRoot = A->getValue();
- if (const Arg *A = Args->getLastArg(options::OPT__dyld_prefix_EQ))
+ if (const Arg *A = Args.getLastArg(options::OPT__dyld_prefix_EQ))
DyldPrefix = A->getValue();
- if (Args->hasArg(options::OPT_nostdlib))
+ if (Args.hasArg(options::OPT_nostdlib))
UseStdLib = false;
- if (const Arg *A = Args->getLastArg(options::OPT_resource_dir))
+ if (const Arg *A = Args.getLastArg(options::OPT_resource_dir))
ResourceDir = A->getValue();
- if (const Arg *A = Args->getLastArg(options::OPT_save_temps_EQ)) {
+ if (const Arg *A = Args.getLastArg(options::OPT_save_temps_EQ)) {
SaveTemps = llvm::StringSwitch<SaveTempsMode>(A->getValue())
.Case("cwd", SaveTempsCwd)
.Case("obj", SaveTempsObj)
.Default(SaveTempsCwd);
}
+ std::unique_ptr<llvm::opt::InputArgList> UArgs =
+ llvm::make_unique<InputArgList>(std::move(Args));
+
// Perform the default argument translations.
- DerivedArgList *TranslatedArgs = TranslateInputArgs(*Args);
+ DerivedArgList *TranslatedArgs = TranslateInputArgs(*UArgs);
// Owned by the host.
- const ToolChain &TC = getToolChain(*Args);
+ const ToolChain &TC = getToolChain(*UArgs);
// The compilation takes ownership of Args.
- Compilation *C = new Compilation(*this, TC, Args, TranslatedArgs);
+ Compilation *C = new Compilation(*this, TC, UArgs.release(), TranslatedArgs);
if (!HandleImmediateArgs(*C))
return C;
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=240349&r1=240348&r2=240349&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Jun 22 17:07:27 2015
@@ -1849,37 +1849,37 @@ bool CompilerInvocation::CreateFromArgs(
std::unique_ptr<OptTable> Opts(createDriverOptTable());
const unsigned IncludedFlagsBitmask = options::CC1Option;
unsigned MissingArgIndex, MissingArgCount;
- std::unique_ptr<InputArgList> Args(
+ InputArgList Args =
Opts->ParseArgs(llvm::makeArrayRef(ArgBegin, ArgEnd), MissingArgIndex,
- MissingArgCount, IncludedFlagsBitmask));
+ MissingArgCount, IncludedFlagsBitmask);
// Check for missing argument error.
if (MissingArgCount) {
Diags.Report(diag::err_drv_missing_argument)
- << Args->getArgString(MissingArgIndex) << MissingArgCount;
+ << Args.getArgString(MissingArgIndex) << MissingArgCount;
Success = false;
}
// Issue errors on unknown arguments.
- for (const Arg *A : Args->filtered(OPT_UNKNOWN)) {
- Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(*Args);
+ for (const Arg *A : Args.filtered(OPT_UNKNOWN)) {
+ Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(Args);
Success = false;
}
- Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), *Args, Diags);
- Success &= ParseMigratorArgs(Res.getMigratorOpts(), *Args);
- ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), *Args);
- Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), *Args, &Diags);
- ParseCommentArgs(Res.getLangOpts()->CommentOpts, *Args);
- ParseFileSystemArgs(Res.getFileSystemOpts(), *Args);
+ Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags);
+ Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
+ ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
+ Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags);
+ ParseCommentArgs(Res.getLangOpts()->CommentOpts, Args);
+ ParseFileSystemArgs(Res.getFileSystemOpts(), Args);
// FIXME: We shouldn't have to pass the DashX option around here
- InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), *Args, Diags);
- ParseTargetArgs(Res.getTargetOpts(), *Args);
- Success &= ParseCodeGenArgs(Res.getCodeGenOpts(), *Args, DashX, Diags,
+ InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags);
+ ParseTargetArgs(Res.getTargetOpts(), Args);
+ Success &= ParseCodeGenArgs(Res.getCodeGenOpts(), Args, DashX, Diags,
Res.getTargetOpts());
- ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), *Args);
+ ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args);
if (DashX != IK_AST && DashX != IK_LLVM_IR) {
- ParseLangArgs(*Res.getLangOpts(), *Args, DashX, Diags);
+ ParseLangArgs(*Res.getLangOpts(), Args, DashX, Diags);
if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
Res.getLangOpts()->ObjCExceptions = 1;
}
@@ -1888,8 +1888,8 @@ bool CompilerInvocation::CreateFromArgs(
// ParsePreprocessorArgs and remove the FileManager
// parameters from the function and the "FileManager.h" #include.
FileManager FileMgr(Res.getFileSystemOpts());
- ParsePreprocessorArgs(Res.getPreprocessorOpts(), *Args, FileMgr, Diags);
- ParsePreprocessorOutputArgs(Res.getPreprocessorOutputOpts(), *Args,
+ ParsePreprocessorArgs(Res.getPreprocessorOpts(), Args, FileMgr, Diags);
+ ParsePreprocessorOutputArgs(Res.getPreprocessorOutputOpts(), Args,
Res.getFrontendOpts().ProgramAction);
return Success;
}
Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=240349&r1=240348&r2=240349&view=diff
==============================================================================
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Mon Jun 22 17:07:27 2015
@@ -161,67 +161,68 @@ bool AssemblerInvocation::CreateFromArgs
const unsigned IncludedFlagsBitmask = options::CC1AsOption;
unsigned MissingArgIndex, MissingArgCount;
- std::unique_ptr<InputArgList> Args(OptTbl->ParseArgs(
- Argv, MissingArgIndex, MissingArgCount, IncludedFlagsBitmask));
+ InputArgList Args = OptTbl->ParseArgs(Argv, MissingArgIndex, MissingArgCount,
+ IncludedFlagsBitmask);
// Check for missing argument error.
if (MissingArgCount) {
Diags.Report(diag::err_drv_missing_argument)
- << Args->getArgString(MissingArgIndex) << MissingArgCount;
+ << Args.getArgString(MissingArgIndex) << MissingArgCount;
Success = false;
}
// Issue errors on unknown arguments.
- for (const Arg *A : Args->filtered(OPT_UNKNOWN)) {
- Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(*Args);
+ for (const Arg *A : Args.filtered(OPT_UNKNOWN)) {
+ Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(Args);
Success = false;
}
// Construct the invocation.
// Target Options
- Opts.Triple = llvm::Triple::normalize(Args->getLastArgValue(OPT_triple));
- Opts.CPU = Args->getLastArgValue(OPT_target_cpu);
- Opts.Features = Args->getAllArgValues(OPT_target_feature);
+ Opts.Triple = llvm::Triple::normalize(Args.getLastArgValue(OPT_triple));
+ Opts.CPU = Args.getLastArgValue(OPT_target_cpu);
+ Opts.Features = Args.getAllArgValues(OPT_target_feature);
// Use the default target triple if unspecified.
if (Opts.Triple.empty())
Opts.Triple = llvm::sys::getDefaultTargetTriple();
// Language Options
- Opts.IncludePaths = Args->getAllArgValues(OPT_I);
- Opts.NoInitialTextSection = Args->hasArg(OPT_n);
- Opts.SaveTemporaryLabels = Args->hasArg(OPT_msave_temp_labels);
- Opts.GenDwarfForAssembly = Args->hasArg(OPT_g_Flag);
- Opts.CompressDebugSections = Args->hasArg(OPT_compress_debug_sections);
- if (Args->hasArg(OPT_gdwarf_2))
+ Opts.IncludePaths = Args.getAllArgValues(OPT_I);
+ Opts.NoInitialTextSection = Args.hasArg(OPT_n);
+ Opts.SaveTemporaryLabels = Args.hasArg(OPT_msave_temp_labels);
+ Opts.GenDwarfForAssembly = Args.hasArg(OPT_g_Flag);
+ Opts.CompressDebugSections = Args.hasArg(OPT_compress_debug_sections);
+ if (Args.hasArg(OPT_gdwarf_2))
Opts.DwarfVersion = 2;
- if (Args->hasArg(OPT_gdwarf_3))
+ if (Args.hasArg(OPT_gdwarf_3))
Opts.DwarfVersion = 3;
- if (Args->hasArg(OPT_gdwarf_4))
+ if (Args.hasArg(OPT_gdwarf_4))
Opts.DwarfVersion = 4;
- Opts.DwarfDebugFlags = Args->getLastArgValue(OPT_dwarf_debug_flags);
- Opts.DwarfDebugProducer = Args->getLastArgValue(OPT_dwarf_debug_producer);
- Opts.DebugCompilationDir = Args->getLastArgValue(OPT_fdebug_compilation_dir);
- Opts.MainFileName = Args->getLastArgValue(OPT_main_file_name);
+ Opts.DwarfDebugFlags = Args.getLastArgValue(OPT_dwarf_debug_flags);
+ Opts.DwarfDebugProducer = Args.getLastArgValue(OPT_dwarf_debug_producer);
+ Opts.DebugCompilationDir = Args.getLastArgValue(OPT_fdebug_compilation_dir);
+ Opts.MainFileName = Args.getLastArgValue(OPT_main_file_name);
// Frontend Options
- if (Args->hasArg(OPT_INPUT)) {
+ if (Args.hasArg(OPT_INPUT)) {
bool First = true;
- for (arg_iterator it = Args->filtered_begin(OPT_INPUT),
- ie = Args->filtered_end(); it != ie; ++it, First=false) {
+ for (arg_iterator it = Args.filtered_begin(OPT_INPUT),
+ ie = Args.filtered_end();
+ it != ie; ++it, First = false) {
const Arg *A = it;
if (First)
Opts.InputFile = A->getValue();
else {
- Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(*Args);
+ Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(Args);
Success = false;
}
}
}
- Opts.LLVMArgs = Args->getAllArgValues(OPT_mllvm);
- Opts.OutputPath = Args->getLastArgValue(OPT_o);
- if (Arg *A = Args->getLastArg(OPT_filetype)) {
+ Opts.LLVMArgs = Args.getAllArgValues(OPT_mllvm);
+ Opts.OutputPath = Args.getLastArgValue(OPT_o);
+ if (Arg *A = Args.getLastArg(OPT_filetype)) {
StringRef Name = A->getValue();
unsigned OutputType = StringSwitch<unsigned>(Name)
.Case("asm", FT_Asm)
@@ -229,25 +230,24 @@ bool AssemblerInvocation::CreateFromArgs
.Case("obj", FT_Obj)
.Default(~0U);
if (OutputType == ~0U) {
- Diags.Report(diag::err_drv_invalid_value)
- << A->getAsString(*Args) << Name;
+ Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
Success = false;
} else
Opts.OutputType = FileType(OutputType);
}
- Opts.ShowHelp = Args->hasArg(OPT_help);
- Opts.ShowVersion = Args->hasArg(OPT_version);
+ Opts.ShowHelp = Args.hasArg(OPT_help);
+ Opts.ShowVersion = Args.hasArg(OPT_version);
// Transliterate Options
Opts.OutputAsmVariant =
- getLastArgIntValue(*Args.get(), OPT_output_asm_variant, 0, Diags);
- Opts.ShowEncoding = Args->hasArg(OPT_show_encoding);
- Opts.ShowInst = Args->hasArg(OPT_show_inst);
+ getLastArgIntValue(Args, OPT_output_asm_variant, 0, Diags);
+ Opts.ShowEncoding = Args.hasArg(OPT_show_encoding);
+ Opts.ShowInst = Args.hasArg(OPT_show_inst);
// Assemble Options
- Opts.RelaxAll = Args->hasArg(OPT_mrelax_all);
- Opts.NoExecStack = Args->hasArg(OPT_mno_exec_stack);
- Opts.FatalWarnings = Args->hasArg(OPT_massembler_fatal_warnings);
+ Opts.RelaxAll = Args.hasArg(OPT_mrelax_all);
+ Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
+ Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
return Success;
}
Modified: cfe/trunk/tools/driver/driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=240349&r1=240348&r2=240349&view=diff
==============================================================================
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Mon Jun 22 17:07:27 2015
@@ -325,12 +325,12 @@ CreateAndPopulateDiagOpts(ArrayRef<const
auto *DiagOpts = new DiagnosticOptions;
std::unique_ptr<OptTable> Opts(createDriverOptTable());
unsigned MissingArgIndex, MissingArgCount;
- std::unique_ptr<InputArgList> Args(
- Opts->ParseArgs(argv.slice(1), MissingArgIndex, MissingArgCount));
+ InputArgList Args =
+ Opts->ParseArgs(argv.slice(1), MissingArgIndex, MissingArgCount);
// We ignore MissingArgCount and the return value of ParseDiagnosticArgs.
// Any errors that would be diagnosed here will also be diagnosed later,
// when the DiagnosticsEngine actually exists.
- (void) ParseDiagnosticArgs(*DiagOpts, *Args);
+ (void)ParseDiagnosticArgs(*DiagOpts, Args);
return DiagOpts;
}
More information about the cfe-commits
mailing list