ExprCXX.h revision ff331c15729f7d4439d253c97f4d60f2a7ffd0c6
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  ~CXXTemporary() { }
547
548public:
549  static CXXTemporary *Create(ASTContext &C,
550                              const CXXDestructorDecl *Destructor);
551
552  const CXXDestructorDecl *getDestructor() const { return Destructor; }
553};
554
555/// \brief Represents binding an expression to a temporary.
556///
557/// This ensures the destructor is called for the temporary. It should only be
558/// needed for non-POD, non-trivially destructable class types. For example:
559///
560/// \code
561///   struct S {
562///     S() { }  // User defined constructor makes S non-POD.
563///     ~S() { } // User defined destructor makes it non-trivial.
564///   };
565///   void test() {
566///     const S &s_ref = S(); // Requires a CXXBindTemporaryExpr.
567///   }
568/// \endcode
569class CXXBindTemporaryExpr : public Expr {
570  CXXTemporary *Temp;
571
572  Stmt *SubExpr;
573
574  CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr)
575   : Expr(CXXBindTemporaryExprClass, subexpr->getType(), false, false),
576     Temp(temp), SubExpr(subexpr) { }
577  ~CXXBindTemporaryExpr() { }
578
579public:
580  CXXBindTemporaryExpr(EmptyShell Empty)
581    : Expr(CXXBindTemporaryExprClass, Empty), Temp(0), SubExpr(0) {}
582
583  static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp,
584                                      Expr* SubExpr);
585
586  CXXTemporary *getTemporary() { return Temp; }
587  const CXXTemporary *getTemporary() const { return Temp; }
588  void setTemporary(CXXTemporary *T) { Temp = T; }
589
590  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
591  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
592  void setSubExpr(Expr *E) { SubExpr = E; }
593
594  virtual SourceRange getSourceRange() const {
595    return SubExpr->getSourceRange();
596  }
597
598  // Implement isa/cast/dyncast/etc.
599  static bool classof(const Stmt *T) {
600    return T->getStmtClass() == CXXBindTemporaryExprClass;
601  }
602  static bool classof(const CXXBindTemporaryExpr *) { return true; }
603
604  // Iterators
605  virtual child_iterator child_begin();
606  virtual child_iterator child_end();
607};
608
609/// CXXBindReferenceExpr - Represents binding an expression to a reference.
610/// In the example:
611///
612/// const int &i = 10;
613///
614/// a bind reference expression is inserted to indicate that 10 is bound to
615/// a reference, and that a temporary needs to be created to hold the
616/// value.
617class CXXBindReferenceExpr : public Expr {
618  // SubExpr - The expression being bound.
619  Stmt *SubExpr;
620
621  // ExtendsLifetime - Whether binding this reference extends the lifetime of
622  // the expression being bound. FIXME: Add C++ reference.
623  bool ExtendsLifetime;
624
625  /// RequiresTemporaryCopy - Whether binding the subexpression requires a
626  /// temporary copy.
627  bool RequiresTemporaryCopy;
628
629  CXXBindReferenceExpr(Expr *subexpr, bool ExtendsLifetime,
630                       bool RequiresTemporaryCopy)
631  : Expr(CXXBindReferenceExprClass, subexpr->getType(), false, false),
632    SubExpr(subexpr), ExtendsLifetime(ExtendsLifetime),
633    RequiresTemporaryCopy(RequiresTemporaryCopy) { }
634  ~CXXBindReferenceExpr() { }
635
636public:
637  static CXXBindReferenceExpr *Create(ASTContext &C, Expr *SubExpr,
638                                      bool ExtendsLifetime,
639                                      bool RequiresTemporaryCopy);
640
641  explicit CXXBindReferenceExpr(EmptyShell Empty)
642    : Expr(CXXBindReferenceExprClass, Empty) { }
643
644  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
645  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
646  void setSubExpr(Expr *E) { SubExpr = E; }
647
648  virtual SourceRange getSourceRange() const {
649    return SubExpr->getSourceRange();
650  }
651
652  /// requiresTemporaryCopy - Whether binding the subexpression requires a
653  /// temporary copy.
654  bool requiresTemporaryCopy() const { return RequiresTemporaryCopy; }
655
656  // extendsLifetime - Whether binding this reference extends the lifetime of
657  // the expression being bound. FIXME: Add C++ reference.
658  bool extendsLifetime() const { return ExtendsLifetime; }
659
660  // Implement isa/cast/dyncast/etc.
661  static bool classof(const Stmt *T) {
662    return T->getStmtClass() == CXXBindReferenceExprClass;
663  }
664  static bool classof(const CXXBindReferenceExpr *) { return true; }
665
666  // Iterators
667  virtual child_iterator child_begin();
668  virtual child_iterator child_end();
669
670  friend class PCHStmtReader;
671};
672
673/// CXXConstructExpr - Represents a call to a C++ constructor.
674class CXXConstructExpr : public Expr {
675public:
676  enum ConstructionKind {
677    CK_Complete,
678    CK_NonVirtualBase,
679    CK_VirtualBase
680  };
681
682private:
683  CXXConstructorDecl *Constructor;
684
685  SourceLocation Loc;
686  bool Elidable : 1;
687  bool ZeroInitialization : 1;
688  unsigned ConstructKind : 2;
689  Stmt **Args;
690  unsigned NumArgs;
691
692protected:
693  CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
694                   SourceLocation Loc,
695                   CXXConstructorDecl *d, bool elidable,
696                   Expr **args, unsigned numargs,
697                   bool ZeroInitialization = false,
698                   ConstructionKind ConstructKind = CK_Complete);
699  ~CXXConstructExpr() { }
700
701  /// \brief Construct an empty C++ construction expression.
702  CXXConstructExpr(StmtClass SC, EmptyShell Empty)
703    : Expr(SC, Empty), Constructor(0), Elidable(0), ZeroInitialization(0),
704      ConstructKind(0), Args(0), NumArgs(0) { }
705
706public:
707  /// \brief Construct an empty C++ construction expression.
708  explicit CXXConstructExpr(EmptyShell Empty)
709    : Expr(CXXConstructExprClass, Empty), Constructor(0),
710      Elidable(0), ZeroInitialization(0),
711      ConstructKind(0), Args(0), NumArgs(0) { }
712
713  static CXXConstructExpr *Create(ASTContext &C, QualType T,
714                                  SourceLocation Loc,
715                                  CXXConstructorDecl *D, bool Elidable,
716                                  Expr **Args, unsigned NumArgs,
717                                  bool ZeroInitialization = false,
718                                  ConstructionKind ConstructKind = CK_Complete);
719
720
721  CXXConstructorDecl* getConstructor() const { return Constructor; }
722  void setConstructor(CXXConstructorDecl *C) { Constructor = C; }
723
724  SourceLocation getLocation() const { return Loc; }
725  void setLocation(SourceLocation Loc) { this->Loc = Loc; }
726
727  /// \brief Whether this construction is elidable.
728  bool isElidable() const { return Elidable; }
729  void setElidable(bool E) { Elidable = E; }
730
731  /// \brief Whether this construction first requires
732  /// zero-initialization before the initializer is called.
733  bool requiresZeroInitialization() const { return ZeroInitialization; }
734  void setRequiresZeroInitialization(bool ZeroInit) {
735    ZeroInitialization = ZeroInit;
736  }
737
738  /// \brief Determines whether this constructor is actually constructing
739  /// a base class (rather than a complete object).
740  ConstructionKind getConstructionKind() const {
741    return (ConstructionKind)ConstructKind;
742  }
743  void setConstructionKind(ConstructionKind CK) {
744    ConstructKind = CK;
745  }
746
747  typedef ExprIterator arg_iterator;
748  typedef ConstExprIterator const_arg_iterator;
749
750  arg_iterator arg_begin() { return Args; }
751  arg_iterator arg_end() { return Args + NumArgs; }
752  const_arg_iterator arg_begin() const { return Args; }
753  const_arg_iterator arg_end() const { return Args + NumArgs; }
754
755  Expr **getArgs() const { return reinterpret_cast<Expr **>(Args); }
756  unsigned getNumArgs() const { return NumArgs; }
757
758  /// getArg - Return the specified argument.
759  Expr *getArg(unsigned Arg) {
760    assert(Arg < NumArgs && "Arg access out of range!");
761    return cast<Expr>(Args[Arg]);
762  }
763  const Expr *getArg(unsigned Arg) const {
764    assert(Arg < NumArgs && "Arg access out of range!");
765    return cast<Expr>(Args[Arg]);
766  }
767
768  /// setArg - Set the specified argument.
769  void setArg(unsigned Arg, Expr *ArgExpr) {
770    assert(Arg < NumArgs && "Arg access out of range!");
771    Args[Arg] = ArgExpr;
772  }
773
774  virtual SourceRange getSourceRange() const;
775
776  static bool classof(const Stmt *T) {
777    return T->getStmtClass() == CXXConstructExprClass ||
778      T->getStmtClass() == CXXTemporaryObjectExprClass;
779  }
780  static bool classof(const CXXConstructExpr *) { return true; }
781
782  // Iterators
783  virtual child_iterator child_begin();
784  virtual child_iterator child_end();
785
786  friend class PCHStmtReader;
787};
788
789/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion
790/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c
791/// x = int(0.5);
792class CXXFunctionalCastExpr : public ExplicitCastExpr {
793  SourceLocation TyBeginLoc;
794  SourceLocation RParenLoc;
795public:
796  CXXFunctionalCastExpr(QualType ty, TypeSourceInfo *writtenTy,
797                        SourceLocation tyBeginLoc, CastKind kind,
798                        Expr *castExpr, CXXBaseSpecifierArray BasePath,
799                        SourceLocation rParenLoc)
800    : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, kind, castExpr,
801                       BasePath, writtenTy),
802      TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
803
804  explicit CXXFunctionalCastExpr(EmptyShell Shell)
805    : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell) { }
806
807  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
808  void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; }
809  SourceLocation getRParenLoc() const { return RParenLoc; }
810  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
811
812  virtual SourceRange getSourceRange() const {
813    return SourceRange(TyBeginLoc, RParenLoc);
814  }
815  static bool classof(const Stmt *T) {
816    return T->getStmtClass() == CXXFunctionalCastExprClass;
817  }
818  static bool classof(const CXXFunctionalCastExpr *) { return true; }
819};
820
821/// @brief Represents a C++ functional cast expression that builds a
822/// temporary object.
823///
824/// This expression type represents a C++ "functional" cast
825/// (C++[expr.type.conv]) with N != 1 arguments that invokes a
826/// constructor to build a temporary object. With N == 1 arguments the
827/// functional cast expression will be represented by CXXFunctionalCastExpr.
828/// Example:
829/// @code
830/// struct X { X(int, float); }
831///
832/// X create_X() {
833///   return X(1, 3.14f); // creates a CXXTemporaryObjectExpr
834/// };
835/// @endcode
836class CXXTemporaryObjectExpr : public CXXConstructExpr {
837  SourceLocation TyBeginLoc;
838  SourceLocation RParenLoc;
839
840public:
841  CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons,
842                         QualType writtenTy, SourceLocation tyBeginLoc,
843                         Expr **Args,unsigned NumArgs,
844                         SourceLocation rParenLoc,
845                         bool ZeroInitialization = false);
846  explicit CXXTemporaryObjectExpr(EmptyShell Empty)
847    : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty) { }
848
849  ~CXXTemporaryObjectExpr() { }
850
851  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
852  SourceLocation getRParenLoc() const { return RParenLoc; }
853
854  virtual SourceRange getSourceRange() const {
855    return SourceRange(TyBeginLoc, RParenLoc);
856  }
857  static bool classof(const Stmt *T) {
858    return T->getStmtClass() == CXXTemporaryObjectExprClass;
859  }
860  static bool classof(const CXXTemporaryObjectExpr *) { return true; }
861
862  friend class PCHStmtReader;
863};
864
865/// CXXScalarValueInitExpr - [C++ 5.2.3p2]
866/// Expression "T()" which creates a value-initialized rvalue of type
867/// T, which is a non-class type.
868///
869class CXXScalarValueInitExpr : public Expr {
870  SourceLocation TyBeginLoc;
871  SourceLocation RParenLoc;
872
873public:
874  CXXScalarValueInitExpr(QualType ty, SourceLocation tyBeginLoc,
875                       SourceLocation rParenLoc ) :
876    Expr(CXXScalarValueInitExprClass, ty, false, false),
877    TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
878  explicit CXXScalarValueInitExpr(EmptyShell Shell)
879    : Expr(CXXScalarValueInitExprClass, Shell) { }
880
881  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
882  SourceLocation getRParenLoc() const { return RParenLoc; }
883
884  void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; }
885  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
886
887  /// @brief Whether this initialization expression was
888  /// implicitly-generated.
889  bool isImplicit() const {
890    return TyBeginLoc.isInvalid() && RParenLoc.isInvalid();
891  }
892
893  virtual SourceRange getSourceRange() const {
894    return SourceRange(TyBeginLoc, RParenLoc);
895  }
896
897  static bool classof(const Stmt *T) {
898    return T->getStmtClass() == CXXScalarValueInitExprClass;
899  }
900  static bool classof(const CXXScalarValueInitExpr *) { return true; }
901
902  // Iterators
903  virtual child_iterator child_begin();
904  virtual child_iterator child_end();
905};
906
907/// CXXNewExpr - A new expression for memory allocation and constructor calls,
908/// e.g: "new CXXNewExpr(foo)".
909class CXXNewExpr : public Expr {
910  // Was the usage ::new, i.e. is the global new to be used?
911  bool GlobalNew : 1;
912  // Is there an initializer? If not, built-ins are uninitialized, else they're
913  // value-initialized.
914  bool Initializer : 1;
915  // Do we allocate an array? If so, the first SubExpr is the size expression.
916  bool Array : 1;
917  // The number of placement new arguments.
918  unsigned NumPlacementArgs : 15;
919  // The number of constructor arguments. This may be 1 even for non-class
920  // types; use the pseudo copy constructor.
921  unsigned NumConstructorArgs : 14;
922  // Contains an optional array size expression, any number of optional
923  // placement arguments, and any number of optional constructor arguments,
924  // in that order.
925  Stmt **SubExprs;
926  // Points to the allocation function used.
927  FunctionDecl *OperatorNew;
928  // Points to the deallocation function used in case of error. May be null.
929  FunctionDecl *OperatorDelete;
930  // Points to the constructor used. Cannot be null if AllocType is a record;
931  // it would still point at the default constructor (even an implicit one).
932  // Must be null for all other types.
933  CXXConstructorDecl *Constructor;
934
935  /// \brief If the allocated type was expressed as a parenthesized type-id,
936  /// the source range covering the parenthesized type-id.
937  SourceRange TypeIdParens;
938
939  SourceLocation StartLoc;
940  SourceLocation EndLoc;
941
942  friend class PCHStmtReader;
943public:
944  CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
945             Expr **placementArgs, unsigned numPlaceArgs,
946             SourceRange TypeIdParens,
947             Expr *arraySize, CXXConstructorDecl *constructor, bool initializer,
948             Expr **constructorArgs, unsigned numConsArgs,
949             FunctionDecl *operatorDelete, QualType ty,
950             SourceLocation startLoc, SourceLocation endLoc);
951  explicit CXXNewExpr(EmptyShell Shell)
952    : Expr(CXXNewExprClass, Shell), SubExprs(0) { }
953
954  void AllocateArgsArray(ASTContext &C, bool isArray, unsigned numPlaceArgs,
955                         unsigned numConsArgs);
956
957  QualType getAllocatedType() const {
958    assert(getType()->isPointerType());
959    return getType()->getAs<PointerType>()->getPointeeType();
960  }
961
962  FunctionDecl *getOperatorNew() const { return OperatorNew; }
963  void setOperatorNew(FunctionDecl *D) { OperatorNew = D; }
964  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
965  void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; }
966  CXXConstructorDecl *getConstructor() const { return Constructor; }
967  void setConstructor(CXXConstructorDecl *D) { Constructor = D; }
968
969  bool isArray() const { return Array; }
970  Expr *getArraySize() {
971    return Array ? cast<Expr>(SubExprs[0]) : 0;
972  }
973  const Expr *getArraySize() const {
974    return Array ? cast<Expr>(SubExprs[0]) : 0;
975  }
976
977  unsigned getNumPlacementArgs() const { return NumPlacementArgs; }
978  Expr *getPlacementArg(unsigned i) {
979    assert(i < NumPlacementArgs && "Index out of range");
980    return cast<Expr>(SubExprs[Array + i]);
981  }
982  const Expr *getPlacementArg(unsigned i) const {
983    assert(i < NumPlacementArgs && "Index out of range");
984    return cast<Expr>(SubExprs[Array + i]);
985  }
986
987  bool isParenTypeId() const { return TypeIdParens.isValid(); }
988  SourceRange getTypeIdParens() const { return TypeIdParens; }
989
990  bool isGlobalNew() const { return GlobalNew; }
991  void setGlobalNew(bool V) { GlobalNew = V; }
992  bool hasInitializer() const { return Initializer; }
993  void setHasInitializer(bool V) { Initializer = V; }
994
995  unsigned getNumConstructorArgs() const { return NumConstructorArgs; }
996  Expr *getConstructorArg(unsigned i) {
997    assert(i < NumConstructorArgs && "Index out of range");
998    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
999  }
1000  const Expr *getConstructorArg(unsigned i) const {
1001    assert(i < NumConstructorArgs && "Index out of range");
1002    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
1003  }
1004
1005  typedef ExprIterator arg_iterator;
1006  typedef ConstExprIterator const_arg_iterator;
1007
1008  arg_iterator placement_arg_begin() {
1009    return SubExprs + Array;
1010  }
1011  arg_iterator placement_arg_end() {
1012    return SubExprs + Array + getNumPlacementArgs();
1013  }
1014  const_arg_iterator placement_arg_begin() const {
1015    return SubExprs + Array;
1016  }
1017  const_arg_iterator placement_arg_end() const {
1018    return SubExprs + Array + getNumPlacementArgs();
1019  }
1020
1021  arg_iterator constructor_arg_begin() {
1022    return SubExprs + Array + getNumPlacementArgs();
1023  }
1024  arg_iterator constructor_arg_end() {
1025    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
1026  }
1027  const_arg_iterator constructor_arg_begin() const {
1028    return SubExprs + Array + getNumPlacementArgs();
1029  }
1030  const_arg_iterator constructor_arg_end() const {
1031    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
1032  }
1033
1034  typedef Stmt **raw_arg_iterator;
1035  raw_arg_iterator raw_arg_begin() { return SubExprs; }
1036  raw_arg_iterator raw_arg_end() {
1037    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
1038  }
1039  const_arg_iterator raw_arg_begin() const { return SubExprs; }
1040  const_arg_iterator raw_arg_end() const { return constructor_arg_end(); }
1041
1042
1043  SourceLocation getStartLoc() const { return StartLoc; }
1044  void setStartLoc(SourceLocation L) { StartLoc = L; }
1045  SourceLocation getEndLoc() const { return EndLoc; }
1046  void setEndLoc(SourceLocation L) { EndLoc = L; }
1047
1048  virtual SourceRange getSourceRange() const {
1049    return SourceRange(StartLoc, EndLoc);
1050  }
1051
1052  static bool classof(const Stmt *T) {
1053    return T->getStmtClass() == CXXNewExprClass;
1054  }
1055  static bool classof(const CXXNewExpr *) { return true; }
1056
1057  // Iterators
1058  virtual child_iterator child_begin();
1059  virtual child_iterator child_end();
1060};
1061
1062/// CXXDeleteExpr - A delete expression for memory deallocation and destructor
1063/// calls, e.g. "delete[] pArray".
1064class CXXDeleteExpr : public Expr {
1065  // Is this a forced global delete, i.e. "::delete"?
1066  bool GlobalDelete : 1;
1067  // Is this the array form of delete, i.e. "delete[]"?
1068  bool ArrayForm : 1;
1069  // Points to the operator delete overload that is used. Could be a member.
1070  FunctionDecl *OperatorDelete;
1071  // The pointer expression to be deleted.
1072  Stmt *Argument;
1073  // Location of the expression.
1074  SourceLocation Loc;
1075public:
1076  CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm,
1077                FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc)
1078    : Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete),
1079      ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg),
1080      Loc(loc) { }
1081  explicit CXXDeleteExpr(EmptyShell Shell)
1082    : Expr(CXXDeleteExprClass, Shell), OperatorDelete(0), Argument(0) { }
1083
1084  bool isGlobalDelete() const { return GlobalDelete; }
1085  bool isArrayForm() const { return ArrayForm; }
1086
1087  void setGlobalDelete(bool V) { GlobalDelete = V; }
1088  void setArrayForm(bool V) { ArrayForm = V; }
1089
1090  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
1091  void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; }
1092
1093  Expr *getArgument() { return cast<Expr>(Argument); }
1094  const Expr *getArgument() const { return cast<Expr>(Argument); }
1095  void setArgument(Expr *E) { Argument = E; }
1096
1097  virtual SourceRange getSourceRange() const {
1098    return SourceRange(Loc, Argument->getLocEnd());
1099  }
1100  void setStartLoc(SourceLocation L) { Loc = L; }
1101
1102  static bool classof(const Stmt *T) {
1103    return T->getStmtClass() == CXXDeleteExprClass;
1104  }
1105  static bool classof(const CXXDeleteExpr *) { return true; }
1106
1107  // Iterators
1108  virtual child_iterator child_begin();
1109  virtual child_iterator child_end();
1110};
1111
1112/// \brief Structure used to store the type being destroyed by a
1113/// pseudo-destructor expression.
1114class PseudoDestructorTypeStorage {
1115  /// \brief Either the type source information or the name of the type, if
1116  /// it couldn't be resolved due to type-dependence.
1117  llvm::PointerUnion<TypeSourceInfo *, IdentifierInfo *> Type;
1118
1119  /// \brief The starting source location of the pseudo-destructor type.
1120  SourceLocation Location;
1121
1122public:
1123  PseudoDestructorTypeStorage() { }
1124
1125  PseudoDestructorTypeStorage(IdentifierInfo *II, SourceLocation Loc)
1126    : Type(II), Location(Loc) { }
1127
1128  PseudoDestructorTypeStorage(TypeSourceInfo *Info);
1129
1130  TypeSourceInfo *getTypeSourceInfo() const {
1131    return Type.dyn_cast<TypeSourceInfo *>();
1132  }
1133
1134  IdentifierInfo *getIdentifier() const {
1135    return Type.dyn_cast<IdentifierInfo *>();
1136  }
1137
1138  SourceLocation getLocation() const { return Location; }
1139};
1140
1141/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
1142///
1143/// A pseudo-destructor is an expression that looks like a member access to a
1144/// destructor of a scalar type, except that scalar types don't have
1145/// destructors. For example:
1146///
1147/// \code
1148/// typedef int T;
1149/// void f(int *p) {
1150///   p->T::~T();
1151/// }
1152/// \endcode
1153///
1154/// Pseudo-destructors typically occur when instantiating templates such as:
1155///
1156/// \code
1157/// template<typename T>
1158/// void destroy(T* ptr) {
1159///   ptr->T::~T();
1160/// }
1161/// \endcode
1162///
1163/// for scalar types. A pseudo-destructor expression has no run-time semantics
1164/// beyond evaluating the base expression.
1165class CXXPseudoDestructorExpr : public Expr {
1166  /// \brief The base expression (that is being destroyed).
1167  Stmt *Base;
1168
1169  /// \brief Whether the operator was an arrow ('->'); otherwise, it was a
1170  /// period ('.').
1171  bool IsArrow : 1;
1172
1173  /// \brief The location of the '.' or '->' operator.
1174  SourceLocation OperatorLoc;
1175
1176  /// \brief The nested-name-specifier that follows the operator, if present.
1177  NestedNameSpecifier *Qualifier;
1178
1179  /// \brief The source range that covers the nested-name-specifier, if
1180  /// present.
1181  SourceRange QualifierRange;
1182
1183  /// \brief The type that precedes the '::' in a qualified pseudo-destructor
1184  /// expression.
1185  TypeSourceInfo *ScopeType;
1186
1187  /// \brief The location of the '::' in a qualified pseudo-destructor
1188  /// expression.
1189  SourceLocation ColonColonLoc;
1190
1191  /// \brief The location of the '~'.
1192  SourceLocation TildeLoc;
1193
1194  /// \brief The type being destroyed, or its name if we were unable to
1195  /// resolve the name.
1196  PseudoDestructorTypeStorage DestroyedType;
1197
1198public:
1199  CXXPseudoDestructorExpr(ASTContext &Context,
1200                          Expr *Base, bool isArrow, SourceLocation OperatorLoc,
1201                          NestedNameSpecifier *Qualifier,
1202                          SourceRange QualifierRange,
1203                          TypeSourceInfo *ScopeType,
1204                          SourceLocation ColonColonLoc,
1205                          SourceLocation TildeLoc,
1206                          PseudoDestructorTypeStorage DestroyedType)
1207    : Expr(CXXPseudoDestructorExprClass,
1208           Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0,
1209                                                          false, 0, false,
1210                                                          false, 0, 0,
1211                                                      FunctionType::ExtInfo())),
1212           /*isTypeDependent=*/(Base->isTypeDependent() ||
1213            (DestroyedType.getTypeSourceInfo() &&
1214              DestroyedType.getTypeSourceInfo()->getType()->isDependentType())),
1215           /*isValueDependent=*/Base->isValueDependent()),
1216      Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
1217      OperatorLoc(OperatorLoc), Qualifier(Qualifier),
1218      QualifierRange(QualifierRange),
1219      ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc),
1220      DestroyedType(DestroyedType) { }
1221
1222  explicit CXXPseudoDestructorExpr(EmptyShell Shell)
1223    : Expr(CXXPseudoDestructorExprClass, Shell),
1224      Base(0), IsArrow(false), Qualifier(0), ScopeType(0) { }
1225
1226  void setBase(Expr *E) { Base = E; }
1227  Expr *getBase() const { return cast<Expr>(Base); }
1228
1229  /// \brief Determines whether this member expression actually had
1230  /// a C++ nested-name-specifier prior to the name of the member, e.g.,
1231  /// x->Base::foo.
1232  bool hasQualifier() const { return Qualifier != 0; }
1233
1234  /// \brief If the member name was qualified, retrieves the source range of
1235  /// the nested-name-specifier that precedes the member name. Otherwise,
1236  /// returns an empty source range.
1237  SourceRange getQualifierRange() const { return QualifierRange; }
1238  void setQualifierRange(SourceRange R) { QualifierRange = R; }
1239
1240  /// \brief If the member name was qualified, retrieves the
1241  /// nested-name-specifier that precedes the member name. Otherwise, returns
1242  /// NULL.
1243  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1244  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
1245
1246  /// \brief Determine whether this pseudo-destructor expression was written
1247  /// using an '->' (otherwise, it used a '.').
1248  bool isArrow() const { return IsArrow; }
1249  void setArrow(bool A) { IsArrow = A; }
1250
1251  /// \brief Retrieve the location of the '.' or '->' operator.
1252  SourceLocation getOperatorLoc() const { return OperatorLoc; }
1253  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
1254
1255  /// \brief Retrieve the scope type in a qualified pseudo-destructor
1256  /// expression.
1257  ///
1258  /// Pseudo-destructor expressions can have extra qualification within them
1259  /// that is not part of the nested-name-specifier, e.g., \c p->T::~T().
1260  /// Here, if the object type of the expression is (or may be) a scalar type,
1261  /// \p T may also be a scalar type and, therefore, cannot be part of a
1262  /// nested-name-specifier. It is stored as the "scope type" of the pseudo-
1263  /// destructor expression.
1264  TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; }
1265  void setScopeTypeInfo(TypeSourceInfo *Info) { ScopeType = Info; }
1266
1267  /// \brief Retrieve the location of the '::' in a qualified pseudo-destructor
1268  /// expression.
1269  SourceLocation getColonColonLoc() const { return ColonColonLoc; }
1270  void setColonColonLoc(SourceLocation L) { ColonColonLoc = L; }
1271
1272  /// \brief Retrieve the location of the '~'.
1273  SourceLocation getTildeLoc() const { return TildeLoc; }
1274  void setTildeLoc(SourceLocation L) { TildeLoc = L; }
1275
1276  /// \brief Retrieve the source location information for the type
1277  /// being destroyed.
1278  ///
1279  /// This type-source information is available for non-dependent
1280  /// pseudo-destructor expressions and some dependent pseudo-destructor
1281  /// expressions. Returns NULL if we only have the identifier for a
1282  /// dependent pseudo-destructor expression.
1283  TypeSourceInfo *getDestroyedTypeInfo() const {
1284    return DestroyedType.getTypeSourceInfo();
1285  }
1286
1287  /// \brief In a dependent pseudo-destructor expression for which we do not
1288  /// have full type information on the destroyed type, provides the name
1289  /// of the destroyed type.
1290  IdentifierInfo *getDestroyedTypeIdentifier() const {
1291    return DestroyedType.getIdentifier();
1292  }
1293
1294  /// \brief Retrieve the type being destroyed.
1295  QualType getDestroyedType() const;
1296
1297  /// \brief Retrieve the starting location of the type being destroyed.
1298  SourceLocation getDestroyedTypeLoc() const {
1299    return DestroyedType.getLocation();
1300  }
1301
1302  /// \brief Set the name of destroyed type for a dependent pseudo-destructor
1303  /// expression.
1304  void setDestroyedType(IdentifierInfo *II, SourceLocation Loc) {
1305    DestroyedType = PseudoDestructorTypeStorage(II, Loc);
1306  }
1307
1308  /// \brief Set the destroyed type.
1309  void setDestroyedType(TypeSourceInfo *Info) {
1310    DestroyedType = PseudoDestructorTypeStorage(Info);
1311  }
1312
1313  virtual SourceRange getSourceRange() const;
1314
1315  static bool classof(const Stmt *T) {
1316    return T->getStmtClass() == CXXPseudoDestructorExprClass;
1317  }
1318  static bool classof(const CXXPseudoDestructorExpr *) { return true; }
1319
1320  // Iterators
1321  virtual child_iterator child_begin();
1322  virtual child_iterator child_end();
1323};
1324
1325/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the
1326/// implementation of TR1/C++0x type trait templates.
1327/// Example:
1328/// __is_pod(int) == true
1329/// __is_enum(std::string) == false
1330class UnaryTypeTraitExpr : public Expr {
1331  /// UTT - The trait.
1332  UnaryTypeTrait UTT;
1333
1334  /// Loc - The location of the type trait keyword.
1335  SourceLocation Loc;
1336
1337  /// RParen - The location of the closing paren.
1338  SourceLocation RParen;
1339
1340  /// QueriedType - The type we're testing.
1341  QualType QueriedType;
1342
1343public:
1344  UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, QualType queried,
1345                     SourceLocation rparen, QualType ty)
1346    : Expr(UnaryTypeTraitExprClass, ty, false, queried->isDependentType()),
1347      UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { }
1348
1349  explicit UnaryTypeTraitExpr(EmptyShell Empty)
1350    : Expr(UnaryTypeTraitExprClass, Empty), UTT((UnaryTypeTrait)0) { }
1351
1352  virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);}
1353
1354  UnaryTypeTrait getTrait() const { return UTT; }
1355
1356  QualType getQueriedType() const { return QueriedType; }
1357
1358  bool EvaluateTrait(ASTContext&) const;
1359
1360  static bool classof(const Stmt *T) {
1361    return T->getStmtClass() == UnaryTypeTraitExprClass;
1362  }
1363  static bool classof(const UnaryTypeTraitExpr *) { return true; }
1364
1365  // Iterators
1366  virtual child_iterator child_begin();
1367  virtual child_iterator child_end();
1368
1369  friend class PCHStmtReader;
1370};
1371
1372/// \brief A reference to an overloaded function set, either an
1373/// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr.
1374class OverloadExpr : public Expr {
1375  /// The results.  These are undesugared, which is to say, they may
1376  /// include UsingShadowDecls.  Access is relative to the naming
1377  /// class.
1378  // FIXME: Allocate this data after the OverloadExpr subclass.
1379  DeclAccessPair *Results;
1380  unsigned NumResults;
1381
1382  /// The common name of these declarations.
1383  DeclarationName Name;
1384
1385  /// The scope specifier, if any.
1386  NestedNameSpecifier *Qualifier;
1387
1388  /// The source range of the scope specifier.
1389  SourceRange QualifierRange;
1390
1391  /// The location of the name.
1392  SourceLocation NameLoc;
1393
1394protected:
1395  /// True if the name was a template-id.
1396  bool HasExplicitTemplateArgs;
1397
1398  OverloadExpr(StmtClass K, ASTContext &C, QualType T, bool Dependent,
1399               NestedNameSpecifier *Qualifier, SourceRange QRange,
1400               DeclarationName Name, SourceLocation NameLoc,
1401               bool HasTemplateArgs,
1402               UnresolvedSetIterator Begin, UnresolvedSetIterator End);
1403
1404  OverloadExpr(StmtClass K, EmptyShell Empty)
1405    : Expr(K, Empty), Results(0), NumResults(0),
1406      Qualifier(0), HasExplicitTemplateArgs(false) { }
1407
1408public:
1409  /// Computes whether an unresolved lookup on the given declarations
1410  /// and optional template arguments is type- and value-dependent.
1411  static bool ComputeDependence(UnresolvedSetIterator Begin,
1412                                UnresolvedSetIterator End,
1413                                const TemplateArgumentListInfo *Args);
1414
1415  /// Finds the overloaded expression in the given expression of
1416  /// OverloadTy.
1417  ///
1418  /// \return the expression (which must be there) and true if it is
1419  /// within an address-of operator.
1420  static llvm::PointerIntPair<OverloadExpr*,1> find(Expr *E) {
1421    assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload));
1422
1423    bool op = false;
1424    E = E->IgnoreParens();
1425    if (isa<UnaryOperator>(E))
1426      op = true, E = cast<UnaryOperator>(E)->getSubExpr()->IgnoreParens();
1427    return llvm::PointerIntPair<OverloadExpr*,1>(cast<OverloadExpr>(E), op);
1428  }
1429
1430  /// Gets the naming class of this lookup, if any.
1431  CXXRecordDecl *getNamingClass() const;
1432
1433  typedef UnresolvedSetImpl::iterator decls_iterator;
1434  decls_iterator decls_begin() const { return UnresolvedSetIterator(Results); }
1435  decls_iterator decls_end() const {
1436    return UnresolvedSetIterator(Results + NumResults);
1437  }
1438
1439  void initializeResults(ASTContext &C,
1440                         UnresolvedSetIterator Begin,UnresolvedSetIterator End);
1441
1442  /// Gets the number of declarations in the unresolved set.
1443  unsigned getNumDecls() const { return NumResults; }
1444
1445  /// Gets the name looked up.
1446  DeclarationName getName() const { return Name; }
1447  void setName(DeclarationName N) { Name = N; }
1448
1449  /// Gets the location of the name.
1450  SourceLocation getNameLoc() const { return NameLoc; }
1451  void setNameLoc(SourceLocation Loc) { NameLoc = Loc; }
1452
1453  /// Fetches the nested-name qualifier, if one was given.
1454  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1455  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
1456
1457  /// Fetches the range of the nested-name qualifier.
1458  SourceRange getQualifierRange() const { return QualifierRange; }
1459  void setQualifierRange(SourceRange R) { QualifierRange = R; }
1460
1461  /// \brief Determines whether this expression had an explicit
1462  /// template argument list, e.g. f<int>.
1463  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
1464
1465  ExplicitTemplateArgumentList &getExplicitTemplateArgs(); // defined far below
1466
1467  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1468    return const_cast<OverloadExpr*>(this)->getExplicitTemplateArgs();
1469  }
1470
1471  ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
1472    if (hasExplicitTemplateArgs())
1473      return &getExplicitTemplateArgs();
1474    return 0;
1475  }
1476
1477  static bool classof(const Stmt *T) {
1478    return T->getStmtClass() == UnresolvedLookupExprClass ||
1479           T->getStmtClass() == UnresolvedMemberExprClass;
1480  }
1481  static bool classof(const OverloadExpr *) { return true; }
1482};
1483
1484/// \brief A reference to a name which we were able to look up during
1485/// parsing but could not resolve to a specific declaration.  This
1486/// arises in several ways:
1487///   * we might be waiting for argument-dependent lookup
1488///   * the name might resolve to an overloaded function
1489/// and eventually:
1490///   * the lookup might have included a function template
1491/// These never include UnresolvedUsingValueDecls, which are always
1492/// class members and therefore appear only in
1493/// UnresolvedMemberLookupExprs.
1494class UnresolvedLookupExpr : public OverloadExpr {
1495  /// True if these lookup results should be extended by
1496  /// argument-dependent lookup if this is the operand of a function
1497  /// call.
1498  bool RequiresADL;
1499
1500  /// True if these lookup results are overloaded.  This is pretty
1501  /// trivially rederivable if we urgently need to kill this field.
1502  bool Overloaded;
1503
1504  /// The naming class (C++ [class.access.base]p5) of the lookup, if
1505  /// any.  This can generally be recalculated from the context chain,
1506  /// but that can be fairly expensive for unqualified lookups.  If we
1507  /// want to improve memory use here, this could go in a union
1508  /// against the qualified-lookup bits.
1509  CXXRecordDecl *NamingClass;
1510
1511  UnresolvedLookupExpr(ASTContext &C, QualType T, bool Dependent,
1512                       CXXRecordDecl *NamingClass,
1513                       NestedNameSpecifier *Qualifier, SourceRange QRange,
1514                       DeclarationName Name, SourceLocation NameLoc,
1515                       bool RequiresADL, bool Overloaded, bool HasTemplateArgs,
1516                       UnresolvedSetIterator Begin, UnresolvedSetIterator End)
1517    : OverloadExpr(UnresolvedLookupExprClass, C, T, Dependent, Qualifier,
1518                   QRange, Name, NameLoc, HasTemplateArgs, Begin, End),
1519      RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass)
1520  {}
1521
1522  UnresolvedLookupExpr(EmptyShell Empty)
1523    : OverloadExpr(UnresolvedLookupExprClass, Empty),
1524      RequiresADL(false), Overloaded(false), NamingClass(0)
1525  {}
1526
1527public:
1528  static UnresolvedLookupExpr *Create(ASTContext &C,
1529                                      bool Dependent,
1530                                      CXXRecordDecl *NamingClass,
1531                                      NestedNameSpecifier *Qualifier,
1532                                      SourceRange QualifierRange,
1533                                      DeclarationName Name,
1534                                      SourceLocation NameLoc,
1535                                      bool ADL, bool Overloaded,
1536                                      UnresolvedSetIterator Begin,
1537                                      UnresolvedSetIterator End) {
1538    return new(C) UnresolvedLookupExpr(C,
1539                                       Dependent ? C.DependentTy : C.OverloadTy,
1540                                       Dependent, NamingClass,
1541                                       Qualifier, QualifierRange,
1542                                       Name, NameLoc, ADL, Overloaded, false,
1543                                       Begin, End);
1544  }
1545
1546  static UnresolvedLookupExpr *Create(ASTContext &C,
1547                                      bool Dependent,
1548                                      CXXRecordDecl *NamingClass,
1549                                      NestedNameSpecifier *Qualifier,
1550                                      SourceRange QualifierRange,
1551                                      DeclarationName Name,
1552                                      SourceLocation NameLoc,
1553                                      bool ADL,
1554                                      const TemplateArgumentListInfo &Args,
1555                                      UnresolvedSetIterator Begin,
1556                                      UnresolvedSetIterator End);
1557
1558  static UnresolvedLookupExpr *CreateEmpty(ASTContext &C,
1559                                           unsigned NumTemplateArgs);
1560
1561  /// True if this declaration should be extended by
1562  /// argument-dependent lookup.
1563  bool requiresADL() const { return RequiresADL; }
1564  void setRequiresADL(bool V) { RequiresADL = V; }
1565
1566  /// True if this lookup is overloaded.
1567  bool isOverloaded() const { return Overloaded; }
1568  void setOverloaded(bool V) { Overloaded = V; }
1569
1570  /// Gets the 'naming class' (in the sense of C++0x
1571  /// [class.access.base]p5) of the lookup.  This is the scope
1572  /// that was looked in to find these results.
1573  CXXRecordDecl *getNamingClass() const { return NamingClass; }
1574  void setNamingClass(CXXRecordDecl *D) { NamingClass = D; }
1575
1576  // Note that, inconsistently with the explicit-template-argument AST
1577  // nodes, users are *forbidden* from calling these methods on objects
1578  // without explicit template arguments.
1579
1580  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
1581    assert(hasExplicitTemplateArgs());
1582    return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1);
1583  }
1584
1585  /// Gets a reference to the explicit template argument list.
1586  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1587    assert(hasExplicitTemplateArgs());
1588    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1589  }
1590
1591  /// \brief Copies the template arguments (if present) into the given
1592  /// structure.
1593  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1594    getExplicitTemplateArgs().copyInto(List);
1595  }
1596
1597  SourceLocation getLAngleLoc() const {
1598    return getExplicitTemplateArgs().LAngleLoc;
1599  }
1600
1601  SourceLocation getRAngleLoc() const {
1602    return getExplicitTemplateArgs().RAngleLoc;
1603  }
1604
1605  TemplateArgumentLoc const *getTemplateArgs() const {
1606    return getExplicitTemplateArgs().getTemplateArgs();
1607  }
1608
1609  unsigned getNumTemplateArgs() const {
1610    return getExplicitTemplateArgs().NumTemplateArgs;
1611  }
1612
1613  virtual SourceRange getSourceRange() const {
1614    SourceRange Range(getNameLoc());
1615    if (getQualifier()) Range.setBegin(getQualifierRange().getBegin());
1616    if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc());
1617    return Range;
1618  }
1619
1620  virtual StmtIterator child_begin();
1621  virtual StmtIterator child_end();
1622
1623  static bool classof(const Stmt *T) {
1624    return T->getStmtClass() == UnresolvedLookupExprClass;
1625  }
1626  static bool classof(const UnresolvedLookupExpr *) { return true; }
1627};
1628
1629/// \brief A qualified reference to a name whose declaration cannot
1630/// yet be resolved.
1631///
1632/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that
1633/// it expresses a reference to a declaration such as
1634/// X<T>::value. The difference, however, is that an
1635/// DependentScopeDeclRefExpr node is used only within C++ templates when
1636/// the qualification (e.g., X<T>::) refers to a dependent type. In
1637/// this case, X<T>::value cannot resolve to a declaration because the
1638/// declaration will differ from on instantiation of X<T> to the
1639/// next. Therefore, DependentScopeDeclRefExpr keeps track of the
1640/// qualifier (X<T>::) and the name of the entity being referenced
1641/// ("value"). Such expressions will instantiate to a DeclRefExpr once the
1642/// declaration can be found.
1643class DependentScopeDeclRefExpr : public Expr {
1644  /// The name of the entity we will be referencing.
1645  DeclarationName Name;
1646
1647  /// Location of the name of the declaration we're referencing.
1648  SourceLocation Loc;
1649
1650  /// QualifierRange - The source range that covers the
1651  /// nested-name-specifier.
1652  SourceRange QualifierRange;
1653
1654  /// \brief The nested-name-specifier that qualifies this unresolved
1655  /// declaration name.
1656  NestedNameSpecifier *Qualifier;
1657
1658  /// \brief Whether the name includes explicit template arguments.
1659  bool HasExplicitTemplateArgs;
1660
1661  DependentScopeDeclRefExpr(QualType T,
1662                            NestedNameSpecifier *Qualifier,
1663                            SourceRange QualifierRange,
1664                            DeclarationName Name,
1665                            SourceLocation NameLoc,
1666                            bool HasExplicitTemplateArgs)
1667    : Expr(DependentScopeDeclRefExprClass, T, true, true),
1668      Name(Name), Loc(NameLoc),
1669      QualifierRange(QualifierRange), Qualifier(Qualifier),
1670      HasExplicitTemplateArgs(HasExplicitTemplateArgs)
1671  {}
1672
1673public:
1674  static DependentScopeDeclRefExpr *Create(ASTContext &C,
1675                                           NestedNameSpecifier *Qualifier,
1676                                           SourceRange QualifierRange,
1677                                           DeclarationName Name,
1678                                           SourceLocation NameLoc,
1679                              const TemplateArgumentListInfo *TemplateArgs = 0);
1680
1681  static DependentScopeDeclRefExpr *CreateEmpty(ASTContext &C,
1682                                                unsigned NumTemplateArgs);
1683
1684  /// \brief Retrieve the name that this expression refers to.
1685  DeclarationName getDeclName() const { return Name; }
1686  void setDeclName(DeclarationName N) { Name =  N; }
1687
1688  /// \brief Retrieve the location of the name within the expression.
1689  SourceLocation getLocation() const { return Loc; }
1690  void setLocation(SourceLocation L) { Loc = L; }
1691
1692  /// \brief Retrieve the source range of the nested-name-specifier.
1693  SourceRange getQualifierRange() const { return QualifierRange; }
1694  void setQualifierRange(SourceRange R) { QualifierRange = R; }
1695
1696  /// \brief Retrieve the nested-name-specifier that qualifies this
1697  /// declaration.
1698  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1699  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
1700
1701  /// Determines whether this lookup had explicit template arguments.
1702  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
1703
1704  // Note that, inconsistently with the explicit-template-argument AST
1705  // nodes, users are *forbidden* from calling these methods on objects
1706  // without explicit template arguments.
1707
1708  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
1709    assert(hasExplicitTemplateArgs());
1710    return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1);
1711  }
1712
1713  /// Gets a reference to the explicit template argument list.
1714  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1715    assert(hasExplicitTemplateArgs());
1716    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1717  }
1718
1719  /// \brief Copies the template arguments (if present) into the given
1720  /// structure.
1721  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1722    getExplicitTemplateArgs().copyInto(List);
1723  }
1724
1725  SourceLocation getLAngleLoc() const {
1726    return getExplicitTemplateArgs().LAngleLoc;
1727  }
1728
1729  SourceLocation getRAngleLoc() const {
1730    return getExplicitTemplateArgs().RAngleLoc;
1731  }
1732
1733  TemplateArgumentLoc const *getTemplateArgs() const {
1734    return getExplicitTemplateArgs().getTemplateArgs();
1735  }
1736
1737  unsigned getNumTemplateArgs() const {
1738    return getExplicitTemplateArgs().NumTemplateArgs;
1739  }
1740
1741  virtual SourceRange getSourceRange() const {
1742    SourceRange Range(QualifierRange.getBegin(), getLocation());
1743    if (hasExplicitTemplateArgs())
1744      Range.setEnd(getRAngleLoc());
1745    return Range;
1746  }
1747
1748  static bool classof(const Stmt *T) {
1749    return T->getStmtClass() == DependentScopeDeclRefExprClass;
1750  }
1751  static bool classof(const DependentScopeDeclRefExpr *) { return true; }
1752
1753  virtual StmtIterator child_begin();
1754  virtual StmtIterator child_end();
1755};
1756
1757class CXXExprWithTemporaries : public Expr {
1758  Stmt *SubExpr;
1759
1760  CXXTemporary **Temps;
1761  unsigned NumTemps;
1762
1763  CXXExprWithTemporaries(ASTContext &C, Expr *SubExpr, CXXTemporary **Temps,
1764                         unsigned NumTemps);
1765  ~CXXExprWithTemporaries();
1766
1767public:
1768  CXXExprWithTemporaries(EmptyShell Empty)
1769    : Expr(CXXExprWithTemporariesClass, Empty),
1770      SubExpr(0), Temps(0), NumTemps(0) {}
1771
1772  static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr,
1773                                        CXXTemporary **Temps,
1774                                        unsigned NumTemps);
1775
1776  unsigned getNumTemporaries() const { return NumTemps; }
1777  void setNumTemporaries(ASTContext &C, unsigned N);
1778
1779  CXXTemporary *getTemporary(unsigned i) {
1780    assert(i < NumTemps && "Index out of range");
1781    return Temps[i];
1782  }
1783  const CXXTemporary *getTemporary(unsigned i) const {
1784    return const_cast<CXXExprWithTemporaries*>(this)->getTemporary(i);
1785  }
1786  void setTemporary(unsigned i, CXXTemporary *T) {
1787    assert(i < NumTemps && "Index out of range");
1788    Temps[i] = T;
1789  }
1790
1791  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
1792  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
1793  void setSubExpr(Expr *E) { SubExpr = E; }
1794
1795  virtual SourceRange getSourceRange() const {
1796    return SubExpr->getSourceRange();
1797  }
1798
1799  // Implement isa/cast/dyncast/etc.
1800  static bool classof(const Stmt *T) {
1801    return T->getStmtClass() == CXXExprWithTemporariesClass;
1802  }
1803  static bool classof(const CXXExprWithTemporaries *) { return true; }
1804
1805  // Iterators
1806  virtual child_iterator child_begin();
1807  virtual child_iterator child_end();
1808};
1809
1810/// \brief Describes an explicit type conversion that uses functional
1811/// notion but could not be resolved because one or more arguments are
1812/// type-dependent.
1813///
1814/// The explicit type conversions expressed by
1815/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN),
1816/// where \c T is some type and \c a1, a2, ..., aN are values, and
1817/// either \C T is a dependent type or one or more of the \c a's is
1818/// type-dependent. For example, this would occur in a template such
1819/// as:
1820///
1821/// \code
1822///   template<typename T, typename A1>
1823///   inline T make_a(const A1& a1) {
1824///     return T(a1);
1825///   }
1826/// \endcode
1827///
1828/// When the returned expression is instantiated, it may resolve to a
1829/// constructor call, conversion function call, or some kind of type
1830/// conversion.
1831class CXXUnresolvedConstructExpr : public Expr {
1832  /// \brief The starting location of the type
1833  SourceLocation TyBeginLoc;
1834
1835  /// \brief The type being constructed.
1836  QualType Type;
1837
1838  /// \brief The location of the left parentheses ('(').
1839  SourceLocation LParenLoc;
1840
1841  /// \brief The location of the right parentheses (')').
1842  SourceLocation RParenLoc;
1843
1844  /// \brief The number of arguments used to construct the type.
1845  unsigned NumArgs;
1846
1847  CXXUnresolvedConstructExpr(SourceLocation TyBegin,
1848                             QualType T,
1849                             SourceLocation LParenLoc,
1850                             Expr **Args,
1851                             unsigned NumArgs,
1852                             SourceLocation RParenLoc);
1853
1854  CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs)
1855    : Expr(CXXUnresolvedConstructExprClass, Empty), NumArgs(NumArgs) { }
1856
1857public:
1858  static CXXUnresolvedConstructExpr *Create(ASTContext &C,
1859                                            SourceLocation TyBegin,
1860                                            QualType T,
1861                                            SourceLocation LParenLoc,
1862                                            Expr **Args,
1863                                            unsigned NumArgs,
1864                                            SourceLocation RParenLoc);
1865
1866  static CXXUnresolvedConstructExpr *CreateEmpty(ASTContext &C,
1867                                                 unsigned NumArgs);
1868
1869  /// \brief Retrieve the source location where the type begins.
1870  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
1871  void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; }
1872
1873  /// \brief Retrieve the type that is being constructed, as specified
1874  /// in the source code.
1875  QualType getTypeAsWritten() const { return Type; }
1876  void setTypeAsWritten(QualType T) { Type = T; }
1877
1878  /// \brief Retrieve the location of the left parentheses ('(') that
1879  /// precedes the argument list.
1880  SourceLocation getLParenLoc() const { return LParenLoc; }
1881  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
1882
1883  /// \brief Retrieve the location of the right parentheses (')') that
1884  /// follows the argument list.
1885  SourceLocation getRParenLoc() const { return RParenLoc; }
1886  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1887
1888  /// \brief Retrieve the number of arguments.
1889  unsigned arg_size() const { return NumArgs; }
1890
1891  typedef Expr** arg_iterator;
1892  arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); }
1893  arg_iterator arg_end() { return arg_begin() + NumArgs; }
1894
1895  typedef const Expr* const * const_arg_iterator;
1896  const_arg_iterator arg_begin() const {
1897    return reinterpret_cast<const Expr* const *>(this + 1);
1898  }
1899  const_arg_iterator arg_end() const {
1900    return arg_begin() + NumArgs;
1901  }
1902
1903  Expr *getArg(unsigned I) {
1904    assert(I < NumArgs && "Argument index out-of-range");
1905    return *(arg_begin() + I);
1906  }
1907
1908  const Expr *getArg(unsigned I) const {
1909    assert(I < NumArgs && "Argument index out-of-range");
1910    return *(arg_begin() + I);
1911  }
1912
1913  void setArg(unsigned I, Expr *E) {
1914    assert(I < NumArgs && "Argument index out-of-range");
1915    *(arg_begin() + I) = E;
1916  }
1917
1918  virtual SourceRange getSourceRange() const {
1919    return SourceRange(TyBeginLoc, RParenLoc);
1920  }
1921  static bool classof(const Stmt *T) {
1922    return T->getStmtClass() == CXXUnresolvedConstructExprClass;
1923  }
1924  static bool classof(const CXXUnresolvedConstructExpr *) { return true; }
1925
1926  // Iterators
1927  virtual child_iterator child_begin();
1928  virtual child_iterator child_end();
1929};
1930
1931/// \brief Represents a C++ member access expression where the actual
1932/// member referenced could not be resolved because the base
1933/// expression or the member name was dependent.
1934///
1935/// Like UnresolvedMemberExprs, these can be either implicit or
1936/// explicit accesses.  It is only possible to get one of these with
1937/// an implicit access if a qualifier is provided.
1938class CXXDependentScopeMemberExpr : public Expr {
1939  /// \brief The expression for the base pointer or class reference,
1940  /// e.g., the \c x in x.f.  Can be null in implicit accesses.
1941  Stmt *Base;
1942
1943  /// \brief The type of the base expression.  Never null, even for
1944  /// implicit accesses.
1945  QualType BaseType;
1946
1947  /// \brief Whether this member expression used the '->' operator or
1948  /// the '.' operator.
1949  bool IsArrow : 1;
1950
1951  /// \brief Whether this member expression has explicitly-specified template
1952  /// arguments.
1953  bool HasExplicitTemplateArgs : 1;
1954
1955  /// \brief The location of the '->' or '.' operator.
1956  SourceLocation OperatorLoc;
1957
1958  /// \brief The nested-name-specifier that precedes the member name, if any.
1959  NestedNameSpecifier *Qualifier;
1960
1961  /// \brief The source range covering the nested name specifier.
1962  SourceRange QualifierRange;
1963
1964  /// \brief In a qualified member access expression such as t->Base::f, this
1965  /// member stores the resolves of name lookup in the context of the member
1966  /// access expression, to be used at instantiation time.
1967  ///
1968  /// FIXME: This member, along with the Qualifier and QualifierRange, could
1969  /// be stuck into a structure that is optionally allocated at the end of
1970  /// the CXXDependentScopeMemberExpr, to save space in the common case.
1971  NamedDecl *FirstQualifierFoundInScope;
1972
1973  /// \brief The member to which this member expression refers, which
1974  /// can be name, overloaded operator, or destructor.
1975  /// FIXME: could also be a template-id
1976  DeclarationName Member;
1977
1978  /// \brief The location of the member name.
1979  SourceLocation MemberLoc;
1980
1981  CXXDependentScopeMemberExpr(ASTContext &C,
1982                          Expr *Base, QualType BaseType, bool IsArrow,
1983                          SourceLocation OperatorLoc,
1984                          NestedNameSpecifier *Qualifier,
1985                          SourceRange QualifierRange,
1986                          NamedDecl *FirstQualifierFoundInScope,
1987                          DeclarationName Member,
1988                          SourceLocation MemberLoc,
1989                          const TemplateArgumentListInfo *TemplateArgs);
1990
1991public:
1992  CXXDependentScopeMemberExpr(ASTContext &C,
1993                          Expr *Base, QualType BaseType,
1994                          bool IsArrow,
1995                          SourceLocation OperatorLoc,
1996                          NestedNameSpecifier *Qualifier,
1997                          SourceRange QualifierRange,
1998                          NamedDecl *FirstQualifierFoundInScope,
1999                          DeclarationName Member,
2000                          SourceLocation MemberLoc)
2001  : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, true, true),
2002    Base(Base), BaseType(BaseType), IsArrow(IsArrow),
2003    HasExplicitTemplateArgs(false), OperatorLoc(OperatorLoc),
2004    Qualifier(Qualifier), QualifierRange(QualifierRange),
2005    FirstQualifierFoundInScope(FirstQualifierFoundInScope),
2006    Member(Member), MemberLoc(MemberLoc) { }
2007
2008  static CXXDependentScopeMemberExpr *
2009  Create(ASTContext &C,
2010         Expr *Base, QualType BaseType, bool IsArrow,
2011         SourceLocation OperatorLoc,
2012         NestedNameSpecifier *Qualifier,
2013         SourceRange QualifierRange,
2014         NamedDecl *FirstQualifierFoundInScope,
2015         DeclarationName Member,
2016         SourceLocation MemberLoc,
2017         const TemplateArgumentListInfo *TemplateArgs);
2018
2019  static CXXDependentScopeMemberExpr *
2020  CreateEmpty(ASTContext &C, unsigned NumTemplateArgs);
2021
2022  /// \brief True if this is an implicit access, i.e. one in which the
2023  /// member being accessed was not written in the source.  The source
2024  /// location of the operator is invalid in this case.
2025  bool isImplicitAccess() const { return Base == 0; }
2026
2027  /// \brief Retrieve the base object of this member expressions,
2028  /// e.g., the \c x in \c x.m.
2029  Expr *getBase() const {
2030    assert(!isImplicitAccess());
2031    return cast<Expr>(Base);
2032  }
2033  void setBase(Expr *E) { Base = E; }
2034
2035  QualType getBaseType() const { return BaseType; }
2036  void setBaseType(QualType T) { BaseType = T; }
2037
2038  /// \brief Determine whether this member expression used the '->'
2039  /// operator; otherwise, it used the '.' operator.
2040  bool isArrow() const { return IsArrow; }
2041  void setArrow(bool A) { IsArrow = A; }
2042
2043  /// \brief Retrieve the location of the '->' or '.' operator.
2044  SourceLocation getOperatorLoc() const { return OperatorLoc; }
2045  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
2046
2047  /// \brief Retrieve the nested-name-specifier that qualifies the member
2048  /// name.
2049  NestedNameSpecifier *getQualifier() const { return Qualifier; }
2050  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
2051
2052  /// \brief Retrieve the source range covering the nested-name-specifier
2053  /// that qualifies the member name.
2054  SourceRange getQualifierRange() const { return QualifierRange; }
2055  void setQualifierRange(SourceRange R) { QualifierRange = R; }
2056
2057  /// \brief Retrieve the first part of the nested-name-specifier that was
2058  /// found in the scope of the member access expression when the member access
2059  /// was initially parsed.
2060  ///
2061  /// This function only returns a useful result when member access expression
2062  /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration
2063  /// returned by this function describes what was found by unqualified name
2064  /// lookup for the identifier "Base" within the scope of the member access
2065  /// expression itself. At template instantiation time, this information is
2066  /// combined with the results of name lookup into the type of the object
2067  /// expression itself (the class type of x).
2068  NamedDecl *getFirstQualifierFoundInScope() const {
2069    return FirstQualifierFoundInScope;
2070  }
2071  void setFirstQualifierFoundInScope(NamedDecl *D) {
2072    FirstQualifierFoundInScope = D;
2073  }
2074
2075  /// \brief Retrieve the name of the member that this expression
2076  /// refers to.
2077  DeclarationName getMember() const { return Member; }
2078  void setMember(DeclarationName N) { Member = N; }
2079
2080  // \brief Retrieve the location of the name of the member that this
2081  // expression refers to.
2082  SourceLocation getMemberLoc() const { return MemberLoc; }
2083  void setMemberLoc(SourceLocation L) { MemberLoc = L; }
2084
2085  /// \brief Determines whether this member expression actually had a C++
2086  /// template argument list explicitly specified, e.g., x.f<int>.
2087  bool hasExplicitTemplateArgs() const {
2088    return HasExplicitTemplateArgs;
2089  }
2090
2091  /// \brief Retrieve the explicit template argument list that followed the
2092  /// member template name, if any.
2093  ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() {
2094    assert(HasExplicitTemplateArgs);
2095    return reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
2096  }
2097
2098  /// \brief Retrieve the explicit template argument list that followed the
2099  /// member template name, if any.
2100  const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const {
2101    return const_cast<CXXDependentScopeMemberExpr *>(this)
2102             ->getExplicitTemplateArgumentList();
2103  }
2104
2105  /// \brief Copies the template arguments (if present) into the given
2106  /// structure.
2107  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
2108    assert(HasExplicitTemplateArgs);
2109    getExplicitTemplateArgumentList()->copyInto(List);
2110  }
2111
2112  /// \brief Initializes the template arguments using the given structure.
2113  void initializeTemplateArgumentsFrom(const TemplateArgumentListInfo &List) {
2114    assert(HasExplicitTemplateArgs);
2115    getExplicitTemplateArgumentList()->initializeFrom(List);
2116  }
2117
2118  /// \brief Retrieve the location of the left angle bracket following the
2119  /// member name ('<'), if any.
2120  SourceLocation getLAngleLoc() const {
2121    assert(HasExplicitTemplateArgs);
2122    return getExplicitTemplateArgumentList()->LAngleLoc;
2123  }
2124
2125  /// \brief Retrieve the template arguments provided as part of this
2126  /// template-id.
2127  const TemplateArgumentLoc *getTemplateArgs() const {
2128    assert(HasExplicitTemplateArgs);
2129    return getExplicitTemplateArgumentList()->getTemplateArgs();
2130  }
2131
2132  /// \brief Retrieve the number of template arguments provided as part of this
2133  /// template-id.
2134  unsigned getNumTemplateArgs() const {
2135    assert(HasExplicitTemplateArgs);
2136    return getExplicitTemplateArgumentList()->NumTemplateArgs;
2137  }
2138
2139  /// \brief Retrieve the location of the right angle bracket following the
2140  /// template arguments ('>').
2141  SourceLocation getRAngleLoc() const {
2142    assert(HasExplicitTemplateArgs);
2143    return getExplicitTemplateArgumentList()->RAngleLoc;
2144  }
2145
2146  virtual SourceRange getSourceRange() const {
2147    SourceRange Range;
2148    if (!isImplicitAccess())
2149      Range.setBegin(Base->getSourceRange().getBegin());
2150    else if (getQualifier())
2151      Range.setBegin(getQualifierRange().getBegin());
2152    else
2153      Range.setBegin(MemberLoc);
2154
2155    if (hasExplicitTemplateArgs())
2156      Range.setEnd(getRAngleLoc());
2157    else
2158      Range.setEnd(MemberLoc);
2159    return Range;
2160  }
2161
2162  static bool classof(const Stmt *T) {
2163    return T->getStmtClass() == CXXDependentScopeMemberExprClass;
2164  }
2165  static bool classof(const CXXDependentScopeMemberExpr *) { return true; }
2166
2167  // Iterators
2168  virtual child_iterator child_begin();
2169  virtual child_iterator child_end();
2170};
2171
2172/// \brief Represents a C++ member access expression for which lookup
2173/// produced a set of overloaded functions.
2174///
2175/// The member access may be explicit or implicit:
2176///    struct A {
2177///      int a, b;
2178///      int explicitAccess() { return this->a + this->A::b; }
2179///      int implicitAccess() { return a + A::b; }
2180///    };
2181///
2182/// In the final AST, an explicit access always becomes a MemberExpr.
2183/// An implicit access may become either a MemberExpr or a
2184/// DeclRefExpr, depending on whether the member is static.
2185class UnresolvedMemberExpr : public OverloadExpr {
2186  /// \brief Whether this member expression used the '->' operator or
2187  /// the '.' operator.
2188  bool IsArrow : 1;
2189
2190  /// \brief Whether the lookup results contain an unresolved using
2191  /// declaration.
2192  bool HasUnresolvedUsing : 1;
2193
2194  /// \brief The expression for the base pointer or class reference,
2195  /// e.g., the \c x in x.f.  This can be null if this is an 'unbased'
2196  /// member expression
2197  Stmt *Base;
2198
2199  /// \brief The type of the base expression;  never null.
2200  QualType BaseType;
2201
2202  /// \brief The location of the '->' or '.' operator.
2203  SourceLocation OperatorLoc;
2204
2205  UnresolvedMemberExpr(ASTContext &C, QualType T, bool Dependent,
2206                       bool HasUnresolvedUsing,
2207                       Expr *Base, QualType BaseType, bool IsArrow,
2208                       SourceLocation OperatorLoc,
2209                       NestedNameSpecifier *Qualifier,
2210                       SourceRange QualifierRange,
2211                       DeclarationName Member,
2212                       SourceLocation MemberLoc,
2213                       const TemplateArgumentListInfo *TemplateArgs,
2214                       UnresolvedSetIterator Begin, UnresolvedSetIterator End);
2215
2216  UnresolvedMemberExpr(EmptyShell Empty)
2217    : OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false),
2218      HasUnresolvedUsing(false), Base(0) { }
2219
2220public:
2221  static UnresolvedMemberExpr *
2222  Create(ASTContext &C, bool Dependent, bool HasUnresolvedUsing,
2223         Expr *Base, QualType BaseType, bool IsArrow,
2224         SourceLocation OperatorLoc,
2225         NestedNameSpecifier *Qualifier,
2226         SourceRange QualifierRange,
2227         DeclarationName Member,
2228         SourceLocation MemberLoc,
2229         const TemplateArgumentListInfo *TemplateArgs,
2230         UnresolvedSetIterator Begin, UnresolvedSetIterator End);
2231
2232  static UnresolvedMemberExpr *
2233  CreateEmpty(ASTContext &C, unsigned NumTemplateArgs);
2234
2235  /// \brief True if this is an implicit access, i.e. one in which the
2236  /// member being accessed was not written in the source.  The source
2237  /// location of the operator is invalid in this case.
2238  bool isImplicitAccess() const { return Base == 0; }
2239
2240  /// \brief Retrieve the base object of this member expressions,
2241  /// e.g., the \c x in \c x.m.
2242  Expr *getBase() {
2243    assert(!isImplicitAccess());
2244    return cast<Expr>(Base);
2245  }
2246  const Expr *getBase() const {
2247    assert(!isImplicitAccess());
2248    return cast<Expr>(Base);
2249  }
2250  void setBase(Expr *E) { Base = E; }
2251
2252  QualType getBaseType() const { return BaseType; }
2253  void setBaseType(QualType T) { BaseType = T; }
2254
2255  /// \brief Determine whether the lookup results contain an unresolved using
2256  /// declaration.
2257  bool hasUnresolvedUsing() const { return HasUnresolvedUsing; }
2258  void setHasUnresolvedUsing(bool V) { HasUnresolvedUsing = V; }
2259
2260  /// \brief Determine whether this member expression used the '->'
2261  /// operator; otherwise, it used the '.' operator.
2262  bool isArrow() const { return IsArrow; }
2263  void setArrow(bool A) { IsArrow = A; }
2264
2265  /// \brief Retrieve the location of the '->' or '.' operator.
2266  SourceLocation getOperatorLoc() const { return OperatorLoc; }
2267  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
2268
2269  /// \brief Retrieves the naming class of this lookup.
2270  CXXRecordDecl *getNamingClass() const;
2271
2272  /// \brief Retrieve the name of the member that this expression
2273  /// refers to.
2274  DeclarationName getMemberName() const { return getName(); }
2275  void setMemberName(DeclarationName N) { setName(N); }
2276
2277  // \brief Retrieve the location of the name of the member that this
2278  // expression refers to.
2279  SourceLocation getMemberLoc() const { return getNameLoc(); }
2280  void setMemberLoc(SourceLocation L) { setNameLoc(L); }
2281
2282  /// \brief Retrieve the explicit template argument list that followed the
2283  /// member template name.
2284  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
2285    assert(hasExplicitTemplateArgs());
2286    return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
2287  }
2288
2289  /// \brief Retrieve the explicit template argument list that followed the
2290  /// member template name, if any.
2291  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
2292    assert(hasExplicitTemplateArgs());
2293    return *reinterpret_cast<const ExplicitTemplateArgumentList *>(this + 1);
2294  }
2295
2296  /// \brief Copies the template arguments into the given structure.
2297  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
2298    getExplicitTemplateArgs().copyInto(List);
2299  }
2300
2301  /// \brief Retrieve the location of the left angle bracket following
2302  /// the member name ('<').
2303  SourceLocation getLAngleLoc() const {
2304    return getExplicitTemplateArgs().LAngleLoc;
2305  }
2306
2307  /// \brief Retrieve the template arguments provided as part of this
2308  /// template-id.
2309  const TemplateArgumentLoc *getTemplateArgs() const {
2310    return getExplicitTemplateArgs().getTemplateArgs();
2311  }
2312
2313  /// \brief Retrieve the number of template arguments provided as
2314  /// part of this template-id.
2315  unsigned getNumTemplateArgs() const {
2316    return getExplicitTemplateArgs().NumTemplateArgs;
2317  }
2318
2319  /// \brief Retrieve the location of the right angle bracket
2320  /// following the template arguments ('>').
2321  SourceLocation getRAngleLoc() const {
2322    return getExplicitTemplateArgs().RAngleLoc;
2323  }
2324
2325  virtual SourceRange getSourceRange() const {
2326    SourceRange Range;
2327    if (!isImplicitAccess())
2328      Range.setBegin(Base->getSourceRange().getBegin());
2329    else if (getQualifier())
2330      Range.setBegin(getQualifierRange().getBegin());
2331    else
2332      Range.setBegin(getMemberLoc());
2333
2334    if (hasExplicitTemplateArgs())
2335      Range.setEnd(getRAngleLoc());
2336    else
2337      Range.setEnd(getMemberLoc());
2338    return Range;
2339  }
2340
2341  static bool classof(const Stmt *T) {
2342    return T->getStmtClass() == UnresolvedMemberExprClass;
2343  }
2344  static bool classof(const UnresolvedMemberExpr *) { return true; }
2345
2346  // Iterators
2347  virtual child_iterator child_begin();
2348  virtual child_iterator child_end();
2349};
2350
2351inline ExplicitTemplateArgumentList &OverloadExpr::getExplicitTemplateArgs() {
2352  if (isa<UnresolvedLookupExpr>(this))
2353    return cast<UnresolvedLookupExpr>(this)->getExplicitTemplateArgs();
2354  else
2355    return cast<UnresolvedMemberExpr>(this)->getExplicitTemplateArgs();
2356}
2357
2358}  // end namespace clang
2359
2360#endif
2361