ExprCXX.h revision 17330019f05966762bc952840ef1926b9becb145
15f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===--- ExprCXX.h - Classes for representing expressions -------*- C++ -*-===//
25f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
35f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//                     The LLVM Compiler Infrastructure
45f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// This file is distributed under the University of Illinois Open Source
60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// License. See LICENSE.TXT for details.
75f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
85f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
95f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//  This file defines the Expr interface and subclasses for C++ expressions.
115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#ifndef LLVM_CLANG_AST_EXPRCXX_H
155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#define LLVM_CLANG_AST_EXPRCXX_H
165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
1764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl#include "clang/Basic/TypeTraits.h"
185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "clang/AST/Expr.h"
19c4a1dea2dc56bd1357ec91b829a0b9e68229a13eDaniel Dunbar#include "clang/AST/Decl.h"
205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang {
225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  class CXXConstructorDecl;
244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===//
261060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek// C++ Expressions.
271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===//
281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
29b4609806e9232593ece09ce08b630836e825865cDouglas Gregor/// CXXOperatorCallExpr - Represents a call to an overloaded operator
30b4609806e9232593ece09ce08b630836e825865cDouglas Gregor/// written using operator syntax, e.g., "x + y" or "*p". While
31b4609806e9232593ece09ce08b630836e825865cDouglas Gregor/// semantically equivalent to a normal call, this AST node provides
32b4609806e9232593ece09ce08b630836e825865cDouglas Gregor/// better information about the syntactic representation of the call.
33b4609806e9232593ece09ce08b630836e825865cDouglas Gregorclass CXXOperatorCallExpr : public CallExpr {
34b4609806e9232593ece09ce08b630836e825865cDouglas Gregorpublic:
35b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  CXXOperatorCallExpr(Expr *fn, Expr **args, unsigned numargs, QualType t,
36b4609806e9232593ece09ce08b630836e825865cDouglas Gregor                      SourceLocation operatorloc)
37b4609806e9232593ece09ce08b630836e825865cDouglas Gregor    : CallExpr(CXXOperatorCallExprClass, fn, args, numargs, t, operatorloc) { }
38b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
39b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// getOperator - Returns the kind of overloaded operator that this
40b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// expression refers to.
41b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  OverloadedOperatorKind getOperator() const;
42b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
43b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// getOperatorLoc - Returns the location of the operator symbol in
44b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// the expression. When @c getOperator()==OO_Call, this is the
45b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// location of the right parentheses; when @c
46b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// getOperator()==OO_Subscript, this is the location of the right
47b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// bracket.
48b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  SourceLocation getOperatorLoc() const { return getRParenLoc(); }
49b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
50b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  virtual SourceRange getSourceRange() const;
51b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
52b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  static bool classof(const Stmt *T) {
53b4609806e9232593ece09ce08b630836e825865cDouglas Gregor    return T->getStmtClass() == CXXOperatorCallExprClass;
54b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  }
55b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  static bool classof(const CXXOperatorCallExpr *) { return true; }
56b4609806e9232593ece09ce08b630836e825865cDouglas Gregor};
57b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
5888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// CXXMemberCallExpr - Represents a call to a member function that
5988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// may be written either with member call syntax (e.g., "obj.func()"
6088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// or "objptr->func()") or with normal function-call syntax
6188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// ("func()") within a member function that ends up calling a member
6288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// function. The callee in either case is a MemberExpr that contains
6388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// both the object argument and the member function, while the
6488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// arguments are the arguments within the parentheses (not including
6588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// the object argument).
6688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorclass CXXMemberCallExpr : public CallExpr {
6788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorpublic:
6888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  CXXMemberCallExpr(Expr *fn, Expr **args, unsigned numargs, QualType t,
6988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor                      SourceLocation rparenloc)
7088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor    : CallExpr(CXXMemberCallExprClass, fn, args, numargs, t, rparenloc) { }
7188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
7288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  /// getImplicitObjectArgument - Retrieves the implicit object
7388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  /// argument for the member call. For example, in "x.f(5)", this
7488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  /// operation would return "x".
7588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  Expr *getImplicitObjectArgument();
7688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
7788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  static bool classof(const Stmt *T) {
7888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor    return T->getStmtClass() == CXXMemberCallExprClass;
7988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  }
8088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  static bool classof(const CXXMemberCallExpr *) { return true; }
8188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor};
8288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
8349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXNamedCastExpr - Abstract class common to all of the C++ "named"
8449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c
8549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// const_cast.
8649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
8749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This abstract class is inherited by all of the classes
8849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// representing "named" casts, e.g., CXXStaticCastExpr,
8949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr.
9049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXNamedCastExpr : public ExplicitCastExpr {
911060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekprivate:
921060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation Loc; // the location of the casting op
9349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
9449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorprotected:
9549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  CXXNamedCastExpr(StmtClass SC, QualType ty, Expr *op, QualType writtenTy,
9649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor                   SourceLocation l)
9749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    : ExplicitCastExpr(SC, ty, op, writtenTy), Loc(l) {}
9849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
991060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
10049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  const char *getCastName() const;
10149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
1021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
1031060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd());
1041060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
1051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
10649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    switch (T->getStmtClass()) {
10749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXNamedCastExprClass:
10849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXStaticCastExprClass:
10949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXDynamicCastExprClass:
11049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXReinterpretCastExprClass:
11149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXConstCastExprClass:
11249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return true;
11349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    default:
11449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return false;
11549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    }
1161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
11749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXNamedCastExpr *) { return true; }
1181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
11949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  virtual void EmitImpl(llvm::Serializer& S) const;
12049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static CXXNamedCastExpr *CreateImpl(llvm::Deserializer& D, ASTContext& C,
12149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor                                      StmtClass SC);
12249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
12349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
12449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]).
12549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
12649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g.,
12749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c static_cast<int>(1.0).
12849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr {
12949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
13049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  CXXStaticCastExpr(QualType ty, Expr *op, QualType writtenTy, SourceLocation l)
13149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    : CXXNamedCastExpr(CXXStaticCastExprClass, ty, op, writtenTy, l) {}
13249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
13349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const Stmt *T) {
13449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXStaticCastExprClass;
13549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
13649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXStaticCastExpr *) { return true; }
13749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
13849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
13949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression
14049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// (C++ [expr.dynamic.cast]), which may perform a run-time check to
14149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// determine how to perform the type cast.
14249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
14349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g.,
14449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c dynamic_cast<Derived*>(BasePtr).
14549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr {
14649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
14749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  CXXDynamicCastExpr(QualType ty, Expr *op, QualType writtenTy, SourceLocation l)
14849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, op, writtenTy, l) {}
14949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
15049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const Stmt *T) {
15149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXDynamicCastExprClass;
15249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
15349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXDynamicCastExpr *) { return true; }
15449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
15549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
15649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++
15749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// [expr.reinterpret.cast]), which provides a differently-typed view
15849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// of a value but performs no actual work at run time.
15949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
16049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g.,
16149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr).
16249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr {
16349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
16449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  CXXReinterpretCastExpr(QualType ty, Expr *op, QualType writtenTy,
16549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor                         SourceLocation l)
16649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, op, writtenTy, l) {}
16749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
16849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const Stmt *T) {
16949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXReinterpretCastExprClass;
17049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
17149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXReinterpretCastExpr *) { return true; }
17249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
17349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
17449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]),
17549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// which can remove type qualifiers but does not change the underlying value.
17649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
17749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g.,
17849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c const_cast<char*>(PtrToConstChar).
17949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr {
18049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
18149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  CXXConstCastExpr(QualType ty, Expr *op, QualType writtenTy,
18249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor                   SourceLocation l)
18349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    : CXXNamedCastExpr(CXXConstCastExprClass, ty, op, writtenTy, l) {}
18449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
18549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const Stmt *T) {
18649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXConstCastExprClass;
18749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
18849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXConstCastExpr *) { return true; }
1891060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
1901060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
1911060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal.
1921060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///
1931060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr {
1941060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool Value;
1951060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation Loc;
1961060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
1971060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) :
1981060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    Expr(CXXBoolLiteralExprClass, Ty), Value(val), Loc(l) {}
1991060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
2001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool getValue() const { return Value; }
2015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
2021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
2035f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
2041060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
2051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXBoolLiteralExprClass;
2061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
2071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXBoolLiteralExpr *) { return true; }
2085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
2091060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
2101060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
2111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
2121060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
2131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
214c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets
215c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly
216c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression.
217c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl///
218c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr)
219c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr {
220c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate:
221c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  bool isTypeOp : 1;
222d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl  union {
223d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    void *Ty;
224d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    Stmt *Ex;
225d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl  } Operand;
226c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  SourceRange Range;
227c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
228c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic:
229c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  CXXTypeidExpr(bool isTypeOp, void *op, QualType Ty, const SourceRange r) :
230d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl      Expr(CXXTypeidExprClass, Ty), isTypeOp(isTypeOp), Range(r) {
231d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    if (isTypeOp)
232d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl      Operand.Ty = op;
233d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    else
234d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl      // op was an Expr*, so cast it back to that to be safe
235d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl      Operand.Ex = static_cast<Stmt*>(op);
236d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl  }
237c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
238c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  bool isTypeOperand() const { return isTypeOp; }
239c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  QualType getTypeOperand() const {
240c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
241d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    return QualType::getFromOpaquePtr(Operand.Ty);
242c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
243c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  Expr* getExprOperand() const {
244c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
245d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    return static_cast<Expr*>(Operand.Ex);
246c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
247c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
248c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual SourceRange getSourceRange() const {
249c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    return Range;
250c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
251c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static bool classof(const Stmt *T) {
252c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    return T->getStmtClass() == CXXTypeidExprClass;
253c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
254c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static bool classof(const CXXTypeidExpr *) { return true; }
255c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
256c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  // Iterators
257c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual child_iterator child_begin();
258c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual child_iterator child_end();
259c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
260c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual void EmitImpl(llvm::Serializer& S) const;
261c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static CXXTypeidExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
262c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl};
263c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
264796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a
265796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is
266796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example:
267796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///
268796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code
269796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo {
270796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public:
271796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///   void bar();
272796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///   void test() { this->bar(); }
273796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// };
274796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode
275796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr {
276796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  SourceLocation Loc;
277796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
278796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic:
279796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  CXXThisExpr(SourceLocation L, QualType Type)
280796da18402f286b897782a298ae3b20c459c102eDouglas Gregor    : Expr(CXXThisExprClass, Type), Loc(L) { }
281796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
282796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
283796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
284796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  static bool classof(const Stmt *T) {
285796da18402f286b897782a298ae3b20c459c102eDouglas Gregor    return T->getStmtClass() == CXXThisExprClass;
286796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  }
287796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  static bool classof(const CXXThisExpr *) { return true; }
288796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
289796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  // Iterators
290796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual child_iterator child_begin();
291796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual child_iterator child_end();
292796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
293796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual void EmitImpl(llvm::Serializer& S) const;
294796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  static CXXThisExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
295796da18402f286b897782a298ae3b20c459c102eDouglas Gregor};
296796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
2971060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  CXXThrowExpr - [C++ 15] C++ Throw Expression.  This handles
2981060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  'throw' and 'throw' assignment-expression.  When
2991060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  assignment-expression isn't present, Op will be null.
3001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///
3011060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr {
3021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Stmt *Op;
3031060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation ThrowLoc;
3041060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
3051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Ty is the void type which is used as the result type of the
3061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // exepression.  The l is the location of the throw keyword.  expr
3071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // can by null, if the optional expression to throw isn't present.
3081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) :
3091060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    Expr(CXXThrowExprClass, Ty), Op(expr), ThrowLoc(l) {}
3101060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); }
3111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Expr *getSubExpr() { return cast_or_null<Expr>(Op); }
3121060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
3141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    if (getSubExpr() == 0)
3151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek      return SourceRange(ThrowLoc, ThrowLoc);
3161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd());
3171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
3181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
3201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXThrowExprClass;
3211060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
3221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXThrowExpr *) { return true; }
3231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
3251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
3261060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
3271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
3281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a
3301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding
3311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly
3321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters.
3331060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr {
3341060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  ParmVarDecl *Param;
3351060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
3361060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Param is the parameter whose default argument is used by this
3371060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // expression.
3381060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  explicit CXXDefaultArgExpr(ParmVarDecl *param)
33961366e9cd41a6dbde4e66416dac21269c8ac1d94Douglas Gregor    : Expr(CXXDefaultArgExprClass,
34061366e9cd41a6dbde4e66416dac21269c8ac1d94Douglas Gregor           param->hasUnparsedDefaultArg()? param->getType().getNonReferenceType()
34161366e9cd41a6dbde4e66416dac21269c8ac1d94Douglas Gregor                                         : param->getDefaultArg()->getType()),
3421060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek      Param(param) { }
3431060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3441060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the parameter that the argument was created from.
3451060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  const ParmVarDecl *getParam() const { return Param; }
3461060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  ParmVarDecl *getParam() { return Param; }
3471060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3481060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the actual argument to the function call.
3491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  const Expr *getExpr() const { return Param->getDefaultArg(); }
3501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Expr *getExpr() { return Param->getDefaultArg(); }
3511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
3531060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // Default argument expressions have no representation in the
3541060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // source, so they have an empty source range.
3551060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange();
3561060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
3571060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3581060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
3591060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXDefaultArgExprClass;
3601060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
3611060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXDefaultArgExpr *) { return true; }
3621060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3631060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
3641060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
3651060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
3661060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Serialization
3681060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
3691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static CXXDefaultArgExpr* CreateImpl(llvm::Deserializer& D,
3701060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek                                       ASTContext& C);
3711060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
372987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
37349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion
37449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c
37549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5);
37649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr {
377987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation TyBeginLoc;
378987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
379987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic:
38049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  CXXFunctionalCastExpr(QualType ty, QualType writtenTy,
38149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor                        SourceLocation tyBeginLoc, Expr *castExpr,
382987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis                        SourceLocation rParenLoc) :
38349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    ExplicitCastExpr(CXXFunctionalCastExprClass, ty, castExpr, writtenTy),
384987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
385987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
386987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
387987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getRParenLoc() const { return RParenLoc; }
388987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
389987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
390987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return SourceRange(TyBeginLoc, RParenLoc);
391987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
392987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const Stmt *T) {
393987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return T->getStmtClass() == CXXFunctionalCastExprClass;
394987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
395987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const CXXFunctionalCastExpr *) { return true; }
396987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
397987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual void EmitImpl(llvm::Serializer& S) const;
398987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static CXXFunctionalCastExpr *
399987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis      CreateImpl(llvm::Deserializer& D, ASTContext& C);
400987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
401987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
402506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a
403506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object.
404506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///
405506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// This expression type represents a C++ "functional" cast
406506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a
407506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor to build a temporary object. If N == 0 but no
408506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor will be called (because the functional cast is
409506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// performing a value-initialized an object whose class type has no
410506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-declared constructors), CXXZeroInitValueExpr will represent
411506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// the functional cast. Finally, with N == 1 arguments the functional
412506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// cast expression will be represented by CXXFunctionalCastExpr.
413506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example:
414506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code
415506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); }
416506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///
417506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() {
418506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///   return X(1, 3.14f); // creates a CXXTemporaryObjectExpr
419506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// };
420506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode
421506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorclass CXXTemporaryObjectExpr : public Expr {
422506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation TyBeginLoc;
423506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation RParenLoc;
424506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  CXXConstructorDecl *Constructor;
425506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  Stmt **Args;
426506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  unsigned NumArgs;
427506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
428506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic:
429506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  CXXTemporaryObjectExpr(CXXConstructorDecl *Cons, QualType writtenTy,
430506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor                         SourceLocation tyBeginLoc, Expr **Args,
431506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor                         unsigned NumArgs, SourceLocation rParenLoc);
432506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
433506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  ~CXXTemporaryObjectExpr();
434506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
435506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
436506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
437506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
438506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  typedef ExprIterator arg_iterator;
439506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  typedef ConstExprIterator const_arg_iterator;
440506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
441506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  arg_iterator arg_begin() { return Args; }
442506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  arg_iterator arg_end() { return Args + NumArgs; }
443506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  const_arg_iterator arg_begin() const { return Args; }
444506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  const_arg_iterator arg_end() const { return Args + NumArgs; }
445506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
446506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  virtual SourceRange getSourceRange() const {
447506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor    return SourceRange(TyBeginLoc, RParenLoc);
448506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  }
449506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  static bool classof(const Stmt *T) {
450506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor    return T->getStmtClass() == CXXTemporaryObjectExprClass;
451506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  }
452506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  static bool classof(const CXXTemporaryObjectExpr *) { return true; }
453506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
454506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  // Iterators
455506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  virtual child_iterator child_begin();
456506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  virtual child_iterator child_end();
457506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
458506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  virtual void EmitImpl(llvm::Serializer& S) const;
459506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  static CXXTemporaryObjectExpr *CreateImpl(llvm::Deserializer& D, ASTContext& C);
460506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor};
461506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
462987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// CXXZeroInitValueExpr - [C++ 5.2.3p2]
463506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type
464506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// T, which is either a non-class type or a class type without any
465506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-defined constructors.
466987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis///
467987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidisclass CXXZeroInitValueExpr : public Expr {
468987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation TyBeginLoc;
469987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
470987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
471987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic:
472987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  CXXZeroInitValueExpr(QualType ty, SourceLocation tyBeginLoc,
473987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis                       SourceLocation rParenLoc ) :
474987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    Expr(CXXZeroInitValueExprClass, ty),
475987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
476987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
477987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
478987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getRParenLoc() const { return RParenLoc; }
479987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
4804c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// @brief Whether this initialization expression was
4814c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// implicitly-generated.
4824c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  bool isImplicit() const {
4834c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor    return TyBeginLoc.isInvalid() && RParenLoc.isInvalid();
4844c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  }
4854c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor
486987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
487987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return SourceRange(TyBeginLoc, RParenLoc);
488987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
489987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
490987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const Stmt *T) {
491987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return T->getStmtClass() == CXXZeroInitValueExprClass;
492987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
493987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const CXXZeroInitValueExpr *) { return true; }
494987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
495987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  // Iterators
496987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual child_iterator child_begin();
497987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual child_iterator child_end();
498987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
499987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual void EmitImpl(llvm::Serializer& S) const;
500987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static CXXZeroInitValueExpr *
501987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis      CreateImpl(llvm::Deserializer& D, ASTContext& C);
502987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
503987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
5049e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// CXXConditionDeclExpr - Condition declaration of a if/switch/while/for
5059e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// statement, e.g: "if (int x = f()) {...}".
5069e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// The main difference with DeclRefExpr is that CXXConditionDeclExpr owns the
5079e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// decl that it references.
5089e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis///
5099e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidisclass CXXConditionDeclExpr : public DeclRefExpr {
5109e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidispublic:
5119e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  CXXConditionDeclExpr(SourceLocation startLoc,
5129e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis                       SourceLocation eqLoc, VarDecl *var)
5139d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor    : DeclRefExpr(CXXConditionDeclExprClass, var,
5149d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor                  var->getType().getNonReferenceType(), startLoc) {}
5159e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
5169e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  virtual void Destroy(ASTContext& Ctx);
5179e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
5189e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  SourceLocation getStartLoc() const { return getLocation(); }
5199e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
5209e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  VarDecl *getVarDecl() { return cast<VarDecl>(getDecl()); }
5219e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  const VarDecl *getVarDecl() const { return cast<VarDecl>(getDecl()); }
5229e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
5239e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
5249e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis    return SourceRange(getStartLoc(), getVarDecl()->getInit()->getLocEnd());
5259e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  }
5269e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
5279e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  static bool classof(const Stmt *T) {
5289e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis    return T->getStmtClass() == CXXConditionDeclExprClass;
5299e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  }
5309e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  static bool classof(const CXXConditionDeclExpr *) { return true; }
5319e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
5329e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  // Iterators
5339e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  virtual child_iterator child_begin();
5349e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  virtual child_iterator child_end();
5359e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
5369e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  // FIXME: Implement these.
5379e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  //virtual void EmitImpl(llvm::Serializer& S) const;
5389e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  //static CXXConditionDeclExpr *
5399e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  //    CreateImpl(llvm::Deserializer& D, ASTContext& C);
5409e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis};
5419e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
5424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls,
5434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)".
5444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr {
5454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Was the usage ::new, i.e. is the global new to be used?
5464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalNew : 1;
5474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Was the form (type-id) used? Otherwise, it was new-type-id.
5484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool ParenTypeId : 1;
5494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is there an initializer? If not, built-ins are uninitialized, else they're
5504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // value-initialized.
5514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool Initializer : 1;
552cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // Do we allocate an array? If so, the first SubExpr is the size expression.
553cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool Array : 1;
5544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The number of placement new arguments.
5554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned NumPlacementArgs : 14;
5564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The number of constructor arguments. This may be 1 even for non-class
5574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // types; use the pseudo copy constructor.
558cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  unsigned NumConstructorArgs : 14;
559cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // Contains an optional array size expression, any number of optional
560cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // placement arguments, and any number of optional constructor arguments,
561cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // in that order.
5624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt **SubExprs;
5634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the allocation function used.
5644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorNew;
5654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the deallocation function used in case of error. May be null.
5664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
5674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the constructor used. Cannot be null if AllocType is a record;
5684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // it would still point at the default constructor (even an implicit one).
5694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Must be null for all other types.
5704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *Constructor;
5714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
5724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation StartLoc;
5734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation EndLoc;
5744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
5754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Deserialization constructor
576cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  CXXNewExpr(QualType ty, bool globalNew, bool parenTypeId, bool initializer,
577cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl             bool array, unsigned numPlaceArgs, unsigned numConsArgs,
578cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl             Stmt **subExprs, FunctionDecl *operatorNew,
579cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl             FunctionDecl *operatorDelete, CXXConstructorDecl *constructor,
580cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl             SourceLocation startLoc, SourceLocation endLoc)
5814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    : Expr(CXXNewExprClass, ty), GlobalNew(globalNew), ParenTypeId(parenTypeId),
582cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl      Initializer(initializer), Array(array), NumPlacementArgs(numPlaceArgs),
583cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl      NumConstructorArgs(numConsArgs), SubExprs(subExprs),
5844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl      OperatorNew(operatorNew), OperatorDelete(operatorDelete),
585cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl      Constructor(constructor), StartLoc(startLoc), EndLoc(endLoc)
5864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  { }
5874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
5884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXNewExpr(bool globalNew, FunctionDecl *operatorNew, Expr **placementArgs,
589cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl             unsigned numPlaceArgs, bool ParenTypeId, Expr *arraySize,
5904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             CXXConstructorDecl *constructor, bool initializer,
5914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             Expr **constructorArgs, unsigned numConsArgs,
5924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             FunctionDecl *operatorDelete, QualType ty,
5934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             SourceLocation startLoc, SourceLocation endLoc);
5944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  ~CXXNewExpr() {
5954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    delete[] SubExprs;
5964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
5974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
598cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  QualType getAllocatedType() const {
599cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    assert(getType()->isPointerType());
600cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return getType()->getAsPointerType()->getPointeeType();
601cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
6024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
6034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorNew() const { return OperatorNew; }
6044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
6054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *getConstructor() const { return Constructor; }
6064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
607cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool isArray() const { return Array; }
608cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  Expr *getArraySize() {
609cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
610cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
611cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  const Expr *getArraySize() const {
612cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
613cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
614cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl
6154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumPlacementArgs() const { return NumPlacementArgs; }
6164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getPlacementArg(unsigned i) {
6174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
618cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
6194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
6204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getPlacementArg(unsigned i) const {
6214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
622cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
6234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
6244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
6254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalNew() const { return GlobalNew; }
6264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isParenTypeId() const { return ParenTypeId; }
6274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool hasInitializer() const { return Initializer; }
6284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
6294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumConstructorArgs() const { return NumConstructorArgs; }
6304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getConstructorArg(unsigned i) {
6314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
632cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
6334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
6344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getConstructorArg(unsigned i) const {
6354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
636cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
6374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
6384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
6394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ExprIterator arg_iterator;
6404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ConstExprIterator const_arg_iterator;
6414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
6424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_begin() {
643cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
6444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
6454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_end() {
646cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
6474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
6484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_begin() const {
649cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
6504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
6514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_end() const {
652cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
6534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
6544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
6554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_begin() {
656cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
6574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
6584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_end() {
659cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
6604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
6614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_begin() const {
662cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
6634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
6644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_end() const {
665cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
6664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
6674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
6684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual SourceRange getSourceRange() const {
6694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(StartLoc, EndLoc);
6704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
6714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
6724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
6734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXNewExprClass;
6744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
6754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXNewExpr *) { return true; }
6764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
6774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
6784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_begin();
6794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_end();
6804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
6814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual void EmitImpl(llvm::Serializer& S) const;
6824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static CXXNewExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
6834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
6844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
6854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor
6864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray".
6874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr {
6884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this a forced global delete, i.e. "::delete"?
6894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalDelete : 1;
6904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this the array form of delete, i.e. "delete[]"?
6914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool ArrayForm : 1;
6924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the operator delete overload that is used. Could be a member.
6934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
6944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The pointer expression to be deleted.
6954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt *Argument;
6964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Location of the expression.
6974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation Loc;
6984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
6994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm,
7004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl                FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc)
7014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    : Expr(CXXDeleteExprClass, ty), GlobalDelete(globalDelete),
7024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl      ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg),
7034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl      Loc(loc) { }
7044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalDelete() const { return GlobalDelete; }
7064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isArrayForm() const { return ArrayForm; }
7074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
7094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getArgument() { return cast<Expr>(Argument); }
7114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getArgument() const { return cast<Expr>(Argument); }
7124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual SourceRange getSourceRange() const {
7144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(Loc, Argument->getLocEnd());
7154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
7184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXDeleteExprClass;
7194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXDeleteExpr *) { return true; }
7214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
7234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_begin();
7244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_end();
7254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual void EmitImpl(llvm::Serializer& S) const;
7274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static CXXDeleteExpr * CreateImpl(llvm::Deserializer& D, ASTContext& C);
7284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
7294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
73017330019f05966762bc952840ef1926b9becb145Douglas Gregor/// \brief Represents the name of a function that has not been
73117330019f05966762bc952840ef1926b9becb145Douglas Gregor/// resolved to any declaration.
73217330019f05966762bc952840ef1926b9becb145Douglas Gregor///
73317330019f05966762bc952840ef1926b9becb145Douglas Gregor/// Unresolved function names occur when a function name is
73417330019f05966762bc952840ef1926b9becb145Douglas Gregor/// encountered prior to an open parentheses ('(') in a C++ function
73517330019f05966762bc952840ef1926b9becb145Douglas Gregor/// call, and the function name itself did not resolve to a
73617330019f05966762bc952840ef1926b9becb145Douglas Gregor/// declaration. These function names can only be resolved when they
73717330019f05966762bc952840ef1926b9becb145Douglas Gregor/// form the postfix-expression of a function call, so that
73817330019f05966762bc952840ef1926b9becb145Douglas Gregor/// argument-dependent lookup finds declarations corresponding to
73917330019f05966762bc952840ef1926b9becb145Douglas Gregor/// these functions.
74017330019f05966762bc952840ef1926b9becb145Douglas Gregor
7415c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// @code
7425c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// template<typename T> void f(T x) {
74317330019f05966762bc952840ef1926b9becb145Douglas Gregor///   g(x); // g is an unresolved function name (that is also a dependent name)
7445c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// }
7455c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// @endcode
74617330019f05966762bc952840ef1926b9becb145Douglas Gregorclass UnresolvedFunctionNameExpr : public Expr {
74717330019f05966762bc952840ef1926b9becb145Douglas Gregor  /// The name that was present in the source
74817330019f05966762bc952840ef1926b9becb145Douglas Gregor  DeclarationName Name;
7495c37de788529cd9180f22069970737a7208bd625Douglas Gregor
75017330019f05966762bc952840ef1926b9becb145Douglas Gregor  /// The location of this name in the source code
7515c37de788529cd9180f22069970737a7208bd625Douglas Gregor  SourceLocation Loc;
7525c37de788529cd9180f22069970737a7208bd625Douglas Gregor
7535c37de788529cd9180f22069970737a7208bd625Douglas Gregorpublic:
75417330019f05966762bc952840ef1926b9becb145Douglas Gregor  UnresolvedFunctionNameExpr(DeclarationName N, QualType T, SourceLocation L)
75517330019f05966762bc952840ef1926b9becb145Douglas Gregor    : Expr(UnresolvedFunctionNameExprClass, T, false, false), Name(N), Loc(L) { }
7565c37de788529cd9180f22069970737a7208bd625Douglas Gregor
75717330019f05966762bc952840ef1926b9becb145Douglas Gregor  /// \brief Retrieves the name that occurred in the source code.
75817330019f05966762bc952840ef1926b9becb145Douglas Gregor  DeclarationName getName() const { return Name; }
7595c37de788529cd9180f22069970737a7208bd625Douglas Gregor
7605c37de788529cd9180f22069970737a7208bd625Douglas Gregor  /// getLocation - Retrieves the location in the source code where
7615c37de788529cd9180f22069970737a7208bd625Douglas Gregor  /// the name occurred.
7625c37de788529cd9180f22069970737a7208bd625Douglas Gregor  SourceLocation getLocation() const { return Loc; }
7635c37de788529cd9180f22069970737a7208bd625Douglas Gregor
7645c37de788529cd9180f22069970737a7208bd625Douglas Gregor  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
7655c37de788529cd9180f22069970737a7208bd625Douglas Gregor
7665c37de788529cd9180f22069970737a7208bd625Douglas Gregor  static bool classof(const Stmt *T) {
76717330019f05966762bc952840ef1926b9becb145Douglas Gregor    return T->getStmtClass() == UnresolvedFunctionNameExprClass;
7685c37de788529cd9180f22069970737a7208bd625Douglas Gregor  }
76917330019f05966762bc952840ef1926b9becb145Douglas Gregor  static bool classof(const UnresolvedFunctionNameExpr *) { return true; }
7705c37de788529cd9180f22069970737a7208bd625Douglas Gregor
7715c37de788529cd9180f22069970737a7208bd625Douglas Gregor  // Iterators
7725c37de788529cd9180f22069970737a7208bd625Douglas Gregor  virtual child_iterator child_begin();
7735c37de788529cd9180f22069970737a7208bd625Douglas Gregor  virtual child_iterator child_end();
7745c37de788529cd9180f22069970737a7208bd625Douglas Gregor
7755c37de788529cd9180f22069970737a7208bd625Douglas Gregor  virtual void EmitImpl(llvm::Serializer& S) const;
77617330019f05966762bc952840ef1926b9becb145Douglas Gregor  static UnresolvedFunctionNameExpr *CreateImpl(llvm::Deserializer& D, ASTContext& C);
7775c37de788529cd9180f22069970737a7208bd625Douglas Gregor};
7785c37de788529cd9180f22069970737a7208bd625Douglas Gregor
77964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the
78064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates.
78164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example:
78264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true
78364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false
78464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr {
78564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// UTT - The trait.
78664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTrait UTT;
78764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
78864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// Loc - The location of the type trait keyword.
78964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation Loc;
79064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
79164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// RParen - The location of the closing paren.
79264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation RParen;
79364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
79464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// QueriedType - The type we're testing.
79564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  QualType QueriedType;
79664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
79764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic:
79864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, QualType queried,
79964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl                     SourceLocation rparen, QualType ty)
80064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl    : Expr(UnaryTypeTraitExprClass, ty, false, queried->isDependentType()),
80164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl      UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { }
80264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
80364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);}
80464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
80564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTrait getTrait() const { return UTT; }
80664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
80764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  QualType getQueriedType() const { return QueriedType; }
80864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
80964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  bool Evaluate() const;
81064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
81164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const Stmt *T) {
81264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl    return T->getStmtClass() == UnaryTypeTraitExprClass;
81364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  }
81464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const UnaryTypeTraitExpr *) { return true; }
81564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
81664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  // Iterators
81764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual child_iterator child_begin();
81864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual child_iterator child_end();
81964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
82064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual void EmitImpl(llvm::Serializer& S) const;
82164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static UnaryTypeTraitExpr *CreateImpl(llvm::Deserializer& D, ASTContext& C);
82264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl};
82364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
8241a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor/// QualifiedDeclRefExpr - A reference to a declared variable,
8251a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor/// function, enum, etc., that includes a qualification, e.g.,
8261a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor/// "N::foo".
8271a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregorclass QualifiedDeclRefExpr : public DeclRefExpr {
8281a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  /// NestedNameLoc - The location of the beginning of the
8291a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  /// nested-name-specifier that qualifies this declaration.
8301a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  SourceLocation NestedNameLoc;
8311a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor
8321a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregorpublic:
8331a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  QualifiedDeclRefExpr(NamedDecl *d, QualType t, SourceLocation l, bool TD,
8341a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor                       bool VD, SourceLocation nnl)
8351a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor    : DeclRefExpr(QualifiedDeclRefExprClass, d, t, l, TD, VD),
8361a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor      NestedNameLoc(nnl) { }
8371a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor
8381a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  virtual SourceRange getSourceRange() const {
8391a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor    return SourceRange(NestedNameLoc, getLocation());
8401a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  }
8411a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor
8421a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  static bool classof(const Stmt *T) {
8431a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor    return T->getStmtClass() == QualifiedDeclRefExprClass;
8441a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  }
8451a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  static bool classof(const QualifiedDeclRefExpr *) { return true; }
8461a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor
8471a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  virtual void EmitImpl(llvm::Serializer& S) const;
8481a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  static QualifiedDeclRefExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
8491a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor};
8501a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor
8515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}  // end namespace clang
8525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
8535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif
854