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

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 3 17:20:21 PDT 2017


On Sun, Sep 3, 2017 at 12:06 AM Mandeep Singh Grang via Phabricator <
reviews at reviews.llvm.org> wrote:

> 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.
>

Hmm, I guess that works - hadn't considered that. Would this work if the
type in the container was PtrLikeInt instead of PtrLikeInt*? Seems it might
be a touch simpler.


> 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?.


Oh, right, sure.


> I found using std::reverse cleaner than using another array to hold the
> reversed one.  What do you say?
>

Fine as-is.


>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D37241
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170904/e5060f59/attachment.html>


More information about the llvm-commits mailing list