]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - contrib/llvm/tools/clang/include/clang/AST/OperationKinds.h
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.git] / contrib / llvm / tools / 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.  A conversion
35   /// from any pointer type to a C pointer type is a bitcast unless
36   /// it's actually BaseToDerived or DerivedToBase.  A conversion to a
37   /// block pointer or ObjC pointer type is a bitcast only if the
38   /// operand has the same type kind; otherwise, it's one of the
39   /// specialized casts below.
40   ///
41   /// Vector coercions are bitcasts.
42   CK_BitCast,
43
44   /// CK_LValueBitCast - A conversion which reinterprets the address of
45   /// an l-value as an l-value of a different kind.  Used for
46   /// reinterpret_casts of l-value expressions to reference types.
47   ///    bool b; reinterpret_cast<char&>(b) = 'a';
48   CK_LValueBitCast,
49   
50   /// CK_LValueToRValue - A conversion which causes the extraction of
51   /// an r-value from the operand gl-value.  The result of an r-value
52   /// conversion is always unqualified.
53   CK_LValueToRValue,
54
55   /// CK_GetObjCProperty - A conversion which calls an Objective-C
56   /// property getter.  The operand is an OK_ObjCProperty l-value; the
57   /// result will generally be an r-value, but could be an ordinary
58   /// gl-value if the property reference is to an implicit property
59   /// for a method that returns a reference type.
60   CK_GetObjCProperty,
61     
62   /// CK_NoOp - A conversion which does not affect the type other than
63   /// (possibly) adding qualifiers.
64   ///   int    -> int
65   ///   char** -> const char * const *
66   CK_NoOp,
67
68   /// CK_BaseToDerived - A conversion from a C++ class pointer/reference
69   /// to a derived class pointer/reference.
70   ///   B *b = static_cast<B*>(a);
71   CK_BaseToDerived,
72
73   /// CK_DerivedToBase - A conversion from a C++ class pointer
74   /// to a base class pointer.
75   ///   A *a = new B();
76   CK_DerivedToBase,
77
78   /// CK_UncheckedDerivedToBase - A conversion from a C++ class
79   /// pointer/reference to a base class that can assume that the
80   /// derived pointer is not null.
81   ///   const A &a = B();
82   ///   b->method_from_a();
83   CK_UncheckedDerivedToBase,
84
85   /// CK_Dynamic - A C++ dynamic_cast.
86   CK_Dynamic,
87
88   /// CK_ToUnion - The GCC cast-to-union extension.
89   ///   int   -> union { int x; float y; }
90   ///   float -> union { int x; float y; }
91   CK_ToUnion,
92
93   /// CK_ArrayToPointerDecay - Array to pointer decay.
94   ///   int[10] -> int*
95   ///   char[5][6] -> char(*)[6]
96   CK_ArrayToPointerDecay,
97
98   /// CK_FunctionToPointerDecay - Function to pointer decay.
99   ///   void(int) -> void(*)(int)
100   CK_FunctionToPointerDecay,
101
102   /// CK_NullToPointer - Null pointer constant to pointer, ObjC
103   /// pointer, or block pointer.
104   ///   (void*) 0
105   ///   void (^block)() = 0;
106   CK_NullToPointer,
107
108   /// CK_NullToMemberPointer - Null pointer constant to member pointer.
109   ///   int A::*mptr = 0;
110   ///   int (A::*fptr)(int) = nullptr;
111   CK_NullToMemberPointer,
112
113   /// CK_BaseToDerivedMemberPointer - Member pointer in base class to
114   /// member pointer in derived class.
115   ///   int B::*mptr = &A::member;
116   CK_BaseToDerivedMemberPointer,
117
118   /// CK_DerivedToBaseMemberPointer - Member pointer in derived class to
119   /// member pointer in base class.
120   ///   int A::*mptr = static_cast<int A::*>(&B::member);
121   CK_DerivedToBaseMemberPointer,
122     
123   /// CK_MemberPointerToBoolean - Member pointer to boolean.  A check
124   /// against the null member pointer.
125   CK_MemberPointerToBoolean,
126
127   /// CK_UserDefinedConversion - Conversion using a user defined type
128   /// conversion function.
129   ///    struct A { operator int(); }; int i = int(A());
130   CK_UserDefinedConversion,
131
132   /// CK_ConstructorConversion - Conversion by constructor.
133   ///    struct A { A(int); }; A a = A(10);
134   CK_ConstructorConversion,
135     
136   /// CK_IntegralToPointer - Integral to pointer.  A special kind of
137   /// reinterpreting conversion.  Applies to normal, ObjC, and block
138   /// pointers.
139   ///    (char*) 0x1001aab0
140   ///    reinterpret_cast<int*>(0)
141   CK_IntegralToPointer,
142     
143   /// CK_PointerToIntegral - Pointer to integral.  A special kind of
144   /// reinterpreting conversion.  Applies to normal, ObjC, and block
145   /// pointers.
146   ///    (intptr_t) "help!"
147   CK_PointerToIntegral,
148
149   /// CK_PointerToBoolean - Pointer to boolean conversion.  A check
150   /// against null.  Applies to normal, ObjC, and block pointers.
151   CK_PointerToBoolean,
152     
153   /// CK_ToVoid - Cast to void, discarding the computed value.
154   ///    (void) malloc(2048)
155   CK_ToVoid,
156     
157   /// CK_VectorSplat - A conversion from an arithmetic type to a
158   /// vector of that element type.  Fills all elements ("splats") with
159   /// the source value.
160   ///    __attribute__((ext_vector_type(4))) int v = 5;
161   CK_VectorSplat,
162     
163   /// CK_IntegralCast - A cast between integral types (other than to
164   /// boolean).  Variously a bitcast, a truncation, a sign-extension,
165   /// or a zero-extension.
166   ///    long l = 5;
167   ///    (unsigned) i
168   CK_IntegralCast,
169
170   /// CK_IntegralToBoolean - Integral to boolean.  A check against zero.
171   ///    (bool) i
172   CK_IntegralToBoolean,
173
174   /// CK_IntegralToFloating - Integral to floating point.
175   ///    float f = i;
176   CK_IntegralToFloating,
177     
178   /// CK_FloatingToIntegral - Floating point to integral.  Rounds
179   /// towards zero, discarding any fractional component.
180   ///    (int) f
181   CK_FloatingToIntegral,
182
183   /// CK_FloatingToBoolean - Floating point to boolean.
184   ///    (bool) f
185   CK_FloatingToBoolean,
186     
187   /// CK_FloatingCast - Casting between floating types of different size.
188   ///    (double) f
189   ///    (float) ld
190   CK_FloatingCast,
191     
192   /// CK_CPointerToObjCPointerCast - Casting a C pointer kind to an
193   /// Objective-C pointer.
194   CK_CPointerToObjCPointerCast,
195
196   /// CK_BlockPointerToObjCPointerCast - Casting a block pointer to an
197   /// ObjC pointer.
198   CK_BlockPointerToObjCPointerCast,
199
200   /// CK_AnyPointerToBlockPointerCast - Casting any non-block pointer
201   /// to a block pointer.  Block-to-block casts are bitcasts.
202   CK_AnyPointerToBlockPointerCast,
203
204   /// \brief Converting between two Objective-C object types, which
205   /// can occur when performing reference binding to an Objective-C
206   /// object.
207   CK_ObjCObjectLValueCast,
208
209   /// \brief A conversion of a floating point real to a floating point
210   /// complex of the original type.  Injects the value as the real
211   /// component with a zero imaginary component.
212   ///   float -> _Complex float
213   CK_FloatingRealToComplex,
214
215   /// \brief Converts a floating point complex to floating point real
216   /// of the source's element type.  Just discards the imaginary
217   /// component.
218   ///   _Complex long double -> long double
219   CK_FloatingComplexToReal,
220
221   /// \brief Converts a floating point complex to bool by comparing
222   /// against 0+0i.
223   CK_FloatingComplexToBoolean,
224
225   /// \brief Converts between different floating point complex types.
226   ///   _Complex float -> _Complex double
227   CK_FloatingComplexCast,
228
229   /// \brief Converts from a floating complex to an integral complex.
230   ///   _Complex float -> _Complex int
231   CK_FloatingComplexToIntegralComplex,
232
233   /// \brief Converts from an integral real to an integral complex
234   /// whose element type matches the source.  Injects the value as
235   /// the real component with a zero imaginary component.
236   ///   long -> _Complex long
237   CK_IntegralRealToComplex,
238
239   /// \brief Converts an integral complex to an integral real of the
240   /// source's element type by discarding the imaginary component.
241   ///   _Complex short -> short
242   CK_IntegralComplexToReal,
243
244   /// \brief Converts an integral complex to bool by comparing against
245   /// 0+0i.
246   CK_IntegralComplexToBoolean,
247
248   /// \brief Converts between different integral complex types.
249   ///   _Complex char -> _Complex long long
250   ///   _Complex unsigned int -> _Complex signed int
251   CK_IntegralComplexCast,
252
253   /// \brief Converts from an integral complex to a floating complex.
254   ///   _Complex unsigned -> _Complex float
255   CK_IntegralComplexToFloatingComplex,
256
257   /// \brief [ARC] Produces a retainable object pointer so that it may
258   /// be consumed, e.g. by being passed to a consuming parameter.
259   /// Calls objc_retain.
260   CK_ARCProduceObject,
261
262   /// \brief [ARC] Consumes a retainable object pointer that has just
263   /// been produced, e.g. as the return value of a retaining call.
264   /// Enters a cleanup to call objc_release at some indefinite time.
265   CK_ARCConsumeObject,
266
267   /// \brief [ARC] Reclaim a retainable object pointer object that may
268   /// have been produced and autoreleased as part of a function return
269   /// sequence.
270   CK_ARCReclaimReturnedObject,
271
272   /// \brief [ARC] Causes a value of block type to be copied to the
273   /// heap, if it is not already there.  A number of other operations
274   /// in ARC cause blocks to be copied; this is for cases where that
275   /// would not otherwise be guaranteed, such as when casting to a
276   /// non-block pointer type.
277   CK_ARCExtendBlockObject
278 };
279
280 #define CK_Invalid ((CastKind) -1)
281
282 enum BinaryOperatorKind {
283   // Operators listed in order of precedence.
284   // Note that additions to this should also update the StmtVisitor class.
285   BO_PtrMemD, BO_PtrMemI,       // [C++ 5.5] Pointer-to-member operators.
286   BO_Mul, BO_Div, BO_Rem,       // [C99 6.5.5] Multiplicative operators.
287   BO_Add, BO_Sub,               // [C99 6.5.6] Additive operators.
288   BO_Shl, BO_Shr,               // [C99 6.5.7] Bitwise shift operators.
289   BO_LT, BO_GT, BO_LE, BO_GE,   // [C99 6.5.8] Relational operators.
290   BO_EQ, BO_NE,                 // [C99 6.5.9] Equality operators.
291   BO_And,                       // [C99 6.5.10] Bitwise AND operator.
292   BO_Xor,                       // [C99 6.5.11] Bitwise XOR operator.
293   BO_Or,                        // [C99 6.5.12] Bitwise OR operator.
294   BO_LAnd,                      // [C99 6.5.13] Logical AND operator.
295   BO_LOr,                       // [C99 6.5.14] Logical OR operator.
296   BO_Assign, BO_MulAssign,      // [C99 6.5.16] Assignment operators.
297   BO_DivAssign, BO_RemAssign,
298   BO_AddAssign, BO_SubAssign,
299   BO_ShlAssign, BO_ShrAssign,
300   BO_AndAssign, BO_XorAssign,
301   BO_OrAssign,
302   BO_Comma                      // [C99 6.5.17] Comma operator.
303 };
304
305 enum UnaryOperatorKind {
306   // Note that additions to this should also update the StmtVisitor class.
307   UO_PostInc, UO_PostDec, // [C99 6.5.2.4] Postfix increment and decrement
308   UO_PreInc, UO_PreDec,   // [C99 6.5.3.1] Prefix increment and decrement
309   UO_AddrOf, UO_Deref,    // [C99 6.5.3.2] Address and indirection
310   UO_Plus, UO_Minus,      // [C99 6.5.3.3] Unary arithmetic
311   UO_Not, UO_LNot,        // [C99 6.5.3.3] Unary arithmetic
312   UO_Real, UO_Imag,       // "__real expr"/"__imag expr" Extension.
313   UO_Extension            // __extension__ marker.
314 };
315
316 /// \brief The kind of bridging performed by the Objective-C bridge cast.
317 enum ObjCBridgeCastKind {
318   /// \brief Bridging via __bridge, which does nothing but reinterpret
319   /// the bits.
320   OBC_Bridge,
321   /// \brief Bridging via __bridge_transfer, which transfers ownership of an
322   /// Objective-C pointer into ARC.
323   OBC_BridgeTransfer,
324   /// \brief Bridging via __bridge_retain, which makes an ARC object available
325   /// as a +1 C pointer.
326   OBC_BridgeRetained
327 };
328
329 }
330
331 #endif