Dmitry Babokin via llvm-dev
2017-Mar-22 18:58 UTC
[llvm-dev] arg_iterator missing inc/dec operators
Reid, After your recent redefinition of arg_iterator, it's missing increment/decrement operators (which people typically expect to be defined for iterators). So some external code relying on this is broken. If it's not intentional, would be nice to have it fixed. Specific code that I is broken looks like this: llvm::Function f; foo(--f->arg_end()); // passing the last argument to the function. Dmitry. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170322/ccf96cef/attachment.html>
Jonathan Roelofs via llvm-dev
2017-Mar-22 19:55 UTC
[llvm-dev] arg_iterator missing inc/dec operators
On 3/22/17 12:58 PM, Dmitry Babokin via llvm-dev wrote:> Reid, > > After your recent redefinition of arg_iterator, it's missing > increment/decrement operators (which people typically expect to be > defined for iterators). So some external code relying on this is broken. > If it's not intentional, would be nice to have it fixed. > > Specific code that I is broken looks like this: > > llvm::Function f; > foo(--f->arg_end()); // passing the last argument to the function.The predecrement / decrement operators *do* exist on this iterator: https://github.com/llvm-mirror/llvm/blob/master/include/llvm/ADT/ilist_iterator.h#L153 Maybe you meant: llvm::Function *f; foo(&*--f->arg_end()); ?> > Dmitry. > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-- Jon Roelofs jonathan at codesourcery.com CodeSourcery / Mentor Embedded
Reid Kleckner via llvm-dev
2017-Mar-22 19:56 UTC
[llvm-dev] arg_iterator missing inc/dec operators
This code doesn't actually want to create and modify a temporary iterator. It's better to rewrite this code as std::prev(f->arg_end()). On Wed, Mar 22, 2017 at 11:58 AM, Dmitry Babokin <babokin at gmail.com> wrote:> Reid, > > After your recent redefinition of arg_iterator, it's missing > increment/decrement operators (which people typically expect to be defined > for iterators). So some external code relying on this is broken. If it's > not intentional, would be nice to have it fixed. > > Specific code that I is broken looks like this: > > llvm::Function f; > foo(--f->arg_end()); // passing the last argument to the function. > > Dmitry. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170322/053256f4/attachment.html>
Dmitry Babokin via llvm-dev
2017-Mar-22 20:12 UTC
[llvm-dev] arg_iterator missing inc/dec operators
> The predecrement / decrement operators *do* exist on this iterator: > https://github.com/llvm-mirror/llvm/blob/master/include/ > llvm/ADT/ilist_iterator.h#L153 > > Maybe you meant: > > llvm::Function *f; > foo(&*--f->arg_end()); > > ? >Correct, I mean exactly this. Though &* is not important in this case. This code doesn't work anymore, as arg_iterator is defined differently now: https://github.com/llvm-mirror/llvm/blob/master/include/llvm/IR/Function.h#L57 I get an error when I'm using pre-decrement operator: error: expression is not assignable --f->arg_end(); Dmitry. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170322/3ffca78c/attachment.html>