]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/clang/include/clang/AST/OperationKinds.def
Merge r357872 from the clang1000-import branch:
[FreeBSD/FreeBSD.git] / contrib / llvm-project / clang / include / clang / AST / OperationKinds.def
1 //===--- OperationKinds.def - Operations Database ---------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file enumerates the different kinds of operations that can be
10 // performed by various expressions.
11 //
12 //===----------------------------------------------------------------------===//
13 //
14 /// @file OperationKinds.def
15 ///
16 /// In this file, each of the C/C++ operations is enumerated CAST_OPERATION,
17 /// BINARY_OPERATION or UNARY_OPERATION macro, each of which can be specified by
18 /// the code including this file.
19 ///
20 /// Macros had one or two arguments:
21 ///
22 /// Name: The name of the operation. Name (prefixed with CK_, UO_ or BO_) will
23 /// be the name of the corresponding enumerator (see OperationsKinds.h).
24 ///
25 /// Spelling: A string that provides a canonical spelling for the operation.
26
27 #ifndef CAST_OPERATION
28 #  define CAST_OPERATION(Name)
29 #endif
30
31 #ifndef BINARY_OPERATION
32 #  define BINARY_OPERATION(Name, Spelling)
33 #endif
34
35 #ifndef UNARY_OPERATION
36 #  define UNARY_OPERATION(Name, Spelling)
37 #endif
38
39 //===- Cast Operations  ---------------------------------------------------===//
40
41 /// CK_Dependent - A conversion which cannot yet be analyzed because
42 /// either the expression or target type is dependent.  These are
43 /// created only for explicit casts; dependent ASTs aren't required
44 /// to even approximately type-check.
45 ///   (T*) malloc(sizeof(T))
46 ///   reinterpret_cast<intptr_t>(A<T>::alloc());
47 CAST_OPERATION(Dependent)
48
49 /// CK_BitCast - A conversion which causes a bit pattern of one type
50 /// to be reinterpreted as a bit pattern of another type.  Generally
51 /// the operands must have equivalent size and unrelated types.
52 ///
53 /// The pointer conversion char* -> int* is a bitcast.  A conversion
54 /// from any pointer type to a C pointer type is a bitcast unless
55 /// it's actually BaseToDerived or DerivedToBase.  A conversion to a
56 /// block pointer or ObjC pointer type is a bitcast only if the
57 /// operand has the same type kind; otherwise, it's one of the
58 /// specialized casts below.
59 ///
60 /// Vector coercions are bitcasts.
61 CAST_OPERATION(BitCast)
62
63 /// CK_LValueBitCast - A conversion which reinterprets the address of
64 /// an l-value as an l-value of a different kind.  Used for
65 /// reinterpret_casts of l-value expressions to reference types.
66 ///    bool b; reinterpret_cast<char&>(b) = 'a';
67 CAST_OPERATION(LValueBitCast)
68
69 /// CK_LValueToRValueBitCast - A conversion that causes us to reinterpret an
70 /// lvalue as an rvalue of a different type. Created by __builtin_bit_cast.
71 CAST_OPERATION(LValueToRValueBitCast)
72
73 /// CK_LValueToRValue - A conversion which causes the extraction of
74 /// an r-value from the operand gl-value.  The result of an r-value
75 /// conversion is always unqualified.
76 CAST_OPERATION(LValueToRValue)
77
78 /// CK_NoOp - A conversion which does not affect the type other than
79 /// (possibly) adding qualifiers.
80 ///   int    -> int
81 ///   char** -> const char * const *
82 CAST_OPERATION(NoOp)
83
84 /// CK_BaseToDerived - A conversion from a C++ class pointer/reference
85 /// to a derived class pointer/reference.
86 ///   B *b = static_cast<B*>(a);
87 CAST_OPERATION(BaseToDerived)
88
89 /// CK_DerivedToBase - A conversion from a C++ class pointer
90 /// to a base class pointer.
91 ///   A *a = new B();
92 CAST_OPERATION(DerivedToBase)
93
94 /// CK_UncheckedDerivedToBase - A conversion from a C++ class
95 /// pointer/reference to a base class that can assume that the
96 /// derived pointer is not null.
97 ///   const A &a = B();
98 ///   b->method_from_a();
99 CAST_OPERATION(UncheckedDerivedToBase)
100
101 /// CK_Dynamic - A C++ dynamic_cast.
102 CAST_OPERATION(Dynamic)
103
104 /// CK_ToUnion - The GCC cast-to-union extension.
105 ///   int   -> union { int x; float y; }
106 ///   float -> union { int x; float y; }
107 CAST_OPERATION(ToUnion)
108
109 /// CK_ArrayToPointerDecay - Array to pointer decay.
110 ///   int[10] -> int*
111 ///   char[5][6] -> char(*)[6]
112 CAST_OPERATION(ArrayToPointerDecay)
113
114 /// CK_FunctionToPointerDecay - Function to pointer decay.
115 ///   void(int) -> void(*)(int)
116 CAST_OPERATION(FunctionToPointerDecay)
117
118 /// CK_NullToPointer - Null pointer constant to pointer, ObjC
119 /// pointer, or block pointer.
120 ///   (void*) 0
121 ///   void (^block)() = 0;
122 CAST_OPERATION(NullToPointer)
123
124 /// CK_NullToMemberPointer - Null pointer constant to member pointer.
125 ///   int A::*mptr = 0;
126 ///   int (A::*fptr)(int) = nullptr;
127 CAST_OPERATION(NullToMemberPointer)
128
129 /// CK_BaseToDerivedMemberPointer - Member pointer in base class to
130 /// member pointer in derived class.
131 ///   int B::*mptr = &A::member;
132 CAST_OPERATION(BaseToDerivedMemberPointer)
133
134 /// CK_DerivedToBaseMemberPointer - Member pointer in derived class to
135 /// member pointer in base class.
136 ///   int A::*mptr = static_cast<int A::*>(&B::member);
137 CAST_OPERATION(DerivedToBaseMemberPointer)
138
139 /// CK_MemberPointerToBoolean - Member pointer to boolean.  A check
140 /// against the null member pointer.
141 CAST_OPERATION(MemberPointerToBoolean)
142
143 /// CK_ReinterpretMemberPointer - Reinterpret a member pointer as a
144 /// different kind of member pointer.  C++ forbids this from
145 /// crossing between function and object types, but otherwise does
146 /// not restrict it.  However, the only operation that is permitted
147 /// on a "punned" member pointer is casting it back to the original
148 /// type, which is required to be a lossless operation (although
149 /// many ABIs do not guarantee this on all possible intermediate types).
150 CAST_OPERATION(ReinterpretMemberPointer)
151
152 /// CK_UserDefinedConversion - Conversion using a user defined type
153 /// conversion function.
154 ///    struct A { operator int(); }; int i = int(A());
155 CAST_OPERATION(UserDefinedConversion)
156
157 /// CK_ConstructorConversion - Conversion by constructor.
158 ///    struct A { A(int); }; A a = A(10);
159 CAST_OPERATION(ConstructorConversion)
160
161 /// CK_IntegralToPointer - Integral to pointer.  A special kind of
162 /// reinterpreting conversion.  Applies to normal, ObjC, and block
163 /// pointers.
164 ///    (char*) 0x1001aab0
165 ///    reinterpret_cast<int*>(0)
166 CAST_OPERATION(IntegralToPointer)
167
168 /// CK_PointerToIntegral - Pointer to integral.  A special kind of
169 /// reinterpreting conversion.  Applies to normal, ObjC, and block
170 /// pointers.
171 ///    (intptr_t) "help!"
172 CAST_OPERATION(PointerToIntegral)
173
174 /// CK_PointerToBoolean - Pointer to boolean conversion.  A check
175 /// against null.  Applies to normal, ObjC, and block pointers.
176 CAST_OPERATION(PointerToBoolean)
177
178 /// CK_ToVoid - Cast to void, discarding the computed value.
179 ///    (void) malloc(2048)
180 CAST_OPERATION(ToVoid)
181
182 /// CK_VectorSplat - A conversion from an arithmetic type to a
183 /// vector of that element type.  Fills all elements ("splats") with
184 /// the source value.
185 ///    __attribute__((ext_vector_type(4))) int v = 5;
186 CAST_OPERATION(VectorSplat)
187
188 /// CK_IntegralCast - A cast between integral types (other than to
189 /// boolean).  Variously a bitcast, a truncation, a sign-extension,
190 /// or a zero-extension.
191 ///    long l = 5;
192 ///    (unsigned) i
193 CAST_OPERATION(IntegralCast)
194
195 /// CK_IntegralToBoolean - Integral to boolean.  A check against zero.
196 ///    (bool) i
197 CAST_OPERATION(IntegralToBoolean)
198
199 /// CK_IntegralToFloating - Integral to floating point.
200 ///    float f = i;
201 CAST_OPERATION(IntegralToFloating)
202
203 /// CK_FixedPointCast - Fixed point to fixed point.
204 ///    (_Accum) 0.5r
205 CAST_OPERATION(FixedPointCast)
206
207 /// CK_FixedPointToIntegral - Fixed point to integral.
208 ///    (int) 2.0k
209 CAST_OPERATION(FixedPointToIntegral)
210
211 /// CK_IntegralToFixedPoint - Integral to a fixed point.
212 ///    (_Accum) 2
213 CAST_OPERATION(IntegralToFixedPoint)
214
215 /// CK_FixedPointToBoolean - Fixed point to boolean.
216 ///    (bool) 0.5r
217 CAST_OPERATION(FixedPointToBoolean)
218
219 /// CK_FloatingToIntegral - Floating point to integral.  Rounds
220 /// towards zero, discarding any fractional component.
221 ///    (int) f
222 CAST_OPERATION(FloatingToIntegral)
223
224 /// CK_FloatingToBoolean - Floating point to boolean.
225 ///    (bool) f
226 CAST_OPERATION(FloatingToBoolean)
227
228 // CK_BooleanToSignedIntegral - Convert a boolean to -1 or 0 for true and
229 // false, respectively.
230 CAST_OPERATION(BooleanToSignedIntegral)
231
232 /// CK_FloatingCast - Casting between floating types of different size.
233 ///    (double) f
234 ///    (float) ld
235 CAST_OPERATION(FloatingCast)
236
237 /// CK_CPointerToObjCPointerCast - Casting a C pointer kind to an
238 /// Objective-C pointer.
239 CAST_OPERATION(CPointerToObjCPointerCast)
240
241 /// CK_BlockPointerToObjCPointerCast - Casting a block pointer to an
242 /// ObjC pointer.
243 CAST_OPERATION(BlockPointerToObjCPointerCast)
244
245 /// CK_AnyPointerToBlockPointerCast - Casting any non-block pointer
246 /// to a block pointer.  Block-to-block casts are bitcasts.
247 CAST_OPERATION(AnyPointerToBlockPointerCast)
248
249 /// Converting between two Objective-C object types, which
250 /// can occur when performing reference binding to an Objective-C
251 /// object.
252 CAST_OPERATION(ObjCObjectLValueCast)
253
254 /// A conversion of a floating point real to a floating point
255 /// complex of the original type.  Injects the value as the real
256 /// component with a zero imaginary component.
257 ///   float -> _Complex float
258 CAST_OPERATION(FloatingRealToComplex)
259
260 /// Converts a floating point complex to floating point real
261 /// of the source's element type.  Just discards the imaginary
262 /// component.
263 ///   _Complex long double -> long double
264 CAST_OPERATION(FloatingComplexToReal)
265
266 /// Converts a floating point complex to bool by comparing
267 /// against 0+0i.
268 CAST_OPERATION(FloatingComplexToBoolean)
269
270 /// Converts between different floating point complex types.
271 ///   _Complex float -> _Complex double
272 CAST_OPERATION(FloatingComplexCast)
273
274 /// Converts from a floating complex to an integral complex.
275 ///   _Complex float -> _Complex int
276 CAST_OPERATION(FloatingComplexToIntegralComplex)
277
278 /// Converts from an integral real to an integral complex
279 /// whose element type matches the source.  Injects the value as
280 /// the real component with a zero imaginary component.
281 ///   long -> _Complex long
282 CAST_OPERATION(IntegralRealToComplex)
283
284 /// Converts an integral complex to an integral real of the
285 /// source's element type by discarding the imaginary component.
286 ///   _Complex short -> short
287 CAST_OPERATION(IntegralComplexToReal)
288
289 /// Converts an integral complex to bool by comparing against
290 /// 0+0i.
291 CAST_OPERATION(IntegralComplexToBoolean)
292
293 /// Converts between different integral complex types.
294 ///   _Complex char -> _Complex long long
295 ///   _Complex unsigned int -> _Complex signed int
296 CAST_OPERATION(IntegralComplexCast)
297
298 /// Converts from an integral complex to a floating complex.
299 ///   _Complex unsigned -> _Complex float
300 CAST_OPERATION(IntegralComplexToFloatingComplex)
301
302 /// [ARC] Produces a retainable object pointer so that it may
303 /// be consumed, e.g. by being passed to a consuming parameter.
304 /// Calls objc_retain.
305 CAST_OPERATION(ARCProduceObject)
306
307 /// [ARC] Consumes a retainable object pointer that has just
308 /// been produced, e.g. as the return value of a retaining call.
309 /// Enters a cleanup to call objc_release at some indefinite time.
310 CAST_OPERATION(ARCConsumeObject)
311
312 /// [ARC] Reclaim a retainable object pointer object that may
313 /// have been produced and autoreleased as part of a function return
314 /// sequence.
315 CAST_OPERATION(ARCReclaimReturnedObject)
316
317 /// [ARC] Causes a value of block type to be copied to the
318 /// heap, if it is not already there.  A number of other operations
319 /// in ARC cause blocks to be copied; this is for cases where that
320 /// would not otherwise be guaranteed, such as when casting to a
321 /// non-block pointer type.
322 CAST_OPERATION(ARCExtendBlockObject)
323
324 /// Converts from _Atomic(T) to T.
325 CAST_OPERATION(AtomicToNonAtomic)
326 /// Converts from T to _Atomic(T).
327 CAST_OPERATION(NonAtomicToAtomic)
328
329 /// Causes a block literal to by copied to the heap and then
330 /// autoreleased.
331 ///
332 /// This particular cast kind is used for the conversion from a C++11
333 /// lambda expression to a block pointer.
334 CAST_OPERATION(CopyAndAutoreleaseBlockObject)
335
336 // Convert a builtin function to a function pointer; only allowed in the
337 // callee of a call expression.
338 CAST_OPERATION(BuiltinFnToFnPtr)
339
340 // Convert a zero value for OpenCL opaque types initialization (event_t,
341 // queue_t, etc.)
342 CAST_OPERATION(ZeroToOCLOpaqueType)
343
344 // Convert a pointer to a different address space.
345 CAST_OPERATION(AddressSpaceConversion)
346
347 // Convert an integer initializer to an OpenCL sampler.
348 CAST_OPERATION(IntToOCLSampler)
349
350 //===- Binary Operations  -------------------------------------------------===//
351 // Operators listed in order of precedence.
352 // Note that additions to this should also update the StmtVisitor class and
353 // BinaryOperator::getOverloadedOperator.
354
355 // [C++ 5.5] Pointer-to-member operators.
356 BINARY_OPERATION(PtrMemD, ".*")
357 BINARY_OPERATION(PtrMemI, "->*")
358 // [C99 6.5.5] Multiplicative operators.
359 BINARY_OPERATION(Mul, "*")
360 BINARY_OPERATION(Div, "/")
361 BINARY_OPERATION(Rem, "%")
362 // [C99 6.5.6] Additive operators.
363 BINARY_OPERATION(Add, "+")
364 BINARY_OPERATION(Sub, "-")
365 // [C99 6.5.7] Bitwise shift operators.
366 BINARY_OPERATION(Shl, "<<")
367 BINARY_OPERATION(Shr, ">>")
368 // C++20 [expr.spaceship] Three-way comparison operator.
369 BINARY_OPERATION(Cmp, "<=>")
370 // [C99 6.5.8] Relational operators.
371 BINARY_OPERATION(LT, "<")
372 BINARY_OPERATION(GT, ">")
373 BINARY_OPERATION(LE, "<=")
374 BINARY_OPERATION(GE, ">=")
375 // [C99 6.5.9] Equality operators.
376 BINARY_OPERATION(EQ, "==")
377 BINARY_OPERATION(NE, "!=")
378 // [C99 6.5.10] Bitwise AND operator.
379 BINARY_OPERATION(And, "&")
380 // [C99 6.5.11] Bitwise XOR operator.
381 BINARY_OPERATION(Xor, "^")
382 // [C99 6.5.12] Bitwise OR operator.
383 BINARY_OPERATION(Or, "|")
384 // [C99 6.5.13] Logical AND operator.
385 BINARY_OPERATION(LAnd, "&&")
386 // [C99 6.5.14] Logical OR operator.
387 BINARY_OPERATION(LOr, "||")
388 // [C99 6.5.16] Assignment operators.
389 BINARY_OPERATION(Assign, "=")
390 BINARY_OPERATION(MulAssign, "*=")
391 BINARY_OPERATION(DivAssign, "/=")
392 BINARY_OPERATION(RemAssign, "%=")
393 BINARY_OPERATION(AddAssign, "+=")
394 BINARY_OPERATION(SubAssign, "-=")
395 BINARY_OPERATION(ShlAssign, "<<=")
396 BINARY_OPERATION(ShrAssign, ">>=")
397 BINARY_OPERATION(AndAssign, "&=")
398 BINARY_OPERATION(XorAssign, "^=")
399 BINARY_OPERATION(OrAssign, "|=")
400 // [C99 6.5.17] Comma operator.
401 BINARY_OPERATION(Comma, ",")
402
403
404 //===- Unary Operations ---------------------------------------------------===//
405 // Note that additions to this should also update the StmtVisitor class and
406 // UnaryOperator::getOverloadedOperator.
407
408 // [C99 6.5.2.4] Postfix increment and decrement
409 UNARY_OPERATION(PostInc, "++")
410 UNARY_OPERATION(PostDec, "--")
411 // [C99 6.5.3.1] Prefix increment and decrement
412 UNARY_OPERATION(PreInc, "++")
413 UNARY_OPERATION(PreDec, "--")
414 // [C99 6.5.3.2] Address and indirection
415 UNARY_OPERATION(AddrOf, "&")
416 UNARY_OPERATION(Deref, "*")
417 // [C99 6.5.3.3] Unary arithmetic
418 UNARY_OPERATION(Plus, "+")
419 UNARY_OPERATION(Minus, "-")
420 UNARY_OPERATION(Not, "~")
421 UNARY_OPERATION(LNot, "!")
422 // "__real expr"/"__imag expr" Extension.
423 UNARY_OPERATION(Real, "__real")
424 UNARY_OPERATION(Imag, "__imag")
425 // __extension__ marker.
426 UNARY_OPERATION(Extension, "__extension__")
427 // [C++ Coroutines] co_await operator
428 UNARY_OPERATION(Coawait, "co_await")
429
430 #undef CAST_OPERATION
431 #undef BINARY_OPERATION
432 #undef UNARY_OPERATION