This is an archive of the discontinued LLVM Phabricator instance.

Option parsing: implement decrement operators for arg_iterator
AbandonedPublic

Authored by grimar on Mar 3 2017, 5:27 AM.

Details

Summary

Implementing of decrement operators allows doing things like:

for (auto *Arg : llvm::reverse(Args.filtered(OPT_z)))

Diff Detail

Event Timeline

grimar created this revision.Mar 3 2017, 5:27 AM
dblaikie edited edge metadata.Mar 3 2017, 11:47 AM

Any chance of using the llvm utility iterator_facade to simplify this class & provide the new functionality?

davide requested changes to this revision.Mar 5 2017, 3:38 PM

ehm, what's your use case for iterating lld arguments in reverse order?

This revision now requires changes to proceed.Mar 5 2017, 3:38 PM

ehm, what's your use case for iterating lld arguments in reverse order?

Case is https://reviews.llvm.org/D30530#inline-264974.

-z linker option can have any text parameter: -z foo, -z boo, -z moo. In my case I am trying to support
-z text/-z notext. Processing only the last text/notext would be enough to know the result value for option.
I am using Args.filtered(OPT_z) to take all -z options now and was asked during review to iterate from backwards.

I'm not entirely sure it's worth the complexity. This just allows the lld driver to return early.

davide added a comment.Mar 6 2017, 1:02 AM

In other words, if you find other cases where this help, fair enough, but I'm reluctant to introduce new code in ArgList with a single consumer for cosmetic reasons only.

grimar added a comment.Mar 6 2017, 1:03 AM

In other words, if you find other cases where this help, fair enough, but I'm reluctant to introduce new code in ArgList with a single consumer for cosmetic reasons only.

I see.

grimar abandoned this revision.Mar 7 2017, 2:22 AM