]> granicus.if.org Git - clang/blob - include/clang/AST/OperationKinds.h
Restore the lvalue-to-rvalue conversion patch with a minimal fix.
[clang] / include / clang / AST / OperationKinds.h
1 //===- OperationKinds.h - Operation enums -----------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file enumerates the different kinds of operations that can be
11 // performed by various expressions.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CLANG_AST_OPERATION_KINDS_H
16 #define LLVM_CLANG_AST_OPERATION_KINDS_H
17
18 namespace clang {
19   
20 /// CastKind - The kind of operation required for a conversion.
21 enum CastKind {
22   /// CK_Dependent - A conversion which cannot yet be analyzed because
23   /// either the expression or target type is dependent.  These are
24   /// created only for explicit casts; dependent ASTs aren't required
25   /// to even approximately type-check.
26   ///   (T*) malloc(sizeof(T))
27   ///   reinterpret_cast<intptr_t>(A<T>::alloc());
28   CK_Dependent,
29
30   /// CK_BitCast - A conversion which causes a bit pattern of one type
31   /// to be reinterpreted as a bit pattern of another type.  Generally
32   /// the operands must have equivalent size and unrelated types.
33   ///
34   /// The pointer conversion char* -> int* is a bitcast.  Many other
35   /// pointer conversions which are "physically" bitcasts are given
36   /// special cast kinds.
37   ///
38   /// Vector coercions are bitcasts.
39   CK_BitCast,
40
41   /// CK_LValueBitCast - A conversion which reinterprets the address of
42   /// an l-value as an l-value of a different kind.  Used for
43   /// reinterpret_casts of l-value expressions to reference types.
44   ///    bool b; reinterpret_cast<char&>(b) = 'a';
45   CK_LValueBitCast,
46   
47   /// CK_LValueToRValue - A conversion which causes the extraction of
48   /// an r-value from the operand gl-value.  The result of an r-value
49   /// conversion is always unqualified.
50   CK_LValueToRValue,
51     
52   /// CK_NoOp - A conversion which does not affect the type other than
53   /// (possibly) adding qualifiers.
54   ///   int    -> int
55   ///   char** -> const char * const *
56   CK_NoOp,
57
58   /// CK_BaseToDerived - A conversion from a C++ class pointer/reference
59   /// to a derived class pointer/reference.
60   ///   B *b = static_cast<B*>(a);
61   CK_BaseToDerived,
62
63   /// CK_DerivedToBase - A conversion from a C++ class pointer
64   /// to a base class pointer.
65   ///   A *a = new B();
66   CK_DerivedToBase,
67
68   /// CK_UncheckedDerivedToBase - A conversion from a C++ class
69   /// pointer/reference to a base class that can assume that the
70   /// derived pointer is not null.
71   ///   const A &a = B();
72   ///   b->method_from_a();
73   CK_UncheckedDerivedToBase,
74
75   /// CK_Dynamic - A C++ dynamic_cast.
76   CK_Dynamic,
77
78   /// CK_ToUnion - The GCC cast-to-union extension.
79   ///   int   -> union { int x; float y; }
80   ///   float -> union { int x; float y; }
81   CK_ToUnion,
82
83   /// CK_ArrayToPointerDecay - Array to pointer decay.
84   ///   int[10] -> int*
85   ///   char[5][6] -> char(*)[6]
86   CK_ArrayToPointerDecay,
87
88   /// CK_FunctionToPointerDecay - Function to pointer decay.
89   ///   void(int) -> void(*)(int)
90   CK_FunctionToPointerDecay,
91
92   /// CK_NullToPointer - Null pointer constant to pointer, ObjC
93   /// pointer, or block pointer.
94   ///   (void*) 0
95   ///   void (^block)() = 0;
96   CK_NullToPointer,
97
98   /// CK_NullToMemberPointer - Null pointer constant to member pointer.
99   ///   int A::*mptr = 0;
100   ///   int (A::*fptr)(int) = nullptr;
101   CK_NullToMemberPointer,
102
103   /// CK_BaseToDerivedMemberPointer - Member pointer in base class to
104   /// member pointer in derived class.
105   ///   int B::*mptr = &A::member;
106   CK_BaseToDerivedMemberPointer,
107
108   /// CK_DerivedToBaseMemberPointer - Member pointer in derived class to
109   /// member pointer in base class.
110   ///   int A::*mptr = static_cast<int A::*>(&B::member);
111   CK_DerivedToBaseMemberPointer,
112     
113   /// CK_MemberPointerToBoolean - Member pointer to boolean.  A check
114   /// against the null member pointer.
115   CK_MemberPointerToBoolean,
116
117   /// CK_UserDefinedConversion - Conversion using a user defined type
118   /// conversion function.
119   ///    struct A { operator int(); }; int i = int(A());
120   CK_UserDefinedConversion,
121
122   /// CK_ConstructorConversion - Conversion by constructor.
123   ///    struct A { A(int); }; A a = A(10);
124   CK_ConstructorConversion,
125     
126   /// CK_IntegralToPointer - Integral to pointer.  A special kind of
127   /// reinterpreting conversion.  Applies to normal, ObjC, and block
128   /// pointers.
129   ///    (char*) 0x1001aab0
130   ///    reinterpret_cast<int*>(0)
131   CK_IntegralToPointer,
132     
133   /// CK_PointerToIntegral - Pointer to integral.  A special kind of
134   /// reinterpreting conversion.  Applies to normal, ObjC, and block
135   /// pointers.
136   ///    (intptr_t) "help!"
137   CK_PointerToIntegral,
138
139   /// CK_PointerToBoolean - Pointer to boolean conversion.  A check
140   /// against null.  Applies to normal, ObjC, and block pointers.
141   CK_PointerToBoolean,
142     
143   /// CK_ToVoid - Cast to void, discarding the computed value.
144   ///    (void) malloc(2048)
145   CK_ToVoid,
146     
147   /// CK_VectorSplat - A conversion from an arithmetic type to a
148   /// vector of that element type.  Fills all elements ("splats") with
149   /// the source value.
150   ///    __attribute__((ext_vector_type(4))) int v = 5;
151   CK_VectorSplat,
152     
153   /// CK_IntegralCast - A cast between integral types (other than to
154   /// boolean).  Variously a bitcast, a truncation, a sign-extension,
155   /// or a zero-extension.
156   ///    long l = 5;
157   ///    (unsigned) i
158   CK_IntegralCast,
159
160   /// CK_IntegralToBoolean - Integral to boolean.  A check against zero.
161   ///    (bool) i
162   CK_IntegralToBoolean,
163
164   /// CK_IntegralToFloating - Integral to floating point.
165   ///    float f = i;
166   CK_IntegralToFloating,
167     
168   /// CK_FloatingToIntegral - Floating point to integral.  Rounds
169   /// towards zero, discarding any fractional component.
170   ///    (int) f
171   CK_FloatingToIntegral,
172
173   /// CK_FloatingToBoolean - Floating point to boolean.
174   ///    (bool) f
175   CK_FloatingToBoolean,
176     
177   /// CK_FloatingCast - Casting between floating types of different size.
178   ///    (double) f
179   ///    (float) ld
180   CK_FloatingCast,
181     
182   /// CK_AnyPointerToObjCPointerCast - Casting any other pointer kind
183   /// to an Objective-C pointer.
184   CK_AnyPointerToObjCPointerCast,
185
186   /// CK_AnyPointerToBlockPointerCast - Casting any other pointer kind
187   /// to a block pointer.
188   CK_AnyPointerToBlockPointerCast,
189
190   /// \brief Converting between two Objective-C object types, which
191   /// can occur when performing reference binding to an Objective-C
192   /// object.
193   CK_ObjCObjectLValueCast,
194
195   /// \brief A conversion of a floating point real to a floating point
196   /// complex of the original type.  Injects the value as the real
197   /// component with a zero imaginary component.
198   ///   float -> _Complex float
199   CK_FloatingRealToComplex,
200
201   /// \brief Converts a floating point complex to floating point real
202   /// of the source's element type.  Just discards the imaginary
203   /// component.
204   ///   _Complex long double -> long double
205   CK_FloatingComplexToReal,
206
207   /// \brief Converts a floating point complex to bool by comparing
208   /// against 0+0i.
209   CK_FloatingComplexToBoolean,
210
211   /// \brief Converts between different floating point complex types.
212   ///   _Complex float -> _Complex double
213   CK_FloatingComplexCast,
214
215   /// \brief Converts from a floating complex to an integral complex.
216   ///   _Complex float -> _Complex int
217   CK_FloatingComplexToIntegralComplex,
218
219   /// \brief Converts from an integral real to an integral complex
220   /// whose element type matches the source.  Injects the value as
221   /// the real component with a zero imaginary component.
222   ///   long -> _Complex long
223   CK_IntegralRealToComplex,
224
225   /// \brief Converts an integral complex to an integral real of the
226   /// source's element type by discarding the imaginary component.
227   ///   _Complex short -> short
228   CK_IntegralComplexToReal,
229
230   /// \brief Converts an integral complex to bool by comparing against
231   /// 0+0i.
232   CK_IntegralComplexToBoolean,
233
234   /// \brief Converts between different integral complex types.
235   ///   _Complex char -> _Complex long long
236   ///   _Complex unsigned int -> _Complex signed int
237   CK_IntegralComplexCast,
238
239   /// \brief Converts from an integral complex to a floating complex.
240   ///   _Complex unsigned -> _Complex float
241   CK_IntegralComplexToFloatingComplex
242 };
243
244 #define CK_Invalid ((CastKind) -1)
245
246 enum BinaryOperatorKind {
247   // Operators listed in order of precedence.
248   // Note that additions to this should also update the StmtVisitor class.
249   BO_PtrMemD, BO_PtrMemI,       // [C++ 5.5] Pointer-to-member operators.
250   BO_Mul, BO_Div, BO_Rem,       // [C99 6.5.5] Multiplicative operators.
251   BO_Add, BO_Sub,               // [C99 6.5.6] Additive operators.
252   BO_Shl, BO_Shr,               // [C99 6.5.7] Bitwise shift operators.
253   BO_LT, BO_GT, BO_LE, BO_GE,   // [C99 6.5.8] Relational operators.
254   BO_EQ, BO_NE,                 // [C99 6.5.9] Equality operators.
255   BO_And,                       // [C99 6.5.10] Bitwise AND operator.
256   BO_Xor,                       // [C99 6.5.11] Bitwise XOR operator.
257   BO_Or,                        // [C99 6.5.12] Bitwise OR operator.
258   BO_LAnd,                      // [C99 6.5.13] Logical AND operator.
259   BO_LOr,                       // [C99 6.5.14] Logical OR operator.
260   BO_Assign, BO_MulAssign,      // [C99 6.5.16] Assignment operators.
261   BO_DivAssign, BO_RemAssign,
262   BO_AddAssign, BO_SubAssign,
263   BO_ShlAssign, BO_ShrAssign,
264   BO_AndAssign, BO_XorAssign,
265   BO_OrAssign,
266   BO_Comma                      // [C99 6.5.17] Comma operator.
267 };
268
269 enum UnaryOperatorKind {
270   // Note that additions to this should also update the StmtVisitor class.
271   UO_PostInc, UO_PostDec, // [C99 6.5.2.4] Postfix increment and decrement
272   UO_PreInc, UO_PreDec,   // [C99 6.5.3.1] Prefix increment and decrement
273   UO_AddrOf, UO_Deref,    // [C99 6.5.3.2] Address and indirection
274   UO_Plus, UO_Minus,      // [C99 6.5.3.3] Unary arithmetic
275   UO_Not, UO_LNot,        // [C99 6.5.3.3] Unary arithmetic
276   UO_Real, UO_Imag,       // "__real expr"/"__imag expr" Extension.
277   UO_Extension            // __extension__ marker.
278 };
279
280 }
281
282 #endif