2010-09-17 15:54:40 +00:00
|
|
|
//===- OperationKinds.h - Operation enums -----------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file enumerates the different kinds of operations that can be
|
|
|
|
// performed by various expressions.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CLANG_AST_OPERATION_KINDS_H
|
|
|
|
#define LLVM_CLANG_AST_OPERATION_KINDS_H
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CastKind - The kind of operation required for a conversion.
|
2010-09-17 15:54:40 +00:00
|
|
|
enum CastKind {
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_Dependent - A conversion which cannot yet be analyzed because
|
|
|
|
/// either the expression or target type is dependent. These are
|
|
|
|
/// created only for explicit casts; dependent ASTs aren't required
|
|
|
|
/// to even approximately type-check.
|
|
|
|
/// (T*) malloc(sizeof(T))
|
|
|
|
/// reinterpret_cast<intptr_t>(A<T>::alloc());
|
|
|
|
CK_Dependent,
|
2010-09-17 15:54:40 +00:00
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_BitCast - A conversion which causes a bit pattern of one type
|
|
|
|
/// to be reinterpreted as a bit pattern of another type. Generally
|
|
|
|
/// the operands must have equivalent size and unrelated types.
|
|
|
|
///
|
2011-10-20 21:14:49 +00:00
|
|
|
/// The pointer conversion char* -> int* is a bitcast. A conversion
|
|
|
|
/// from any pointer type to a C pointer type is a bitcast unless
|
|
|
|
/// it's actually BaseToDerived or DerivedToBase. A conversion to a
|
|
|
|
/// block pointer or ObjC pointer type is a bitcast only if the
|
|
|
|
/// operand has the same type kind; otherwise, it's one of the
|
|
|
|
/// specialized casts below.
|
2011-02-20 13:06:31 +00:00
|
|
|
///
|
|
|
|
/// Vector coercions are bitcasts.
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_BitCast,
|
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_LValueBitCast - A conversion which reinterprets the address of
|
|
|
|
/// an l-value as an l-value of a different kind. Used for
|
|
|
|
/// reinterpret_casts of l-value expressions to reference types.
|
|
|
|
/// bool b; reinterpret_cast<char&>(b) = 'a';
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_LValueBitCast,
|
2011-02-20 13:06:31 +00:00
|
|
|
|
|
|
|
/// CK_LValueToRValue - A conversion which causes the extraction of
|
|
|
|
/// an r-value from the operand gl-value. The result of an r-value
|
|
|
|
/// conversion is always unqualified.
|
|
|
|
CK_LValueToRValue,
|
|
|
|
|
|
|
|
/// CK_NoOp - A conversion which does not affect the type other than
|
|
|
|
/// (possibly) adding qualifiers.
|
|
|
|
/// int -> int
|
|
|
|
/// char** -> const char * const *
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_NoOp,
|
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_BaseToDerived - A conversion from a C++ class pointer/reference
|
|
|
|
/// to a derived class pointer/reference.
|
|
|
|
/// B *b = static_cast<B*>(a);
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_BaseToDerived,
|
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_DerivedToBase - A conversion from a C++ class pointer
|
|
|
|
/// to a base class pointer.
|
|
|
|
/// A *a = new B();
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_DerivedToBase,
|
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_UncheckedDerivedToBase - A conversion from a C++ class
|
|
|
|
/// pointer/reference to a base class that can assume that the
|
|
|
|
/// derived pointer is not null.
|
|
|
|
/// const A &a = B();
|
|
|
|
/// b->method_from_a();
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_UncheckedDerivedToBase,
|
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_Dynamic - A C++ dynamic_cast.
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_Dynamic,
|
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_ToUnion - The GCC cast-to-union extension.
|
|
|
|
/// int -> union { int x; float y; }
|
|
|
|
/// float -> union { int x; float y; }
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_ToUnion,
|
|
|
|
|
|
|
|
/// CK_ArrayToPointerDecay - Array to pointer decay.
|
2011-02-20 13:06:31 +00:00
|
|
|
/// int[10] -> int*
|
|
|
|
/// char[5][6] -> char(*)[6]
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_ArrayToPointerDecay,
|
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_FunctionToPointerDecay - Function to pointer decay.
|
|
|
|
/// void(int) -> void(*)(int)
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_FunctionToPointerDecay,
|
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_NullToPointer - Null pointer constant to pointer, ObjC
|
|
|
|
/// pointer, or block pointer.
|
|
|
|
/// (void*) 0
|
|
|
|
/// void (^block)() = 0;
|
|
|
|
CK_NullToPointer,
|
|
|
|
|
|
|
|
/// CK_NullToMemberPointer - Null pointer constant to member pointer.
|
|
|
|
/// int A::*mptr = 0;
|
|
|
|
/// int (A::*fptr)(int) = nullptr;
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_NullToMemberPointer,
|
|
|
|
|
|
|
|
/// CK_BaseToDerivedMemberPointer - Member pointer in base class to
|
|
|
|
/// member pointer in derived class.
|
2011-02-20 13:06:31 +00:00
|
|
|
/// int B::*mptr = &A::member;
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_BaseToDerivedMemberPointer,
|
|
|
|
|
|
|
|
/// CK_DerivedToBaseMemberPointer - Member pointer in derived class to
|
|
|
|
/// member pointer in base class.
|
2011-02-20 13:06:31 +00:00
|
|
|
/// int A::*mptr = static_cast<int A::*>(&B::member);
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_DerivedToBaseMemberPointer,
|
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_MemberPointerToBoolean - Member pointer to boolean. A check
|
|
|
|
/// against the null member pointer.
|
|
|
|
CK_MemberPointerToBoolean,
|
|
|
|
|
2012-04-14 14:01:31 +00:00
|
|
|
/// CK_ReinterpretMemberPointer - Reinterpret a member pointer as a
|
|
|
|
/// different kind of member pointer. C++ forbids this from
|
|
|
|
/// crossing between function and object types, but otherwise does
|
|
|
|
/// not restrict it. However, the only operation that is permitted
|
|
|
|
/// on a "punned" member pointer is casting it back to the original
|
|
|
|
/// type, which is required to be a lossless operation (although
|
|
|
|
/// many ABIs do not guarantee this on all possible intermediate types).
|
|
|
|
CK_ReinterpretMemberPointer,
|
|
|
|
|
2010-09-17 15:54:40 +00:00
|
|
|
/// CK_UserDefinedConversion - Conversion using a user defined type
|
|
|
|
/// conversion function.
|
2011-02-20 13:06:31 +00:00
|
|
|
/// struct A { operator int(); }; int i = int(A());
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_UserDefinedConversion,
|
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_ConstructorConversion - Conversion by constructor.
|
|
|
|
/// struct A { A(int); }; A a = A(10);
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_ConstructorConversion,
|
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_IntegralToPointer - Integral to pointer. A special kind of
|
|
|
|
/// reinterpreting conversion. Applies to normal, ObjC, and block
|
|
|
|
/// pointers.
|
|
|
|
/// (char*) 0x1001aab0
|
|
|
|
/// reinterpret_cast<int*>(0)
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_IntegralToPointer,
|
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_PointerToIntegral - Pointer to integral. A special kind of
|
|
|
|
/// reinterpreting conversion. Applies to normal, ObjC, and block
|
|
|
|
/// pointers.
|
|
|
|
/// (intptr_t) "help!"
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_PointerToIntegral,
|
2011-02-20 13:06:31 +00:00
|
|
|
|
|
|
|
/// CK_PointerToBoolean - Pointer to boolean conversion. A check
|
|
|
|
/// against null. Applies to normal, ObjC, and block pointers.
|
|
|
|
CK_PointerToBoolean,
|
2010-09-17 15:54:40 +00:00
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_ToVoid - Cast to void, discarding the computed value.
|
|
|
|
/// (void) malloc(2048)
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_ToVoid,
|
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_VectorSplat - A conversion from an arithmetic type to a
|
|
|
|
/// vector of that element type. Fills all elements ("splats") with
|
|
|
|
/// the source value.
|
|
|
|
/// __attribute__((ext_vector_type(4))) int v = 5;
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_VectorSplat,
|
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_IntegralCast - A cast between integral types (other than to
|
|
|
|
/// boolean). Variously a bitcast, a truncation, a sign-extension,
|
|
|
|
/// or a zero-extension.
|
|
|
|
/// long l = 5;
|
|
|
|
/// (unsigned) i
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_IntegralCast,
|
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_IntegralToBoolean - Integral to boolean. A check against zero.
|
|
|
|
/// (bool) i
|
|
|
|
CK_IntegralToBoolean,
|
|
|
|
|
2010-09-17 15:54:40 +00:00
|
|
|
/// CK_IntegralToFloating - Integral to floating point.
|
2011-02-20 13:06:31 +00:00
|
|
|
/// float f = i;
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_IntegralToFloating,
|
|
|
|
|
2011-02-20 13:06:31 +00:00
|
|
|
/// CK_FloatingToIntegral - Floating point to integral. Rounds
|
|
|
|
/// towards zero, discarding any fractional component.
|
|
|
|
/// (int) f
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_FloatingToIntegral,
|
2011-02-20 13:06:31 +00:00
|
|
|
|
|
|
|
/// CK_FloatingToBoolean - Floating point to boolean.
|
|
|
|
/// (bool) f
|
|
|
|
CK_FloatingToBoolean,
|
2010-09-17 15:54:40 +00:00
|
|
|
|
|
|
|
/// CK_FloatingCast - Casting between floating types of different size.
|
2011-02-20 13:06:31 +00:00
|
|
|
/// (double) f
|
|
|
|
/// (float) ld
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_FloatingCast,
|
|
|
|
|
2011-10-20 21:14:49 +00:00
|
|
|
/// CK_CPointerToObjCPointerCast - Casting a C pointer kind to an
|
|
|
|
/// Objective-C pointer.
|
|
|
|
CK_CPointerToObjCPointerCast,
|
2010-09-17 15:54:40 +00:00
|
|
|
|
2011-10-20 21:14:49 +00:00
|
|
|
/// CK_BlockPointerToObjCPointerCast - Casting a block pointer to an
|
|
|
|
/// ObjC pointer.
|
|
|
|
CK_BlockPointerToObjCPointerCast,
|
|
|
|
|
|
|
|
/// CK_AnyPointerToBlockPointerCast - Casting any non-block pointer
|
|
|
|
/// to a block pointer. Block-to-block casts are bitcasts.
|
2010-09-17 15:54:40 +00:00
|
|
|
CK_AnyPointerToBlockPointerCast,
|
|
|
|
|
|
|
|
/// \brief Converting between two Objective-C object types, which
|
|
|
|
/// can occur when performing reference binding to an Objective-C
|
|
|
|
/// object.
|
2011-02-20 13:06:31 +00:00
|
|
|
CK_ObjCObjectLValueCast,
|
|
|
|
|
|
|
|
/// \brief A conversion of a floating point real to a floating point
|
|
|
|
/// complex of the original type. Injects the value as the real
|
|
|
|
/// component with a zero imaginary component.
|
|
|
|
/// float -> _Complex float
|
|
|
|
CK_FloatingRealToComplex,
|
|
|
|
|
|
|
|
/// \brief 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
|
|
|
|
CK_FloatingComplexToReal,
|
|
|
|
|
|
|
|
/// \brief Converts a floating point complex to bool by comparing
|
|
|
|
/// against 0+0i.
|
|
|
|
CK_FloatingComplexToBoolean,
|
|
|
|
|
|
|
|
/// \brief Converts between different floating point complex types.
|
|
|
|
/// _Complex float -> _Complex double
|
|
|
|
CK_FloatingComplexCast,
|
|
|
|
|
|
|
|
/// \brief Converts from a floating complex to an integral complex.
|
|
|
|
/// _Complex float -> _Complex int
|
|
|
|
CK_FloatingComplexToIntegralComplex,
|
|
|
|
|
|
|
|
/// \brief Converts from an integral real to an integral complex
|
|
|
|
/// whose element type matches the source. Injects the value as
|
|
|
|
/// the real component with a zero imaginary component.
|
|
|
|
/// long -> _Complex long
|
|
|
|
CK_IntegralRealToComplex,
|
|
|
|
|
|
|
|
/// \brief Converts an integral complex to an integral real of the
|
|
|
|
/// source's element type by discarding the imaginary component.
|
|
|
|
/// _Complex short -> short
|
|
|
|
CK_IntegralComplexToReal,
|
|
|
|
|
|
|
|
/// \brief Converts an integral complex to bool by comparing against
|
|
|
|
/// 0+0i.
|
|
|
|
CK_IntegralComplexToBoolean,
|
|
|
|
|
|
|
|
/// \brief Converts between different integral complex types.
|
|
|
|
/// _Complex char -> _Complex long long
|
|
|
|
/// _Complex unsigned int -> _Complex signed int
|
|
|
|
CK_IntegralComplexCast,
|
|
|
|
|
|
|
|
/// \brief Converts from an integral complex to a floating complex.
|
|
|
|
/// _Complex unsigned -> _Complex float
|
2011-07-17 15:40:56 +00:00
|
|
|
CK_IntegralComplexToFloatingComplex,
|
|
|
|
|
2011-10-20 21:14:49 +00:00
|
|
|
/// \brief [ARC] Produces a retainable object pointer so that it may
|
|
|
|
/// be consumed, e.g. by being passed to a consuming parameter.
|
|
|
|
/// Calls objc_retain.
|
|
|
|
CK_ARCProduceObject,
|
2011-07-17 15:40:56 +00:00
|
|
|
|
2011-10-20 21:14:49 +00:00
|
|
|
/// \brief [ARC] Consumes a retainable object pointer that has just
|
|
|
|
/// been produced, e.g. as the return value of a retaining call.
|
|
|
|
/// Enters a cleanup to call objc_release at some indefinite time.
|
|
|
|
CK_ARCConsumeObject,
|
2011-07-17 15:40:56 +00:00
|
|
|
|
2011-10-20 21:14:49 +00:00
|
|
|
/// \brief [ARC] Reclaim a retainable object pointer object that may
|
|
|
|
/// have been produced and autoreleased as part of a function return
|
2011-07-17 15:40:56 +00:00
|
|
|
/// sequence.
|
2011-10-20 21:14:49 +00:00
|
|
|
CK_ARCReclaimReturnedObject,
|
|
|
|
|
|
|
|
/// \brief [ARC] Causes a value of block type to be copied to the
|
|
|
|
/// heap, if it is not already there. A number of other operations
|
|
|
|
/// in ARC cause blocks to be copied; this is for cases where that
|
|
|
|
/// would not otherwise be guaranteed, such as when casting to a
|
|
|
|
/// non-block pointer type.
|
2012-04-14 14:01:31 +00:00
|
|
|
CK_ARCExtendBlockObject,
|
|
|
|
|
|
|
|
/// \brief Converts from _Atomic(T) to T.
|
|
|
|
CK_AtomicToNonAtomic,
|
|
|
|
/// \brief Converts from T to _Atomic(T).
|
|
|
|
CK_NonAtomicToAtomic,
|
|
|
|
|
|
|
|
/// \brief Causes a block literal to by copied to the heap and then
|
|
|
|
/// autoreleased.
|
|
|
|
///
|
|
|
|
/// This particular cast kind is used for the conversion from a C++11
|
|
|
|
/// lambda expression to a block pointer.
|
2012-12-02 13:20:44 +00:00
|
|
|
CK_CopyAndAutoreleaseBlockObject,
|
|
|
|
|
|
|
|
// Convert a builtin function to a function pointer; only allowed in the
|
|
|
|
// callee of a call expression.
|
|
|
|
CK_BuiltinFnToFnPtr
|
2010-09-17 15:54:40 +00:00
|
|
|
};
|
|
|
|
|
2012-08-15 20:02:54 +00:00
|
|
|
static const CastKind CK_Invalid = static_cast<CastKind>(-1);
|
2010-09-17 15:54:40 +00:00
|
|
|
|
|
|
|
enum BinaryOperatorKind {
|
|
|
|
// Operators listed in order of precedence.
|
|
|
|
// Note that additions to this should also update the StmtVisitor class.
|
|
|
|
BO_PtrMemD, BO_PtrMemI, // [C++ 5.5] Pointer-to-member operators.
|
|
|
|
BO_Mul, BO_Div, BO_Rem, // [C99 6.5.5] Multiplicative operators.
|
|
|
|
BO_Add, BO_Sub, // [C99 6.5.6] Additive operators.
|
|
|
|
BO_Shl, BO_Shr, // [C99 6.5.7] Bitwise shift operators.
|
|
|
|
BO_LT, BO_GT, BO_LE, BO_GE, // [C99 6.5.8] Relational operators.
|
|
|
|
BO_EQ, BO_NE, // [C99 6.5.9] Equality operators.
|
|
|
|
BO_And, // [C99 6.5.10] Bitwise AND operator.
|
|
|
|
BO_Xor, // [C99 6.5.11] Bitwise XOR operator.
|
|
|
|
BO_Or, // [C99 6.5.12] Bitwise OR operator.
|
|
|
|
BO_LAnd, // [C99 6.5.13] Logical AND operator.
|
|
|
|
BO_LOr, // [C99 6.5.14] Logical OR operator.
|
|
|
|
BO_Assign, BO_MulAssign, // [C99 6.5.16] Assignment operators.
|
|
|
|
BO_DivAssign, BO_RemAssign,
|
|
|
|
BO_AddAssign, BO_SubAssign,
|
|
|
|
BO_ShlAssign, BO_ShrAssign,
|
|
|
|
BO_AndAssign, BO_XorAssign,
|
|
|
|
BO_OrAssign,
|
|
|
|
BO_Comma // [C99 6.5.17] Comma operator.
|
|
|
|
};
|
|
|
|
|
|
|
|
enum UnaryOperatorKind {
|
|
|
|
// Note that additions to this should also update the StmtVisitor class.
|
|
|
|
UO_PostInc, UO_PostDec, // [C99 6.5.2.4] Postfix increment and decrement
|
|
|
|
UO_PreInc, UO_PreDec, // [C99 6.5.3.1] Prefix increment and decrement
|
|
|
|
UO_AddrOf, UO_Deref, // [C99 6.5.3.2] Address and indirection
|
|
|
|
UO_Plus, UO_Minus, // [C99 6.5.3.3] Unary arithmetic
|
|
|
|
UO_Not, UO_LNot, // [C99 6.5.3.3] Unary arithmetic
|
|
|
|
UO_Real, UO_Imag, // "__real expr"/"__imag expr" Extension.
|
|
|
|
UO_Extension // __extension__ marker.
|
|
|
|
};
|
|
|
|
|
2011-07-17 15:40:56 +00:00
|
|
|
/// \brief The kind of bridging performed by the Objective-C bridge cast.
|
|
|
|
enum ObjCBridgeCastKind {
|
|
|
|
/// \brief Bridging via __bridge, which does nothing but reinterpret
|
|
|
|
/// the bits.
|
|
|
|
OBC_Bridge,
|
|
|
|
/// \brief Bridging via __bridge_transfer, which transfers ownership of an
|
|
|
|
/// Objective-C pointer into ARC.
|
|
|
|
OBC_BridgeTransfer,
|
|
|
|
/// \brief Bridging via __bridge_retain, which makes an ARC object available
|
|
|
|
/// as a +1 C pointer.
|
|
|
|
OBC_BridgeRetained
|
|
|
|
};
|
|
|
|
|
2010-09-17 15:54:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|