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>
Reid Kleckner via llvm-dev
2017-Mar-22 20:20 UTC
[llvm-dev] arg_iterator missing inc/dec operators
On Wed, Mar 22, 2017 at 1:12 PM, Dmitry Babokin <babokin at gmail.com> wrote:> 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(); >Today's arg_iterator is now just an Argument*, which is the world's simplest iterator. The '--f->arg_end()' snippet only compiled before this change because we used to use fancy ilist iterators which had overloaded decrement operators. I don't think we should make a wrapper pointer iterator type just to make old code like this compile. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170322/1654e3e6/attachment.html>
Dmitry Babokin via llvm-dev
2017-Mar-22 20:23 UTC
[llvm-dev] arg_iterator missing inc/dec operators
Reid, std::prev() works, though IMHO increment/decrement are more conventional way (I'm not saying better) to work with iterators. I have no problem fixing code on my side, I'm just bringing your attention that code like this is broken. If your judgement is to keep it the way it is now, I'm ok with it. Thanks. Dmitry. On Wed, Mar 22, 2017 at 1:20 PM, Reid Kleckner <rnk at google.com> wrote:> On Wed, Mar 22, 2017 at 1:12 PM, Dmitry Babokin <babokin at gmail.com> wrote: > >> 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(); >> > > Today's arg_iterator is now just an Argument*, which is the world's > simplest iterator. The '--f->arg_end()' snippet only compiled before this > change because we used to use fancy ilist iterators which had overloaded > decrement operators. > > I don't think we should make a wrapper pointer iterator type just to make > old code like this compile. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170322/be37a51d/attachment.html>