[AST] Move operations enum to a definition file.

Summary:
This patch moves the enum definitions to a definition (.def) file.

These modifications provide way to list enumerators of a given type.

As an example, this allow parsing of "kinds" in the dynamic matchers.
see: http://reviews.llvm.org/D19871
The dynamic matcher "ofKind" also required this patch to be fixed.

Reviewers: klimek, aaron.ballman, rsmith

Subscribers: klimek, sbenza, alexfh, cfe-commits

Differential Revision: http://reviews.llvm.org/D20207

llvm-svn: 269347
This commit is contained in:
Etienne Bergeron 2016-05-12 20:58:56 +00:00
parent 6a493f2c4a
commit 5356d96d19
4 changed files with 420 additions and 474 deletions

View File

@ -0,0 +1,406 @@
//===--- OperationKinds.def - Operations Database ---------------*- 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.
//
//===----------------------------------------------------------------------===//
//
/// @file OperationKinds.def
///
/// In this file, each of the C/C++ operations is enumerated CAST_OPERATION,
/// BINARY_OPERATION or UNARY_OPERATION macro, each of which can be specified by
/// the code including this file.
///
/// Macros had one or two arguments:
///
/// Name: The name of the operation. Name (prefixed with CK_, UO_ or BO_) will
/// be the name of the corresponding enumerator (see OperationsKinds.h).
///
/// Spelling: A string that provides a canonical spelling for the operation.
#ifndef CAST_OPERATION
# define CAST_OPERATION(Name)
#endif
#ifndef BINARY_OPERATION
# define BINARY_OPERATION(Name, Spelling)
#endif
#ifndef UNARY_OPERATION
# define UNARY_OPERATION(Name, Spelling)
#endif
//===- Cast Operations ---------------------------------------------------===//
/// 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());
CAST_OPERATION(Dependent)
/// 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.
///
/// 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.
///
/// Vector coercions are bitcasts.
CAST_OPERATION(BitCast)
/// 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';
CAST_OPERATION(LValueBitCast)
/// 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.
CAST_OPERATION(LValueToRValue)
/// CK_NoOp - A conversion which does not affect the type other than
/// (possibly) adding qualifiers.
/// int -> int
/// char** -> const char * const *
CAST_OPERATION(NoOp)
/// CK_BaseToDerived - A conversion from a C++ class pointer/reference
/// to a derived class pointer/reference.
/// B *b = static_cast<B*>(a);
CAST_OPERATION(BaseToDerived)
/// CK_DerivedToBase - A conversion from a C++ class pointer
/// to a base class pointer.
/// A *a = new B();
CAST_OPERATION(DerivedToBase)
/// 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();
CAST_OPERATION(UncheckedDerivedToBase)
/// CK_Dynamic - A C++ dynamic_cast.
CAST_OPERATION(Dynamic)
/// CK_ToUnion - The GCC cast-to-union extension.
/// int -> union { int x; float y; }
/// float -> union { int x; float y; }
CAST_OPERATION(ToUnion)
/// CK_ArrayToPointerDecay - Array to pointer decay.
/// int[10] -> int*
/// char[5][6] -> char(*)[6]
CAST_OPERATION(ArrayToPointerDecay)
/// CK_FunctionToPointerDecay - Function to pointer decay.
/// void(int) -> void(*)(int)
CAST_OPERATION(FunctionToPointerDecay)
/// CK_NullToPointer - Null pointer constant to pointer, ObjC
/// pointer, or block pointer.
/// (void*) 0
/// void (^block)() = 0;
CAST_OPERATION(NullToPointer)
/// CK_NullToMemberPointer - Null pointer constant to member pointer.
/// int A::*mptr = 0;
/// int (A::*fptr)(int) = nullptr;
CAST_OPERATION(NullToMemberPointer)
/// CK_BaseToDerivedMemberPointer - Member pointer in base class to
/// member pointer in derived class.
/// int B::*mptr = &A::member;
CAST_OPERATION(BaseToDerivedMemberPointer)
/// CK_DerivedToBaseMemberPointer - Member pointer in derived class to
/// member pointer in base class.
/// int A::*mptr = static_cast<int A::*>(&B::member);
CAST_OPERATION(DerivedToBaseMemberPointer)
/// CK_MemberPointerToBoolean - Member pointer to boolean. A check
/// against the null member pointer.
CAST_OPERATION(MemberPointerToBoolean)
/// 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).
CAST_OPERATION(ReinterpretMemberPointer)
/// CK_UserDefinedConversion - Conversion using a user defined type
/// conversion function.
/// struct A { operator int(); }; int i = int(A());
CAST_OPERATION(UserDefinedConversion)
/// CK_ConstructorConversion - Conversion by constructor.
/// struct A { A(int); }; A a = A(10);
CAST_OPERATION(ConstructorConversion)
/// CK_IntegralToPointer - Integral to pointer. A special kind of
/// reinterpreting conversion. Applies to normal, ObjC, and block
/// pointers.
/// (char*) 0x1001aab0
/// reinterpret_cast<int*>(0)
CAST_OPERATION(IntegralToPointer)
/// CK_PointerToIntegral - Pointer to integral. A special kind of
/// reinterpreting conversion. Applies to normal, ObjC, and block
/// pointers.
/// (intptr_t) "help!"
CAST_OPERATION(PointerToIntegral)
/// CK_PointerToBoolean - Pointer to boolean conversion. A check
/// against null. Applies to normal, ObjC, and block pointers.
CAST_OPERATION(PointerToBoolean)
/// CK_ToVoid - Cast to void, discarding the computed value.
/// (void) malloc(2048)
CAST_OPERATION(ToVoid)
/// 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;
CAST_OPERATION(VectorSplat)
/// 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
CAST_OPERATION(IntegralCast)
/// CK_IntegralToBoolean - Integral to boolean. A check against zero.
/// (bool) i
CAST_OPERATION(IntegralToBoolean)
/// CK_IntegralToFloating - Integral to floating point.
/// float f = i;
CAST_OPERATION(IntegralToFloating)
/// CK_FloatingToIntegral - Floating point to integral. Rounds
/// towards zero, discarding any fractional component.
/// (int) f
CAST_OPERATION(FloatingToIntegral)
/// CK_FloatingToBoolean - Floating point to boolean.
/// (bool) f
CAST_OPERATION(FloatingToBoolean)
// CK_BooleanToSignedIntegral - Convert a boolean to -1 or 0 for true and
// false, respectively.
CAST_OPERATION(BooleanToSignedIntegral)
/// CK_FloatingCast - Casting between floating types of different size.
/// (double) f
/// (float) ld
CAST_OPERATION(FloatingCast)
/// CK_CPointerToObjCPointerCast - Casting a C pointer kind to an
/// Objective-C pointer.
CAST_OPERATION(CPointerToObjCPointerCast)
/// CK_BlockPointerToObjCPointerCast - Casting a block pointer to an
/// ObjC pointer.
CAST_OPERATION(BlockPointerToObjCPointerCast)
/// CK_AnyPointerToBlockPointerCast - Casting any non-block pointer
/// to a block pointer. Block-to-block casts are bitcasts.
CAST_OPERATION(AnyPointerToBlockPointerCast)
/// \brief Converting between two Objective-C object types, which
/// can occur when performing reference binding to an Objective-C
/// object.
CAST_OPERATION(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
CAST_OPERATION(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
CAST_OPERATION(FloatingComplexToReal)
/// \brief Converts a floating point complex to bool by comparing
/// against 0+0i.
CAST_OPERATION(FloatingComplexToBoolean)
/// \brief Converts between different floating point complex types.
/// _Complex float -> _Complex double
CAST_OPERATION(FloatingComplexCast)
/// \brief Converts from a floating complex to an integral complex.
/// _Complex float -> _Complex int
CAST_OPERATION(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
CAST_OPERATION(IntegralRealToComplex)
/// \brief Converts an integral complex to an integral real of the
/// source's element type by discarding the imaginary component.
/// _Complex short -> short
CAST_OPERATION(IntegralComplexToReal)
/// \brief Converts an integral complex to bool by comparing against
/// 0+0i.
CAST_OPERATION(IntegralComplexToBoolean)
/// \brief Converts between different integral complex types.
/// _Complex char -> _Complex long long
/// _Complex unsigned int -> _Complex signed int
CAST_OPERATION(IntegralComplexCast)
/// \brief Converts from an integral complex to a floating complex.
/// _Complex unsigned -> _Complex float
CAST_OPERATION(IntegralComplexToFloatingComplex)
/// \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.
CAST_OPERATION(ARCProduceObject)
/// \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.
CAST_OPERATION(ARCConsumeObject)
/// \brief [ARC] Reclaim a retainable object pointer object that may
/// have been produced and autoreleased as part of a function return
/// sequence.
CAST_OPERATION(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.
CAST_OPERATION(ARCExtendBlockObject)
/// \brief Converts from _Atomic(T) to T.
CAST_OPERATION(AtomicToNonAtomic)
/// \brief Converts from T to _Atomic(T).
CAST_OPERATION(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.
CAST_OPERATION(CopyAndAutoreleaseBlockObject)
// Convert a builtin function to a function pointer; only allowed in the
// callee of a call expression.
CAST_OPERATION(BuiltinFnToFnPtr)
// Convert a zero value for OpenCL event_t initialization.
CAST_OPERATION(ZeroToOCLEvent)
// Convert a pointer to a different address space.
CAST_OPERATION(AddressSpaceConversion)
//===- Binary Operations -------------------------------------------------===//
// Operators listed in order of precedence.
// Note that additions to this should also update the StmtVisitor class.
// [C++ 5.5] Pointer-to-member operators.
BINARY_OPERATION(PtrMemD, ".*")
BINARY_OPERATION(PtrMemI, "->*")
// [C99 6.5.5] Multiplicative operators.
BINARY_OPERATION(Mul, "*")
BINARY_OPERATION(Div, "/")
BINARY_OPERATION(Rem, "%")
// [C99 6.5.6] Additive operators.
BINARY_OPERATION(Add, "+")
BINARY_OPERATION(Sub, "-")
// [C99 6.5.7] Bitwise shift operators.
BINARY_OPERATION(Shl, "<<")
BINARY_OPERATION(Shr, ">>")
// [C99 6.5.8] Relational operators.
BINARY_OPERATION(LT, "<")
BINARY_OPERATION(GT, ">")
BINARY_OPERATION(LE, "<=")
BINARY_OPERATION(GE, ">=")
// [C99 6.5.9] Equality operators.
BINARY_OPERATION(EQ, "==")
BINARY_OPERATION(NE, "!=")
// [C99 6.5.10] Bitwise AND operator.
BINARY_OPERATION(And, "&")
// [C99 6.5.11] Bitwise XOR operator.
BINARY_OPERATION(Xor, "^")
// [C99 6.5.12] Bitwise OR operator.
BINARY_OPERATION(Or, "|")
// [C99 6.5.13] Logical AND operator.
BINARY_OPERATION(LAnd, "&&")
// [C99 6.5.14] Logical OR operator.
BINARY_OPERATION(LOr, "||")
// [C99 6.5.16] Assignment operators.
BINARY_OPERATION(Assign, "=")
BINARY_OPERATION(MulAssign, "*=")
BINARY_OPERATION(DivAssign, "/=")
BINARY_OPERATION(RemAssign, "%=")
BINARY_OPERATION(AddAssign, "+=")
BINARY_OPERATION(SubAssign, "-=")
BINARY_OPERATION(ShlAssign, "<<=")
BINARY_OPERATION(ShrAssign, ">>=")
BINARY_OPERATION(AndAssign, "&=")
BINARY_OPERATION(XorAssign, "^=")
BINARY_OPERATION(OrAssign, "|=")
// [C99 6.5.17] Comma operator.
BINARY_OPERATION(Comma, ",")
//===- Unary Operations ---------------------------------------------------===//
// Note that additions to this should also update the StmtVisitor class.
// [C99 6.5.2.4] Postfix increment and decrement
UNARY_OPERATION(PostInc, "++")
UNARY_OPERATION(PostDec, "--")
// [C99 6.5.3.1] Prefix increment and decrement
UNARY_OPERATION(PreInc, "++")
UNARY_OPERATION(PreDec, "--")
// [C99 6.5.3.2] Address and indirection
UNARY_OPERATION(AddrOf, "&")
UNARY_OPERATION(Deref, "*")
// [C99 6.5.3.3] Unary arithmetic
UNARY_OPERATION(Plus, "+")
UNARY_OPERATION(Minus, "-")
UNARY_OPERATION(Not, "~")
UNARY_OPERATION(LNot, "!")
// "__real expr"/"__imag expr" Extension.
UNARY_OPERATION(Real, "__real")
UNARY_OPERATION(Imag, "__imag")
// __extension__ marker.
UNARY_OPERATION(Extension, "__extension__")
// [C++ Coroutines] co_await operator
UNARY_OPERATION(Coawait, "co_await")
#undef CAST_OPERATION
#undef BINARY_OPERATION
#undef UNARY_OPERATION

View File

@ -19,327 +19,20 @@ namespace clang {
/// CastKind - The kind of operation required for a conversion.
enum CastKind {
/// 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,
/// 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.
///
/// 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.
///
/// Vector coercions are bitcasts.
CK_BitCast,
/// 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';
CK_LValueBitCast,
/// 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 *
CK_NoOp,
/// CK_BaseToDerived - A conversion from a C++ class pointer/reference
/// to a derived class pointer/reference.
/// B *b = static_cast<B*>(a);
CK_BaseToDerived,
/// CK_DerivedToBase - A conversion from a C++ class pointer
/// to a base class pointer.
/// A *a = new B();
CK_DerivedToBase,
/// 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();
CK_UncheckedDerivedToBase,
/// CK_Dynamic - A C++ dynamic_cast.
CK_Dynamic,
/// CK_ToUnion - The GCC cast-to-union extension.
/// int -> union { int x; float y; }
/// float -> union { int x; float y; }
CK_ToUnion,
/// CK_ArrayToPointerDecay - Array to pointer decay.
/// int[10] -> int*
/// char[5][6] -> char(*)[6]
CK_ArrayToPointerDecay,
/// CK_FunctionToPointerDecay - Function to pointer decay.
/// void(int) -> void(*)(int)
CK_FunctionToPointerDecay,
/// 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;
CK_NullToMemberPointer,
/// CK_BaseToDerivedMemberPointer - Member pointer in base class to
/// member pointer in derived class.
/// int B::*mptr = &A::member;
CK_BaseToDerivedMemberPointer,
/// CK_DerivedToBaseMemberPointer - Member pointer in derived class to
/// member pointer in base class.
/// int A::*mptr = static_cast<int A::*>(&B::member);
CK_DerivedToBaseMemberPointer,
/// CK_MemberPointerToBoolean - Member pointer to boolean. A check
/// against the null member pointer.
CK_MemberPointerToBoolean,
/// 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,
/// CK_UserDefinedConversion - Conversion using a user defined type
/// conversion function.
/// struct A { operator int(); }; int i = int(A());
CK_UserDefinedConversion,
/// CK_ConstructorConversion - Conversion by constructor.
/// struct A { A(int); }; A a = A(10);
CK_ConstructorConversion,
/// CK_IntegralToPointer - Integral to pointer. A special kind of
/// reinterpreting conversion. Applies to normal, ObjC, and block
/// pointers.
/// (char*) 0x1001aab0
/// reinterpret_cast<int*>(0)
CK_IntegralToPointer,
/// CK_PointerToIntegral - Pointer to integral. A special kind of
/// reinterpreting conversion. Applies to normal, ObjC, and block
/// pointers.
/// (intptr_t) "help!"
CK_PointerToIntegral,
/// CK_PointerToBoolean - Pointer to boolean conversion. A check
/// against null. Applies to normal, ObjC, and block pointers.
CK_PointerToBoolean,
/// CK_ToVoid - Cast to void, discarding the computed value.
/// (void) malloc(2048)
CK_ToVoid,
/// 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;
CK_VectorSplat,
/// 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
CK_IntegralCast,
/// CK_IntegralToBoolean - Integral to boolean. A check against zero.
/// (bool) i
CK_IntegralToBoolean,
/// CK_IntegralToFloating - Integral to floating point.
/// float f = i;
CK_IntegralToFloating,
/// CK_FloatingToIntegral - Floating point to integral. Rounds
/// towards zero, discarding any fractional component.
/// (int) f
CK_FloatingToIntegral,
/// CK_FloatingToBoolean - Floating point to boolean.
/// (bool) f
CK_FloatingToBoolean,
// CK_BooleanToSignedIntegral - Convert a boolean to -1 or 0 for true and
// false, respectively.
CK_BooleanToSignedIntegral,
/// CK_FloatingCast - Casting between floating types of different size.
/// (double) f
/// (float) ld
CK_FloatingCast,
/// CK_CPointerToObjCPointerCast - Casting a C pointer kind to an
/// Objective-C pointer.
CK_CPointerToObjCPointerCast,
/// 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.
CK_AnyPointerToBlockPointerCast,
/// \brief Converting between two Objective-C object types, which
/// can occur when performing reference binding to an Objective-C
/// object.
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
CK_IntegralComplexToFloatingComplex,
/// \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,
/// \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,
/// \brief [ARC] Reclaim a retainable object pointer object that may
/// have been produced and autoreleased as part of a function return
/// sequence.
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.
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.
CK_CopyAndAutoreleaseBlockObject,
// Convert a builtin function to a function pointer; only allowed in the
// callee of a call expression.
CK_BuiltinFnToFnPtr,
// Convert a zero value for OpenCL event_t initialization.
CK_ZeroToOCLEvent,
// Convert a pointer to a different address space.
CK_AddressSpaceConversion
#define CAST_OPERATION(Name) CK_##Name,
#include "clang/AST/OperationKinds.def"
};
static const CastKind CK_Invalid = static_cast<CastKind>(-1);
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.
#define BINARY_OPERATION(Name, Spelling) BO_##Name,
#include "clang/AST/OperationKinds.def"
};
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.
UO_Coawait // [C++ Coroutines] co_await operator
#define UNARY_OPERATION(Name, Spelling) UO_##Name,
#include "clang/AST/OperationKinds.def"
};
/// \brief The kind of bridging performed by the Objective-C bridge cast.
@ -355,6 +48,6 @@ enum ObjCBridgeCastKind {
OBC_BridgeRetained
};
}
} // end namespace clang
#endif

View File

@ -43,6 +43,7 @@ module Clang_Basic {
textual header "Basic/OpenCLExtensions.def"
textual header "Basic/OpenCLImageTypes.def"
textual header "Basic/OpenMPKinds.def"
textual header "Basic/OperationKinds.def"
textual header "Basic/OperatorKinds.def"
textual header "Basic/Sanitizers.def"
textual header "Basic/TokenKinds.def"

View File

@ -1084,20 +1084,8 @@ StringLiteral::getLocationOfByte(unsigned ByteNo, const SourceManager &SM,
/// corresponds to, e.g. "sizeof" or "[pre]++".
StringRef UnaryOperator::getOpcodeStr(Opcode Op) {
switch (Op) {
case UO_PostInc: return "++";
case UO_PostDec: return "--";
case UO_PreInc: return "++";
case UO_PreDec: return "--";
case UO_AddrOf: return "&";
case UO_Deref: return "*";
case UO_Plus: return "+";
case UO_Minus: return "-";
case UO_Not: return "~";
case UO_LNot: return "!";
case UO_Real: return "__real";
case UO_Imag: return "__imag";
case UO_Extension: return "__extension__";
case UO_Coawait: return "co_await";
#define UNARY_OPERATION(Name, Spelling) case UO_##Name: return Spelling;
#include "clang/AST/OperationKinds.def"
}
llvm_unreachable("Unknown unary operator");
}
@ -1608,120 +1596,9 @@ bool CastExpr::CastConsistency() const {
const char *CastExpr::getCastKindName() const {
switch (getCastKind()) {
case CK_Dependent:
return "Dependent";
case CK_BitCast:
return "BitCast";
case CK_LValueBitCast:
return "LValueBitCast";
case CK_LValueToRValue:
return "LValueToRValue";
case CK_NoOp:
return "NoOp";
case CK_BaseToDerived:
return "BaseToDerived";
case CK_DerivedToBase:
return "DerivedToBase";
case CK_UncheckedDerivedToBase:
return "UncheckedDerivedToBase";
case CK_Dynamic:
return "Dynamic";
case CK_ToUnion:
return "ToUnion";
case CK_ArrayToPointerDecay:
return "ArrayToPointerDecay";
case CK_FunctionToPointerDecay:
return "FunctionToPointerDecay";
case CK_NullToMemberPointer:
return "NullToMemberPointer";
case CK_NullToPointer:
return "NullToPointer";
case CK_BaseToDerivedMemberPointer:
return "BaseToDerivedMemberPointer";
case CK_DerivedToBaseMemberPointer:
return "DerivedToBaseMemberPointer";
case CK_ReinterpretMemberPointer:
return "ReinterpretMemberPointer";
case CK_UserDefinedConversion:
return "UserDefinedConversion";
case CK_ConstructorConversion:
return "ConstructorConversion";
case CK_IntegralToPointer:
return "IntegralToPointer";
case CK_PointerToIntegral:
return "PointerToIntegral";
case CK_PointerToBoolean:
return "PointerToBoolean";
case CK_ToVoid:
return "ToVoid";
case CK_VectorSplat:
return "VectorSplat";
case CK_IntegralCast:
return "IntegralCast";
case CK_BooleanToSignedIntegral:
return "BooleanToSignedIntegral";
case CK_IntegralToBoolean:
return "IntegralToBoolean";
case CK_IntegralToFloating:
return "IntegralToFloating";
case CK_FloatingToIntegral:
return "FloatingToIntegral";
case CK_FloatingCast:
return "FloatingCast";
case CK_FloatingToBoolean:
return "FloatingToBoolean";
case CK_MemberPointerToBoolean:
return "MemberPointerToBoolean";
case CK_CPointerToObjCPointerCast:
return "CPointerToObjCPointerCast";
case CK_BlockPointerToObjCPointerCast:
return "BlockPointerToObjCPointerCast";
case CK_AnyPointerToBlockPointerCast:
return "AnyPointerToBlockPointerCast";
case CK_ObjCObjectLValueCast:
return "ObjCObjectLValueCast";
case CK_FloatingRealToComplex:
return "FloatingRealToComplex";
case CK_FloatingComplexToReal:
return "FloatingComplexToReal";
case CK_FloatingComplexToBoolean:
return "FloatingComplexToBoolean";
case CK_FloatingComplexCast:
return "FloatingComplexCast";
case CK_FloatingComplexToIntegralComplex:
return "FloatingComplexToIntegralComplex";
case CK_IntegralRealToComplex:
return "IntegralRealToComplex";
case CK_IntegralComplexToReal:
return "IntegralComplexToReal";
case CK_IntegralComplexToBoolean:
return "IntegralComplexToBoolean";
case CK_IntegralComplexCast:
return "IntegralComplexCast";
case CK_IntegralComplexToFloatingComplex:
return "IntegralComplexToFloatingComplex";
case CK_ARCConsumeObject:
return "ARCConsumeObject";
case CK_ARCProduceObject:
return "ARCProduceObject";
case CK_ARCReclaimReturnedObject:
return "ARCReclaimReturnedObject";
case CK_ARCExtendBlockObject:
return "ARCExtendBlockObject";
case CK_AtomicToNonAtomic:
return "AtomicToNonAtomic";
case CK_NonAtomicToAtomic:
return "NonAtomicToAtomic";
case CK_CopyAndAutoreleaseBlockObject:
return "CopyAndAutoreleaseBlockObject";
case CK_BuiltinFnToFnPtr:
return "BuiltinFnToFnPtr";
case CK_ZeroToOCLEvent:
return "ZeroToOCLEvent";
case CK_AddressSpaceConversion:
return "AddressSpaceConversion";
#define CAST_OPERATION(Name) case CK_##Name: return #Name;
#include "clang/AST/OperationKinds.def"
}
llvm_unreachable("Unhandled cast kind!");
}
@ -1818,40 +1695,9 @@ CStyleCastExpr *CStyleCastExpr::CreateEmpty(const ASTContext &C,
/// corresponds to, e.g. "<<=".
StringRef BinaryOperator::getOpcodeStr(Opcode Op) {
switch (Op) {
case BO_PtrMemD: return ".*";
case BO_PtrMemI: return "->*";
case BO_Mul: return "*";
case BO_Div: return "/";
case BO_Rem: return "%";
case BO_Add: return "+";
case BO_Sub: return "-";
case BO_Shl: return "<<";
case BO_Shr: return ">>";
case BO_LT: return "<";
case BO_GT: return ">";
case BO_LE: return "<=";
case BO_GE: return ">=";
case BO_EQ: return "==";
case BO_NE: return "!=";
case BO_And: return "&";
case BO_Xor: return "^";
case BO_Or: return "|";
case BO_LAnd: return "&&";
case BO_LOr: return "||";
case BO_Assign: return "=";
case BO_MulAssign: return "*=";
case BO_DivAssign: return "/=";
case BO_RemAssign: return "%=";
case BO_AddAssign: return "+=";
case BO_SubAssign: return "-=";
case BO_ShlAssign: return "<<=";
case BO_ShrAssign: return ">>=";
case BO_AndAssign: return "&=";
case BO_XorAssign: return "^=";
case BO_OrAssign: return "|=";
case BO_Comma: return ",";
#define BINARY_OPERATION(Name, Spelling) case BO_##Name: return Spelling;
#include "clang/AST/OperationKinds.def"
}
llvm_unreachable("Invalid OpCode!");
}