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