15baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall//===- OperationKinds.h - Operation enums -----------------------*- C++ -*-===//
25baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall//
35baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall//                     The LLVM Compiler Infrastructure
45baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall//
55baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall// This file is distributed under the University of Illinois Open Source
65baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall// License. See LICENSE.TXT for details.
75baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall//
85baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall//===----------------------------------------------------------------------===//
95baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall//
105baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall// This file enumerates the different kinds of operations that can be
115baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall// performed by various expressions.
125baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall//
135baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall//===----------------------------------------------------------------------===//
145baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
155baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall#ifndef LLVM_CLANG_AST_OPERATION_KINDS_H
165baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall#define LLVM_CLANG_AST_OPERATION_KINDS_H
175baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
185baba9d98364a3525d6afa15a04cdad82fd6dd30John McCallnamespace clang {
195baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
20e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall/// CastKind - The kind of operation required for a conversion.
215baba9d98364a3525d6afa15a04cdad82fd6dd30John McCallenum CastKind {
22e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_Dependent - A conversion which cannot yet be analyzed because
23e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// either the expression or target type is dependent.  These are
24e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// created only for explicit casts; dependent ASTs aren't required
25e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// to even approximately type-check.
26e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   (T*) malloc(sizeof(T))
27e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   reinterpret_cast<intptr_t>(A<T>::alloc());
28daa8e4e888758d55a7a759dd4a91b83921cef222John McCall  CK_Dependent,
29daa8e4e888758d55a7a759dd4a91b83921cef222John McCall
30e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_BitCast - A conversion which causes a bit pattern of one type
31e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// to be reinterpreted as a bit pattern of another type.  Generally
32e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// the operands must have equivalent size and unrelated types.
33e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///
341d9b3b25f7ac0d0195bba6b507a684fe5e7943eeJohn McCall  /// The pointer conversion char* -> int* is a bitcast.  A conversion
351d9b3b25f7ac0d0195bba6b507a684fe5e7943eeJohn McCall  /// from any pointer type to a C pointer type is a bitcast unless
361d9b3b25f7ac0d0195bba6b507a684fe5e7943eeJohn McCall  /// it's actually BaseToDerived or DerivedToBase.  A conversion to a
371d9b3b25f7ac0d0195bba6b507a684fe5e7943eeJohn McCall  /// block pointer or ObjC pointer type is a bitcast only if the
381d9b3b25f7ac0d0195bba6b507a684fe5e7943eeJohn McCall  /// operand has the same type kind; otherwise, it's one of the
391d9b3b25f7ac0d0195bba6b507a684fe5e7943eeJohn McCall  /// specialized casts below.
40e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///
41e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// Vector coercions are bitcasts.
425baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_BitCast,
435baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
44e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_LValueBitCast - A conversion which reinterprets the address of
45e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// an l-value as an l-value of a different kind.  Used for
46e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// reinterpret_casts of l-value expressions to reference types.
47e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///    bool b; reinterpret_cast<char&>(b) = 'a';
485baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_LValueBitCast,
490ae287a498b8cec2086fe6b7e753cbb3df63e74aJohn McCall
500ae287a498b8cec2086fe6b7e753cbb3df63e74aJohn McCall  /// CK_LValueToRValue - A conversion which causes the extraction of
510ae287a498b8cec2086fe6b7e753cbb3df63e74aJohn McCall  /// an r-value from the operand gl-value.  The result of an r-value
520ae287a498b8cec2086fe6b7e753cbb3df63e74aJohn McCall  /// conversion is always unqualified.
530ae287a498b8cec2086fe6b7e753cbb3df63e74aJohn McCall  CK_LValueToRValue,
54f6a1648197562e0b133440d612d9af297d0a86ccJohn McCall
55e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_NoOp - A conversion which does not affect the type other than
56e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// (possibly) adding qualifiers.
57e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   int    -> int
58e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   char** -> const char * const *
595baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_NoOp,
605baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
61e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_BaseToDerived - A conversion from a C++ class pointer/reference
62e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// to a derived class pointer/reference.
63e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   B *b = static_cast<B*>(a);
645baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_BaseToDerived,
655baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
66e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_DerivedToBase - A conversion from a C++ class pointer
67e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// to a base class pointer.
68e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   A *a = new B();
695baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_DerivedToBase,
705baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
71e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_UncheckedDerivedToBase - A conversion from a C++ class
72e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// pointer/reference to a base class that can assume that the
73e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// derived pointer is not null.
74e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   const A &a = B();
75e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   b->method_from_a();
765baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_UncheckedDerivedToBase,
775baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
78e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_Dynamic - A C++ dynamic_cast.
795baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_Dynamic,
805baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
81e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_ToUnion - The GCC cast-to-union extension.
82e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   int   -> union { int x; float y; }
83e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   float -> union { int x; float y; }
845baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_ToUnion,
855baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
865baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  /// CK_ArrayToPointerDecay - Array to pointer decay.
87e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   int[10] -> int*
88e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   char[5][6] -> char(*)[6]
895baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_ArrayToPointerDecay,
905baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
9168d114dc3e1d9ef0c0b073edcb824d4d7f37d416Sebastian Redl  /// CK_FunctionToPointerDecay - Function to pointer decay.
92e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   void(int) -> void(*)(int)
935baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_FunctionToPointerDecay,
945baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
95e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_NullToPointer - Null pointer constant to pointer, ObjC
96e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// pointer, or block pointer.
97e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   (void*) 0
98e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   void (^block)() = 0;
99404cd1669c3ba138a9ae0a619bd689cce5aae271John McCall  CK_NullToPointer,
100404cd1669c3ba138a9ae0a619bd689cce5aae271John McCall
101e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_NullToMemberPointer - Null pointer constant to member pointer.
102e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   int A::*mptr = 0;
103e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   int (A::*fptr)(int) = nullptr;
1045baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_NullToMemberPointer,
1055baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
1065baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  /// CK_BaseToDerivedMemberPointer - Member pointer in base class to
1075baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  /// member pointer in derived class.
108e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   int B::*mptr = &A::member;
1095baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_BaseToDerivedMemberPointer,
1105baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
1115baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  /// CK_DerivedToBaseMemberPointer - Member pointer in derived class to
1125baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  /// member pointer in base class.
113e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   int A::*mptr = static_cast<int A::*>(&B::member);
1145baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_DerivedToBaseMemberPointer,
1155baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
116e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_MemberPointerToBoolean - Member pointer to boolean.  A check
117e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// against the null member pointer.
118e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  CK_MemberPointerToBoolean,
119e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall
1204d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall  /// CK_ReinterpretMemberPointer - Reinterpret a member pointer as a
1214d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall  /// different kind of member pointer.  C++ forbids this from
1224d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall  /// crossing between function and object types, but otherwise does
1234d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall  /// not restrict it.  However, the only operation that is permitted
1244d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall  /// on a "punned" member pointer is casting it back to the original
1254d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall  /// type, which is required to be a lossless operation (although
1264d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall  /// many ABIs do not guarantee this on all possible intermediate types).
1274d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall  CK_ReinterpretMemberPointer,
1284d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall
1295baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  /// CK_UserDefinedConversion - Conversion using a user defined type
1305baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  /// conversion function.
131e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///    struct A { operator int(); }; int i = int(A());
1325baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_UserDefinedConversion,
1335baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
134e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_ConstructorConversion - Conversion by constructor.
135e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///    struct A { A(int); }; A a = A(10);
1365baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_ConstructorConversion,
1375baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
138e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_IntegralToPointer - Integral to pointer.  A special kind of
139e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// reinterpreting conversion.  Applies to normal, ObjC, and block
140e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// pointers.
141e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///    (char*) 0x1001aab0
142e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///    reinterpret_cast<int*>(0)
1435baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_IntegralToPointer,
1445baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
145e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_PointerToIntegral - Pointer to integral.  A special kind of
146e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// reinterpreting conversion.  Applies to normal, ObjC, and block
147e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// pointers.
148e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///    (intptr_t) "help!"
1495baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_PointerToIntegral,
150daa8e4e888758d55a7a759dd4a91b83921cef222John McCall
151e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_PointerToBoolean - Pointer to boolean conversion.  A check
152e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// against null.  Applies to normal, ObjC, and block pointers.
153daa8e4e888758d55a7a759dd4a91b83921cef222John McCall  CK_PointerToBoolean,
1545baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
155e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_ToVoid - Cast to void, discarding the computed value.
156e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///    (void) malloc(2048)
1575baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_ToVoid,
1585baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
159e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_VectorSplat - A conversion from an arithmetic type to a
160e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// vector of that element type.  Fills all elements ("splats") with
161e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// the source value.
162e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///    __attribute__((ext_vector_type(4))) int v = 5;
1635baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_VectorSplat,
1645baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
165e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_IntegralCast - A cast between integral types (other than to
166e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// boolean).  Variously a bitcast, a truncation, a sign-extension,
167e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// or a zero-extension.
168e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///    long l = 5;
169e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///    (unsigned) i
1705baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_IntegralCast,
1715baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
172e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_IntegralToBoolean - Integral to boolean.  A check against zero.
173e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///    (bool) i
174daa8e4e888758d55a7a759dd4a91b83921cef222John McCall  CK_IntegralToBoolean,
175daa8e4e888758d55a7a759dd4a91b83921cef222John McCall
1765baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  /// CK_IntegralToFloating - Integral to floating point.
177e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///    float f = i;
1785baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_IntegralToFloating,
1795baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
180e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// CK_FloatingToIntegral - Floating point to integral.  Rounds
181e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// towards zero, discarding any fractional component.
182e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///    (int) f
1835baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_FloatingToIntegral,
184daa8e4e888758d55a7a759dd4a91b83921cef222John McCall
185daa8e4e888758d55a7a759dd4a91b83921cef222John McCall  /// CK_FloatingToBoolean - Floating point to boolean.
186e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///    (bool) f
187daa8e4e888758d55a7a759dd4a91b83921cef222John McCall  CK_FloatingToBoolean,
1885baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
1895baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  /// CK_FloatingCast - Casting between floating types of different size.
190e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///    (double) f
191e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///    (float) ld
1925baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_FloatingCast,
1935baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
1941d9b3b25f7ac0d0195bba6b507a684fe5e7943eeJohn McCall  /// CK_CPointerToObjCPointerCast - Casting a C pointer kind to an
1951d9b3b25f7ac0d0195bba6b507a684fe5e7943eeJohn McCall  /// Objective-C pointer.
1961d9b3b25f7ac0d0195bba6b507a684fe5e7943eeJohn McCall  CK_CPointerToObjCPointerCast,
1975baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
1981d9b3b25f7ac0d0195bba6b507a684fe5e7943eeJohn McCall  /// CK_BlockPointerToObjCPointerCast - Casting a block pointer to an
1991d9b3b25f7ac0d0195bba6b507a684fe5e7943eeJohn McCall  /// ObjC pointer.
2001d9b3b25f7ac0d0195bba6b507a684fe5e7943eeJohn McCall  CK_BlockPointerToObjCPointerCast,
2011d9b3b25f7ac0d0195bba6b507a684fe5e7943eeJohn McCall
2021d9b3b25f7ac0d0195bba6b507a684fe5e7943eeJohn McCall  /// CK_AnyPointerToBlockPointerCast - Casting any non-block pointer
2031d9b3b25f7ac0d0195bba6b507a684fe5e7943eeJohn McCall  /// to a block pointer.  Block-to-block casts are bitcasts.
2045baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  CK_AnyPointerToBlockPointerCast,
2055baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
2065baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  /// \brief Converting between two Objective-C object types, which
2075baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  /// can occur when performing reference binding to an Objective-C
2085baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  /// object.
2092bb5d00fcf71a7b4d478d478be778fff0494aff6John McCall  CK_ObjCObjectLValueCast,
2102bb5d00fcf71a7b4d478d478be778fff0494aff6John McCall
211e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// \brief A conversion of a floating point real to a floating point
212e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// complex of the original type.  Injects the value as the real
213e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// component with a zero imaginary component.
214e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   float -> _Complex float
2152bb5d00fcf71a7b4d478d478be778fff0494aff6John McCall  CK_FloatingRealToComplex,
2162bb5d00fcf71a7b4d478d478be778fff0494aff6John McCall
217e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// \brief Converts a floating point complex to floating point real
218e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// of the source's element type.  Just discards the imaginary
219e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// component.
220e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   _Complex long double -> long double
221f3ea8cfe6b1c2ef0702efe130561e9e66708d799John McCall  CK_FloatingComplexToReal,
222f3ea8cfe6b1c2ef0702efe130561e9e66708d799John McCall
223e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// \brief Converts a floating point complex to bool by comparing
224e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// against 0+0i.
225f3ea8cfe6b1c2ef0702efe130561e9e66708d799John McCall  CK_FloatingComplexToBoolean,
226f3ea8cfe6b1c2ef0702efe130561e9e66708d799John McCall
227e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// \brief Converts between different floating point complex types.
228e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   _Complex float -> _Complex double
2292bb5d00fcf71a7b4d478d478be778fff0494aff6John McCall  CK_FloatingComplexCast,
2302bb5d00fcf71a7b4d478d478be778fff0494aff6John McCall
231e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// \brief Converts from a floating complex to an integral complex.
232e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   _Complex float -> _Complex int
233f3ea8cfe6b1c2ef0702efe130561e9e66708d799John McCall  CK_FloatingComplexToIntegralComplex,
234f3ea8cfe6b1c2ef0702efe130561e9e66708d799John McCall
235e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// \brief Converts from an integral real to an integral complex
236e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// whose element type matches the source.  Injects the value as
237e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// the real component with a zero imaginary component.
238e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   long -> _Complex long
2392bb5d00fcf71a7b4d478d478be778fff0494aff6John McCall  CK_IntegralRealToComplex,
2402bb5d00fcf71a7b4d478d478be778fff0494aff6John McCall
241e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// \brief Converts an integral complex to an integral real of the
242e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// source's element type by discarding the imaginary component.
243e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   _Complex short -> short
244f3ea8cfe6b1c2ef0702efe130561e9e66708d799John McCall  CK_IntegralComplexToReal,
245f3ea8cfe6b1c2ef0702efe130561e9e66708d799John McCall
246e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// \brief Converts an integral complex to bool by comparing against
247e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// 0+0i.
248f3ea8cfe6b1c2ef0702efe130561e9e66708d799John McCall  CK_IntegralComplexToBoolean,
249f3ea8cfe6b1c2ef0702efe130561e9e66708d799John McCall
250e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// \brief Converts between different integral complex types.
251e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   _Complex char -> _Complex long long
252e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   _Complex unsigned int -> _Complex signed int
2532bb5d00fcf71a7b4d478d478be778fff0494aff6John McCall  CK_IntegralComplexCast,
2542bb5d00fcf71a7b4d478d478be778fff0494aff6John McCall
255e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  /// \brief Converts from an integral complex to a floating complex.
256e2b768877b77fa4e00171ee6e6443722e0f3d111John McCall  ///   _Complex unsigned -> _Complex float
257f85e193739c953358c865005855253af4f68a497John McCall  CK_IntegralComplexToFloatingComplex,
258f85e193739c953358c865005855253af4f68a497John McCall
259dc05b11c67331016473fbc7909827b1b89c9616bJohn McCall  /// \brief [ARC] Produces a retainable object pointer so that it may
260dc05b11c67331016473fbc7909827b1b89c9616bJohn McCall  /// be consumed, e.g. by being passed to a consuming parameter.
261dc05b11c67331016473fbc7909827b1b89c9616bJohn McCall  /// Calls objc_retain.
26233e56f3273457bfa22c7c50bc46cf5a18216863dJohn McCall  CK_ARCProduceObject,
263f85e193739c953358c865005855253af4f68a497John McCall
264dc05b11c67331016473fbc7909827b1b89c9616bJohn McCall  /// \brief [ARC] Consumes a retainable object pointer that has just
265dc05b11c67331016473fbc7909827b1b89c9616bJohn McCall  /// been produced, e.g. as the return value of a retaining call.
266dc05b11c67331016473fbc7909827b1b89c9616bJohn McCall  /// Enters a cleanup to call objc_release at some indefinite time.
26733e56f3273457bfa22c7c50bc46cf5a18216863dJohn McCall  CK_ARCConsumeObject,
2687e5e5f4cc36fe50f46ad76dca7a266434c94f475John McCall
269dc05b11c67331016473fbc7909827b1b89c9616bJohn McCall  /// \brief [ARC] Reclaim a retainable object pointer object that may
270dc05b11c67331016473fbc7909827b1b89c9616bJohn McCall  /// have been produced and autoreleased as part of a function return
2717e5e5f4cc36fe50f46ad76dca7a266434c94f475John McCall  /// sequence.
27233e56f3273457bfa22c7c50bc46cf5a18216863dJohn McCall  CK_ARCReclaimReturnedObject,
273dc05b11c67331016473fbc7909827b1b89c9616bJohn McCall
274dc05b11c67331016473fbc7909827b1b89c9616bJohn McCall  /// \brief [ARC] Causes a value of block type to be copied to the
275dc05b11c67331016473fbc7909827b1b89c9616bJohn McCall  /// heap, if it is not already there.  A number of other operations
276dc05b11c67331016473fbc7909827b1b89c9616bJohn McCall  /// in ARC cause blocks to be copied; this is for cases where that
277dc05b11c67331016473fbc7909827b1b89c9616bJohn McCall  /// would not otherwise be guaranteed, such as when casting to a
278dc05b11c67331016473fbc7909827b1b89c9616bJohn McCall  /// non-block pointer type.
2797a7ee3033e44b45630981355460ef89efa0bdcc4David Chisnall  CK_ARCExtendBlockObject,
2807a7ee3033e44b45630981355460ef89efa0bdcc4David Chisnall
2817a7ee3033e44b45630981355460ef89efa0bdcc4David Chisnall  /// \brief Converts from _Atomic(T) to T.
2827a7ee3033e44b45630981355460ef89efa0bdcc4David Chisnall  CK_AtomicToNonAtomic,
2837a7ee3033e44b45630981355460ef89efa0bdcc4David Chisnall  /// \brief Converts from T to _Atomic(T).
284ac1303eca6cbe3e623fb5ec6fe7ec184ef4b0dfaDouglas Gregor  CK_NonAtomicToAtomic,
285ac1303eca6cbe3e623fb5ec6fe7ec184ef4b0dfaDouglas Gregor
286ac1303eca6cbe3e623fb5ec6fe7ec184ef4b0dfaDouglas Gregor  /// \brief Causes a block literal to by copied to the heap and then
287ac1303eca6cbe3e623fb5ec6fe7ec184ef4b0dfaDouglas Gregor  /// autoreleased.
288ac1303eca6cbe3e623fb5ec6fe7ec184ef4b0dfaDouglas Gregor  ///
289ac1303eca6cbe3e623fb5ec6fe7ec184ef4b0dfaDouglas Gregor  /// This particular cast kind is used for the conversion from a C++11
290ac1303eca6cbe3e623fb5ec6fe7ec184ef4b0dfaDouglas Gregor  /// lambda expression to a block pointer.
291a6c66cedc022c9e5d45a937d6b8cff491a6bf81bEli Friedman  CK_CopyAndAutoreleaseBlockObject,
292a6c66cedc022c9e5d45a937d6b8cff491a6bf81bEli Friedman
293a6c66cedc022c9e5d45a937d6b8cff491a6bf81bEli Friedman  // Convert a builtin function to a function pointer; only allowed in the
294a6c66cedc022c9e5d45a937d6b8cff491a6bf81bEli Friedman  // callee of a call expression.
295e6b9d802fb7b16d93474c4f1c179ab36202e8a8bGuy Benyei  CK_BuiltinFnToFnPtr,
296e6b9d802fb7b16d93474c4f1c179ab36202e8a8bGuy Benyei
297e6b9d802fb7b16d93474c4f1c179ab36202e8a8bGuy Benyei  // Convert a zero value for OpenCL event_t initialization.
298651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  CK_ZeroToOCLEvent,
299651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines
300651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  // Convert a pointer to a different address space.
301651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  CK_AddressSpaceConversion
3025baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall};
3035baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
304c50a0e3900f1b44503be48457508af372f4dd05aAbramo Bagnarastatic const CastKind CK_Invalid = static_cast<CastKind>(-1);
3055baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
3065baba9d98364a3525d6afa15a04cdad82fd6dd30John McCallenum BinaryOperatorKind {
3075baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  // Operators listed in order of precedence.
3085baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  // Note that additions to this should also update the StmtVisitor class.
3095baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  BO_PtrMemD, BO_PtrMemI,       // [C++ 5.5] Pointer-to-member operators.
3105baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  BO_Mul, BO_Div, BO_Rem,       // [C99 6.5.5] Multiplicative operators.
3115baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  BO_Add, BO_Sub,               // [C99 6.5.6] Additive operators.
3125baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  BO_Shl, BO_Shr,               // [C99 6.5.7] Bitwise shift operators.
3135baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  BO_LT, BO_GT, BO_LE, BO_GE,   // [C99 6.5.8] Relational operators.
3145baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  BO_EQ, BO_NE,                 // [C99 6.5.9] Equality operators.
3155baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  BO_And,                       // [C99 6.5.10] Bitwise AND operator.
3165baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  BO_Xor,                       // [C99 6.5.11] Bitwise XOR operator.
3175baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  BO_Or,                        // [C99 6.5.12] Bitwise OR operator.
3185baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  BO_LAnd,                      // [C99 6.5.13] Logical AND operator.
3195baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  BO_LOr,                       // [C99 6.5.14] Logical OR operator.
3205baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  BO_Assign, BO_MulAssign,      // [C99 6.5.16] Assignment operators.
3215baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  BO_DivAssign, BO_RemAssign,
3225baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  BO_AddAssign, BO_SubAssign,
3235baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  BO_ShlAssign, BO_ShrAssign,
3245baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  BO_AndAssign, BO_XorAssign,
3255baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  BO_OrAssign,
3265baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  BO_Comma                      // [C99 6.5.17] Comma operator.
3275baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall};
3285baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
3295baba9d98364a3525d6afa15a04cdad82fd6dd30John McCallenum UnaryOperatorKind {
3305baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  // Note that additions to this should also update the StmtVisitor class.
3315baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  UO_PostInc, UO_PostDec, // [C99 6.5.2.4] Postfix increment and decrement
3325baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  UO_PreInc, UO_PreDec,   // [C99 6.5.3.1] Prefix increment and decrement
3335baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  UO_AddrOf, UO_Deref,    // [C99 6.5.3.2] Address and indirection
3345baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  UO_Plus, UO_Minus,      // [C99 6.5.3.3] Unary arithmetic
3355baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  UO_Not, UO_LNot,        // [C99 6.5.3.3] Unary arithmetic
3365baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  UO_Real, UO_Imag,       // "__real expr"/"__imag expr" Extension.
3375baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall  UO_Extension            // __extension__ marker.
3385baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall};
3395baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
340f85e193739c953358c865005855253af4f68a497John McCall/// \brief The kind of bridging performed by the Objective-C bridge cast.
341f85e193739c953358c865005855253af4f68a497John McCallenum ObjCBridgeCastKind {
342f85e193739c953358c865005855253af4f68a497John McCall  /// \brief Bridging via __bridge, which does nothing but reinterpret
343f85e193739c953358c865005855253af4f68a497John McCall  /// the bits.
344f85e193739c953358c865005855253af4f68a497John McCall  OBC_Bridge,
345f85e193739c953358c865005855253af4f68a497John McCall  /// \brief Bridging via __bridge_transfer, which transfers ownership of an
346f85e193739c953358c865005855253af4f68a497John McCall  /// Objective-C pointer into ARC.
347f85e193739c953358c865005855253af4f68a497John McCall  OBC_BridgeTransfer,
348f85e193739c953358c865005855253af4f68a497John McCall  /// \brief Bridging via __bridge_retain, which makes an ARC object available
349f85e193739c953358c865005855253af4f68a497John McCall  /// as a +1 C pointer.
350f85e193739c953358c865005855253af4f68a497John McCall  OBC_BridgeRetained
351f85e193739c953358c865005855253af4f68a497John McCall};
352f85e193739c953358c865005855253af4f68a497John McCall
3535baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall}
3545baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall
3555baba9d98364a3525d6afa15a04cdad82fd6dd30John McCall#endif
356