This is an archive of the discontinued LLVM Phabricator instance.

[ELF2] - output of all unknown arguments instead of only one
ClosedPublic

Authored by grimar on Sep 23 2015, 3:46 AM.

Details

Summary

I suggest to report all unknown arguments before exit(1), that is helpful for debugging.

Diff Detail

Event Timeline

grimar updated this revision to Diff 35477.Sep 23 2015, 3:46 AM
grimar retitled this revision from to [ELF2] - output of all unknown arguments instead of only one.
grimar updated this object.
grimar added a reviewer: rafael.
grimar added a project: lld.
grimar added subscribers: grimar, llvm-commits.
rafael edited edge metadata.Sep 23 2015, 6:15 AM
rafael added a subscriber: rafael.
  • for (auto *Arg : Args.filtered(OPT_UNKNOWN))
  • error(Twine("unknown argument: ") + Arg->getSpelling());

+
+ auto unknowns = Args.filtered(OPT_UNKNOWN);
+ for (llvm::opt::arg_iterator Arg = unknowns.begin(), End = unknowns.end(); Arg != End; ++Arg)
+ warning(Twine("warning: unknown argument: ") + (*Arg)->getSpelling());
+ if (unknowns.begin() != unknowns.end())
+ error(Twine("unknown argument(s) found"));
+

You should still be able to use a range loop:

auto Unknowns = Args.filtered(OPT_UNKNOWN);
for (auto *Arg : Unknows)

....

if (Unkonws.begin() != Unknows.end())
...

grimar updated this revision to Diff 35490.Sep 23 2015, 6:49 AM
grimar edited edge metadata.

Agree. Returned range loop.

rafael added inline comments.Sep 23 2015, 8:14 AM
DriverUtils.cpp
62

Variables should start with an upper case letter.

grimar updated this revision to Diff 35508.Sep 23 2015, 8:30 AM

Comment about naming variables addressed.

DriverUtils.cpp
62

Fixed.

This is fine by me, but Rui should probably be the one to have the final say.

ruiu accepted this revision.Sep 23 2015, 2:40 PM
ruiu edited edge metadata.

LGTM with this fix.

DriverUtils.cpp
62

Can you write the real type of Unknowns instead of auto?

This revision is now accepted and ready to land.Sep 23 2015, 2:40 PM
grimar updated this revision to Diff 35597.Sep 24 2015, 2:46 AM
grimar edited edge metadata.
  • Review comment addressed.
  • Fixed code format in Error.cpp

Could you please commit this if it is fine now. I dont have permissions for that yet.

DriverUtils.cpp
62

Done.

ruiu added a comment.Sep 24 2015, 11:52 AM

LGTM

DriverUtils.cpp
66

This Twine() is not needed because error() is overloaded both for StringRef and Twine. I'll make that change and submit.

grimar closed this revision.Sep 25 2015, 2:59 AM

r248524