range-for'ify Args->filtered_begin(...) loops

We already have Args->filtered(...) which is a drop-in range-for
replacement.

llvm-svn: 239381
This commit is contained in:
Sean Silva
2015-06-09 01:57:17 +00:00
parent e34147ce2f
commit 14facf307c
5 changed files with 103 additions and 182 deletions

View File

@@ -140,10 +140,8 @@ InputArgList *Driver::ParseArgStrings(ArrayRef<const char *> ArgStrings) {
} }
} }
for (arg_iterator it = Args->filtered_begin(options::OPT_UNKNOWN), for (const Arg *A : Args->filtered(options::OPT_UNKNOWN))
ie = Args->filtered_end(); it != ie; ++it) { Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(*Args);
Diags.Report(diag::err_drv_unknown_argument) << (*it) ->getAsString(*Args);
}
return Args; return Args;
} }
@@ -347,9 +345,7 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
DefaultTargetTriple = A->getValue(); 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(); Dir = InstalledDir = A->getValue();
for (arg_iterator it = Args->filtered_begin(options::OPT_B), for (const Arg *A : Args->filtered(options::OPT_B)) {
ie = Args->filtered_end(); it != ie; ++it) {
const Arg *A = *it;
A->claim(); A->claim();
PrefixDirs.push_back(A->getValue(0)); PrefixDirs.push_back(A->getValue(0));
} }
@@ -1467,9 +1463,8 @@ void Driver::BuildJobs(Compilation &C) const {
if (Opt.getKind() == Option::FlagClass) { if (Opt.getKind() == Option::FlagClass) {
bool DuplicateClaimed = false; bool DuplicateClaimed = false;
for (arg_iterator it = C.getArgs().filtered_begin(&Opt), for (const Arg *AA : C.getArgs().filtered(&Opt)) {
ie = C.getArgs().filtered_end(); it != ie; ++it) { if (AA->isClaimed()) {
if ((*it)->isClaimed()) {
DuplicateClaimed = true; DuplicateClaimed = true;
break; break;
} }

View File

@@ -2174,14 +2174,9 @@ static void GetHexagonLibraryPaths(
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// -L Args // -L Args
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
for (arg_iterator for (const Arg *A : Args.filtered(options::OPT_L))
it = Args.filtered_begin(options::OPT_L), for (unsigned i = 0, e = A->getNumValues(); i != e; ++i)
ie = Args.filtered_end(); LibPaths->push_back(A->getValue(i));
it != ie;
++it) {
for (unsigned i = 0, e = (*it)->getNumValues(); i != e; ++i)
LibPaths->push_back((*it)->getValue(i));
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Other standard paths // Other standard paths

View File

@@ -342,10 +342,7 @@ void Clang::AddPreprocessingOptions(Compilation &C,
Args.AddLastArg(CmdArgs, options::OPT_MV); Args.AddLastArg(CmdArgs, options::OPT_MV);
// Convert all -MQ <target> args to -MT <quoted target> // Convert all -MQ <target> args to -MT <quoted target>
for (arg_iterator it = Args.filtered_begin(options::OPT_MT, for (const Arg *A : Args.filtered(options::OPT_MT, options::OPT_MQ)) {
options::OPT_MQ),
ie = Args.filtered_end(); it != ie; ++it) {
const Arg *A = *it;
A->claim(); A->claim();
if (A->getOption().matches(options::OPT_MQ)) { if (A->getOption().matches(options::OPT_MQ)) {
@@ -366,10 +363,7 @@ void Clang::AddPreprocessingOptions(Compilation &C,
// replacement into a build system already set up to be generating // replacement into a build system already set up to be generating
// .gch files. // .gch files.
bool RenderedImplicitInclude = false; bool RenderedImplicitInclude = false;
for (arg_iterator it = Args.filtered_begin(options::OPT_clang_i_Group), for (const Arg *A : Args.filtered(options::OPT_clang_i_Group)) {
ie = Args.filtered_end(); it != ie; ++it) {
const Arg *A = it;
if (A->getOption().matches(options::OPT_include)) { if (A->getOption().matches(options::OPT_include)) {
bool IsFirstImplicitInclude = !RenderedImplicitInclude; bool IsFirstImplicitInclude = !RenderedImplicitInclude;
RenderedImplicitInclude = true; RenderedImplicitInclude = true;
@@ -1254,11 +1248,9 @@ static std::string getPPCTargetCPU(const ArgList &Args) {
static void getPPCTargetFeatures(const ArgList &Args, static void getPPCTargetFeatures(const ArgList &Args,
std::vector<const char *> &Features) { std::vector<const char *> &Features) {
for (arg_iterator it = Args.filtered_begin(options::OPT_m_ppc_Features_Group), for (const Arg *A : Args.filtered(options::OPT_m_ppc_Features_Group)) {
ie = Args.filtered_end(); StringRef Name = A->getOption().getName();
it != ie; ++it) { A->claim();
StringRef Name = (*it)->getOption().getName();
(*it)->claim();
// Skip over "-m". // Skip over "-m".
assert(Name.startswith("m") && "Invalid feature name."); assert(Name.startswith("m") && "Invalid feature name.");
@@ -1619,11 +1611,9 @@ static void getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
// Now add any that the user explicitly requested on the command line, // Now add any that the user explicitly requested on the command line,
// which may override the defaults. // which may override the defaults.
for (arg_iterator it = Args.filtered_begin(options::OPT_m_x86_Features_Group), for (const Arg *A : Args.filtered(options::OPT_m_x86_Features_Group)) {
ie = Args.filtered_end(); StringRef Name = A->getOption().getName();
it != ie; ++it) { A->claim();
StringRef Name = (*it)->getOption().getName();
(*it)->claim();
// Skip over "-m". // Skip over "-m".
assert(Name.startswith("m") && "Invalid feature name."); assert(Name.startswith("m") && "Invalid feature name.");
@@ -2086,10 +2076,8 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
// When using an integrated assembler, translate -Wa, and -Xassembler // When using an integrated assembler, translate -Wa, and -Xassembler
// options. // options.
bool CompressDebugSections = false; bool CompressDebugSections = false;
for (arg_iterator it = Args.filtered_begin(options::OPT_Wa_COMMA, for (const Arg *A :
options::OPT_Xassembler), Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {
ie = Args.filtered_end(); it != ie; ++it) {
const Arg *A = *it;
A->claim(); A->claim();
for (unsigned i = 0, e = A->getNumValues(); i != e; ++i) { for (unsigned i = 0, e = A->getNumValues(); i != e; ++i) {
@@ -2970,14 +2958,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.hasArg(options::OPT_frewrite_map_file) || if (Args.hasArg(options::OPT_frewrite_map_file) ||
Args.hasArg(options::OPT_frewrite_map_file_EQ)) { Args.hasArg(options::OPT_frewrite_map_file_EQ)) {
for (arg_iterator for (const Arg *A : Args.filtered(options::OPT_frewrite_map_file,
MFI = Args.filtered_begin(options::OPT_frewrite_map_file, options::OPT_frewrite_map_file_EQ)) {
options::OPT_frewrite_map_file_EQ),
MFE = Args.filtered_end();
MFI != MFE; ++MFI) {
CmdArgs.push_back("-frewrite-map-file"); CmdArgs.push_back("-frewrite-map-file");
CmdArgs.push_back((*MFI)->getValue()); CmdArgs.push_back(A->getValue());
(*MFI)->claim(); A->claim();
} }
} }
@@ -3605,10 +3590,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
} }
// Warn about ignored options to clang. // Warn about ignored options to clang.
for (arg_iterator it = Args.filtered_begin( for (const Arg *A :
options::OPT_clang_ignored_gcc_optimization_f_Group), Args.filtered(options::OPT_clang_ignored_gcc_optimization_f_Group)) {
ie = Args.filtered_end(); it != ie; ++it) { D.Diag(diag::warn_ignored_gcc_optimization) << A->getAsString(Args);
D.Diag(diag::warn_ignored_gcc_optimization) << (*it)->getAsString(Args);
} }
claimNoWarnArgs(Args); claimNoWarnArgs(Args);
@@ -3929,16 +3913,15 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
} }
// --param ssp-buffer-size= // --param ssp-buffer-size=
for (arg_iterator it = Args.filtered_begin(options::OPT__param), for (const Arg *A : Args.filtered(options::OPT__param)) {
ie = Args.filtered_end(); it != ie; ++it) { StringRef Str(A->getValue());
StringRef Str((*it)->getValue());
if (Str.startswith("ssp-buffer-size=")) { if (Str.startswith("ssp-buffer-size=")) {
if (StackProtectorLevel) { if (StackProtectorLevel) {
CmdArgs.push_back("-stack-protector-buffer-size"); CmdArgs.push_back("-stack-protector-buffer-size");
// FIXME: Verify the argument is a valid integer. // FIXME: Verify the argument is a valid integer.
CmdArgs.push_back(Args.MakeArgString(Str.drop_front(16))); CmdArgs.push_back(Args.MakeArgString(Str.drop_front(16)));
} }
(*it)->claim(); A->claim();
} }
} }
@@ -4678,17 +4661,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// parser. // parser.
Args.AddAllArgValues(CmdArgs, options::OPT_Xclang); Args.AddAllArgValues(CmdArgs, options::OPT_Xclang);
bool OptDisabled = false; bool OptDisabled = false;
for (arg_iterator it = Args.filtered_begin(options::OPT_mllvm), for (const Arg *A : Args.filtered(options::OPT_mllvm)) {
ie = Args.filtered_end(); it != ie; ++it) { A->claim();
(*it)->claim();
// We translate this by hand to the -cc1 argument, since nightly test uses // We translate this by hand to the -cc1 argument, since nightly test uses
// it and developers have been trained to spell it with -mllvm. // it and developers have been trained to spell it with -mllvm.
if (StringRef((*it)->getValue(0)) == "-disable-llvm-optzns") { if (StringRef(A->getValue(0)) == "-disable-llvm-optzns") {
CmdArgs.push_back("-disable-llvm-optzns"); CmdArgs.push_back("-disable-llvm-optzns");
OptDisabled = true; OptDisabled = true;
} else } else
(*it)->render(Args, CmdArgs); A->render(Args, CmdArgs);
} }
// With -save-temps, we want to save the unoptimized bitcode output from the // With -save-temps, we want to save the unoptimized bitcode output from the
@@ -5219,10 +5201,8 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
// doesn't handle that so rather than warning about unused flags that are // doesn't handle that so rather than warning about unused flags that are
// actually used, we'll lie by omission instead. // actually used, we'll lie by omission instead.
// FIXME: Stop lying and consume only the appropriate driver flags // FIXME: Stop lying and consume only the appropriate driver flags
for (arg_iterator it = Args.filtered_begin(options::OPT_W_Group), for (const Arg *A : Args.filtered(options::OPT_W_Group))
ie = Args.filtered_end(); A->claim();
it != ie; ++it)
(*it)->claim();
CollectArgsForIntegratedAssembler(C, Args, CmdArgs, CollectArgsForIntegratedAssembler(C, Args, CmdArgs,
getToolChain().getDriver()); getToolChain().getDriver());
@@ -5553,10 +5533,9 @@ static void constructHexagonLinkArgs(Compilation &C, const JobAction &JA,
std::vector<std::string> oslibs; std::vector<std::string> oslibs;
bool hasStandalone= false; bool hasStandalone= false;
for (arg_iterator it = Args.filtered_begin(options::OPT_moslib_EQ), for (const Arg *A : Args.filtered(options::OPT_moslib_EQ)) {
ie = Args.filtered_end(); it != ie; ++it) { A->claim();
(*it)->claim(); oslibs.emplace_back(A->getValue());
oslibs.emplace_back((*it)->getValue());
hasStandalone = hasStandalone || (oslibs.back() == "standalone"); hasStandalone = hasStandalone || (oslibs.back() == "standalone");
} }
if (oslibs.empty()) { if (oslibs.empty()) {
@@ -6359,10 +6338,8 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
Args.AddAllArgs(CmdArgs, options::OPT_F); Args.AddAllArgs(CmdArgs, options::OPT_F);
// -iframework should be forwarded as -F. // -iframework should be forwarded as -F.
for (auto it = Args.filtered_begin(options::OPT_iframework), for (const Arg *A : Args.filtered(options::OPT_iframework))
ie = Args.filtered_end(); it != ie; ++it) CmdArgs.push_back(Args.MakeArgString(std::string("-F") + A->getValue()));
CmdArgs.push_back(Args.MakeArgString(std::string("-F") +
(*it)->getValue()));
if (!Args.hasArg(options::OPT_nostdlib) && if (!Args.hasArg(options::OPT_nostdlib) &&
!Args.hasArg(options::OPT_nodefaultlibs)) { !Args.hasArg(options::OPT_nodefaultlibs)) {

View File

@@ -239,10 +239,8 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
Opts.InlineMaxStackDepth, Diags); Opts.InlineMaxStackDepth, Diags);
Opts.CheckersControlList.clear(); Opts.CheckersControlList.clear();
for (arg_iterator it = Args.filtered_begin(OPT_analyzer_checker, for (const Arg *A :
OPT_analyzer_disable_checker), Args.filtered(OPT_analyzer_checker, OPT_analyzer_disable_checker)) {
ie = Args.filtered_end(); it != ie; ++it) {
const Arg *A = *it;
A->claim(); A->claim();
bool enable = (A->getOption().getID() == OPT_analyzer_checker); bool enable = (A->getOption().getID() == OPT_analyzer_checker);
// We can have a list of comma separated checker names, e.g: // We can have a list of comma separated checker names, e.g:
@@ -255,9 +253,7 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
} }
// Go through the analyzer configuration options. // Go through the analyzer configuration options.
for (arg_iterator it = Args.filtered_begin(OPT_analyzer_config), for (const Arg *A : Args.filtered(OPT_analyzer_config)) {
ie = Args.filtered_end(); it != ie; ++it) {
const Arg *A = *it;
A->claim(); A->claim();
// We can have a list of comma separated config names, e.g: // We can have a list of comma separated config names, e.g:
// '-analyzer-config key1=val1,key2=val2' // '-analyzer-config key1=val1,key2=val2'
@@ -871,22 +867,17 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
Opts.ProgramAction = frontend::PluginAction; Opts.ProgramAction = frontend::PluginAction;
Opts.ActionName = A->getValue(); Opts.ActionName = A->getValue();
for (arg_iterator it = Args.filtered_begin(OPT_plugin_arg), for (const Arg *AA : Args.filtered(OPT_plugin_arg))
end = Args.filtered_end(); it != end; ++it) { if (AA->getValue(0) == Opts.ActionName)
if ((*it)->getValue(0) == Opts.ActionName) Opts.PluginArgs.emplace_back(AA->getValue(1));
Opts.PluginArgs.emplace_back((*it)->getValue(1));
}
} }
Opts.AddPluginActions = Args.getAllArgValues(OPT_add_plugin); Opts.AddPluginActions = Args.getAllArgValues(OPT_add_plugin);
Opts.AddPluginArgs.resize(Opts.AddPluginActions.size()); Opts.AddPluginArgs.resize(Opts.AddPluginActions.size());
for (int i = 0, e = Opts.AddPluginActions.size(); i != e; ++i) { for (int i = 0, e = Opts.AddPluginActions.size(); i != e; ++i)
for (arg_iterator it = Args.filtered_begin(OPT_plugin_arg), for (const Arg *A : Args.filtered(OPT_plugin_arg))
end = Args.filtered_end(); it != end; ++it) { if (A->getValue(0) == Opts.AddPluginActions[i])
if ((*it)->getValue(0) == Opts.AddPluginActions[i]) Opts.AddPluginArgs[i].emplace_back(A->getValue(1));
Opts.AddPluginArgs[i].emplace_back((*it)->getValue(1));
}
}
if (const Arg *A = Args.getLastArg(OPT_code_completion_at)) { if (const Arg *A = Args.getLastArg(OPT_code_completion_at)) {
Opts.CodeCompletionAt = Opts.CodeCompletionAt =
@@ -1088,98 +1079,77 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) {
Opts.ModulesValidateSystemHeaders = Opts.ModulesValidateSystemHeaders =
Args.hasArg(OPT_fmodules_validate_system_headers); Args.hasArg(OPT_fmodules_validate_system_headers);
for (arg_iterator it = Args.filtered_begin(OPT_fmodules_ignore_macro), for (const Arg *A : Args.filtered(OPT_fmodules_ignore_macro)) {
ie = Args.filtered_end(); StringRef MacroDef = A->getValue();
it != ie; ++it) {
StringRef MacroDef = (*it)->getValue();
Opts.ModulesIgnoreMacros.insert(MacroDef.split('=').first); Opts.ModulesIgnoreMacros.insert(MacroDef.split('=').first);
} }
// Add -I..., -F..., and -index-header-map options in order. // Add -I..., -F..., and -index-header-map options in order.
bool IsIndexHeaderMap = false; bool IsIndexHeaderMap = false;
for (arg_iterator it = Args.filtered_begin(OPT_I, OPT_F, for (const Arg *A : Args.filtered(OPT_I, OPT_F, OPT_index_header_map)) {
OPT_index_header_map), if (A->getOption().matches(OPT_index_header_map)) {
ie = Args.filtered_end(); it != ie; ++it) {
if ((*it)->getOption().matches(OPT_index_header_map)) {
// -index-header-map applies to the next -I or -F. // -index-header-map applies to the next -I or -F.
IsIndexHeaderMap = true; IsIndexHeaderMap = true;
continue; continue;
} }
frontend::IncludeDirGroup Group frontend::IncludeDirGroup Group =
= IsIndexHeaderMap? frontend::IndexHeaderMap : frontend::Angled; IsIndexHeaderMap ? frontend::IndexHeaderMap : frontend::Angled;
Opts.AddPath((*it)->getValue(), Group, Opts.AddPath(A->getValue(), Group,
/*IsFramework=*/ (*it)->getOption().matches(OPT_F), true); /*IsFramework=*/A->getOption().matches(OPT_F), true);
IsIndexHeaderMap = false; IsIndexHeaderMap = false;
} }
// Add -iprefix/-iwithprefix/-iwithprefixbefore options. // Add -iprefix/-iwithprefix/-iwithprefixbefore options.
StringRef Prefix = ""; // FIXME: This isn't the correct default prefix. StringRef Prefix = ""; // FIXME: This isn't the correct default prefix.
for (arg_iterator it = Args.filtered_begin(OPT_iprefix, OPT_iwithprefix, for (const Arg *A :
OPT_iwithprefixbefore), Args.filtered(OPT_iprefix, OPT_iwithprefix, OPT_iwithprefixbefore)) {
ie = Args.filtered_end(); it != ie; ++it) {
const Arg *A = *it;
if (A->getOption().matches(OPT_iprefix)) if (A->getOption().matches(OPT_iprefix))
Prefix = A->getValue(); Prefix = A->getValue();
else if (A->getOption().matches(OPT_iwithprefix)) else if (A->getOption().matches(OPT_iwithprefix))
Opts.AddPath(Prefix.str() + A->getValue(), Opts.AddPath(Prefix.str() + A->getValue(), frontend::After, false, true);
frontend::After, false, true);
else else
Opts.AddPath(Prefix.str() + A->getValue(), Opts.AddPath(Prefix.str() + A->getValue(), frontend::Angled, false, true);
frontend::Angled, false, true);
} }
for (arg_iterator it = Args.filtered_begin(OPT_idirafter), for (const Arg *A : Args.filtered(OPT_idirafter))
ie = Args.filtered_end(); it != ie; ++it) Opts.AddPath(A->getValue(), frontend::After, false, true);
Opts.AddPath((*it)->getValue(), frontend::After, false, true); for (const Arg *A : Args.filtered(OPT_iquote))
for (arg_iterator it = Args.filtered_begin(OPT_iquote), Opts.AddPath(A->getValue(), frontend::Quoted, false, true);
ie = Args.filtered_end(); it != ie; ++it) for (const Arg *A : Args.filtered(OPT_isystem, OPT_iwithsysroot))
Opts.AddPath((*it)->getValue(), frontend::Quoted, false, true); Opts.AddPath(A->getValue(), frontend::System, false,
for (arg_iterator it = Args.filtered_begin(OPT_isystem, !A->getOption().matches(OPT_iwithsysroot));
OPT_iwithsysroot), ie = Args.filtered_end(); it != ie; ++it) for (const Arg *A : Args.filtered(OPT_iframework))
Opts.AddPath((*it)->getValue(), frontend::System, false, Opts.AddPath(A->getValue(), frontend::System, true, true);
!(*it)->getOption().matches(OPT_iwithsysroot));
for (arg_iterator it = Args.filtered_begin(OPT_iframework),
ie = Args.filtered_end(); it != ie; ++it)
Opts.AddPath((*it)->getValue(), frontend::System, true, true);
// Add the paths for the various language specific isystem flags. // Add the paths for the various language specific isystem flags.
for (arg_iterator it = Args.filtered_begin(OPT_c_isystem), for (const Arg *A : Args.filtered(OPT_c_isystem))
ie = Args.filtered_end(); it != ie; ++it) Opts.AddPath(A->getValue(), frontend::CSystem, false, true);
Opts.AddPath((*it)->getValue(), frontend::CSystem, false, true); for (const Arg *A : Args.filtered(OPT_cxx_isystem))
for (arg_iterator it = Args.filtered_begin(OPT_cxx_isystem), Opts.AddPath(A->getValue(), frontend::CXXSystem, false, true);
ie = Args.filtered_end(); it != ie; ++it) for (const Arg *A : Args.filtered(OPT_objc_isystem))
Opts.AddPath((*it)->getValue(), frontend::CXXSystem, false, true); Opts.AddPath(A->getValue(), frontend::ObjCSystem, false,true);
for (arg_iterator it = Args.filtered_begin(OPT_objc_isystem), for (const Arg *A : Args.filtered(OPT_objcxx_isystem))
ie = Args.filtered_end(); it != ie; ++it) Opts.AddPath(A->getValue(), frontend::ObjCXXSystem, false, true);
Opts.AddPath((*it)->getValue(), frontend::ObjCSystem, false,true);
for (arg_iterator it = Args.filtered_begin(OPT_objcxx_isystem),
ie = Args.filtered_end(); it != ie; ++it)
Opts.AddPath((*it)->getValue(), frontend::ObjCXXSystem, false, true);
// Add the internal paths from a driver that detects standard include paths. // Add the internal paths from a driver that detects standard include paths.
for (arg_iterator I = Args.filtered_begin(OPT_internal_isystem, for (const Arg *A :
OPT_internal_externc_isystem), Args.filtered(OPT_internal_isystem, OPT_internal_externc_isystem)) {
E = Args.filtered_end();
I != E; ++I) {
frontend::IncludeDirGroup Group = frontend::System; frontend::IncludeDirGroup Group = frontend::System;
if ((*I)->getOption().matches(OPT_internal_externc_isystem)) if (A->getOption().matches(OPT_internal_externc_isystem))
Group = frontend::ExternCSystem; Group = frontend::ExternCSystem;
Opts.AddPath((*I)->getValue(), Group, false, true); Opts.AddPath(A->getValue(), Group, false, true);
} }
// Add the path prefixes which are implicitly treated as being system headers. // Add the path prefixes which are implicitly treated as being system headers.
for (arg_iterator I = Args.filtered_begin(OPT_system_header_prefix, for (const Arg *A :
OPT_no_system_header_prefix), Args.filtered(OPT_system_header_prefix, OPT_no_system_header_prefix))
E = Args.filtered_end();
I != E; ++I)
Opts.AddSystemHeaderPrefix( Opts.AddSystemHeaderPrefix(
(*I)->getValue(), (*I)->getOption().matches(OPT_system_header_prefix)); A->getValue(), A->getOption().matches(OPT_system_header_prefix));
for (arg_iterator I = Args.filtered_begin(OPT_ivfsoverlay), for (const Arg *A : Args.filtered(OPT_ivfsoverlay))
E = Args.filtered_end(); I != E; ++I) Opts.AddVFSOverlayFile(A->getValue());
Opts.AddVFSOverlayFile((*I)->getValue());
} }
void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
@@ -1708,11 +1678,8 @@ static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
Opts.DisablePCHValidation = Args.hasArg(OPT_fno_validate_pch); Opts.DisablePCHValidation = Args.hasArg(OPT_fno_validate_pch);
Opts.DumpDeserializedPCHDecls = Args.hasArg(OPT_dump_deserialized_pch_decls); Opts.DumpDeserializedPCHDecls = Args.hasArg(OPT_dump_deserialized_pch_decls);
for (arg_iterator it = Args.filtered_begin(OPT_error_on_deserialized_pch_decl), for (const Arg *A : Args.filtered(OPT_error_on_deserialized_pch_decl))
ie = Args.filtered_end(); it != ie; ++it) {
const Arg *A = *it;
Opts.DeserializedPCHDeclsToErrorOn.insert(A->getValue()); Opts.DeserializedPCHDeclsToErrorOn.insert(A->getValue());
}
if (const Arg *A = Args.getLastArg(OPT_preamble_bytes_EQ)) { if (const Arg *A = Args.getLastArg(OPT_preamble_bytes_EQ)) {
StringRef Value(A->getValue()); StringRef Value(A->getValue());
@@ -1731,38 +1698,28 @@ static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
} }
// Add macros from the command line. // Add macros from the command line.
for (arg_iterator it = Args.filtered_begin(OPT_D, OPT_U), for (const Arg *A : Args.filtered(OPT_D, OPT_U)) {
ie = Args.filtered_end(); it != ie; ++it) { if (A->getOption().matches(OPT_D))
if ((*it)->getOption().matches(OPT_D)) Opts.addMacroDef(A->getValue());
Opts.addMacroDef((*it)->getValue());
else else
Opts.addMacroUndef((*it)->getValue()); Opts.addMacroUndef(A->getValue());
} }
Opts.MacroIncludes = Args.getAllArgValues(OPT_imacros); Opts.MacroIncludes = Args.getAllArgValues(OPT_imacros);
// Add the ordered list of -includes. // Add the ordered list of -includes.
for (arg_iterator it = Args.filtered_begin(OPT_include), for (const Arg *A : Args.filtered(OPT_include))
ie = Args.filtered_end(); it != ie; ++it) {
const Arg *A = *it;
Opts.Includes.emplace_back(A->getValue()); Opts.Includes.emplace_back(A->getValue());
}
for (arg_iterator it = Args.filtered_begin(OPT_chain_include), for (const Arg *A : Args.filtered(OPT_chain_include))
ie = Args.filtered_end(); it != ie; ++it) {
const Arg *A = *it;
Opts.ChainedIncludes.emplace_back(A->getValue()); Opts.ChainedIncludes.emplace_back(A->getValue());
}
// Include 'altivec.h' if -faltivec option present // Include 'altivec.h' if -faltivec option present
if (Args.hasArg(OPT_faltivec)) if (Args.hasArg(OPT_faltivec))
Opts.Includes.emplace_back("altivec.h"); Opts.Includes.emplace_back("altivec.h");
for (arg_iterator it = Args.filtered_begin(OPT_remap_file), for (const Arg *A : Args.filtered(OPT_remap_file)) {
ie = Args.filtered_end(); it != ie; ++it) { std::pair<StringRef, StringRef> Split = StringRef(A->getValue()).split(';');
const Arg *A = *it;
std::pair<StringRef,StringRef> Split =
StringRef(A->getValue()).split(';');
if (Split.second.empty()) { if (Split.second.empty()) {
Diags.Report(diag::err_drv_invalid_remap_file) << A->getAsString(Args); Diags.Report(diag::err_drv_invalid_remap_file) << A->getAsString(Args);
@@ -1771,7 +1728,7 @@ static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
Opts.addRemappedFile(Split.first, Split.second); Opts.addRemappedFile(Split.first, Split.second);
} }
if (Arg *A = Args.getLastArg(OPT_fobjc_arc_cxxlib_EQ)) { if (Arg *A = Args.getLastArg(OPT_fobjc_arc_cxxlib_EQ)) {
StringRef Name = A->getValue(); StringRef Name = A->getValue();
unsigned Library = llvm::StringSwitch<unsigned>(Name) unsigned Library = llvm::StringSwitch<unsigned>(Name)
@@ -1874,9 +1831,8 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
} }
// Issue errors on unknown arguments. // Issue errors on unknown arguments.
for (arg_iterator it = Args->filtered_begin(OPT_UNKNOWN), for (const Arg *A : Args->filtered(OPT_UNKNOWN)) {
ie = Args->filtered_end(); it != ie; ++it) { Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(*Args);
Diags.Report(diag::err_drv_unknown_argument) << (*it)->getAsString(*Args);
Success = false; Success = false;
} }

View File

@@ -173,10 +173,8 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
} }
// Issue errors on unknown arguments. // Issue errors on unknown arguments.
for (arg_iterator it = Args->filtered_begin(OPT_UNKNOWN), for (const Arg *A : Args->filtered(OPT_UNKNOWN)) {
ie = Args->filtered_end(); Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(*Args);
it != ie; ++it) {
Diags.Report(diag::err_drv_unknown_argument) << (*it)->getAsString(*Args);
Success = false; Success = false;
} }