Fix PR8639 by making the "argument unused during compilation" less agressive. Now we

don't warn if an argument is not used because it is shadowed by a subsequent argument.

llvm-svn: 122281
This commit is contained in:
Rafael Espindola 2010-12-20 22:45:09 +00:00
parent 5ac4e5f812
commit 7f73489c3f
2 changed files with 16 additions and 22 deletions

View File

@ -55,62 +55,59 @@ Arg *ArgList::getLastArgNoClaim(OptSpecifier Id) const {
} }
Arg *ArgList::getLastArg(OptSpecifier Id) const { Arg *ArgList::getLastArg(OptSpecifier Id) const {
Arg *A = getLastArgNoClaim(Id); Arg *Res = 0;
if (A) for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
A->claim(); if ((*it)->getOption().matches(Id)) {
return A; Res = *it;
Res->claim();
}
}
return Res;
} }
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1) const { Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1) const {
Arg *Res = 0; Arg *Res = 0;
for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it) { for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id0) || if ((*it)->getOption().matches(Id0) ||
(*it)->getOption().matches(Id1)) { (*it)->getOption().matches(Id1)) {
Res = *it; Res = *it;
break; Res->claim();
} }
} }
if (Res)
Res->claim();
return Res; return Res;
} }
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1, Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
OptSpecifier Id2) const { OptSpecifier Id2) const {
Arg *Res = 0; Arg *Res = 0;
for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it) { for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id0) || if ((*it)->getOption().matches(Id0) ||
(*it)->getOption().matches(Id1) || (*it)->getOption().matches(Id1) ||
(*it)->getOption().matches(Id2)) { (*it)->getOption().matches(Id2)) {
Res = *it; Res = *it;
break; Res->claim();
} }
} }
if (Res)
Res->claim();
return Res; return Res;
} }
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1, Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
OptSpecifier Id2, OptSpecifier Id3) const { OptSpecifier Id2, OptSpecifier Id3) const {
Arg *Res = 0; Arg *Res = 0;
for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it) { for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id0) || if ((*it)->getOption().matches(Id0) ||
(*it)->getOption().matches(Id1) || (*it)->getOption().matches(Id1) ||
(*it)->getOption().matches(Id2) || (*it)->getOption().matches(Id2) ||
(*it)->getOption().matches(Id3)) { (*it)->getOption().matches(Id3)) {
Res = *it; Res = *it;
break; Res->claim();
} }
} }
if (Res)
Res->claim();
return Res; return Res;
} }

View File

@ -1147,9 +1147,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
A->render(Args, CmdArgs); A->render(Args, CmdArgs);
} }
// Silence warning for "clang -O2 -O0 -c foo.c -o foo.o"
Args.ClaimAllArgs(options::OPT_O_Group);
Args.AddAllArgs(CmdArgs, options::OPT_W_Group); Args.AddAllArgs(CmdArgs, options::OPT_W_Group);
Args.AddLastArg(CmdArgs, options::OPT_pedantic); Args.AddLastArg(CmdArgs, options::OPT_pedantic);
Args.AddLastArg(CmdArgs, options::OPT_pedantic_errors); Args.AddLastArg(CmdArgs, options::OPT_pedantic_errors);