clang  3.8.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_BooleanToSignedIntegral - Convert a boolean to -1 or 0 for true and
190  // false, respectively.
192 
193  /// CK_FloatingCast - Casting between floating types of different size.
194  /// (double) f
195  /// (float) ld
197 
198  /// CK_CPointerToObjCPointerCast - Casting a C pointer kind to an
199  /// Objective-C pointer.
201 
202  /// CK_BlockPointerToObjCPointerCast - Casting a block pointer to an
203  /// ObjC pointer.
205 
206  /// CK_AnyPointerToBlockPointerCast - Casting any non-block pointer
207  /// to a block pointer. Block-to-block casts are bitcasts.
209 
210  /// \brief Converting between two Objective-C object types, which
211  /// can occur when performing reference binding to an Objective-C
212  /// object.
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
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
226 
227  /// \brief Converts a floating point complex to bool by comparing
228  /// against 0+0i.
230 
231  /// \brief Converts between different floating point complex types.
232  /// _Complex float -> _Complex double
234 
235  /// \brief Converts from a floating complex to an integral complex.
236  /// _Complex float -> _Complex int
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
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
249 
250  /// \brief Converts an integral complex to bool by comparing against
251  /// 0+0i.
253 
254  /// \brief Converts between different integral complex types.
255  /// _Complex char -> _Complex long long
256  /// _Complex unsigned int -> _Complex signed int
258 
259  /// \brief Converts from an integral complex to a floating complex.
260  /// _Complex unsigned -> _Complex float
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.
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.
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.
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.
284 
285  /// \brief Converts from _Atomic(T) to T.
287  /// \brief Converts from T to _Atomic(T).
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.
296 
297  // Convert a builtin function to a function pointer; only allowed in the
298  // callee of a call expression.
300 
301  // Convert a zero value for OpenCL event_t initialization.
303 
304  // Convert a pointer to a different address space.
306 };
307 
308 static const CastKind CK_Invalid = static_cast<CastKind>(-1);
309 
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.
330  BO_Comma // [C99 6.5.17] Comma operator.
331 };
332 
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.
347  /// \brief Bridging via __bridge, which does nothing but reinterpret
348  /// the bits.
350  /// \brief Bridging via __bridge_transfer, which transfers ownership of an
351  /// Objective-C pointer into ARC.
353  /// \brief Bridging via __bridge_retain, which makes an ARC object available
354  /// as a +1 C pointer.
356 };
357 
358 }
359 
360 #endif
CK_LValueToRValue - A conversion which causes the extraction of an r-value from the operand gl-value...
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.
CK_ToUnion - The GCC cast-to-union extension.
CK_BaseToDerivedMemberPointer - Member pointer in base class to member pointer in derived class...
CK_FloatingToIntegral - Floating point to integral.
[ARC] Consumes a retainable object pointer that has just been produced, e.g.
CK_IntegralToFloating - Integral to floating point.
CK_IntegralCast - A cast between integral types (other than to boolean).
CK_Dynamic - A C++ dynamic_cast.
CK_Dependent - A conversion which cannot yet be analyzed because either the expression or target type...
Converts between different integral complex types.
Converting between two Objective-C object types, which can occur when performing reference binding to...
CK_FloatingCast - Casting between floating types of different size.
[ARC] Causes a value of block type to be copied to the heap, if it is not already there...
CK_VectorSplat - A conversion from an arithmetic type to a vector of that element type...
CK_NullToPointer - Null pointer constant to pointer, ObjC pointer, or block pointer.
CK_PointerToIntegral - Pointer to integral.
CK_IntegralToPointer - Integral to pointer.
Converts a floating point complex to bool by comparing against 0+0i.
CK_IntegralToBoolean - Integral to boolean.
BinaryOperatorKind
Bridging via __bridge_transfer, which transfers ownership of an Objective-C pointer into ARC...
CK_AnyPointerToBlockPointerCast - Casting any non-block pointer to a block pointer.
Causes a block literal to by copied to the heap and then autoreleased.
CastKind
CastKind - The kind of operation required for a conversion.
CK_FunctionToPointerDecay - Function to pointer decay.
Converts between different floating point complex types.
CK_PointerToBoolean - Pointer to boolean conversion.
Converts an integral complex to an integral real of the source's element type by discarding the imagi...
CK_BitCast - A conversion which causes a bit pattern of one type to be reinterpreted as a bit pattern...
CK_ConstructorConversion - Conversion by constructor.
Converts from an integral complex to a floating complex.
CK_ArrayToPointerDecay - Array to pointer decay.
CK_CPointerToObjCPointerCast - Casting a C pointer kind to an Objective-C pointer.
CK_UserDefinedConversion - Conversion using a user defined type conversion function.
CK_NullToMemberPointer - Null pointer constant to member pointer.
CK_ReinterpretMemberPointer - Reinterpret a member pointer as a different kind of member pointer...
CK_DerivedToBase - A conversion from a C++ class pointer to a base class pointer. ...
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.
Converts an integral complex to bool by comparing against 0+0i.
CK_BaseToDerived - A conversion from a C++ class pointer/reference to a derived class pointer/referen...
CK_BlockPointerToObjCPointerCast - Casting a block pointer to an ObjC pointer.
A conversion of a floating point real to a floating point complex of the original type...
CK_MemberPointerToBoolean - Member pointer to boolean.
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.
CK_LValueBitCast - A conversion which reinterprets the address of an l-value as an l-value of a diffe...
Converts from T to _Atomic(T).
Converts from a floating complex to an integral complex.
CK_UncheckedDerivedToBase - A conversion from a C++ class pointer/reference to a base class that can ...
Converts from _Atomic(T) to T.
CK_NoOp - A conversion which does not affect the type other than (possibly) adding qualifiers...
CK_DerivedToBaseMemberPointer - Member pointer in derived class to member pointer in base class...
CK_ToVoid - Cast to void, discarding the computed value.
CK_FloatingToBoolean - Floating point to boolean.