[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 15:07:31 PST 2016


> On Feb 18, 2016, at 14:52, Chandler Carruth <chandlerc at gmail.com> wrote:
> 
> On Thu, Feb 18, 2016 at 2:50 PM Jordan Rose via llvm-commits <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
> 
>> On Feb 18, 2016, at 14:48, Chandler Carruth <chandlerc at gmail.com <mailto: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, {})".
> 
> It's a private type though, right? Anyways, just seems like a lot of code for a simple thing.

It's probably paranoia, but the private type doesn't protect anything.

class Test {
  struct Private {};
  Test(int, Private) {}
public:
  struct Public {};
  Test(int, Public) {}
};

auto test = Test(0, {});

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


More information about the llvm-commits mailing list