clang  3.7.0
OperationKinds.h
Go to the documentation of this file.
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());
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.
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';
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.
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 *
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);
65 
66  /// CK_DerivedToBase - A conversion from a C++ class pointer
67  /// to a base class pointer.
68  /// A *a = new B();
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();
77 
78  /// CK_Dynamic - A C++ dynamic_cast.
80 
81  /// CK_ToUnion - The GCC cast-to-union extension.
82  /// int -> union { int x; float y; }
83  /// float -> union { int x; float y; }
85 
86  /// CK_ArrayToPointerDecay - Array to pointer decay.
87  /// int[10] -> int*
88  /// char[5][6] -> char(*)[6]
90 
91  /// CK_FunctionToPointerDecay - Function to pointer decay.
92  /// void(int) -> void(*)(int)
94 
95  /// CK_NullToPointer - Null pointer constant to pointer, ObjC
96  /// pointer, or block pointer.
97  /// (void*) 0
98  /// void (^block)() = 0;
100 
101  /// CK_NullToMemberPointer - Null pointer constant to member pointer.
102  /// int A::*mptr = 0;
103  /// int (A::*fptr)(int) = nullptr;
105 
106  /// CK_BaseToDerivedMemberPointer - Member pointer in base class to
107  /// member pointer in derived class.
108  /// int B::*mptr = &A::member;
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);
115 
116  /// CK_MemberPointerToBoolean - Member pointer to boolean. A check
117  /// against the null member pointer.
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).
128 
129  /// CK_UserDefinedConversion - Conversion using a user defined type
130  /// conversion function.
131  /// struct A { operator int(); }; int i = int(A());
133 
134  /// CK_ConstructorConversion - Conversion by constructor.
135  /// struct A { A(int); }; A a = A(10);
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)
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!"
150 
151  /// CK_PointerToBoolean - Pointer to boolean conversion. A check
152  /// against null. Applies to normal, ObjC, and block pointers.
154 
155  /// CK_ToVoid - Cast to void, discarding the computed value.
156  /// (void) malloc(2048)
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;
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
171 
172  /// CK_IntegralToBoolean - Integral to boolean. A check against zero.
173  /// (bool) i
175 
176  /// CK_IntegralToFloating - Integral to floating point.
177  /// float f = i;
179 
180  /// CK_FloatingToIntegral - Floating point to integral. Rounds
181  /// towards zero, discarding any fractional component.
182  /// (int) f
184 
185  /// CK_FloatingToBoolean - Floating point to boolean.
186  /// (bool) f
188 
189  /// CK_FloatingCast - Casting between floating types of different size.
190  /// (double) f
191  /// (float) ld
193 
194  /// CK_CPointerToObjCPointerCast - Casting a C pointer kind to an
195  /// Objective-C pointer.
197 
198  /// CK_BlockPointerToObjCPointerCast - Casting a block pointer to an
199  /// ObjC pointer.
201 
202  /// CK_AnyPointerToBlockPointerCast - Casting any non-block pointer
203  /// to a block pointer. Block-to-block casts are bitcasts.
205 
206  /// \brief Converting between two Objective-C object types, which
207  /// can occur when performing reference binding to an Objective-C
208  /// object.
210 
211  /// \brief A conversion of a floating point real to a floating point
212  /// complex of the original type. Injects the value as the real
213  /// component with a zero imaginary component.
214  /// float -> _Complex float
216 
217  /// \brief Converts a floating point complex to floating point real
218  /// of the source's element type. Just discards the imaginary
219  /// component.
220  /// _Complex long double -> long double
222 
223  /// \brief Converts a floating point complex to bool by comparing
224  /// against 0+0i.
226 
227  /// \brief Converts between different floating point complex types.
228  /// _Complex float -> _Complex double
230 
231  /// \brief Converts from a floating complex to an integral complex.
232  /// _Complex float -> _Complex int
234 
235  /// \brief Converts from an integral real to an integral complex
236  /// whose element type matches the source. Injects the value as
237  /// the real component with a zero imaginary component.
238  /// long -> _Complex long
240 
241  /// \brief Converts an integral complex to an integral real of the
242  /// source's element type by discarding the imaginary component.
243  /// _Complex short -> short
245 
246  /// \brief Converts an integral complex to bool by comparing against
247  /// 0+0i.
249 
250  /// \brief Converts between different integral complex types.
251  /// _Complex char -> _Complex long long
252  /// _Complex unsigned int -> _Complex signed int
254 
255  /// \brief Converts from an integral complex to a floating complex.
256  /// _Complex unsigned -> _Complex float
258 
259  /// \brief [ARC] Produces a retainable object pointer so that it may
260  /// be consumed, e.g. by being passed to a consuming parameter.
261  /// Calls objc_retain.
263 
264  /// \brief [ARC] Consumes a retainable object pointer that has just
265  /// been produced, e.g. as the return value of a retaining call.
266  /// Enters a cleanup to call objc_release at some indefinite time.
268 
269  /// \brief [ARC] Reclaim a retainable object pointer object that may
270  /// have been produced and autoreleased as part of a function return
271  /// sequence.
273 
274  /// \brief [ARC] Causes a value of block type to be copied to the
275  /// heap, if it is not already there. A number of other operations
276  /// in ARC cause blocks to be copied; this is for cases where that
277  /// would not otherwise be guaranteed, such as when casting to a
278  /// non-block pointer type.
280 
281  /// \brief Converts from _Atomic(T) to T.
283  /// \brief Converts from T to _Atomic(T).
285 
286  /// \brief Causes a block literal to by copied to the heap and then
287  /// autoreleased.
288  ///
289  /// This particular cast kind is used for the conversion from a C++11
290  /// lambda expression to a block pointer.
292 
293  // Convert a builtin function to a function pointer; only allowed in the
294  // callee of a call expression.
296 
297  // Convert a zero value for OpenCL event_t initialization.
299 
300  // Convert a pointer to a different address space.
302 };
303 
304 static const CastKind CK_Invalid = static_cast<CastKind>(-1);
305 
307  // Operators listed in order of precedence.
308  // Note that additions to this should also update the StmtVisitor class.
309  BO_PtrMemD, BO_PtrMemI, // [C++ 5.5] Pointer-to-member operators.
310  BO_Mul, BO_Div, BO_Rem, // [C99 6.5.5] Multiplicative operators.
311  BO_Add, BO_Sub, // [C99 6.5.6] Additive operators.
312  BO_Shl, BO_Shr, // [C99 6.5.7] Bitwise shift operators.
313  BO_LT, BO_GT, BO_LE, BO_GE, // [C99 6.5.8] Relational operators.
314  BO_EQ, BO_NE, // [C99 6.5.9] Equality operators.
315  BO_And, // [C99 6.5.10] Bitwise AND operator.
316  BO_Xor, // [C99 6.5.11] Bitwise XOR operator.
317  BO_Or, // [C99 6.5.12] Bitwise OR operator.
318  BO_LAnd, // [C99 6.5.13] Logical AND operator.
319  BO_LOr, // [C99 6.5.14] Logical OR operator.
320  BO_Assign, BO_MulAssign, // [C99 6.5.16] Assignment operators.
326  BO_Comma // [C99 6.5.17] Comma operator.
327 };
328 
330  // Note that additions to this should also update the StmtVisitor class.
331  UO_PostInc, UO_PostDec, // [C99 6.5.2.4] Postfix increment and decrement
332  UO_PreInc, UO_PreDec, // [C99 6.5.3.1] Prefix increment and decrement
333  UO_AddrOf, UO_Deref, // [C99 6.5.3.2] Address and indirection
334  UO_Plus, UO_Minus, // [C99 6.5.3.3] Unary arithmetic
335  UO_Not, UO_LNot, // [C99 6.5.3.3] Unary arithmetic
336  UO_Real, UO_Imag, // "__real expr"/"__imag expr" Extension.
337  UO_Extension // __extension__ marker.
338 };
339 
340 /// \brief The kind of bridging performed by the Objective-C bridge cast.
342  /// \brief Bridging via __bridge, which does nothing but reinterpret
343  /// the bits.
345  /// \brief Bridging via __bridge_transfer, which transfers ownership of an
346  /// Objective-C pointer into ARC.
348  /// \brief Bridging via __bridge_retain, which makes an ARC object available
349  /// as a +1 C pointer.
351 };
352 
353 }
354 
355 #endif
static const CastKind CK_Invalid
ObjCBridgeCastKind
The kind of bridging performed by the Objective-C bridge cast.
Bridging via __bridge, which does nothing but reinterpret the bits.
[ARC] Consumes a retainable object pointer that has just been produced, e.g. as the return value of a...
CK_Dynamic - A C++ dynamic_cast.
Converts between different integral complex types. _Complex char -> _Complex long long _Complex unsig...
Converting between two Objective-C object types, which can occur when performing reference binding to...
[ARC] Causes a value of block type to be copied to the heap, if it is not already there...
Converts a floating point complex to bool by comparing against 0+0i.
BinaryOperatorKind
Bridging via __bridge_transfer, which transfers ownership of an Objective-C pointer into ARC...
Causes a block literal to by copied to the heap and then autoreleased.
CastKind
CastKind - The kind of operation required for a conversion.
Converts between different floating point complex types. _Complex float -> _Complex double...
Converts an integral complex to an integral real of the source's element type by discarding the imagi...
Converts from an integral complex to a floating complex. _Complex unsigned -> _Complex float...
Converts from an integral real to an integral complex whose element type matches the source...
Converts a floating point complex to floating point real of the source's element type. Just discards the imaginary component. _Complex long double -> long double.
Converts an integral complex to bool by comparing against 0+0i.
A conversion of a floating point real to a floating point complex of the original type...
Bridging via __bridge_retain, which makes an ARC object available as a +1 C pointer.
[ARC] Reclaim a retainable object pointer object that may have been produced and autoreleased as part...
[ARC] Produces a retainable object pointer so that it may be consumed, e.g. by being passed to a cons...
Converts from T to _Atomic(T).
Converts from a floating complex to an integral complex. _Complex float -> _Complex int...
Converts from _Atomic(T) to T.