[PATCH] D37241: [unittests] Add reverse iteration unit test for pointer-like keys
Mandeep Singh Grang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 5 12:55:24 PDT 2017
mgrang marked 2 inline comments as done.
mgrang added inline comments.
================
Comment at: unittests/Support/ReverseIterationTest.cpp:61-67
+ static inline PtrLikeInt *getEmptyKey() {
+ return reinterpret_cast<PtrLikeInt *>(0x7fffffff);
+ }
+
+ static inline PtrLikeInt *getTombstoneKey() {
+ return reinterpret_cast<PtrLikeInt *>(-0x7fffffff - 1);
+ }
----------------
dblaikie wrote:
> Rather than mangling pointers - have two fixed instances of PtrLikeInt that can be pointed to (a local static PtrLikeInt in getEmpty/TombstoneKey would probably suffice:
>
> static PtrLikeInt *getEmptyKey() {
> static const PtrLikeInt EmptyKey;
> return &EmptyKey;
> }
>
> something like that? (drop the 'inline' keyword from (static and non-static) member functions defined inline in a class - they already have that linkage)
Making EmptyKey as a "const" would require an initializer as well as a change in the signature of the getEmptyKey function (which causes build conflicts due to mismatching definitions). So I have dropped the const.
Repository:
rL LLVM
https://reviews.llvm.org/D37241
More information about the llvm-commits
mailing list