ExprCXX.h revision 7cb6bd70f9436f630a508ba017414ca2466eeb35
1//===--- ExprCXX.h - Classes for representing expressions -------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10//  This file defines the Expr interface and subclasses for C++ expressions.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_AST_EXPRCXX_H
15#define LLVM_CLANG_AST_EXPRCXX_H
16
17#include "clang/Basic/TypeTraits.h"
18#include "clang/AST/Expr.h"
19#include "clang/AST/UnresolvedSet.h"
20#include "clang/AST/TemplateBase.h"
21
22namespace clang {
23
24  class CXXConstructorDecl;
25  class CXXDestructorDecl;
26  class CXXMethodDecl;
27  class CXXTemporary;
28  class TemplateArgumentListInfo;
29
30//===--------------------------------------------------------------------===//
31// C++ Expressions.
32//===--------------------------------------------------------------------===//
33
34/// \brief A call to an overloaded operator written using operator
35/// syntax.
36///
37/// Represents a call to an overloaded operator written using operator
38/// syntax, e.g., "x + y" or "*p". While semantically equivalent to a
39/// normal call, this AST node provides better information about the
40/// syntactic representation of the call.
41///
42/// In a C++ template, this expression node kind will be used whenever
43/// any of the arguments are type-dependent. In this case, the
44/// function itself will be a (possibly empty) set of functions and
45/// function templates that were found by name lookup at template
46/// definition time.
47class CXXOperatorCallExpr : public CallExpr {
48  /// \brief The overloaded operator.
49  OverloadedOperatorKind Operator;
50
51public:
52  CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn,
53                      Expr **args, unsigned numargs, QualType t,
54                      SourceLocation operatorloc)
55    : CallExpr(C, CXXOperatorCallExprClass, fn, args, numargs, t, operatorloc),
56      Operator(Op) {}
57  explicit CXXOperatorCallExpr(ASTContext& C, EmptyShell Empty) :
58    CallExpr(C, CXXOperatorCallExprClass, Empty) { }
59
60
61  /// getOperator - Returns the kind of overloaded operator that this
62  /// expression refers to.
63  OverloadedOperatorKind getOperator() const { return Operator; }
64  void setOperator(OverloadedOperatorKind Kind) { Operator = Kind; }
65
66  /// getOperatorLoc - Returns the location of the operator symbol in
67  /// the expression. When @c getOperator()==OO_Call, this is the
68  /// location of the right parentheses; when @c
69  /// getOperator()==OO_Subscript, this is the location of the right
70  /// bracket.
71  SourceLocation getOperatorLoc() const { return getRParenLoc(); }
72
73  virtual SourceRange getSourceRange() const;
74
75  static bool classof(const Stmt *T) {
76    return T->getStmtClass() == CXXOperatorCallExprClass;
77  }
78  static bool classof(const CXXOperatorCallExpr *) { return true; }
79};
80
81/// CXXMemberCallExpr - Represents a call to a member function that
82/// may be written either with member call syntax (e.g., "obj.func()"
83/// or "objptr->func()") or with normal function-call syntax
84/// ("func()") within a member function that ends up calling a member
85/// function. The callee in either case is a MemberExpr that contains
86/// both the object argument and the member function, while the
87/// arguments are the arguments within the parentheses (not including
88/// the object argument).
89class CXXMemberCallExpr : public CallExpr {
90public:
91  CXXMemberCallExpr(ASTContext &C, Expr *fn, Expr **args, unsigned numargs,
92                    QualType t, SourceLocation rparenloc)
93    : CallExpr(C, CXXMemberCallExprClass, fn, args, numargs, t, rparenloc) {}
94
95  CXXMemberCallExpr(ASTContext &C, EmptyShell Empty)
96    : CallExpr(C, CXXMemberCallExprClass, Empty) { }
97
98  /// getImplicitObjectArgument - Retrieves the implicit object
99  /// argument for the member call. For example, in "x.f(5)", this
100  /// operation would return "x".
101  Expr *getImplicitObjectArgument();
102
103  virtual SourceRange getSourceRange() const;
104
105  static bool classof(const Stmt *T) {
106    return T->getStmtClass() == CXXMemberCallExprClass;
107  }
108  static bool classof(const CXXMemberCallExpr *) { return true; }
109};
110
111/// CXXNamedCastExpr - Abstract class common to all of the C++ "named"
112/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c
113/// const_cast.
114///
115/// This abstract class is inherited by all of the classes
116/// representing "named" casts, e.g., CXXStaticCastExpr,
117/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr.
118class CXXNamedCastExpr : public ExplicitCastExpr {
119private:
120  SourceLocation Loc; // the location of the casting op
121
122protected:
123  CXXNamedCastExpr(StmtClass SC, QualType ty, CastKind kind, Expr *op,
124                   CXXBaseSpecifierArray BasePath, TypeSourceInfo *writtenTy,
125                   SourceLocation l)
126    : ExplicitCastExpr(SC, ty, kind, op, BasePath, writtenTy), Loc(l) {}
127
128  explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell)
129    : ExplicitCastExpr(SC, Shell) { }
130
131public:
132  const char *getCastName() const;
133
134  /// \brief Retrieve the location of the cast operator keyword, e.g.,
135  /// "static_cast".
136  SourceLocation getOperatorLoc() const { return Loc; }
137  void setOperatorLoc(SourceLocation L) { Loc = L; }
138
139  virtual SourceRange getSourceRange() const {
140    return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd());
141  }
142  static bool classof(const Stmt *T) {
143    switch (T->getStmtClass()) {
144    case CXXStaticCastExprClass:
145    case CXXDynamicCastExprClass:
146    case CXXReinterpretCastExprClass:
147    case CXXConstCastExprClass:
148      return true;
149    default:
150      return false;
151    }
152  }
153  static bool classof(const CXXNamedCastExpr *) { return true; }
154};
155
156/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]).
157///
158/// This expression node represents a C++ static cast, e.g.,
159/// @c static_cast<int>(1.0).
160class CXXStaticCastExpr : public CXXNamedCastExpr {
161public:
162  CXXStaticCastExpr(QualType ty, CastKind kind, Expr *op,
163                    CXXBaseSpecifierArray BasePath, TypeSourceInfo *writtenTy,
164                    SourceLocation l)
165    : CXXNamedCastExpr(CXXStaticCastExprClass, ty, kind, op, BasePath, writtenTy, l) {}
166
167  explicit CXXStaticCastExpr(EmptyShell Empty)
168    : CXXNamedCastExpr(CXXStaticCastExprClass, Empty) { }
169
170  static bool classof(const Stmt *T) {
171    return T->getStmtClass() == CXXStaticCastExprClass;
172  }
173  static bool classof(const CXXStaticCastExpr *) { return true; }
174};
175
176/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression
177/// (C++ [expr.dynamic.cast]), which may perform a run-time check to
178/// determine how to perform the type cast.
179///
180/// This expression node represents a dynamic cast, e.g.,
181/// @c dynamic_cast<Derived*>(BasePtr).
182class CXXDynamicCastExpr : public CXXNamedCastExpr {
183public:
184  CXXDynamicCastExpr(QualType ty, CastKind kind, Expr *op,
185                     CXXBaseSpecifierArray BasePath, TypeSourceInfo *writtenTy,
186                     SourceLocation l)
187    : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, kind, op, BasePath,
188                       writtenTy, l) {}
189
190  explicit CXXDynamicCastExpr(EmptyShell Empty)
191    : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty) { }
192
193  static bool classof(const Stmt *T) {
194    return T->getStmtClass() == CXXDynamicCastExprClass;
195  }
196  static bool classof(const CXXDynamicCastExpr *) { return true; }
197};
198
199/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++
200/// [expr.reinterpret.cast]), which provides a differently-typed view
201/// of a value but performs no actual work at run time.
202///
203/// This expression node represents a reinterpret cast, e.g.,
204/// @c reinterpret_cast<int>(VoidPtr).
205class CXXReinterpretCastExpr : public CXXNamedCastExpr {
206public:
207  CXXReinterpretCastExpr(QualType ty, CastKind kind, Expr *op,
208                         CXXBaseSpecifierArray BasePath,
209                         TypeSourceInfo *writtenTy, SourceLocation l)
210    : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, kind, op, BasePath,
211                       writtenTy, l) {}
212
213  explicit CXXReinterpretCastExpr(EmptyShell Empty)
214    : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty) { }
215
216  static bool classof(const Stmt *T) {
217    return T->getStmtClass() == CXXReinterpretCastExprClass;
218  }
219  static bool classof(const CXXReinterpretCastExpr *) { return true; }
220};
221
222/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]),
223/// which can remove type qualifiers but does not change the underlying value.
224///
225/// This expression node represents a const cast, e.g.,
226/// @c const_cast<char*>(PtrToConstChar).
227class CXXConstCastExpr : public CXXNamedCastExpr {
228public:
229  CXXConstCastExpr(QualType ty, Expr *op, TypeSourceInfo *writtenTy,
230                   SourceLocation l)
231    : CXXNamedCastExpr(CXXConstCastExprClass, ty, CK_NoOp, op,
232                       CXXBaseSpecifierArray(), writtenTy, l) {}
233
234  explicit CXXConstCastExpr(EmptyShell Empty)
235    : CXXNamedCastExpr(CXXConstCastExprClass, Empty) { }
236
237  static bool classof(const Stmt *T) {
238    return T->getStmtClass() == CXXConstCastExprClass;
239  }
240  static bool classof(const CXXConstCastExpr *) { return true; }
241};
242
243/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal.
244///
245class CXXBoolLiteralExpr : public Expr {
246  bool Value;
247  SourceLocation Loc;
248public:
249  CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) :
250    Expr(CXXBoolLiteralExprClass, Ty, false, false), Value(val), Loc(l) {}
251
252  explicit CXXBoolLiteralExpr(EmptyShell Empty)
253    : Expr(CXXBoolLiteralExprClass, Empty) { }
254
255  bool getValue() const { return Value; }
256  void setValue(bool V) { Value = V; }
257
258  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
259
260  SourceLocation getLocation() const { return Loc; }
261  void setLocation(SourceLocation L) { Loc = L; }
262
263  static bool classof(const Stmt *T) {
264    return T->getStmtClass() == CXXBoolLiteralExprClass;
265  }
266  static bool classof(const CXXBoolLiteralExpr *) { return true; }
267
268  // Iterators
269  virtual child_iterator child_begin();
270  virtual child_iterator child_end();
271};
272
273/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal
274class CXXNullPtrLiteralExpr : public Expr {
275  SourceLocation Loc;
276public:
277  CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) :
278    Expr(CXXNullPtrLiteralExprClass, Ty, false, false), Loc(l) {}
279
280  explicit CXXNullPtrLiteralExpr(EmptyShell Empty)
281    : Expr(CXXNullPtrLiteralExprClass, Empty) { }
282
283  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
284
285  SourceLocation getLocation() const { return Loc; }
286  void setLocation(SourceLocation L) { Loc = L; }
287
288  static bool classof(const Stmt *T) {
289    return T->getStmtClass() == CXXNullPtrLiteralExprClass;
290  }
291  static bool classof(const CXXNullPtrLiteralExpr *) { return true; }
292
293  virtual child_iterator child_begin();
294  virtual child_iterator child_end();
295};
296
297/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets
298/// the type_info that corresponds to the supplied type, or the (possibly
299/// dynamic) type of the supplied expression.
300///
301/// This represents code like @c typeid(int) or @c typeid(*objPtr)
302class CXXTypeidExpr : public Expr {
303private:
304  llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
305  SourceRange Range;
306
307public:
308  CXXTypeidExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R)
309    : Expr(CXXTypeidExprClass, Ty,
310           // typeid is never type-dependent (C++ [temp.dep.expr]p4)
311           false,
312           // typeid is value-dependent if the type or expression are dependent
313           Operand->getType()->isDependentType()),
314      Operand(Operand), Range(R) { }
315
316  CXXTypeidExpr(QualType Ty, Expr *Operand, SourceRange R)
317    : Expr(CXXTypeidExprClass, Ty,
318        // typeid is never type-dependent (C++ [temp.dep.expr]p4)
319        false,
320        // typeid is value-dependent if the type or expression are dependent
321        Operand->isTypeDependent() || Operand->isValueDependent()),
322      Operand(Operand), Range(R) { }
323
324  CXXTypeidExpr(EmptyShell Empty, bool isExpr)
325    : Expr(CXXTypeidExprClass, Empty) {
326    if (isExpr)
327      Operand = (Expr*)0;
328    else
329      Operand = (TypeSourceInfo*)0;
330  }
331
332  bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
333
334  /// \brief Retrieves the type operand of this typeid() expression after
335  /// various required adjustments (removing reference types, cv-qualifiers).
336  QualType getTypeOperand() const;
337
338  /// \brief Retrieve source information for the type operand.
339  TypeSourceInfo *getTypeOperandSourceInfo() const {
340    assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
341    return Operand.get<TypeSourceInfo *>();
342  }
343
344  void setTypeOperandSourceInfo(TypeSourceInfo *TSI) {
345    assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
346    Operand = TSI;
347  }
348
349  Expr *getExprOperand() const {
350    assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
351    return static_cast<Expr*>(Operand.get<Stmt *>());
352  }
353
354  void setExprOperand(Expr *E) {
355    assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
356    Operand = E;
357  }
358
359  virtual SourceRange getSourceRange() const { return Range; }
360  void setSourceRange(SourceRange R) { Range = R; }
361
362  static bool classof(const Stmt *T) {
363    return T->getStmtClass() == CXXTypeidExprClass;
364  }
365  static bool classof(const CXXTypeidExpr *) { return true; }
366
367  // Iterators
368  virtual child_iterator child_begin();
369  virtual child_iterator child_end();
370};
371
372/// CXXThisExpr - Represents the "this" expression in C++, which is a
373/// pointer to the object on which the current member function is
374/// executing (C++ [expr.prim]p3). Example:
375///
376/// @code
377/// class Foo {
378/// public:
379///   void bar();
380///   void test() { this->bar(); }
381/// };
382/// @endcode
383class CXXThisExpr : public Expr {
384  SourceLocation Loc;
385  bool Implicit : 1;
386
387public:
388  CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit)
389    : Expr(CXXThisExprClass, Type,
390           // 'this' is type-dependent if the class type of the enclosing
391           // member function is dependent (C++ [temp.dep.expr]p2)
392           Type->isDependentType(), Type->isDependentType()),
393      Loc(L), Implicit(isImplicit) { }
394
395  CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {}
396
397  SourceLocation getLocation() const { return Loc; }
398  void setLocation(SourceLocation L) { Loc = L; }
399
400  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
401
402  bool isImplicit() const { return Implicit; }
403  void setImplicit(bool I) { Implicit = I; }
404
405  static bool classof(const Stmt *T) {
406    return T->getStmtClass() == CXXThisExprClass;
407  }
408  static bool classof(const CXXThisExpr *) { return true; }
409
410  // Iterators
411  virtual child_iterator child_begin();
412  virtual child_iterator child_end();
413};
414
415///  CXXThrowExpr - [C++ 15] C++ Throw Expression.  This handles
416///  'throw' and 'throw' assignment-expression.  When
417///  assignment-expression isn't present, Op will be null.
418///
419class CXXThrowExpr : public Expr {
420  Stmt *Op;
421  SourceLocation ThrowLoc;
422public:
423  // Ty is the void type which is used as the result type of the
424  // exepression.  The l is the location of the throw keyword.  expr
425  // can by null, if the optional expression to throw isn't present.
426  CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) :
427    Expr(CXXThrowExprClass, Ty, false, false), Op(expr), ThrowLoc(l) {}
428  CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {}
429
430  const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); }
431  Expr *getSubExpr() { return cast_or_null<Expr>(Op); }
432  void setSubExpr(Expr *E) { Op = E; }
433
434  SourceLocation getThrowLoc() const { return ThrowLoc; }
435  void setThrowLoc(SourceLocation L) { ThrowLoc = L; }
436
437  virtual SourceRange getSourceRange() const {
438    if (getSubExpr() == 0)
439      return SourceRange(ThrowLoc, ThrowLoc);
440    return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd());
441  }
442
443  static bool classof(const Stmt *T) {
444    return T->getStmtClass() == CXXThrowExprClass;
445  }
446  static bool classof(const CXXThrowExpr *) { return true; }
447
448  // Iterators
449  virtual child_iterator child_begin();
450  virtual child_iterator child_end();
451};
452
453/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a
454/// function call argument that was created from the corresponding
455/// parameter's default argument, when the call did not explicitly
456/// supply arguments for all of the parameters.
457class CXXDefaultArgExpr : public Expr {
458  /// \brief The parameter whose default is being used.
459  ///
460  /// When the bit is set, the subexpression is stored after the
461  /// CXXDefaultArgExpr itself. When the bit is clear, the parameter's
462  /// actual default expression is the subexpression.
463  llvm::PointerIntPair<ParmVarDecl *, 1, bool> Param;
464
465  /// \brief The location where the default argument expression was used.
466  SourceLocation Loc;
467
468  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param)
469    : Expr(SC,
470           param->hasUnparsedDefaultArg()
471             ? param->getType().getNonReferenceType()
472             : param->getDefaultArg()->getType(),
473           false, false),
474      Param(param, false), Loc(Loc) { }
475
476  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param,
477                    Expr *SubExpr)
478    : Expr(SC, SubExpr->getType(), false, false), Param(param, true), Loc(Loc) {
479    *reinterpret_cast<Expr **>(this + 1) = SubExpr;
480  }
481
482public:
483  CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {}
484
485
486  // Param is the parameter whose default argument is used by this
487  // expression.
488  static CXXDefaultArgExpr *Create(ASTContext &C, SourceLocation Loc,
489                                   ParmVarDecl *Param) {
490    return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param);
491  }
492
493  // Param is the parameter whose default argument is used by this
494  // expression, and SubExpr is the expression that will actually be used.
495  static CXXDefaultArgExpr *Create(ASTContext &C,
496                                   SourceLocation Loc,
497                                   ParmVarDecl *Param,
498                                   Expr *SubExpr);
499
500  // Retrieve the parameter that the argument was created from.
501  const ParmVarDecl *getParam() const { return Param.getPointer(); }
502  ParmVarDecl *getParam() { return Param.getPointer(); }
503
504  // Retrieve the actual argument to the function call.
505  const Expr *getExpr() const {
506    if (Param.getInt())
507      return *reinterpret_cast<Expr const * const*> (this + 1);
508    return getParam()->getDefaultArg();
509  }
510  Expr *getExpr() {
511    if (Param.getInt())
512      return *reinterpret_cast<Expr **> (this + 1);
513    return getParam()->getDefaultArg();
514  }
515
516  /// \brief Retrieve the location where this default argument was actually
517  /// used.
518  SourceLocation getUsedLocation() const { return Loc; }
519
520  virtual SourceRange getSourceRange() const {
521    // Default argument expressions have no representation in the
522    // source, so they have an empty source range.
523    return SourceRange();
524  }
525
526  static bool classof(const Stmt *T) {
527    return T->getStmtClass() == CXXDefaultArgExprClass;
528  }
529  static bool classof(const CXXDefaultArgExpr *) { return true; }
530
531  // Iterators
532  virtual child_iterator child_begin();
533  virtual child_iterator child_end();
534
535  friend class PCHStmtReader;
536  friend class PCHStmtWriter;
537};
538
539/// CXXTemporary - Represents a C++ temporary.
540class CXXTemporary {
541  /// Destructor - The destructor that needs to be called.
542  const CXXDestructorDecl *Destructor;
543
544  CXXTemporary(const CXXDestructorDecl *destructor)
545    : Destructor(destructor) { }
546
547public:
548  static CXXTemporary *Create(ASTContext &C,
549                              const CXXDestructorDecl *Destructor);
550
551  const CXXDestructorDecl *getDestructor() const { return Destructor; }
552};
553
554/// \brief Represents binding an expression to a temporary.
555///
556/// This ensures the destructor is called for the temporary. It should only be
557/// needed for non-POD, non-trivially destructable class types. For example:
558///
559/// \code
560///   struct S {
561///     S() { }  // User defined constructor makes S non-POD.
562///     ~S() { } // User defined destructor makes it non-trivial.
563///   };
564///   void test() {
565///     const S &s_ref = S(); // Requires a CXXBindTemporaryExpr.
566///   }
567/// \endcode
568class CXXBindTemporaryExpr : public Expr {
569  CXXTemporary *Temp;
570
571  Stmt *SubExpr;
572
573  CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr)
574   : Expr(CXXBindTemporaryExprClass, subexpr->getType(), false, false),
575     Temp(temp), SubExpr(subexpr) { }
576
577public:
578  CXXBindTemporaryExpr(EmptyShell Empty)
579    : Expr(CXXBindTemporaryExprClass, Empty), Temp(0), SubExpr(0) {}
580
581  static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp,
582                                      Expr* SubExpr);
583
584  CXXTemporary *getTemporary() { return Temp; }
585  const CXXTemporary *getTemporary() const { return Temp; }
586  void setTemporary(CXXTemporary *T) { Temp = T; }
587
588  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
589  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
590  void setSubExpr(Expr *E) { SubExpr = E; }
591
592  virtual SourceRange getSourceRange() const {
593    return SubExpr->getSourceRange();
594  }
595
596  // Implement isa/cast/dyncast/etc.
597  static bool classof(const Stmt *T) {
598    return T->getStmtClass() == CXXBindTemporaryExprClass;
599  }
600  static bool classof(const CXXBindTemporaryExpr *) { return true; }
601
602  // Iterators
603  virtual child_iterator child_begin();
604  virtual child_iterator child_end();
605};
606
607/// CXXBindReferenceExpr - Represents binding an expression to a reference.
608/// In the example:
609///
610/// const int &i = 10;
611///
612/// a bind reference expression is inserted to indicate that 10 is bound to
613/// a reference, and that a temporary needs to be created to hold the
614/// value.
615class CXXBindReferenceExpr : public Expr {
616  // SubExpr - The expression being bound.
617  Stmt *SubExpr;
618
619  // ExtendsLifetime - Whether binding this reference extends the lifetime of
620  // the expression being bound. FIXME: Add C++ reference.
621  bool ExtendsLifetime;
622
623  /// RequiresTemporaryCopy - Whether binding the subexpression requires a
624  /// temporary copy.
625  bool RequiresTemporaryCopy;
626
627  CXXBindReferenceExpr(Expr *subexpr, bool ExtendsLifetime,
628                       bool RequiresTemporaryCopy)
629  : Expr(CXXBindReferenceExprClass, subexpr->getType(), false, false),
630    SubExpr(subexpr), ExtendsLifetime(ExtendsLifetime),
631    RequiresTemporaryCopy(RequiresTemporaryCopy) { }
632
633public:
634  static CXXBindReferenceExpr *Create(ASTContext &C, Expr *SubExpr,
635                                      bool ExtendsLifetime,
636                                      bool RequiresTemporaryCopy);
637
638  explicit CXXBindReferenceExpr(EmptyShell Empty)
639    : Expr(CXXBindReferenceExprClass, Empty) { }
640
641  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
642  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
643  void setSubExpr(Expr *E) { SubExpr = E; }
644
645  virtual SourceRange getSourceRange() const {
646    return SubExpr->getSourceRange();
647  }
648
649  /// requiresTemporaryCopy - Whether binding the subexpression requires a
650  /// temporary copy.
651  bool requiresTemporaryCopy() const { return RequiresTemporaryCopy; }
652
653  // extendsLifetime - Whether binding this reference extends the lifetime of
654  // the expression being bound. FIXME: Add C++ reference.
655  bool extendsLifetime() const { return ExtendsLifetime; }
656
657  // Implement isa/cast/dyncast/etc.
658  static bool classof(const Stmt *T) {
659    return T->getStmtClass() == CXXBindReferenceExprClass;
660  }
661  static bool classof(const CXXBindReferenceExpr *) { return true; }
662
663  // Iterators
664  virtual child_iterator child_begin();
665  virtual child_iterator child_end();
666
667  friend class PCHStmtReader;
668};
669
670/// CXXConstructExpr - Represents a call to a C++ constructor.
671class CXXConstructExpr : public Expr {
672public:
673  enum ConstructionKind {
674    CK_Complete,
675    CK_NonVirtualBase,
676    CK_VirtualBase
677  };
678
679private:
680  CXXConstructorDecl *Constructor;
681
682  SourceLocation Loc;
683  bool Elidable : 1;
684  bool ZeroInitialization : 1;
685  unsigned ConstructKind : 2;
686  Stmt **Args;
687  unsigned NumArgs;
688
689protected:
690  CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
691                   SourceLocation Loc,
692                   CXXConstructorDecl *d, bool elidable,
693                   Expr **args, unsigned numargs,
694                   bool ZeroInitialization = false,
695                   ConstructionKind ConstructKind = CK_Complete);
696
697  /// \brief Construct an empty C++ construction expression.
698  CXXConstructExpr(StmtClass SC, EmptyShell Empty)
699    : Expr(SC, Empty), Constructor(0), Elidable(0), ZeroInitialization(0),
700      ConstructKind(0), Args(0), NumArgs(0) { }
701
702public:
703  /// \brief Construct an empty C++ construction expression.
704  explicit CXXConstructExpr(EmptyShell Empty)
705    : Expr(CXXConstructExprClass, Empty), Constructor(0),
706      Elidable(0), ZeroInitialization(0),
707      ConstructKind(0), Args(0), NumArgs(0) { }
708
709  static CXXConstructExpr *Create(ASTContext &C, QualType T,
710                                  SourceLocation Loc,
711                                  CXXConstructorDecl *D, bool Elidable,
712                                  Expr **Args, unsigned NumArgs,
713                                  bool ZeroInitialization = false,
714                                  ConstructionKind ConstructKind = CK_Complete);
715
716
717  CXXConstructorDecl* getConstructor() const { return Constructor; }
718  void setConstructor(CXXConstructorDecl *C) { Constructor = C; }
719
720  SourceLocation getLocation() const { return Loc; }
721  void setLocation(SourceLocation Loc) { this->Loc = Loc; }
722
723  /// \brief Whether this construction is elidable.
724  bool isElidable() const { return Elidable; }
725  void setElidable(bool E) { Elidable = E; }
726
727  /// \brief Whether this construction first requires
728  /// zero-initialization before the initializer is called.
729  bool requiresZeroInitialization() const { return ZeroInitialization; }
730  void setRequiresZeroInitialization(bool ZeroInit) {
731    ZeroInitialization = ZeroInit;
732  }
733
734  /// \brief Determines whether this constructor is actually constructing
735  /// a base class (rather than a complete object).
736  ConstructionKind getConstructionKind() const {
737    return (ConstructionKind)ConstructKind;
738  }
739  void setConstructionKind(ConstructionKind CK) {
740    ConstructKind = CK;
741  }
742
743  typedef ExprIterator arg_iterator;
744  typedef ConstExprIterator const_arg_iterator;
745
746  arg_iterator arg_begin() { return Args; }
747  arg_iterator arg_end() { return Args + NumArgs; }
748  const_arg_iterator arg_begin() const { return Args; }
749  const_arg_iterator arg_end() const { return Args + NumArgs; }
750
751  Expr **getArgs() const { return reinterpret_cast<Expr **>(Args); }
752  unsigned getNumArgs() const { return NumArgs; }
753
754  /// getArg - Return the specified argument.
755  Expr *getArg(unsigned Arg) {
756    assert(Arg < NumArgs && "Arg access out of range!");
757    return cast<Expr>(Args[Arg]);
758  }
759  const Expr *getArg(unsigned Arg) const {
760    assert(Arg < NumArgs && "Arg access out of range!");
761    return cast<Expr>(Args[Arg]);
762  }
763
764  /// setArg - Set the specified argument.
765  void setArg(unsigned Arg, Expr *ArgExpr) {
766    assert(Arg < NumArgs && "Arg access out of range!");
767    Args[Arg] = ArgExpr;
768  }
769
770  virtual SourceRange getSourceRange() const;
771
772  static bool classof(const Stmt *T) {
773    return T->getStmtClass() == CXXConstructExprClass ||
774      T->getStmtClass() == CXXTemporaryObjectExprClass;
775  }
776  static bool classof(const CXXConstructExpr *) { return true; }
777
778  // Iterators
779  virtual child_iterator child_begin();
780  virtual child_iterator child_end();
781
782  friend class PCHStmtReader;
783};
784
785/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion
786/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c
787/// x = int(0.5);
788class CXXFunctionalCastExpr : public ExplicitCastExpr {
789  SourceLocation TyBeginLoc;
790  SourceLocation RParenLoc;
791public:
792  CXXFunctionalCastExpr(QualType ty, TypeSourceInfo *writtenTy,
793                        SourceLocation tyBeginLoc, CastKind kind,
794                        Expr *castExpr, CXXBaseSpecifierArray BasePath,
795                        SourceLocation rParenLoc)
796    : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, kind, castExpr,
797                       BasePath, writtenTy),
798      TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
799
800  explicit CXXFunctionalCastExpr(EmptyShell Shell)
801    : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell) { }
802
803  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
804  void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; }
805  SourceLocation getRParenLoc() const { return RParenLoc; }
806  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
807
808  virtual SourceRange getSourceRange() const {
809    return SourceRange(TyBeginLoc, RParenLoc);
810  }
811  static bool classof(const Stmt *T) {
812    return T->getStmtClass() == CXXFunctionalCastExprClass;
813  }
814  static bool classof(const CXXFunctionalCastExpr *) { return true; }
815};
816
817/// @brief Represents a C++ functional cast expression that builds a
818/// temporary object.
819///
820/// This expression type represents a C++ "functional" cast
821/// (C++[expr.type.conv]) with N != 1 arguments that invokes a
822/// constructor to build a temporary object. With N == 1 arguments the
823/// functional cast expression will be represented by CXXFunctionalCastExpr.
824/// Example:
825/// @code
826/// struct X { X(int, float); }
827///
828/// X create_X() {
829///   return X(1, 3.14f); // creates a CXXTemporaryObjectExpr
830/// };
831/// @endcode
832class CXXTemporaryObjectExpr : public CXXConstructExpr {
833  SourceLocation TyBeginLoc;
834  SourceLocation RParenLoc;
835
836public:
837  CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons,
838                         QualType writtenTy, SourceLocation tyBeginLoc,
839                         Expr **Args,unsigned NumArgs,
840                         SourceLocation rParenLoc,
841                         bool ZeroInitialization = false);
842  explicit CXXTemporaryObjectExpr(EmptyShell Empty)
843    : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty) { }
844
845  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
846  SourceLocation getRParenLoc() const { return RParenLoc; }
847
848  virtual SourceRange getSourceRange() const {
849    return SourceRange(TyBeginLoc, RParenLoc);
850  }
851  static bool classof(const Stmt *T) {
852    return T->getStmtClass() == CXXTemporaryObjectExprClass;
853  }
854  static bool classof(const CXXTemporaryObjectExpr *) { return true; }
855
856  friend class PCHStmtReader;
857};
858
859/// CXXScalarValueInitExpr - [C++ 5.2.3p2]
860/// Expression "T()" which creates a value-initialized rvalue of type
861/// T, which is a non-class type.
862///
863class CXXScalarValueInitExpr : public Expr {
864  SourceLocation TyBeginLoc;
865  SourceLocation RParenLoc;
866
867public:
868  CXXScalarValueInitExpr(QualType ty, SourceLocation tyBeginLoc,
869                       SourceLocation rParenLoc ) :
870    Expr(CXXScalarValueInitExprClass, ty, false, false),
871    TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
872  explicit CXXScalarValueInitExpr(EmptyShell Shell)
873    : Expr(CXXScalarValueInitExprClass, Shell) { }
874
875  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
876  SourceLocation getRParenLoc() const { return RParenLoc; }
877
878  void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; }
879  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
880
881  /// @brief Whether this initialization expression was
882  /// implicitly-generated.
883  bool isImplicit() const {
884    return TyBeginLoc.isInvalid() && RParenLoc.isInvalid();
885  }
886
887  virtual SourceRange getSourceRange() const {
888    return SourceRange(TyBeginLoc, RParenLoc);
889  }
890
891  static bool classof(const Stmt *T) {
892    return T->getStmtClass() == CXXScalarValueInitExprClass;
893  }
894  static bool classof(const CXXScalarValueInitExpr *) { return true; }
895
896  // Iterators
897  virtual child_iterator child_begin();
898  virtual child_iterator child_end();
899};
900
901/// CXXNewExpr - A new expression for memory allocation and constructor calls,
902/// e.g: "new CXXNewExpr(foo)".
903class CXXNewExpr : public Expr {
904  // Was the usage ::new, i.e. is the global new to be used?
905  bool GlobalNew : 1;
906  // Is there an initializer? If not, built-ins are uninitialized, else they're
907  // value-initialized.
908  bool Initializer : 1;
909  // Do we allocate an array? If so, the first SubExpr is the size expression.
910  bool Array : 1;
911  // The number of placement new arguments.
912  unsigned NumPlacementArgs : 15;
913  // The number of constructor arguments. This may be 1 even for non-class
914  // types; use the pseudo copy constructor.
915  unsigned NumConstructorArgs : 14;
916  // Contains an optional array size expression, any number of optional
917  // placement arguments, and any number of optional constructor arguments,
918  // in that order.
919  Stmt **SubExprs;
920  // Points to the allocation function used.
921  FunctionDecl *OperatorNew;
922  // Points to the deallocation function used in case of error. May be null.
923  FunctionDecl *OperatorDelete;
924  // Points to the constructor used. Cannot be null if AllocType is a record;
925  // it would still point at the default constructor (even an implicit one).
926  // Must be null for all other types.
927  CXXConstructorDecl *Constructor;
928
929  /// \brief If the allocated type was expressed as a parenthesized type-id,
930  /// the source range covering the parenthesized type-id.
931  SourceRange TypeIdParens;
932
933  SourceLocation StartLoc;
934  SourceLocation EndLoc;
935
936  friend class PCHStmtReader;
937public:
938  CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
939             Expr **placementArgs, unsigned numPlaceArgs,
940             SourceRange TypeIdParens,
941             Expr *arraySize, CXXConstructorDecl *constructor, bool initializer,
942             Expr **constructorArgs, unsigned numConsArgs,
943             FunctionDecl *operatorDelete, QualType ty,
944             SourceLocation startLoc, SourceLocation endLoc);
945  explicit CXXNewExpr(EmptyShell Shell)
946    : Expr(CXXNewExprClass, Shell), SubExprs(0) { }
947
948  void AllocateArgsArray(ASTContext &C, bool isArray, unsigned numPlaceArgs,
949                         unsigned numConsArgs);
950
951  QualType getAllocatedType() const {
952    assert(getType()->isPointerType());
953    return getType()->getAs<PointerType>()->getPointeeType();
954  }
955
956  FunctionDecl *getOperatorNew() const { return OperatorNew; }
957  void setOperatorNew(FunctionDecl *D) { OperatorNew = D; }
958  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
959  void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; }
960  CXXConstructorDecl *getConstructor() const { return Constructor; }
961  void setConstructor(CXXConstructorDecl *D) { Constructor = D; }
962
963  bool isArray() const { return Array; }
964  Expr *getArraySize() {
965    return Array ? cast<Expr>(SubExprs[0]) : 0;
966  }
967  const Expr *getArraySize() const {
968    return Array ? cast<Expr>(SubExprs[0]) : 0;
969  }
970
971  unsigned getNumPlacementArgs() const { return NumPlacementArgs; }
972  Expr *getPlacementArg(unsigned i) {
973    assert(i < NumPlacementArgs && "Index out of range");
974    return cast<Expr>(SubExprs[Array + i]);
975  }
976  const Expr *getPlacementArg(unsigned i) const {
977    assert(i < NumPlacementArgs && "Index out of range");
978    return cast<Expr>(SubExprs[Array + i]);
979  }
980
981  bool isParenTypeId() const { return TypeIdParens.isValid(); }
982  SourceRange getTypeIdParens() const { return TypeIdParens; }
983
984  bool isGlobalNew() const { return GlobalNew; }
985  void setGlobalNew(bool V) { GlobalNew = V; }
986  bool hasInitializer() const { return Initializer; }
987  void setHasInitializer(bool V) { Initializer = V; }
988
989  unsigned getNumConstructorArgs() const { return NumConstructorArgs; }
990  Expr *getConstructorArg(unsigned i) {
991    assert(i < NumConstructorArgs && "Index out of range");
992    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
993  }
994  const Expr *getConstructorArg(unsigned i) const {
995    assert(i < NumConstructorArgs && "Index out of range");
996    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
997  }
998
999  typedef ExprIterator arg_iterator;
1000  typedef ConstExprIterator const_arg_iterator;
1001
1002  arg_iterator placement_arg_begin() {
1003    return SubExprs + Array;
1004  }
1005  arg_iterator placement_arg_end() {
1006    return SubExprs + Array + getNumPlacementArgs();
1007  }
1008  const_arg_iterator placement_arg_begin() const {
1009    return SubExprs + Array;
1010  }
1011  const_arg_iterator placement_arg_end() const {
1012    return SubExprs + Array + getNumPlacementArgs();
1013  }
1014
1015  arg_iterator constructor_arg_begin() {
1016    return SubExprs + Array + getNumPlacementArgs();
1017  }
1018  arg_iterator constructor_arg_end() {
1019    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
1020  }
1021  const_arg_iterator constructor_arg_begin() const {
1022    return SubExprs + Array + getNumPlacementArgs();
1023  }
1024  const_arg_iterator constructor_arg_end() const {
1025    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
1026  }
1027
1028  typedef Stmt **raw_arg_iterator;
1029  raw_arg_iterator raw_arg_begin() { return SubExprs; }
1030  raw_arg_iterator raw_arg_end() {
1031    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
1032  }
1033  const_arg_iterator raw_arg_begin() const { return SubExprs; }
1034  const_arg_iterator raw_arg_end() const { return constructor_arg_end(); }
1035
1036
1037  SourceLocation getStartLoc() const { return StartLoc; }
1038  void setStartLoc(SourceLocation L) { StartLoc = L; }
1039  SourceLocation getEndLoc() const { return EndLoc; }
1040  void setEndLoc(SourceLocation L) { EndLoc = L; }
1041
1042  virtual SourceRange getSourceRange() const {
1043    return SourceRange(StartLoc, EndLoc);
1044  }
1045
1046  static bool classof(const Stmt *T) {
1047    return T->getStmtClass() == CXXNewExprClass;
1048  }
1049  static bool classof(const CXXNewExpr *) { return true; }
1050
1051  // Iterators
1052  virtual child_iterator child_begin();
1053  virtual child_iterator child_end();
1054};
1055
1056/// CXXDeleteExpr - A delete expression for memory deallocation and destructor
1057/// calls, e.g. "delete[] pArray".
1058class CXXDeleteExpr : public Expr {
1059  // Is this a forced global delete, i.e. "::delete"?
1060  bool GlobalDelete : 1;
1061  // Is this the array form of delete, i.e. "delete[]"?
1062  bool ArrayForm : 1;
1063  // Points to the operator delete overload that is used. Could be a member.
1064  FunctionDecl *OperatorDelete;
1065  // The pointer expression to be deleted.
1066  Stmt *Argument;
1067  // Location of the expression.
1068  SourceLocation Loc;
1069public:
1070  CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm,
1071                FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc)
1072    : Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete),
1073      ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg),
1074      Loc(loc) { }
1075  explicit CXXDeleteExpr(EmptyShell Shell)
1076    : Expr(CXXDeleteExprClass, Shell), OperatorDelete(0), Argument(0) { }
1077
1078  bool isGlobalDelete() const { return GlobalDelete; }
1079  bool isArrayForm() const { return ArrayForm; }
1080
1081  void setGlobalDelete(bool V) { GlobalDelete = V; }
1082  void setArrayForm(bool V) { ArrayForm = V; }
1083
1084  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
1085  void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; }
1086
1087  Expr *getArgument() { return cast<Expr>(Argument); }
1088  const Expr *getArgument() const { return cast<Expr>(Argument); }
1089  void setArgument(Expr *E) { Argument = E; }
1090
1091  virtual SourceRange getSourceRange() const {
1092    return SourceRange(Loc, Argument->getLocEnd());
1093  }
1094  void setStartLoc(SourceLocation L) { Loc = L; }
1095
1096  static bool classof(const Stmt *T) {
1097    return T->getStmtClass() == CXXDeleteExprClass;
1098  }
1099  static bool classof(const CXXDeleteExpr *) { return true; }
1100
1101  // Iterators
1102  virtual child_iterator child_begin();
1103  virtual child_iterator child_end();
1104};
1105
1106/// \brief Structure used to store the type being destroyed by a
1107/// pseudo-destructor expression.
1108class PseudoDestructorTypeStorage {
1109  /// \brief Either the type source information or the name of the type, if
1110  /// it couldn't be resolved due to type-dependence.
1111  llvm::PointerUnion<TypeSourceInfo *, IdentifierInfo *> Type;
1112
1113  /// \brief The starting source location of the pseudo-destructor type.
1114  SourceLocation Location;
1115
1116public:
1117  PseudoDestructorTypeStorage() { }
1118
1119  PseudoDestructorTypeStorage(IdentifierInfo *II, SourceLocation Loc)
1120    : Type(II), Location(Loc) { }
1121
1122  PseudoDestructorTypeStorage(TypeSourceInfo *Info);
1123
1124  TypeSourceInfo *getTypeSourceInfo() const {
1125    return Type.dyn_cast<TypeSourceInfo *>();
1126  }
1127
1128  IdentifierInfo *getIdentifier() const {
1129    return Type.dyn_cast<IdentifierInfo *>();
1130  }
1131
1132  SourceLocation getLocation() const { return Location; }
1133};
1134
1135/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
1136///
1137/// A pseudo-destructor is an expression that looks like a member access to a
1138/// destructor of a scalar type, except that scalar types don't have
1139/// destructors. For example:
1140///
1141/// \code
1142/// typedef int T;
1143/// void f(int *p) {
1144///   p->T::~T();
1145/// }
1146/// \endcode
1147///
1148/// Pseudo-destructors typically occur when instantiating templates such as:
1149///
1150/// \code
1151/// template<typename T>
1152/// void destroy(T* ptr) {
1153///   ptr->T::~T();
1154/// }
1155/// \endcode
1156///
1157/// for scalar types. A pseudo-destructor expression has no run-time semantics
1158/// beyond evaluating the base expression.
1159class CXXPseudoDestructorExpr : public Expr {
1160  /// \brief The base expression (that is being destroyed).
1161  Stmt *Base;
1162
1163  /// \brief Whether the operator was an arrow ('->'); otherwise, it was a
1164  /// period ('.').
1165  bool IsArrow : 1;
1166
1167  /// \brief The location of the '.' or '->' operator.
1168  SourceLocation OperatorLoc;
1169
1170  /// \brief The nested-name-specifier that follows the operator, if present.
1171  NestedNameSpecifier *Qualifier;
1172
1173  /// \brief The source range that covers the nested-name-specifier, if
1174  /// present.
1175  SourceRange QualifierRange;
1176
1177  /// \brief The type that precedes the '::' in a qualified pseudo-destructor
1178  /// expression.
1179  TypeSourceInfo *ScopeType;
1180
1181  /// \brief The location of the '::' in a qualified pseudo-destructor
1182  /// expression.
1183  SourceLocation ColonColonLoc;
1184
1185  /// \brief The location of the '~'.
1186  SourceLocation TildeLoc;
1187
1188  /// \brief The type being destroyed, or its name if we were unable to
1189  /// resolve the name.
1190  PseudoDestructorTypeStorage DestroyedType;
1191
1192public:
1193  CXXPseudoDestructorExpr(ASTContext &Context,
1194                          Expr *Base, bool isArrow, SourceLocation OperatorLoc,
1195                          NestedNameSpecifier *Qualifier,
1196                          SourceRange QualifierRange,
1197                          TypeSourceInfo *ScopeType,
1198                          SourceLocation ColonColonLoc,
1199                          SourceLocation TildeLoc,
1200                          PseudoDestructorTypeStorage DestroyedType)
1201    : Expr(CXXPseudoDestructorExprClass,
1202           Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0,
1203                                                          false, 0, false,
1204                                                          false, 0, 0,
1205                                                      FunctionType::ExtInfo())),
1206           /*isTypeDependent=*/(Base->isTypeDependent() ||
1207            (DestroyedType.getTypeSourceInfo() &&
1208              DestroyedType.getTypeSourceInfo()->getType()->isDependentType())),
1209           /*isValueDependent=*/Base->isValueDependent()),
1210      Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
1211      OperatorLoc(OperatorLoc), Qualifier(Qualifier),
1212      QualifierRange(QualifierRange),
1213      ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc),
1214      DestroyedType(DestroyedType) { }
1215
1216  explicit CXXPseudoDestructorExpr(EmptyShell Shell)
1217    : Expr(CXXPseudoDestructorExprClass, Shell),
1218      Base(0), IsArrow(false), Qualifier(0), ScopeType(0) { }
1219
1220  void setBase(Expr *E) { Base = E; }
1221  Expr *getBase() const { return cast<Expr>(Base); }
1222
1223  /// \brief Determines whether this member expression actually had
1224  /// a C++ nested-name-specifier prior to the name of the member, e.g.,
1225  /// x->Base::foo.
1226  bool hasQualifier() const { return Qualifier != 0; }
1227
1228  /// \brief If the member name was qualified, retrieves the source range of
1229  /// the nested-name-specifier that precedes the member name. Otherwise,
1230  /// returns an empty source range.
1231  SourceRange getQualifierRange() const { return QualifierRange; }
1232  void setQualifierRange(SourceRange R) { QualifierRange = R; }
1233
1234  /// \brief If the member name was qualified, retrieves the
1235  /// nested-name-specifier that precedes the member name. Otherwise, returns
1236  /// NULL.
1237  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1238  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
1239
1240  /// \brief Determine whether this pseudo-destructor expression was written
1241  /// using an '->' (otherwise, it used a '.').
1242  bool isArrow() const { return IsArrow; }
1243  void setArrow(bool A) { IsArrow = A; }
1244
1245  /// \brief Retrieve the location of the '.' or '->' operator.
1246  SourceLocation getOperatorLoc() const { return OperatorLoc; }
1247  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
1248
1249  /// \brief Retrieve the scope type in a qualified pseudo-destructor
1250  /// expression.
1251  ///
1252  /// Pseudo-destructor expressions can have extra qualification within them
1253  /// that is not part of the nested-name-specifier, e.g., \c p->T::~T().
1254  /// Here, if the object type of the expression is (or may be) a scalar type,
1255  /// \p T may also be a scalar type and, therefore, cannot be part of a
1256  /// nested-name-specifier. It is stored as the "scope type" of the pseudo-
1257  /// destructor expression.
1258  TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; }
1259  void setScopeTypeInfo(TypeSourceInfo *Info) { ScopeType = Info; }
1260
1261  /// \brief Retrieve the location of the '::' in a qualified pseudo-destructor
1262  /// expression.
1263  SourceLocation getColonColonLoc() const { return ColonColonLoc; }
1264  void setColonColonLoc(SourceLocation L) { ColonColonLoc = L; }
1265
1266  /// \brief Retrieve the location of the '~'.
1267  SourceLocation getTildeLoc() const { return TildeLoc; }
1268  void setTildeLoc(SourceLocation L) { TildeLoc = L; }
1269
1270  /// \brief Retrieve the source location information for the type
1271  /// being destroyed.
1272  ///
1273  /// This type-source information is available for non-dependent
1274  /// pseudo-destructor expressions and some dependent pseudo-destructor
1275  /// expressions. Returns NULL if we only have the identifier for a
1276  /// dependent pseudo-destructor expression.
1277  TypeSourceInfo *getDestroyedTypeInfo() const {
1278    return DestroyedType.getTypeSourceInfo();
1279  }
1280
1281  /// \brief In a dependent pseudo-destructor expression for which we do not
1282  /// have full type information on the destroyed type, provides the name
1283  /// of the destroyed type.
1284  IdentifierInfo *getDestroyedTypeIdentifier() const {
1285    return DestroyedType.getIdentifier();
1286  }
1287
1288  /// \brief Retrieve the type being destroyed.
1289  QualType getDestroyedType() const;
1290
1291  /// \brief Retrieve the starting location of the type being destroyed.
1292  SourceLocation getDestroyedTypeLoc() const {
1293    return DestroyedType.getLocation();
1294  }
1295
1296  /// \brief Set the name of destroyed type for a dependent pseudo-destructor
1297  /// expression.
1298  void setDestroyedType(IdentifierInfo *II, SourceLocation Loc) {
1299    DestroyedType = PseudoDestructorTypeStorage(II, Loc);
1300  }
1301
1302  /// \brief Set the destroyed type.
1303  void setDestroyedType(TypeSourceInfo *Info) {
1304    DestroyedType = PseudoDestructorTypeStorage(Info);
1305  }
1306
1307  virtual SourceRange getSourceRange() const;
1308
1309  static bool classof(const Stmt *T) {
1310    return T->getStmtClass() == CXXPseudoDestructorExprClass;
1311  }
1312  static bool classof(const CXXPseudoDestructorExpr *) { return true; }
1313
1314  // Iterators
1315  virtual child_iterator child_begin();
1316  virtual child_iterator child_end();
1317};
1318
1319/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the
1320/// implementation of TR1/C++0x type trait templates.
1321/// Example:
1322/// __is_pod(int) == true
1323/// __is_enum(std::string) == false
1324class UnaryTypeTraitExpr : public Expr {
1325  /// UTT - The trait.
1326  UnaryTypeTrait UTT;
1327
1328  /// Loc - The location of the type trait keyword.
1329  SourceLocation Loc;
1330
1331  /// RParen - The location of the closing paren.
1332  SourceLocation RParen;
1333
1334  /// QueriedType - The type we're testing.
1335  QualType QueriedType;
1336
1337public:
1338  UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, QualType queried,
1339                     SourceLocation rparen, QualType ty)
1340    : Expr(UnaryTypeTraitExprClass, ty, false, queried->isDependentType()),
1341      UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { }
1342
1343  explicit UnaryTypeTraitExpr(EmptyShell Empty)
1344    : Expr(UnaryTypeTraitExprClass, Empty), UTT((UnaryTypeTrait)0) { }
1345
1346  virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);}
1347
1348  UnaryTypeTrait getTrait() const { return UTT; }
1349
1350  QualType getQueriedType() const { return QueriedType; }
1351
1352  bool EvaluateTrait(ASTContext&) const;
1353
1354  static bool classof(const Stmt *T) {
1355    return T->getStmtClass() == UnaryTypeTraitExprClass;
1356  }
1357  static bool classof(const UnaryTypeTraitExpr *) { return true; }
1358
1359  // Iterators
1360  virtual child_iterator child_begin();
1361  virtual child_iterator child_end();
1362
1363  friend class PCHStmtReader;
1364};
1365
1366/// \brief A reference to an overloaded function set, either an
1367/// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr.
1368class OverloadExpr : public Expr {
1369  /// The results.  These are undesugared, which is to say, they may
1370  /// include UsingShadowDecls.  Access is relative to the naming
1371  /// class.
1372  // FIXME: Allocate this data after the OverloadExpr subclass.
1373  DeclAccessPair *Results;
1374  unsigned NumResults;
1375
1376  /// The common name of these declarations.
1377  DeclarationName Name;
1378
1379  /// The scope specifier, if any.
1380  NestedNameSpecifier *Qualifier;
1381
1382  /// The source range of the scope specifier.
1383  SourceRange QualifierRange;
1384
1385  /// The location of the name.
1386  SourceLocation NameLoc;
1387
1388protected:
1389  /// True if the name was a template-id.
1390  bool HasExplicitTemplateArgs;
1391
1392  OverloadExpr(StmtClass K, ASTContext &C, QualType T, bool Dependent,
1393               NestedNameSpecifier *Qualifier, SourceRange QRange,
1394               DeclarationName Name, SourceLocation NameLoc,
1395               bool HasTemplateArgs,
1396               UnresolvedSetIterator Begin, UnresolvedSetIterator End);
1397
1398  OverloadExpr(StmtClass K, EmptyShell Empty)
1399    : Expr(K, Empty), Results(0), NumResults(0),
1400      Qualifier(0), HasExplicitTemplateArgs(false) { }
1401
1402public:
1403  /// Computes whether an unresolved lookup on the given declarations
1404  /// and optional template arguments is type- and value-dependent.
1405  static bool ComputeDependence(UnresolvedSetIterator Begin,
1406                                UnresolvedSetIterator End,
1407                                const TemplateArgumentListInfo *Args);
1408
1409  /// Finds the overloaded expression in the given expression of
1410  /// OverloadTy.
1411  ///
1412  /// \return the expression (which must be there) and true if it is
1413  /// within an address-of operator.
1414  static llvm::PointerIntPair<OverloadExpr*,1> find(Expr *E) {
1415    assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload));
1416
1417    bool op = false;
1418    E = E->IgnoreParens();
1419    if (isa<UnaryOperator>(E))
1420      op = true, E = cast<UnaryOperator>(E)->getSubExpr()->IgnoreParens();
1421    return llvm::PointerIntPair<OverloadExpr*,1>(cast<OverloadExpr>(E), op);
1422  }
1423
1424  /// Gets the naming class of this lookup, if any.
1425  CXXRecordDecl *getNamingClass() const;
1426
1427  typedef UnresolvedSetImpl::iterator decls_iterator;
1428  decls_iterator decls_begin() const { return UnresolvedSetIterator(Results); }
1429  decls_iterator decls_end() const {
1430    return UnresolvedSetIterator(Results + NumResults);
1431  }
1432
1433  void initializeResults(ASTContext &C,
1434                         UnresolvedSetIterator Begin,UnresolvedSetIterator End);
1435
1436  /// Gets the number of declarations in the unresolved set.
1437  unsigned getNumDecls() const { return NumResults; }
1438
1439  /// Gets the name looked up.
1440  DeclarationName getName() const { return Name; }
1441  void setName(DeclarationName N) { Name = N; }
1442
1443  /// Gets the location of the name.
1444  SourceLocation getNameLoc() const { return NameLoc; }
1445  void setNameLoc(SourceLocation Loc) { NameLoc = Loc; }
1446
1447  /// Fetches the nested-name qualifier, if one was given.
1448  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1449  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
1450
1451  /// Fetches the range of the nested-name qualifier.
1452  SourceRange getQualifierRange() const { return QualifierRange; }
1453  void setQualifierRange(SourceRange R) { QualifierRange = R; }
1454
1455  /// \brief Determines whether this expression had an explicit
1456  /// template argument list, e.g. f<int>.
1457  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
1458
1459  ExplicitTemplateArgumentList &getExplicitTemplateArgs(); // defined far below
1460
1461  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1462    return const_cast<OverloadExpr*>(this)->getExplicitTemplateArgs();
1463  }
1464
1465  ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
1466    if (hasExplicitTemplateArgs())
1467      return &getExplicitTemplateArgs();
1468    return 0;
1469  }
1470
1471  static bool classof(const Stmt *T) {
1472    return T->getStmtClass() == UnresolvedLookupExprClass ||
1473           T->getStmtClass() == UnresolvedMemberExprClass;
1474  }
1475  static bool classof(const OverloadExpr *) { return true; }
1476};
1477
1478/// \brief A reference to a name which we were able to look up during
1479/// parsing but could not resolve to a specific declaration.  This
1480/// arises in several ways:
1481///   * we might be waiting for argument-dependent lookup
1482///   * the name might resolve to an overloaded function
1483/// and eventually:
1484///   * the lookup might have included a function template
1485/// These never include UnresolvedUsingValueDecls, which are always
1486/// class members and therefore appear only in
1487/// UnresolvedMemberLookupExprs.
1488class UnresolvedLookupExpr : public OverloadExpr {
1489  /// True if these lookup results should be extended by
1490  /// argument-dependent lookup if this is the operand of a function
1491  /// call.
1492  bool RequiresADL;
1493
1494  /// True if these lookup results are overloaded.  This is pretty
1495  /// trivially rederivable if we urgently need to kill this field.
1496  bool Overloaded;
1497
1498  /// The naming class (C++ [class.access.base]p5) of the lookup, if
1499  /// any.  This can generally be recalculated from the context chain,
1500  /// but that can be fairly expensive for unqualified lookups.  If we
1501  /// want to improve memory use here, this could go in a union
1502  /// against the qualified-lookup bits.
1503  CXXRecordDecl *NamingClass;
1504
1505  UnresolvedLookupExpr(ASTContext &C, QualType T, bool Dependent,
1506                       CXXRecordDecl *NamingClass,
1507                       NestedNameSpecifier *Qualifier, SourceRange QRange,
1508                       DeclarationName Name, SourceLocation NameLoc,
1509                       bool RequiresADL, bool Overloaded, bool HasTemplateArgs,
1510                       UnresolvedSetIterator Begin, UnresolvedSetIterator End)
1511    : OverloadExpr(UnresolvedLookupExprClass, C, T, Dependent, Qualifier,
1512                   QRange, Name, NameLoc, HasTemplateArgs, Begin, End),
1513      RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass)
1514  {}
1515
1516  UnresolvedLookupExpr(EmptyShell Empty)
1517    : OverloadExpr(UnresolvedLookupExprClass, Empty),
1518      RequiresADL(false), Overloaded(false), NamingClass(0)
1519  {}
1520
1521public:
1522  static UnresolvedLookupExpr *Create(ASTContext &C,
1523                                      bool Dependent,
1524                                      CXXRecordDecl *NamingClass,
1525                                      NestedNameSpecifier *Qualifier,
1526                                      SourceRange QualifierRange,
1527                                      DeclarationName Name,
1528                                      SourceLocation NameLoc,
1529                                      bool ADL, bool Overloaded,
1530                                      UnresolvedSetIterator Begin,
1531                                      UnresolvedSetIterator End) {
1532    return new(C) UnresolvedLookupExpr(C,
1533                                       Dependent ? C.DependentTy : C.OverloadTy,
1534                                       Dependent, NamingClass,
1535                                       Qualifier, QualifierRange,
1536                                       Name, NameLoc, ADL, Overloaded, false,
1537                                       Begin, End);
1538  }
1539
1540  static UnresolvedLookupExpr *Create(ASTContext &C,
1541                                      bool Dependent,
1542                                      CXXRecordDecl *NamingClass,
1543                                      NestedNameSpecifier *Qualifier,
1544                                      SourceRange QualifierRange,
1545                                      DeclarationName Name,
1546                                      SourceLocation NameLoc,
1547                                      bool ADL,
1548                                      const TemplateArgumentListInfo &Args,
1549                                      UnresolvedSetIterator Begin,
1550                                      UnresolvedSetIterator End);
1551
1552  static UnresolvedLookupExpr *CreateEmpty(ASTContext &C,
1553                                           unsigned NumTemplateArgs);
1554
1555  /// True if this declaration should be extended by
1556  /// argument-dependent lookup.
1557  bool requiresADL() const { return RequiresADL; }
1558  void setRequiresADL(bool V) { RequiresADL = V; }
1559
1560  /// True if this lookup is overloaded.
1561  bool isOverloaded() const { return Overloaded; }
1562  void setOverloaded(bool V) { Overloaded = V; }
1563
1564  /// Gets the 'naming class' (in the sense of C++0x
1565  /// [class.access.base]p5) of the lookup.  This is the scope
1566  /// that was looked in to find these results.
1567  CXXRecordDecl *getNamingClass() const { return NamingClass; }
1568  void setNamingClass(CXXRecordDecl *D) { NamingClass = D; }
1569
1570  // Note that, inconsistently with the explicit-template-argument AST
1571  // nodes, users are *forbidden* from calling these methods on objects
1572  // without explicit template arguments.
1573
1574  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
1575    assert(hasExplicitTemplateArgs());
1576    return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1);
1577  }
1578
1579  /// Gets a reference to the explicit template argument list.
1580  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1581    assert(hasExplicitTemplateArgs());
1582    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1583  }
1584
1585  /// \brief Copies the template arguments (if present) into the given
1586  /// structure.
1587  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1588    getExplicitTemplateArgs().copyInto(List);
1589  }
1590
1591  SourceLocation getLAngleLoc() const {
1592    return getExplicitTemplateArgs().LAngleLoc;
1593  }
1594
1595  SourceLocation getRAngleLoc() const {
1596    return getExplicitTemplateArgs().RAngleLoc;
1597  }
1598
1599  TemplateArgumentLoc const *getTemplateArgs() const {
1600    return getExplicitTemplateArgs().getTemplateArgs();
1601  }
1602
1603  unsigned getNumTemplateArgs() const {
1604    return getExplicitTemplateArgs().NumTemplateArgs;
1605  }
1606
1607  virtual SourceRange getSourceRange() const {
1608    SourceRange Range(getNameLoc());
1609    if (getQualifier()) Range.setBegin(getQualifierRange().getBegin());
1610    if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc());
1611    return Range;
1612  }
1613
1614  virtual StmtIterator child_begin();
1615  virtual StmtIterator child_end();
1616
1617  static bool classof(const Stmt *T) {
1618    return T->getStmtClass() == UnresolvedLookupExprClass;
1619  }
1620  static bool classof(const UnresolvedLookupExpr *) { return true; }
1621};
1622
1623/// \brief A qualified reference to a name whose declaration cannot
1624/// yet be resolved.
1625///
1626/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that
1627/// it expresses a reference to a declaration such as
1628/// X<T>::value. The difference, however, is that an
1629/// DependentScopeDeclRefExpr node is used only within C++ templates when
1630/// the qualification (e.g., X<T>::) refers to a dependent type. In
1631/// this case, X<T>::value cannot resolve to a declaration because the
1632/// declaration will differ from on instantiation of X<T> to the
1633/// next. Therefore, DependentScopeDeclRefExpr keeps track of the
1634/// qualifier (X<T>::) and the name of the entity being referenced
1635/// ("value"). Such expressions will instantiate to a DeclRefExpr once the
1636/// declaration can be found.
1637class DependentScopeDeclRefExpr : public Expr {
1638  /// The name of the entity we will be referencing.
1639  DeclarationName Name;
1640
1641  /// Location of the name of the declaration we're referencing.
1642  SourceLocation Loc;
1643
1644  /// QualifierRange - The source range that covers the
1645  /// nested-name-specifier.
1646  SourceRange QualifierRange;
1647
1648  /// \brief The nested-name-specifier that qualifies this unresolved
1649  /// declaration name.
1650  NestedNameSpecifier *Qualifier;
1651
1652  /// \brief Whether the name includes explicit template arguments.
1653  bool HasExplicitTemplateArgs;
1654
1655  DependentScopeDeclRefExpr(QualType T,
1656                            NestedNameSpecifier *Qualifier,
1657                            SourceRange QualifierRange,
1658                            DeclarationName Name,
1659                            SourceLocation NameLoc,
1660                            bool HasExplicitTemplateArgs)
1661    : Expr(DependentScopeDeclRefExprClass, T, true, true),
1662      Name(Name), Loc(NameLoc),
1663      QualifierRange(QualifierRange), Qualifier(Qualifier),
1664      HasExplicitTemplateArgs(HasExplicitTemplateArgs)
1665  {}
1666
1667public:
1668  static DependentScopeDeclRefExpr *Create(ASTContext &C,
1669                                           NestedNameSpecifier *Qualifier,
1670                                           SourceRange QualifierRange,
1671                                           DeclarationName Name,
1672                                           SourceLocation NameLoc,
1673                              const TemplateArgumentListInfo *TemplateArgs = 0);
1674
1675  static DependentScopeDeclRefExpr *CreateEmpty(ASTContext &C,
1676                                                unsigned NumTemplateArgs);
1677
1678  /// \brief Retrieve the name that this expression refers to.
1679  DeclarationName getDeclName() const { return Name; }
1680  void setDeclName(DeclarationName N) { Name =  N; }
1681
1682  /// \brief Retrieve the location of the name within the expression.
1683  SourceLocation getLocation() const { return Loc; }
1684  void setLocation(SourceLocation L) { Loc = L; }
1685
1686  /// \brief Retrieve the source range of the nested-name-specifier.
1687  SourceRange getQualifierRange() const { return QualifierRange; }
1688  void setQualifierRange(SourceRange R) { QualifierRange = R; }
1689
1690  /// \brief Retrieve the nested-name-specifier that qualifies this
1691  /// declaration.
1692  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1693  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
1694
1695  /// Determines whether this lookup had explicit template arguments.
1696  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
1697
1698  // Note that, inconsistently with the explicit-template-argument AST
1699  // nodes, users are *forbidden* from calling these methods on objects
1700  // without explicit template arguments.
1701
1702  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
1703    assert(hasExplicitTemplateArgs());
1704    return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1);
1705  }
1706
1707  /// Gets a reference to the explicit template argument list.
1708  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1709    assert(hasExplicitTemplateArgs());
1710    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1711  }
1712
1713  /// \brief Copies the template arguments (if present) into the given
1714  /// structure.
1715  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1716    getExplicitTemplateArgs().copyInto(List);
1717  }
1718
1719  SourceLocation getLAngleLoc() const {
1720    return getExplicitTemplateArgs().LAngleLoc;
1721  }
1722
1723  SourceLocation getRAngleLoc() const {
1724    return getExplicitTemplateArgs().RAngleLoc;
1725  }
1726
1727  TemplateArgumentLoc const *getTemplateArgs() const {
1728    return getExplicitTemplateArgs().getTemplateArgs();
1729  }
1730
1731  unsigned getNumTemplateArgs() const {
1732    return getExplicitTemplateArgs().NumTemplateArgs;
1733  }
1734
1735  virtual SourceRange getSourceRange() const {
1736    SourceRange Range(QualifierRange.getBegin(), getLocation());
1737    if (hasExplicitTemplateArgs())
1738      Range.setEnd(getRAngleLoc());
1739    return Range;
1740  }
1741
1742  static bool classof(const Stmt *T) {
1743    return T->getStmtClass() == DependentScopeDeclRefExprClass;
1744  }
1745  static bool classof(const DependentScopeDeclRefExpr *) { return true; }
1746
1747  virtual StmtIterator child_begin();
1748  virtual StmtIterator child_end();
1749};
1750
1751class CXXExprWithTemporaries : public Expr {
1752  Stmt *SubExpr;
1753
1754  CXXTemporary **Temps;
1755  unsigned NumTemps;
1756
1757  CXXExprWithTemporaries(ASTContext &C, Expr *SubExpr, CXXTemporary **Temps,
1758                         unsigned NumTemps);
1759
1760public:
1761  CXXExprWithTemporaries(EmptyShell Empty)
1762    : Expr(CXXExprWithTemporariesClass, Empty),
1763      SubExpr(0), Temps(0), NumTemps(0) {}
1764
1765  static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr,
1766                                        CXXTemporary **Temps,
1767                                        unsigned NumTemps);
1768
1769  unsigned getNumTemporaries() const { return NumTemps; }
1770  void setNumTemporaries(ASTContext &C, unsigned N);
1771
1772  CXXTemporary *getTemporary(unsigned i) {
1773    assert(i < NumTemps && "Index out of range");
1774    return Temps[i];
1775  }
1776  const CXXTemporary *getTemporary(unsigned i) const {
1777    return const_cast<CXXExprWithTemporaries*>(this)->getTemporary(i);
1778  }
1779  void setTemporary(unsigned i, CXXTemporary *T) {
1780    assert(i < NumTemps && "Index out of range");
1781    Temps[i] = T;
1782  }
1783
1784  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
1785  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
1786  void setSubExpr(Expr *E) { SubExpr = E; }
1787
1788  virtual SourceRange getSourceRange() const {
1789    return SubExpr->getSourceRange();
1790  }
1791
1792  // Implement isa/cast/dyncast/etc.
1793  static bool classof(const Stmt *T) {
1794    return T->getStmtClass() == CXXExprWithTemporariesClass;
1795  }
1796  static bool classof(const CXXExprWithTemporaries *) { return true; }
1797
1798  // Iterators
1799  virtual child_iterator child_begin();
1800  virtual child_iterator child_end();
1801};
1802
1803/// \brief Describes an explicit type conversion that uses functional
1804/// notion but could not be resolved because one or more arguments are
1805/// type-dependent.
1806///
1807/// The explicit type conversions expressed by
1808/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN),
1809/// where \c T is some type and \c a1, a2, ..., aN are values, and
1810/// either \C T is a dependent type or one or more of the \c a's is
1811/// type-dependent. For example, this would occur in a template such
1812/// as:
1813///
1814/// \code
1815///   template<typename T, typename A1>
1816///   inline T make_a(const A1& a1) {
1817///     return T(a1);
1818///   }
1819/// \endcode
1820///
1821/// When the returned expression is instantiated, it may resolve to a
1822/// constructor call, conversion function call, or some kind of type
1823/// conversion.
1824class CXXUnresolvedConstructExpr : public Expr {
1825  /// \brief The starting location of the type
1826  SourceLocation TyBeginLoc;
1827
1828  /// \brief The type being constructed.
1829  QualType Type;
1830
1831  /// \brief The location of the left parentheses ('(').
1832  SourceLocation LParenLoc;
1833
1834  /// \brief The location of the right parentheses (')').
1835  SourceLocation RParenLoc;
1836
1837  /// \brief The number of arguments used to construct the type.
1838  unsigned NumArgs;
1839
1840  CXXUnresolvedConstructExpr(SourceLocation TyBegin,
1841                             QualType T,
1842                             SourceLocation LParenLoc,
1843                             Expr **Args,
1844                             unsigned NumArgs,
1845                             SourceLocation RParenLoc);
1846
1847  CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs)
1848    : Expr(CXXUnresolvedConstructExprClass, Empty), NumArgs(NumArgs) { }
1849
1850public:
1851  static CXXUnresolvedConstructExpr *Create(ASTContext &C,
1852                                            SourceLocation TyBegin,
1853                                            QualType T,
1854                                            SourceLocation LParenLoc,
1855                                            Expr **Args,
1856                                            unsigned NumArgs,
1857                                            SourceLocation RParenLoc);
1858
1859  static CXXUnresolvedConstructExpr *CreateEmpty(ASTContext &C,
1860                                                 unsigned NumArgs);
1861
1862  /// \brief Retrieve the source location where the type begins.
1863  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
1864  void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; }
1865
1866  /// \brief Retrieve the type that is being constructed, as specified
1867  /// in the source code.
1868  QualType getTypeAsWritten() const { return Type; }
1869  void setTypeAsWritten(QualType T) { Type = T; }
1870
1871  /// \brief Retrieve the location of the left parentheses ('(') that
1872  /// precedes the argument list.
1873  SourceLocation getLParenLoc() const { return LParenLoc; }
1874  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
1875
1876  /// \brief Retrieve the location of the right parentheses (')') that
1877  /// follows the argument list.
1878  SourceLocation getRParenLoc() const { return RParenLoc; }
1879  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1880
1881  /// \brief Retrieve the number of arguments.
1882  unsigned arg_size() const { return NumArgs; }
1883
1884  typedef Expr** arg_iterator;
1885  arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); }
1886  arg_iterator arg_end() { return arg_begin() + NumArgs; }
1887
1888  typedef const Expr* const * const_arg_iterator;
1889  const_arg_iterator arg_begin() const {
1890    return reinterpret_cast<const Expr* const *>(this + 1);
1891  }
1892  const_arg_iterator arg_end() const {
1893    return arg_begin() + NumArgs;
1894  }
1895
1896  Expr *getArg(unsigned I) {
1897    assert(I < NumArgs && "Argument index out-of-range");
1898    return *(arg_begin() + I);
1899  }
1900
1901  const Expr *getArg(unsigned I) const {
1902    assert(I < NumArgs && "Argument index out-of-range");
1903    return *(arg_begin() + I);
1904  }
1905
1906  void setArg(unsigned I, Expr *E) {
1907    assert(I < NumArgs && "Argument index out-of-range");
1908    *(arg_begin() + I) = E;
1909  }
1910
1911  virtual SourceRange getSourceRange() const {
1912    return SourceRange(TyBeginLoc, RParenLoc);
1913  }
1914  static bool classof(const Stmt *T) {
1915    return T->getStmtClass() == CXXUnresolvedConstructExprClass;
1916  }
1917  static bool classof(const CXXUnresolvedConstructExpr *) { return true; }
1918
1919  // Iterators
1920  virtual child_iterator child_begin();
1921  virtual child_iterator child_end();
1922};
1923
1924/// \brief Represents a C++ member access expression where the actual
1925/// member referenced could not be resolved because the base
1926/// expression or the member name was dependent.
1927///
1928/// Like UnresolvedMemberExprs, these can be either implicit or
1929/// explicit accesses.  It is only possible to get one of these with
1930/// an implicit access if a qualifier is provided.
1931class CXXDependentScopeMemberExpr : public Expr {
1932  /// \brief The expression for the base pointer or class reference,
1933  /// e.g., the \c x in x.f.  Can be null in implicit accesses.
1934  Stmt *Base;
1935
1936  /// \brief The type of the base expression.  Never null, even for
1937  /// implicit accesses.
1938  QualType BaseType;
1939
1940  /// \brief Whether this member expression used the '->' operator or
1941  /// the '.' operator.
1942  bool IsArrow : 1;
1943
1944  /// \brief Whether this member expression has explicitly-specified template
1945  /// arguments.
1946  bool HasExplicitTemplateArgs : 1;
1947
1948  /// \brief The location of the '->' or '.' operator.
1949  SourceLocation OperatorLoc;
1950
1951  /// \brief The nested-name-specifier that precedes the member name, if any.
1952  NestedNameSpecifier *Qualifier;
1953
1954  /// \brief The source range covering the nested name specifier.
1955  SourceRange QualifierRange;
1956
1957  /// \brief In a qualified member access expression such as t->Base::f, this
1958  /// member stores the resolves of name lookup in the context of the member
1959  /// access expression, to be used at instantiation time.
1960  ///
1961  /// FIXME: This member, along with the Qualifier and QualifierRange, could
1962  /// be stuck into a structure that is optionally allocated at the end of
1963  /// the CXXDependentScopeMemberExpr, to save space in the common case.
1964  NamedDecl *FirstQualifierFoundInScope;
1965
1966  /// \brief The member to which this member expression refers, which
1967  /// can be name, overloaded operator, or destructor.
1968  /// FIXME: could also be a template-id
1969  DeclarationName Member;
1970
1971  /// \brief The location of the member name.
1972  SourceLocation MemberLoc;
1973
1974  CXXDependentScopeMemberExpr(ASTContext &C,
1975                          Expr *Base, QualType BaseType, bool IsArrow,
1976                          SourceLocation OperatorLoc,
1977                          NestedNameSpecifier *Qualifier,
1978                          SourceRange QualifierRange,
1979                          NamedDecl *FirstQualifierFoundInScope,
1980                          DeclarationName Member,
1981                          SourceLocation MemberLoc,
1982                          const TemplateArgumentListInfo *TemplateArgs);
1983
1984public:
1985  CXXDependentScopeMemberExpr(ASTContext &C,
1986                          Expr *Base, QualType BaseType,
1987                          bool IsArrow,
1988                          SourceLocation OperatorLoc,
1989                          NestedNameSpecifier *Qualifier,
1990                          SourceRange QualifierRange,
1991                          NamedDecl *FirstQualifierFoundInScope,
1992                          DeclarationName Member,
1993                          SourceLocation MemberLoc)
1994  : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, true, true),
1995    Base(Base), BaseType(BaseType), IsArrow(IsArrow),
1996    HasExplicitTemplateArgs(false), OperatorLoc(OperatorLoc),
1997    Qualifier(Qualifier), QualifierRange(QualifierRange),
1998    FirstQualifierFoundInScope(FirstQualifierFoundInScope),
1999    Member(Member), MemberLoc(MemberLoc) { }
2000
2001  static CXXDependentScopeMemberExpr *
2002  Create(ASTContext &C,
2003         Expr *Base, QualType BaseType, bool IsArrow,
2004         SourceLocation OperatorLoc,
2005         NestedNameSpecifier *Qualifier,
2006         SourceRange QualifierRange,
2007         NamedDecl *FirstQualifierFoundInScope,
2008         DeclarationName Member,
2009         SourceLocation MemberLoc,
2010         const TemplateArgumentListInfo *TemplateArgs);
2011
2012  static CXXDependentScopeMemberExpr *
2013  CreateEmpty(ASTContext &C, unsigned NumTemplateArgs);
2014
2015  /// \brief True if this is an implicit access, i.e. one in which the
2016  /// member being accessed was not written in the source.  The source
2017  /// location of the operator is invalid in this case.
2018  bool isImplicitAccess() const { return Base == 0; }
2019
2020  /// \brief Retrieve the base object of this member expressions,
2021  /// e.g., the \c x in \c x.m.
2022  Expr *getBase() const {
2023    assert(!isImplicitAccess());
2024    return cast<Expr>(Base);
2025  }
2026  void setBase(Expr *E) { Base = E; }
2027
2028  QualType getBaseType() const { return BaseType; }
2029  void setBaseType(QualType T) { BaseType = T; }
2030
2031  /// \brief Determine whether this member expression used the '->'
2032  /// operator; otherwise, it used the '.' operator.
2033  bool isArrow() const { return IsArrow; }
2034  void setArrow(bool A) { IsArrow = A; }
2035
2036  /// \brief Retrieve the location of the '->' or '.' operator.
2037  SourceLocation getOperatorLoc() const { return OperatorLoc; }
2038  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
2039
2040  /// \brief Retrieve the nested-name-specifier that qualifies the member
2041  /// name.
2042  NestedNameSpecifier *getQualifier() const { return Qualifier; }
2043  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
2044
2045  /// \brief Retrieve the source range covering the nested-name-specifier
2046  /// that qualifies the member name.
2047  SourceRange getQualifierRange() const { return QualifierRange; }
2048  void setQualifierRange(SourceRange R) { QualifierRange = R; }
2049
2050  /// \brief Retrieve the first part of the nested-name-specifier that was
2051  /// found in the scope of the member access expression when the member access
2052  /// was initially parsed.
2053  ///
2054  /// This function only returns a useful result when member access expression
2055  /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration
2056  /// returned by this function describes what was found by unqualified name
2057  /// lookup for the identifier "Base" within the scope of the member access
2058  /// expression itself. At template instantiation time, this information is
2059  /// combined with the results of name lookup into the type of the object
2060  /// expression itself (the class type of x).
2061  NamedDecl *getFirstQualifierFoundInScope() const {
2062    return FirstQualifierFoundInScope;
2063  }
2064  void setFirstQualifierFoundInScope(NamedDecl *D) {
2065    FirstQualifierFoundInScope = D;
2066  }
2067
2068  /// \brief Retrieve the name of the member that this expression
2069  /// refers to.
2070  DeclarationName getMember() const { return Member; }
2071  void setMember(DeclarationName N) { Member = N; }
2072
2073  // \brief Retrieve the location of the name of the member that this
2074  // expression refers to.
2075  SourceLocation getMemberLoc() const { return MemberLoc; }
2076  void setMemberLoc(SourceLocation L) { MemberLoc = L; }
2077
2078  /// \brief Determines whether this member expression actually had a C++
2079  /// template argument list explicitly specified, e.g., x.f<int>.
2080  bool hasExplicitTemplateArgs() const {
2081    return HasExplicitTemplateArgs;
2082  }
2083
2084  /// \brief Retrieve the explicit template argument list that followed the
2085  /// member template name, if any.
2086  ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() {
2087    assert(HasExplicitTemplateArgs);
2088    return reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
2089  }
2090
2091  /// \brief Retrieve the explicit template argument list that followed the
2092  /// member template name, if any.
2093  const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const {
2094    return const_cast<CXXDependentScopeMemberExpr *>(this)
2095             ->getExplicitTemplateArgumentList();
2096  }
2097
2098  /// \brief Copies the template arguments (if present) into the given
2099  /// structure.
2100  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
2101    assert(HasExplicitTemplateArgs);
2102    getExplicitTemplateArgumentList()->copyInto(List);
2103  }
2104
2105  /// \brief Initializes the template arguments using the given structure.
2106  void initializeTemplateArgumentsFrom(const TemplateArgumentListInfo &List) {
2107    assert(HasExplicitTemplateArgs);
2108    getExplicitTemplateArgumentList()->initializeFrom(List);
2109  }
2110
2111  /// \brief Retrieve the location of the left angle bracket following the
2112  /// member name ('<'), if any.
2113  SourceLocation getLAngleLoc() const {
2114    assert(HasExplicitTemplateArgs);
2115    return getExplicitTemplateArgumentList()->LAngleLoc;
2116  }
2117
2118  /// \brief Retrieve the template arguments provided as part of this
2119  /// template-id.
2120  const TemplateArgumentLoc *getTemplateArgs() const {
2121    assert(HasExplicitTemplateArgs);
2122    return getExplicitTemplateArgumentList()->getTemplateArgs();
2123  }
2124
2125  /// \brief Retrieve the number of template arguments provided as part of this
2126  /// template-id.
2127  unsigned getNumTemplateArgs() const {
2128    assert(HasExplicitTemplateArgs);
2129    return getExplicitTemplateArgumentList()->NumTemplateArgs;
2130  }
2131
2132  /// \brief Retrieve the location of the right angle bracket following the
2133  /// template arguments ('>').
2134  SourceLocation getRAngleLoc() const {
2135    assert(HasExplicitTemplateArgs);
2136    return getExplicitTemplateArgumentList()->RAngleLoc;
2137  }
2138
2139  virtual SourceRange getSourceRange() const {
2140    SourceRange Range;
2141    if (!isImplicitAccess())
2142      Range.setBegin(Base->getSourceRange().getBegin());
2143    else if (getQualifier())
2144      Range.setBegin(getQualifierRange().getBegin());
2145    else
2146      Range.setBegin(MemberLoc);
2147
2148    if (hasExplicitTemplateArgs())
2149      Range.setEnd(getRAngleLoc());
2150    else
2151      Range.setEnd(MemberLoc);
2152    return Range;
2153  }
2154
2155  static bool classof(const Stmt *T) {
2156    return T->getStmtClass() == CXXDependentScopeMemberExprClass;
2157  }
2158  static bool classof(const CXXDependentScopeMemberExpr *) { return true; }
2159
2160  // Iterators
2161  virtual child_iterator child_begin();
2162  virtual child_iterator child_end();
2163};
2164
2165/// \brief Represents a C++ member access expression for which lookup
2166/// produced a set of overloaded functions.
2167///
2168/// The member access may be explicit or implicit:
2169///    struct A {
2170///      int a, b;
2171///      int explicitAccess() { return this->a + this->A::b; }
2172///      int implicitAccess() { return a + A::b; }
2173///    };
2174///
2175/// In the final AST, an explicit access always becomes a MemberExpr.
2176/// An implicit access may become either a MemberExpr or a
2177/// DeclRefExpr, depending on whether the member is static.
2178class UnresolvedMemberExpr : public OverloadExpr {
2179  /// \brief Whether this member expression used the '->' operator or
2180  /// the '.' operator.
2181  bool IsArrow : 1;
2182
2183  /// \brief Whether the lookup results contain an unresolved using
2184  /// declaration.
2185  bool HasUnresolvedUsing : 1;
2186
2187  /// \brief The expression for the base pointer or class reference,
2188  /// e.g., the \c x in x.f.  This can be null if this is an 'unbased'
2189  /// member expression
2190  Stmt *Base;
2191
2192  /// \brief The type of the base expression;  never null.
2193  QualType BaseType;
2194
2195  /// \brief The location of the '->' or '.' operator.
2196  SourceLocation OperatorLoc;
2197
2198  UnresolvedMemberExpr(ASTContext &C, QualType T, bool Dependent,
2199                       bool HasUnresolvedUsing,
2200                       Expr *Base, QualType BaseType, bool IsArrow,
2201                       SourceLocation OperatorLoc,
2202                       NestedNameSpecifier *Qualifier,
2203                       SourceRange QualifierRange,
2204                       DeclarationName Member,
2205                       SourceLocation MemberLoc,
2206                       const TemplateArgumentListInfo *TemplateArgs,
2207                       UnresolvedSetIterator Begin, UnresolvedSetIterator End);
2208
2209  UnresolvedMemberExpr(EmptyShell Empty)
2210    : OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false),
2211      HasUnresolvedUsing(false), Base(0) { }
2212
2213public:
2214  static UnresolvedMemberExpr *
2215  Create(ASTContext &C, bool Dependent, bool HasUnresolvedUsing,
2216         Expr *Base, QualType BaseType, bool IsArrow,
2217         SourceLocation OperatorLoc,
2218         NestedNameSpecifier *Qualifier,
2219         SourceRange QualifierRange,
2220         DeclarationName Member,
2221         SourceLocation MemberLoc,
2222         const TemplateArgumentListInfo *TemplateArgs,
2223         UnresolvedSetIterator Begin, UnresolvedSetIterator End);
2224
2225  static UnresolvedMemberExpr *
2226  CreateEmpty(ASTContext &C, unsigned NumTemplateArgs);
2227
2228  /// \brief True if this is an implicit access, i.e. one in which the
2229  /// member being accessed was not written in the source.  The source
2230  /// location of the operator is invalid in this case.
2231  bool isImplicitAccess() const { return Base == 0; }
2232
2233  /// \brief Retrieve the base object of this member expressions,
2234  /// e.g., the \c x in \c x.m.
2235  Expr *getBase() {
2236    assert(!isImplicitAccess());
2237    return cast<Expr>(Base);
2238  }
2239  const Expr *getBase() const {
2240    assert(!isImplicitAccess());
2241    return cast<Expr>(Base);
2242  }
2243  void setBase(Expr *E) { Base = E; }
2244
2245  QualType getBaseType() const { return BaseType; }
2246  void setBaseType(QualType T) { BaseType = T; }
2247
2248  /// \brief Determine whether the lookup results contain an unresolved using
2249  /// declaration.
2250  bool hasUnresolvedUsing() const { return HasUnresolvedUsing; }
2251  void setHasUnresolvedUsing(bool V) { HasUnresolvedUsing = V; }
2252
2253  /// \brief Determine whether this member expression used the '->'
2254  /// operator; otherwise, it used the '.' operator.
2255  bool isArrow() const { return IsArrow; }
2256  void setArrow(bool A) { IsArrow = A; }
2257
2258  /// \brief Retrieve the location of the '->' or '.' operator.
2259  SourceLocation getOperatorLoc() const { return OperatorLoc; }
2260  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
2261
2262  /// \brief Retrieves the naming class of this lookup.
2263  CXXRecordDecl *getNamingClass() const;
2264
2265  /// \brief Retrieve the name of the member that this expression
2266  /// refers to.
2267  DeclarationName getMemberName() const { return getName(); }
2268  void setMemberName(DeclarationName N) { setName(N); }
2269
2270  // \brief Retrieve the location of the name of the member that this
2271  // expression refers to.
2272  SourceLocation getMemberLoc() const { return getNameLoc(); }
2273  void setMemberLoc(SourceLocation L) { setNameLoc(L); }
2274
2275  /// \brief Retrieve the explicit template argument list that followed the
2276  /// member template name.
2277  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
2278    assert(hasExplicitTemplateArgs());
2279    return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
2280  }
2281
2282  /// \brief Retrieve the explicit template argument list that followed the
2283  /// member template name, if any.
2284  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
2285    assert(hasExplicitTemplateArgs());
2286    return *reinterpret_cast<const ExplicitTemplateArgumentList *>(this + 1);
2287  }
2288
2289  /// \brief Copies the template arguments into the given structure.
2290  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
2291    getExplicitTemplateArgs().copyInto(List);
2292  }
2293
2294  /// \brief Retrieve the location of the left angle bracket following
2295  /// the member name ('<').
2296  SourceLocation getLAngleLoc() const {
2297    return getExplicitTemplateArgs().LAngleLoc;
2298  }
2299
2300  /// \brief Retrieve the template arguments provided as part of this
2301  /// template-id.
2302  const TemplateArgumentLoc *getTemplateArgs() const {
2303    return getExplicitTemplateArgs().getTemplateArgs();
2304  }
2305
2306  /// \brief Retrieve the number of template arguments provided as
2307  /// part of this template-id.
2308  unsigned getNumTemplateArgs() const {
2309    return getExplicitTemplateArgs().NumTemplateArgs;
2310  }
2311
2312  /// \brief Retrieve the location of the right angle bracket
2313  /// following the template arguments ('>').
2314  SourceLocation getRAngleLoc() const {
2315    return getExplicitTemplateArgs().RAngleLoc;
2316  }
2317
2318  virtual SourceRange getSourceRange() const {
2319    SourceRange Range;
2320    if (!isImplicitAccess())
2321      Range.setBegin(Base->getSourceRange().getBegin());
2322    else if (getQualifier())
2323      Range.setBegin(getQualifierRange().getBegin());
2324    else
2325      Range.setBegin(getMemberLoc());
2326
2327    if (hasExplicitTemplateArgs())
2328      Range.setEnd(getRAngleLoc());
2329    else
2330      Range.setEnd(getMemberLoc());
2331    return Range;
2332  }
2333
2334  static bool classof(const Stmt *T) {
2335    return T->getStmtClass() == UnresolvedMemberExprClass;
2336  }
2337  static bool classof(const UnresolvedMemberExpr *) { return true; }
2338
2339  // Iterators
2340  virtual child_iterator child_begin();
2341  virtual child_iterator child_end();
2342};
2343
2344inline ExplicitTemplateArgumentList &OverloadExpr::getExplicitTemplateArgs() {
2345  if (isa<UnresolvedLookupExpr>(this))
2346    return cast<UnresolvedLookupExpr>(this)->getExplicitTemplateArgs();
2347  else
2348    return cast<UnresolvedMemberExpr>(this)->getExplicitTemplateArgs();
2349}
2350
2351}  // end namespace clang
2352
2353#endif
2354