Re: r360974 - Refactor constant evaluation of typeid(T) to track a symbolic type_info

2019-05-16 Thread Kristina Brooks via cfe-commits
It seems to have been causing asserts to trip on 64-bit hosts while running
tests (ppc64be, ppc64le and x86_64 were all affected), ie:

http://lab.llvm.org:8011/builders/clang-cmake-x86_64-avx2-linux/builds/9528/steps/test-suite/logs/test.log


On Fri, May 17, 2019 at 6:51 AM via cfe-commits 
wrote:

> I'm not sure that is problem. Our internal linux build bot also hit the
> same problem and it has a 64-bit CPU.
>
> Douglas Yung
>
> -Original Message-
> From: cfe-commits  On Behalf Of Chris
> Bieneman via cfe-commits
> Sent: Thursday, May 16, 2019 22:45
> To: Chris Bieneman 
> Cc: Richard Smith ; cfe-commits@lists.llvm.org
> Subject: Re: r360974 - Refactor constant evaluation of typeid(T) to track
> a symbolic type_info
>
> I did some digging before reverting. The bots your patch is failing on are
> 32-bit CPUs. It looks like your static_assert is assuming 8-byte aligned
> pointers, so it always fails on the 32-bit builders.
>
> -Chris
>
> > On May 16, 2019, at 10:14 PM, Chris Bieneman 
> wrote:
> >
> > Sorry to do this, but I'm also reverting r360977, because it seems to be
> on top of this one.
> >
> > -Chris
> >
> >> On May 16, 2019, at 9:58 PM, Chris Bieneman via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>
> >> Hey Richard,
> >>
> >> This change is tripping up a bunch of the bots:
> >>
> >> http://lab.llvm.org:8011/builders/clang-cmake-armv8-lld/builds/1397
> >>
> >> I'm going to revert it so that we don't leave the bots broken overnight.
> >>
> >> -Chris
> >>
> >>> On May 16, 2019, at 6:46 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>>
> >>> Author: rsmith
> >>> Date: Thu May 16 18:46:05 2019
> >>> New Revision: 360974
> >>>
> >>> URL: http://llvm.org/viewvc/llvm-project?rev=360974=rev
> >>> Log:
> >>> Refactor constant evaluation of typeid(T) to track a symbolic
> >>> type_info object rather than tracking the originating expression.
> >>>
> >>> This is groundwork for supporting polymorphic typeid expressions.
> >>> (Note that this somewhat regresses our support for DR1968, but it
> >>> turns out that that never actually worked anyway, at least in
> >>> non-trivial cases.)
> >>>
> >>> Modified:
> >>>  cfe/trunk/include/clang/AST/APValue.h
> >>>  cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
> >>>  cfe/trunk/lib/AST/APValue.cpp
> >>>  cfe/trunk/lib/AST/ExprConstant.cpp
> >>>  cfe/trunk/lib/CodeGen/CGExprConstant.cpp
> >>>  cfe/trunk/lib/Sema/SemaTemplate.cpp
> >>>  cfe/trunk/test/CXX/drs/dr19xx.cpp
> >>>  cfe/trunk/test/Parser/MicrosoftExtensions.cpp
> >>>  cfe/trunk/test/SemaCXX/builtin-constant-p.cpp
> >>>  cfe/trunk/test/SemaCXX/typeid.cpp
> >>>  cfe/trunk/www/cxx_dr_status.html
> >>>
> >>> Modified: cfe/trunk/include/clang/AST/APValue.h
> >>> URL:
> >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APVa
> >>> lue.h?rev=360974=360973=360974=diff
> >>> 
> >>> ==
> >>> --- cfe/trunk/include/clang/AST/APValue.h (original)
> >>> +++ cfe/trunk/include/clang/AST/APValue.h Thu May 16 18:46:05 2019
> >>> @@ -24,14 +24,52 @@ namespace clang { class AddrLabelExpr; class
> >>> ASTContext; class CharUnits;
> >>> +  class CXXRecordDecl;
> >>> +  class Decl;
> >>> class DiagnosticBuilder;
> >>> class Expr;
> >>> class FieldDecl;
> >>> -  class Decl;
> >>> +  struct PrintingPolicy;
> >>> +  class Type;
> >>> class ValueDecl;
> >>> -  class CXXRecordDecl;
> >>> -  class QualType;
> >>>
> >>> +/// Symbolic representation of typeid(T) for some type T.
> >>> +class TypeInfoLValue {
> >>> +  const Type *T;
> >>> +
> >>> +public:
> >>> +  TypeInfoLValue() : T() {}
> >>> +  explicit TypeInfoLValue(const Type *T);
> >>> +
> >>> +  const Type *getType() const { return T; }  explicit operator
> >>> + bool() const { return T; }
> >>> +
> >>> +  void *getOpaqueValue() { return const_cast(T); }  static
> >>> + TypeInfoLValue getFromOpaqueValue(void *Value) {
> >>> +TypeInfoLValue V;
> >>> +V.T = reinterpret_cast(Value);
> >>> +return V;
> >>> +  }
> >>> +
> >>> +  void print(llvm::raw_ostream , const PrintingPolicy )
> >>> +const; }; }
> >>> +
> >>> +namespace llvm {
> >>> +template<> struct PointerLikeTypeTraits {
> >>> +  static void *getAsVoidPointer(clang::TypeInfoLValue V) {
> >>> +return V.getOpaqueValue();
> >>> +  }
> >>> +  static clang::TypeInfoLValue getFromVoidPointer(void *P) {
> >>> +return clang::TypeInfoLValue::getFromOpaqueValue(P);
> >>> +  }
> >>> +  // Validated by static_assert in APValue.cpp; hardcoded to avoid
> >>> +needing
> >>> +  // to include Type.h.
> >>> +  static constexpr int NumLowBitsAvailable = 3; }; }
> >>> +
> >>> +namespace clang {
> >>> /// APValue - This class implements a discriminated union of
> >>> [uninitialized] /// [APSInt] [APFloat], [Complex APSInt] [Complex
> >>> APFloat], [Expr + Offset], /// [Vector: N * APValue], [Array: N *
> >>> APValue] @@ -57,13 +95,18 @@ public:
> >>>
> >>> class LValueBase {
> >>> 

Re: r360974 - Refactor constant evaluation of typeid(T) to track a symbolic type_info

2019-05-16 Thread Richard Smith via cfe-commits
I'm looking into this; feel free to revert, or I will if I don't find
what's up shortly. Sorry for the problems!

On Thu, 16 May 2019 at 22:51, via cfe-commits
 wrote:
>
> I'm not sure that is problem. Our internal linux build bot also hit the same 
> problem and it has a 64-bit CPU.
>
> Douglas Yung
>
> -Original Message-
> From: cfe-commits  On Behalf Of Chris 
> Bieneman via cfe-commits
> Sent: Thursday, May 16, 2019 22:45
> To: Chris Bieneman 
> Cc: Richard Smith ; cfe-commits@lists.llvm.org
> Subject: Re: r360974 - Refactor constant evaluation of typeid(T) to track a 
> symbolic type_info
>
> I did some digging before reverting. The bots your patch is failing on are 
> 32-bit CPUs. It looks like your static_assert is assuming 8-byte aligned 
> pointers, so it always fails on the 32-bit builders.
>
> -Chris
>
> > On May 16, 2019, at 10:14 PM, Chris Bieneman  wrote:
> >
> > Sorry to do this, but I'm also reverting r360977, because it seems to be on 
> > top of this one.
> >
> > -Chris
> >
> >> On May 16, 2019, at 9:58 PM, Chris Bieneman via cfe-commits 
> >>  wrote:
> >>
> >> Hey Richard,
> >>
> >> This change is tripping up a bunch of the bots:
> >>
> >> http://lab.llvm.org:8011/builders/clang-cmake-armv8-lld/builds/1397
> >>
> >> I'm going to revert it so that we don't leave the bots broken overnight.
> >>
> >> -Chris
> >>
> >>> On May 16, 2019, at 6:46 PM, Richard Smith via cfe-commits 
> >>>  wrote:
> >>>
> >>> Author: rsmith
> >>> Date: Thu May 16 18:46:05 2019
> >>> New Revision: 360974
> >>>
> >>> URL: http://llvm.org/viewvc/llvm-project?rev=360974=rev
> >>> Log:
> >>> Refactor constant evaluation of typeid(T) to track a symbolic
> >>> type_info object rather than tracking the originating expression.
> >>>
> >>> This is groundwork for supporting polymorphic typeid expressions.
> >>> (Note that this somewhat regresses our support for DR1968, but it
> >>> turns out that that never actually worked anyway, at least in
> >>> non-trivial cases.)
> >>>
> >>> Modified:
> >>>  cfe/trunk/include/clang/AST/APValue.h
> >>>  cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
> >>>  cfe/trunk/lib/AST/APValue.cpp
> >>>  cfe/trunk/lib/AST/ExprConstant.cpp
> >>>  cfe/trunk/lib/CodeGen/CGExprConstant.cpp
> >>>  cfe/trunk/lib/Sema/SemaTemplate.cpp
> >>>  cfe/trunk/test/CXX/drs/dr19xx.cpp
> >>>  cfe/trunk/test/Parser/MicrosoftExtensions.cpp
> >>>  cfe/trunk/test/SemaCXX/builtin-constant-p.cpp
> >>>  cfe/trunk/test/SemaCXX/typeid.cpp
> >>>  cfe/trunk/www/cxx_dr_status.html
> >>>
> >>> Modified: cfe/trunk/include/clang/AST/APValue.h
> >>> URL:
> >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APVa
> >>> lue.h?rev=360974=360973=360974=diff
> >>> 
> >>> ==
> >>> --- cfe/trunk/include/clang/AST/APValue.h (original)
> >>> +++ cfe/trunk/include/clang/AST/APValue.h Thu May 16 18:46:05 2019
> >>> @@ -24,14 +24,52 @@ namespace clang { class AddrLabelExpr; class
> >>> ASTContext; class CharUnits;
> >>> +  class CXXRecordDecl;
> >>> +  class Decl;
> >>> class DiagnosticBuilder;
> >>> class Expr;
> >>> class FieldDecl;
> >>> -  class Decl;
> >>> +  struct PrintingPolicy;
> >>> +  class Type;
> >>> class ValueDecl;
> >>> -  class CXXRecordDecl;
> >>> -  class QualType;
> >>>
> >>> +/// Symbolic representation of typeid(T) for some type T.
> >>> +class TypeInfoLValue {
> >>> +  const Type *T;
> >>> +
> >>> +public:
> >>> +  TypeInfoLValue() : T() {}
> >>> +  explicit TypeInfoLValue(const Type *T);
> >>> +
> >>> +  const Type *getType() const { return T; }  explicit operator
> >>> + bool() const { return T; }
> >>> +
> >>> +  void *getOpaqueValue() { return const_cast(T); }  static
> >>> + TypeInfoLValue getFromOpaqueValue(void *Value) {
> >>> +TypeInfoLValue V;
> >>> +V.T = reinterpret_cast(Value);
> >>> +return V;
> >>> +  }
> >>> +
> >>> +  void print(llvm::raw_ostream , const PrintingPolicy )
> >>> +const; }; }
> >>> +
> >>> +namespace llvm {
> >>> +template<> struct PointerLikeTypeTraits {
> >>> +  static void *getAsVoidPointer(clang::TypeInfoLValue V) {
> >>> +return V.getOpaqueValue();
> >>> +  }
> >>> +  static clang::TypeInfoLValue getFromVoidPointer(void *P) {
> >>> +return clang::TypeInfoLValue::getFromOpaqueValue(P);
> >>> +  }
> >>> +  // Validated by static_assert in APValue.cpp; hardcoded to avoid
> >>> +needing
> >>> +  // to include Type.h.
> >>> +  static constexpr int NumLowBitsAvailable = 3; }; }
> >>> +
> >>> +namespace clang {
> >>> /// APValue - This class implements a discriminated union of
> >>> [uninitialized] /// [APSInt] [APFloat], [Complex APSInt] [Complex
> >>> APFloat], [Expr + Offset], /// [Vector: N * APValue], [Array: N *
> >>> APValue] @@ -57,13 +95,18 @@ public:
> >>>
> >>> class LValueBase {
> >>> public:
> >>> -typedef llvm::PointerUnion PtrTy;
> >>> +typedef llvm::PointerUnion >>> TypeInfoLValue>
> >>> +PtrTy;
> >>>
> >>> -LValueBase() : 

RE: r360974 - Refactor constant evaluation of typeid(T) to track a symbolic type_info

2019-05-16 Thread via cfe-commits
I'm not sure that is problem. Our internal linux build bot also hit the same 
problem and it has a 64-bit CPU.

Douglas Yung

-Original Message-
From: cfe-commits  On Behalf Of Chris 
Bieneman via cfe-commits
Sent: Thursday, May 16, 2019 22:45
To: Chris Bieneman 
Cc: Richard Smith ; cfe-commits@lists.llvm.org
Subject: Re: r360974 - Refactor constant evaluation of typeid(T) to track a 
symbolic type_info

I did some digging before reverting. The bots your patch is failing on are 
32-bit CPUs. It looks like your static_assert is assuming 8-byte aligned 
pointers, so it always fails on the 32-bit builders.

-Chris

> On May 16, 2019, at 10:14 PM, Chris Bieneman  wrote:
> 
> Sorry to do this, but I'm also reverting r360977, because it seems to be on 
> top of this one.
> 
> -Chris
> 
>> On May 16, 2019, at 9:58 PM, Chris Bieneman via cfe-commits 
>>  wrote:
>> 
>> Hey Richard,
>> 
>> This change is tripping up a bunch of the bots:
>> 
>> http://lab.llvm.org:8011/builders/clang-cmake-armv8-lld/builds/1397
>> 
>> I'm going to revert it so that we don't leave the bots broken overnight.
>> 
>> -Chris
>> 
>>> On May 16, 2019, at 6:46 PM, Richard Smith via cfe-commits 
>>>  wrote:
>>> 
>>> Author: rsmith
>>> Date: Thu May 16 18:46:05 2019
>>> New Revision: 360974
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=360974=rev
>>> Log:
>>> Refactor constant evaluation of typeid(T) to track a symbolic 
>>> type_info object rather than tracking the originating expression.
>>> 
>>> This is groundwork for supporting polymorphic typeid expressions. 
>>> (Note that this somewhat regresses our support for DR1968, but it 
>>> turns out that that never actually worked anyway, at least in 
>>> non-trivial cases.)
>>> 
>>> Modified:
>>>  cfe/trunk/include/clang/AST/APValue.h
>>>  cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
>>>  cfe/trunk/lib/AST/APValue.cpp
>>>  cfe/trunk/lib/AST/ExprConstant.cpp
>>>  cfe/trunk/lib/CodeGen/CGExprConstant.cpp
>>>  cfe/trunk/lib/Sema/SemaTemplate.cpp
>>>  cfe/trunk/test/CXX/drs/dr19xx.cpp
>>>  cfe/trunk/test/Parser/MicrosoftExtensions.cpp
>>>  cfe/trunk/test/SemaCXX/builtin-constant-p.cpp
>>>  cfe/trunk/test/SemaCXX/typeid.cpp
>>>  cfe/trunk/www/cxx_dr_status.html
>>> 
>>> Modified: cfe/trunk/include/clang/AST/APValue.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APVa
>>> lue.h?rev=360974=360973=360974=diff
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/AST/APValue.h (original)
>>> +++ cfe/trunk/include/clang/AST/APValue.h Thu May 16 18:46:05 2019
>>> @@ -24,14 +24,52 @@ namespace clang { class AddrLabelExpr; class 
>>> ASTContext; class CharUnits;
>>> +  class CXXRecordDecl;
>>> +  class Decl;
>>> class DiagnosticBuilder;
>>> class Expr;
>>> class FieldDecl;
>>> -  class Decl;
>>> +  struct PrintingPolicy;
>>> +  class Type;
>>> class ValueDecl;
>>> -  class CXXRecordDecl;
>>> -  class QualType;
>>> 
>>> +/// Symbolic representation of typeid(T) for some type T.
>>> +class TypeInfoLValue {
>>> +  const Type *T;
>>> +
>>> +public:
>>> +  TypeInfoLValue() : T() {}
>>> +  explicit TypeInfoLValue(const Type *T);
>>> +
>>> +  const Type *getType() const { return T; }  explicit operator 
>>> + bool() const { return T; }
>>> +
>>> +  void *getOpaqueValue() { return const_cast(T); }  static 
>>> + TypeInfoLValue getFromOpaqueValue(void *Value) {
>>> +TypeInfoLValue V;
>>> +V.T = reinterpret_cast(Value);
>>> +return V;
>>> +  }
>>> +
>>> +  void print(llvm::raw_ostream , const PrintingPolicy ) 
>>> +const; }; }
>>> +
>>> +namespace llvm {
>>> +template<> struct PointerLikeTypeTraits {
>>> +  static void *getAsVoidPointer(clang::TypeInfoLValue V) {
>>> +return V.getOpaqueValue();
>>> +  }
>>> +  static clang::TypeInfoLValue getFromVoidPointer(void *P) {
>>> +return clang::TypeInfoLValue::getFromOpaqueValue(P);
>>> +  }
>>> +  // Validated by static_assert in APValue.cpp; hardcoded to avoid 
>>> +needing
>>> +  // to include Type.h.
>>> +  static constexpr int NumLowBitsAvailable = 3; }; }
>>> +
>>> +namespace clang {
>>> /// APValue - This class implements a discriminated union of 
>>> [uninitialized] /// [APSInt] [APFloat], [Complex APSInt] [Complex 
>>> APFloat], [Expr + Offset], /// [Vector: N * APValue], [Array: N * 
>>> APValue] @@ -57,13 +95,18 @@ public:
>>> 
>>> class LValueBase {
>>> public:
>>> -typedef llvm::PointerUnion PtrTy;
>>> +typedef llvm::PointerUnion>> TypeInfoLValue>
>>> +PtrTy;
>>> 
>>> -LValueBase() : CallIndex(0), Version(0) {}
>>> +LValueBase() : Local{} {}
>>> 
>>>   template 
>>> -LValueBase(T P, unsigned I = 0, unsigned V = 0)
>>> -: Ptr(P), CallIndex(I), Version(V) {}
>>> +LValueBase(T P, unsigned I = 0, unsigned V = 0) : Ptr(P), Local{I, V} {
>>> +  assert(!is() &&
>>> + "don't use this constructor to form a type_info lvalue");
>>> +}
>>> +
>>> +static LValueBase 

Re: r360974 - Refactor constant evaluation of typeid(T) to track a symbolic type_info

2019-05-16 Thread Chris Bieneman via cfe-commits
I did some digging before reverting. The bots your patch is failing on are 
32-bit CPUs. It looks like your static_assert is assuming 8-byte aligned 
pointers, so it always fails on the 32-bit builders.

-Chris

> On May 16, 2019, at 10:14 PM, Chris Bieneman  wrote:
> 
> Sorry to do this, but I'm also reverting r360977, because it seems to be on 
> top of this one.
> 
> -Chris
> 
>> On May 16, 2019, at 9:58 PM, Chris Bieneman via cfe-commits 
>>  wrote:
>> 
>> Hey Richard,
>> 
>> This change is tripping up a bunch of the bots:
>> 
>> http://lab.llvm.org:8011/builders/clang-cmake-armv8-lld/builds/1397
>> 
>> I'm going to revert it so that we don't leave the bots broken overnight.
>> 
>> -Chris
>> 
>>> On May 16, 2019, at 6:46 PM, Richard Smith via cfe-commits 
>>>  wrote:
>>> 
>>> Author: rsmith
>>> Date: Thu May 16 18:46:05 2019
>>> New Revision: 360974
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=360974=rev
>>> Log:
>>> Refactor constant evaluation of typeid(T) to track a symbolic type_info
>>> object rather than tracking the originating expression.
>>> 
>>> This is groundwork for supporting polymorphic typeid expressions. (Note
>>> that this somewhat regresses our support for DR1968, but it turns out
>>> that that never actually worked anyway, at least in non-trivial cases.)
>>> 
>>> Modified:
>>>  cfe/trunk/include/clang/AST/APValue.h
>>>  cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
>>>  cfe/trunk/lib/AST/APValue.cpp
>>>  cfe/trunk/lib/AST/ExprConstant.cpp
>>>  cfe/trunk/lib/CodeGen/CGExprConstant.cpp
>>>  cfe/trunk/lib/Sema/SemaTemplate.cpp
>>>  cfe/trunk/test/CXX/drs/dr19xx.cpp
>>>  cfe/trunk/test/Parser/MicrosoftExtensions.cpp
>>>  cfe/trunk/test/SemaCXX/builtin-constant-p.cpp
>>>  cfe/trunk/test/SemaCXX/typeid.cpp
>>>  cfe/trunk/www/cxx_dr_status.html
>>> 
>>> Modified: cfe/trunk/include/clang/AST/APValue.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APValue.h?rev=360974=360973=360974=diff
>>> ==
>>> --- cfe/trunk/include/clang/AST/APValue.h (original)
>>> +++ cfe/trunk/include/clang/AST/APValue.h Thu May 16 18:46:05 2019
>>> @@ -24,14 +24,52 @@ namespace clang {
>>> class AddrLabelExpr;
>>> class ASTContext;
>>> class CharUnits;
>>> +  class CXXRecordDecl;
>>> +  class Decl;
>>> class DiagnosticBuilder;
>>> class Expr;
>>> class FieldDecl;
>>> -  class Decl;
>>> +  struct PrintingPolicy;
>>> +  class Type;
>>> class ValueDecl;
>>> -  class CXXRecordDecl;
>>> -  class QualType;
>>> 
>>> +/// Symbolic representation of typeid(T) for some type T.
>>> +class TypeInfoLValue {
>>> +  const Type *T;
>>> +
>>> +public:
>>> +  TypeInfoLValue() : T() {}
>>> +  explicit TypeInfoLValue(const Type *T);
>>> +
>>> +  const Type *getType() const { return T; }
>>> +  explicit operator bool() const { return T; }
>>> +
>>> +  void *getOpaqueValue() { return const_cast(T); }
>>> +  static TypeInfoLValue getFromOpaqueValue(void *Value) {
>>> +TypeInfoLValue V;
>>> +V.T = reinterpret_cast(Value);
>>> +return V;
>>> +  }
>>> +
>>> +  void print(llvm::raw_ostream , const PrintingPolicy ) const;
>>> +};
>>> +}
>>> +
>>> +namespace llvm {
>>> +template<> struct PointerLikeTypeTraits {
>>> +  static void *getAsVoidPointer(clang::TypeInfoLValue V) {
>>> +return V.getOpaqueValue();
>>> +  }
>>> +  static clang::TypeInfoLValue getFromVoidPointer(void *P) {
>>> +return clang::TypeInfoLValue::getFromOpaqueValue(P);
>>> +  }
>>> +  // Validated by static_assert in APValue.cpp; hardcoded to avoid needing
>>> +  // to include Type.h.
>>> +  static constexpr int NumLowBitsAvailable = 3;
>>> +};
>>> +}
>>> +
>>> +namespace clang {
>>> /// APValue - This class implements a discriminated union of [uninitialized]
>>> /// [APSInt] [APFloat], [Complex APSInt] [Complex APFloat], [Expr + Offset],
>>> /// [Vector: N * APValue], [Array: N * APValue]
>>> @@ -57,13 +95,18 @@ public:
>>> 
>>> class LValueBase {
>>> public:
>>> -typedef llvm::PointerUnion PtrTy;
>>> +typedef llvm::PointerUnion>> TypeInfoLValue>
>>> +PtrTy;
>>> 
>>> -LValueBase() : CallIndex(0), Version(0) {}
>>> +LValueBase() : Local{} {}
>>> 
>>>   template 
>>> -LValueBase(T P, unsigned I = 0, unsigned V = 0)
>>> -: Ptr(P), CallIndex(I), Version(V) {}
>>> +LValueBase(T P, unsigned I = 0, unsigned V = 0) : Ptr(P), Local{I, V} {
>>> +  assert(!is() &&
>>> + "don't use this constructor to form a type_info lvalue");
>>> +}
>>> +
>>> +static LValueBase getTypeInfo(TypeInfoLValue LV, QualType TypeInfo);
>>> 
>>>   template 
>>>   bool is() const { return Ptr.is(); }
>>> @@ -78,28 +121,15 @@ public:
>>> 
>>>   bool isNull() const;
>>> 
>>> -explicit operator bool () const;
>>> +explicit operator bool() const;
>>> 
>>> -PtrTy getPointer() const {
>>> -  return Ptr;
>>> -}
>>> +PtrTy getPointer() const { return Ptr; }
>>> 
>>> -unsigned getCallIndex() 

Re: r360974 - Refactor constant evaluation of typeid(T) to track a symbolic type_info

2019-05-16 Thread Chris Bieneman via cfe-commits
Sorry to do this, but I'm also reverting r360977, because it seems to be on top 
of this one.

-Chris

> On May 16, 2019, at 9:58 PM, Chris Bieneman via cfe-commits 
>  wrote:
> 
> Hey Richard,
> 
> This change is tripping up a bunch of the bots:
> 
> http://lab.llvm.org:8011/builders/clang-cmake-armv8-lld/builds/1397
> 
> I'm going to revert it so that we don't leave the bots broken overnight.
> 
> -Chris
> 
>> On May 16, 2019, at 6:46 PM, Richard Smith via cfe-commits 
>>  wrote:
>> 
>> Author: rsmith
>> Date: Thu May 16 18:46:05 2019
>> New Revision: 360974
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=360974=rev
>> Log:
>> Refactor constant evaluation of typeid(T) to track a symbolic type_info
>> object rather than tracking the originating expression.
>> 
>> This is groundwork for supporting polymorphic typeid expressions. (Note
>> that this somewhat regresses our support for DR1968, but it turns out
>> that that never actually worked anyway, at least in non-trivial cases.)
>> 
>> Modified:
>>   cfe/trunk/include/clang/AST/APValue.h
>>   cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
>>   cfe/trunk/lib/AST/APValue.cpp
>>   cfe/trunk/lib/AST/ExprConstant.cpp
>>   cfe/trunk/lib/CodeGen/CGExprConstant.cpp
>>   cfe/trunk/lib/Sema/SemaTemplate.cpp
>>   cfe/trunk/test/CXX/drs/dr19xx.cpp
>>   cfe/trunk/test/Parser/MicrosoftExtensions.cpp
>>   cfe/trunk/test/SemaCXX/builtin-constant-p.cpp
>>   cfe/trunk/test/SemaCXX/typeid.cpp
>>   cfe/trunk/www/cxx_dr_status.html
>> 
>> Modified: cfe/trunk/include/clang/AST/APValue.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APValue.h?rev=360974=360973=360974=diff
>> ==
>> --- cfe/trunk/include/clang/AST/APValue.h (original)
>> +++ cfe/trunk/include/clang/AST/APValue.h Thu May 16 18:46:05 2019
>> @@ -24,14 +24,52 @@ namespace clang {
>>  class AddrLabelExpr;
>>  class ASTContext;
>>  class CharUnits;
>> +  class CXXRecordDecl;
>> +  class Decl;
>>  class DiagnosticBuilder;
>>  class Expr;
>>  class FieldDecl;
>> -  class Decl;
>> +  struct PrintingPolicy;
>> +  class Type;
>>  class ValueDecl;
>> -  class CXXRecordDecl;
>> -  class QualType;
>> 
>> +/// Symbolic representation of typeid(T) for some type T.
>> +class TypeInfoLValue {
>> +  const Type *T;
>> +
>> +public:
>> +  TypeInfoLValue() : T() {}
>> +  explicit TypeInfoLValue(const Type *T);
>> +
>> +  const Type *getType() const { return T; }
>> +  explicit operator bool() const { return T; }
>> +
>> +  void *getOpaqueValue() { return const_cast(T); }
>> +  static TypeInfoLValue getFromOpaqueValue(void *Value) {
>> +TypeInfoLValue V;
>> +V.T = reinterpret_cast(Value);
>> +return V;
>> +  }
>> +
>> +  void print(llvm::raw_ostream , const PrintingPolicy ) const;
>> +};
>> +}
>> +
>> +namespace llvm {
>> +template<> struct PointerLikeTypeTraits {
>> +  static void *getAsVoidPointer(clang::TypeInfoLValue V) {
>> +return V.getOpaqueValue();
>> +  }
>> +  static clang::TypeInfoLValue getFromVoidPointer(void *P) {
>> +return clang::TypeInfoLValue::getFromOpaqueValue(P);
>> +  }
>> +  // Validated by static_assert in APValue.cpp; hardcoded to avoid needing
>> +  // to include Type.h.
>> +  static constexpr int NumLowBitsAvailable = 3;
>> +};
>> +}
>> +
>> +namespace clang {
>> /// APValue - This class implements a discriminated union of [uninitialized]
>> /// [APSInt] [APFloat], [Complex APSInt] [Complex APFloat], [Expr + Offset],
>> /// [Vector: N * APValue], [Array: N * APValue]
>> @@ -57,13 +95,18 @@ public:
>> 
>>  class LValueBase {
>>  public:
>> -typedef llvm::PointerUnion PtrTy;
>> +typedef llvm::PointerUnion> TypeInfoLValue>
>> +PtrTy;
>> 
>> -LValueBase() : CallIndex(0), Version(0) {}
>> +LValueBase() : Local{} {}
>> 
>>template 
>> -LValueBase(T P, unsigned I = 0, unsigned V = 0)
>> -: Ptr(P), CallIndex(I), Version(V) {}
>> +LValueBase(T P, unsigned I = 0, unsigned V = 0) : Ptr(P), Local{I, V} {
>> +  assert(!is() &&
>> + "don't use this constructor to form a type_info lvalue");
>> +}
>> +
>> +static LValueBase getTypeInfo(TypeInfoLValue LV, QualType TypeInfo);
>> 
>>template 
>>bool is() const { return Ptr.is(); }
>> @@ -78,28 +121,15 @@ public:
>> 
>>bool isNull() const;
>> 
>> -explicit operator bool () const;
>> +explicit operator bool() const;
>> 
>> -PtrTy getPointer() const {
>> -  return Ptr;
>> -}
>> +PtrTy getPointer() const { return Ptr; }
>> 
>> -unsigned getCallIndex() const {
>> -  return CallIndex;
>> -}
>> +unsigned getCallIndex() const;
>> +unsigned getVersion() const;
>> +QualType getTypeInfoType() const;
>> 
>> -void setCallIndex(unsigned Index) {
>> -  CallIndex = Index;
>> -}
>> -
>> -unsigned getVersion() const {
>> -  return Version;
>> -}
>> -
>> -friend bool operator==(const LValueBase , const 

Re: r360974 - Refactor constant evaluation of typeid(T) to track a symbolic type_info

2019-05-16 Thread Chris Bieneman via cfe-commits
Hey Richard,

This change is tripping up a bunch of the bots:

http://lab.llvm.org:8011/builders/clang-cmake-armv8-lld/builds/1397

I'm going to revert it so that we don't leave the bots broken overnight.

-Chris

> On May 16, 2019, at 6:46 PM, Richard Smith via cfe-commits 
>  wrote:
> 
> Author: rsmith
> Date: Thu May 16 18:46:05 2019
> New Revision: 360974
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=360974=rev
> Log:
> Refactor constant evaluation of typeid(T) to track a symbolic type_info
> object rather than tracking the originating expression.
> 
> This is groundwork for supporting polymorphic typeid expressions. (Note
> that this somewhat regresses our support for DR1968, but it turns out
> that that never actually worked anyway, at least in non-trivial cases.)
> 
> Modified:
>cfe/trunk/include/clang/AST/APValue.h
>cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
>cfe/trunk/lib/AST/APValue.cpp
>cfe/trunk/lib/AST/ExprConstant.cpp
>cfe/trunk/lib/CodeGen/CGExprConstant.cpp
>cfe/trunk/lib/Sema/SemaTemplate.cpp
>cfe/trunk/test/CXX/drs/dr19xx.cpp
>cfe/trunk/test/Parser/MicrosoftExtensions.cpp
>cfe/trunk/test/SemaCXX/builtin-constant-p.cpp
>cfe/trunk/test/SemaCXX/typeid.cpp
>cfe/trunk/www/cxx_dr_status.html
> 
> Modified: cfe/trunk/include/clang/AST/APValue.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APValue.h?rev=360974=360973=360974=diff
> ==
> --- cfe/trunk/include/clang/AST/APValue.h (original)
> +++ cfe/trunk/include/clang/AST/APValue.h Thu May 16 18:46:05 2019
> @@ -24,14 +24,52 @@ namespace clang {
>   class AddrLabelExpr;
>   class ASTContext;
>   class CharUnits;
> +  class CXXRecordDecl;
> +  class Decl;
>   class DiagnosticBuilder;
>   class Expr;
>   class FieldDecl;
> -  class Decl;
> +  struct PrintingPolicy;
> +  class Type;
>   class ValueDecl;
> -  class CXXRecordDecl;
> -  class QualType;
> 
> +/// Symbolic representation of typeid(T) for some type T.
> +class TypeInfoLValue {
> +  const Type *T;
> +
> +public:
> +  TypeInfoLValue() : T() {}
> +  explicit TypeInfoLValue(const Type *T);
> +
> +  const Type *getType() const { return T; }
> +  explicit operator bool() const { return T; }
> +
> +  void *getOpaqueValue() { return const_cast(T); }
> +  static TypeInfoLValue getFromOpaqueValue(void *Value) {
> +TypeInfoLValue V;
> +V.T = reinterpret_cast(Value);
> +return V;
> +  }
> +
> +  void print(llvm::raw_ostream , const PrintingPolicy ) const;
> +};
> +}
> +
> +namespace llvm {
> +template<> struct PointerLikeTypeTraits {
> +  static void *getAsVoidPointer(clang::TypeInfoLValue V) {
> +return V.getOpaqueValue();
> +  }
> +  static clang::TypeInfoLValue getFromVoidPointer(void *P) {
> +return clang::TypeInfoLValue::getFromOpaqueValue(P);
> +  }
> +  // Validated by static_assert in APValue.cpp; hardcoded to avoid needing
> +  // to include Type.h.
> +  static constexpr int NumLowBitsAvailable = 3;
> +};
> +}
> +
> +namespace clang {
> /// APValue - This class implements a discriminated union of [uninitialized]
> /// [APSInt] [APFloat], [Complex APSInt] [Complex APFloat], [Expr + Offset],
> /// [Vector: N * APValue], [Array: N * APValue]
> @@ -57,13 +95,18 @@ public:
> 
>   class LValueBase {
>   public:
> -typedef llvm::PointerUnion PtrTy;
> +typedef llvm::PointerUnion TypeInfoLValue>
> +PtrTy;
> 
> -LValueBase() : CallIndex(0), Version(0) {}
> +LValueBase() : Local{} {}
> 
> template 
> -LValueBase(T P, unsigned I = 0, unsigned V = 0)
> -: Ptr(P), CallIndex(I), Version(V) {}
> +LValueBase(T P, unsigned I = 0, unsigned V = 0) : Ptr(P), Local{I, V} {
> +  assert(!is() &&
> + "don't use this constructor to form a type_info lvalue");
> +}
> +
> +static LValueBase getTypeInfo(TypeInfoLValue LV, QualType TypeInfo);
> 
> template 
> bool is() const { return Ptr.is(); }
> @@ -78,28 +121,15 @@ public:
> 
> bool isNull() const;
> 
> -explicit operator bool () const;
> +explicit operator bool() const;
> 
> -PtrTy getPointer() const {
> -  return Ptr;
> -}
> +PtrTy getPointer() const { return Ptr; }
> 
> -unsigned getCallIndex() const {
> -  return CallIndex;
> -}
> +unsigned getCallIndex() const;
> +unsigned getVersion() const;
> +QualType getTypeInfoType() const;
> 
> -void setCallIndex(unsigned Index) {
> -  CallIndex = Index;
> -}
> -
> -unsigned getVersion() const {
> -  return Version;
> -}
> -
> -friend bool operator==(const LValueBase , const LValueBase ) {
> -  return LHS.Ptr == RHS.Ptr && LHS.CallIndex == RHS.CallIndex &&
> - LHS.Version == RHS.Version;
> -}
> +friend bool operator==(const LValueBase , const LValueBase );
> friend bool operator!=(const LValueBase , const LValueBase ) {
>   return !(LHS == RHS);
> }
> @@ 

r360974 - Refactor constant evaluation of typeid(T) to track a symbolic type_info

2019-05-16 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu May 16 18:46:05 2019
New Revision: 360974

URL: http://llvm.org/viewvc/llvm-project?rev=360974=rev
Log:
Refactor constant evaluation of typeid(T) to track a symbolic type_info
object rather than tracking the originating expression.

This is groundwork for supporting polymorphic typeid expressions. (Note
that this somewhat regresses our support for DR1968, but it turns out
that that never actually worked anyway, at least in non-trivial cases.)

Modified:
cfe/trunk/include/clang/AST/APValue.h
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/lib/AST/APValue.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CXX/drs/dr19xx.cpp
cfe/trunk/test/Parser/MicrosoftExtensions.cpp
cfe/trunk/test/SemaCXX/builtin-constant-p.cpp
cfe/trunk/test/SemaCXX/typeid.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/include/clang/AST/APValue.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APValue.h?rev=360974=360973=360974=diff
==
--- cfe/trunk/include/clang/AST/APValue.h (original)
+++ cfe/trunk/include/clang/AST/APValue.h Thu May 16 18:46:05 2019
@@ -24,14 +24,52 @@ namespace clang {
   class AddrLabelExpr;
   class ASTContext;
   class CharUnits;
+  class CXXRecordDecl;
+  class Decl;
   class DiagnosticBuilder;
   class Expr;
   class FieldDecl;
-  class Decl;
+  struct PrintingPolicy;
+  class Type;
   class ValueDecl;
-  class CXXRecordDecl;
-  class QualType;
 
+/// Symbolic representation of typeid(T) for some type T.
+class TypeInfoLValue {
+  const Type *T;
+
+public:
+  TypeInfoLValue() : T() {}
+  explicit TypeInfoLValue(const Type *T);
+
+  const Type *getType() const { return T; }
+  explicit operator bool() const { return T; }
+
+  void *getOpaqueValue() { return const_cast(T); }
+  static TypeInfoLValue getFromOpaqueValue(void *Value) {
+TypeInfoLValue V;
+V.T = reinterpret_cast(Value);
+return V;
+  }
+
+  void print(llvm::raw_ostream , const PrintingPolicy ) const;
+};
+}
+
+namespace llvm {
+template<> struct PointerLikeTypeTraits {
+  static void *getAsVoidPointer(clang::TypeInfoLValue V) {
+return V.getOpaqueValue();
+  }
+  static clang::TypeInfoLValue getFromVoidPointer(void *P) {
+return clang::TypeInfoLValue::getFromOpaqueValue(P);
+  }
+  // Validated by static_assert in APValue.cpp; hardcoded to avoid needing
+  // to include Type.h.
+  static constexpr int NumLowBitsAvailable = 3;
+};
+}
+
+namespace clang {
 /// APValue - This class implements a discriminated union of [uninitialized]
 /// [APSInt] [APFloat], [Complex APSInt] [Complex APFloat], [Expr + Offset],
 /// [Vector: N * APValue], [Array: N * APValue]
@@ -57,13 +95,18 @@ public:
 
   class LValueBase {
   public:
-typedef llvm::PointerUnion PtrTy;
+typedef llvm::PointerUnion
+PtrTy;
 
-LValueBase() : CallIndex(0), Version(0) {}
+LValueBase() : Local{} {}
 
 template 
-LValueBase(T P, unsigned I = 0, unsigned V = 0)
-: Ptr(P), CallIndex(I), Version(V) {}
+LValueBase(T P, unsigned I = 0, unsigned V = 0) : Ptr(P), Local{I, V} {
+  assert(!is() &&
+ "don't use this constructor to form a type_info lvalue");
+}
+
+static LValueBase getTypeInfo(TypeInfoLValue LV, QualType TypeInfo);
 
 template 
 bool is() const { return Ptr.is(); }
@@ -78,28 +121,15 @@ public:
 
 bool isNull() const;
 
-explicit operator bool () const;
+explicit operator bool() const;
 
-PtrTy getPointer() const {
-  return Ptr;
-}
+PtrTy getPointer() const { return Ptr; }
 
-unsigned getCallIndex() const {
-  return CallIndex;
-}
+unsigned getCallIndex() const;
+unsigned getVersion() const;
+QualType getTypeInfoType() const;
 
-void setCallIndex(unsigned Index) {
-  CallIndex = Index;
-}
-
-unsigned getVersion() const {
-  return Version;
-}
-
-friend bool operator==(const LValueBase , const LValueBase ) {
-  return LHS.Ptr == RHS.Ptr && LHS.CallIndex == RHS.CallIndex &&
- LHS.Version == RHS.Version;
-}
+friend bool operator==(const LValueBase , const LValueBase );
 friend bool operator!=(const LValueBase , const LValueBase ) {
   return !(LHS == RHS);
 }
@@ -107,7 +137,14 @@ public:
 
   private:
 PtrTy Ptr;
-unsigned CallIndex, Version;
+struct LocalState {
+  unsigned CallIndex, Version;
+};
+union {
+  LocalState Local;
+  /// The type std::type_info, if this is a TypeInfoLValue.
+  void *TypeInfoType;
+};
   };
 
   /// A FieldDecl or CXXRecordDecl, along with a flag indicating whether we

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: