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