ExprCXX.h revision b4609806e9232593ece09ce08b630836e825865c
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
175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "clang/AST/Expr.h"
18c4a1dea2dc56bd1357ec91b829a0b9e68229a13eDaniel Dunbar#include "clang/AST/Decl.h"
195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang {
215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===//
231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek// C++ Expressions.
241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===//
251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
26b4609806e9232593ece09ce08b630836e825865cDouglas Gregor/// CXXOperatorCallExpr - Represents a call to an overloaded operator
27b4609806e9232593ece09ce08b630836e825865cDouglas Gregor/// written using operator syntax, e.g., "x + y" or "*p". While
28b4609806e9232593ece09ce08b630836e825865cDouglas Gregor/// semantically equivalent to a normal call, this AST node provides
29b4609806e9232593ece09ce08b630836e825865cDouglas Gregor/// better information about the syntactic representation of the call.
30b4609806e9232593ece09ce08b630836e825865cDouglas Gregorclass CXXOperatorCallExpr : public CallExpr {
31b4609806e9232593ece09ce08b630836e825865cDouglas Gregorpublic:
32b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  CXXOperatorCallExpr(Expr *fn, Expr **args, unsigned numargs, QualType t,
33b4609806e9232593ece09ce08b630836e825865cDouglas Gregor                      SourceLocation operatorloc)
34b4609806e9232593ece09ce08b630836e825865cDouglas Gregor    : CallExpr(CXXOperatorCallExprClass, fn, args, numargs, t, operatorloc) { }
35b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
36b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// getOperator - Returns the kind of overloaded operator that this
37b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// expression refers to.
38b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  OverloadedOperatorKind getOperator() const;
39b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
40b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// getOperatorLoc - Returns the location of the operator symbol in
41b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// the expression. When @c getOperator()==OO_Call, this is the
42b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// location of the right parentheses; when @c
43b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// getOperator()==OO_Subscript, this is the location of the right
44b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// bracket.
45b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  SourceLocation getOperatorLoc() const { return getRParenLoc(); }
46b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
47b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  virtual SourceRange getSourceRange() const;
48b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
49b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  static bool classof(const Stmt *T) {
50b4609806e9232593ece09ce08b630836e825865cDouglas Gregor    return T->getStmtClass() == CXXOperatorCallExprClass;
51b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  }
52b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  static bool classof(const CXXOperatorCallExpr *) { return true; }
53b4609806e9232593ece09ce08b630836e825865cDouglas Gregor};
54b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
5549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXNamedCastExpr - Abstract class common to all of the C++ "named"
5649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c
5749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// const_cast.
5849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
5949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This abstract class is inherited by all of the classes
6049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// representing "named" casts, e.g., CXXStaticCastExpr,
6149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr.
6249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXNamedCastExpr : public ExplicitCastExpr {
631060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekprivate:
641060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation Loc; // the location of the casting op
6549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
6649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorprotected:
6749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  CXXNamedCastExpr(StmtClass SC, QualType ty, Expr *op, QualType writtenTy,
6849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor                   SourceLocation l)
6949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    : ExplicitCastExpr(SC, ty, op, writtenTy), Loc(l) {}
7049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
711060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
7249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  const char *getCastName() const;
7349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
741060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
751060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd());
761060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
771060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
7849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    switch (T->getStmtClass()) {
7949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXNamedCastExprClass:
8049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXStaticCastExprClass:
8149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXDynamicCastExprClass:
8249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXReinterpretCastExprClass:
8349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXConstCastExprClass:
8449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return true;
8549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    default:
8649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return false;
8749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    }
881060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
8949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXNamedCastExpr *) { return true; }
901060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
9149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  virtual void EmitImpl(llvm::Serializer& S) const;
9249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static CXXNamedCastExpr *CreateImpl(llvm::Deserializer& D, ASTContext& C,
9349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor                                      StmtClass SC);
9449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
9549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
9649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]).
9749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
9849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g.,
9949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c static_cast<int>(1.0).
10049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr {
10149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
10249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  CXXStaticCastExpr(QualType ty, Expr *op, QualType writtenTy, SourceLocation l)
10349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    : CXXNamedCastExpr(CXXStaticCastExprClass, ty, op, writtenTy, l) {}
10449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
10549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const Stmt *T) {
10649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXStaticCastExprClass;
10749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
10849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXStaticCastExpr *) { return true; }
10949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
11049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
11149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression
11249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// (C++ [expr.dynamic.cast]), which may perform a run-time check to
11349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// determine how to perform the type cast.
11449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
11549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g.,
11649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c dynamic_cast<Derived*>(BasePtr).
11749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr {
11849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
11949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  CXXDynamicCastExpr(QualType ty, Expr *op, QualType writtenTy, SourceLocation l)
12049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, op, writtenTy, l) {}
12149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
12249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const Stmt *T) {
12349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXDynamicCastExprClass;
12449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
12549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXDynamicCastExpr *) { return true; }
12649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
12749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
12849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++
12949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// [expr.reinterpret.cast]), which provides a differently-typed view
13049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// of a value but performs no actual work at run time.
13149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
13249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g.,
13349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr).
13449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr {
13549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
13649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  CXXReinterpretCastExpr(QualType ty, Expr *op, QualType writtenTy,
13749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor                         SourceLocation l)
13849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, op, writtenTy, l) {}
13949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
14049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const Stmt *T) {
14149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXReinterpretCastExprClass;
14249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
14349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXReinterpretCastExpr *) { return true; }
14449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
14549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
14649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]),
14749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// which can remove type qualifiers but does not change the underlying value.
14849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
14949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g.,
15049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c const_cast<char*>(PtrToConstChar).
15149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr {
15249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
15349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  CXXConstCastExpr(QualType ty, Expr *op, QualType writtenTy,
15449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor                   SourceLocation l)
15549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    : CXXNamedCastExpr(CXXConstCastExprClass, ty, op, writtenTy, l) {}
15649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
15749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const Stmt *T) {
15849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXConstCastExprClass;
15949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
16049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXConstCastExpr *) { return true; }
1611060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
1621060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
1631060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal.
1641060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///
1651060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr {
1661060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool Value;
1671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation Loc;
1681060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
1691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) :
1701060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    Expr(CXXBoolLiteralExprClass, Ty), Value(val), Loc(l) {}
1711060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
1721060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool getValue() const { return Value; }
1735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
1741060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
1755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
1761060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
1771060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXBoolLiteralExprClass;
1781060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
1791060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXBoolLiteralExpr *) { return true; }
1805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
1811060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
1821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
1831060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
1841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
1851060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
186c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets
187c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly
188c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression.
189c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl///
190c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr)
191c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr {
192c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate:
193c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  bool isTypeOp : 1;
194c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  void *Operand;
195c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  SourceRange Range;
196c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
197c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic:
198c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  CXXTypeidExpr(bool isTypeOp, void *op, QualType Ty, const SourceRange r) :
199c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    Expr(CXXTypeidExprClass, Ty), isTypeOp(isTypeOp), Operand(op), Range(r) {}
200c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
201c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  bool isTypeOperand() const { return isTypeOp; }
202c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  QualType getTypeOperand() const {
203c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
204c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    return QualType::getFromOpaquePtr(Operand);
205c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
206c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  Expr* getExprOperand() const {
207c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
208c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    return static_cast<Expr*>(Operand);
209c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
210c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
211c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual SourceRange getSourceRange() const {
212c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    return Range;
213c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
214c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static bool classof(const Stmt *T) {
215c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    return T->getStmtClass() == CXXTypeidExprClass;
216c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
217c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static bool classof(const CXXTypeidExpr *) { return true; }
218c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
219c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  // Iterators
220c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual child_iterator child_begin();
221c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual child_iterator child_end();
222c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
223c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual void EmitImpl(llvm::Serializer& S) const;
224c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static CXXTypeidExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
225c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl};
226c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
227796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a
228796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is
229796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example:
230796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///
231796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code
232796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo {
233796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public:
234796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///   void bar();
235796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///   void test() { this->bar(); }
236796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// };
237796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode
238796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr {
239796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  SourceLocation Loc;
240796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
241796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic:
242796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  CXXThisExpr(SourceLocation L, QualType Type)
243796da18402f286b897782a298ae3b20c459c102eDouglas Gregor    : Expr(CXXThisExprClass, Type), Loc(L) { }
244796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
245796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
246796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
247796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  static bool classof(const Stmt *T) {
248796da18402f286b897782a298ae3b20c459c102eDouglas Gregor    return T->getStmtClass() == CXXThisExprClass;
249796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  }
250796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  static bool classof(const CXXThisExpr *) { return true; }
251796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
252796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  // Iterators
253796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual child_iterator child_begin();
254796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual child_iterator child_end();
255796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
256796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual void EmitImpl(llvm::Serializer& S) const;
257796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  static CXXThisExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
258796da18402f286b897782a298ae3b20c459c102eDouglas Gregor};
259796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
2601060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  CXXThrowExpr - [C++ 15] C++ Throw Expression.  This handles
2611060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  'throw' and 'throw' assignment-expression.  When
2621060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  assignment-expression isn't present, Op will be null.
2631060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///
2641060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr {
2651060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Stmt *Op;
2661060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation ThrowLoc;
2671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
2681060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Ty is the void type which is used as the result type of the
2691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // exepression.  The l is the location of the throw keyword.  expr
2701060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // can by null, if the optional expression to throw isn't present.
2711060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) :
2721060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    Expr(CXXThrowExprClass, Ty), Op(expr), ThrowLoc(l) {}
2731060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); }
2741060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Expr *getSubExpr() { return cast_or_null<Expr>(Op); }
2751060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
2761060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
2771060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    if (getSubExpr() == 0)
2781060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek      return SourceRange(ThrowLoc, ThrowLoc);
2791060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd());
2801060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
2811060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
2821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
2831060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXThrowExprClass;
2841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
2851060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXThrowExpr *) { return true; }
2861060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
2871060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
2881060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
2891060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
2901060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
2911060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
2921060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a
2931060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding
2941060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly
2951060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters.
2961060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr {
2971060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  ParmVarDecl *Param;
2981060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
2991060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Param is the parameter whose default argument is used by this
3001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // expression.
3011060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  explicit CXXDefaultArgExpr(ParmVarDecl *param)
3021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    : Expr(CXXDefaultArgExprClass, param->getDefaultArg()->getType()),
3031060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek      Param(param) { }
3041060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the parameter that the argument was created from.
3061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  const ParmVarDecl *getParam() const { return Param; }
3071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  ParmVarDecl *getParam() { return Param; }
3081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3091060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the actual argument to the function call.
3101060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  const Expr *getExpr() const { return Param->getDefaultArg(); }
3111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Expr *getExpr() { return Param->getDefaultArg(); }
3121060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
3141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // Default argument expressions have no representation in the
3151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // source, so they have an empty source range.
3161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange();
3171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
3181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
3201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXDefaultArgExprClass;
3211060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
3221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXDefaultArgExpr *) { 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  // Serialization
3291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
3301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static CXXDefaultArgExpr* CreateImpl(llvm::Deserializer& D,
3311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek                                       ASTContext& C);
3321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
333987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
33449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion
33549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c
33649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5);
33749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr {
338987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation TyBeginLoc;
339987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
340987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic:
34149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  CXXFunctionalCastExpr(QualType ty, QualType writtenTy,
34249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor                        SourceLocation tyBeginLoc, Expr *castExpr,
343987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis                        SourceLocation rParenLoc) :
34449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    ExplicitCastExpr(CXXFunctionalCastExprClass, ty, castExpr, writtenTy),
345987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
346987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
347987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
348987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getRParenLoc() const { return RParenLoc; }
349987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
350987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
351987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return SourceRange(TyBeginLoc, RParenLoc);
352987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
353987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const Stmt *T) {
354987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return T->getStmtClass() == CXXFunctionalCastExprClass;
355987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
356987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const CXXFunctionalCastExpr *) { return true; }
357987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
358987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual void EmitImpl(llvm::Serializer& S) const;
359987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static CXXFunctionalCastExpr *
360987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis      CreateImpl(llvm::Deserializer& D, ASTContext& C);
361987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
362987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
363987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// CXXZeroInitValueExpr - [C++ 5.2.3p2]
364987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// Expression "T()" which creates a value-initialized Rvalue of non-class
365987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// type T.
366987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis///
367987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidisclass CXXZeroInitValueExpr : public Expr {
368987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation TyBeginLoc;
369987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
370987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
371987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic:
372987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  CXXZeroInitValueExpr(QualType ty, SourceLocation tyBeginLoc,
373987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis                       SourceLocation rParenLoc ) :
374987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    Expr(CXXZeroInitValueExprClass, ty),
375987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
376987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
377987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
378987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getRParenLoc() const { return RParenLoc; }
379987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
380987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
381987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return SourceRange(TyBeginLoc, RParenLoc);
382987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
383987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
384987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const Stmt *T) {
385987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return T->getStmtClass() == CXXZeroInitValueExprClass;
386987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
387987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const CXXZeroInitValueExpr *) { return true; }
388987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
389987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  // Iterators
390987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual child_iterator child_begin();
391987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual child_iterator child_end();
392987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
393987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual void EmitImpl(llvm::Serializer& S) const;
394987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static CXXZeroInitValueExpr *
395987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis      CreateImpl(llvm::Deserializer& D, ASTContext& C);
396987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
397987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
3989e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// CXXConditionDeclExpr - Condition declaration of a if/switch/while/for
3999e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// statement, e.g: "if (int x = f()) {...}".
4009e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// The main difference with DeclRefExpr is that CXXConditionDeclExpr owns the
4019e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// decl that it references.
4029e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis///
4039e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidisclass CXXConditionDeclExpr : public DeclRefExpr {
4049e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidispublic:
4059e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  CXXConditionDeclExpr(SourceLocation startLoc,
4069e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis                       SourceLocation eqLoc, VarDecl *var)
4079d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor    : DeclRefExpr(CXXConditionDeclExprClass, var,
4089d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor                  var->getType().getNonReferenceType(), startLoc) {}
4099e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
4109e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  virtual void Destroy(ASTContext& Ctx);
4119e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
4129e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  SourceLocation getStartLoc() const { return getLocation(); }
4139e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
4149e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  VarDecl *getVarDecl() { return cast<VarDecl>(getDecl()); }
4159e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  const VarDecl *getVarDecl() const { return cast<VarDecl>(getDecl()); }
4169e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
4179e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
4189e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis    return SourceRange(getStartLoc(), getVarDecl()->getInit()->getLocEnd());
4199e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  }
4209e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
4219e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  static bool classof(const Stmt *T) {
4229e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis    return T->getStmtClass() == CXXConditionDeclExprClass;
4239e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  }
4249e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  static bool classof(const CXXConditionDeclExpr *) { return true; }
4259e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
4269e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  // Iterators
4279e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  virtual child_iterator child_begin();
4289e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  virtual child_iterator child_end();
4299e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
4309e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  // FIXME: Implement these.
4319e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  //virtual void EmitImpl(llvm::Serializer& S) const;
4329e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  //static CXXConditionDeclExpr *
4339e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  //    CreateImpl(llvm::Deserializer& D, ASTContext& C);
4349e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis};
4359e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
4365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}  // end namespace clang
4375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
4385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif
439