This is an archive of the discontinued LLVM Phabricator instance.

[clang][test] Fix prefix operator++ signature in iterators
ClosedPublic

Authored by gamesh411 on Oct 16 2020, 12:36 AM.

Details

Summary

Prefix operator++ should return the iterator incremented by reference.

Diff Detail

Event Timeline

gamesh411 created this revision.Oct 16 2020, 12:36 AM
gamesh411 requested review of this revision.Oct 16 2020, 12:36 AM

What is the context here? Did it cause any crash/bug or were you just reading through the code for a good night sleep? :D

gamesh411 added a comment.EditedOct 19 2020, 1:01 AM

What is the context here? Did it cause any crash/bug or were you just reading through the code for a good night sleep? :D

No crashes this time 🙏, just happened to notice it with @baloghadamsoftware.

Actually I was debugging thru iterator-related code and was making assumptions on the signature of operators.
Then I noticed the assymetry of return types in case of operator++ (fundamental types have ref return values in prefix case, but the simulator header did not for iterators).

Note that the libc++ implementation uses reference return types:
https://github.com/llvm/llvm-project/blob/master/libcxx/include/iterator
So does the libstd++ implementation:
https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/stl_iterator.h

martong accepted this revision.Oct 20 2020, 5:14 AM

Ok, thanks for the context. LG!

This revision is now accepted and ready to land.Oct 20 2020, 5:14 AM