]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/AST/ExprCXX.h
MFC
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / AST / ExprCXX.h
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/Basic/ExpressionTraits.h"
19 #include "clang/AST/Expr.h"
20 #include "clang/AST/UnresolvedSet.h"
21 #include "clang/AST/TemplateBase.h"
22
23 namespace clang {
24
25 class CXXConstructorDecl;
26 class CXXDestructorDecl;
27 class CXXMethodDecl;
28 class CXXTemporary;
29 class TemplateArgumentListInfo;
30
31 //===--------------------------------------------------------------------===//
32 // C++ Expressions.
33 //===--------------------------------------------------------------------===//
34
35 /// \brief A call to an overloaded operator written using operator
36 /// syntax.
37 ///
38 /// Represents a call to an overloaded operator written using operator
39 /// syntax, e.g., "x + y" or "*p". While semantically equivalent to a
40 /// normal call, this AST node provides better information about the
41 /// syntactic representation of the call.
42 ///
43 /// In a C++ template, this expression node kind will be used whenever
44 /// any of the arguments are type-dependent. In this case, the
45 /// function itself will be a (possibly empty) set of functions and
46 /// function templates that were found by name lookup at template
47 /// definition time.
48 class CXXOperatorCallExpr : public CallExpr {
49   /// \brief The overloaded operator.
50   OverloadedOperatorKind Operator;
51
52 public:
53   CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn,
54                       Expr **args, unsigned numargs, QualType t,
55                       ExprValueKind VK, SourceLocation operatorloc)
56     : CallExpr(C, CXXOperatorCallExprClass, fn, 0, args, numargs, t, VK,
57                operatorloc),
58       Operator(Op) {}
59   explicit CXXOperatorCallExpr(ASTContext& C, EmptyShell Empty) :
60     CallExpr(C, CXXOperatorCallExprClass, Empty) { }
61
62
63   /// getOperator - Returns the kind of overloaded operator that this
64   /// expression refers to.
65   OverloadedOperatorKind getOperator() const { return Operator; }
66   void setOperator(OverloadedOperatorKind Kind) { Operator = Kind; }
67
68   /// getOperatorLoc - Returns the location of the operator symbol in
69   /// the expression. When @c getOperator()==OO_Call, this is the
70   /// location of the right parentheses; when @c
71   /// getOperator()==OO_Subscript, this is the location of the right
72   /// bracket.
73   SourceLocation getOperatorLoc() const { return getRParenLoc(); }
74
75   SourceRange getSourceRange() const;
76
77   static bool classof(const Stmt *T) {
78     return T->getStmtClass() == CXXOperatorCallExprClass;
79   }
80   static bool classof(const CXXOperatorCallExpr *) { return true; }
81 };
82
83 /// CXXMemberCallExpr - Represents a call to a member function that
84 /// may be written either with member call syntax (e.g., "obj.func()"
85 /// or "objptr->func()") or with normal function-call syntax
86 /// ("func()") within a member function that ends up calling a member
87 /// function. The callee in either case is a MemberExpr that contains
88 /// both the object argument and the member function, while the
89 /// arguments are the arguments within the parentheses (not including
90 /// the object argument).
91 class CXXMemberCallExpr : public CallExpr {
92 public:
93   CXXMemberCallExpr(ASTContext &C, Expr *fn, Expr **args, unsigned numargs,
94                     QualType t, ExprValueKind VK, SourceLocation RP)
95     : CallExpr(C, CXXMemberCallExprClass, fn, 0, args, numargs, t, VK, RP) {}
96
97   CXXMemberCallExpr(ASTContext &C, EmptyShell Empty)
98     : CallExpr(C, CXXMemberCallExprClass, Empty) { }
99
100   /// getImplicitObjectArgument - Retrieves the implicit object
101   /// argument for the member call. For example, in "x.f(5)", this
102   /// operation would return "x".
103   Expr *getImplicitObjectArgument() const;
104   
105   /// Retrieves the declaration of the called method.
106   CXXMethodDecl *getMethodDecl() const;
107
108   /// getRecordDecl - Retrieves the CXXRecordDecl for the underlying type of
109   /// the implicit object argument. Note that this is may not be the same
110   /// declaration as that of the class context of the CXXMethodDecl which this
111   /// function is calling.
112   /// FIXME: Returns 0 for member pointer call exprs.
113   CXXRecordDecl *getRecordDecl();
114
115   static bool classof(const Stmt *T) {
116     return T->getStmtClass() == CXXMemberCallExprClass;
117   }
118   static bool classof(const CXXMemberCallExpr *) { return true; }
119 };
120
121 /// CUDAKernelCallExpr - Represents a call to a CUDA kernel function.
122 class CUDAKernelCallExpr : public CallExpr {
123 private:
124   enum { CONFIG, END_PREARG };
125
126 public:
127   CUDAKernelCallExpr(ASTContext &C, Expr *fn, CallExpr *Config,
128                      Expr **args, unsigned numargs, QualType t,
129                      ExprValueKind VK, SourceLocation RP)
130     : CallExpr(C, CUDAKernelCallExprClass, fn, END_PREARG, args, numargs, t, VK,
131                RP) {
132     setConfig(Config);
133   }
134
135   CUDAKernelCallExpr(ASTContext &C, EmptyShell Empty)
136     : CallExpr(C, CUDAKernelCallExprClass, END_PREARG, Empty) { }
137
138   const CallExpr *getConfig() const {
139     return cast_or_null<CallExpr>(getPreArg(CONFIG));
140   }
141   CallExpr *getConfig() { return cast_or_null<CallExpr>(getPreArg(CONFIG)); }
142   void setConfig(CallExpr *E) { setPreArg(CONFIG, E); }
143
144   static bool classof(const Stmt *T) {
145     return T->getStmtClass() == CUDAKernelCallExprClass;
146   }
147   static bool classof(const CUDAKernelCallExpr *) { return true; }
148 };
149
150 /// CXXNamedCastExpr - Abstract class common to all of the C++ "named"
151 /// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c
152 /// const_cast.
153 ///
154 /// This abstract class is inherited by all of the classes
155 /// representing "named" casts, e.g., CXXStaticCastExpr,
156 /// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr.
157 class CXXNamedCastExpr : public ExplicitCastExpr {
158 private:
159   SourceLocation Loc; // the location of the casting op
160   SourceLocation RParenLoc; // the location of the right parenthesis
161   
162 protected:
163   CXXNamedCastExpr(StmtClass SC, QualType ty, ExprValueKind VK,
164                    CastKind kind, Expr *op, unsigned PathSize,
165                    TypeSourceInfo *writtenTy, SourceLocation l,
166                    SourceLocation RParenLoc)
167     : ExplicitCastExpr(SC, ty, VK, kind, op, PathSize, writtenTy), Loc(l),
168       RParenLoc(RParenLoc) {}
169
170   explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize)
171     : ExplicitCastExpr(SC, Shell, PathSize) { }
172
173   friend class ASTStmtReader;
174   
175 public:
176   const char *getCastName() const;
177
178   /// \brief Retrieve the location of the cast operator keyword, e.g.,
179   /// "static_cast".
180   SourceLocation getOperatorLoc() const { return Loc; }
181
182   /// \brief Retrieve the location of the closing parenthesis.
183   SourceLocation getRParenLoc() const { return RParenLoc; }
184   
185   SourceRange getSourceRange() const {
186     return SourceRange(Loc, RParenLoc);
187   }
188   static bool classof(const Stmt *T) {
189     switch (T->getStmtClass()) {
190     case CXXStaticCastExprClass:
191     case CXXDynamicCastExprClass:
192     case CXXReinterpretCastExprClass:
193     case CXXConstCastExprClass:
194       return true;
195     default:
196       return false;
197     }
198   }
199   static bool classof(const CXXNamedCastExpr *) { return true; }
200 };
201
202 /// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]).
203 ///
204 /// This expression node represents a C++ static cast, e.g.,
205 /// @c static_cast<int>(1.0).
206 class CXXStaticCastExpr : public CXXNamedCastExpr {
207   CXXStaticCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op,
208                     unsigned pathSize, TypeSourceInfo *writtenTy,
209                     SourceLocation l, SourceLocation RParenLoc)
210     : CXXNamedCastExpr(CXXStaticCastExprClass, ty, vk, kind, op, pathSize,
211                        writtenTy, l, RParenLoc) {}
212
213   explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize)
214     : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize) { }
215
216 public:
217   static CXXStaticCastExpr *Create(ASTContext &Context, QualType T,
218                                    ExprValueKind VK, CastKind K, Expr *Op,
219                                    const CXXCastPath *Path,
220                                    TypeSourceInfo *Written, SourceLocation L, 
221                                    SourceLocation RParenLoc);
222   static CXXStaticCastExpr *CreateEmpty(ASTContext &Context,
223                                         unsigned PathSize);
224
225   static bool classof(const Stmt *T) {
226     return T->getStmtClass() == CXXStaticCastExprClass;
227   }
228   static bool classof(const CXXStaticCastExpr *) { return true; }
229 };
230
231 /// CXXDynamicCastExpr - A C++ @c dynamic_cast expression
232 /// (C++ [expr.dynamic.cast]), which may perform a run-time check to
233 /// determine how to perform the type cast.
234 ///
235 /// This expression node represents a dynamic cast, e.g.,
236 /// @c dynamic_cast<Derived*>(BasePtr).
237 class CXXDynamicCastExpr : public CXXNamedCastExpr {
238   CXXDynamicCastExpr(QualType ty, ExprValueKind VK, CastKind kind,
239                      Expr *op, unsigned pathSize, TypeSourceInfo *writtenTy,
240                      SourceLocation l, SourceLocation RParenLoc)
241     : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, VK, kind, op, pathSize,
242                        writtenTy, l, RParenLoc) {}
243
244   explicit CXXDynamicCastExpr(EmptyShell Empty, unsigned pathSize)
245     : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize) { }
246
247 public:
248   static CXXDynamicCastExpr *Create(ASTContext &Context, QualType T,
249                                     ExprValueKind VK, CastKind Kind, Expr *Op,
250                                     const CXXCastPath *Path,
251                                     TypeSourceInfo *Written, SourceLocation L, 
252                                     SourceLocation RParenLoc);
253   
254   static CXXDynamicCastExpr *CreateEmpty(ASTContext &Context,
255                                          unsigned pathSize);
256
257   bool isAlwaysNull() const;
258
259   static bool classof(const Stmt *T) {
260     return T->getStmtClass() == CXXDynamicCastExprClass;
261   }
262   static bool classof(const CXXDynamicCastExpr *) { return true; }
263 };
264
265 /// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++
266 /// [expr.reinterpret.cast]), which provides a differently-typed view
267 /// of a value but performs no actual work at run time.
268 ///
269 /// This expression node represents a reinterpret cast, e.g.,
270 /// @c reinterpret_cast<int>(VoidPtr).
271 class CXXReinterpretCastExpr : public CXXNamedCastExpr {
272   CXXReinterpretCastExpr(QualType ty, ExprValueKind vk, CastKind kind,
273                          Expr *op, unsigned pathSize,
274                          TypeSourceInfo *writtenTy, SourceLocation l, 
275                          SourceLocation RParenLoc)
276     : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, vk, kind, op,
277                        pathSize, writtenTy, l, RParenLoc) {}
278
279   CXXReinterpretCastExpr(EmptyShell Empty, unsigned pathSize)
280     : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize) { }
281
282 public:
283   static CXXReinterpretCastExpr *Create(ASTContext &Context, QualType T,
284                                         ExprValueKind VK, CastKind Kind,
285                                         Expr *Op, const CXXCastPath *Path,
286                                  TypeSourceInfo *WrittenTy, SourceLocation L, 
287                                         SourceLocation RParenLoc);
288   static CXXReinterpretCastExpr *CreateEmpty(ASTContext &Context,
289                                              unsigned pathSize);
290
291   static bool classof(const Stmt *T) {
292     return T->getStmtClass() == CXXReinterpretCastExprClass;
293   }
294   static bool classof(const CXXReinterpretCastExpr *) { return true; }
295 };
296
297 /// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]),
298 /// which can remove type qualifiers but does not change the underlying value.
299 ///
300 /// This expression node represents a const cast, e.g.,
301 /// @c const_cast<char*>(PtrToConstChar).
302 class CXXConstCastExpr : public CXXNamedCastExpr {
303   CXXConstCastExpr(QualType ty, ExprValueKind VK, Expr *op,
304                    TypeSourceInfo *writtenTy, SourceLocation l, 
305                    SourceLocation RParenLoc)
306     : CXXNamedCastExpr(CXXConstCastExprClass, ty, VK, CK_NoOp, op, 
307                        0, writtenTy, l, RParenLoc) {}
308
309   explicit CXXConstCastExpr(EmptyShell Empty)
310     : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0) { }
311
312 public:
313   static CXXConstCastExpr *Create(ASTContext &Context, QualType T,
314                                   ExprValueKind VK, Expr *Op,
315                                   TypeSourceInfo *WrittenTy, SourceLocation L, 
316                                   SourceLocation RParenLoc);
317   static CXXConstCastExpr *CreateEmpty(ASTContext &Context);
318
319   static bool classof(const Stmt *T) {
320     return T->getStmtClass() == CXXConstCastExprClass;
321   }
322   static bool classof(const CXXConstCastExpr *) { return true; }
323 };
324
325 /// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal.
326 ///
327 class CXXBoolLiteralExpr : public Expr {
328   bool Value;
329   SourceLocation Loc;
330 public:
331   CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) :
332     Expr(CXXBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
333          false),
334     Value(val), Loc(l) {}
335
336   explicit CXXBoolLiteralExpr(EmptyShell Empty)
337     : Expr(CXXBoolLiteralExprClass, Empty) { }
338
339   bool getValue() const { return Value; }
340   void setValue(bool V) { Value = V; }
341
342   SourceRange getSourceRange() const { return SourceRange(Loc); }
343
344   SourceLocation getLocation() const { return Loc; }
345   void setLocation(SourceLocation L) { Loc = L; }
346
347   static bool classof(const Stmt *T) {
348     return T->getStmtClass() == CXXBoolLiteralExprClass;
349   }
350   static bool classof(const CXXBoolLiteralExpr *) { return true; }
351
352   // Iterators
353   child_range children() { return child_range(); }
354 };
355
356 /// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal
357 class CXXNullPtrLiteralExpr : public Expr {
358   SourceLocation Loc;
359 public:
360   CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) :
361     Expr(CXXNullPtrLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
362          false),
363     Loc(l) {}
364
365   explicit CXXNullPtrLiteralExpr(EmptyShell Empty)
366     : Expr(CXXNullPtrLiteralExprClass, Empty) { }
367
368   SourceRange getSourceRange() const { return SourceRange(Loc); }
369
370   SourceLocation getLocation() const { return Loc; }
371   void setLocation(SourceLocation L) { Loc = L; }
372
373   static bool classof(const Stmt *T) {
374     return T->getStmtClass() == CXXNullPtrLiteralExprClass;
375   }
376   static bool classof(const CXXNullPtrLiteralExpr *) { return true; }
377
378   child_range children() { return child_range(); }
379 };
380
381 /// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets
382 /// the type_info that corresponds to the supplied type, or the (possibly
383 /// dynamic) type of the supplied expression.
384 ///
385 /// This represents code like @c typeid(int) or @c typeid(*objPtr)
386 class CXXTypeidExpr : public Expr {
387 private:
388   llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
389   SourceRange Range;
390
391 public:
392   CXXTypeidExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R)
393     : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary,
394            // typeid is never type-dependent (C++ [temp.dep.expr]p4)
395            false,
396            // typeid is value-dependent if the type or expression are dependent
397            Operand->getType()->isDependentType(),
398            Operand->getType()->containsUnexpandedParameterPack()),
399       Operand(Operand), Range(R) { }
400   
401   CXXTypeidExpr(QualType Ty, Expr *Operand, SourceRange R)
402     : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary,
403         // typeid is never type-dependent (C++ [temp.dep.expr]p4)
404            false,
405         // typeid is value-dependent if the type or expression are dependent
406            Operand->isTypeDependent() || Operand->isValueDependent(),
407            Operand->containsUnexpandedParameterPack()),
408       Operand(Operand), Range(R) { }
409
410   CXXTypeidExpr(EmptyShell Empty, bool isExpr)
411     : Expr(CXXTypeidExprClass, Empty) {
412     if (isExpr)
413       Operand = (Expr*)0;
414     else
415       Operand = (TypeSourceInfo*)0;
416   }
417   
418   bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
419   
420   /// \brief Retrieves the type operand of this typeid() expression after
421   /// various required adjustments (removing reference types, cv-qualifiers).
422   QualType getTypeOperand() const;
423
424   /// \brief Retrieve source information for the type operand.
425   TypeSourceInfo *getTypeOperandSourceInfo() const {
426     assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
427     return Operand.get<TypeSourceInfo *>();
428   }
429
430   void setTypeOperandSourceInfo(TypeSourceInfo *TSI) {
431     assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
432     Operand = TSI;
433   }
434   
435   Expr *getExprOperand() const {
436     assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
437     return static_cast<Expr*>(Operand.get<Stmt *>());
438   }
439   
440   void setExprOperand(Expr *E) {
441     assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
442     Operand = E;
443   }
444   
445   SourceRange getSourceRange() const { return Range; }
446   void setSourceRange(SourceRange R) { Range = R; }
447   
448   static bool classof(const Stmt *T) {
449     return T->getStmtClass() == CXXTypeidExprClass;
450   }
451   static bool classof(const CXXTypeidExpr *) { return true; }
452
453   // Iterators
454   child_range children() {
455     if (isTypeOperand()) return child_range();
456     Stmt **begin = reinterpret_cast<Stmt**>(&Operand);
457     return child_range(begin, begin + 1);
458   }
459 };
460
461 /// CXXUuidofExpr - A microsoft C++ @c __uuidof expression, which gets
462 /// the _GUID that corresponds to the supplied type or expression.
463 ///
464 /// This represents code like @c __uuidof(COMTYPE) or @c __uuidof(*comPtr)
465 class CXXUuidofExpr : public Expr {
466 private:
467   llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
468   SourceRange Range;
469
470 public:
471   CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R)
472     : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary,
473            false, Operand->getType()->isDependentType(),
474            Operand->getType()->containsUnexpandedParameterPack()),
475       Operand(Operand), Range(R) { }
476   
477   CXXUuidofExpr(QualType Ty, Expr *Operand, SourceRange R)
478     : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary,
479            false, Operand->isTypeDependent(),
480            Operand->containsUnexpandedParameterPack()),
481       Operand(Operand), Range(R) { }
482
483   CXXUuidofExpr(EmptyShell Empty, bool isExpr)
484     : Expr(CXXUuidofExprClass, Empty) {
485     if (isExpr)
486       Operand = (Expr*)0;
487     else
488       Operand = (TypeSourceInfo*)0;
489   }
490   
491   bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
492   
493   /// \brief Retrieves the type operand of this __uuidof() expression after
494   /// various required adjustments (removing reference types, cv-qualifiers).
495   QualType getTypeOperand() const;
496
497   /// \brief Retrieve source information for the type operand.
498   TypeSourceInfo *getTypeOperandSourceInfo() const {
499     assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
500     return Operand.get<TypeSourceInfo *>();
501   }
502
503   void setTypeOperandSourceInfo(TypeSourceInfo *TSI) {
504     assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
505     Operand = TSI;
506   }
507   
508   Expr *getExprOperand() const {
509     assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)");
510     return static_cast<Expr*>(Operand.get<Stmt *>());
511   }
512   
513   void setExprOperand(Expr *E) {
514     assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)");
515     Operand = E;
516   }
517
518   SourceRange getSourceRange() const { return Range; }
519   void setSourceRange(SourceRange R) { Range = R; }
520   
521   static bool classof(const Stmt *T) {
522     return T->getStmtClass() == CXXUuidofExprClass;
523   }
524   static bool classof(const CXXUuidofExpr *) { return true; }
525
526   // Iterators
527   child_range children() {
528     if (isTypeOperand()) return child_range();
529     Stmt **begin = reinterpret_cast<Stmt**>(&Operand);
530     return child_range(begin, begin + 1);
531   }
532 };
533
534 /// CXXThisExpr - Represents the "this" expression in C++, which is a
535 /// pointer to the object on which the current member function is
536 /// executing (C++ [expr.prim]p3). Example:
537 ///
538 /// @code
539 /// class Foo {
540 /// public:
541 ///   void bar();
542 ///   void test() { this->bar(); }
543 /// };
544 /// @endcode
545 class CXXThisExpr : public Expr {
546   SourceLocation Loc;
547   bool Implicit : 1;
548   
549 public:
550   CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit)
551     : Expr(CXXThisExprClass, Type, VK_RValue, OK_Ordinary,
552            // 'this' is type-dependent if the class type of the enclosing
553            // member function is dependent (C++ [temp.dep.expr]p2)
554            Type->isDependentType(), Type->isDependentType(),
555            /*ContainsUnexpandedParameterPack=*/false),
556       Loc(L), Implicit(isImplicit) { }
557
558   CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {}
559
560   SourceLocation getLocation() const { return Loc; }
561   void setLocation(SourceLocation L) { Loc = L; }
562
563   SourceRange getSourceRange() const { return SourceRange(Loc); }
564
565   bool isImplicit() const { return Implicit; }
566   void setImplicit(bool I) { Implicit = I; }
567   
568   static bool classof(const Stmt *T) {
569     return T->getStmtClass() == CXXThisExprClass;
570   }
571   static bool classof(const CXXThisExpr *) { return true; }
572
573   // Iterators
574   child_range children() { return child_range(); }
575 };
576
577 ///  CXXThrowExpr - [C++ 15] C++ Throw Expression.  This handles
578 ///  'throw' and 'throw' assignment-expression.  When
579 ///  assignment-expression isn't present, Op will be null.
580 ///
581 class CXXThrowExpr : public Expr {
582   Stmt *Op;
583   SourceLocation ThrowLoc;
584 public:
585   // Ty is the void type which is used as the result type of the
586   // exepression.  The l is the location of the throw keyword.  expr
587   // can by null, if the optional expression to throw isn't present.
588   CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) :
589     Expr(CXXThrowExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
590          expr && expr->containsUnexpandedParameterPack()),
591     Op(expr), ThrowLoc(l) {}
592   CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {}
593
594   const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); }
595   Expr *getSubExpr() { return cast_or_null<Expr>(Op); }
596   void setSubExpr(Expr *E) { Op = E; }
597
598   SourceLocation getThrowLoc() const { return ThrowLoc; }
599   void setThrowLoc(SourceLocation L) { ThrowLoc = L; }
600
601   SourceRange getSourceRange() const {
602     if (getSubExpr() == 0)
603       return SourceRange(ThrowLoc, ThrowLoc);
604     return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd());
605   }
606
607   static bool classof(const Stmt *T) {
608     return T->getStmtClass() == CXXThrowExprClass;
609   }
610   static bool classof(const CXXThrowExpr *) { return true; }
611
612   // Iterators
613   child_range children() {
614     return child_range(&Op, Op ? &Op+1 : &Op);
615   }
616 };
617
618 /// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a
619 /// function call argument that was created from the corresponding
620 /// parameter's default argument, when the call did not explicitly
621 /// supply arguments for all of the parameters.
622 class CXXDefaultArgExpr : public Expr {
623   /// \brief The parameter whose default is being used.
624   ///
625   /// When the bit is set, the subexpression is stored after the 
626   /// CXXDefaultArgExpr itself. When the bit is clear, the parameter's
627   /// actual default expression is the subexpression.
628   llvm::PointerIntPair<ParmVarDecl *, 1, bool> Param;
629
630   /// \brief The location where the default argument expression was used.
631   SourceLocation Loc;
632   
633   CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param)
634     : Expr(SC, 
635            param->hasUnparsedDefaultArg()
636              ? param->getType().getNonReferenceType()
637              : param->getDefaultArg()->getType(),
638            param->getDefaultArg()->getValueKind(),
639            param->getDefaultArg()->getObjectKind(), false, false, false),
640       Param(param, false), Loc(Loc) { }
641
642   CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param, 
643                     Expr *SubExpr)
644     : Expr(SC, SubExpr->getType(),
645            SubExpr->getValueKind(), SubExpr->getObjectKind(),
646            false, false, false), 
647       Param(param, true), Loc(Loc) {
648     *reinterpret_cast<Expr **>(this + 1) = SubExpr;
649   }
650   
651 public:
652   CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {}
653
654   
655   // Param is the parameter whose default argument is used by this
656   // expression.
657   static CXXDefaultArgExpr *Create(ASTContext &C, SourceLocation Loc,
658                                    ParmVarDecl *Param) {
659     return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param);
660   }
661
662   // Param is the parameter whose default argument is used by this
663   // expression, and SubExpr is the expression that will actually be used.
664   static CXXDefaultArgExpr *Create(ASTContext &C, 
665                                    SourceLocation Loc,
666                                    ParmVarDecl *Param, 
667                                    Expr *SubExpr);
668   
669   // Retrieve the parameter that the argument was created from.
670   const ParmVarDecl *getParam() const { return Param.getPointer(); }
671   ParmVarDecl *getParam() { return Param.getPointer(); }
672   
673   // Retrieve the actual argument to the function call.
674   const Expr *getExpr() const { 
675     if (Param.getInt())
676       return *reinterpret_cast<Expr const * const*> (this + 1);
677     return getParam()->getDefaultArg(); 
678   }
679   Expr *getExpr() { 
680     if (Param.getInt())
681       return *reinterpret_cast<Expr **> (this + 1);
682     return getParam()->getDefaultArg(); 
683   }
684
685   /// \brief Retrieve the location where this default argument was actually 
686   /// used.
687   SourceLocation getUsedLocation() const { return Loc; }
688   
689   SourceRange getSourceRange() const {
690     // Default argument expressions have no representation in the
691     // source, so they have an empty source range.
692     return SourceRange();
693   }
694
695   static bool classof(const Stmt *T) {
696     return T->getStmtClass() == CXXDefaultArgExprClass;
697   }
698   static bool classof(const CXXDefaultArgExpr *) { return true; }
699
700   // Iterators
701   child_range children() { return child_range(); }
702
703   friend class ASTStmtReader;
704   friend class ASTStmtWriter;
705 };
706
707 /// CXXTemporary - Represents a C++ temporary.
708 class CXXTemporary {
709   /// Destructor - The destructor that needs to be called.
710   const CXXDestructorDecl *Destructor;
711
712   CXXTemporary(const CXXDestructorDecl *destructor)
713     : Destructor(destructor) { }
714
715 public:
716   static CXXTemporary *Create(ASTContext &C,
717                               const CXXDestructorDecl *Destructor);
718
719   const CXXDestructorDecl *getDestructor() const { return Destructor; }
720 };
721
722 /// \brief Represents binding an expression to a temporary.
723 ///
724 /// This ensures the destructor is called for the temporary. It should only be
725 /// needed for non-POD, non-trivially destructable class types. For example:
726 ///
727 /// \code
728 ///   struct S {
729 ///     S() { }  // User defined constructor makes S non-POD.
730 ///     ~S() { } // User defined destructor makes it non-trivial.
731 ///   };
732 ///   void test() {
733 ///     const S &s_ref = S(); // Requires a CXXBindTemporaryExpr.
734 ///   }
735 /// \endcode
736 class CXXBindTemporaryExpr : public Expr {
737   CXXTemporary *Temp;
738
739   Stmt *SubExpr;
740
741   CXXBindTemporaryExpr(CXXTemporary *temp, Expr* SubExpr)
742    : Expr(CXXBindTemporaryExprClass, SubExpr->getType(),
743           VK_RValue, OK_Ordinary, SubExpr->isTypeDependent(), 
744           SubExpr->isValueDependent(),
745           SubExpr->containsUnexpandedParameterPack()),
746      Temp(temp), SubExpr(SubExpr) { }
747
748 public:
749   CXXBindTemporaryExpr(EmptyShell Empty)
750     : Expr(CXXBindTemporaryExprClass, Empty), Temp(0), SubExpr(0) {}
751   
752   static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp,
753                                       Expr* SubExpr);
754
755   CXXTemporary *getTemporary() { return Temp; }
756   const CXXTemporary *getTemporary() const { return Temp; }
757   void setTemporary(CXXTemporary *T) { Temp = T; }
758
759   const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
760   Expr *getSubExpr() { return cast<Expr>(SubExpr); }
761   void setSubExpr(Expr *E) { SubExpr = E; }
762
763   SourceRange getSourceRange() const { 
764     return SubExpr->getSourceRange();
765   }
766
767   // Implement isa/cast/dyncast/etc.
768   static bool classof(const Stmt *T) {
769     return T->getStmtClass() == CXXBindTemporaryExprClass;
770   }
771   static bool classof(const CXXBindTemporaryExpr *) { return true; }
772
773   // Iterators
774   child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
775 };
776
777 /// CXXConstructExpr - Represents a call to a C++ constructor.
778 class CXXConstructExpr : public Expr {
779 public:
780   enum ConstructionKind {
781     CK_Complete,
782     CK_NonVirtualBase,
783     CK_VirtualBase,
784     CK_Delegating
785   };
786     
787 private:
788   CXXConstructorDecl *Constructor;
789
790   SourceLocation Loc;
791   SourceRange ParenRange;
792   bool Elidable : 1;
793   bool ZeroInitialization : 1;
794   unsigned ConstructKind : 2;
795   Stmt **Args;
796   unsigned NumArgs;
797
798 protected:
799   CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
800                    SourceLocation Loc,
801                    CXXConstructorDecl *d, bool elidable,
802                    Expr **args, unsigned numargs,
803                    bool ZeroInitialization = false,
804                    ConstructionKind ConstructKind = CK_Complete,
805                    SourceRange ParenRange = SourceRange());
806
807   /// \brief Construct an empty C++ construction expression.
808   CXXConstructExpr(StmtClass SC, EmptyShell Empty)
809     : Expr(SC, Empty), Constructor(0), Elidable(0), ZeroInitialization(0),
810       ConstructKind(0), Args(0), NumArgs(0) { }
811
812 public:
813   /// \brief Construct an empty C++ construction expression.
814   explicit CXXConstructExpr(EmptyShell Empty)
815     : Expr(CXXConstructExprClass, Empty), Constructor(0),
816       Elidable(0), ZeroInitialization(0),
817       ConstructKind(0), Args(0), NumArgs(0) { }
818
819   static CXXConstructExpr *Create(ASTContext &C, QualType T,
820                                   SourceLocation Loc,
821                                   CXXConstructorDecl *D, bool Elidable,
822                                   Expr **Args, unsigned NumArgs,
823                                   bool ZeroInitialization = false,
824                                   ConstructionKind ConstructKind = CK_Complete,
825                                   SourceRange ParenRange = SourceRange());
826
827
828   CXXConstructorDecl* getConstructor() const { return Constructor; }
829   void setConstructor(CXXConstructorDecl *C) { Constructor = C; }
830   
831   SourceLocation getLocation() const { return Loc; }
832   void setLocation(SourceLocation Loc) { this->Loc = Loc; }
833   
834   /// \brief Whether this construction is elidable.
835   bool isElidable() const { return Elidable; }
836   void setElidable(bool E) { Elidable = E; }
837   
838   /// \brief Whether this construction first requires
839   /// zero-initialization before the initializer is called.
840   bool requiresZeroInitialization() const { return ZeroInitialization; }
841   void setRequiresZeroInitialization(bool ZeroInit) {
842     ZeroInitialization = ZeroInit;
843   }
844   
845   /// \brief Determines whether this constructor is actually constructing
846   /// a base class (rather than a complete object).
847   ConstructionKind getConstructionKind() const {
848     return (ConstructionKind)ConstructKind;
849   }
850   void setConstructionKind(ConstructionKind CK) { 
851     ConstructKind = CK;
852   }
853   
854   typedef ExprIterator arg_iterator;
855   typedef ConstExprIterator const_arg_iterator;
856
857   arg_iterator arg_begin() { return Args; }
858   arg_iterator arg_end() { return Args + NumArgs; }
859   const_arg_iterator arg_begin() const { return Args; }
860   const_arg_iterator arg_end() const { return Args + NumArgs; }
861
862   Expr **getArgs() const { return reinterpret_cast<Expr **>(Args); }
863   unsigned getNumArgs() const { return NumArgs; }
864
865   /// getArg - Return the specified argument.
866   Expr *getArg(unsigned Arg) {
867     assert(Arg < NumArgs && "Arg access out of range!");
868     return cast<Expr>(Args[Arg]);
869   }
870   const Expr *getArg(unsigned Arg) const {
871     assert(Arg < NumArgs && "Arg access out of range!");
872     return cast<Expr>(Args[Arg]);
873   }
874
875   /// setArg - Set the specified argument.
876   void setArg(unsigned Arg, Expr *ArgExpr) {
877     assert(Arg < NumArgs && "Arg access out of range!");
878     Args[Arg] = ArgExpr;
879   }
880
881   SourceRange getSourceRange() const;
882   SourceRange getParenRange() const { return ParenRange; }
883
884   static bool classof(const Stmt *T) {
885     return T->getStmtClass() == CXXConstructExprClass ||
886       T->getStmtClass() == CXXTemporaryObjectExprClass;
887   }
888   static bool classof(const CXXConstructExpr *) { return true; }
889
890   // Iterators
891   child_range children() {
892     return child_range(&Args[0], &Args[0]+NumArgs);
893   }
894
895   friend class ASTStmtReader;
896 };
897
898 /// CXXFunctionalCastExpr - Represents an explicit C++ type conversion
899 /// that uses "functional" notion (C++ [expr.type.conv]). Example: @c
900 /// x = int(0.5);
901 class CXXFunctionalCastExpr : public ExplicitCastExpr {
902   SourceLocation TyBeginLoc;
903   SourceLocation RParenLoc;
904
905   CXXFunctionalCastExpr(QualType ty, ExprValueKind VK,
906                         TypeSourceInfo *writtenTy,
907                         SourceLocation tyBeginLoc, CastKind kind,
908                         Expr *castExpr, unsigned pathSize,
909                         SourceLocation rParenLoc) 
910     : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, VK, kind,
911                        castExpr, pathSize, writtenTy),
912       TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
913
914   explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize)
915     : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize) { }
916
917 public:
918   static CXXFunctionalCastExpr *Create(ASTContext &Context, QualType T,
919                                        ExprValueKind VK,
920                                        TypeSourceInfo *Written,
921                                        SourceLocation TyBeginLoc,
922                                        CastKind Kind, Expr *Op,
923                                        const CXXCastPath *Path,
924                                        SourceLocation RPLoc);
925   static CXXFunctionalCastExpr *CreateEmpty(ASTContext &Context,
926                                             unsigned PathSize);
927
928   SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
929   void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; }
930   SourceLocation getRParenLoc() const { return RParenLoc; }
931   void setRParenLoc(SourceLocation L) { RParenLoc = L; }
932
933   SourceRange getSourceRange() const {
934     return SourceRange(TyBeginLoc, RParenLoc);
935   }
936   static bool classof(const Stmt *T) {
937     return T->getStmtClass() == CXXFunctionalCastExprClass;
938   }
939   static bool classof(const CXXFunctionalCastExpr *) { return true; }
940 };
941
942 /// @brief Represents a C++ functional cast expression that builds a
943 /// temporary object.
944 ///
945 /// This expression type represents a C++ "functional" cast
946 /// (C++[expr.type.conv]) with N != 1 arguments that invokes a
947 /// constructor to build a temporary object. With N == 1 arguments the 
948 /// functional cast expression will be represented by CXXFunctionalCastExpr.
949 /// Example:
950 /// @code
951 /// struct X { X(int, float); }
952 ///
953 /// X create_X() {
954 ///   return X(1, 3.14f); // creates a CXXTemporaryObjectExpr
955 /// };
956 /// @endcode
957 class CXXTemporaryObjectExpr : public CXXConstructExpr {
958   TypeSourceInfo *Type;
959
960 public:
961   CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons,
962                          TypeSourceInfo *Type,
963                          Expr **Args,unsigned NumArgs,
964                          SourceRange parenRange,
965                          bool ZeroInitialization = false);
966   explicit CXXTemporaryObjectExpr(EmptyShell Empty)
967     : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty), Type() { }
968
969   TypeSourceInfo *getTypeSourceInfo() const { return Type; }
970
971   SourceRange getSourceRange() const;
972   
973   static bool classof(const Stmt *T) {
974     return T->getStmtClass() == CXXTemporaryObjectExprClass;
975   }
976   static bool classof(const CXXTemporaryObjectExpr *) { return true; }
977
978   friend class ASTStmtReader;
979 };
980
981 /// CXXScalarValueInitExpr - [C++ 5.2.3p2]
982 /// Expression "T()" which creates a value-initialized rvalue of type
983 /// T, which is a non-class type.
984 ///
985 class CXXScalarValueInitExpr : public Expr {
986   SourceLocation RParenLoc;
987   TypeSourceInfo *TypeInfo;
988
989   friend class ASTStmtReader;
990   
991 public:
992   /// \brief Create an explicitly-written scalar-value initialization 
993   /// expression.
994   CXXScalarValueInitExpr(QualType Type,
995                          TypeSourceInfo *TypeInfo,
996                          SourceLocation rParenLoc ) :
997     Expr(CXXScalarValueInitExprClass, Type, VK_RValue, OK_Ordinary,
998          false, false, false),
999     RParenLoc(rParenLoc), TypeInfo(TypeInfo) {}
1000
1001   explicit CXXScalarValueInitExpr(EmptyShell Shell)
1002     : Expr(CXXScalarValueInitExprClass, Shell) { }
1003
1004   TypeSourceInfo *getTypeSourceInfo() const {
1005     return TypeInfo;
1006   }
1007   
1008   SourceLocation getRParenLoc() const { return RParenLoc; }
1009
1010   SourceRange getSourceRange() const;
1011
1012   static bool classof(const Stmt *T) {
1013     return T->getStmtClass() == CXXScalarValueInitExprClass;
1014   }
1015   static bool classof(const CXXScalarValueInitExpr *) { return true; }
1016
1017   // Iterators
1018   child_range children() { return child_range(); }
1019 };
1020
1021 /// CXXNewExpr - A new expression for memory allocation and constructor calls,
1022 /// e.g: "new CXXNewExpr(foo)".
1023 class CXXNewExpr : public Expr {
1024   // Was the usage ::new, i.e. is the global new to be used?
1025   bool GlobalNew : 1;
1026   // Is there an initializer? If not, built-ins are uninitialized, else they're
1027   // value-initialized.
1028   bool Initializer : 1;
1029   // Do we allocate an array? If so, the first SubExpr is the size expression.
1030   bool Array : 1;
1031   // If this is an array allocation, does the usual deallocation
1032   // function for the allocated type want to know the allocated size?
1033   bool UsualArrayDeleteWantsSize : 1;
1034   // The number of placement new arguments.
1035   unsigned NumPlacementArgs : 14;
1036   // The number of constructor arguments. This may be 1 even for non-class
1037   // types; use the pseudo copy constructor.
1038   unsigned NumConstructorArgs : 14;
1039   // Contains an optional array size expression, any number of optional
1040   // placement arguments, and any number of optional constructor arguments,
1041   // in that order.
1042   Stmt **SubExprs;
1043   // Points to the allocation function used.
1044   FunctionDecl *OperatorNew;
1045   // Points to the deallocation function used in case of error. May be null.
1046   FunctionDecl *OperatorDelete;
1047   // Points to the constructor used. Cannot be null if AllocType is a record;
1048   // it would still point at the default constructor (even an implicit one).
1049   // Must be null for all other types.
1050   CXXConstructorDecl *Constructor;
1051
1052   /// \brief The allocated type-source information, as written in the source.
1053   TypeSourceInfo *AllocatedTypeInfo;
1054   
1055   /// \brief If the allocated type was expressed as a parenthesized type-id, 
1056   /// the source range covering the parenthesized type-id.
1057   SourceRange TypeIdParens;
1058   
1059   SourceLocation StartLoc;
1060   SourceLocation EndLoc;
1061   SourceLocation ConstructorLParen;
1062   SourceLocation ConstructorRParen;
1063
1064   friend class ASTStmtReader;
1065 public:
1066   CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
1067              Expr **placementArgs, unsigned numPlaceArgs,
1068              SourceRange TypeIdParens,
1069              Expr *arraySize, CXXConstructorDecl *constructor, bool initializer,
1070              Expr **constructorArgs, unsigned numConsArgs,
1071              FunctionDecl *operatorDelete, bool usualArrayDeleteWantsSize,
1072              QualType ty, TypeSourceInfo *AllocatedTypeInfo,
1073              SourceLocation startLoc, SourceLocation endLoc,
1074              SourceLocation constructorLParen,
1075              SourceLocation constructorRParen);
1076   explicit CXXNewExpr(EmptyShell Shell)
1077     : Expr(CXXNewExprClass, Shell), SubExprs(0) { }
1078
1079   void AllocateArgsArray(ASTContext &C, bool isArray, unsigned numPlaceArgs,
1080                          unsigned numConsArgs);
1081   
1082   QualType getAllocatedType() const {
1083     assert(getType()->isPointerType());
1084     return getType()->getAs<PointerType>()->getPointeeType();
1085   }
1086
1087   TypeSourceInfo *getAllocatedTypeSourceInfo() const {
1088     return AllocatedTypeInfo;
1089   }
1090
1091   /// \brief True if the allocation result needs to be null-checked.
1092   /// C++0x [expr.new]p13:
1093   ///   If the allocation function returns null, initialization shall
1094   ///   not be done, the deallocation function shall not be called,
1095   ///   and the value of the new-expression shall be null.
1096   /// An allocation function is not allowed to return null unless it
1097   /// has a non-throwing exception-specification.  The '03 rule is
1098   /// identical except that the definition of a non-throwing
1099   /// exception specification is just "is it throw()?".
1100   bool shouldNullCheckAllocation(ASTContext &Ctx) const;
1101   
1102   FunctionDecl *getOperatorNew() const { return OperatorNew; }
1103   void setOperatorNew(FunctionDecl *D) { OperatorNew = D; }
1104   FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
1105   void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; }
1106   CXXConstructorDecl *getConstructor() const { return Constructor; }
1107   void setConstructor(CXXConstructorDecl *D) { Constructor = D; }
1108
1109   bool isArray() const { return Array; }
1110   Expr *getArraySize() {
1111     return Array ? cast<Expr>(SubExprs[0]) : 0;
1112   }
1113   const Expr *getArraySize() const {
1114     return Array ? cast<Expr>(SubExprs[0]) : 0;
1115   }
1116
1117   unsigned getNumPlacementArgs() const { return NumPlacementArgs; }
1118   Expr **getPlacementArgs() { 
1119     return reinterpret_cast<Expr **>(SubExprs + Array); 
1120   }
1121   
1122   Expr *getPlacementArg(unsigned i) {
1123     assert(i < NumPlacementArgs && "Index out of range");
1124     return cast<Expr>(SubExprs[Array + i]);
1125   }
1126   const Expr *getPlacementArg(unsigned i) const {
1127     assert(i < NumPlacementArgs && "Index out of range");
1128     return cast<Expr>(SubExprs[Array + i]);
1129   }
1130
1131   bool isParenTypeId() const { return TypeIdParens.isValid(); }
1132   SourceRange getTypeIdParens() const { return TypeIdParens; }
1133
1134   bool isGlobalNew() const { return GlobalNew; }
1135   bool hasInitializer() const { return Initializer; }
1136
1137   /// Answers whether the usual array deallocation function for the
1138   /// allocated type expects the size of the allocation as a
1139   /// parameter.
1140   bool doesUsualArrayDeleteWantSize() const {
1141     return UsualArrayDeleteWantsSize;
1142   }
1143
1144   unsigned getNumConstructorArgs() const { return NumConstructorArgs; }
1145   
1146   Expr **getConstructorArgs() {
1147     return reinterpret_cast<Expr **>(SubExprs + Array + NumPlacementArgs);
1148   }
1149   
1150   Expr *getConstructorArg(unsigned i) {
1151     assert(i < NumConstructorArgs && "Index out of range");
1152     return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
1153   }
1154   const Expr *getConstructorArg(unsigned i) const {
1155     assert(i < NumConstructorArgs && "Index out of range");
1156     return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
1157   }
1158
1159   typedef ExprIterator arg_iterator;
1160   typedef ConstExprIterator const_arg_iterator;
1161
1162   arg_iterator placement_arg_begin() {
1163     return SubExprs + Array;
1164   }
1165   arg_iterator placement_arg_end() {
1166     return SubExprs + Array + getNumPlacementArgs();
1167   }
1168   const_arg_iterator placement_arg_begin() const {
1169     return SubExprs + Array;
1170   }
1171   const_arg_iterator placement_arg_end() const {
1172     return SubExprs + Array + getNumPlacementArgs();
1173   }
1174
1175   arg_iterator constructor_arg_begin() {
1176     return SubExprs + Array + getNumPlacementArgs();
1177   }
1178   arg_iterator constructor_arg_end() {
1179     return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
1180   }
1181   const_arg_iterator constructor_arg_begin() const {
1182     return SubExprs + Array + getNumPlacementArgs();
1183   }
1184   const_arg_iterator constructor_arg_end() const {
1185     return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
1186   }
1187   
1188   typedef Stmt **raw_arg_iterator;
1189   raw_arg_iterator raw_arg_begin() { return SubExprs; }
1190   raw_arg_iterator raw_arg_end() {
1191     return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
1192   }
1193   const_arg_iterator raw_arg_begin() const { return SubExprs; }
1194   const_arg_iterator raw_arg_end() const { return constructor_arg_end(); }
1195
1196   SourceLocation getStartLoc() const { return StartLoc; }
1197   SourceLocation getEndLoc() const { return EndLoc; }
1198
1199   SourceLocation getConstructorLParen() const { return ConstructorLParen; }
1200   SourceLocation getConstructorRParen() const { return ConstructorRParen; }
1201
1202   SourceRange getSourceRange() const {
1203     return SourceRange(StartLoc, EndLoc);
1204   }
1205
1206   static bool classof(const Stmt *T) {
1207     return T->getStmtClass() == CXXNewExprClass;
1208   }
1209   static bool classof(const CXXNewExpr *) { return true; }
1210
1211   // Iterators
1212   child_range children() {
1213     return child_range(&SubExprs[0],
1214                        &SubExprs[0] + Array + getNumPlacementArgs()
1215                          + getNumConstructorArgs());
1216   }
1217 };
1218
1219 /// CXXDeleteExpr - A delete expression for memory deallocation and destructor
1220 /// calls, e.g. "delete[] pArray".
1221 class CXXDeleteExpr : public Expr {
1222   // Is this a forced global delete, i.e. "::delete"?
1223   bool GlobalDelete : 1;
1224   // Is this the array form of delete, i.e. "delete[]"?
1225   bool ArrayForm : 1;
1226   // ArrayFormAsWritten can be different from ArrayForm if 'delete' is applied
1227   // to pointer-to-array type (ArrayFormAsWritten will be false while ArrayForm
1228   // will be true).
1229   bool ArrayFormAsWritten : 1;
1230   // Does the usual deallocation function for the element type require
1231   // a size_t argument?
1232   bool UsualArrayDeleteWantsSize : 1;
1233   // Points to the operator delete overload that is used. Could be a member.
1234   FunctionDecl *OperatorDelete;
1235   // The pointer expression to be deleted.
1236   Stmt *Argument;
1237   // Location of the expression.
1238   SourceLocation Loc;
1239 public:
1240   CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm,
1241                 bool arrayFormAsWritten, bool usualArrayDeleteWantsSize,
1242                 FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc)
1243     : Expr(CXXDeleteExprClass, ty, VK_RValue, OK_Ordinary, false, false,
1244            arg->containsUnexpandedParameterPack()),
1245       GlobalDelete(globalDelete),
1246       ArrayForm(arrayForm), ArrayFormAsWritten(arrayFormAsWritten),
1247       UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize),
1248       OperatorDelete(operatorDelete), Argument(arg), Loc(loc) { }
1249   explicit CXXDeleteExpr(EmptyShell Shell)
1250     : Expr(CXXDeleteExprClass, Shell), OperatorDelete(0), Argument(0) { }
1251
1252   bool isGlobalDelete() const { return GlobalDelete; }
1253   bool isArrayForm() const { return ArrayForm; }
1254   bool isArrayFormAsWritten() const { return ArrayFormAsWritten; }
1255
1256   /// Answers whether the usual array deallocation function for the
1257   /// allocated type expects the size of the allocation as a
1258   /// parameter.  This can be true even if the actual deallocation
1259   /// function that we're using doesn't want a size.
1260   bool doesUsualArrayDeleteWantSize() const {
1261     return UsualArrayDeleteWantsSize;
1262   }
1263
1264   FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
1265
1266   Expr *getArgument() { return cast<Expr>(Argument); }
1267   const Expr *getArgument() const { return cast<Expr>(Argument); }
1268
1269   /// \brief Retrieve the type being destroyed.  If the type being
1270   /// destroyed is a dependent type which may or may not be a pointer,
1271   /// return an invalid type.
1272   QualType getDestroyedType() const;
1273   
1274   SourceRange getSourceRange() const {
1275     return SourceRange(Loc, Argument->getLocEnd());
1276   }
1277
1278   static bool classof(const Stmt *T) {
1279     return T->getStmtClass() == CXXDeleteExprClass;
1280   }
1281   static bool classof(const CXXDeleteExpr *) { return true; }
1282
1283   // Iterators
1284   child_range children() { return child_range(&Argument, &Argument+1); }
1285
1286   friend class ASTStmtReader;
1287 };
1288
1289 /// \brief Structure used to store the type being destroyed by a 
1290 /// pseudo-destructor expression.
1291 class PseudoDestructorTypeStorage {
1292   /// \brief Either the type source information or the name of the type, if 
1293   /// it couldn't be resolved due to type-dependence.
1294   llvm::PointerUnion<TypeSourceInfo *, IdentifierInfo *> Type;
1295   
1296   /// \brief The starting source location of the pseudo-destructor type.
1297   SourceLocation Location;
1298   
1299 public:
1300   PseudoDestructorTypeStorage() { }
1301   
1302   PseudoDestructorTypeStorage(IdentifierInfo *II, SourceLocation Loc)
1303     : Type(II), Location(Loc) { }
1304   
1305   PseudoDestructorTypeStorage(TypeSourceInfo *Info);
1306   
1307   TypeSourceInfo *getTypeSourceInfo() const { 
1308     return Type.dyn_cast<TypeSourceInfo *>(); 
1309   }
1310   
1311   IdentifierInfo *getIdentifier() const {
1312     return Type.dyn_cast<IdentifierInfo *>();
1313   }
1314   
1315   SourceLocation getLocation() const { return Location; }
1316 };
1317   
1318 /// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
1319 ///
1320 /// A pseudo-destructor is an expression that looks like a member access to a
1321 /// destructor of a scalar type, except that scalar types don't have 
1322 /// destructors. For example:
1323 ///
1324 /// \code
1325 /// typedef int T;
1326 /// void f(int *p) {
1327 ///   p->T::~T();
1328 /// }
1329 /// \endcode
1330 ///
1331 /// Pseudo-destructors typically occur when instantiating templates such as:
1332 /// 
1333 /// \code
1334 /// template<typename T>
1335 /// void destroy(T* ptr) {
1336 ///   ptr->T::~T();
1337 /// }
1338 /// \endcode
1339 ///
1340 /// for scalar types. A pseudo-destructor expression has no run-time semantics
1341 /// beyond evaluating the base expression.
1342 class CXXPseudoDestructorExpr : public Expr {
1343   /// \brief The base expression (that is being destroyed).
1344   Stmt *Base;
1345
1346   /// \brief Whether the operator was an arrow ('->'); otherwise, it was a
1347   /// period ('.').
1348   bool IsArrow : 1;
1349
1350   /// \brief The location of the '.' or '->' operator.
1351   SourceLocation OperatorLoc;
1352   
1353   /// \brief The nested-name-specifier that follows the operator, if present.
1354   NestedNameSpecifierLoc QualifierLoc;
1355
1356   /// \brief The type that precedes the '::' in a qualified pseudo-destructor
1357   /// expression.
1358   TypeSourceInfo *ScopeType;
1359   
1360   /// \brief The location of the '::' in a qualified pseudo-destructor 
1361   /// expression.
1362   SourceLocation ColonColonLoc;
1363   
1364   /// \brief The location of the '~'.
1365   SourceLocation TildeLoc;
1366   
1367   /// \brief The type being destroyed, or its name if we were unable to 
1368   /// resolve the name.
1369   PseudoDestructorTypeStorage DestroyedType;
1370
1371   friend class ASTStmtReader;
1372   
1373 public:
1374   CXXPseudoDestructorExpr(ASTContext &Context,
1375                           Expr *Base, bool isArrow, SourceLocation OperatorLoc,
1376                           NestedNameSpecifierLoc QualifierLoc,
1377                           TypeSourceInfo *ScopeType,
1378                           SourceLocation ColonColonLoc,
1379                           SourceLocation TildeLoc,
1380                           PseudoDestructorTypeStorage DestroyedType);
1381
1382   explicit CXXPseudoDestructorExpr(EmptyShell Shell)
1383     : Expr(CXXPseudoDestructorExprClass, Shell),
1384       Base(0), IsArrow(false), QualifierLoc(), ScopeType(0) { }
1385
1386   Expr *getBase() const { return cast<Expr>(Base); }
1387
1388   /// \brief Determines whether this member expression actually had
1389   /// a C++ nested-name-specifier prior to the name of the member, e.g.,
1390   /// x->Base::foo.
1391   bool hasQualifier() const { return QualifierLoc; }
1392
1393   /// \brief Retrieves the nested-name-specifier that qualifies the type name,
1394   /// with source-location information.
1395   NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
1396   
1397   /// \brief If the member name was qualified, retrieves the
1398   /// nested-name-specifier that precedes the member name. Otherwise, returns
1399   /// NULL.
1400   NestedNameSpecifier *getQualifier() const { 
1401     return QualifierLoc.getNestedNameSpecifier(); 
1402   }
1403
1404   /// \brief Determine whether this pseudo-destructor expression was written
1405   /// using an '->' (otherwise, it used a '.').
1406   bool isArrow() const { return IsArrow; }
1407
1408   /// \brief Retrieve the location of the '.' or '->' operator.
1409   SourceLocation getOperatorLoc() const { return OperatorLoc; }
1410
1411   /// \brief Retrieve the scope type in a qualified pseudo-destructor 
1412   /// expression.
1413   ///
1414   /// Pseudo-destructor expressions can have extra qualification within them
1415   /// that is not part of the nested-name-specifier, e.g., \c p->T::~T().
1416   /// Here, if the object type of the expression is (or may be) a scalar type,
1417   /// \p T may also be a scalar type and, therefore, cannot be part of a 
1418   /// nested-name-specifier. It is stored as the "scope type" of the pseudo-
1419   /// destructor expression.
1420   TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; }
1421   
1422   /// \brief Retrieve the location of the '::' in a qualified pseudo-destructor
1423   /// expression.
1424   SourceLocation getColonColonLoc() const { return ColonColonLoc; }
1425   
1426   /// \brief Retrieve the location of the '~'.
1427   SourceLocation getTildeLoc() const { return TildeLoc; }
1428   
1429   /// \brief Retrieve the source location information for the type
1430   /// being destroyed.
1431   ///
1432   /// This type-source information is available for non-dependent 
1433   /// pseudo-destructor expressions and some dependent pseudo-destructor
1434   /// expressions. Returns NULL if we only have the identifier for a
1435   /// dependent pseudo-destructor expression.
1436   TypeSourceInfo *getDestroyedTypeInfo() const { 
1437     return DestroyedType.getTypeSourceInfo(); 
1438   }
1439   
1440   /// \brief In a dependent pseudo-destructor expression for which we do not
1441   /// have full type information on the destroyed type, provides the name
1442   /// of the destroyed type.
1443   IdentifierInfo *getDestroyedTypeIdentifier() const {
1444     return DestroyedType.getIdentifier();
1445   }
1446   
1447   /// \brief Retrieve the type being destroyed.
1448   QualType getDestroyedType() const;
1449   
1450   /// \brief Retrieve the starting location of the type being destroyed.
1451   SourceLocation getDestroyedTypeLoc() const { 
1452     return DestroyedType.getLocation(); 
1453   }
1454
1455   /// \brief Set the name of destroyed type for a dependent pseudo-destructor
1456   /// expression.
1457   void setDestroyedType(IdentifierInfo *II, SourceLocation Loc) {
1458     DestroyedType = PseudoDestructorTypeStorage(II, Loc);
1459   }
1460
1461   /// \brief Set the destroyed type.
1462   void setDestroyedType(TypeSourceInfo *Info) {
1463     DestroyedType = PseudoDestructorTypeStorage(Info);
1464   }
1465
1466   SourceRange getSourceRange() const;
1467
1468   static bool classof(const Stmt *T) {
1469     return T->getStmtClass() == CXXPseudoDestructorExprClass;
1470   }
1471   static bool classof(const CXXPseudoDestructorExpr *) { return true; }
1472
1473   // Iterators
1474   child_range children() { return child_range(&Base, &Base + 1); }
1475 };
1476
1477 /// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the
1478 /// implementation of TR1/C++0x type trait templates.
1479 /// Example:
1480 /// __is_pod(int) == true
1481 /// __is_enum(std::string) == false
1482 class UnaryTypeTraitExpr : public Expr {
1483   /// UTT - The trait. A UnaryTypeTrait enum in MSVC compat unsigned.
1484   unsigned UTT : 31;
1485   /// The value of the type trait. Unspecified if dependent.
1486   bool Value : 1;
1487
1488   /// Loc - The location of the type trait keyword.
1489   SourceLocation Loc;
1490
1491   /// RParen - The location of the closing paren.
1492   SourceLocation RParen;
1493
1494   /// The type being queried.
1495   TypeSourceInfo *QueriedType;
1496
1497 public:
1498   UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, 
1499                      TypeSourceInfo *queried, bool value,
1500                      SourceLocation rparen, QualType ty)
1501     : Expr(UnaryTypeTraitExprClass, ty, VK_RValue, OK_Ordinary,
1502            false,  queried->getType()->isDependentType(),
1503            queried->getType()->containsUnexpandedParameterPack()),
1504       UTT(utt), Value(value), Loc(loc), RParen(rparen), QueriedType(queried) { }
1505
1506   explicit UnaryTypeTraitExpr(EmptyShell Empty)
1507     : Expr(UnaryTypeTraitExprClass, Empty), UTT(0), Value(false),
1508       QueriedType() { }
1509
1510   SourceRange getSourceRange() const { return SourceRange(Loc, RParen);}
1511
1512   UnaryTypeTrait getTrait() const { return static_cast<UnaryTypeTrait>(UTT); }
1513
1514   QualType getQueriedType() const { return QueriedType->getType(); }
1515
1516   TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; }
1517   
1518   bool getValue() const { return Value; }
1519
1520   static bool classof(const Stmt *T) {
1521     return T->getStmtClass() == UnaryTypeTraitExprClass;
1522   }
1523   static bool classof(const UnaryTypeTraitExpr *) { return true; }
1524
1525   // Iterators
1526   child_range children() { return child_range(); }
1527
1528   friend class ASTStmtReader;
1529 };
1530
1531 /// BinaryTypeTraitExpr - A GCC or MS binary type trait, as used in the
1532 /// implementation of TR1/C++0x type trait templates.
1533 /// Example:
1534 /// __is_base_of(Base, Derived) == true
1535 class BinaryTypeTraitExpr : public Expr {
1536   /// BTT - The trait. A BinaryTypeTrait enum in MSVC compat unsigned.
1537   unsigned BTT : 8;
1538
1539   /// The value of the type trait. Unspecified if dependent.
1540   bool Value : 1;
1541
1542   /// Loc - The location of the type trait keyword.
1543   SourceLocation Loc;
1544
1545   /// RParen - The location of the closing paren.
1546   SourceLocation RParen;
1547
1548   /// The lhs type being queried.
1549   TypeSourceInfo *LhsType;
1550
1551   /// The rhs type being queried.
1552   TypeSourceInfo *RhsType;
1553
1554 public:
1555   BinaryTypeTraitExpr(SourceLocation loc, BinaryTypeTrait btt, 
1556                      TypeSourceInfo *lhsType, TypeSourceInfo *rhsType, 
1557                      bool value, SourceLocation rparen, QualType ty)
1558     : Expr(BinaryTypeTraitExprClass, ty, VK_RValue, OK_Ordinary, false, 
1559            lhsType->getType()->isDependentType() ||
1560            rhsType->getType()->isDependentType(),
1561            (lhsType->getType()->containsUnexpandedParameterPack() ||
1562             rhsType->getType()->containsUnexpandedParameterPack())),
1563       BTT(btt), Value(value), Loc(loc), RParen(rparen),
1564       LhsType(lhsType), RhsType(rhsType) { }
1565
1566
1567   explicit BinaryTypeTraitExpr(EmptyShell Empty)
1568     : Expr(BinaryTypeTraitExprClass, Empty), BTT(0), Value(false),
1569       LhsType(), RhsType() { }
1570
1571   SourceRange getSourceRange() const {
1572     return SourceRange(Loc, RParen);
1573   }
1574
1575   BinaryTypeTrait getTrait() const {
1576     return static_cast<BinaryTypeTrait>(BTT);
1577   }
1578
1579   QualType getLhsType() const { return LhsType->getType(); }
1580   QualType getRhsType() const { return RhsType->getType(); }
1581
1582   TypeSourceInfo *getLhsTypeSourceInfo() const { return LhsType; }
1583   TypeSourceInfo *getRhsTypeSourceInfo() const { return RhsType; }
1584   
1585   bool getValue() const { assert(!isTypeDependent()); return Value; }
1586
1587   static bool classof(const Stmt *T) {
1588     return T->getStmtClass() == BinaryTypeTraitExprClass;
1589   }
1590   static bool classof(const BinaryTypeTraitExpr *) { return true; }
1591
1592   // Iterators
1593   child_range children() { return child_range(); }
1594
1595   friend class ASTStmtReader;
1596 };
1597
1598 /// ArrayTypeTraitExpr - An Embarcadero array type trait, as used in the
1599 /// implementation of __array_rank and __array_extent.
1600 /// Example:
1601 /// __array_rank(int[10][20]) == 2
1602 /// __array_extent(int, 1)    == 20
1603 class ArrayTypeTraitExpr : public Expr {
1604   /// ATT - The trait. An ArrayTypeTrait enum in MSVC compat unsigned.
1605   unsigned ATT : 2;
1606
1607   /// The value of the type trait. Unspecified if dependent.
1608   uint64_t Value;
1609
1610   /// The array dimension being queried, or -1 if not used
1611   Expr *Dimension;
1612
1613   /// Loc - The location of the type trait keyword.
1614   SourceLocation Loc;
1615
1616   /// RParen - The location of the closing paren.
1617   SourceLocation RParen;
1618
1619   /// The type being queried.
1620   TypeSourceInfo *QueriedType;
1621
1622 public:
1623   ArrayTypeTraitExpr(SourceLocation loc, ArrayTypeTrait att,
1624                      TypeSourceInfo *queried, uint64_t value,
1625                      Expr *dimension, SourceLocation rparen, QualType ty)
1626     : Expr(ArrayTypeTraitExprClass, ty, VK_RValue, OK_Ordinary,
1627            false, queried->getType()->isDependentType(),
1628            queried->getType()->containsUnexpandedParameterPack()),
1629       ATT(att), Value(value), Dimension(dimension),
1630       Loc(loc), RParen(rparen), QueriedType(queried) { }
1631
1632
1633   explicit ArrayTypeTraitExpr(EmptyShell Empty)
1634     : Expr(ArrayTypeTraitExprClass, Empty), ATT(0), Value(false),
1635       QueriedType() { }
1636
1637   virtual ~ArrayTypeTraitExpr() { }
1638
1639   virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen); }
1640
1641   ArrayTypeTrait getTrait() const { return static_cast<ArrayTypeTrait>(ATT); }
1642
1643   QualType getQueriedType() const { return QueriedType->getType(); }
1644
1645   TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; }
1646
1647   uint64_t getValue() const { assert(!isTypeDependent()); return Value; }
1648
1649   Expr *getDimensionExpression() const { return Dimension; }
1650
1651   static bool classof(const Stmt *T) {
1652     return T->getStmtClass() == ArrayTypeTraitExprClass;
1653   }
1654   static bool classof(const ArrayTypeTraitExpr *) { return true; }
1655
1656   // Iterators
1657   child_range children() { return child_range(); }
1658
1659   friend class ASTStmtReader;
1660 };
1661
1662 /// ExpressionTraitExpr - An expression trait intrinsic
1663 /// Example:
1664 /// __is_lvalue_expr(std::cout) == true
1665 /// __is_lvalue_expr(1) == false
1666 class ExpressionTraitExpr : public Expr {
1667   /// ET - The trait. A ExpressionTrait enum in MSVC compat unsigned.
1668   unsigned ET : 31;
1669   /// The value of the type trait. Unspecified if dependent.
1670   bool Value : 1;
1671
1672   /// Loc - The location of the type trait keyword.
1673   SourceLocation Loc;
1674
1675   /// RParen - The location of the closing paren.
1676   SourceLocation RParen;
1677
1678   Expr* QueriedExpression;
1679 public:
1680   ExpressionTraitExpr(SourceLocation loc, ExpressionTrait et, 
1681                      Expr *queried, bool value,
1682                      SourceLocation rparen, QualType resultType)
1683     : Expr(ExpressionTraitExprClass, resultType, VK_RValue, OK_Ordinary,
1684            false, // Not type-dependent
1685            // Value-dependent if the argument is type-dependent.
1686            queried->isTypeDependent(),
1687            queried->containsUnexpandedParameterPack()),
1688       ET(et), Value(value), Loc(loc), RParen(rparen), QueriedExpression(queried) { }
1689
1690   explicit ExpressionTraitExpr(EmptyShell Empty)
1691     : Expr(ExpressionTraitExprClass, Empty), ET(0), Value(false),
1692       QueriedExpression() { }
1693
1694   SourceRange getSourceRange() const { return SourceRange(Loc, RParen);}
1695
1696   ExpressionTrait getTrait() const { return static_cast<ExpressionTrait>(ET); }
1697
1698   Expr *getQueriedExpression() const { return QueriedExpression; }
1699
1700   bool getValue() const { return Value; }
1701
1702   static bool classof(const Stmt *T) {
1703     return T->getStmtClass() == ExpressionTraitExprClass;
1704   }
1705   static bool classof(const ExpressionTraitExpr *) { return true; }
1706
1707   // Iterators
1708   child_range children() { return child_range(); }
1709
1710   friend class ASTStmtReader;
1711 };
1712
1713
1714 /// \brief A reference to an overloaded function set, either an
1715 /// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr.
1716 class OverloadExpr : public Expr {
1717   /// The results.  These are undesugared, which is to say, they may
1718   /// include UsingShadowDecls.  Access is relative to the naming
1719   /// class.
1720   // FIXME: Allocate this data after the OverloadExpr subclass.
1721   DeclAccessPair *Results;
1722   unsigned NumResults;
1723
1724   /// The common name of these declarations.
1725   DeclarationNameInfo NameInfo;
1726
1727   /// \brief The nested-name-specifier that qualifies the name, if any.
1728   NestedNameSpecifierLoc QualifierLoc;
1729
1730 protected:
1731   /// True if the name was a template-id.
1732   bool HasExplicitTemplateArgs;
1733
1734   OverloadExpr(StmtClass K, ASTContext &C,
1735                NestedNameSpecifierLoc QualifierLoc,
1736                const DeclarationNameInfo &NameInfo,
1737                const TemplateArgumentListInfo *TemplateArgs,
1738                UnresolvedSetIterator Begin, UnresolvedSetIterator End,
1739                bool KnownDependent = false,
1740                bool KnownContainsUnexpandedParameterPack = false);
1741
1742   OverloadExpr(StmtClass K, EmptyShell Empty)
1743     : Expr(K, Empty), Results(0), NumResults(0),
1744       QualifierLoc(), HasExplicitTemplateArgs(false) { }
1745
1746   void initializeResults(ASTContext &C,
1747                          UnresolvedSetIterator Begin,
1748                          UnresolvedSetIterator End);
1749
1750 public:
1751   struct FindResult {
1752     OverloadExpr *Expression;
1753     bool IsAddressOfOperand;
1754     bool HasFormOfMemberPointer;
1755   };
1756
1757   /// Finds the overloaded expression in the given expression of
1758   /// OverloadTy.
1759   ///
1760   /// \return the expression (which must be there) and true if it has
1761   /// the particular form of a member pointer expression
1762   static FindResult find(Expr *E) {
1763     assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload));
1764
1765     FindResult Result;
1766
1767     E = E->IgnoreParens();
1768     if (isa<UnaryOperator>(E)) {
1769       assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf);
1770       E = cast<UnaryOperator>(E)->getSubExpr();
1771       OverloadExpr *Ovl = cast<OverloadExpr>(E->IgnoreParens());
1772
1773       Result.HasFormOfMemberPointer = (E == Ovl && Ovl->getQualifier());
1774       Result.IsAddressOfOperand = true;
1775       Result.Expression = Ovl;
1776     } else {
1777       Result.HasFormOfMemberPointer = false;
1778       Result.IsAddressOfOperand = false;
1779       Result.Expression = cast<OverloadExpr>(E);
1780     }
1781
1782     return Result;
1783   }
1784
1785   /// Gets the naming class of this lookup, if any.
1786   CXXRecordDecl *getNamingClass() const;
1787
1788   typedef UnresolvedSetImpl::iterator decls_iterator;
1789   decls_iterator decls_begin() const { return UnresolvedSetIterator(Results); }
1790   decls_iterator decls_end() const { 
1791     return UnresolvedSetIterator(Results + NumResults);
1792   }
1793   
1794   /// Gets the number of declarations in the unresolved set.
1795   unsigned getNumDecls() const { return NumResults; }
1796
1797   /// Gets the full name info.
1798   const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
1799
1800   /// Gets the name looked up.
1801   DeclarationName getName() const { return NameInfo.getName(); }
1802
1803   /// Gets the location of the name.
1804   SourceLocation getNameLoc() const { return NameInfo.getLoc(); }
1805
1806   /// Fetches the nested-name qualifier, if one was given.
1807   NestedNameSpecifier *getQualifier() const { 
1808     return QualifierLoc.getNestedNameSpecifier(); 
1809   }
1810
1811   /// Fetches the nested-name qualifier with source-location information, if 
1812   /// one was given.
1813   NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
1814
1815   /// \brief Determines whether this expression had an explicit
1816   /// template argument list, e.g. f<int>.
1817   bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
1818
1819   ExplicitTemplateArgumentList &getExplicitTemplateArgs(); // defined far below
1820
1821   const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1822     return const_cast<OverloadExpr*>(this)->getExplicitTemplateArgs();
1823   }
1824
1825   /// \brief Retrieves the optional explicit template arguments.
1826   /// This points to the same data as getExplicitTemplateArgs(), but
1827   /// returns null if there are no explicit template arguments.
1828   const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
1829     if (!hasExplicitTemplateArgs()) return 0;
1830     return &getExplicitTemplateArgs();
1831   }
1832
1833   static bool classof(const Stmt *T) {
1834     return T->getStmtClass() == UnresolvedLookupExprClass ||
1835            T->getStmtClass() == UnresolvedMemberExprClass;
1836   }
1837   static bool classof(const OverloadExpr *) { return true; }
1838
1839   friend class ASTStmtReader;
1840   friend class ASTStmtWriter;
1841 };
1842
1843 /// \brief A reference to a name which we were able to look up during
1844 /// parsing but could not resolve to a specific declaration.  This
1845 /// arises in several ways:
1846 ///   * we might be waiting for argument-dependent lookup
1847 ///   * the name might resolve to an overloaded function
1848 /// and eventually:
1849 ///   * the lookup might have included a function template
1850 /// These never include UnresolvedUsingValueDecls, which are always
1851 /// class members and therefore appear only in
1852 /// UnresolvedMemberLookupExprs.
1853 class UnresolvedLookupExpr : public OverloadExpr {
1854   /// True if these lookup results should be extended by
1855   /// argument-dependent lookup if this is the operand of a function
1856   /// call.
1857   bool RequiresADL;
1858
1859   /// True if namespace ::std should be considered an associated namespace
1860   /// for the purposes of argument-dependent lookup. See C++0x [stmt.ranged]p1.
1861   bool StdIsAssociatedNamespace;
1862
1863   /// True if these lookup results are overloaded.  This is pretty
1864   /// trivially rederivable if we urgently need to kill this field.
1865   bool Overloaded;
1866
1867   /// The naming class (C++ [class.access.base]p5) of the lookup, if
1868   /// any.  This can generally be recalculated from the context chain,
1869   /// but that can be fairly expensive for unqualified lookups.  If we
1870   /// want to improve memory use here, this could go in a union
1871   /// against the qualified-lookup bits.
1872   CXXRecordDecl *NamingClass;
1873
1874   UnresolvedLookupExpr(ASTContext &C, 
1875                        CXXRecordDecl *NamingClass,
1876                        NestedNameSpecifierLoc QualifierLoc,
1877                        const DeclarationNameInfo &NameInfo,
1878                        bool RequiresADL, bool Overloaded, 
1879                        const TemplateArgumentListInfo *TemplateArgs,
1880                        UnresolvedSetIterator Begin, UnresolvedSetIterator End,
1881                        bool StdIsAssociatedNamespace)
1882     : OverloadExpr(UnresolvedLookupExprClass, C, QualifierLoc, NameInfo, 
1883                    TemplateArgs, Begin, End),
1884       RequiresADL(RequiresADL),
1885       StdIsAssociatedNamespace(StdIsAssociatedNamespace),
1886       Overloaded(Overloaded), NamingClass(NamingClass)
1887   {}
1888
1889   UnresolvedLookupExpr(EmptyShell Empty)
1890     : OverloadExpr(UnresolvedLookupExprClass, Empty),
1891       RequiresADL(false), StdIsAssociatedNamespace(false), Overloaded(false),
1892       NamingClass(0)
1893   {}
1894
1895   friend class ASTStmtReader;
1896   
1897 public:
1898   static UnresolvedLookupExpr *Create(ASTContext &C,
1899                                       CXXRecordDecl *NamingClass,
1900                                       NestedNameSpecifierLoc QualifierLoc,
1901                                       const DeclarationNameInfo &NameInfo,
1902                                       bool ADL, bool Overloaded,
1903                                       UnresolvedSetIterator Begin, 
1904                                       UnresolvedSetIterator End,
1905                                       bool StdIsAssociatedNamespace = false) {
1906     assert((ADL || !StdIsAssociatedNamespace) &&
1907            "std considered associated namespace when not performing ADL");
1908     return new(C) UnresolvedLookupExpr(C, NamingClass, QualifierLoc, NameInfo, 
1909                                        ADL, Overloaded, 0, Begin, End,
1910                                        StdIsAssociatedNamespace);
1911   }
1912
1913   static UnresolvedLookupExpr *Create(ASTContext &C,
1914                                       CXXRecordDecl *NamingClass,
1915                                       NestedNameSpecifierLoc QualifierLoc,
1916                                       const DeclarationNameInfo &NameInfo,
1917                                       bool ADL,
1918                                       const TemplateArgumentListInfo &Args,
1919                                       UnresolvedSetIterator Begin, 
1920                                       UnresolvedSetIterator End);
1921
1922   static UnresolvedLookupExpr *CreateEmpty(ASTContext &C,
1923                                            bool HasExplicitTemplateArgs,
1924                                            unsigned NumTemplateArgs);
1925
1926   /// True if this declaration should be extended by
1927   /// argument-dependent lookup.
1928   bool requiresADL() const { return RequiresADL; }
1929
1930   /// True if namespace ::std should be artificially added to the set of
1931   /// associated namespaecs for argument-dependent lookup purposes.
1932   bool isStdAssociatedNamespace() const { return StdIsAssociatedNamespace; }
1933
1934   /// True if this lookup is overloaded.
1935   bool isOverloaded() const { return Overloaded; }
1936
1937   /// Gets the 'naming class' (in the sense of C++0x
1938   /// [class.access.base]p5) of the lookup.  This is the scope
1939   /// that was looked in to find these results.
1940   CXXRecordDecl *getNamingClass() const { return NamingClass; }
1941
1942   // Note that, inconsistently with the explicit-template-argument AST
1943   // nodes, users are *forbidden* from calling these methods on objects
1944   // without explicit template arguments.
1945
1946   ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
1947     assert(hasExplicitTemplateArgs());
1948     return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1);
1949   }
1950
1951   /// Gets a reference to the explicit template argument list.
1952   const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1953     assert(hasExplicitTemplateArgs());
1954     return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1955   }
1956
1957   /// \brief Retrieves the optional explicit template arguments.
1958   /// This points to the same data as getExplicitTemplateArgs(), but
1959   /// returns null if there are no explicit template arguments.
1960   const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
1961     if (!hasExplicitTemplateArgs()) return 0;
1962     return &getExplicitTemplateArgs();
1963   }
1964
1965   /// \brief Copies the template arguments (if present) into the given
1966   /// structure.
1967   void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1968     getExplicitTemplateArgs().copyInto(List);
1969   }
1970   
1971   SourceLocation getLAngleLoc() const {
1972     return getExplicitTemplateArgs().LAngleLoc;
1973   }
1974
1975   SourceLocation getRAngleLoc() const {
1976     return getExplicitTemplateArgs().RAngleLoc;
1977   }
1978
1979   TemplateArgumentLoc const *getTemplateArgs() const {
1980     return getExplicitTemplateArgs().getTemplateArgs();
1981   }
1982
1983   unsigned getNumTemplateArgs() const {
1984     return getExplicitTemplateArgs().NumTemplateArgs;
1985   }
1986
1987   SourceRange getSourceRange() const {
1988     SourceRange Range(getNameInfo().getSourceRange());
1989     if (getQualifierLoc()) 
1990       Range.setBegin(getQualifierLoc().getBeginLoc());
1991     if (hasExplicitTemplateArgs()) 
1992       Range.setEnd(getRAngleLoc());
1993     return Range;
1994   }
1995
1996   child_range children() { return child_range(); }
1997
1998   static bool classof(const Stmt *T) {
1999     return T->getStmtClass() == UnresolvedLookupExprClass;
2000   }
2001   static bool classof(const UnresolvedLookupExpr *) { return true; }
2002 };
2003
2004 /// \brief A qualified reference to a name whose declaration cannot
2005 /// yet be resolved.
2006 ///
2007 /// DependentScopeDeclRefExpr is similar to DeclRefExpr in that
2008 /// it expresses a reference to a declaration such as
2009 /// X<T>::value. The difference, however, is that an
2010 /// DependentScopeDeclRefExpr node is used only within C++ templates when
2011 /// the qualification (e.g., X<T>::) refers to a dependent type. In
2012 /// this case, X<T>::value cannot resolve to a declaration because the
2013 /// declaration will differ from on instantiation of X<T> to the
2014 /// next. Therefore, DependentScopeDeclRefExpr keeps track of the
2015 /// qualifier (X<T>::) and the name of the entity being referenced
2016 /// ("value"). Such expressions will instantiate to a DeclRefExpr once the
2017 /// declaration can be found.
2018 class DependentScopeDeclRefExpr : public Expr {
2019   /// \brief The nested-name-specifier that qualifies this unresolved
2020   /// declaration name.
2021   NestedNameSpecifierLoc QualifierLoc;
2022   
2023   /// The name of the entity we will be referencing.
2024   DeclarationNameInfo NameInfo;
2025
2026   /// \brief Whether the name includes explicit template arguments.
2027   bool HasExplicitTemplateArgs;
2028
2029   DependentScopeDeclRefExpr(QualType T,
2030                             NestedNameSpecifierLoc QualifierLoc,
2031                             const DeclarationNameInfo &NameInfo,
2032                             const TemplateArgumentListInfo *Args);
2033
2034 public:
2035   static DependentScopeDeclRefExpr *Create(ASTContext &C,
2036                                            NestedNameSpecifierLoc QualifierLoc,
2037                                            const DeclarationNameInfo &NameInfo,
2038                               const TemplateArgumentListInfo *TemplateArgs = 0);
2039
2040   static DependentScopeDeclRefExpr *CreateEmpty(ASTContext &C,
2041                                                 bool HasExplicitTemplateArgs,
2042                                                 unsigned NumTemplateArgs);
2043
2044   /// \brief Retrieve the name that this expression refers to.
2045   const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
2046
2047   /// \brief Retrieve the name that this expression refers to.
2048   DeclarationName getDeclName() const { return NameInfo.getName(); }
2049
2050   /// \brief Retrieve the location of the name within the expression.
2051   SourceLocation getLocation() const { return NameInfo.getLoc(); }
2052
2053   /// \brief Retrieve the nested-name-specifier that qualifies the
2054   /// name, with source location information.
2055   NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
2056   
2057   
2058   /// \brief Retrieve the nested-name-specifier that qualifies this
2059   /// declaration.
2060   NestedNameSpecifier *getQualifier() const { 
2061     return QualifierLoc.getNestedNameSpecifier(); 
2062   }
2063
2064   /// Determines whether this lookup had explicit template arguments.
2065   bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
2066
2067   // Note that, inconsistently with the explicit-template-argument AST
2068   // nodes, users are *forbidden* from calling these methods on objects
2069   // without explicit template arguments.
2070
2071   ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
2072     assert(hasExplicitTemplateArgs());
2073     return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1);
2074   }
2075
2076   /// Gets a reference to the explicit template argument list.
2077   const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
2078     assert(hasExplicitTemplateArgs());
2079     return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
2080   }
2081
2082   /// \brief Retrieves the optional explicit template arguments.
2083   /// This points to the same data as getExplicitTemplateArgs(), but
2084   /// returns null if there are no explicit template arguments.
2085   const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
2086     if (!hasExplicitTemplateArgs()) return 0;
2087     return &getExplicitTemplateArgs();
2088   }
2089
2090   /// \brief Copies the template arguments (if present) into the given
2091   /// structure.
2092   void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
2093     getExplicitTemplateArgs().copyInto(List);
2094   }
2095   
2096   SourceLocation getLAngleLoc() const {
2097     return getExplicitTemplateArgs().LAngleLoc;
2098   }
2099
2100   SourceLocation getRAngleLoc() const {
2101     return getExplicitTemplateArgs().RAngleLoc;
2102   }
2103
2104   TemplateArgumentLoc const *getTemplateArgs() const {
2105     return getExplicitTemplateArgs().getTemplateArgs();
2106   }
2107
2108   unsigned getNumTemplateArgs() const {
2109     return getExplicitTemplateArgs().NumTemplateArgs;
2110   }
2111
2112   SourceRange getSourceRange() const {
2113     SourceRange Range(QualifierLoc.getBeginLoc(), getLocation());
2114     if (hasExplicitTemplateArgs())
2115       Range.setEnd(getRAngleLoc());
2116     return Range;
2117   }
2118
2119   static bool classof(const Stmt *T) {
2120     return T->getStmtClass() == DependentScopeDeclRefExprClass;
2121   }
2122   static bool classof(const DependentScopeDeclRefExpr *) { return true; }
2123
2124   child_range children() { return child_range(); }
2125
2126   friend class ASTStmtReader;
2127   friend class ASTStmtWriter;
2128 };
2129
2130 /// Represents an expression --- generally a full-expression --- which
2131 /// introduces cleanups to be run at the end of the sub-expression's
2132 /// evaluation.  The most common source of expression-introduced
2133 /// cleanups is temporary objects in C++, but several other C++
2134 /// expressions can create cleanups.
2135 class ExprWithCleanups : public Expr {
2136   Stmt *SubExpr;
2137
2138   CXXTemporary **Temps;
2139   unsigned NumTemps;
2140
2141   ExprWithCleanups(ASTContext &C, Expr *SubExpr,
2142                    CXXTemporary **Temps, unsigned NumTemps);
2143   
2144 public:
2145   ExprWithCleanups(EmptyShell Empty)
2146     : Expr(ExprWithCleanupsClass, Empty),
2147       SubExpr(0), Temps(0), NumTemps(0) {}
2148                          
2149   static ExprWithCleanups *Create(ASTContext &C, Expr *SubExpr,
2150                                         CXXTemporary **Temps, 
2151                                         unsigned NumTemps);
2152
2153   unsigned getNumTemporaries() const { return NumTemps; }
2154   void setNumTemporaries(ASTContext &C, unsigned N);
2155     
2156   CXXTemporary *getTemporary(unsigned i) {
2157     assert(i < NumTemps && "Index out of range");
2158     return Temps[i];
2159   }
2160   const CXXTemporary *getTemporary(unsigned i) const {
2161     return const_cast<ExprWithCleanups*>(this)->getTemporary(i);
2162   }
2163   void setTemporary(unsigned i, CXXTemporary *T) {
2164     assert(i < NumTemps && "Index out of range");
2165     Temps[i] = T;
2166   }
2167
2168   Expr *getSubExpr() { return cast<Expr>(SubExpr); }
2169   const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
2170   void setSubExpr(Expr *E) { SubExpr = E; }
2171
2172   SourceRange getSourceRange() const { 
2173     return SubExpr->getSourceRange();
2174   }
2175
2176   // Implement isa/cast/dyncast/etc.
2177   static bool classof(const Stmt *T) {
2178     return T->getStmtClass() == ExprWithCleanupsClass;
2179   }
2180   static bool classof(const ExprWithCleanups *) { return true; }
2181
2182   // Iterators
2183   child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
2184 };
2185
2186 /// \brief Describes an explicit type conversion that uses functional
2187 /// notion but could not be resolved because one or more arguments are
2188 /// type-dependent.
2189 ///
2190 /// The explicit type conversions expressed by
2191 /// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN),
2192 /// where \c T is some type and \c a1, a2, ..., aN are values, and
2193 /// either \C T is a dependent type or one or more of the \c a's is
2194 /// type-dependent. For example, this would occur in a template such
2195 /// as:
2196 ///
2197 /// \code
2198 ///   template<typename T, typename A1>
2199 ///   inline T make_a(const A1& a1) {
2200 ///     return T(a1);
2201 ///   }
2202 /// \endcode
2203 ///
2204 /// When the returned expression is instantiated, it may resolve to a
2205 /// constructor call, conversion function call, or some kind of type
2206 /// conversion.
2207 class CXXUnresolvedConstructExpr : public Expr {
2208   /// \brief The type being constructed.
2209   TypeSourceInfo *Type;
2210   
2211   /// \brief The location of the left parentheses ('(').
2212   SourceLocation LParenLoc;
2213
2214   /// \brief The location of the right parentheses (')').
2215   SourceLocation RParenLoc;
2216
2217   /// \brief The number of arguments used to construct the type.
2218   unsigned NumArgs;
2219
2220   CXXUnresolvedConstructExpr(TypeSourceInfo *Type,
2221                              SourceLocation LParenLoc,
2222                              Expr **Args,
2223                              unsigned NumArgs,
2224                              SourceLocation RParenLoc);
2225
2226   CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs)
2227     : Expr(CXXUnresolvedConstructExprClass, Empty), Type(), NumArgs(NumArgs) { }
2228
2229   friend class ASTStmtReader;
2230   
2231 public:
2232   static CXXUnresolvedConstructExpr *Create(ASTContext &C,
2233                                             TypeSourceInfo *Type,
2234                                             SourceLocation LParenLoc,
2235                                             Expr **Args,
2236                                             unsigned NumArgs,
2237                                             SourceLocation RParenLoc);
2238
2239   static CXXUnresolvedConstructExpr *CreateEmpty(ASTContext &C,
2240                                                  unsigned NumArgs);
2241
2242   /// \brief Retrieve the type that is being constructed, as specified
2243   /// in the source code.
2244   QualType getTypeAsWritten() const { return Type->getType(); }
2245
2246   /// \brief Retrieve the type source information for the type being 
2247   /// constructed.
2248   TypeSourceInfo *getTypeSourceInfo() const { return Type; }
2249   
2250   /// \brief Retrieve the location of the left parentheses ('(') that
2251   /// precedes the argument list.
2252   SourceLocation getLParenLoc() const { return LParenLoc; }
2253   void setLParenLoc(SourceLocation L) { LParenLoc = L; }
2254
2255   /// \brief Retrieve the location of the right parentheses (')') that
2256   /// follows the argument list.
2257   SourceLocation getRParenLoc() const { return RParenLoc; }
2258   void setRParenLoc(SourceLocation L) { RParenLoc = L; }
2259
2260   /// \brief Retrieve the number of arguments.
2261   unsigned arg_size() const { return NumArgs; }
2262
2263   typedef Expr** arg_iterator;
2264   arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); }
2265   arg_iterator arg_end() { return arg_begin() + NumArgs; }
2266
2267   typedef const Expr* const * const_arg_iterator;
2268   const_arg_iterator arg_begin() const {
2269     return reinterpret_cast<const Expr* const *>(this + 1);
2270   }
2271   const_arg_iterator arg_end() const {
2272     return arg_begin() + NumArgs;
2273   }
2274
2275   Expr *getArg(unsigned I) {
2276     assert(I < NumArgs && "Argument index out-of-range");
2277     return *(arg_begin() + I);
2278   }
2279
2280   const Expr *getArg(unsigned I) const {
2281     assert(I < NumArgs && "Argument index out-of-range");
2282     return *(arg_begin() + I);
2283   }
2284
2285   void setArg(unsigned I, Expr *E) {
2286     assert(I < NumArgs && "Argument index out-of-range");
2287     *(arg_begin() + I) = E;
2288   }
2289
2290   SourceRange getSourceRange() const;
2291   
2292   static bool classof(const Stmt *T) {
2293     return T->getStmtClass() == CXXUnresolvedConstructExprClass;
2294   }
2295   static bool classof(const CXXUnresolvedConstructExpr *) { return true; }
2296
2297   // Iterators
2298   child_range children() {
2299     Stmt **begin = reinterpret_cast<Stmt**>(this+1);
2300     return child_range(begin, begin + NumArgs);
2301   }
2302 };
2303
2304 /// \brief Represents a C++ member access expression where the actual
2305 /// member referenced could not be resolved because the base
2306 /// expression or the member name was dependent.
2307 ///
2308 /// Like UnresolvedMemberExprs, these can be either implicit or
2309 /// explicit accesses.  It is only possible to get one of these with
2310 /// an implicit access if a qualifier is provided.
2311 class CXXDependentScopeMemberExpr : public Expr {
2312   /// \brief The expression for the base pointer or class reference,
2313   /// e.g., the \c x in x.f.  Can be null in implicit accesses.
2314   Stmt *Base;
2315
2316   /// \brief The type of the base expression.  Never null, even for
2317   /// implicit accesses.
2318   QualType BaseType;
2319
2320   /// \brief Whether this member expression used the '->' operator or
2321   /// the '.' operator.
2322   bool IsArrow : 1;
2323
2324   /// \brief Whether this member expression has explicitly-specified template
2325   /// arguments.
2326   bool HasExplicitTemplateArgs : 1;
2327
2328   /// \brief The location of the '->' or '.' operator.
2329   SourceLocation OperatorLoc;
2330
2331   /// \brief The nested-name-specifier that precedes the member name, if any.
2332   NestedNameSpecifierLoc QualifierLoc;
2333
2334   /// \brief In a qualified member access expression such as t->Base::f, this
2335   /// member stores the resolves of name lookup in the context of the member
2336   /// access expression, to be used at instantiation time.
2337   ///
2338   /// FIXME: This member, along with the QualifierLoc, could
2339   /// be stuck into a structure that is optionally allocated at the end of
2340   /// the CXXDependentScopeMemberExpr, to save space in the common case.
2341   NamedDecl *FirstQualifierFoundInScope;
2342
2343   /// \brief The member to which this member expression refers, which
2344   /// can be name, overloaded operator, or destructor.
2345   /// FIXME: could also be a template-id
2346   DeclarationNameInfo MemberNameInfo;
2347
2348   CXXDependentScopeMemberExpr(ASTContext &C,
2349                           Expr *Base, QualType BaseType, bool IsArrow,
2350                           SourceLocation OperatorLoc,
2351                           NestedNameSpecifierLoc QualifierLoc,
2352                           NamedDecl *FirstQualifierFoundInScope,
2353                           DeclarationNameInfo MemberNameInfo,
2354                           const TemplateArgumentListInfo *TemplateArgs);
2355
2356 public:
2357   CXXDependentScopeMemberExpr(ASTContext &C,
2358                               Expr *Base, QualType BaseType,
2359                               bool IsArrow,
2360                               SourceLocation OperatorLoc,
2361                               NestedNameSpecifierLoc QualifierLoc,
2362                               NamedDecl *FirstQualifierFoundInScope,
2363                               DeclarationNameInfo MemberNameInfo);
2364
2365   static CXXDependentScopeMemberExpr *
2366   Create(ASTContext &C,
2367          Expr *Base, QualType BaseType, bool IsArrow,
2368          SourceLocation OperatorLoc,
2369          NestedNameSpecifierLoc QualifierLoc,
2370          NamedDecl *FirstQualifierFoundInScope,
2371          DeclarationNameInfo MemberNameInfo,
2372          const TemplateArgumentListInfo *TemplateArgs);
2373
2374   static CXXDependentScopeMemberExpr *
2375   CreateEmpty(ASTContext &C, bool HasExplicitTemplateArgs, 
2376               unsigned NumTemplateArgs);
2377
2378   /// \brief True if this is an implicit access, i.e. one in which the
2379   /// member being accessed was not written in the source.  The source
2380   /// location of the operator is invalid in this case.
2381   bool isImplicitAccess() const;
2382
2383   /// \brief Retrieve the base object of this member expressions,
2384   /// e.g., the \c x in \c x.m.
2385   Expr *getBase() const {
2386     assert(!isImplicitAccess());
2387     return cast<Expr>(Base);
2388   }
2389
2390   QualType getBaseType() const { return BaseType; }
2391
2392   /// \brief Determine whether this member expression used the '->'
2393   /// operator; otherwise, it used the '.' operator.
2394   bool isArrow() const { return IsArrow; }
2395
2396   /// \brief Retrieve the location of the '->' or '.' operator.
2397   SourceLocation getOperatorLoc() const { return OperatorLoc; }
2398
2399   /// \brief Retrieve the nested-name-specifier that qualifies the member
2400   /// name.
2401   NestedNameSpecifier *getQualifier() const { 
2402     return QualifierLoc.getNestedNameSpecifier(); 
2403   }
2404
2405   /// \brief Retrieve the nested-name-specifier that qualifies the member
2406   /// name, with source location information.
2407   NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
2408   
2409   
2410   /// \brief Retrieve the first part of the nested-name-specifier that was
2411   /// found in the scope of the member access expression when the member access
2412   /// was initially parsed.
2413   ///
2414   /// This function only returns a useful result when member access expression
2415   /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration
2416   /// returned by this function describes what was found by unqualified name
2417   /// lookup for the identifier "Base" within the scope of the member access
2418   /// expression itself. At template instantiation time, this information is
2419   /// combined with the results of name lookup into the type of the object
2420   /// expression itself (the class type of x).
2421   NamedDecl *getFirstQualifierFoundInScope() const {
2422     return FirstQualifierFoundInScope;
2423   }
2424
2425   /// \brief Retrieve the name of the member that this expression
2426   /// refers to.
2427   const DeclarationNameInfo &getMemberNameInfo() const {
2428     return MemberNameInfo;
2429   }
2430
2431   /// \brief Retrieve the name of the member that this expression
2432   /// refers to.
2433   DeclarationName getMember() const { return MemberNameInfo.getName(); }
2434
2435   // \brief Retrieve the location of the name of the member that this
2436   // expression refers to.
2437   SourceLocation getMemberLoc() const { return MemberNameInfo.getLoc(); }
2438
2439   /// \brief Determines whether this member expression actually had a C++
2440   /// template argument list explicitly specified, e.g., x.f<int>.
2441   bool hasExplicitTemplateArgs() const {
2442     return HasExplicitTemplateArgs;
2443   }
2444
2445   /// \brief Retrieve the explicit template argument list that followed the
2446   /// member template name, if any.
2447   ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
2448     assert(HasExplicitTemplateArgs);
2449     return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
2450   }
2451
2452   /// \brief Retrieve the explicit template argument list that followed the
2453   /// member template name, if any.
2454   const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
2455     return const_cast<CXXDependentScopeMemberExpr *>(this)
2456              ->getExplicitTemplateArgs();
2457   }
2458
2459   /// \brief Retrieves the optional explicit template arguments.
2460   /// This points to the same data as getExplicitTemplateArgs(), but
2461   /// returns null if there are no explicit template arguments.
2462   const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
2463     if (!hasExplicitTemplateArgs()) return 0;
2464     return &getExplicitTemplateArgs();
2465   }
2466
2467   /// \brief Copies the template arguments (if present) into the given
2468   /// structure.
2469   void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
2470     getExplicitTemplateArgs().copyInto(List);
2471   }
2472
2473   /// \brief Initializes the template arguments using the given structure.
2474   void initializeTemplateArgumentsFrom(const TemplateArgumentListInfo &List) {
2475     getExplicitTemplateArgs().initializeFrom(List);
2476   }
2477
2478   /// \brief Retrieve the location of the left angle bracket following the
2479   /// member name ('<'), if any.
2480   SourceLocation getLAngleLoc() const {
2481     return getExplicitTemplateArgs().LAngleLoc;
2482   }
2483
2484   /// \brief Retrieve the template arguments provided as part of this
2485   /// template-id.
2486   const TemplateArgumentLoc *getTemplateArgs() const {
2487     return getExplicitTemplateArgs().getTemplateArgs();
2488   }
2489
2490   /// \brief Retrieve the number of template arguments provided as part of this
2491   /// template-id.
2492   unsigned getNumTemplateArgs() const {
2493     return getExplicitTemplateArgs().NumTemplateArgs;
2494   }
2495
2496   /// \brief Retrieve the location of the right angle bracket following the
2497   /// template arguments ('>').
2498   SourceLocation getRAngleLoc() const {
2499     return getExplicitTemplateArgs().RAngleLoc;
2500   }
2501
2502   SourceRange getSourceRange() const {
2503     SourceRange Range;
2504     if (!isImplicitAccess())
2505       Range.setBegin(Base->getSourceRange().getBegin());
2506     else if (getQualifier())
2507       Range.setBegin(getQualifierLoc().getBeginLoc());
2508     else
2509       Range.setBegin(MemberNameInfo.getBeginLoc());
2510
2511     if (hasExplicitTemplateArgs())
2512       Range.setEnd(getRAngleLoc());
2513     else
2514       Range.setEnd(MemberNameInfo.getEndLoc());
2515     return Range;
2516   }
2517
2518   static bool classof(const Stmt *T) {
2519     return T->getStmtClass() == CXXDependentScopeMemberExprClass;
2520   }
2521   static bool classof(const CXXDependentScopeMemberExpr *) { return true; }
2522
2523   // Iterators
2524   child_range children() {
2525     if (isImplicitAccess()) return child_range();
2526     return child_range(&Base, &Base + 1);
2527   }
2528
2529   friend class ASTStmtReader;
2530   friend class ASTStmtWriter;
2531 };
2532
2533 /// \brief Represents a C++ member access expression for which lookup
2534 /// produced a set of overloaded functions.
2535 ///
2536 /// The member access may be explicit or implicit:
2537 ///    struct A {
2538 ///      int a, b;
2539 ///      int explicitAccess() { return this->a + this->A::b; }
2540 ///      int implicitAccess() { return a + A::b; }
2541 ///    };
2542 ///
2543 /// In the final AST, an explicit access always becomes a MemberExpr.
2544 /// An implicit access may become either a MemberExpr or a
2545 /// DeclRefExpr, depending on whether the member is static.
2546 class UnresolvedMemberExpr : public OverloadExpr {
2547   /// \brief Whether this member expression used the '->' operator or
2548   /// the '.' operator.
2549   bool IsArrow : 1;
2550
2551   /// \brief Whether the lookup results contain an unresolved using
2552   /// declaration.
2553   bool HasUnresolvedUsing : 1;
2554
2555   /// \brief The expression for the base pointer or class reference,
2556   /// e.g., the \c x in x.f.  This can be null if this is an 'unbased'
2557   /// member expression
2558   Stmt *Base;
2559
2560   /// \brief The type of the base expression;  never null.
2561   QualType BaseType;
2562
2563   /// \brief The location of the '->' or '.' operator.
2564   SourceLocation OperatorLoc;
2565
2566   UnresolvedMemberExpr(ASTContext &C, bool HasUnresolvedUsing,
2567                        Expr *Base, QualType BaseType, bool IsArrow,
2568                        SourceLocation OperatorLoc,
2569                        NestedNameSpecifierLoc QualifierLoc,
2570                        const DeclarationNameInfo &MemberNameInfo,
2571                        const TemplateArgumentListInfo *TemplateArgs,
2572                        UnresolvedSetIterator Begin, UnresolvedSetIterator End);
2573   
2574   UnresolvedMemberExpr(EmptyShell Empty)
2575     : OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false),
2576       HasUnresolvedUsing(false), Base(0) { }
2577
2578   friend class ASTStmtReader;
2579   
2580 public:
2581   static UnresolvedMemberExpr *
2582   Create(ASTContext &C, bool HasUnresolvedUsing,
2583          Expr *Base, QualType BaseType, bool IsArrow,
2584          SourceLocation OperatorLoc,
2585          NestedNameSpecifierLoc QualifierLoc,
2586          const DeclarationNameInfo &MemberNameInfo,
2587          const TemplateArgumentListInfo *TemplateArgs,
2588          UnresolvedSetIterator Begin, UnresolvedSetIterator End);
2589
2590   static UnresolvedMemberExpr *
2591   CreateEmpty(ASTContext &C, bool HasExplicitTemplateArgs,
2592               unsigned NumTemplateArgs);
2593
2594   /// \brief True if this is an implicit access, i.e. one in which the
2595   /// member being accessed was not written in the source.  The source
2596   /// location of the operator is invalid in this case.
2597   bool isImplicitAccess() const;
2598
2599   /// \brief Retrieve the base object of this member expressions,
2600   /// e.g., the \c x in \c x.m.
2601   Expr *getBase() {
2602     assert(!isImplicitAccess());
2603     return cast<Expr>(Base);
2604   }
2605   const Expr *getBase() const {
2606     assert(!isImplicitAccess());
2607     return cast<Expr>(Base);
2608   }
2609
2610   QualType getBaseType() const { return BaseType; }
2611
2612   /// \brief Determine whether the lookup results contain an unresolved using
2613   /// declaration.
2614   bool hasUnresolvedUsing() const { return HasUnresolvedUsing; }
2615
2616   /// \brief Determine whether this member expression used the '->'
2617   /// operator; otherwise, it used the '.' operator.
2618   bool isArrow() const { return IsArrow; }
2619
2620   /// \brief Retrieve the location of the '->' or '.' operator.
2621   SourceLocation getOperatorLoc() const { return OperatorLoc; }
2622
2623   /// \brief Retrieves the naming class of this lookup.
2624   CXXRecordDecl *getNamingClass() const;
2625
2626   /// \brief Retrieve the full name info for the member that this expression
2627   /// refers to.
2628   const DeclarationNameInfo &getMemberNameInfo() const { return getNameInfo(); }
2629
2630   /// \brief Retrieve the name of the member that this expression
2631   /// refers to.
2632   DeclarationName getMemberName() const { return getName(); }
2633
2634   // \brief Retrieve the location of the name of the member that this
2635   // expression refers to.
2636   SourceLocation getMemberLoc() const { return getNameLoc(); }
2637
2638   /// \brief Retrieve the explicit template argument list that followed the
2639   /// member template name.
2640   ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
2641     assert(hasExplicitTemplateArgs());
2642     return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
2643   }
2644
2645   /// \brief Retrieve the explicit template argument list that followed the
2646   /// member template name, if any.
2647   const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
2648     assert(hasExplicitTemplateArgs());
2649     return *reinterpret_cast<const ExplicitTemplateArgumentList *>(this + 1);
2650   }
2651
2652   /// \brief Retrieves the optional explicit template arguments.
2653   /// This points to the same data as getExplicitTemplateArgs(), but
2654   /// returns null if there are no explicit template arguments.
2655   const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
2656     if (!hasExplicitTemplateArgs()) return 0;
2657     return &getExplicitTemplateArgs();
2658   }
2659
2660   /// \brief Copies the template arguments into the given structure.
2661   void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
2662     getExplicitTemplateArgs().copyInto(List);
2663   }
2664
2665   /// \brief Retrieve the location of the left angle bracket following
2666   /// the member name ('<').
2667   SourceLocation getLAngleLoc() const {
2668     return getExplicitTemplateArgs().LAngleLoc;
2669   }
2670
2671   /// \brief Retrieve the template arguments provided as part of this
2672   /// template-id.
2673   const TemplateArgumentLoc *getTemplateArgs() const {
2674     return getExplicitTemplateArgs().getTemplateArgs();
2675   }
2676
2677   /// \brief Retrieve the number of template arguments provided as
2678   /// part of this template-id.
2679   unsigned getNumTemplateArgs() const {
2680     return getExplicitTemplateArgs().NumTemplateArgs;
2681   }
2682
2683   /// \brief Retrieve the location of the right angle bracket
2684   /// following the template arguments ('>').
2685   SourceLocation getRAngleLoc() const {
2686     return getExplicitTemplateArgs().RAngleLoc;
2687   }
2688
2689   SourceRange getSourceRange() const {
2690     SourceRange Range = getMemberNameInfo().getSourceRange();
2691     if (!isImplicitAccess())
2692       Range.setBegin(Base->getSourceRange().getBegin());
2693     else if (getQualifierLoc())
2694       Range.setBegin(getQualifierLoc().getBeginLoc());
2695
2696     if (hasExplicitTemplateArgs())
2697       Range.setEnd(getRAngleLoc());
2698     return Range;
2699   }
2700
2701   static bool classof(const Stmt *T) {
2702     return T->getStmtClass() == UnresolvedMemberExprClass;
2703   }
2704   static bool classof(const UnresolvedMemberExpr *) { return true; }
2705
2706   // Iterators
2707   child_range children() {
2708     if (isImplicitAccess()) return child_range();
2709     return child_range(&Base, &Base + 1);
2710   }
2711 };
2712
2713 /// \brief Represents a C++0x noexcept expression (C++ [expr.unary.noexcept]).
2714 ///
2715 /// The noexcept expression tests whether a given expression might throw. Its
2716 /// result is a boolean constant.
2717 class CXXNoexceptExpr : public Expr {
2718   bool Value : 1;
2719   Stmt *Operand;
2720   SourceRange Range;
2721
2722   friend class ASTStmtReader;
2723
2724 public:
2725   CXXNoexceptExpr(QualType Ty, Expr *Operand, CanThrowResult Val,
2726                   SourceLocation Keyword, SourceLocation RParen)
2727     : Expr(CXXNoexceptExprClass, Ty, VK_RValue, OK_Ordinary,
2728            /*TypeDependent*/false,
2729            /*ValueDependent*/Val == CT_Dependent,
2730            Operand->containsUnexpandedParameterPack()),
2731       Value(Val == CT_Cannot), Operand(Operand), Range(Keyword, RParen)
2732   { }
2733
2734   CXXNoexceptExpr(EmptyShell Empty)
2735     : Expr(CXXNoexceptExprClass, Empty)
2736   { }
2737
2738   Expr *getOperand() const { return static_cast<Expr*>(Operand); }
2739
2740   SourceRange getSourceRange() const { return Range; }
2741
2742   bool getValue() const { return Value; }
2743
2744   static bool classof(const Stmt *T) {
2745     return T->getStmtClass() == CXXNoexceptExprClass;
2746   }
2747   static bool classof(const CXXNoexceptExpr *) { return true; }
2748
2749   // Iterators
2750   child_range children() { return child_range(&Operand, &Operand + 1); }
2751 };
2752
2753 /// \brief Represents a C++0x pack expansion that produces a sequence of 
2754 /// expressions.
2755 ///
2756 /// A pack expansion expression contains a pattern (which itself is an
2757 /// expression) followed by an ellipsis. For example:
2758 ///
2759 /// \code
2760 /// template<typename F, typename ...Types>
2761 /// void forward(F f, Types &&...args) {
2762 ///   f(static_cast<Types&&>(args)...);
2763 /// }
2764 /// \endcode
2765 ///
2766 /// Here, the argument to the function object \c f is a pack expansion whose
2767 /// pattern is \c static_cast<Types&&>(args). When the \c forward function 
2768 /// template is instantiated, the pack expansion will instantiate to zero or
2769 /// or more function arguments to the function object \c f.
2770 class PackExpansionExpr : public Expr {
2771   SourceLocation EllipsisLoc;
2772   
2773   /// \brief The number of expansions that will be produced by this pack
2774   /// expansion expression, if known.
2775   ///
2776   /// When zero, the number of expansions is not known. Otherwise, this value
2777   /// is the number of expansions + 1.
2778   unsigned NumExpansions;
2779   
2780   Stmt *Pattern;
2781   
2782   friend class ASTStmtReader;
2783   friend class ASTStmtWriter;
2784   
2785 public:
2786   PackExpansionExpr(QualType T, Expr *Pattern, SourceLocation EllipsisLoc,
2787                     llvm::Optional<unsigned> NumExpansions)
2788     : Expr(PackExpansionExprClass, T, Pattern->getValueKind(), 
2789            Pattern->getObjectKind(), /*TypeDependent=*/true, 
2790            /*ValueDependent=*/true, /*ContainsUnexpandedParameterPack=*/false),
2791       EllipsisLoc(EllipsisLoc),
2792       NumExpansions(NumExpansions? *NumExpansions + 1 : 0),
2793       Pattern(Pattern) { }
2794
2795   PackExpansionExpr(EmptyShell Empty) : Expr(PackExpansionExprClass, Empty) { }
2796   
2797   /// \brief Retrieve the pattern of the pack expansion.
2798   Expr *getPattern() { return reinterpret_cast<Expr *>(Pattern); }
2799
2800   /// \brief Retrieve the pattern of the pack expansion.
2801   const Expr *getPattern() const { return reinterpret_cast<Expr *>(Pattern); }
2802
2803   /// \brief Retrieve the location of the ellipsis that describes this pack
2804   /// expansion.
2805   SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
2806   
2807   /// \brief Determine the number of expansions that will be produced when 
2808   /// this pack expansion is instantiated, if already known.
2809   llvm::Optional<unsigned> getNumExpansions() const {
2810     if (NumExpansions)
2811       return NumExpansions - 1;
2812     
2813     return llvm::Optional<unsigned>();
2814   }
2815   
2816   SourceRange getSourceRange() const {
2817     return SourceRange(Pattern->getLocStart(), EllipsisLoc);
2818   }
2819
2820   static bool classof(const Stmt *T) {
2821     return T->getStmtClass() == PackExpansionExprClass;
2822   }
2823   static bool classof(const PackExpansionExpr *) { return true; }
2824   
2825   // Iterators
2826   child_range children() {
2827     return child_range(&Pattern, &Pattern + 1);
2828   }
2829 };
2830   
2831 inline ExplicitTemplateArgumentList &OverloadExpr::getExplicitTemplateArgs() {
2832   if (isa<UnresolvedLookupExpr>(this))
2833     return cast<UnresolvedLookupExpr>(this)->getExplicitTemplateArgs();
2834   else
2835     return cast<UnresolvedMemberExpr>(this)->getExplicitTemplateArgs();
2836 }
2837
2838 /// \brief Represents an expression that computes the length of a parameter 
2839 /// pack.
2840 ///
2841 /// \code
2842 /// template<typename ...Types>
2843 /// struct count {
2844 ///   static const unsigned value = sizeof...(Types);
2845 /// };
2846 /// \endcode
2847 class SizeOfPackExpr : public Expr {
2848   /// \brief The location of the 'sizeof' keyword.
2849   SourceLocation OperatorLoc;
2850   
2851   /// \brief The location of the name of the parameter pack.
2852   SourceLocation PackLoc;
2853   
2854   /// \brief The location of the closing parenthesis.
2855   SourceLocation RParenLoc;
2856   
2857   /// \brief The length of the parameter pack, if known.
2858   ///
2859   /// When this expression is value-dependent, the length of the parameter pack
2860   /// is unknown. When this expression is not value-dependent, the length is
2861   /// known.
2862   unsigned Length;
2863   
2864   /// \brief The parameter pack itself.
2865   NamedDecl *Pack;
2866   
2867   friend class ASTStmtReader;
2868   friend class ASTStmtWriter;
2869   
2870 public:
2871   /// \brief Creates a value-dependent expression that computes the length of
2872   /// the given parameter pack.
2873   SizeOfPackExpr(QualType SizeType, SourceLocation OperatorLoc, NamedDecl *Pack, 
2874                  SourceLocation PackLoc, SourceLocation RParenLoc)
2875     : Expr(SizeOfPackExprClass, SizeType, VK_RValue, OK_Ordinary,
2876            /*TypeDependent=*/false, /*ValueDependent=*/true,
2877            /*ContainsUnexpandedParameterPack=*/false),
2878       OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc),
2879       Length(0), Pack(Pack) { }
2880
2881   /// \brief Creates an expression that computes the length of
2882   /// the given parameter pack, which is already known.
2883   SizeOfPackExpr(QualType SizeType, SourceLocation OperatorLoc, NamedDecl *Pack, 
2884                  SourceLocation PackLoc, SourceLocation RParenLoc,
2885                  unsigned Length)
2886   : Expr(SizeOfPackExprClass, SizeType, VK_RValue, OK_Ordinary,
2887          /*TypeDependent=*/false, /*ValueDependent=*/false,
2888          /*ContainsUnexpandedParameterPack=*/false),
2889     OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc),
2890     Length(Length), Pack(Pack) { }
2891
2892   /// \brief Create an empty expression.
2893   SizeOfPackExpr(EmptyShell Empty) : Expr(SizeOfPackExprClass, Empty) { }
2894   
2895   /// \brief Determine the location of the 'sizeof' keyword.
2896   SourceLocation getOperatorLoc() const { return OperatorLoc; }
2897
2898   /// \brief Determine the location of the parameter pack.
2899   SourceLocation getPackLoc() const { return PackLoc; }
2900   
2901   /// \brief Determine the location of the right parenthesis.
2902   SourceLocation getRParenLoc() const { return RParenLoc; }
2903   
2904   /// \brief Retrieve the parameter pack.
2905   NamedDecl *getPack() const { return Pack; }
2906   
2907   /// \brief Retrieve the length of the parameter pack.
2908   ///
2909   /// This routine may only be invoked when the expression is not 
2910   /// value-dependent.
2911   unsigned getPackLength() const {
2912     assert(!isValueDependent() && 
2913            "Cannot get the length of a value-dependent pack size expression");
2914     return Length;
2915   }
2916   
2917   SourceRange getSourceRange() const {
2918     return SourceRange(OperatorLoc, RParenLoc);
2919   }
2920   
2921   static bool classof(const Stmt *T) {
2922     return T->getStmtClass() == SizeOfPackExprClass;
2923   }
2924   static bool classof(const SizeOfPackExpr *) { return true; }
2925   
2926   // Iterators
2927   child_range children() { return child_range(); }
2928 };
2929
2930 /// \brief Represents a reference to a non-type template parameter pack that
2931 /// has been substituted with a non-template argument pack.
2932 ///
2933 /// When a pack expansion in the source code contains multiple parameter packs
2934 /// and those parameter packs correspond to different levels of template
2935 /// parameter lists, this node node is used to represent a non-type template 
2936 /// parameter pack from an outer level, which has already had its argument pack
2937 /// substituted but that still lives within a pack expansion that itself
2938 /// could not be instantiated. When actually performing a substitution into
2939 /// that pack expansion (e.g., when all template parameters have corresponding
2940 /// arguments), this type will be replaced with the appropriate underlying
2941 /// expression at the current pack substitution index.
2942 class SubstNonTypeTemplateParmPackExpr : public Expr {
2943   /// \brief The non-type template parameter pack itself.
2944   NonTypeTemplateParmDecl *Param;
2945   
2946   /// \brief A pointer to the set of template arguments that this
2947   /// parameter pack is instantiated with.
2948   const TemplateArgument *Arguments;
2949   
2950   /// \brief The number of template arguments in \c Arguments.
2951   unsigned NumArguments;
2952   
2953   /// \brief The location of the non-type template parameter pack reference.
2954   SourceLocation NameLoc;
2955   
2956   friend class ASTStmtReader;
2957   friend class ASTStmtWriter;
2958   
2959 public:
2960   SubstNonTypeTemplateParmPackExpr(QualType T, 
2961                                    NonTypeTemplateParmDecl *Param,
2962                                    SourceLocation NameLoc,
2963                                    const TemplateArgument &ArgPack);
2964   
2965   SubstNonTypeTemplateParmPackExpr(EmptyShell Empty) 
2966     : Expr(SubstNonTypeTemplateParmPackExprClass, Empty) { }
2967   
2968   /// \brief Retrieve the non-type template parameter pack being substituted.
2969   NonTypeTemplateParmDecl *getParameterPack() const { return Param; }
2970
2971   /// \brief Retrieve the location of the parameter pack name.
2972   SourceLocation getParameterPackLocation() const { return NameLoc; }
2973   
2974   /// \brief Retrieve the template argument pack containing the substituted
2975   /// template arguments.
2976   TemplateArgument getArgumentPack() const;
2977
2978   SourceRange getSourceRange() const { return NameLoc; }
2979   
2980   static bool classof(const Stmt *T) {
2981     return T->getStmtClass() == SubstNonTypeTemplateParmPackExprClass;
2982   }
2983   static bool classof(const SubstNonTypeTemplateParmPackExpr *) { 
2984     return true; 
2985   }
2986   
2987   // Iterators
2988   child_range children() { return child_range(); }
2989 };
2990   
2991 }  // end namespace clang
2992
2993 #endif