What the FIXMEs want, the FIXMEs shall have.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89861 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Driver/ArgList.h b/include/clang/Driver/ArgList.h
index beb92e7..ab1abff 100644
--- a/include/clang/Driver/ArgList.h
+++ b/include/clang/Driver/ArgList.h
@@ -62,6 +62,7 @@
SkipToNextArg();
}
+ operator const Arg*() { return *Current; }
reference operator*() const { return *Current; }
pointer operator->() const { return *Current; }
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index b40dc27..87357cf 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -965,10 +965,9 @@
if (isa<FlagOption>(Opt)) {
bool DuplicateClaimed = false;
- // FIXME: Use iterator.
- for (ArgList::const_iterator it = C.getArgs().begin(),
- ie = C.getArgs().end(); it != ie; ++it) {
- if ((*it)->isClaimed() && (*it)->getOption().matches(&Opt)) {
+ for (arg_iterator it = C.getArgs().filtered_begin(&Opt),
+ ie = C.getArgs().filtered_end(); it != ie; ++it) {
+ if ((*it)->isClaimed()) {
DuplicateClaimed = true;
break;
}
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index ccca336..baa59cf 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -130,13 +130,9 @@
// wonky, but we include looking for .gch so we can support seamless
// replacement into a build system already set up to be generating
// .gch files.
- //
- // FIXME: Use iterator.
- for (ArgList::const_iterator
- it = Args.begin(), ie = Args.end(); it != ie; ++it) {
- const Arg *A = *it;
- if (!A->getOption().matches(options::OPT_clang_i_Group))
- continue;
+ for (arg_iterator it = Args.filtered_begin(options::OPT_clang_i_Group),
+ ie = Args.filtered_end(); it != ie; ++it) {
+ const Arg *A = it;
if (A->getOption().matches(options::OPT_include)) {
// Use PCH if the user requested it, except for C++ (for now).
@@ -484,25 +480,21 @@
CmdArgs.push_back(CPUName);
}
- // FIXME: Use iterator.
- for (ArgList::const_iterator
- it = Args.begin(), ie = Args.end(); it != ie; ++it) {
- const Arg *A = *it;
- if (A->getOption().matches(options::OPT_m_x86_Features_Group)) {
- llvm::StringRef Name = A->getOption().getName();
+ for (arg_iterator it = Args.filtered_begin(options::OPT_m_x86_Features_Group),
+ ie = Args.filtered_end(); it != ie; ++it) {
+ llvm::StringRef Name = it->getOption().getName();
+ it->claim();
- // Skip over "-m".
- assert(Name.startswith("-m") && "Invalid feature name.");
- Name = Name.substr(2);
+ // Skip over "-m".
+ assert(Name.startswith("-m") && "Invalid feature name.");
+ Name = Name.substr(2);
- bool IsNegative = Name.startswith("no-");
- if (IsNegative)
- Name = Name.substr(3);
+ bool IsNegative = Name.startswith("no-");
+ if (IsNegative)
+ Name = Name.substr(3);
- A->claim();
- CmdArgs.push_back("-target-feature");
- CmdArgs.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
- }
+ CmdArgs.push_back("-target-feature");
+ CmdArgs.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
}
}
@@ -1089,15 +1081,10 @@
// Explicitly warn that these options are unsupported, even though
// we are allowing compilation to continue.
- // FIXME: Use iterator.
- for (ArgList::const_iterator
- it = Args.begin(), ie = Args.end(); it != ie; ++it) {
- const Arg *A = *it;
- if (A->getOption().matches(options::OPT_pg)) {
- A->claim();
- D.Diag(clang::diag::warn_drv_clang_unsupported)
- << A->getAsString(Args);
- }
+ for (arg_iterator it = Args.filtered_begin(options::OPT_pg),
+ ie = Args.filtered_end(); it != ie; ++it) {
+ it->claim();
+ D.Diag(clang::diag::warn_drv_clang_unsupported) << it->getAsString(Args);
}
// Claim some arguments which clang supports automatically.
@@ -1110,15 +1097,8 @@
// Claim some arguments which clang doesn't support, but we don't
// care to warn the user about.
-
- // FIXME: Use iterator.
- for (ArgList::const_iterator
- it = Args.begin(), ie = Args.end(); it != ie; ++it) {
- const Arg *A = *it;
- if (A->getOption().matches(options::OPT_clang_ignored_f_Group) ||
- A->getOption().matches(options::OPT_clang_ignored_m_Group))
- A->claim();
- }
+ Args.ClaimAllArgs(options::OPT_clang_ignored_f_Group);
+ Args.ClaimAllArgs(options::OPT_clang_ignored_m_Group);
}
void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA,
@@ -1391,18 +1371,13 @@
// used to inhibit the default -fno-builtin-str{cat,cpy}.
//
// FIXME: Should we grow a better way to deal with "removing" args?
- //
- // FIXME: Use iterator.
- for (ArgList::const_iterator it = Args.begin(),
- ie = Args.end(); it != ie; ++it) {
- const Arg *A = *it;
- if (A->getOption().matches(options::OPT_f_Group) ||
- A->getOption().matches(options::OPT_fsyntax_only)) {
- if (!A->getOption().matches(options::OPT_fbuiltin_strcat) &&
- !A->getOption().matches(options::OPT_fbuiltin_strcpy)) {
- A->claim();
- A->render(Args, CmdArgs);
- }
+ for (arg_iterator it = Args.filtered_begin(options::OPT_f_Group,
+ options::OPT_fsyntax_only),
+ ie = Args.filtered_end(); it != ie; ++it) {
+ if (!it->getOption().matches(options::OPT_fbuiltin_strcat) &&
+ !it->getOption().matches(options::OPT_fbuiltin_strcpy)) {
+ it->claim();
+ it->render(Args, CmdArgs);
}
}
} else