Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CXX / over / over.built / ast.cpp
blob78f86edb1e96162aca44fd7091706d8d63e40de0
1 // RUN: %clang_cc1 -std=c++17 -Wno-unused -ast-dump %s -ast-dump-filter Test | FileCheck %s
3 namespace Test {
4 template<typename T, typename U>
5 void Unary(T t, T* pt, T U::* mpt, T(&ft)(), T(&at)[4]) {
6 // CHECK: UnaryOperator {{.*}} '<dependent type>' lvalue prefix '*' cannot overflow
7 // CHECK-NEXT: DeclRefExpr {{.*}} 'T' lvalue ParmVar {{.*}} 't' 'T'
8 *t;
10 // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '+' cannot overflow
11 // CHECK-NEXT: DeclRefExpr {{.*}} 'T' lvalue ParmVar {{.*}} 't' 'T'
12 +t;
14 // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '-' cannot overflow
15 // CHECK-NEXT: DeclRefExpr {{.*}} 'T' lvalue ParmVar {{.*}} 't' 'T'
16 -t;
18 // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '!' cannot overflow
19 // CHECK-NEXT: DeclRefExpr {{.*}} 'T' lvalue ParmVar {{.*}} 't' 'T'
20 !t;
22 // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '~' cannot overflow
23 // CHECK-NEXT: DeclRefExpr {{.*}} 'T' lvalue ParmVar {{.*}} 't' 'T'
24 ~t;
26 // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '&' cannot overflow
27 // CHECK-NEXT: DeclRefExpr {{.*}} 'T' lvalue ParmVar {{.*}} 't' 'T'
28 &t;
30 // CHECK: UnaryOperator {{.*}} '<dependent type>' lvalue prefix '++' cannot overflow
31 // CHECK-NEXT: DeclRefExpr {{.*}} 'T' lvalue ParmVar {{.*}} 't' 'T'
32 ++t;
34 // CHECK: UnaryOperator {{.*}} '<dependent type>' lvalue prefix '--' cannot overflow
35 // CHECK-NEXT: DeclRefExpr {{.*}} 'T' lvalue ParmVar {{.*}} 't' 'T'
36 --t;
38 // CHECK: UnaryOperator {{.*}} 'T' lvalue prefix '*' cannot overflow
39 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T *' <LValueToRValue>
40 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
41 *pt;
43 // CHECK: UnaryOperator {{.*}} 'T *' prefix '+' cannot overflow
44 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T *' <LValueToRValue>
45 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
46 +pt;
48 // CHECK: UnaryOperator {{.*}} 'bool' prefix '!' cannot overflow
49 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'bool' <PointerToBoolean>
50 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T *' <LValueToRValue>
51 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
52 !pt;
54 // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '&' cannot overflow
55 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
56 &pt;
58 // CHECK: UnaryOperator {{.*}} 'T *' lvalue prefix '++' cannot overflow
59 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
60 ++pt;
62 // CHECK: UnaryOperator {{.*}} 'T *' lvalue prefix '--' cannot overflow
63 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
64 --pt;
66 // CHECK: UnaryOperator {{.*}} 'bool' prefix '!' cannot overflow
67 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'bool' <MemberPointerToBoolean>
68 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T U::*' <LValueToRValue>
69 // CHECK-NEXT: DeclRefExpr {{.*}} 'T U::*' lvalue ParmVar {{.*}} 'mpt' 'T U::*'
70 !mpt;
72 // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '&' cannot overflow
73 // CHECK-NEXT: DeclRefExpr {{.*}} 'T U::*' lvalue ParmVar {{.*}} 'mpt' 'T U::*'
74 &mpt;
76 // CHECK: UnaryOperator {{.*}} 'T ()' lvalue prefix '*' cannot overflow
77 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T (*)()' <FunctionToPointerDecay>
78 // CHECK-NEXT: DeclRefExpr {{.*}} 'T ()' lvalue ParmVar {{.*}} 'ft' 'T (&)()'
79 *ft;
81 // CHECK: UnaryOperator {{.*}} 'T (*)()' prefix '+' cannot overflow
82 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T (*)()' <FunctionToPointerDecay>
83 // CHECK-NEXT: DeclRefExpr {{.*}} 'T ()' lvalue ParmVar {{.*}} 'ft' 'T (&)()'
84 +ft;
86 // CHECK: UnaryOperator {{.*}} 'bool' prefix '!' cannot overflow
87 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'bool' <PointerToBoolean>
88 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T (*)()' <FunctionToPointerDecay>
89 // CHECK-NEXT: DeclRefExpr {{.*}} 'T ()' lvalue ParmVar {{.*}} 'ft' 'T (&)()'
90 !ft;
92 // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '&' cannot overflow
93 // CHECK-NEXT: DeclRefExpr {{.*}} 'T ()' lvalue ParmVar {{.*}} 'ft' 'T (&)()'
94 &ft;
96 // CHECK: UnaryOperator {{.*}} 'T' lvalue prefix '*' cannot overflow
97 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T *' <ArrayToPointerDecay>
98 // CHECK-NEXT: DeclRefExpr {{.*}} 'T[4]' lvalue ParmVar {{.*}} 'at' 'T (&)[4]'
99 *at;
101 // CHECK: UnaryOperator {{.*}} 'T *' prefix '+' cannot overflow
102 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T *' <ArrayToPointerDecay>
103 // CHECK-NEXT: DeclRefExpr {{.*}} 'T[4]' lvalue ParmVar {{.*}} 'at' 'T (&)[4]'
104 +at;
106 // CHECK: UnaryOperator {{.*}} 'bool' prefix '!' cannot overflow
107 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'bool' <PointerToBoolean>
108 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T *' <ArrayToPointerDecay>
109 // CHECK-NEXT: DeclRefExpr {{.*}} 'T[4]' lvalue ParmVar {{.*}} 'at' 'T (&)[4]'
110 !at;
112 // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '&' cannot overflow
113 // CHECK-NEXT: DeclRefExpr {{.*}} 'T[4]' lvalue ParmVar {{.*}} 'at' 'T (&)[4]'
114 &at;
117 template<typename T, typename U>
118 void Binary(T* pt, U* pu) {
119 // CHECK: BinaryOperator {{.*}} '<dependent type>' '+'
120 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
121 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 3
122 pt + 3;
124 // CHECK: BinaryOperator {{.*}} '<dependent type>' '-'
125 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
126 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
127 pt - pt;
129 // CHECK: BinaryOperator {{.*}} '<dependent type>' '-'
130 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
131 // CHECK-NEXT: DeclRefExpr {{.*}} 'U *' lvalue ParmVar {{.*}} 'pu' 'U *'
132 pt - pu;
134 // CHECK: BinaryOperator {{.*}} '<dependent type>' '=='
135 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
136 // CHECK-NEXT: DeclRefExpr {{.*}} 'U *' lvalue ParmVar {{.*}} 'pu' 'U *'
137 pt == pu;
139 } // namespace Test