[PATCH] D37241: [unittests] Add reverse iteration unit tests for pointer-like keys

Mandeep Singh Grang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 3 00:06:09 PDT 2017


mgrang added inline comments.


================
Comment at: unittests/Support/ReverseIterationTest.cpp:69
+
+  static unsigned getHashValue(const PtrLikeInt *PtrVal) {
+    return (unsigned)(PtrVal->value * 37U);
----------------
How about this implementation? PtrLikeInt is pointer-like but it hashes based on an integer value.
I don't think this would work for SmallPtrSet (as you had pointed out).


================
Comment at: unittests/Support/ReverseIterationTest.cpp:95
+  if (shouldReverseIterate<PtrLikeInt *>())
+    std::reverse(&IterKeys[0], &IterKeys[4]);
+
----------------
@dblaikie llvm::reverse(IterKeys) does not change the existing array, right?. I found using std::reverse cleaner than using another array to hold the reversed one.  What do you say?


Repository:
  rL LLVM

https://reviews.llvm.org/D37241





More information about the llvm-commits mailing list