Warning, /include/clang/AST/OperationKinds.def is written in an unsupported language. File is not indexed.
0001 //===--- OperationKinds.def - Operations Database ---------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file enumerates the different kinds of operations that can be
0010 // performed by various expressions.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 //
0014 /// @file OperationKinds.def
0015 ///
0016 /// In this file, each of the C/C++ operations is enumerated CAST_OPERATION,
0017 /// BINARY_OPERATION or UNARY_OPERATION macro, each of which can be specified by
0018 /// the code including this file.
0019 ///
0020 /// Macros had one or two arguments:
0021 ///
0022 /// Name: The name of the operation. Name (prefixed with CK_, UO_ or BO_) will
0023 /// be the name of the corresponding enumerator (see OperationsKinds.h).
0024 ///
0025 /// Spelling: A string that provides a canonical spelling for the operation.
0026
0027 #ifndef CAST_OPERATION
0028 # define CAST_OPERATION(Name)
0029 #endif
0030
0031 #ifndef BINARY_OPERATION
0032 # define BINARY_OPERATION(Name, Spelling)
0033 #endif
0034
0035 #ifndef UNARY_OPERATION
0036 # define UNARY_OPERATION(Name, Spelling)
0037 #endif
0038
0039 //===- Cast Operations ---------------------------------------------------===//
0040
0041 /// CK_Dependent - A conversion which cannot yet be analyzed because
0042 /// either the expression or target type is dependent. These are
0043 /// created only for explicit casts; dependent ASTs aren't required
0044 /// to even approximately type-check.
0045 /// (T*) malloc(sizeof(T))
0046 /// reinterpret_cast<intptr_t>(A<T>::alloc());
0047 CAST_OPERATION(Dependent)
0048
0049 /// CK_BitCast - A conversion which causes a bit pattern of one type
0050 /// to be reinterpreted as a bit pattern of another type. Generally
0051 /// the operands must have equivalent size and unrelated types.
0052 ///
0053 /// The pointer conversion char* -> int* is a bitcast. A conversion
0054 /// from any pointer type to a C pointer type is a bitcast unless
0055 /// it's actually BaseToDerived or DerivedToBase. A conversion to a
0056 /// block pointer or ObjC pointer type is a bitcast only if the
0057 /// operand has the same type kind; otherwise, it's one of the
0058 /// specialized casts below.
0059 ///
0060 /// Vector coercions are bitcasts.
0061 CAST_OPERATION(BitCast)
0062
0063 /// CK_LValueBitCast - A conversion which reinterprets the address of
0064 /// an l-value as an l-value of a different kind. Used for
0065 /// reinterpret_casts of l-value expressions to reference types.
0066 /// bool b; reinterpret_cast<char&>(b) = 'a';
0067 CAST_OPERATION(LValueBitCast)
0068
0069 /// CK_LValueToRValueBitCast - A conversion that causes us to reinterpret the
0070 /// object representation of an lvalue as an rvalue. Created by
0071 /// __builtin_bit_cast.
0072 CAST_OPERATION(LValueToRValueBitCast)
0073
0074 /// CK_LValueToRValue - A conversion which causes the extraction of
0075 /// an r-value from the operand gl-value. The result of an r-value
0076 /// conversion is always unqualified.
0077 CAST_OPERATION(LValueToRValue)
0078
0079 /// CK_NoOp - A conversion which does not affect the type other than
0080 /// (possibly) adding qualifiers or removing noexcept.
0081 /// int -> int
0082 /// char** -> const char * const *
0083 /// int[1] -> int[]
0084 /// void () noexcept -> void ()
0085 CAST_OPERATION(NoOp)
0086
0087 /// CK_BaseToDerived - A conversion from a C++ class pointer/reference
0088 /// to a derived class pointer/reference.
0089 /// B *b = static_cast<B*>(a);
0090 CAST_OPERATION(BaseToDerived)
0091
0092 /// CK_DerivedToBase - A conversion from a C++ class pointer
0093 /// to a base class pointer.
0094 /// A *a = new B();
0095 CAST_OPERATION(DerivedToBase)
0096
0097 /// CK_UncheckedDerivedToBase - A conversion from a C++ class
0098 /// pointer/reference to a base class that can assume that the
0099 /// derived pointer is not null.
0100 /// const A &a = B();
0101 /// b->method_from_a();
0102 CAST_OPERATION(UncheckedDerivedToBase)
0103
0104 /// CK_Dynamic - A C++ dynamic_cast.
0105 CAST_OPERATION(Dynamic)
0106
0107 /// CK_ToUnion - The GCC cast-to-union extension.
0108 /// int -> union { int x; float y; }
0109 /// float -> union { int x; float y; }
0110 CAST_OPERATION(ToUnion)
0111
0112 /// CK_ArrayToPointerDecay - Array to pointer decay.
0113 /// int[10] -> int*
0114 /// char[5][6] -> char(*)[6]
0115 CAST_OPERATION(ArrayToPointerDecay)
0116
0117 /// CK_FunctionToPointerDecay - Function to pointer decay.
0118 /// void(int) -> void(*)(int)
0119 CAST_OPERATION(FunctionToPointerDecay)
0120
0121 /// CK_NullToPointer - Null pointer constant to pointer, ObjC
0122 /// pointer, or block pointer.
0123 /// (void*) 0
0124 /// void (^block)() = 0;
0125 CAST_OPERATION(NullToPointer)
0126
0127 /// CK_NullToMemberPointer - Null pointer constant to member pointer.
0128 /// int A::*mptr = 0;
0129 /// int (A::*fptr)(int) = nullptr;
0130 CAST_OPERATION(NullToMemberPointer)
0131
0132 /// CK_BaseToDerivedMemberPointer - Member pointer in base class to
0133 /// member pointer in derived class.
0134 /// int B::*mptr = &A::member;
0135 CAST_OPERATION(BaseToDerivedMemberPointer)
0136
0137 /// CK_DerivedToBaseMemberPointer - Member pointer in derived class to
0138 /// member pointer in base class.
0139 /// int A::*mptr = static_cast<int A::*>(&B::member);
0140 CAST_OPERATION(DerivedToBaseMemberPointer)
0141
0142 /// CK_MemberPointerToBoolean - Member pointer to boolean. A check
0143 /// against the null member pointer.
0144 CAST_OPERATION(MemberPointerToBoolean)
0145
0146 /// CK_ReinterpretMemberPointer - Reinterpret a member pointer as a
0147 /// different kind of member pointer. C++ forbids this from
0148 /// crossing between function and object types, but otherwise does
0149 /// not restrict it. However, the only operation that is permitted
0150 /// on a "punned" member pointer is casting it back to the original
0151 /// type, which is required to be a lossless operation (although
0152 /// many ABIs do not guarantee this on all possible intermediate types).
0153 CAST_OPERATION(ReinterpretMemberPointer)
0154
0155 /// CK_UserDefinedConversion - Conversion using a user defined type
0156 /// conversion function.
0157 /// struct A { operator int(); }; int i = int(A());
0158 CAST_OPERATION(UserDefinedConversion)
0159
0160 /// CK_ConstructorConversion - Conversion by constructor.
0161 /// struct A { A(int); }; A a = A(10);
0162 CAST_OPERATION(ConstructorConversion)
0163
0164 /// CK_IntegralToPointer - Integral to pointer. A special kind of
0165 /// reinterpreting conversion. Applies to normal, ObjC, and block
0166 /// pointers.
0167 /// (char*) 0x1001aab0
0168 /// reinterpret_cast<int*>(0)
0169 CAST_OPERATION(IntegralToPointer)
0170
0171 /// CK_PointerToIntegral - Pointer to integral. A special kind of
0172 /// reinterpreting conversion. Applies to normal, ObjC, and block
0173 /// pointers.
0174 /// (intptr_t) "help!"
0175 CAST_OPERATION(PointerToIntegral)
0176
0177 /// CK_PointerToBoolean - Pointer to boolean conversion. A check
0178 /// against null. Applies to normal, ObjC, and block pointers.
0179 CAST_OPERATION(PointerToBoolean)
0180
0181 /// CK_ToVoid - Cast to void, discarding the computed value.
0182 /// (void) malloc(2048)
0183 CAST_OPERATION(ToVoid)
0184
0185 /// CK_MatrixCast - A cast between matrix types of the same dimensions.
0186 CAST_OPERATION(MatrixCast)
0187
0188 /// CK_VectorSplat - A conversion from an arithmetic type to a
0189 /// vector of that element type. Fills all elements ("splats") with
0190 /// the source value.
0191 /// __attribute__((ext_vector_type(4))) int v = 5;
0192 CAST_OPERATION(VectorSplat)
0193
0194 /// CK_IntegralCast - A cast between integral types (other than to
0195 /// boolean). Variously a bitcast, a truncation, a sign-extension,
0196 /// or a zero-extension.
0197 /// long l = 5;
0198 /// (unsigned) i
0199 CAST_OPERATION(IntegralCast)
0200
0201 /// CK_IntegralToBoolean - Integral to boolean. A check against zero.
0202 /// (bool) i
0203 CAST_OPERATION(IntegralToBoolean)
0204
0205 /// CK_IntegralToFloating - Integral to floating point.
0206 /// float f = i;
0207 CAST_OPERATION(IntegralToFloating)
0208
0209 /// CK_FloatingToFixedPoint - Floating to fixed point.
0210 /// _Accum a = f;
0211 CAST_OPERATION(FloatingToFixedPoint)
0212
0213 /// CK_FixedPointToFloating - Fixed point to floating.
0214 /// (float) 2.5k
0215 CAST_OPERATION(FixedPointToFloating)
0216
0217 /// CK_FixedPointCast - Fixed point to fixed point.
0218 /// (_Accum) 0.5r
0219 CAST_OPERATION(FixedPointCast)
0220
0221 /// CK_FixedPointToIntegral - Fixed point to integral.
0222 /// (int) 2.0k
0223 CAST_OPERATION(FixedPointToIntegral)
0224
0225 /// CK_IntegralToFixedPoint - Integral to a fixed point.
0226 /// (_Accum) 2
0227 CAST_OPERATION(IntegralToFixedPoint)
0228
0229 /// CK_FixedPointToBoolean - Fixed point to boolean.
0230 /// (bool) 0.5r
0231 CAST_OPERATION(FixedPointToBoolean)
0232
0233 /// CK_FloatingToIntegral - Floating point to integral. Rounds
0234 /// towards zero, discarding any fractional component.
0235 /// (int) f
0236 CAST_OPERATION(FloatingToIntegral)
0237
0238 /// CK_FloatingToBoolean - Floating point to boolean.
0239 /// (bool) f
0240 CAST_OPERATION(FloatingToBoolean)
0241
0242 // CK_BooleanToSignedIntegral - Convert a boolean to -1 or 0 for true and
0243 // false, respectively.
0244 CAST_OPERATION(BooleanToSignedIntegral)
0245
0246 /// CK_FloatingCast - Casting between floating types of different size.
0247 /// (double) f
0248 /// (float) ld
0249 CAST_OPERATION(FloatingCast)
0250
0251 /// CK_CPointerToObjCPointerCast - Casting a C pointer kind to an
0252 /// Objective-C pointer.
0253 CAST_OPERATION(CPointerToObjCPointerCast)
0254
0255 /// CK_BlockPointerToObjCPointerCast - Casting a block pointer to an
0256 /// ObjC pointer.
0257 CAST_OPERATION(BlockPointerToObjCPointerCast)
0258
0259 /// CK_AnyPointerToBlockPointerCast - Casting any non-block pointer
0260 /// to a block pointer. Block-to-block casts are bitcasts.
0261 CAST_OPERATION(AnyPointerToBlockPointerCast)
0262
0263 /// Converting between two Objective-C object types, which
0264 /// can occur when performing reference binding to an Objective-C
0265 /// object.
0266 CAST_OPERATION(ObjCObjectLValueCast)
0267
0268 /// A conversion of a floating point real to a floating point
0269 /// complex of the original type. Injects the value as the real
0270 /// component with a zero imaginary component.
0271 /// float -> _Complex float
0272 CAST_OPERATION(FloatingRealToComplex)
0273
0274 /// Converts a floating point complex to floating point real
0275 /// of the source's element type. Just discards the imaginary
0276 /// component.
0277 /// _Complex long double -> long double
0278 CAST_OPERATION(FloatingComplexToReal)
0279
0280 /// Converts a floating point complex to bool by comparing
0281 /// against 0+0i.
0282 CAST_OPERATION(FloatingComplexToBoolean)
0283
0284 /// Converts between different floating point complex types.
0285 /// _Complex float -> _Complex double
0286 CAST_OPERATION(FloatingComplexCast)
0287
0288 /// Converts from a floating complex to an integral complex.
0289 /// _Complex float -> _Complex int
0290 CAST_OPERATION(FloatingComplexToIntegralComplex)
0291
0292 /// Converts from an integral real to an integral complex
0293 /// whose element type matches the source. Injects the value as
0294 /// the real component with a zero imaginary component.
0295 /// long -> _Complex long
0296 CAST_OPERATION(IntegralRealToComplex)
0297
0298 /// Converts an integral complex to an integral real of the
0299 /// source's element type by discarding the imaginary component.
0300 /// _Complex short -> short
0301 CAST_OPERATION(IntegralComplexToReal)
0302
0303 /// Converts an integral complex to bool by comparing against
0304 /// 0+0i.
0305 CAST_OPERATION(IntegralComplexToBoolean)
0306
0307 /// Converts between different integral complex types.
0308 /// _Complex char -> _Complex long long
0309 /// _Complex unsigned int -> _Complex signed int
0310 CAST_OPERATION(IntegralComplexCast)
0311
0312 /// Converts from an integral complex to a floating complex.
0313 /// _Complex unsigned -> _Complex float
0314 CAST_OPERATION(IntegralComplexToFloatingComplex)
0315
0316 /// [ARC] Produces a retainable object pointer so that it may
0317 /// be consumed, e.g. by being passed to a consuming parameter.
0318 /// Calls objc_retain.
0319 CAST_OPERATION(ARCProduceObject)
0320
0321 /// [ARC] Consumes a retainable object pointer that has just
0322 /// been produced, e.g. as the return value of a retaining call.
0323 /// Enters a cleanup to call objc_release at some indefinite time.
0324 CAST_OPERATION(ARCConsumeObject)
0325
0326 /// [ARC] Reclaim a retainable object pointer object that may
0327 /// have been produced and autoreleased as part of a function return
0328 /// sequence.
0329 CAST_OPERATION(ARCReclaimReturnedObject)
0330
0331 /// [ARC] Causes a value of block type to be copied to the
0332 /// heap, if it is not already there. A number of other operations
0333 /// in ARC cause blocks to be copied; this is for cases where that
0334 /// would not otherwise be guaranteed, such as when casting to a
0335 /// non-block pointer type.
0336 CAST_OPERATION(ARCExtendBlockObject)
0337
0338 /// Converts from _Atomic(T) to T.
0339 CAST_OPERATION(AtomicToNonAtomic)
0340 /// Converts from T to _Atomic(T).
0341 CAST_OPERATION(NonAtomicToAtomic)
0342
0343 /// Causes a block literal to by copied to the heap and then
0344 /// autoreleased.
0345 ///
0346 /// This particular cast kind is used for the conversion from a C++11
0347 /// lambda expression to a block pointer.
0348 CAST_OPERATION(CopyAndAutoreleaseBlockObject)
0349
0350 // Convert a builtin function to a function pointer; only allowed in the
0351 // callee of a call expression.
0352 CAST_OPERATION(BuiltinFnToFnPtr)
0353
0354 // Convert a zero value for OpenCL opaque types initialization (event_t,
0355 // queue_t, etc.)
0356 CAST_OPERATION(ZeroToOCLOpaqueType)
0357
0358 // Convert a pointer to a different address space.
0359 CAST_OPERATION(AddressSpaceConversion)
0360
0361 // Convert an integer initializer to an OpenCL sampler.
0362 CAST_OPERATION(IntToOCLSampler)
0363
0364 // Truncate a vector type by dropping elements from the end (HLSL only).
0365 CAST_OPERATION(HLSLVectorTruncation)
0366
0367 // Non-decaying array RValue cast (HLSL only).
0368 CAST_OPERATION(HLSLArrayRValue)
0369
0370 //===- Binary Operations -------------------------------------------------===//
0371 // Operators listed in order of precedence.
0372 // Note that additions to this should also update the StmtVisitor class,
0373 // BinaryOperator::getOverloadedOperator and CXBinaryOperatorKind enum.
0374
0375 // [C++ 5.5] Pointer-to-member operators.
0376 BINARY_OPERATION(PtrMemD, ".*")
0377 BINARY_OPERATION(PtrMemI, "->*")
0378 // [C99 6.5.5] Multiplicative operators.
0379 BINARY_OPERATION(Mul, "*")
0380 BINARY_OPERATION(Div, "/")
0381 BINARY_OPERATION(Rem, "%")
0382 // [C99 6.5.6] Additive operators.
0383 BINARY_OPERATION(Add, "+")
0384 BINARY_OPERATION(Sub, "-")
0385 // [C99 6.5.7] Bitwise shift operators.
0386 BINARY_OPERATION(Shl, "<<")
0387 BINARY_OPERATION(Shr, ">>")
0388 // C++20 [expr.spaceship] Three-way comparison operator.
0389 BINARY_OPERATION(Cmp, "<=>")
0390 // [C99 6.5.8] Relational operators.
0391 BINARY_OPERATION(LT, "<")
0392 BINARY_OPERATION(GT, ">")
0393 BINARY_OPERATION(LE, "<=")
0394 BINARY_OPERATION(GE, ">=")
0395 // [C99 6.5.9] Equality operators.
0396 BINARY_OPERATION(EQ, "==")
0397 BINARY_OPERATION(NE, "!=")
0398 // [C99 6.5.10] Bitwise AND operator.
0399 BINARY_OPERATION(And, "&")
0400 // [C99 6.5.11] Bitwise XOR operator.
0401 BINARY_OPERATION(Xor, "^")
0402 // [C99 6.5.12] Bitwise OR operator.
0403 BINARY_OPERATION(Or, "|")
0404 // [C99 6.5.13] Logical AND operator.
0405 BINARY_OPERATION(LAnd, "&&")
0406 // [C99 6.5.14] Logical OR operator.
0407 BINARY_OPERATION(LOr, "||")
0408 // [C99 6.5.16] Assignment operators.
0409 BINARY_OPERATION(Assign, "=")
0410 BINARY_OPERATION(MulAssign, "*=")
0411 BINARY_OPERATION(DivAssign, "/=")
0412 BINARY_OPERATION(RemAssign, "%=")
0413 BINARY_OPERATION(AddAssign, "+=")
0414 BINARY_OPERATION(SubAssign, "-=")
0415 BINARY_OPERATION(ShlAssign, "<<=")
0416 BINARY_OPERATION(ShrAssign, ">>=")
0417 BINARY_OPERATION(AndAssign, "&=")
0418 BINARY_OPERATION(XorAssign, "^=")
0419 BINARY_OPERATION(OrAssign, "|=")
0420 // [C99 6.5.17] Comma operator.
0421 BINARY_OPERATION(Comma, ",")
0422
0423
0424 //===- Unary Operations ---------------------------------------------------===//
0425 // Note that additions to this should also update the StmtVisitor class,
0426 // UnaryOperator::getOverloadedOperator and CXUnaryOperatorKind enum.
0427
0428 // [C99 6.5.2.4] Postfix increment and decrement
0429 UNARY_OPERATION(PostInc, "++")
0430 UNARY_OPERATION(PostDec, "--")
0431 // [C99 6.5.3.1] Prefix increment and decrement
0432 UNARY_OPERATION(PreInc, "++")
0433 UNARY_OPERATION(PreDec, "--")
0434 // [C99 6.5.3.2] Address and indirection
0435 UNARY_OPERATION(AddrOf, "&")
0436 UNARY_OPERATION(Deref, "*")
0437 // [C99 6.5.3.3] Unary arithmetic
0438 UNARY_OPERATION(Plus, "+")
0439 UNARY_OPERATION(Minus, "-")
0440 UNARY_OPERATION(Not, "~")
0441 UNARY_OPERATION(LNot, "!")
0442 // "__real expr"/"__imag expr" Extension.
0443 UNARY_OPERATION(Real, "__real")
0444 UNARY_OPERATION(Imag, "__imag")
0445 // __extension__ marker.
0446 UNARY_OPERATION(Extension, "__extension__")
0447 // [C++ Coroutines] co_await operator
0448 UNARY_OPERATION(Coawait, "co_await")
0449
0450 #undef CAST_OPERATION
0451 #undef BINARY_OPERATION
0452 #undef UNARY_OPERATION