Expr.h revision ba49817c5b9f502602672861cf369fd0e53966e8
15f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===--- Expr.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.
115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#ifndef LLVM_CLANG_AST_EXPR_H
155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#define LLVM_CLANG_AST_EXPR_H
165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
1794deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson#include "clang/AST/APValue.h"
185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "clang/AST/Stmt.h"
195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "clang/AST/Type.h"
205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "llvm/ADT/APSInt.h"
21525a05093a4816af961fe2bc6b8a81c17e2e26c2Chris Lattner#include "llvm/ADT/APFloat.h"
223b8d116703db8018f855cbb4733ace426422623bNate Begeman#include "llvm/ADT/SmallVector.h"
23c5ae899b4bbf65488445316c63168079177db0edSteve Naroff#include <vector>
245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang {
26590b6646ef747d2f7b42e5f40487ff07642d7b6fChris Lattner  class ASTContext;
27c44eec6dd29ee9415cbd38a35deff4c8b67abb6aAnders Carlsson  class APValue;
28c4a1dea2dc56bd1357ec91b829a0b9e68229a13eDaniel Dunbar  class Decl;
29c4a1dea2dc56bd1357ec91b829a0b9e68229a13eDaniel Dunbar  class IdentifierInfo;
30c4a1dea2dc56bd1357ec91b829a0b9e68229a13eDaniel Dunbar  class ParmVarDecl;
318e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor  class NamedDecl;
32c4a1dea2dc56bd1357ec91b829a0b9e68229a13eDaniel Dunbar  class ValueDecl;
3356ee6896f2efebffb4a2cce5a7610cdf1eddbbbeSteve Naroff  class BlockDecl;
3488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  class CXXOperatorCallExpr;
3588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  class CXXMemberCallExpr;
3688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// Expr - This represents one expression.  Note that Expr's are subclasses of
385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// Stmt.  This allows an expression to be transparently used any place a Stmt
395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// is required.
405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer///
415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass Expr : public Stmt {
425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  QualType TR;
43898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor
44898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// TypeDependent - Whether this expression is type-dependent
45898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// (C++ [temp.dep.expr]).
46898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  bool TypeDependent : 1;
47898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor
48898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// ValueDependent - Whether this expression is value-dependent
49898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// (C++ [temp.dep.constexpr]).
50898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  bool ValueDependent : 1;
51898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor
525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerprotected:
53898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  // FIXME: Eventually, this constructor should go away and we should
54898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  // require every subclass to provide type/value-dependence
55898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  // information.
56898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  Expr(StmtClass SC, QualType T)
57b3eef68111ffc220e449be96da1747998c057790Douglas Gregor    : Stmt(SC), TypeDependent(false), ValueDependent(false) {
5883233a4b7c2bc7b531ffa3b33fdd1cd8138373b6Douglas Gregor    setType(T);
5983233a4b7c2bc7b531ffa3b33fdd1cd8138373b6Douglas Gregor  }
60898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor
61898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  Expr(StmtClass SC, QualType T, bool TD, bool VD)
62b3eef68111ffc220e449be96da1747998c057790Douglas Gregor    : Stmt(SC), TypeDependent(TD), ValueDependent(VD) {
63898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor    setType(T);
64898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  }
65898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor
66f7c2aa0b049272d8f318988c1965760dcb852578Douglas Gregorpublic:
67f7c2aa0b049272d8f318988c1965760dcb852578Douglas Gregor  QualType getType() const { return TR; }
68f7c2aa0b049272d8f318988c1965760dcb852578Douglas Gregor  void setType(QualType t) {
699d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor    // In C++, the type of an expression is always adjusted so that it
709d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor    // will not have reference type an expression will never have
719d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor    // reference type (C++ [expr]p6). Use
729d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor    // QualType::getNonReferenceType() to retrieve the non-reference
739d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor    // type. Additionally, inspect Expr::isLvalue to determine whether
749d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor    // an expression that is adjusted in this manner should be
759d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor    // considered an lvalue.
76f7c2aa0b049272d8f318988c1965760dcb852578Douglas Gregor    assert((TR.isNull() || !TR->isReferenceType()) &&
778320aaaa01d931aa234fc3bce05b399ef41898d5Daniel Dunbar           "Expressions can't have reference type");
78f7c2aa0b049272d8f318988c1965760dcb852578Douglas Gregor
79f7c2aa0b049272d8f318988c1965760dcb852578Douglas Gregor    TR = t;
809d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor  }
8177ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek
82898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// isValueDependent - Determines whether this expression is
83898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// value-dependent (C++ [temp.dep.constexpr]). For example, the
84898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// array bound of "Chars" in the following example is
85898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// value-dependent.
86898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// @code
87898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// template<int Size, char (&Chars)[Size]> struct meta_string;
88898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// @endcode
89898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  bool isValueDependent() const { return ValueDependent; }
90898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor
91898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// isTypeDependent - Determines whether this expression is
92898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// type-dependent (C++ [temp.dep.expr]), which means that its type
93898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// could change from one template instantiation to the next. For
94898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// example, the expressions "x" and "x + y" are type-dependent in
95898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// the following code, but "y" is not type-dependent:
96898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// @code
97898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// template<typename T>
98898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// void add(T x, int y) {
99898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  ///   x + y;
100898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// }
101898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  /// @endcode
102898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  bool isTypeDependent() const { return TypeDependent; }
103898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor
1045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// SourceLocation tokens are not useful in isolation - they are low level
1055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// value objects created/interpreted by SourceManager. We assume AST
1065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// clients will have a pointer to the respective SourceManager.
1075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  virtual SourceRange getSourceRange() const = 0;
1085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
1095f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// getExprLoc - Return the preferred location for the arrow when diagnosing
1105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// a problem with a generic expression.
1115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  virtual SourceLocation getExprLoc() const { return getLocStart(); }
1125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
113026dc96ac6ece60da5e1b98e2a71bd0ff0939fd8Chris Lattner  /// isUnusedResultAWarning - Return true if this immediate expression should
114026dc96ac6ece60da5e1b98e2a71bd0ff0939fd8Chris Lattner  /// be warned about if the result is unused.  If so, fill in Loc and Ranges
115026dc96ac6ece60da5e1b98e2a71bd0ff0939fd8Chris Lattner  /// with location to warn on and the source range[s] to report with the
116026dc96ac6ece60da5e1b98e2a71bd0ff0939fd8Chris Lattner  /// warning.
117026dc96ac6ece60da5e1b98e2a71bd0ff0939fd8Chris Lattner  bool isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
118026dc96ac6ece60da5e1b98e2a71bd0ff0939fd8Chris Lattner                              SourceRange &R2) const;
1195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
1205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// isLvalue - C99 6.3.2.1: an lvalue is an expression with an object type or
1215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// incomplete type other than void. Nonarray expressions that can be lvalues:
1225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  ///  - name, where name must be a variable
1235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  ///  - e[i]
1245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  ///  - (e), where e must be an lvalue
1255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  ///  - e.name, where e must be an lvalue
1265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  ///  - e->name
1275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  ///  - *e, the type of e cannot be a function type
1285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  ///  - string-constant
12908ad47cbd1f81fcb31dbc731c13b885a07e12704Bill Wendling  ///  - reference type [C++ [expr]]
1305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  ///
1315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  enum isLvalueResult {
1325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    LV_Valid,
1335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    LV_NotObjectType,
1345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    LV_IncompleteVoidType,
135fec0b49c3fa621fbf63e420f3d54a5bb3a0265d2Steve Naroff    LV_DuplicateVectorComponents,
13686f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor    LV_InvalidExpression,
13786f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor    LV_MemberFunction
1385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  };
13928be73f74c9e241a23ea24fe5756623de6bf1084Chris Lattner  isLvalueResult isLvalue(ASTContext &Ctx) const;
1405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
1415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// isModifiableLvalue - C99 6.3.2.1: an lvalue that does not have array type,
1425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// does not have an incomplete type, does not have a const-qualified type,
1435f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// and if it is a structure or union, does not have any member (including,
1445f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// recursively, any member or element of all contained aggregates or unions)
1455f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// with a const-qualified type.
1465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  enum isModifiableLvalueResult {
1475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    MLV_Valid,
1485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    MLV_NotObjectType,
1495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    MLV_IncompleteVoidType,
150fec0b49c3fa621fbf63e420f3d54a5bb3a0265d2Steve Naroff    MLV_DuplicateVectorComponents,
1515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    MLV_InvalidExpression,
152ca354faa7e9b99af17070c82b9662a5fca76422cChris Lattner    MLV_LValueCast,           // Specialized form of MLV_InvalidExpression.
1535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    MLV_IncompleteType,
1545f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    MLV_ConstQualified,
1554f6a7d7ead09b439216c32f2de806a998aeb222aSteve Naroff    MLV_ArrayType,
1565daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian    MLV_NotBlockQualified,
157ba8d2d684e74a20bef03828c21c991d222c7e9e5Fariborz Jahanian    MLV_ReadonlyProperty,
15886f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor    MLV_NoSetterProperty,
15986f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor    MLV_MemberFunction
1605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  };
16128be73f74c9e241a23ea24fe5756623de6bf1084Chris Lattner  isModifiableLvalueResult isModifiableLvalue(ASTContext &Ctx) const;
1625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
16327c8dc06f65d7abcf6a7e7f64a7960c9a150ca01Douglas Gregor  bool isBitField();
1645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
165cd8f646eca128f52a7bce0103c51ff82ce96f374Daniel Dunbar  /// getIntegerConstantExprValue() - Return the value of an integer
166cd8f646eca128f52a7bce0103c51ff82ce96f374Daniel Dunbar  /// constant expression. The expression must be a valid integer
167cd8f646eca128f52a7bce0103c51ff82ce96f374Daniel Dunbar  /// constant expression as determined by isIntegerConstantExpr.
168cd8f646eca128f52a7bce0103c51ff82ce96f374Daniel Dunbar  llvm::APSInt getIntegerConstantExprValue(ASTContext &Ctx) const {
1698070a8497c0fb3e6f70a557f788405d8945b1208Daniel Dunbar    llvm::APSInt X;
170cd8f646eca128f52a7bce0103c51ff82ce96f374Daniel Dunbar    bool success = isIntegerConstantExpr(X, Ctx);
171a5d1cb7ef3f0780540e7fd7180399fd220ef0210Daniel Dunbar    success = success;
172cd8f646eca128f52a7bce0103c51ff82ce96f374Daniel Dunbar    assert(success && "Illegal argument to getIntegerConstantExpr");
173cd8f646eca128f52a7bce0103c51ff82ce96f374Daniel Dunbar    return X;
174cd8f646eca128f52a7bce0103c51ff82ce96f374Daniel Dunbar  }
175cd8f646eca128f52a7bce0103c51ff82ce96f374Daniel Dunbar
1765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// isIntegerConstantExpr - Return true if this expression is a valid integer
1775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// constant expression, and, if so, return its value in Result.  If not a
1785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// valid i-c-e, return false and fill in Loc (if specified) with the location
1795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// of the invalid expression.
180590b6646ef747d2f7b42e5f40487ff07642d7b6fChris Lattner  bool isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx,
181590b6646ef747d2f7b42e5f40487ff07642d7b6fChris Lattner                             SourceLocation *Loc = 0,
1825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer                             bool isEvaluated = true) const;
1832d6744ff04c1690a1485178d550d2fab84a0270bDaniel Dunbar  bool isIntegerConstantExprInternal(llvm::APSInt &Result, ASTContext &Ctx,
1842d6744ff04c1690a1485178d550d2fab84a0270bDaniel Dunbar                             SourceLocation *Loc = 0,
1852d6744ff04c1690a1485178d550d2fab84a0270bDaniel Dunbar                             bool isEvaluated = true) const;
186590b6646ef747d2f7b42e5f40487ff07642d7b6fChris Lattner  bool isIntegerConstantExpr(ASTContext &Ctx, SourceLocation *Loc = 0) const {
1878070a8497c0fb3e6f70a557f788405d8945b1208Daniel Dunbar    llvm::APSInt X;
188590b6646ef747d2f7b42e5f40487ff07642d7b6fChris Lattner    return isIntegerConstantExpr(X, Ctx, Loc);
1895f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
190c9e8f606787b0bc0c3b08e566b87cc1751694168Eli Friedman  /// isConstantInitializer - Returns true if this expression is a constant
191c9e8f606787b0bc0c3b08e566b87cc1751694168Eli Friedman  /// initializer, which can be emitted at compile-time.
192c9e8f606787b0bc0c3b08e566b87cc1751694168Eli Friedman  bool isConstantInitializer(ASTContext &Ctx) const;
1935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
19494deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson  /// EvalResult is a struct with detailed info about an evaluated expression.
19594deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson  struct EvalResult {
1962d6744ff04c1690a1485178d550d2fab84a0270bDaniel Dunbar    /// Val - This is the value the expression can be folded to.
19794deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson    APValue Val;
19894deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson
19994deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson    /// HasSideEffects - Whether the evaluated expression has side effects.
20094deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson    /// For example, (f() && 0) can be folded, but it still has side effects.
20194deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson    bool HasSideEffects;
20294deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson
20394deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson    /// Diag - If the expression is unfoldable, then Diag contains a note
20494deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson    /// diagnostic indicating why it's not foldable. DiagLoc indicates a caret
20594deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson    /// position for the error, and DiagExpr is the expression that caused
20694deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson    /// the error.
20794deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson    /// If the expression is foldable, but not an integer constant expression,
20894deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson    /// Diag contains a note diagnostic that describes why it isn't an integer
20994deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson    /// constant expression. If the expression *is* an integer constant
21094deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson    /// expression, then Diag will be zero.
21194deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson    unsigned Diag;
21294deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson    const Expr *DiagExpr;
21394deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson    SourceLocation DiagLoc;
21494deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson
21594deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson    EvalResult() : HasSideEffects(false), Diag(0), DiagExpr(0) {}
21694deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson  };
21794deaf675ae60e11c2d9475c6dbfd0c7123160f5Anders Carlsson
2186ee7aa154e8bbb21a21254293410b944f78b0bfeChris Lattner  /// Evaluate - Return true if this is a constant which we can fold using
219019f4e858e78587f2241ff1a76c747d7bcd7578cChris Lattner  /// any crazy technique (that has nothing to do with language standards) that
220019f4e858e78587f2241ff1a76c747d7bcd7578cChris Lattner  /// we want to.  If this function returns true, it returns the folded constant
221019f4e858e78587f2241ff1a76c747d7bcd7578cChris Lattner  /// in Result.
2225b45d4ef1ea3f04ec863daf8aa29be6c6e021750Anders Carlsson  bool Evaluate(EvalResult &Result, ASTContext &Ctx) const;
2235b45d4ef1ea3f04ec863daf8aa29be6c6e021750Anders Carlsson
2246ee7aa154e8bbb21a21254293410b944f78b0bfeChris Lattner  /// isEvaluatable - Call Evaluate to see if this expression can be constant
22545b6b9d080ac56917337d73d8f1cd6374b27b05dChris Lattner  /// folded, but discard the result.
22645b6b9d080ac56917337d73d8f1cd6374b27b05dChris Lattner  bool isEvaluatable(ASTContext &Ctx) const;
227c44eec6dd29ee9415cbd38a35deff4c8b67abb6aAnders Carlsson
22851fe996231b1d7199f76e4005ff4c943d5deeecdAnders Carlsson  /// EvaluateAsInt - Call Evaluate and return the folded integer. This
22951fe996231b1d7199f76e4005ff4c943d5deeecdAnders Carlsson  /// must be called on an expression that constant folds to an integer.
23051fe996231b1d7199f76e4005ff4c943d5deeecdAnders Carlsson  llvm::APSInt EvaluateAsInt(ASTContext &Ctx) const;
23151fe996231b1d7199f76e4005ff4c943d5deeecdAnders Carlsson
232efa9b3877ef298bcb792600ac33521827e1f7fafAnders Carlsson  /// isNullPointerConstant - C99 6.3.2.3p3 -  Return true if this is either an
233efa9b3877ef298bcb792600ac33521827e1f7fafAnders Carlsson  /// integer constant expression with the value zero, or if this is one that is
234efa9b3877ef298bcb792600ac33521827e1f7fafAnders Carlsson  /// cast to void*.
235efa9b3877ef298bcb792600ac33521827e1f7fafAnders Carlsson  bool isNullPointerConstant(ASTContext &Ctx) const;
236efa9b3877ef298bcb792600ac33521827e1f7fafAnders Carlsson
2372e5f54aa1dd15a62c34a9d1d24a5a0692f43934aTed Kremenek  /// hasGlobalStorage - Return true if this expression has static storage
2384cc627111453b75519d5130b57e06256da7b00e8Chris Lattner  /// duration.  This means that the address of this expression is a link-time
2394cc627111453b75519d5130b57e06256da7b00e8Chris Lattner  /// constant.
2402e5f54aa1dd15a62c34a9d1d24a5a0692f43934aTed Kremenek  bool hasGlobalStorage() const;
24144baa8abba2a1552b6b50bf750a8750ab9da9f76Fariborz Jahanian
24244baa8abba2a1552b6b50bf750a8750ab9da9f76Fariborz Jahanian  /// isOBJCGCCandidate - Return true if this expression may be used in a read/
24344baa8abba2a1552b6b50bf750a8750ab9da9f76Fariborz Jahanian  /// write barrier.
24444baa8abba2a1552b6b50bf750a8750ab9da9f76Fariborz Jahanian  bool isOBJCGCCandidate() const;
2454e99a5fc3b203397a91136c6e695e405fb8fc606Ted Kremenek
2464e99a5fc3b203397a91136c6e695e405fb8fc606Ted Kremenek  /// IgnoreParens - Ignore parentheses.  If this Expr is a ParenExpr, return
2474e99a5fc3b203397a91136c6e695e405fb8fc606Ted Kremenek  ///  its subexpression.  If that subexpression is also a ParenExpr,
2484e99a5fc3b203397a91136c6e695e405fb8fc606Ted Kremenek  ///  then this method recursively returns its subexpression, and so forth.
2494e99a5fc3b203397a91136c6e695e405fb8fc606Ted Kremenek  ///  Otherwise, the method returns the current Expr.
2504e99a5fc3b203397a91136c6e695e405fb8fc606Ted Kremenek  Expr* IgnoreParens();
25156f349400c5932a196509c0480ff6f99a9a0b48fChris Lattner
25256f349400c5932a196509c0480ff6f99a9a0b48fChris Lattner  /// IgnoreParenCasts - Ignore parentheses and casts.  Strip off any ParenExpr
25327c8dc06f65d7abcf6a7e7f64a7960c9a150ca01Douglas Gregor  /// or CastExprs, returning their operand.
25456f349400c5932a196509c0480ff6f99a9a0b48fChris Lattner  Expr *IgnoreParenCasts();
2554e99a5fc3b203397a91136c6e695e405fb8fc606Ted Kremenek
256ecdd84147c0765caa999ddc22dde25b42712bb4dChris Lattner  /// IgnoreParenNoopCasts - Ignore parentheses and casts that do not change the
257ecdd84147c0765caa999ddc22dde25b42712bb4dChris Lattner  /// value (including ptr->int casts of the same size).  Strip off any
258ecdd84147c0765caa999ddc22dde25b42712bb4dChris Lattner  /// ParenExpr or CastExprs, returning their operand.
259ecdd84147c0765caa999ddc22dde25b42712bb4dChris Lattner  Expr *IgnoreParenNoopCasts(ASTContext &Ctx);
260ecdd84147c0765caa999ddc22dde25b42712bb4dChris Lattner
2614e99a5fc3b203397a91136c6e695e405fb8fc606Ted Kremenek  const Expr* IgnoreParens() const {
2624e99a5fc3b203397a91136c6e695e405fb8fc606Ted Kremenek    return const_cast<Expr*>(this)->IgnoreParens();
2634e99a5fc3b203397a91136c6e695e405fb8fc606Ted Kremenek  }
26456f349400c5932a196509c0480ff6f99a9a0b48fChris Lattner  const Expr *IgnoreParenCasts() const {
26556f349400c5932a196509c0480ff6f99a9a0b48fChris Lattner    return const_cast<Expr*>(this)->IgnoreParenCasts();
26656f349400c5932a196509c0480ff6f99a9a0b48fChris Lattner  }
267ecdd84147c0765caa999ddc22dde25b42712bb4dChris Lattner  const Expr *IgnoreParenNoopCasts(ASTContext &Ctx) const {
268ecdd84147c0765caa999ddc22dde25b42712bb4dChris Lattner    return const_cast<Expr*>(this)->IgnoreParenNoopCasts(Ctx);
269ecdd84147c0765caa999ddc22dde25b42712bb4dChris Lattner  }
270ecdd84147c0765caa999ddc22dde25b42712bb4dChris Lattner
271898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  static bool hasAnyTypeDependentArguments(Expr** Exprs, unsigned NumExprs);
272898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  static bool hasAnyValueDependentArguments(Expr** Exprs, unsigned NumExprs);
273898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor
2745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const Stmt *T) {
2755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return T->getStmtClass() >= firstExprConstant &&
2765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer           T->getStmtClass() <= lastExprConstant;
2775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
2785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const Expr *) { return true; }
2792e7d352dbec06755105237afba183492d31d03cbTed Kremenek
280e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static inline Expr* Create(llvm::Deserializer& D, ASTContext& C) {
281e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop    return cast<Expr>(Stmt::Create(D, C));
2822e7d352dbec06755105237afba183492d31d03cbTed Kremenek  }
2835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
2845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
2855549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek
2865549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek//===----------------------------------------------------------------------===//
2875f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// Primary Expressions.
2885f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
2895f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
2905f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// DeclRefExpr - [C99 6.5.1p2] - A reference to a declared variable, function,
2915f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// enum, etc.
2925f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass DeclRefExpr : public Expr {
2938e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor  NamedDecl *D;
2945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation Loc;
2959e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
2969e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidisprotected:
2971a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  // FIXME: Eventually, this constructor will go away and all subclasses
2981a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  // will have to provide the type- and value-dependent flags.
2998e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor  DeclRefExpr(StmtClass SC, NamedDecl *d, QualType t, SourceLocation l) :
3009e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis    Expr(SC, t), D(d), Loc(l) {}
3019e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
3021a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  DeclRefExpr(StmtClass SC, NamedDecl *d, QualType t, SourceLocation l, bool TD,
3031a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor              bool VD) :
3041a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor    Expr(SC, t, TD, VD), D(d), Loc(l) {}
3051a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor
3065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic:
307898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  // FIXME: Eventually, this constructor will go away and all clients
308898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  // will have to provide the type- and value-dependent flags.
3098e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor  DeclRefExpr(NamedDecl *d, QualType t, SourceLocation l) :
3105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    Expr(DeclRefExprClass, t), D(d), Loc(l) {}
311898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor
312898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor  DeclRefExpr(NamedDecl *d, QualType t, SourceLocation l, bool TD, bool VD) :
313898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor    Expr(DeclRefExprClass, t, TD, VD), D(d), Loc(l) {}
3145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
3158e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor  NamedDecl *getDecl() { return D; }
3168e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor  const NamedDecl *getDecl() const { return D; }
317904eed3f6148758d39a2d3c88f3133274460d645Douglas Gregor  void setDecl(NamedDecl *NewD) { D = NewD; }
318904eed3f6148758d39a2d3c88f3133274460d645Douglas Gregor
3199e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  SourceLocation getLocation() const { return Loc; }
3205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
3215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
3225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const Stmt *T) {
3239e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis    return T->getStmtClass() == DeclRefExprClass ||
3241a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor           T->getStmtClass() == CXXConditionDeclExprClass ||
3251a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor           T->getStmtClass() == QualifiedDeclRefExprClass;
3265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
3275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const DeclRefExpr *) { return true; }
32877ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek
32977ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  // Iterators
33077ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_begin();
33177ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_end();
3322dc9ac73a8a34cabf261a81a1653d7379065ac61Ted Kremenek
333ec0aa78745f7b3bc96c20fffd1115bf26aaa0eadTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
334e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static DeclRefExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
3355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
3365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
337d9f6910f4ef37c0e8eeee2a01287d9572c3176efChris Lattner/// PredefinedExpr - [C99 6.4.2.2] - A predefined identifier such as __func__.
338d9f6910f4ef37c0e8eeee2a01287d9572c3176efChris Lattnerclass PredefinedExpr : public Expr {
339227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlssonpublic:
340227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlsson  enum IdentType {
341227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlsson    Func,
342227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlsson    Function,
343cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor    PrettyFunction
344227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlsson  };
345227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlsson
346227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlssonprivate:
347227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlsson  SourceLocation Loc;
348227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlsson  IdentType Type;
349227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlssonpublic:
350d9f6910f4ef37c0e8eeee2a01287d9572c3176efChris Lattner  PredefinedExpr(SourceLocation l, QualType type, IdentType IT)
351d9f6910f4ef37c0e8eeee2a01287d9572c3176efChris Lattner    : Expr(PredefinedExprClass, type), Loc(l), Type(IT) {}
352227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlsson
353227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlsson  IdentType getIdentType() const { return Type; }
354227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlsson
355227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlsson  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
356227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlsson
357227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlsson  static bool classof(const Stmt *T) {
358d9f6910f4ef37c0e8eeee2a01287d9572c3176efChris Lattner    return T->getStmtClass() == PredefinedExprClass;
359227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlsson  }
360d9f6910f4ef37c0e8eeee2a01287d9572c3176efChris Lattner  static bool classof(const PredefinedExpr *) { return true; }
36177ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek
36277ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  // Iterators
36377ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_begin();
36477ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_end();
3651ba485e582edfc8636afc25a6d7453c869530688Ted Kremenek
366ec0aa78745f7b3bc96c20fffd1115bf26aaa0eadTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
367d9f6910f4ef37c0e8eeee2a01287d9572c3176efChris Lattner  static PredefinedExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
368227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlsson};
369227426661be33ff3e21f2b6b9f97971da2da044fAnders Carlsson
3705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass IntegerLiteral : public Expr {
3715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  llvm::APInt Value;
3725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation Loc;
3735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic:
3745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  // type should be IntTy, LongTy, LongLongTy, UnsignedIntTy, UnsignedLongTy,
3755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  // or UnsignedLongLongTy
3765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  IntegerLiteral(const llvm::APInt &V, QualType type, SourceLocation l)
3775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    : Expr(IntegerLiteralClass, type), Value(V), Loc(l) {
3785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    assert(type->isIntegerType() && "Illegal type in IntegerLiteral");
3795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
3805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  const llvm::APInt &getValue() const { return Value; }
3815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
3825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
383313a81dd820c9b2c0203bdcd974c781a81e4f0cfDouglas Gregor  /// \brief Retrieve the location of the literal.
384313a81dd820c9b2c0203bdcd974c781a81e4f0cfDouglas Gregor  SourceLocation getLocation() const { return Loc; }
385313a81dd820c9b2c0203bdcd974c781a81e4f0cfDouglas Gregor
3865f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const Stmt *T) {
3875f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return T->getStmtClass() == IntegerLiteralClass;
3885f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
3895f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const IntegerLiteral *) { return true; }
39077ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek
39177ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  // Iterators
39277ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_begin();
39377ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_end();
3942dc9ac73a8a34cabf261a81a1653d7379065ac61Ted Kremenek
395ec0aa78745f7b3bc96c20fffd1115bf26aaa0eadTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
396e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static IntegerLiteral* CreateImpl(llvm::Deserializer& D, ASTContext& C);
3975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
3985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
3995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass CharacterLiteral : public Expr {
4005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  unsigned Value;
4015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation Loc;
402c250aae4f645833aed3a6321bc8598f7330dce8dChris Lattner  bool IsWide;
4035f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic:
4045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  // type should be IntTy
405c250aae4f645833aed3a6321bc8598f7330dce8dChris Lattner  CharacterLiteral(unsigned value, bool iswide, QualType type, SourceLocation l)
406c250aae4f645833aed3a6321bc8598f7330dce8dChris Lattner    : Expr(CharacterLiteralClass, type), Value(value), Loc(l), IsWide(iswide) {
4075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
4082eadfb638eb1bb6ccfd6fd0453e764d47e27eed9Chris Lattner  SourceLocation getLoc() const { return Loc; }
409c250aae4f645833aed3a6321bc8598f7330dce8dChris Lattner  bool isWide() const { return IsWide; }
4102eadfb638eb1bb6ccfd6fd0453e764d47e27eed9Chris Lattner
4115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
4125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
4135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  unsigned getValue() const { return Value; }
4145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
4155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const Stmt *T) {
4165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return T->getStmtClass() == CharacterLiteralClass;
4175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
4185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const CharacterLiteral *) { return true; }
41977ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek
42077ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  // Iterators
42177ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_begin();
42277ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_end();
4237338a8299ec393eaf6bb580b5ef9ab2b08b5bd11Ted Kremenek
424ec0aa78745f7b3bc96c20fffd1115bf26aaa0eadTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
425e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static CharacterLiteral* CreateImpl(llvm::Deserializer& D, ASTContext& C);
4265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
4275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
4285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass FloatingLiteral : public Expr {
429525a05093a4816af961fe2bc6b8a81c17e2e26c2Chris Lattner  llvm::APFloat Value;
430720c4ec57b6110873cd533ad434853a27e7c3f4aTed Kremenek  bool IsExact : 1;
4315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation Loc;
4325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic:
433720c4ec57b6110873cd533ad434853a27e7c3f4aTed Kremenek  FloatingLiteral(const llvm::APFloat &V, bool* isexact,
434720c4ec57b6110873cd533ad434853a27e7c3f4aTed Kremenek                  QualType Type, SourceLocation L)
435720c4ec57b6110873cd533ad434853a27e7c3f4aTed Kremenek    : Expr(FloatingLiteralClass, Type), Value(V), IsExact(*isexact), Loc(L) {}
4365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
437c9bec4bfea9090a08dd83a7b213f0c8adf8d78ecChris Lattner  const llvm::APFloat &getValue() const { return Value; }
438720c4ec57b6110873cd533ad434853a27e7c3f4aTed Kremenek
439720c4ec57b6110873cd533ad434853a27e7c3f4aTed Kremenek  bool isExact() const { return IsExact; }
440c9bec4bfea9090a08dd83a7b213f0c8adf8d78ecChris Lattner
441da8249e57f3badecf925571881fe57243935c6c1Chris Lattner  /// getValueAsApproximateDouble - This returns the value as an inaccurate
442da8249e57f3badecf925571881fe57243935c6c1Chris Lattner  /// double.  Note that this may cause loss of precision, but is useful for
443da8249e57f3badecf925571881fe57243935c6c1Chris Lattner  /// debugging dumps, etc.
444da8249e57f3badecf925571881fe57243935c6c1Chris Lattner  double getValueAsApproximateDouble() const;
445da8249e57f3badecf925571881fe57243935c6c1Chris Lattner
4465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
4475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
4485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const Stmt *T) {
4495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return T->getStmtClass() == FloatingLiteralClass;
4505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
4515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const FloatingLiteral *) { return true; }
45277ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek
45377ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  // Iterators
45477ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_begin();
45577ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_end();
456612c9b9ca73593b3194866c9e1a51554db9752e7Ted Kremenek
457ec0aa78745f7b3bc96c20fffd1115bf26aaa0eadTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
458e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static FloatingLiteral* CreateImpl(llvm::Deserializer& D, ASTContext& C);
4595f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
4605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
4615d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner/// ImaginaryLiteral - We support imaginary integer and floating point literals,
4625d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner/// like "1.0i".  We represent these as a wrapper around FloatingLiteral and
4635d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner/// IntegerLiteral classes.  Instances of this class always have a Complex type
4645d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner/// whose element type matches the subexpression.
4655d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner///
4665d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattnerclass ImaginaryLiteral : public Expr {
4675549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Stmt *Val;
4685d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattnerpublic:
4695d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner  ImaginaryLiteral(Expr *val, QualType Ty)
4705d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner    : Expr(ImaginaryLiteralClass, Ty), Val(val) {}
4715d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner
4725549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  const Expr *getSubExpr() const { return cast<Expr>(Val); }
4735549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getSubExpr() { return cast<Expr>(Val); }
4745d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner
4755d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner  virtual SourceRange getSourceRange() const { return Val->getSourceRange(); }
4765d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner  static bool classof(const Stmt *T) {
4775d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner    return T->getStmtClass() == ImaginaryLiteralClass;
4785d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner  }
4795d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner  static bool classof(const ImaginaryLiteral *) { return true; }
4805d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner
4815d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner  // Iterators
4825d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner  virtual child_iterator child_begin();
4835d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner  virtual child_iterator child_end();
4841c72de1be77fc43cc27e9bf1cbfe7bd25bee2f81Ted Kremenek
485ec0aa78745f7b3bc96c20fffd1115bf26aaa0eadTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
486e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static ImaginaryLiteral* CreateImpl(llvm::Deserializer& D, ASTContext& C);
4875d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner};
4885d66145eed1c319df5a69977cb8ff74f597ea544Chris Lattner
489e6a82b2c29ad05534841e5f8fd033fb17b6f61e2Ted Kremenek/// StringLiteral - This represents a string literal expression, e.g. "foo"
490e6a82b2c29ad05534841e5f8fd033fb17b6f61e2Ted Kremenek/// or L"bar" (wide strings).  The actual string is returned by getStrData()
491e6a82b2c29ad05534841e5f8fd033fb17b6f61e2Ted Kremenek/// is NOT null-terminated, and the length of the string is determined by
492a7ad98ff0919d6a24ea7c46634ea29bea551c1a0Chris Lattner/// calling getByteLength().  The C type for a string is always a
493c4a09c189981b4561428e4b56fd250718e2717bbChris Lattner/// ConstantArrayType.  In C++, the char type is const qualified, in C it is
494c4a09c189981b4561428e4b56fd250718e2717bbChris Lattner/// not.
495690398188ea5b428f06aa13c7d4ce6eb741ad4f9Chris Lattner///
496690398188ea5b428f06aa13c7d4ce6eb741ad4f9Chris Lattner/// Note that strings in C can be formed by concatenation of multiple string
4978bea7c0ee44c71c817de7dc2be932b73bec90c9fChris Lattner/// literal pptokens in translation phase #6.  This keeps track of the locations
498690398188ea5b428f06aa13c7d4ce6eb741ad4f9Chris Lattner/// of each of these pieces.
499c4a09c189981b4561428e4b56fd250718e2717bbChris Lattner///
500c4a09c189981b4561428e4b56fd250718e2717bbChris Lattner/// Strings in C can also be truncated and extended by assigning into arrays,
501c4a09c189981b4561428e4b56fd250718e2717bbChris Lattner/// e.g. with constructs like:
502c4a09c189981b4561428e4b56fd250718e2717bbChris Lattner///   char X[2] = "foobar";
503c4a09c189981b4561428e4b56fd250718e2717bbChris Lattner/// In this case, getByteLength() will return 6, but the string literal will
504c4a09c189981b4561428e4b56fd250718e2717bbChris Lattner/// have type "char[2]".
5055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass StringLiteral : public Expr {
5065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  const char *StrData;
5075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  unsigned ByteLength;
5085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool IsWide;
509726e168dc09fb23f53c7b004f8e919421ee91806Chris Lattner  unsigned NumConcatenated;
510726e168dc09fb23f53c7b004f8e919421ee91806Chris Lattner  SourceLocation TokLocs[1];
5112085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner
5122085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner  StringLiteral(QualType Ty) : Expr(StringLiteralClass, Ty) {}
5135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic:
5142085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner  /// This is the "fully general" constructor that allows representation of
5152085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner  /// strings formed from multiple concatenated tokens.
5162085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner  static StringLiteral *Create(ASTContext &C, const char *StrData,
5172085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner                               unsigned ByteLength, bool Wide, QualType Ty,
5182085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner                               SourceLocation *Loc, unsigned NumStrs);
5192085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner
5202085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner  /// Simple constructor for string literals made from one token.
5212085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner  static StringLiteral *Create(ASTContext &C, const char *StrData,
5222085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner                               unsigned ByteLength,
5232085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner                               bool Wide, QualType Ty, SourceLocation Loc) {
5242085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner    return Create(C, StrData, ByteLength, Wide, Ty, &Loc, 1);
5252085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner  }
5266e94ef5696cfb005d3fc7bbac8dcf7690b64f0a5Ted Kremenek
527726e168dc09fb23f53c7b004f8e919421ee91806Chris Lattner  void Destroy(ASTContext &C);
5285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
5295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  const char *getStrData() const { return StrData; }
5305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  unsigned getByteLength() const { return ByteLength; }
5315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool isWide() const { return IsWide; }
532726e168dc09fb23f53c7b004f8e919421ee91806Chris Lattner
533726e168dc09fb23f53c7b004f8e919421ee91806Chris Lattner  /// getNumConcatenated - Get the number of string literal tokens that were
534726e168dc09fb23f53c7b004f8e919421ee91806Chris Lattner  /// concatenated in translation phase #6 to form this string literal.
535726e168dc09fb23f53c7b004f8e919421ee91806Chris Lattner  unsigned getNumConcatenated() const { return NumConcatenated; }
536726e168dc09fb23f53c7b004f8e919421ee91806Chris Lattner
537726e168dc09fb23f53c7b004f8e919421ee91806Chris Lattner  SourceLocation getStrTokenLoc(unsigned TokNum) const {
538726e168dc09fb23f53c7b004f8e919421ee91806Chris Lattner    assert(TokNum < NumConcatenated && "Invalid tok number");
539726e168dc09fb23f53c7b004f8e919421ee91806Chris Lattner    return TokLocs[TokNum];
540726e168dc09fb23f53c7b004f8e919421ee91806Chris Lattner  }
541b137299ce5bb6c36fbba651858600857fda4dd50Chris Lattner
542b137299ce5bb6c36fbba651858600857fda4dd50Chris Lattner  typedef const SourceLocation *tokloc_iterator;
543b137299ce5bb6c36fbba651858600857fda4dd50Chris Lattner  tokloc_iterator tokloc_begin() const { return TokLocs; }
544b137299ce5bb6c36fbba651858600857fda4dd50Chris Lattner  tokloc_iterator tokloc_end() const { return TokLocs+NumConcatenated; }
5455f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
5465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  virtual SourceRange getSourceRange() const {
547726e168dc09fb23f53c7b004f8e919421ee91806Chris Lattner    return SourceRange(TokLocs[0], TokLocs[NumConcatenated-1]);
5485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
5495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const Stmt *T) {
5505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return T->getStmtClass() == StringLiteralClass;
5515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
5525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const StringLiteral *) { return true; }
55377ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek
55477ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  // Iterators
55577ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_begin();
55677ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_end();
5577febad7377c04607aa2c744d58af61e1abea6250Ted Kremenek
558ec0aa78745f7b3bc96c20fffd1115bf26aaa0eadTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
559e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static StringLiteral* CreateImpl(llvm::Deserializer& D, ASTContext& C);
5605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
5615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
5625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// ParenExpr - This represents a parethesized expression, e.g. "(1)".  This
5635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// AST node is only formed if full location information is requested.
5645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass ParenExpr : public Expr {
5655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation L, R;
5665549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Stmt *Val;
5675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic:
5685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  ParenExpr(SourceLocation l, SourceLocation r, Expr *val)
569898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor    : Expr(ParenExprClass, val->getType(),
570898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor           val->isTypeDependent(), val->isValueDependent()),
571898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor      L(l), R(r), Val(val) {}
5725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
5735549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  const Expr *getSubExpr() const { return cast<Expr>(Val); }
5745549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getSubExpr() { return cast<Expr>(Val); }
575866b5c03e3b9c01cf496ad97b85a05afc917345bTed Kremenek  virtual SourceRange getSourceRange() const { return SourceRange(L, R); }
5765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
577313a81dd820c9b2c0203bdcd974c781a81e4f0cfDouglas Gregor  /// \brief Get the location of the left parentheses '('.
578313a81dd820c9b2c0203bdcd974c781a81e4f0cfDouglas Gregor  SourceLocation getLParen() const { return L; }
579313a81dd820c9b2c0203bdcd974c781a81e4f0cfDouglas Gregor
580313a81dd820c9b2c0203bdcd974c781a81e4f0cfDouglas Gregor  /// \brief Get the location of the right parentheses ')'.
581313a81dd820c9b2c0203bdcd974c781a81e4f0cfDouglas Gregor  SourceLocation getRParen() const { return R; }
582313a81dd820c9b2c0203bdcd974c781a81e4f0cfDouglas Gregor
5835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const Stmt *T) {
5845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return T->getStmtClass() == ParenExprClass;
5855f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
5865f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const ParenExpr *) { return true; }
58777ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek
58877ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  // Iterators
58977ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_begin();
59077ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_end();
5919eea2ca5f2cb5d77569274702b5b06273e426dc2Ted Kremenek
592ec0aa78745f7b3bc96c20fffd1115bf26aaa0eadTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
593e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static ParenExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
5945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
5955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
5965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
5970518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl/// UnaryOperator - This represents the unary-expression's (except sizeof and
5980518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl/// alignof), the postinc/postdec operators from postfix-expression, and various
5995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// extensions.
600dbb36971c68ea944ac4b1fbe2d97fe7cca3b20acChris Lattner///
601dbb36971c68ea944ac4b1fbe2d97fe7cca3b20acChris Lattner/// Notes on various nodes:
602dbb36971c68ea944ac4b1fbe2d97fe7cca3b20acChris Lattner///
603dbb36971c68ea944ac4b1fbe2d97fe7cca3b20acChris Lattner/// Real/Imag - These return the real/imag part of a complex operand.  If
604dbb36971c68ea944ac4b1fbe2d97fe7cca3b20acChris Lattner///   applied to a non-complex value, the former returns its operand and the
605dbb36971c68ea944ac4b1fbe2d97fe7cca3b20acChris Lattner///   later returns zero in the type of the operand.
606dbb36971c68ea944ac4b1fbe2d97fe7cca3b20acChris Lattner///
60773d0d4fac161ed12926e010dcf8b448a8de6a2ecChris Lattner/// __builtin_offsetof(type, a.b[10]) is represented as a unary operator whose
60873d0d4fac161ed12926e010dcf8b448a8de6a2ecChris Lattner///   subexpression is a compound literal with the various MemberExpr and
60973d0d4fac161ed12926e010dcf8b448a8de6a2ecChris Lattner///   ArraySubscriptExpr's applied to it.
61073d0d4fac161ed12926e010dcf8b448a8de6a2ecChris Lattner///
6115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass UnaryOperator : public Expr {
6125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic:
61313d130c3d225cdb5b1e6d9e86cea12eea718c707Chris Lattner  // Note that additions to this should also update the StmtVisitor class.
6145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  enum Opcode {
6155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    PostInc, PostDec, // [C99 6.5.2.4] Postfix increment and decrement operators
6165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    PreInc, PreDec,   // [C99 6.5.3.1] Prefix increment and decrement operators.
6175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    AddrOf, Deref,    // [C99 6.5.3.2] Address and indirection operators.
6185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    Plus, Minus,      // [C99 6.5.3.3] Unary arithmetic operators.
6195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    Not, LNot,        // [C99 6.5.3.3] Unary arithmetic operators.
6205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    Real, Imag,       // "__real expr"/"__imag expr" Extension.
62173d0d4fac161ed12926e010dcf8b448a8de6a2ecChris Lattner    Extension,        // __extension__ marker.
62273d0d4fac161ed12926e010dcf8b448a8de6a2ecChris Lattner    OffsetOf          // __builtin_offsetof
6235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  };
6245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerprivate:
6255549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Stmt *Val;
6265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  Opcode Opc;
6275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation Loc;
6285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic:
6295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
6305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  UnaryOperator(Expr *input, Opcode opc, QualType type, SourceLocation l)
6319103bb27f4eefa0e0d7935387750e3aca24abc49Douglas Gregor    : Expr(UnaryOperatorClass, type,
6329103bb27f4eefa0e0d7935387750e3aca24abc49Douglas Gregor           input->isTypeDependent() && opc != OffsetOf,
6339103bb27f4eefa0e0d7935387750e3aca24abc49Douglas Gregor           input->isValueDependent()),
6349103bb27f4eefa0e0d7935387750e3aca24abc49Douglas Gregor      Val(input), Opc(opc), Loc(l) {}
6355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
6365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  Opcode getOpcode() const { return Opc; }
6375549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getSubExpr() const { return cast<Expr>(Val); }
6385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
6395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// getOperatorLoc - Return the location of the operator.
6405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation getOperatorLoc() const { return Loc; }
6415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
6425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// isPostfix - Return true if this is a postfix operation, like x++.
6432085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner  static bool isPostfix(Opcode Op) {
6442085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner    return Op == PostInc || Op == PostDec;
6452085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner  }
6465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
6475a56ac30d04e8f0431a08980885662a47a6308aaTed Kremenek  /// isPostfix - Return true if this is a prefix operation, like --x.
6482085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner  static bool isPrefix(Opcode Op) {
6492085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner    return Op == PreInc || Op == PreDec;
6502085fd6cd22ec5c268175251db10d7c60caf7aaaChris Lattner  }
6515a56ac30d04e8f0431a08980885662a47a6308aaTed Kremenek
6525a56ac30d04e8f0431a08980885662a47a6308aaTed Kremenek  bool isPrefix() const { return isPrefix(Opc); }
6535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool isPostfix() const { return isPostfix(Opc); }
6545d826b82936beb2c32dd02460332ba8035192c65Ted Kremenek  bool isIncrementOp() const {return Opc==PreInc || Opc==PostInc; }
6555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool isIncrementDecrementOp() const { return Opc>=PostInc && Opc<=PreDec; }
6565a1deb8d9c0722beae28d693fa137bbb942bd11fAnders Carlsson  bool isOffsetOfOp() const { return Opc == OffsetOf; }
6575f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool isArithmeticOp(Opcode Op) { return Op >= Plus && Op <= LNot; }
6585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
6595f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
6605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// corresponds to, e.g. "sizeof" or "[pre]++"
6615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static const char *getOpcodeStr(Opcode Op);
6625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
6635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  virtual SourceRange getSourceRange() const {
6645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    if (isPostfix())
6655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer      return SourceRange(Val->getLocStart(), Loc);
6665f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    else
6675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer      return SourceRange(Loc, Val->getLocEnd());
6685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
6695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  virtual SourceLocation getExprLoc() const { return Loc; }
6705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
6715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const Stmt *T) {
6725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return T->getStmtClass() == UnaryOperatorClass;
6735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
6745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const UnaryOperator *) { return true; }
67577ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek
67677ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  // Iterators
67777ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_begin();
67877ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_end();
6791049436d4b53d928b555f7381bc1639dd302bbc7Ted Kremenek
680ec0aa78745f7b3bc96c20fffd1115bf26aaa0eadTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
681e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static UnaryOperator* CreateImpl(llvm::Deserializer& D, ASTContext& C);
6825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
6835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
6840518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl/// SizeOfAlignOfExpr - [C99 6.5.3.4] - This is for sizeof/alignof, both of
6850518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl/// types and expressions.
6860518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redlclass SizeOfAlignOfExpr : public Expr {
6870518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl  bool isSizeof : 1;  // true if sizeof, false if alignof.
6880518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl  bool isType : 1;    // true if operand is a type, false if an expression
689d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl  union {
690d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    void *Ty;
691d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    Stmt *Ex;
692d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl  } Argument;
6935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation OpLoc, RParenLoc;
6945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic:
695ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor  SizeOfAlignOfExpr(bool issizeof, QualType T,
6960518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl                    QualType resultType, SourceLocation op,
6970518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl                    SourceLocation rp) :
6982850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl      Expr(SizeOfAlignOfExprClass, resultType,
699ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor           false, // Never type-dependent (C++ [temp.dep.expr]p3).
7002850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           // Value-dependent if the argument is type-dependent.
701ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor           T->isDependentType()),
702ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor      isSizeof(issizeof), isType(true), OpLoc(op), RParenLoc(rp) {
703ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor    Argument.Ty = T.getAsOpaquePtr();
704ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor  }
705ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor
706ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor  SizeOfAlignOfExpr(bool issizeof, Expr *E,
707ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor                    QualType resultType, SourceLocation op,
708ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor                    SourceLocation rp) :
709ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor      Expr(SizeOfAlignOfExprClass, resultType,
710ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor           false, // Never type-dependent (C++ [temp.dep.expr]p3).
711ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor           // Value-dependent if the argument is type-dependent.
712ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor           E->isTypeDependent()),
713ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor      isSizeof(issizeof), isType(false), OpLoc(op), RParenLoc(rp) {
714ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor    Argument.Ex = E;
715d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl  }
7160518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl
7179048891ff983d0681c116c6e8f1073aa31bdd6e8Daniel Dunbar  virtual void Destroy(ASTContext& C);
7189048891ff983d0681c116c6e8f1073aa31bdd6e8Daniel Dunbar
7195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool isSizeOf() const { return isSizeof; }
7200518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl  bool isArgumentType() const { return isType; }
7210518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl  QualType getArgumentType() const {
7220518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl    assert(isArgumentType() && "calling getArgumentType() when arg is expr");
723d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    return QualType::getFromOpaquePtr(Argument.Ty);
7240518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl  }
725caae7b099a0324b7c15dc89a9b70969d5d7ce996Chris Lattner  Expr *getArgumentExpr() {
7260518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl    assert(!isArgumentType() && "calling getArgumentExpr() when arg is type");
727d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    return static_cast<Expr*>(Argument.Ex);
7280518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl  }
729caae7b099a0324b7c15dc89a9b70969d5d7ce996Chris Lattner  const Expr *getArgumentExpr() const {
730caae7b099a0324b7c15dc89a9b70969d5d7ce996Chris Lattner    return const_cast<SizeOfAlignOfExpr*>(this)->getArgumentExpr();
731caae7b099a0324b7c15dc89a9b70969d5d7ce996Chris Lattner  }
732caae7b099a0324b7c15dc89a9b70969d5d7ce996Chris Lattner
7330518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl  /// Gets the argument type, or the type of the argument expression, whichever
7340518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl  /// is appropriate.
7350518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl  QualType getTypeOfArgument() const {
7360518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl    return isArgumentType() ? getArgumentType() : getArgumentExpr()->getType();
7370518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl  }
7380518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl
73976e773a443be9f006610f46529e07d4c8d857680Chris Lattner  SourceLocation getOperatorLoc() const { return OpLoc; }
740866b5c03e3b9c01cf496ad97b85a05afc917345bTed Kremenek
741866b5c03e3b9c01cf496ad97b85a05afc917345bTed Kremenek  virtual SourceRange getSourceRange() const {
742866b5c03e3b9c01cf496ad97b85a05afc917345bTed Kremenek    return SourceRange(OpLoc, RParenLoc);
743866b5c03e3b9c01cf496ad97b85a05afc917345bTed Kremenek  }
7445f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
7455f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const Stmt *T) {
7460518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl    return T->getStmtClass() == SizeOfAlignOfExprClass;
7475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
7480518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl  static bool classof(const SizeOfAlignOfExpr *) { return true; }
74977ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek
75077ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  // Iterators
75177ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_begin();
75277ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_end();
753ea2fe9b435e1b55135de32dcac97366554706ac4Ted Kremenek
754ea2fe9b435e1b55135de32dcac97366554706ac4Ted Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
7550518999d3adcc289997bd974dce90cc97f5c1c44Sebastian Redl  static SizeOfAlignOfExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
7565f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
7575f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
7585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
7595f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// Postfix Operators.
7605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
7615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
7625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
7635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass ArraySubscriptExpr : public Expr {
76477ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  enum { LHS, RHS, END_EXPR=2 };
7655549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Stmt* SubExprs[END_EXPR];
7665f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation RBracketLoc;
7675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic:
7682324512285caac0332bbbc6e4cab6245d2a370a1Ted Kremenek  ArraySubscriptExpr(Expr *lhs, Expr *rhs, QualType t,
76973d0d4fac161ed12926e010dcf8b448a8de6a2ecChris Lattner                     SourceLocation rbracketloc)
7702850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl  : Expr(ArraySubscriptExprClass, t,
7712850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl         lhs->isTypeDependent() || rhs->isTypeDependent(),
7722850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl         lhs->isValueDependent() || rhs->isValueDependent()),
7732850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl    RBracketLoc(rbracketloc) {
77473d0d4fac161ed12926e010dcf8b448a8de6a2ecChris Lattner    SubExprs[LHS] = lhs;
77573d0d4fac161ed12926e010dcf8b448a8de6a2ecChris Lattner    SubExprs[RHS] = rhs;
77673d0d4fac161ed12926e010dcf8b448a8de6a2ecChris Lattner  }
7775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
7782324512285caac0332bbbc6e4cab6245d2a370a1Ted Kremenek  /// An array access can be written A[4] or 4[A] (both are equivalent).
7792324512285caac0332bbbc6e4cab6245d2a370a1Ted Kremenek  /// - getBase() and getIdx() always present the normalized view: A[4].
7802324512285caac0332bbbc6e4cab6245d2a370a1Ted Kremenek  ///    In this case getBase() returns "A" and getIdx() returns "4".
7812324512285caac0332bbbc6e4cab6245d2a370a1Ted Kremenek  /// - getLHS() and getRHS() present the syntactic view. e.g. for
7822324512285caac0332bbbc6e4cab6245d2a370a1Ted Kremenek  ///    4[A] getLHS() returns "4".
78333fd5c124aac15bab7cad95e4e0e7761356d2c06Christopher Lamb  /// Note: Because vector element access is also written A[4] we must
78433fd5c124aac15bab7cad95e4e0e7761356d2c06Christopher Lamb  /// predicate the format conversion in getBase and getIdx only on the
78533fd5c124aac15bab7cad95e4e0e7761356d2c06Christopher Lamb  /// the type of the RHS, as it is possible for the LHS to be a vector of
78633fd5c124aac15bab7cad95e4e0e7761356d2c06Christopher Lamb  /// integer type
7875549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getLHS() { return cast<Expr>(SubExprs[LHS]); }
7885549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  const Expr *getLHS() const { return cast<Expr>(SubExprs[LHS]); }
78977ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek
7905549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getRHS() { return cast<Expr>(SubExprs[RHS]); }
7915549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  const Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
7922324512285caac0332bbbc6e4cab6245d2a370a1Ted Kremenek
79377ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  Expr *getBase() {
7945549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek    return cast<Expr>(getRHS()->getType()->isIntegerType() ? getLHS():getRHS());
79577ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  }
79677ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek
7972324512285caac0332bbbc6e4cab6245d2a370a1Ted Kremenek  const Expr *getBase() const {
7985549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek    return cast<Expr>(getRHS()->getType()->isIntegerType() ? getLHS():getRHS());
7992324512285caac0332bbbc6e4cab6245d2a370a1Ted Kremenek  }
8002324512285caac0332bbbc6e4cab6245d2a370a1Ted Kremenek
80177ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  Expr *getIdx() {
8025549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek    return cast<Expr>(getRHS()->getType()->isIntegerType() ? getRHS():getLHS());
8032324512285caac0332bbbc6e4cab6245d2a370a1Ted Kremenek  }
8042324512285caac0332bbbc6e4cab6245d2a370a1Ted Kremenek
80577ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  const Expr *getIdx() const {
8065549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek    return cast<Expr>(getRHS()->getType()->isIntegerType() ? getRHS():getLHS());
80777ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  }
8085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
809866b5c03e3b9c01cf496ad97b85a05afc917345bTed Kremenek  virtual SourceRange getSourceRange() const {
81077ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek    return SourceRange(getLHS()->getLocStart(), RBracketLoc);
8115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
812866b5c03e3b9c01cf496ad97b85a05afc917345bTed Kremenek
813026dc96ac6ece60da5e1b98e2a71bd0ff0939fd8Chris Lattner  SourceLocation getRBracketLoc() const { return RBracketLoc; }
8145cd9d6daf3acd4cc87fecebd81d9495b9e4ba9cdChris Lattner  virtual SourceLocation getExprLoc() const { return getBase()->getExprLoc(); }
8155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
8165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const Stmt *T) {
8175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return T->getStmtClass() == ArraySubscriptExprClass;
8185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
8195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const ArraySubscriptExpr *) { return true; }
82077ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek
82177ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  // Iterators
82277ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_begin();
82377ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_end();
82496fa54fc6dc7f4c8dad1fb22fc7fc4f4d775d6c0Ted Kremenek
825ec0aa78745f7b3bc96c20fffd1115bf26aaa0eadTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
826e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static ArraySubscriptExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
8275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
8285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
8295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
830b4609806e9232593ece09ce08b630836e825865cDouglas Gregor/// CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
831b4609806e9232593ece09ce08b630836e825865cDouglas Gregor/// CallExpr itself represents a normal function call, e.g., "f(x, 2)",
832b4609806e9232593ece09ce08b630836e825865cDouglas Gregor/// while its subclasses may represent alternative syntax that (semantically)
833b4609806e9232593ece09ce08b630836e825865cDouglas Gregor/// results in a function call. For example, CXXOperatorCallExpr is
834b4609806e9232593ece09ce08b630836e825865cDouglas Gregor/// a subclass for overloaded operator calls that use operator syntax, e.g.,
835b4609806e9232593ece09ce08b630836e825865cDouglas Gregor/// "str1 + str2" to resolve to a function call.
8365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass CallExpr : public Expr {
83777ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  enum { FN=0, ARGS_START=1 };
8385549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Stmt **SubExprs;
8395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  unsigned NumArgs;
8405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation RParenLoc;
841d7fe4ea296646f049e4ff4cc37aa92ff4014a6b3Ted Kremenek
842d7fe4ea296646f049e4ff4cc37aa92ff4014a6b3Ted Kremenek  // This version of the ctor is for deserialization.
843b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  CallExpr(StmtClass SC, Stmt** subexprs, unsigned numargs, QualType t,
844d7fe4ea296646f049e4ff4cc37aa92ff4014a6b3Ted Kremenek           SourceLocation rparenloc)
845b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  : Expr(SC,t), SubExprs(subexprs),
846d7fe4ea296646f049e4ff4cc37aa92ff4014a6b3Ted Kremenek    NumArgs(numargs), RParenLoc(rparenloc) {}
847b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
848b4609806e9232593ece09ce08b630836e825865cDouglas Gregorprotected:
849b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  // This version of the constructor is for derived classes.
850668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek  CallExpr(ASTContext& C, StmtClass SC, Expr *fn, Expr **args, unsigned numargs,
851668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek           QualType t, SourceLocation rparenloc);
852d7fe4ea296646f049e4ff4cc37aa92ff4014a6b3Ted Kremenek
8535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic:
854668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek  CallExpr(ASTContext& C, Expr *fn, Expr **args, unsigned numargs, QualType t,
8555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer           SourceLocation rparenloc);
856668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek
857668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek  ~CallExpr() {}
858668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek
859668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek  void Destroy(ASTContext& C);
8605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
8615549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  const Expr *getCallee() const { return cast<Expr>(SubExprs[FN]); }
8625549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getCallee() { return cast<Expr>(SubExprs[FN]); }
86318b2515e1bf8c86a4900792692e42fe1296be28dChris Lattner  void setCallee(Expr *F) { SubExprs[FN] = F; }
8645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
8655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// getNumArgs - Return the number of actual arguments to this call.
8665f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  ///
8675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  unsigned getNumArgs() const { return NumArgs; }
8685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
8695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// getArg - Return the specified argument.
8705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  Expr *getArg(unsigned Arg) {
8715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    assert(Arg < NumArgs && "Arg access out of range!");
8725549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek    return cast<Expr>(SubExprs[Arg+ARGS_START]);
8735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
8745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  const Expr *getArg(unsigned Arg) const {
8755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    assert(Arg < NumArgs && "Arg access out of range!");
8765549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek    return cast<Expr>(SubExprs[Arg+ARGS_START]);
8775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
878668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek
879668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek  // FIXME: Why is this needed?  Why not just create the CallExpr with the
880668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek  // corect number of arguments?  It makes the ASTs less brittle.
881934f276cc5b45e19cd12ebb2d04fd7972a23865cSteve Naroff  /// setArg - Set the specified argument.
882934f276cc5b45e19cd12ebb2d04fd7972a23865cSteve Naroff  void setArg(unsigned Arg, Expr *ArgExpr) {
883934f276cc5b45e19cd12ebb2d04fd7972a23865cSteve Naroff    assert(Arg < NumArgs && "Arg access out of range!");
884934f276cc5b45e19cd12ebb2d04fd7972a23865cSteve Naroff    SubExprs[Arg+ARGS_START] = ArgExpr;
885934f276cc5b45e19cd12ebb2d04fd7972a23865cSteve Naroff  }
886d18b3299debb7b0dbd9d34d9369189dc98c87f53Chris Lattner
887668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek  // FIXME: It would be great to just get rid of this.  There is only one
888668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek  // callee of this method, and it probably could be refactored to not use
889668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek  // this method and instead just create a CallExpr with the right number of
890668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek  // arguments.
891d18b3299debb7b0dbd9d34d9369189dc98c87f53Chris Lattner  /// setNumArgs - This changes the number of arguments present in this call.
892d18b3299debb7b0dbd9d34d9369189dc98c87f53Chris Lattner  /// Any orphaned expressions are deleted by this, and any new operands are set
893d18b3299debb7b0dbd9d34d9369189dc98c87f53Chris Lattner  /// to null.
8948189cde56b4f6f938cd65f53c932fe1860d0204cTed Kremenek  void setNumArgs(ASTContext& C, unsigned NumArgs);
895d18b3299debb7b0dbd9d34d9369189dc98c87f53Chris Lattner
8965549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  typedef ExprIterator arg_iterator;
8975549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  typedef ConstExprIterator const_arg_iterator;
8985549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek
899d18b3299debb7b0dbd9d34d9369189dc98c87f53Chris Lattner  arg_iterator arg_begin() { return SubExprs+ARGS_START; }
900d18b3299debb7b0dbd9d34d9369189dc98c87f53Chris Lattner  arg_iterator arg_end() { return SubExprs+ARGS_START+getNumArgs(); }
9015549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  const_arg_iterator arg_begin() const { return SubExprs+ARGS_START; }
9025549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  const_arg_iterator arg_end() const { return SubExprs+ARGS_START+getNumArgs();}
903d18b3299debb7b0dbd9d34d9369189dc98c87f53Chris Lattner
9045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// getNumCommas - Return the number of commas that must have been present in
9055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// this function call.
9065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  unsigned getNumCommas() const { return NumArgs ? NumArgs - 1 : 0; }
9075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
908cb888967400a03504c88acedd5248d6778a82f46Chris Lattner  /// isBuiltinCall - If this is a call to a builtin, return the builtin ID.  If
909cb888967400a03504c88acedd5248d6778a82f46Chris Lattner  /// not, return 0.
9103c385e5f8d9008fff18597ca302be19fa86e51f6Douglas Gregor  unsigned isBuiltinCall(ASTContext &Context) const;
911cb888967400a03504c88acedd5248d6778a82f46Chris Lattner
912d18b3299debb7b0dbd9d34d9369189dc98c87f53Chris Lattner  SourceLocation getRParenLoc() const { return RParenLoc; }
913866b5c03e3b9c01cf496ad97b85a05afc917345bTed Kremenek
914866b5c03e3b9c01cf496ad97b85a05afc917345bTed Kremenek  virtual SourceRange getSourceRange() const {
91577ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek    return SourceRange(getCallee()->getLocStart(), RParenLoc);
9165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
9175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
9185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const Stmt *T) {
919b4609806e9232593ece09ce08b630836e825865cDouglas Gregor    return T->getStmtClass() == CallExprClass ||
92088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor           T->getStmtClass() == CXXOperatorCallExprClass ||
92188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor           T->getStmtClass() == CXXMemberCallExprClass;
9225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
9235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const CallExpr *) { return true; }
92488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  static bool classof(const CXXOperatorCallExpr *) { return true; }
92588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  static bool classof(const CXXMemberCallExpr *) { return true; }
92688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
92777ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  // Iterators
92877ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_begin();
92977ed8e4edf6ed78c53fb20ec3210aff2a59c9d87Ted Kremenek  virtual child_iterator child_end();
930d7fe4ea296646f049e4ff4cc37aa92ff4014a6b3Ted Kremenek
931ec0aa78745f7b3bc96c20fffd1115bf26aaa0eadTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
932b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  static CallExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C,
933b4609806e9232593ece09ce08b630836e825865cDouglas Gregor                              StmtClass SC);
9345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
9355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
936ddca44e86281bb7dcf5fdcaf1563434c524e3861Chris Lattner/// MemberExpr - [C99 6.5.2.3] Structure and Union Members.  X->F and X.F.
9375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer///
9385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass MemberExpr : public Expr {
939ddca44e86281bb7dcf5fdcaf1563434c524e3861Chris Lattner  /// Base - the expression for the base pointer or structure references.  In
940ddca44e86281bb7dcf5fdcaf1563434c524e3861Chris Lattner  /// X.F, this is "X".
9415549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Stmt *Base;
942ddca44e86281bb7dcf5fdcaf1563434c524e3861Chris Lattner
943ddca44e86281bb7dcf5fdcaf1563434c524e3861Chris Lattner  /// MemberDecl - This is the decl being referenced by the field/member name.
944ddca44e86281bb7dcf5fdcaf1563434c524e3861Chris Lattner  /// In X.F, this is the decl referenced by F.
94586f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor  NamedDecl *MemberDecl;
946ddca44e86281bb7dcf5fdcaf1563434c524e3861Chris Lattner
947ddca44e86281bb7dcf5fdcaf1563434c524e3861Chris Lattner  /// MemberLoc - This is the location of the member name.
9485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation MemberLoc;
949ddca44e86281bb7dcf5fdcaf1563434c524e3861Chris Lattner
950ddca44e86281bb7dcf5fdcaf1563434c524e3861Chris Lattner  /// IsArrow - True if this is "X->F", false if this is "X.F".
951ddca44e86281bb7dcf5fdcaf1563434c524e3861Chris Lattner  bool IsArrow;
9525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic:
95386f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor  MemberExpr(Expr *base, bool isarrow, NamedDecl *memberdecl, SourceLocation l,
954510190777c4bd53e960eea4665b204778fec1b64Eli Friedman             QualType ty)
955510190777c4bd53e960eea4665b204778fec1b64Eli Friedman    : Expr(MemberExprClass, ty),
9565f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer      Base(base), MemberDecl(memberdecl), MemberLoc(l), IsArrow(isarrow) {}
957510190777c4bd53e960eea4665b204778fec1b64Eli Friedman
95888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  void setBase(Expr *E) { Base = E; }
9595549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getBase() const { return cast<Expr>(Base); }
96086f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor  NamedDecl *getMemberDecl() const { return MemberDecl; }
96188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  void setMemberDecl(NamedDecl *D) { MemberDecl = D; }
9625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool isArrow() const { return IsArrow; }
963ddca44e86281bb7dcf5fdcaf1563434c524e3861Chris Lattner
964ddca44e86281bb7dcf5fdcaf1563434c524e3861Chris Lattner  /// getMemberLoc - Return the location of the "member", in X->F, it is the
965ddca44e86281bb7dcf5fdcaf1563434c524e3861Chris Lattner  /// location of 'F'.
966026dc96ac6ece60da5e1b98e2a71bd0ff0939fd8Chris Lattner  SourceLocation getMemberLoc() const { return MemberLoc; }
9675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
9685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  virtual SourceRange getSourceRange() const {
9695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return SourceRange(getBase()->getLocStart(), MemberLoc);
9705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
971866b5c03e3b9c01cf496ad97b85a05afc917345bTed Kremenek
9725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  virtual SourceLocation getExprLoc() const { return MemberLoc; }
9735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
9745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const Stmt *T) {
9755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return T->getStmtClass() == MemberExprClass;
9765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
9775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const MemberExpr *) { return true; }
9781237c673c07f9d827129ba02720108816abde562Ted Kremenek
9791237c673c07f9d827129ba02720108816abde562Ted Kremenek  // Iterators
9801237c673c07f9d827129ba02720108816abde562Ted Kremenek  virtual child_iterator child_begin();
9811237c673c07f9d827129ba02720108816abde562Ted Kremenek  virtual child_iterator child_end();
982bd57e7c4754c0ce5d7d460041c8fd613e45c4319Ted Kremenek
983bd57e7c4754c0ce5d7d460041c8fd613e45c4319Ted Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
984e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static MemberExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
9855f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
9865f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
987aff1edd84aaafef15b737acd8ec61abcca6d6bc3Steve Naroff/// CompoundLiteralExpr - [C99 6.5.2.5]
988aff1edd84aaafef15b737acd8ec61abcca6d6bc3Steve Naroff///
989aff1edd84aaafef15b737acd8ec61abcca6d6bc3Steve Naroffclass CompoundLiteralExpr : public Expr {
9900fc53dfc7a33f68e71ef245389c4e7cd34a62a39Chris Lattner  /// LParenLoc - If non-null, this is the location of the left paren in a
9910fc53dfc7a33f68e71ef245389c4e7cd34a62a39Chris Lattner  /// compound literal like "(int){4}".  This can be null if this is a
9920fc53dfc7a33f68e71ef245389c4e7cd34a62a39Chris Lattner  /// synthesized compound expression.
9930fc53dfc7a33f68e71ef245389c4e7cd34a62a39Chris Lattner  SourceLocation LParenLoc;
9945549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Stmt *Init;
995e9b12198c4cc7f5687960100351b4af006c14469Steve Naroff  bool FileScope;
996aff1edd84aaafef15b737acd8ec61abcca6d6bc3Steve Naroffpublic:
997a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  CompoundLiteralExpr(SourceLocation lparenloc, QualType ty, Expr *init,
998a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner                      bool fileScope)
999a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner    : Expr(CompoundLiteralExprClass, ty), LParenLoc(lparenloc), Init(init),
1000a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner      FileScope(fileScope) {}
1001aff1edd84aaafef15b737acd8ec61abcca6d6bc3Steve Naroff
10025549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  const Expr *getInitializer() const { return cast<Expr>(Init); }
10035549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getInitializer() { return cast<Expr>(Init); }
1004e9b12198c4cc7f5687960100351b4af006c14469Steve Naroff
1005e9b12198c4cc7f5687960100351b4af006c14469Steve Naroff  bool isFileScope() const { return FileScope; }
1006aff1edd84aaafef15b737acd8ec61abcca6d6bc3Steve Naroff
10070fc53dfc7a33f68e71ef245389c4e7cd34a62a39Chris Lattner  SourceLocation getLParenLoc() const { return LParenLoc; }
10080fc53dfc7a33f68e71ef245389c4e7cd34a62a39Chris Lattner
100973d0d4fac161ed12926e010dcf8b448a8de6a2ecChris Lattner  virtual SourceRange getSourceRange() const {
10100fc53dfc7a33f68e71ef245389c4e7cd34a62a39Chris Lattner    // FIXME: Init should never be null.
10110fc53dfc7a33f68e71ef245389c4e7cd34a62a39Chris Lattner    if (!Init)
10120fc53dfc7a33f68e71ef245389c4e7cd34a62a39Chris Lattner      return SourceRange();
10130fc53dfc7a33f68e71ef245389c4e7cd34a62a39Chris Lattner    if (LParenLoc.isInvalid())
101473d0d4fac161ed12926e010dcf8b448a8de6a2ecChris Lattner      return Init->getSourceRange();
10150fc53dfc7a33f68e71ef245389c4e7cd34a62a39Chris Lattner    return SourceRange(LParenLoc, Init->getLocEnd());
101673d0d4fac161ed12926e010dcf8b448a8de6a2ecChris Lattner  }
1017aff1edd84aaafef15b737acd8ec61abcca6d6bc3Steve Naroff
1018aff1edd84aaafef15b737acd8ec61abcca6d6bc3Steve Naroff  static bool classof(const Stmt *T) {
1019aff1edd84aaafef15b737acd8ec61abcca6d6bc3Steve Naroff    return T->getStmtClass() == CompoundLiteralExprClass;
1020aff1edd84aaafef15b737acd8ec61abcca6d6bc3Steve Naroff  }
1021aff1edd84aaafef15b737acd8ec61abcca6d6bc3Steve Naroff  static bool classof(const CompoundLiteralExpr *) { return true; }
10221237c673c07f9d827129ba02720108816abde562Ted Kremenek
10231237c673c07f9d827129ba02720108816abde562Ted Kremenek  // Iterators
10241237c673c07f9d827129ba02720108816abde562Ted Kremenek  virtual child_iterator child_begin();
10251237c673c07f9d827129ba02720108816abde562Ted Kremenek  virtual child_iterator child_end();
10264b7d9ca9fd65a5a68e907b1b7effe33bf1e93629Ted Kremenek
10274b7d9ca9fd65a5a68e907b1b7effe33bf1e93629Ted Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
1028e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static CompoundLiteralExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
1029aff1edd84aaafef15b737acd8ec61abcca6d6bc3Steve Naroff};
1030aff1edd84aaafef15b737acd8ec61abcca6d6bc3Steve Naroff
103149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CastExpr - Base class for type casts, including both implicit
103249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// casts (ImplicitCastExpr) and explicit casts that have some
103349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// representation in the source code (ExplicitCastExpr's derived
103449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// classes).
10350835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidisclass CastExpr : public Expr {
10360835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis  Stmt *Op;
10370835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidisprotected:
10380835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis  CastExpr(StmtClass SC, QualType ty, Expr *op) :
1039898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor    Expr(SC, ty,
1040898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor         // Cast expressions are type-dependent if the type is
1041898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor         // dependent (C++ [temp.dep.expr]p3).
1042898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor         ty->isDependentType(),
1043898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor         // Cast expressions are value-dependent if the type is
1044898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor         // dependent or if the subexpression is value-dependent.
1045898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor         ty->isDependentType() || (op && op->isValueDependent())),
1046898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor    Op(op) {}
10470835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis
10480835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidispublic:
10490835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis  Expr *getSubExpr() { return cast<Expr>(Op); }
10500835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis  const Expr *getSubExpr() const { return cast<Expr>(Op); }
10510835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis
10520835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis  static bool classof(const Stmt *T) {
10539d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor    StmtClass SC = T->getStmtClass();
10549d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor    if (SC >= CXXNamedCastExprClass && SC <= CXXFunctionalCastExprClass)
10559d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor      return true;
10569d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor
10576eec8e883de118b431e3ead5b1e604a6ac68ff6bDouglas Gregor    if (SC >= ImplicitCastExprClass && SC <= CStyleCastExprClass)
10580835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis      return true;
10599d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor
10609d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor    return false;
10610835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis  }
10620835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis  static bool classof(const CastExpr *) { return true; }
10630835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis
10640835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis  // Iterators
10650835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis  virtual child_iterator child_begin();
10660835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis  virtual child_iterator child_end();
10670835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis};
10680835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis
106949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// ImplicitCastExpr - Allows us to explicitly represent implicit type
107049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// conversions, which have no direct representation in the original
107149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// source code. For example: converting T[]->T*, void f()->void
107249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// (*f)(), float->double, short->int, etc.
107349b4526992a8c8a6a290aa3efa9828154a24af8dSteve Naroff///
1074bf3af056289893f58d37b05a2c80970708781d61Douglas Gregor/// In C, implicit casts always produce rvalues. However, in C++, an
1075bf3af056289893f58d37b05a2c80970708781d61Douglas Gregor/// implicit cast whose result is being bound to a reference will be
1076bf3af056289893f58d37b05a2c80970708781d61Douglas Gregor/// an lvalue. For example:
1077bf3af056289893f58d37b05a2c80970708781d61Douglas Gregor///
1078bf3af056289893f58d37b05a2c80970708781d61Douglas Gregor/// @code
1079bf3af056289893f58d37b05a2c80970708781d61Douglas Gregor/// class Base { };
1080bf3af056289893f58d37b05a2c80970708781d61Douglas Gregor/// class Derived : public Base { };
1081bf3af056289893f58d37b05a2c80970708781d61Douglas Gregor/// void f(Derived d) {
1082bf3af056289893f58d37b05a2c80970708781d61Douglas Gregor///   Base& b = d; // initializer is an ImplicitCastExpr to an lvalue of type Base
1083bf3af056289893f58d37b05a2c80970708781d61Douglas Gregor/// }
1084bf3af056289893f58d37b05a2c80970708781d61Douglas Gregor/// @endcode
10850835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidisclass ImplicitCastExpr : public CastExpr {
1086eb8f3063257a392f15aea48d42fb73ec51afc548Douglas Gregor  /// LvalueCast - Whether this cast produces an lvalue.
1087eb8f3063257a392f15aea48d42fb73ec51afc548Douglas Gregor  bool LvalueCast;
1088eb8f3063257a392f15aea48d42fb73ec51afc548Douglas Gregor
108949b4526992a8c8a6a290aa3efa9828154a24af8dSteve Naroffpublic:
1090eb8f3063257a392f15aea48d42fb73ec51afc548Douglas Gregor  ImplicitCastExpr(QualType ty, Expr *op, bool Lvalue) :
1091b3eef68111ffc220e449be96da1747998c057790Douglas Gregor    CastExpr(ImplicitCastExprClass, ty, op), LvalueCast(Lvalue) { }
109290045e8ebabf50d6f1b3a67081a621b20b5e5341Steve Naroff
10930835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
10940835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis    return getSubExpr()->getSourceRange();
10950835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidis  }
109690045e8ebabf50d6f1b3a67081a621b20b5e5341Steve Naroff
1097eb8f3063257a392f15aea48d42fb73ec51afc548Douglas Gregor  /// isLvalueCast - Whether this cast produces an lvalue.
1098eb8f3063257a392f15aea48d42fb73ec51afc548Douglas Gregor  bool isLvalueCast() const { return LvalueCast; }
1099eb8f3063257a392f15aea48d42fb73ec51afc548Douglas Gregor
1100eb8f3063257a392f15aea48d42fb73ec51afc548Douglas Gregor  /// setLvalueCast - Set whether this cast produces an lvalue.
1101eb8f3063257a392f15aea48d42fb73ec51afc548Douglas Gregor  void setLvalueCast(bool Lvalue) { LvalueCast = Lvalue; }
1102eb8f3063257a392f15aea48d42fb73ec51afc548Douglas Gregor
110349b4526992a8c8a6a290aa3efa9828154a24af8dSteve Naroff  static bool classof(const Stmt *T) {
110449b4526992a8c8a6a290aa3efa9828154a24af8dSteve Naroff    return T->getStmtClass() == ImplicitCastExprClass;
110549b4526992a8c8a6a290aa3efa9828154a24af8dSteve Naroff  }
110649b4526992a8c8a6a290aa3efa9828154a24af8dSteve Naroff  static bool classof(const ImplicitCastExpr *) { return true; }
11071237c673c07f9d827129ba02720108816abde562Ted Kremenek
1108ec0aa78745f7b3bc96c20fffd1115bf26aaa0eadTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
1109e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static ImplicitCastExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
111049b4526992a8c8a6a290aa3efa9828154a24af8dSteve Naroff};
111149b4526992a8c8a6a290aa3efa9828154a24af8dSteve Naroff
111249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// ExplicitCastExpr - An explicit cast written in the source
111349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// code.
111449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
111549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This class is effectively an abstract class, because it provides
111649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// the basic representation of an explicitly-written cast without
111749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// specifying which kind of cast (C cast, functional cast, static
111849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// cast, etc.) was written; specific derived classes represent the
111949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// particular style of cast and its location information.
11205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer///
112149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// Unlike implicit casts, explicit cast nodes have two different
112249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// types: the type that was written into the source code, and the
112349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// actual type of the expression as determined by semantic
112449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// analysis. These types may differ slightly. For example, in C++ one
112549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// can cast to a reference type, which indicates that the resulting
112649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// expression will be an lvalue. The reference type, however, will
112749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// not be used as the type of the expression.
11280835a3cdeefe714b4959d31127ea155e56393125Argyrios Kyrtzidisclass ExplicitCastExpr : public CastExpr {
112949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  /// TypeAsWritten - The type that this expression is casting to, as
113049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  /// written in the source code.
113149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  QualType TypeAsWritten;
113249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
113349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorprotected:
11348320aaaa01d931aa234fc3bce05b399ef41898d5Daniel Dunbar  ExplicitCastExpr(StmtClass SC, QualType exprTy, Expr *op, QualType writtenTy)
11358320aaaa01d931aa234fc3bce05b399ef41898d5Daniel Dunbar    : CastExpr(SC, exprTy, op), TypeAsWritten(writtenTy) {}
113649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
113749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
113849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  /// getTypeAsWritten - Returns the type that this expression is
113949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  /// casting to, as written in the source code.
114049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  QualType getTypeAsWritten() const { return TypeAsWritten; }
114149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
114249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const Stmt *T) {
11439d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor    StmtClass SC = T->getStmtClass();
11446eec8e883de118b431e3ead5b1e604a6ac68ff6bDouglas Gregor    if (SC >= ExplicitCastExprClass && SC <= CStyleCastExprClass)
11459d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor      return true;
11469d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor    if (SC >= CXXNamedCastExprClass && SC <= CXXFunctionalCastExprClass)
114749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return true;
11489d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor
11499d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor    return false;
115049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
115149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const ExplicitCastExpr *) { return true; }
115249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
115349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
11546eec8e883de118b431e3ead5b1e604a6ac68ff6bDouglas Gregor/// CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style
115549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// cast in C++ (C++ [expr.cast]), which uses the syntax
115649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// (Type)expr. For example: @c (int)f.
11576eec8e883de118b431e3ead5b1e604a6ac68ff6bDouglas Gregorclass CStyleCastExpr : public ExplicitCastExpr {
1158b2f9e516327310d95840d442416084508f80c183Steve Naroff  SourceLocation LPLoc; // the location of the left paren
1159b2f9e516327310d95840d442416084508f80c183Steve Naroff  SourceLocation RPLoc; // the location of the right paren
11605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic:
11616eec8e883de118b431e3ead5b1e604a6ac68ff6bDouglas Gregor  CStyleCastExpr(QualType exprTy, Expr *op, QualType writtenTy,
1162b2f9e516327310d95840d442416084508f80c183Steve Naroff                    SourceLocation l, SourceLocation r) :
1163b2f9e516327310d95840d442416084508f80c183Steve Naroff    ExplicitCastExpr(CStyleCastExprClass, exprTy, op, writtenTy),
1164b2f9e516327310d95840d442416084508f80c183Steve Naroff    LPLoc(l), RPLoc(r) {}
116549b4526992a8c8a6a290aa3efa9828154a24af8dSteve Naroff
1166b2f9e516327310d95840d442416084508f80c183Steve Naroff  SourceLocation getLParenLoc() const { return LPLoc; }
1167b2f9e516327310d95840d442416084508f80c183Steve Naroff  SourceLocation getRParenLoc() const { return RPLoc; }
11685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
11695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  virtual SourceRange getSourceRange() const {
1170b2f9e516327310d95840d442416084508f80c183Steve Naroff    return SourceRange(LPLoc, getSubExpr()->getSourceRange().getEnd());
11715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
11725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const Stmt *T) {
11736eec8e883de118b431e3ead5b1e604a6ac68ff6bDouglas Gregor    return T->getStmtClass() == CStyleCastExprClass;
11745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
11756eec8e883de118b431e3ead5b1e604a6ac68ff6bDouglas Gregor  static bool classof(const CStyleCastExpr *) { return true; }
11769971c9ace70624987cd74645a75f4bfbc05afdf2Ted Kremenek
1177ec0aa78745f7b3bc96c20fffd1115bf26aaa0eadTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
11786eec8e883de118b431e3ead5b1e604a6ac68ff6bDouglas Gregor  static CStyleCastExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
11795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
11805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
11813fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// \brief A builtin binary operation expression such as "x + y" or "x <= y".
11823fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor///
11833fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// This expression node kind describes a builtin binary operation,
11843fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// such as "x + y" for integer values "x" and "y". The operands will
11853fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// already have been converted to appropriate types (e.g., by
11863fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// performing promotions or conversions).
11873fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor///
11883fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// In C++, where operators may be overloaded, a different kind of
11893fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// expression node (CXXOperatorCallExpr) is used to express the
11903fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// invocation of an overloaded operator with operator syntax. Within
11913fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// a C++ template, whether BinaryOperator or CXXOperatorCallExpr is
11923fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// used to store an expression "x + y" depends on the subexpressions
11933fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// for x and y. If neither x or y is type-dependent, and the "+"
11943fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// operator resolves to a built-in operation, BinaryOperator will be
11953fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// used to express the computation (x and y may still be
11963fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// value-dependent). If either x or y is type-dependent, or if the
11973fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// "+" resolves to an overloaded operator, CXXOperatorCallExpr will
11983fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// be used to express the computation.
11995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass BinaryOperator : public Expr {
12005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic:
12015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  enum Opcode {
12025f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    // Operators listed in order of precedence.
120303d6fb99224c36935c9af9f4785cb33453c99b2bChris Lattner    // Note that additions to this should also update the StmtVisitor class.
1204224605064a4ef87d1c3d35ad1cb363f8b534012bSebastian Redl    PtrMemD, PtrMemI, // [C++ 5.5] Pointer-to-member operators.
12055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    Mul, Div, Rem,    // [C99 6.5.5] Multiplicative operators.
12065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    Add, Sub,         // [C99 6.5.6] Additive operators.
12075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    Shl, Shr,         // [C99 6.5.7] Bitwise shift operators.
12085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    LT, GT, LE, GE,   // [C99 6.5.8] Relational operators.
12095f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    EQ, NE,           // [C99 6.5.9] Equality operators.
12105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    And,              // [C99 6.5.10] Bitwise AND operator.
12115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    Xor,              // [C99 6.5.11] Bitwise XOR operator.
12125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    Or,               // [C99 6.5.12] Bitwise OR operator.
12135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    LAnd,             // [C99 6.5.13] Logical AND operator.
12145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    LOr,              // [C99 6.5.14] Logical OR operator.
12155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    Assign, MulAssign,// [C99 6.5.16] Assignment operators.
12165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    DivAssign, RemAssign,
12175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    AddAssign, SubAssign,
12185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    ShlAssign, ShrAssign,
12195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    AndAssign, XorAssign,
12205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    OrAssign,
12215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    Comma             // [C99 6.5.17] Comma operator.
12225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  };
122317d1b2ac9f8371a0a2e79d4f8e0008658164f080Chris Lattnerprivate:
122417d1b2ac9f8371a0a2e79d4f8e0008658164f080Chris Lattner  enum { LHS, RHS, END_EXPR };
12255549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Stmt* SubExprs[END_EXPR];
122617d1b2ac9f8371a0a2e79d4f8e0008658164f080Chris Lattner  Opcode Opc;
122717d1b2ac9f8371a0a2e79d4f8e0008658164f080Chris Lattner  SourceLocation OpLoc;
122817d1b2ac9f8371a0a2e79d4f8e0008658164f080Chris Lattnerpublic:
12295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
123017d1b2ac9f8371a0a2e79d4f8e0008658164f080Chris Lattner  BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
123117d1b2ac9f8371a0a2e79d4f8e0008658164f080Chris Lattner                 SourceLocation opLoc)
1232898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor    : Expr(BinaryOperatorClass, ResTy,
1233898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor           lhs->isTypeDependent() || rhs->isTypeDependent(),
1234898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor           lhs->isValueDependent() || rhs->isValueDependent()),
1235898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor      Opc(opc), OpLoc(opLoc) {
12361237c673c07f9d827129ba02720108816abde562Ted Kremenek    SubExprs[LHS] = lhs;
12371237c673c07f9d827129ba02720108816abde562Ted Kremenek    SubExprs[RHS] = rhs;
12385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    assert(!isCompoundAssignmentOp() &&
12395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer           "Use ArithAssignBinaryOperator for compound assignments");
12405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
12415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
124217d1b2ac9f8371a0a2e79d4f8e0008658164f080Chris Lattner  SourceLocation getOperatorLoc() const { return OpLoc; }
12435f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  Opcode getOpcode() const { return Opc; }
12445549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getLHS() const { return cast<Expr>(SubExprs[LHS]); }
12455549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
12465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  virtual SourceRange getSourceRange() const {
12475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return SourceRange(getLHS()->getLocStart(), getRHS()->getLocEnd());
12485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
12495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
12505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
12515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// corresponds to, e.g. "<<=".
12525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static const char *getOpcodeStr(Opcode Op);
12535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
1254063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  /// \brief Retrieve the binary opcode that corresponds to the given
1255063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  /// overloaded operator.
1256063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  static Opcode getOverloadedOpcode(OverloadedOperatorKind OO);
1257063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor
1258063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  /// \brief Retrieve the overloaded operator kind that corresponds to
1259063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  /// the given binary opcode.
1260063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  static OverloadedOperatorKind getOverloadedOperator(Opcode Opc);
1261063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor
12625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// predicates to categorize the respective opcodes.
12635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool isMultiplicativeOp() const { return Opc >= Mul && Opc <= Rem; }
12645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool isAdditiveOp() const { return Opc == Add || Opc == Sub; }
12655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool isShiftOp() const { return Opc == Shl || Opc == Shr; }
12665f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool isBitwiseOp() const { return Opc >= And && Opc <= Or; }
1267f2da7a06f6b98c3886d9b871ab839f5085b1c238Ted Kremenek
1268f2da7a06f6b98c3886d9b871ab839f5085b1c238Ted Kremenek  static bool isRelationalOp(Opcode Opc) { return Opc >= LT && Opc <= GE; }
1269f2da7a06f6b98c3886d9b871ab839f5085b1c238Ted Kremenek  bool isRelationalOp() const { return isRelationalOp(Opc); }
1270f2da7a06f6b98c3886d9b871ab839f5085b1c238Ted Kremenek
1271f2da7a06f6b98c3886d9b871ab839f5085b1c238Ted Kremenek  static bool isEqualityOp(Opcode Opc) { return Opc == EQ || Opc == NE; }
1272f2da7a06f6b98c3886d9b871ab839f5085b1c238Ted Kremenek  bool isEqualityOp() const { return isEqualityOp(Opc); }
1273f2da7a06f6b98c3886d9b871ab839f5085b1c238Ted Kremenek
1274f2da7a06f6b98c3886d9b871ab839f5085b1c238Ted Kremenek  static bool isLogicalOp(Opcode Opc) { return Opc == LAnd || Opc == LOr; }
1275f2da7a06f6b98c3886d9b871ab839f5085b1c238Ted Kremenek  bool isLogicalOp() const { return isLogicalOp(Opc); }
1276f2da7a06f6b98c3886d9b871ab839f5085b1c238Ted Kremenek
12775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool isAssignmentOp() const { return Opc >= Assign && Opc <= OrAssign; }
12785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool isCompoundAssignmentOp() const { return Opc > Assign && Opc <= OrAssign;}
12795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool isShiftAssignOp() const { return Opc == ShlAssign || Opc == ShrAssign; }
12805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
1281eb14fe839ec24c2ca14e5f094be147a34e3d3339Chris Lattner  static bool classof(const Stmt *S) {
1282eb14fe839ec24c2ca14e5f094be147a34e3d3339Chris Lattner    return S->getStmtClass() == BinaryOperatorClass ||
1283eb14fe839ec24c2ca14e5f094be147a34e3d3339Chris Lattner           S->getStmtClass() == CompoundAssignOperatorClass;
12845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
12855f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const BinaryOperator *) { return true; }
12861237c673c07f9d827129ba02720108816abde562Ted Kremenek
12871237c673c07f9d827129ba02720108816abde562Ted Kremenek  // Iterators
12881237c673c07f9d827129ba02720108816abde562Ted Kremenek  virtual child_iterator child_begin();
12891237c673c07f9d827129ba02720108816abde562Ted Kremenek  virtual child_iterator child_end();
12902dc9ac73a8a34cabf261a81a1653d7379065ac61Ted Kremenek
1291ec0aa78745f7b3bc96c20fffd1115bf26aaa0eadTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
1292e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static BinaryOperator* CreateImpl(llvm::Deserializer& D, ASTContext& C);
12931237c673c07f9d827129ba02720108816abde562Ted Kremenek
12945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerprotected:
129517d1b2ac9f8371a0a2e79d4f8e0008658164f080Chris Lattner  BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
129617d1b2ac9f8371a0a2e79d4f8e0008658164f080Chris Lattner                 SourceLocation oploc, bool dead)
129717d1b2ac9f8371a0a2e79d4f8e0008658164f080Chris Lattner    : Expr(CompoundAssignOperatorClass, ResTy), Opc(opc), OpLoc(oploc) {
12981237c673c07f9d827129ba02720108816abde562Ted Kremenek    SubExprs[LHS] = lhs;
12991237c673c07f9d827129ba02720108816abde562Ted Kremenek    SubExprs[RHS] = rhs;
13005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
13015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
13025f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
13035f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// CompoundAssignOperator - For compound assignments (e.g. +=), we keep
13045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// track of the type the operation is performed in.  Due to the semantics of
13055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// these operators, the operands are promoted, the aritmetic performed, an
13065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// implicit conversion back to the result type done, then the assignment takes
13075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// place.  This captures the intermediate type which the computation is done
13085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// in.
13095f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass CompoundAssignOperator : public BinaryOperator {
13105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  QualType ComputationType;
13115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic:
13125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  CompoundAssignOperator(Expr *lhs, Expr *rhs, Opcode opc,
131317d1b2ac9f8371a0a2e79d4f8e0008658164f080Chris Lattner                         QualType ResType, QualType CompType,
131417d1b2ac9f8371a0a2e79d4f8e0008658164f080Chris Lattner                         SourceLocation OpLoc)
131517d1b2ac9f8371a0a2e79d4f8e0008658164f080Chris Lattner    : BinaryOperator(lhs, rhs, opc, ResType, OpLoc, true),
131617d1b2ac9f8371a0a2e79d4f8e0008658164f080Chris Lattner      ComputationType(CompType) {
13175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    assert(isCompoundAssignmentOp() &&
13185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer           "Only should be used for compound assignments");
13195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
13205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
13215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  QualType getComputationType() const { return ComputationType; }
13225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
13235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const CompoundAssignOperator *) { return true; }
13245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const Stmt *S) {
1325eb14fe839ec24c2ca14e5f094be147a34e3d3339Chris Lattner    return S->getStmtClass() == CompoundAssignOperatorClass;
13265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
132783efb151a0c1df8cb8fb25d6dbb6c0f12f07f60aTed Kremenek
1328ec0aa78745f7b3bc96c20fffd1115bf26aaa0eadTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
1329e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static CompoundAssignOperator* CreateImpl(llvm::Deserializer& D,
1330e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop                                            ASTContext& C);
13315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
13325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
13335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// ConditionalOperator - The ?: operator.  Note that LHS may be null when the
13345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// GNU "missing LHS" extension is in use.
13355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer///
13365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass ConditionalOperator : public Expr {
13371237c673c07f9d827129ba02720108816abde562Ted Kremenek  enum { COND, LHS, RHS, END_EXPR };
13385549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Stmt* SubExprs[END_EXPR]; // Left/Middle/Right hand sides.
13395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic:
13405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  ConditionalOperator(Expr *cond, Expr *lhs, Expr *rhs, QualType t)
1341898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor    : Expr(ConditionalOperatorClass, t,
1342898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor           // FIXME: the type of the conditional operator doesn't
1343898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor           // depend on the type of the conditional, but the standard
1344898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor           // seems to imply that it could. File a bug!
1345898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor           ((lhs && lhs->isTypeDependent()) || (rhs && rhs->isTypeDependent())),
1346898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor           (cond->isValueDependent() ||
1347898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor            (lhs && lhs->isValueDependent()) ||
1348898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor            (rhs && rhs->isValueDependent()))) {
13491237c673c07f9d827129ba02720108816abde562Ted Kremenek    SubExprs[COND] = cond;
13501237c673c07f9d827129ba02720108816abde562Ted Kremenek    SubExprs[LHS] = lhs;
13511237c673c07f9d827129ba02720108816abde562Ted Kremenek    SubExprs[RHS] = rhs;
13521237c673c07f9d827129ba02720108816abde562Ted Kremenek  }
13535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
1354395a2abf0028968d85958610e393e067885dc14fTed Kremenek  // getCond - Return the expression representing the condition for
1355395a2abf0028968d85958610e393e067885dc14fTed Kremenek  //  the ?: operator.
13565549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getCond() const { return cast<Expr>(SubExprs[COND]); }
1357395a2abf0028968d85958610e393e067885dc14fTed Kremenek
1358395a2abf0028968d85958610e393e067885dc14fTed Kremenek  // getTrueExpr - Return the subexpression representing the value of the ?:
1359395a2abf0028968d85958610e393e067885dc14fTed Kremenek  //  expression if the condition evaluates to true.  In most cases this value
1360395a2abf0028968d85958610e393e067885dc14fTed Kremenek  //  will be the same as getLHS() except a GCC extension allows the left
1361395a2abf0028968d85958610e393e067885dc14fTed Kremenek  //  subexpression to be omitted, and instead of the condition be returned.
1362395a2abf0028968d85958610e393e067885dc14fTed Kremenek  //  e.g: x ?: y is shorthand for x ? x : y, except that the expression "x"
1363395a2abf0028968d85958610e393e067885dc14fTed Kremenek  //  is only evaluated once.
1364395a2abf0028968d85958610e393e067885dc14fTed Kremenek  Expr *getTrueExpr() const {
13655549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek    return cast<Expr>(SubExprs[LHS] ? SubExprs[LHS] : SubExprs[COND]);
1366395a2abf0028968d85958610e393e067885dc14fTed Kremenek  }
1367395a2abf0028968d85958610e393e067885dc14fTed Kremenek
1368395a2abf0028968d85958610e393e067885dc14fTed Kremenek  // getTrueExpr - Return the subexpression representing the value of the ?:
1369395a2abf0028968d85958610e393e067885dc14fTed Kremenek  // expression if the condition evaluates to false. This is the same as getRHS.
13705549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getFalseExpr() const { return cast<Expr>(SubExprs[RHS]); }
1371395a2abf0028968d85958610e393e067885dc14fTed Kremenek
13725549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getLHS() const { return cast_or_null<Expr>(SubExprs[LHS]); }
13735549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
13745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
13755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  virtual SourceRange getSourceRange() const {
13765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return SourceRange(getCond()->getLocStart(), getRHS()->getLocEnd());
13775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
13785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const Stmt *T) {
13795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return T->getStmtClass() == ConditionalOperatorClass;
13805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
13815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const ConditionalOperator *) { return true; }
13821237c673c07f9d827129ba02720108816abde562Ted Kremenek
13831237c673c07f9d827129ba02720108816abde562Ted Kremenek  // Iterators
13841237c673c07f9d827129ba02720108816abde562Ted Kremenek  virtual child_iterator child_begin();
13851237c673c07f9d827129ba02720108816abde562Ted Kremenek  virtual child_iterator child_end();
1386aa33763cc3dfa2fcb4fdb3c5b4be0c37f8d8f8e9Ted Kremenek
1387ec0aa78745f7b3bc96c20fffd1115bf26aaa0eadTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
1388e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static ConditionalOperator* CreateImpl(llvm::Deserializer& D, ASTContext& C);
13895f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
13905f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
13916481a57fefbf1a313ff439028470fe4c27a3b7a3Chris Lattner/// AddrLabelExpr - The GNU address of label extension, representing &&label.
13926481a57fefbf1a313ff439028470fe4c27a3b7a3Chris Lattnerclass AddrLabelExpr : public Expr {
13935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation AmpAmpLoc, LabelLoc;
13945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  LabelStmt *Label;
13955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic:
13966481a57fefbf1a313ff439028470fe4c27a3b7a3Chris Lattner  AddrLabelExpr(SourceLocation AALoc, SourceLocation LLoc, LabelStmt *L,
13976481a57fefbf1a313ff439028470fe4c27a3b7a3Chris Lattner                QualType t)
13986481a57fefbf1a313ff439028470fe4c27a3b7a3Chris Lattner    : Expr(AddrLabelExprClass, t), AmpAmpLoc(AALoc), LabelLoc(LLoc), Label(L) {}
13995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
14005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  virtual SourceRange getSourceRange() const {
14015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return SourceRange(AmpAmpLoc, LabelLoc);
14025f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
14035f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
14045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  LabelStmt *getLabel() const { return Label; }
14055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
14065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  static bool classof(const Stmt *T) {
14076481a57fefbf1a313ff439028470fe4c27a3b7a3Chris Lattner    return T->getStmtClass() == AddrLabelExprClass;
14085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
14096481a57fefbf1a313ff439028470fe4c27a3b7a3Chris Lattner  static bool classof(const AddrLabelExpr *) { return true; }
14101237c673c07f9d827129ba02720108816abde562Ted Kremenek
14111237c673c07f9d827129ba02720108816abde562Ted Kremenek  // Iterators
14121237c673c07f9d827129ba02720108816abde562Ted Kremenek  virtual child_iterator child_begin();
14131237c673c07f9d827129ba02720108816abde562Ted Kremenek  virtual child_iterator child_end();
1414aa33763cc3dfa2fcb4fdb3c5b4be0c37f8d8f8e9Ted Kremenek
1415ec0aa78745f7b3bc96c20fffd1115bf26aaa0eadTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
1416e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static AddrLabelExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
14175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
1418ab18c4c0ac1a46a38aa84c2c8ea485612e21a614Chris Lattner
1419ab18c4c0ac1a46a38aa84c2c8ea485612e21a614Chris Lattner/// StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
1420ab18c4c0ac1a46a38aa84c2c8ea485612e21a614Chris Lattner/// The StmtExpr contains a single CompoundStmt node, which it evaluates and
1421ab18c4c0ac1a46a38aa84c2c8ea485612e21a614Chris Lattner/// takes the value of the last subexpression.
1422ab18c4c0ac1a46a38aa84c2c8ea485612e21a614Chris Lattnerclass StmtExpr : public Expr {
14235549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Stmt *SubStmt;
1424ab18c4c0ac1a46a38aa84c2c8ea485612e21a614Chris Lattner  SourceLocation LParenLoc, RParenLoc;
1425ab18c4c0ac1a46a38aa84c2c8ea485612e21a614Chris Lattnerpublic:
1426d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff  StmtExpr(CompoundStmt *substmt, QualType T,
1427d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff           SourceLocation lp, SourceLocation rp) :
1428d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff    Expr(StmtExprClass, T), SubStmt(substmt),  LParenLoc(lp), RParenLoc(rp) { }
1429ab18c4c0ac1a46a38aa84c2c8ea485612e21a614Chris Lattner
14305549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  CompoundStmt *getSubStmt() { return cast<CompoundStmt>(SubStmt); }
14315549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  const CompoundStmt *getSubStmt() const { return cast<CompoundStmt>(SubStmt); }
1432ab18c4c0ac1a46a38aa84c2c8ea485612e21a614Chris Lattner
1433ab18c4c0ac1a46a38aa84c2c8ea485612e21a614Chris Lattner  virtual SourceRange getSourceRange() const {
1434ab18c4c0ac1a46a38aa84c2c8ea485612e21a614Chris Lattner    return SourceRange(LParenLoc, RParenLoc);
1435ab18c4c0ac1a46a38aa84c2c8ea485612e21a614Chris Lattner  }
14365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
1437026dc96ac6ece60da5e1b98e2a71bd0ff0939fd8Chris Lattner  SourceLocation getLParenLoc() const { return LParenLoc; }
1438026dc96ac6ece60da5e1b98e2a71bd0ff0939fd8Chris Lattner  SourceLocation getRParenLoc() const { return RParenLoc; }
1439026dc96ac6ece60da5e1b98e2a71bd0ff0939fd8Chris Lattner
1440ab18c4c0ac1a46a38aa84c2c8ea485612e21a614Chris Lattner  static bool classof(const Stmt *T) {
1441ab18c4c0ac1a46a38aa84c2c8ea485612e21a614Chris Lattner    return T->getStmtClass() == StmtExprClass;
1442ab18c4c0ac1a46a38aa84c2c8ea485612e21a614Chris Lattner  }
1443ab18c4c0ac1a46a38aa84c2c8ea485612e21a614Chris Lattner  static bool classof(const StmtExpr *) { return true; }
14441237c673c07f9d827129ba02720108816abde562Ted Kremenek
14451237c673c07f9d827129ba02720108816abde562Ted Kremenek  // Iterators
14461237c673c07f9d827129ba02720108816abde562Ted Kremenek  virtual child_iterator child_begin();
14471237c673c07f9d827129ba02720108816abde562Ted Kremenek  virtual child_iterator child_end();
1448aa33763cc3dfa2fcb4fdb3c5b4be0c37f8d8f8e9Ted Kremenek
1449ec0aa78745f7b3bc96c20fffd1115bf26aaa0eadTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
1450e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static StmtExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
1451ab18c4c0ac1a46a38aa84c2c8ea485612e21a614Chris Lattner};
1452ab18c4c0ac1a46a38aa84c2c8ea485612e21a614Chris Lattner
1453d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff/// TypesCompatibleExpr - GNU builtin-in function __builtin_type_compatible_p.
1454d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff/// This AST node represents a function that returns 1 if two *types* (not
1455d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff/// expressions) are compatible. The result of this built-in function can be
1456d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff/// used in integer constant expressions.
1457d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroffclass TypesCompatibleExpr : public Expr {
1458d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff  QualType Type1;
1459d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff  QualType Type2;
1460363bcff47df2fda3cfcfcd994b7888157df58c43Steve Naroff  SourceLocation BuiltinLoc, RParenLoc;
1461d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroffpublic:
1462363bcff47df2fda3cfcfcd994b7888157df58c43Steve Naroff  TypesCompatibleExpr(QualType ReturnType, SourceLocation BLoc,
1463d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff                      QualType t1, QualType t2, SourceLocation RP) :
1464d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff    Expr(TypesCompatibleExprClass, ReturnType), Type1(t1), Type2(t2),
1465363bcff47df2fda3cfcfcd994b7888157df58c43Steve Naroff    BuiltinLoc(BLoc), RParenLoc(RP) {}
1466d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff
14677f28fe8e00ec4fac17977374d8da491f873a3b05Steve Naroff  QualType getArgType1() const { return Type1; }
14687f28fe8e00ec4fac17977374d8da491f873a3b05Steve Naroff  QualType getArgType2() const { return Type2; }
1469ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff
1470d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff  virtual SourceRange getSourceRange() const {
1471363bcff47df2fda3cfcfcd994b7888157df58c43Steve Naroff    return SourceRange(BuiltinLoc, RParenLoc);
1472d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff  }
1473d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff  static bool classof(const Stmt *T) {
1474d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff    return T->getStmtClass() == TypesCompatibleExprClass;
1475d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff  }
1476d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff  static bool classof(const TypesCompatibleExpr *) { return true; }
14771237c673c07f9d827129ba02720108816abde562Ted Kremenek
14781237c673c07f9d827129ba02720108816abde562Ted Kremenek  // Iterators
14791237c673c07f9d827129ba02720108816abde562Ted Kremenek  virtual child_iterator child_begin();
14801237c673c07f9d827129ba02720108816abde562Ted Kremenek  virtual child_iterator child_end();
1481d17c24ff8597fe0dee4210639d225bc4f7c5ac04Daniel Dunbar
1482d17c24ff8597fe0dee4210639d225bc4f7c5ac04Daniel Dunbar  virtual void EmitImpl(llvm::Serializer& S) const;
1483d17c24ff8597fe0dee4210639d225bc4f7c5ac04Daniel Dunbar  static TypesCompatibleExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
1484d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff};
1485d34e915f33224c508ad55fbf975bd10b7876e197Steve Naroff
1486d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman/// ShuffleVectorExpr - clang-specific builtin-in function
1487d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman/// __builtin_shufflevector.
1488d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman/// This AST node represents a operator that does a constant
1489d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman/// shuffle, similar to LLVM's shufflevector instruction. It takes
1490d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman/// two vectors and a variable number of constant indices,
1491d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman/// and returns the appropriately shuffled vector.
1492d38617c8a50f9729c254ab76cd359af797c6739bEli Friedmanclass ShuffleVectorExpr : public Expr {
1493d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  SourceLocation BuiltinLoc, RParenLoc;
1494d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman
1495d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  // SubExprs - the list of values passed to the __builtin_shufflevector
1496d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  // function. The first two are vectors, and the rest are constant
1497d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  // indices.  The number of values in this list is always
1498d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  // 2+the number of indices in the vector type.
14995549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Stmt **SubExprs;
1500d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  unsigned NumExprs;
1501d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman
1502d38617c8a50f9729c254ab76cd359af797c6739bEli Friedmanpublic:
1503d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  ShuffleVectorExpr(Expr **args, unsigned nexpr,
1504d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman                    QualType Type, SourceLocation BLoc,
1505d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman                    SourceLocation RP) :
1506d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman    Expr(ShuffleVectorExprClass, Type), BuiltinLoc(BLoc),
1507f809e3bd0c3d063f22ba34981072dae306ca9272Ted Kremenek    RParenLoc(RP), NumExprs(nexpr) {
1508f809e3bd0c3d063f22ba34981072dae306ca9272Ted Kremenek
15095549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek    SubExprs = new Stmt*[nexpr];
1510d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman    for (unsigned i = 0; i < nexpr; i++)
1511d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman      SubExprs[i] = args[i];
1512d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  }
1513d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman
1514d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  virtual SourceRange getSourceRange() const {
1515d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman    return SourceRange(BuiltinLoc, RParenLoc);
1516d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  }
1517d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  static bool classof(const Stmt *T) {
1518d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman    return T->getStmtClass() == ShuffleVectorExprClass;
1519d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  }
1520d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  static bool classof(const ShuffleVectorExpr *) { return true; }
1521d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman
1522d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  ~ShuffleVectorExpr() {
1523d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman    delete [] SubExprs;
1524d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  }
1525d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman
1526d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  /// getNumSubExprs - Return the size of the SubExprs array.  This includes the
1527d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  /// constant expression, the actual arguments passed in, and the function
1528d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  /// pointers.
1529d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  unsigned getNumSubExprs() const { return NumExprs; }
1530d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman
1531d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  /// getExpr - Return the Expr at the specified index.
1532d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  Expr *getExpr(unsigned Index) {
1533d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman    assert((Index < NumExprs) && "Arg access out of range!");
15345549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek    return cast<Expr>(SubExprs[Index]);
1535d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  }
1536d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  const Expr *getExpr(unsigned Index) const {
1537d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman    assert((Index < NumExprs) && "Arg access out of range!");
15385549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek    return cast<Expr>(SubExprs[Index]);
1539d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  }
1540d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman
1541dde8c94873976632e3ada4d8d067e1e244184d51Eli Friedman  unsigned getShuffleMaskIdx(ASTContext &Ctx, unsigned N) {
1542dde8c94873976632e3ada4d8d067e1e244184d51Eli Friedman    assert((N < NumExprs - 2) && "Shuffle idx out of range!");
1543a5d1cb7ef3f0780540e7fd7180399fd220ef0210Daniel Dunbar    return getExpr(N+2)->getIntegerConstantExprValue(Ctx).getZExtValue();
1544d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  }
1545d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman
1546d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  // Iterators
1547d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  virtual child_iterator child_begin();
1548d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman  virtual child_iterator child_end();
1549d17c24ff8597fe0dee4210639d225bc4f7c5ac04Daniel Dunbar
1550d17c24ff8597fe0dee4210639d225bc4f7c5ac04Daniel Dunbar  virtual void EmitImpl(llvm::Serializer& S) const;
1551d17c24ff8597fe0dee4210639d225bc4f7c5ac04Daniel Dunbar  static ShuffleVectorExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
1552d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman};
1553d38617c8a50f9729c254ab76cd359af797c6739bEli Friedman
1554d04fdd5f99f985abf2e7b7d7d4d427eebe001e55Steve Naroff/// ChooseExpr - GNU builtin-in function __builtin_choose_expr.
1555d04fdd5f99f985abf2e7b7d7d4d427eebe001e55Steve Naroff/// This AST node is similar to the conditional operator (?:) in C, with
1556d04fdd5f99f985abf2e7b7d7d4d427eebe001e55Steve Naroff/// the following exceptions:
15577976932a1c256d447316ffac58e9821417725e34Eli Friedman/// - the test expression must be a integer constant expression.
15587976932a1c256d447316ffac58e9821417725e34Eli Friedman/// - the expression returned acts like the chosen subexpression in every
15597976932a1c256d447316ffac58e9821417725e34Eli Friedman///   visible way: the type is the same as that of the chosen subexpression,
15607976932a1c256d447316ffac58e9821417725e34Eli Friedman///   and all predicates (whether it's an l-value, whether it's an integer
15617976932a1c256d447316ffac58e9821417725e34Eli Friedman///   constant expression, etc.) return the same result as for the chosen
15627976932a1c256d447316ffac58e9821417725e34Eli Friedman///   sub-expression.
1563d04fdd5f99f985abf2e7b7d7d4d427eebe001e55Steve Naroffclass ChooseExpr : public Expr {
15641237c673c07f9d827129ba02720108816abde562Ted Kremenek  enum { COND, LHS, RHS, END_EXPR };
15655549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Stmt* SubExprs[END_EXPR]; // Left/Middle/Right hand sides.
1566d04fdd5f99f985abf2e7b7d7d4d427eebe001e55Steve Naroff  SourceLocation BuiltinLoc, RParenLoc;
1567d04fdd5f99f985abf2e7b7d7d4d427eebe001e55Steve Naroffpublic:
1568d04fdd5f99f985abf2e7b7d7d4d427eebe001e55Steve Naroff  ChooseExpr(SourceLocation BLoc, Expr *cond, Expr *lhs, Expr *rhs, QualType t,
1569d04fdd5f99f985abf2e7b7d7d4d427eebe001e55Steve Naroff             SourceLocation RP)
1570d04fdd5f99f985abf2e7b7d7d4d427eebe001e55Steve Naroff    : Expr(ChooseExprClass, t),
15711237c673c07f9d827129ba02720108816abde562Ted Kremenek      BuiltinLoc(BLoc), RParenLoc(RP) {
15721237c673c07f9d827129ba02720108816abde562Ted Kremenek      SubExprs[COND] = cond;
15731237c673c07f9d827129ba02720108816abde562Ted Kremenek      SubExprs[LHS] = lhs;
15741237c673c07f9d827129ba02720108816abde562Ted Kremenek      SubExprs[RHS] = rhs;
15751237c673c07f9d827129ba02720108816abde562Ted Kremenek    }
15767976932a1c256d447316ffac58e9821417725e34Eli Friedman
15777976932a1c256d447316ffac58e9821417725e34Eli Friedman  /// isConditionTrue - Return whether the condition is true (i.e. not
15787976932a1c256d447316ffac58e9821417725e34Eli Friedman  /// equal to zero).
157927437caadea35f84d550cd29f024fcf3ea240eecChris Lattner  bool isConditionTrue(ASTContext &C) const;
15807976932a1c256d447316ffac58e9821417725e34Eli Friedman
15817976932a1c256d447316ffac58e9821417725e34Eli Friedman  /// getChosenSubExpr - Return the subexpression chosen according to the
15827976932a1c256d447316ffac58e9821417725e34Eli Friedman  /// condition.
15837976932a1c256d447316ffac58e9821417725e34Eli Friedman  Expr *getChosenSubExpr(ASTContext &C) const {
15847976932a1c256d447316ffac58e9821417725e34Eli Friedman    return isConditionTrue(C) ? getLHS() : getRHS();
15857976932a1c256d447316ffac58e9821417725e34Eli Friedman  }
15867976932a1c256d447316ffac58e9821417725e34Eli Friedman
15875549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getCond() const { return cast<Expr>(SubExprs[COND]); }
15885549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getLHS() const { return cast<Expr>(SubExprs[LHS]); }
15895549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
15901237c673c07f9d827129ba02720108816abde562Ted Kremenek
1591d04fdd5f99f985abf2e7b7d7d4d427eebe001e55Steve Naroff  virtual SourceRange getSourceRange() const {
1592d04fdd5f99f985abf2e7b7d7d4d427eebe001e55Steve Naroff    return SourceRange(BuiltinLoc, RParenLoc);
1593d04fdd5f99f985abf2e7b7d7d4d427eebe001e55Steve Naroff  }
1594d04fdd5f99f985abf2e7b7d7d4d427eebe001e55Steve Naroff  static bool classof(const Stmt *T) {
1595d04fdd5f99f985abf2e7b7d7d4d427eebe001e55Steve Naroff    return T->getStmtClass() == ChooseExprClass;
1596d04fdd5f99f985abf2e7b7d7d4d427eebe001e55Steve Naroff  }
1597d04fdd5f99f985abf2e7b7d7d4d427eebe001e55Steve Naroff  static bool classof(const ChooseExpr *) { return true; }
15981237c673c07f9d827129ba02720108816abde562Ted Kremenek
15991237c673c07f9d827129ba02720108816abde562Ted Kremenek  // Iterators
16001237c673c07f9d827129ba02720108816abde562Ted Kremenek  virtual child_iterator child_begin();
16011237c673c07f9d827129ba02720108816abde562Ted Kremenek  virtual child_iterator child_end();
1602d17c24ff8597fe0dee4210639d225bc4f7c5ac04Daniel Dunbar
1603d17c24ff8597fe0dee4210639d225bc4f7c5ac04Daniel Dunbar  virtual void EmitImpl(llvm::Serializer& S) const;
1604d17c24ff8597fe0dee4210639d225bc4f7c5ac04Daniel Dunbar  static ChooseExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
1605d04fdd5f99f985abf2e7b7d7d4d427eebe001e55Steve Naroff};
1606d04fdd5f99f985abf2e7b7d7d4d427eebe001e55Steve Naroff
16072d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor/// GNUNullExpr - Implements the GNU __null extension, which is a name
16082d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor/// for a null pointer constant that has integral type (e.g., int or
16092d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor/// long) and is the same size and alignment as a pointer. The __null
16102d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor/// extension is typically only used by system headers, which define
16112d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor/// NULL as __null in C++ rather than using 0 (which is an integer
16122d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor/// that may not match the size of a pointer).
16132d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregorclass GNUNullExpr : public Expr {
16142d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor  /// TokenLoc - The location of the __null keyword.
16152d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor  SourceLocation TokenLoc;
16162d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor
16172d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregorpublic:
16182d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor  GNUNullExpr(QualType Ty, SourceLocation Loc)
16192d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor    : Expr(GNUNullExprClass, Ty), TokenLoc(Loc) { }
16202d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor
16212d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor  /// getTokenLocation - The location of the __null token.
16222d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor  SourceLocation getTokenLocation() const { return TokenLoc; }
16232d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor
16242d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor  virtual SourceRange getSourceRange() const {
16252d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor    return SourceRange(TokenLoc);
16262d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor  }
16272d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor  static bool classof(const Stmt *T) {
16282d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor    return T->getStmtClass() == GNUNullExprClass;
16292d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor  }
16302d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor  static bool classof(const GNUNullExpr *) { return true; }
16312d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor
16322d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor  // Iterators
16332d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor  virtual child_iterator child_begin();
16342d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor  virtual child_iterator child_end();
16352d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor
16362d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor  virtual void EmitImpl(llvm::Serializer& S) const;
16372d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor  static GNUNullExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
16382d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor};
16392d8b273470684a9cd47f0ce24743cc1f71ef7cbcDouglas Gregor
16407c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson/// VAArgExpr, used for the builtin function __builtin_va_start.
16417c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlssonclass VAArgExpr : public Expr {
16425549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Stmt *Val;
16437c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson  SourceLocation BuiltinLoc, RParenLoc;
16447c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlssonpublic:
16457c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson  VAArgExpr(SourceLocation BLoc, Expr* e, QualType t, SourceLocation RPLoc)
16467c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson    : Expr(VAArgExprClass, t),
16477c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson      Val(e),
16487c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson      BuiltinLoc(BLoc),
16497c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson      RParenLoc(RPLoc) { }
16507c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson
16515549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  const Expr *getSubExpr() const { return cast<Expr>(Val); }
16525549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getSubExpr() { return cast<Expr>(Val); }
16537c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson  virtual SourceRange getSourceRange() const {
16547c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson    return SourceRange(BuiltinLoc, RParenLoc);
16557c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson  }
16567c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson  static bool classof(const Stmt *T) {
16577c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson    return T->getStmtClass() == VAArgExprClass;
16587c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson  }
16597c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson  static bool classof(const VAArgExpr *) { return true; }
16607c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson
16617c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson  // Iterators
16627c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson  virtual child_iterator child_begin();
16637c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson  virtual child_iterator child_end();
1664d17c24ff8597fe0dee4210639d225bc4f7c5ac04Daniel Dunbar
1665d17c24ff8597fe0dee4210639d225bc4f7c5ac04Daniel Dunbar  virtual void EmitImpl(llvm::Serializer& S) const;
1666d17c24ff8597fe0dee4210639d225bc4f7c5ac04Daniel Dunbar  static VAArgExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
16677c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson};
16687c50aca2fe36f6daa9bf1c8c428f30e72f96470aAnders Carlsson
16694c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// @brief Describes an C or C++ initializer list.
16704c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor///
16714c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// InitListExpr describes an initializer list, which can be used to
16724c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// initialize objects of different types, including
16734c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// struct/class/union types, arrays, and vectors. For example:
16744c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor///
16754c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// @code
16764c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// struct foo x = { 1, { 2, 3 } };
16774c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// @endcode
1678196ef51bc4d008ec1c69851fb3b0f8d036065931Chris Lattner///
16794c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// Prior to semantic analysis, an initializer list will represent the
16804c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// initializer list as written by the user, but will have the
16814c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// placeholder type "void". This initializer list is called the
16824c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// syntactic form of the initializer, and may contain C99 designated
16834c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// initializers (represented as DesignatedInitExprs), initializations
16844c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// of subobject members without explicit braces, and so on. Clients
16854c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// interested in the original syntax of the initializer list should
16864c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// use the syntactic form of the initializer list.
1687196ef51bc4d008ec1c69851fb3b0f8d036065931Chris Lattner///
16884c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// After semantic analysis, the initializer list will represent the
16894c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// semantic form of the initializer, where the initializations of all
16904c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// subobjects are made explicit with nested InitListExpr nodes and
16914c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// C99 designators have been eliminated by placing the designated
16924c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// initializations into the subobject they initialize. Additionally,
16934c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// any "holes" in the initialization, where no initializer has been
16944c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// specified for a particular subobject, will be replaced with
16953498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor/// implicitly-generated ImplicitValueInitExpr expressions that
16964c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// value-initialize the subobjects. Note, however, that the
16974c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// initializer lists may still have fewer initializers than there are
16984c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// elements to initialize within the object.
1699196ef51bc4d008ec1c69851fb3b0f8d036065931Chris Lattner///
17004c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// Given the semantic form of the initializer list, one can retrieve
17014c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// the original syntactic form of that initializer list (if it
17024c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// exists) using getSyntacticForm(). Since many initializer lists
17034c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// have the same syntactic and semantic forms, getSyntacticForm() may
17044c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// return NULL, indicating that the current initializer list also
17054c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor/// serves as its syntactic form.
170666b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlssonclass InitListExpr : public Expr {
17075549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  std::vector<Stmt *> InitExprs;
170866b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson  SourceLocation LBraceLoc, RBraceLoc;
1709418f6c7d142e5ff4607f70cd8431d008442bafe9Chris Lattner
17104c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// Contains the initializer list that describes the syntactic form
17114c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// written in the source code.
17124c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  InitListExpr *SyntacticForm;
17134c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor
17140bb76897bedb8b747efc6523efb432fc24966118Douglas Gregor  /// If this initializer list initializes a union, specifies which
17150bb76897bedb8b747efc6523efb432fc24966118Douglas Gregor  /// field within the union will be initialized.
17160bb76897bedb8b747efc6523efb432fc24966118Douglas Gregor  FieldDecl *UnionFieldInit;
17170bb76897bedb8b747efc6523efb432fc24966118Douglas Gregor
1718a9c878086036de36482cc21e35a33cabe9699b0aDouglas Gregor  /// Whether this initializer list originally had a GNU array-range
1719a9c878086036de36482cc21e35a33cabe9699b0aDouglas Gregor  /// designator in it. This is a temporary marker used by CodeGen.
1720a9c878086036de36482cc21e35a33cabe9699b0aDouglas Gregor  bool HadArrayRangeDesignator;
1721a9c878086036de36482cc21e35a33cabe9699b0aDouglas Gregor
172266b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlssonpublic:
172366b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson  InitListExpr(SourceLocation lbraceloc, Expr **initexprs, unsigned numinits,
17244c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor               SourceLocation rbraceloc);
172566b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson
1726c5ae899b4bbf65488445316c63168079177db0edSteve Naroff  unsigned getNumInits() const { return InitExprs.size(); }
172766b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson
172866b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson  const Expr* getInit(unsigned Init) const {
1729c5ae899b4bbf65488445316c63168079177db0edSteve Naroff    assert(Init < getNumInits() && "Initializer access out of range!");
17304c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor    return cast_or_null<Expr>(InitExprs[Init]);
173166b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson  }
173266b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson
173366b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson  Expr* getInit(unsigned Init) {
1734c5ae899b4bbf65488445316c63168079177db0edSteve Naroff    assert(Init < getNumInits() && "Initializer access out of range!");
17354c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor    return cast_or_null<Expr>(InitExprs[Init]);
173666b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson  }
173766b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson
17389e8925e72f53a9e2c4633b6b48e965ed01702fe4Steve Naroff  void setInit(unsigned Init, Expr *expr) {
1739c5ae899b4bbf65488445316c63168079177db0edSteve Naroff    assert(Init < getNumInits() && "Initializer access out of range!");
17409e8925e72f53a9e2c4633b6b48e965ed01702fe4Steve Naroff    InitExprs[Init] = expr;
17419e8925e72f53a9e2c4633b6b48e965ed01702fe4Steve Naroff  }
1742c5ae899b4bbf65488445316c63168079177db0edSteve Naroff
17434c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// @brief Specify the number of initializers
17444c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  ///
17454c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// If there are more than @p NumInits initializers, the remaining
17464c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// initializers will be destroyed. If there are fewer than @p
17474c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// NumInits initializers, NULL expressions will be added for the
17484c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// unknown initializers.
17494c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  void resizeInits(ASTContext &Context, unsigned NumInits);
17504c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor
17514c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// @brief Updates the initializer at index @p Init with the new
17524c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// expression @p expr, and returns the old expression at that
17534c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// location.
17544c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  ///
17554c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// When @p Init is out of range for this initializer list, the
17564c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// initializer list will be extended with NULL expressions to
17574c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// accomodate the new entry.
17584c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  Expr *updateInit(unsigned Init, Expr *expr);
1759c5ae899b4bbf65488445316c63168079177db0edSteve Naroff
17600bb76897bedb8b747efc6523efb432fc24966118Douglas Gregor  /// \brief If this initializes a union, specifies which field in the
17610bb76897bedb8b747efc6523efb432fc24966118Douglas Gregor  /// union to initialize.
17620bb76897bedb8b747efc6523efb432fc24966118Douglas Gregor  ///
17630bb76897bedb8b747efc6523efb432fc24966118Douglas Gregor  /// Typically, this field is the first named field within the
17640bb76897bedb8b747efc6523efb432fc24966118Douglas Gregor  /// union. However, a designated initializer can specify the
17650bb76897bedb8b747efc6523efb432fc24966118Douglas Gregor  /// initialization of a different field within the union.
17660bb76897bedb8b747efc6523efb432fc24966118Douglas Gregor  FieldDecl *getInitializedFieldInUnion() { return UnionFieldInit; }
17670bb76897bedb8b747efc6523efb432fc24966118Douglas Gregor  void setInitializedFieldInUnion(FieldDecl *FD) { UnionFieldInit = FD; }
17680bb76897bedb8b747efc6523efb432fc24966118Douglas Gregor
1769c5ae899b4bbf65488445316c63168079177db0edSteve Naroff  // Explicit InitListExpr's originate from source code (and have valid source
1770c5ae899b4bbf65488445316c63168079177db0edSteve Naroff  // locations). Implicit InitListExpr's are created by the semantic analyzer.
1771b3eef68111ffc220e449be96da1747998c057790Douglas Gregor  bool isExplicit() {
1772b3eef68111ffc220e449be96da1747998c057790Douglas Gregor    return LBraceLoc.isValid() && RBraceLoc.isValid();
1773b3eef68111ffc220e449be96da1747998c057790Douglas Gregor  }
17749e8925e72f53a9e2c4633b6b48e965ed01702fe4Steve Naroff
177587fd703e097c27d63479cb83b687d4000a22bbb1Douglas Gregor  void setRBraceLoc(SourceLocation Loc) { RBraceLoc = Loc; }
177687fd703e097c27d63479cb83b687d4000a22bbb1Douglas Gregor
17774c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// @brief Retrieve the initializer list that describes the
17784c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// syntactic form of the initializer.
17794c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  ///
17804c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  ///
17814c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  InitListExpr *getSyntacticForm() const { return SyntacticForm; }
17824c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  void setSyntacticForm(InitListExpr *Init) { SyntacticForm = Init; }
17834c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor
1784a9c878086036de36482cc21e35a33cabe9699b0aDouglas Gregor  bool hadArrayRangeDesignator() const { return HadArrayRangeDesignator; }
1785a9c878086036de36482cc21e35a33cabe9699b0aDouglas Gregor  void sawArrayRangeDesignator() {
1786a9c878086036de36482cc21e35a33cabe9699b0aDouglas Gregor    HadArrayRangeDesignator = true;
1787a9c878086036de36482cc21e35a33cabe9699b0aDouglas Gregor  }
1788a9c878086036de36482cc21e35a33cabe9699b0aDouglas Gregor
178966b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson  virtual SourceRange getSourceRange() const {
179066b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson    return SourceRange(LBraceLoc, RBraceLoc);
179166b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson  }
179266b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson  static bool classof(const Stmt *T) {
179366b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson    return T->getStmtClass() == InitListExprClass;
179466b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson  }
179566b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson  static bool classof(const InitListExpr *) { return true; }
179666b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson
179766b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson  // Iterators
179866b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson  virtual child_iterator child_begin();
179966b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson  virtual child_iterator child_end();
18006336f8dbae5145eb7b1429a8ec424c44e668f7cbTed Kremenek
18017fcfa4a9b5054bc2a3bc65093f9d2e9e67a70838Ted Kremenek  typedef std::vector<Stmt *>::iterator iterator;
18027fcfa4a9b5054bc2a3bc65093f9d2e9e67a70838Ted Kremenek  typedef std::vector<Stmt *>::reverse_iterator reverse_iterator;
18037fcfa4a9b5054bc2a3bc65093f9d2e9e67a70838Ted Kremenek
18047fcfa4a9b5054bc2a3bc65093f9d2e9e67a70838Ted Kremenek  iterator begin() { return InitExprs.begin(); }
18057fcfa4a9b5054bc2a3bc65093f9d2e9e67a70838Ted Kremenek  iterator end() { return InitExprs.end(); }
18067fcfa4a9b5054bc2a3bc65093f9d2e9e67a70838Ted Kremenek  reverse_iterator rbegin() { return InitExprs.rbegin(); }
18077fcfa4a9b5054bc2a3bc65093f9d2e9e67a70838Ted Kremenek  reverse_iterator rend() { return InitExprs.rend(); }
18087fcfa4a9b5054bc2a3bc65093f9d2e9e67a70838Ted Kremenek
18097fcfa4a9b5054bc2a3bc65093f9d2e9e67a70838Ted Kremenek  // Serailization.
18106336f8dbae5145eb7b1429a8ec424c44e668f7cbTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
1811e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop  static InitListExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
18126336f8dbae5145eb7b1429a8ec424c44e668f7cbTed Kremenek
18136336f8dbae5145eb7b1429a8ec424c44e668f7cbTed Kremenekprivate:
18146336f8dbae5145eb7b1429a8ec424c44e668f7cbTed Kremenek  // Used by serializer.
181528a309e387a0a69b0c055c1565aa147fc695f906Chris Lattner  InitListExpr() : Expr(InitListExprClass, QualType()) {}
181666b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson};
181766b5a8a39088598c01a9fa6f032dc908612dc8ecAnders Carlsson
181805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor/// @brief Represents a C99 designated initializer expression.
181905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor///
182005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor/// A designated initializer expression (C99 6.7.8) contains one or
182105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor/// more designators (which can be field designators, array
182205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor/// designators, or GNU array-range designators) followed by an
182305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor/// expression that initializes the field or element(s) that the
182405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor/// designators refer to. For example, given:
182505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor///
182605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor/// @code
182705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor/// struct point {
182805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor///   double x;
182905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor///   double y;
183005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor/// };
183105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor/// struct point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 };
183205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor/// @endcode
183305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor///
183405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor/// The InitListExpr contains three DesignatedInitExprs, the first of
183505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor/// which covers @c [2].y=1.0. This DesignatedInitExpr will have two
183605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor/// designators, one array designator for @c [2] followed by one field
183705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor/// designator for @c .y. The initalization expression will be 1.0.
183805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregorclass DesignatedInitExpr : public Expr {
183905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// The location of the '=' or ':' prior to the actual initializer
184005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// expression.
184105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  SourceLocation EqualOrColonLoc;
184205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
184305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// Whether this designated initializer used the GNU deprecated ':'
184405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// syntax rather than the C99 '=' syntax.
184505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  bool UsesColonSyntax : 1;
184605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
184705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// The number of designators in this initializer expression.
184805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  unsigned NumDesignators : 15;
184905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
185005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// The number of subexpressions of this initializer expression,
185105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// which contains both the initializer and any additional
185205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// expressions used by array and array-range designators.
185305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  unsigned NumSubExprs : 16;
185405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
185505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  DesignatedInitExpr(QualType Ty, unsigned NumDesignators,
185605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor                     SourceLocation EqualOrColonLoc, bool UsesColonSyntax,
185705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor                     unsigned NumSubExprs)
185805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    : Expr(DesignatedInitExprClass, Ty),
185905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      EqualOrColonLoc(EqualOrColonLoc), UsesColonSyntax(UsesColonSyntax),
186005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      NumDesignators(NumDesignators), NumSubExprs(NumSubExprs) { }
186105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
186205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregorpublic:
186305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// A field designator, e.g., ".x".
186405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  struct FieldDesignator {
186505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    /// Refers to the field that is being initialized. The low bit
186605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    /// of this field determines whether this is actually a pointer
186705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    /// to an IdentifierInfo (if 1) or a FieldDecl (if 0). When
186805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    /// initially constructed, a field designator will store an
186905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    /// IdentifierInfo*. After semantic analysis has resolved that
187005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    /// name, the field designator will instead store a FieldDecl*.
187105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    uintptr_t NameOrField;
187205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
187305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    /// The location of the '.' in the designated initializer.
187405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    unsigned DotLoc;
187505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
187605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    /// The location of the field name in the designated initializer.
187705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    unsigned FieldLoc;
187805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  };
187905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
188005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// An array or GNU array-range designator, e.g., "[9]" or "[10..15]".
188105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  struct ArrayOrRangeDesignator {
188205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    /// Location of the first index expression within the designated
188305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    /// initializer expression's list of subexpressions.
188405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    unsigned Index;
188505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    /// The location of the '[' starting the array range designator.
188605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    unsigned LBracketLoc;
188705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    /// The location of the ellipsis separating the start and end
188805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    /// indices. Only valid for GNU array-range designators.
188905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    unsigned EllipsisLoc;
189005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    /// The location of the ']' terminating the array range designator.
189105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    unsigned RBracketLoc;
189205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  };
189305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
189405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// @brief Represents a single C99 designator.
189505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  ///
189605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// @todo This class is infuriatingly similar to clang::Designator,
189705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// but minor differences (storing indices vs. storing pointers)
189805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// keep us from reusing it. Try harder, later, to rectify these
189905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// differences.
190005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  class Designator {
190105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    /// @brief The kind of designator this describes.
190205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    enum {
190305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      FieldDesignator,
190405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      ArrayDesignator,
190505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      ArrayRangeDesignator
190605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    } Kind;
190705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
190805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    union {
190905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      /// A field designator, e.g., ".x".
191005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      struct FieldDesignator Field;
191105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      /// An array or GNU array-range designator, e.g., "[9]" or "[10..15]".
191205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      struct ArrayOrRangeDesignator ArrayOrRange;
191305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    };
191405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    friend class DesignatedInitExpr;
191505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
191605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  public:
191705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    /// @brief Initializes a field designator.
191805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    Designator(const IdentifierInfo *FieldName, SourceLocation DotLoc,
191905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor               SourceLocation FieldLoc)
192005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      : Kind(FieldDesignator) {
192105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      Field.NameOrField = reinterpret_cast<uintptr_t>(FieldName) | 0x01;
192205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      Field.DotLoc = DotLoc.getRawEncoding();
192305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      Field.FieldLoc = FieldLoc.getRawEncoding();
192405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    }
192505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
192605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    /// @brief Initializes an array designator.
192705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    Designator(unsigned Index, SourceLocation LBracketLoc,
192805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor               SourceLocation RBracketLoc)
192905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      : Kind(ArrayDesignator) {
193005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      ArrayOrRange.Index = Index;
193105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      ArrayOrRange.LBracketLoc = LBracketLoc.getRawEncoding();
193205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      ArrayOrRange.EllipsisLoc = SourceLocation().getRawEncoding();
193305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      ArrayOrRange.RBracketLoc = RBracketLoc.getRawEncoding();
193405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    }
193505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
193605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    /// @brief Initializes a GNU array-range designator.
193705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    Designator(unsigned Index, SourceLocation LBracketLoc,
193805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor               SourceLocation EllipsisLoc, SourceLocation RBracketLoc)
193905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      : Kind(ArrayRangeDesignator) {
194005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      ArrayOrRange.Index = Index;
194105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      ArrayOrRange.LBracketLoc = LBracketLoc.getRawEncoding();
194205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      ArrayOrRange.EllipsisLoc = EllipsisLoc.getRawEncoding();
194305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      ArrayOrRange.RBracketLoc = RBracketLoc.getRawEncoding();
194405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    }
194505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
194605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    bool isFieldDesignator() const { return Kind == FieldDesignator; }
194705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    bool isArrayDesignator() const { return Kind == ArrayDesignator; }
194805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    bool isArrayRangeDesignator() const { return Kind == ArrayRangeDesignator; }
194905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
195005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    IdentifierInfo * getFieldName();
195105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
195205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    FieldDecl *getField() {
195305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      assert(Kind == FieldDesignator && "Only valid on a field designator");
195405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      if (Field.NameOrField & 0x01)
195505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor        return 0;
195605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      else
195705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor        return reinterpret_cast<FieldDecl *>(Field.NameOrField);
195805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    }
195905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
196005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    void setField(FieldDecl *FD) {
196105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      assert(Kind == FieldDesignator && "Only valid on a field designator");
196205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      Field.NameOrField = reinterpret_cast<uintptr_t>(FD);
196305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    }
196405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
196587f55cf59e82f246d8605733e9300d0c5f6830a6Douglas Gregor    SourceLocation getDotLoc() const {
196687f55cf59e82f246d8605733e9300d0c5f6830a6Douglas Gregor      assert(Kind == FieldDesignator && "Only valid on a field designator");
196787f55cf59e82f246d8605733e9300d0c5f6830a6Douglas Gregor      return SourceLocation::getFromRawEncoding(Field.DotLoc);
196887f55cf59e82f246d8605733e9300d0c5f6830a6Douglas Gregor    }
196987f55cf59e82f246d8605733e9300d0c5f6830a6Douglas Gregor
197005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    SourceLocation getFieldLoc() const {
197105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      assert(Kind == FieldDesignator && "Only valid on a field designator");
197205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      return SourceLocation::getFromRawEncoding(Field.FieldLoc);
197305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    }
197405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
197505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    SourceLocation getLBracketLoc() const {
197605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      assert((Kind == ArrayDesignator || Kind == ArrayRangeDesignator) &&
197705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor             "Only valid on an array or array-range designator");
197805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      return SourceLocation::getFromRawEncoding(ArrayOrRange.LBracketLoc);
197905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    }
198005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
198105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    SourceLocation getRBracketLoc() const {
198205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      assert((Kind == ArrayDesignator || Kind == ArrayRangeDesignator) &&
198305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor             "Only valid on an array or array-range designator");
198405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      return SourceLocation::getFromRawEncoding(ArrayOrRange.RBracketLoc);
198505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    }
198605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
198705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    SourceLocation getEllipsisLoc() const {
198805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      assert(Kind == ArrayRangeDesignator &&
198905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor             "Only valid on an array-range designator");
199005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor      return SourceLocation::getFromRawEncoding(ArrayOrRange.EllipsisLoc);
199105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    }
19924c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor
19934c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor    SourceLocation getStartLocation() const {
19944c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor      if (Kind == FieldDesignator)
19954c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor        return getDotLoc().isInvalid()? getFieldLoc() : getDotLoc();
19964c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor      else
19974c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor        return getLBracketLoc();
19984c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor    }
199905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  };
200005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
200105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  static DesignatedInitExpr *Create(ASTContext &C, Designator *Designators,
200205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor                                    unsigned NumDesignators,
200305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor                                    Expr **IndexExprs, unsigned NumIndexExprs,
200405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor                                    SourceLocation EqualOrColonLoc,
200505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor                                    bool UsesColonSyntax, Expr *Init);
200605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
200705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// @brief Returns the number of designators in this initializer.
200805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  unsigned size() const { return NumDesignators; }
200905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
201005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  // Iterator access to the designators.
201105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  typedef Designator* designators_iterator;
201205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  designators_iterator designators_begin();
201305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  designators_iterator designators_end();
201405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
201505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  Expr *getArrayIndex(const Designator& D);
201605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  Expr *getArrayRangeStart(const Designator& D);
201705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  Expr *getArrayRangeEnd(const Designator& D);
201805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
201905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// @brief Retrieve the location of the '=' that precedes the
202005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// initializer value itself, if present.
202105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  SourceLocation getEqualOrColonLoc() const { return EqualOrColonLoc; }
202205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
202305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// @brief Determines whether this designated initializer used the
202405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// GNU 'fieldname:' syntax or the C99 '=' syntax.
202505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  bool usesColonSyntax() const { return UsesColonSyntax; }
202605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
202705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  /// @brief Retrieve the initializer value.
202805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  Expr *getInit() const {
202905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    return cast<Expr>(*const_cast<DesignatedInitExpr*>(this)->child_begin());
203005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  }
203105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
203205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  void setInit(Expr *init) {
203305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    *child_begin() = init;
203405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  }
203505c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
203605c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  virtual SourceRange getSourceRange() const;
203705c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
203805c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  static bool classof(const Stmt *T) {
203905c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor    return T->getStmtClass() == DesignatedInitExprClass;
204005c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  }
204105c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  static bool classof(const DesignatedInitExpr *) { return true; }
204205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
204305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  // Iterators
204405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  virtual child_iterator child_begin();
20453498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor  virtual child_iterator child_end();
20463498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor};
20473498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor
20483498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor/// \brief Represents an implicitly-generated value initialization of
20493498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor/// an object of a given type.
20503498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor///
20511a51b4a11b7db25cac2134249711ecaaf9d1c0a8Douglas Gregor/// Implicit value initializations occur within semantic initializer
20521a51b4a11b7db25cac2134249711ecaaf9d1c0a8Douglas Gregor/// list expressions (InitListExpr) as placeholders for subobject
20533498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor/// initializations not explicitly specified by the user.
20541a51b4a11b7db25cac2134249711ecaaf9d1c0a8Douglas Gregor///
20551a51b4a11b7db25cac2134249711ecaaf9d1c0a8Douglas Gregor/// \see InitListExpr
20563498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregorclass ImplicitValueInitExpr : public Expr {
20573498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregorpublic:
20583498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor  explicit ImplicitValueInitExpr(QualType ty)
20593498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor    : Expr(ImplicitValueInitExprClass, ty) { }
20603498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor
20613498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor  static bool classof(const Stmt *T) {
20623498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor    return T->getStmtClass() == ImplicitValueInitExprClass;
20633498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor  }
20643498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor  static bool classof(const ImplicitValueInitExpr *) { return true; }
20653498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor
20663498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor  virtual SourceRange getSourceRange() const {
20673498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor    return SourceRange();
20683498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor  }
20693498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor
20703498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor  // Iterators
20713498bdb9e9cb300de74c7b51c92608e2902b2348Douglas Gregor  virtual child_iterator child_begin();
207205c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor  virtual child_iterator child_end();
207305c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor};
207405c13a3411782108d65aab3c77b1a231a4963bc0Douglas Gregor
20754eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff//===----------------------------------------------------------------------===//
20764eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff// Clang Extensions
20774eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff//===----------------------------------------------------------------------===//
20784eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff
2079a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner
2080a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner/// ExtVectorElementExpr - This represents access to specific elements of a
2081a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner/// vector, and may occur on the left hand side or right hand side.  For example
2082a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner/// the following is legal:  "V.xy = V.zw" if V is a 4 element extended vector.
2083a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner///
208473525de7fd9bdd534382dc89a24f1f76db3e04b9Chris Lattner/// Note that the base may have either vector or pointer to vector type, just
208573525de7fd9bdd534382dc89a24f1f76db3e04b9Chris Lattner/// like a struct field reference.
208673525de7fd9bdd534382dc89a24f1f76db3e04b9Chris Lattner///
2087a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattnerclass ExtVectorElementExpr : public Expr {
2088a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  Stmt *Base;
2089a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  IdentifierInfo &Accessor;
2090a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  SourceLocation AccessorLoc;
2091a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattnerpublic:
2092a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  ExtVectorElementExpr(QualType ty, Expr *base, IdentifierInfo &accessor,
2093a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner                       SourceLocation loc)
2094a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner    : Expr(ExtVectorElementExprClass, ty),
2095a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner      Base(base), Accessor(accessor), AccessorLoc(loc) {}
2096a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner
2097a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  const Expr *getBase() const { return cast<Expr>(Base); }
2098a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  Expr *getBase() { return cast<Expr>(Base); }
2099a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner
2100a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  IdentifierInfo &getAccessor() const { return Accessor; }
2101a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner
2102a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  /// getNumElements - Get the number of components being selected.
2103a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  unsigned getNumElements() const;
2104a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner
2105a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  /// containsDuplicateElements - Return true if any element access is
2106a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  /// repeated.
2107a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  bool containsDuplicateElements() const;
2108a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner
2109a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  /// getEncodedElementAccess - Encode the elements accessed into an llvm
2110a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  /// aggregate Constant of ConstantInt(s).
2111a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  void getEncodedElementAccess(llvm::SmallVectorImpl<unsigned> &Elts) const;
2112a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner
2113a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  virtual SourceRange getSourceRange() const {
2114a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner    return SourceRange(getBase()->getLocStart(), AccessorLoc);
2115a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  }
2116a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner
21172140e904dbe53657339cb5b1cc13de563ca0d1fcChris Lattner  /// isArrow - Return true if the base expression is a pointer to vector,
21182140e904dbe53657339cb5b1cc13de563ca0d1fcChris Lattner  /// return false if the base expression is a vector.
21192140e904dbe53657339cb5b1cc13de563ca0d1fcChris Lattner  bool isArrow() const;
21202140e904dbe53657339cb5b1cc13de563ca0d1fcChris Lattner
2121a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  static bool classof(const Stmt *T) {
2122a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner    return T->getStmtClass() == ExtVectorElementExprClass;
2123a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  }
2124a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  static bool classof(const ExtVectorElementExpr *) { return true; }
2125a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner
2126a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  // Iterators
2127a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  virtual child_iterator child_begin();
2128a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner  virtual child_iterator child_end();
2129d17c24ff8597fe0dee4210639d225bc4f7c5ac04Daniel Dunbar
2130d17c24ff8597fe0dee4210639d225bc4f7c5ac04Daniel Dunbar  virtual void EmitImpl(llvm::Serializer& S) const;
2131d17c24ff8597fe0dee4210639d225bc4f7c5ac04Daniel Dunbar  static ExtVectorElementExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
2132a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner};
2133a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner
2134a09f585a7fdbb01b4bf9de3679fd37005379ca66Chris Lattner
213556ee6896f2efebffb4a2cce5a7610cdf1eddbbbeSteve Naroff/// BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
21369c3c902835ef7d37300463ad47176ec21a67dc8bSteve Naroff/// ^{ statement-body }   or   ^(int arg1, float arg2){ statement-body }
21374eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroffclass BlockExpr : public Expr {
213856ee6896f2efebffb4a2cce5a7610cdf1eddbbbeSteve Naroffprotected:
213956ee6896f2efebffb4a2cce5a7610cdf1eddbbbeSteve Naroff  BlockDecl *TheBlock;
2140b83d287bc7f47d36fb0751a481e2ef9308b37252Mike Stump  bool HasBlockDeclRefExprs;
21414eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroffpublic:
2142b83d287bc7f47d36fb0751a481e2ef9308b37252Mike Stump  BlockExpr(BlockDecl *BD, QualType ty, bool hasBlockDeclRefExprs)
2143b83d287bc7f47d36fb0751a481e2ef9308b37252Mike Stump    : Expr(BlockExprClass, ty),
2144b83d287bc7f47d36fb0751a481e2ef9308b37252Mike Stump      TheBlock(BD), HasBlockDeclRefExprs(hasBlockDeclRefExprs) {}
21459c3c902835ef7d37300463ad47176ec21a67dc8bSteve Naroff
2146d5cab5435371b8cc74a9e05ebd40b5995ebad149Anders Carlsson  const BlockDecl *getBlockDecl() const { return TheBlock; }
214756ee6896f2efebffb4a2cce5a7610cdf1eddbbbeSteve Naroff  BlockDecl *getBlockDecl() { return TheBlock; }
214856ee6896f2efebffb4a2cce5a7610cdf1eddbbbeSteve Naroff
214956ee6896f2efebffb4a2cce5a7610cdf1eddbbbeSteve Naroff  // Convenience functions for probing the underlying BlockDecl.
215056ee6896f2efebffb4a2cce5a7610cdf1eddbbbeSteve Naroff  SourceLocation getCaretLocation() const;
215156ee6896f2efebffb4a2cce5a7610cdf1eddbbbeSteve Naroff  const Stmt *getBody() const;
215256ee6896f2efebffb4a2cce5a7610cdf1eddbbbeSteve Naroff  Stmt *getBody();
21539c3c902835ef7d37300463ad47176ec21a67dc8bSteve Naroff
21549c3c902835ef7d37300463ad47176ec21a67dc8bSteve Naroff  virtual SourceRange getSourceRange() const {
215556ee6896f2efebffb4a2cce5a7610cdf1eddbbbeSteve Naroff    return SourceRange(getCaretLocation(), getBody()->getLocEnd());
21569c3c902835ef7d37300463ad47176ec21a67dc8bSteve Naroff  }
21579c3c902835ef7d37300463ad47176ec21a67dc8bSteve Naroff
215856ee6896f2efebffb4a2cce5a7610cdf1eddbbbeSteve Naroff  /// getFunctionType - Return the underlying function type for this block.
215956ee6896f2efebffb4a2cce5a7610cdf1eddbbbeSteve Naroff  const FunctionType *getFunctionType() const;
216056ee6896f2efebffb4a2cce5a7610cdf1eddbbbeSteve Naroff
2161b83d287bc7f47d36fb0751a481e2ef9308b37252Mike Stump  /// hasBlockDeclRefExprs - Return true iff the block has BlockDeclRefExpr
2162b83d287bc7f47d36fb0751a481e2ef9308b37252Mike Stump  /// contained inside.
2163b83d287bc7f47d36fb0751a481e2ef9308b37252Mike Stump  bool hasBlockDeclRefExprs() const { return HasBlockDeclRefExprs; }
2164b83d287bc7f47d36fb0751a481e2ef9308b37252Mike Stump
21654eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  static bool classof(const Stmt *T) {
21669c3c902835ef7d37300463ad47176ec21a67dc8bSteve Naroff    return T->getStmtClass() == BlockExprClass;
21674eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  }
21684eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  static bool classof(const BlockExpr *) { return true; }
21694eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff
21704eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  // Iterators
21714eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  virtual child_iterator child_begin();
21724eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  virtual child_iterator child_end();
217356ee6896f2efebffb4a2cce5a7610cdf1eddbbbeSteve Naroff
21744eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  virtual void EmitImpl(llvm::Serializer& S) const;
21759c3c902835ef7d37300463ad47176ec21a67dc8bSteve Naroff  static BlockExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
21764eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff};
21779c3c902835ef7d37300463ad47176ec21a67dc8bSteve Naroff
21784eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff/// BlockDeclRefExpr - A reference to a declared variable, function,
21794eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff/// enum, etc.
21804eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroffclass BlockDeclRefExpr : public Expr {
21814eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  ValueDecl *D;
21824eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  SourceLocation Loc;
21834eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  bool IsByRef;
21844eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroffpublic:
21854eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  BlockDeclRefExpr(ValueDecl *d, QualType t, SourceLocation l, bool ByRef) :
21864eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff       Expr(BlockDeclRefExprClass, t), D(d), Loc(l), IsByRef(ByRef) {}
21874eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff
21884eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  ValueDecl *getDecl() { return D; }
21894eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  const ValueDecl *getDecl() const { return D; }
21904eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
21914eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff
21924eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  bool isByRef() const { return IsByRef; }
21934eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff
21944eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  static bool classof(const Stmt *T) {
21954eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff    return T->getStmtClass() == BlockDeclRefExprClass;
21964eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  }
21974eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  static bool classof(const BlockDeclRefExpr *) { return true; }
21984eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff
21994eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  // Iterators
22004eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  virtual child_iterator child_begin();
22014eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  virtual child_iterator child_end();
22024eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff
22034eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  virtual void EmitImpl(llvm::Serializer& S) const;
22044eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff  static BlockDeclRefExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
22054eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff};
22064eb206bebcdab28ababe8df55c6185cec2cdc071Steve Naroff
22075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}  // end namespace clang
22085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
22095f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif
2210