[llvm] r261268 - [ADT] Be less clever when using a nonce type for disambiguation.

Jordan Rose via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 18 14:50:51 PST 2016


> On Feb 18, 2016, at 14:48, Chandler Carruth <chandlerc at gmail.com> wrote:
> 
> On Thu, Feb 18, 2016 at 2:07 PM Jordan Rose via llvm-commits <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
> Author: jrose
> Date: Thu Feb 18 16:03:23 2016
> New Revision: 261268
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=261268&view=rev <http://llvm.org/viewvc/llvm-project?rev=261268&view=rev>
> Log:
> [ADT] Be less clever when using a nonce type for disambiguation.
> 
> Old compilers don't like constexpr, but we're only going to use this in one
> place anyway: this file. Everyone else should go through PointerLikeTypeTraits.
> 
> Update to r261259.
> 
> Modified:
>     llvm/trunk/include/llvm/ADT/PointerEmbeddedInt.h
> 
> Modified: llvm/trunk/include/llvm/ADT/PointerEmbeddedInt.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PointerEmbeddedInt.h?rev=261268&r1=261267&r2=261268&view=diff <http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PointerEmbeddedInt.h?rev=261268&r1=261267&r2=261268&view=diff>
> ==============================================================================
> --- llvm/trunk/include/llvm/ADT/PointerEmbeddedInt.h (original)
> +++ llvm/trunk/include/llvm/ADT/PointerEmbeddedInt.h Thu Feb 18 16:03:23 2016
> @@ -45,7 +45,9 @@ class PointerEmbeddedInt {
>      Mask = static_cast<uintptr_t>(-1) << Bits
>    };
> 
> -  static constexpr const struct RawValueTag {} RawValue = RawValueTag();
> +  struct RawValueTag {
> +    explicit RawValueTag() = default;
> +  };
> 
> Why not just "struct RawValueTag {};"? Not sure what all the explicit stuff is buying you here...

I had that at first, but then thought about what happened last time: a particular collision of types that no one had thought to check. I wanted to make sure no one invoked the raw constructor with "PointerEmbeddedInt(rawValue, {})".

Jordan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160218/1cb0ecd1/attachment.html>


More information about the llvm-commits mailing list