blob: 18c0f77ab29e3c77c69d4f8a4cc566b59ca03f78 [file] [log] [blame]
Ted Kremeneka758d092007-08-24 20:21:10 +00001//===--- ExprCXX.cpp - (C++) Expression AST Node Implementation -----------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner0bc735f2007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Ted Kremeneka758d092007-08-24 20:21:10 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the subclesses of Expr class declared in ExprCXX.h
11//
12//===----------------------------------------------------------------------===//
13
Douglas Gregorb4609802008-11-14 16:09:21 +000014#include "clang/Basic/IdentifierTable.h"
15#include "clang/AST/DeclCXX.h"
Ted Kremeneka758d092007-08-24 20:21:10 +000016#include "clang/AST/ExprCXX.h"
17using namespace clang;
18
Argyrios Kyrtzidis4189a762008-09-10 02:14:49 +000019void CXXConditionDeclExpr::Destroy(ASTContext& C) {
Sebastian Redldf2d3cf2009-02-05 15:12:41 +000020 // FIXME: Cannot destroy the decl here, because it is linked into the
21 // DeclContext's chain.
22 //getVarDecl()->Destroy(C);
Ted Kremenek8189cde2009-02-07 01:47:29 +000023 this->~CXXConditionDeclExpr();
24 C.Deallocate(this);
Argyrios Kyrtzidis4189a762008-09-10 02:14:49 +000025}
Argyrios Kyrtzidis9e922b12008-09-09 23:47:53 +000026
Ted Kremeneka758d092007-08-24 20:21:10 +000027//===----------------------------------------------------------------------===//
28// Child Iterators for iterating over subexpressions/substatements
29//===----------------------------------------------------------------------===//
30
Sebastian Redlc42e1182008-11-11 11:37:55 +000031// CXXTypeidExpr - has child iterators if the operand is an expression
32Stmt::child_iterator CXXTypeidExpr::child_begin() {
Sebastian Redld4575892008-12-03 23:17:54 +000033 return isTypeOperand() ? child_iterator() : &Operand.Ex;
Sebastian Redlc42e1182008-11-11 11:37:55 +000034}
35Stmt::child_iterator CXXTypeidExpr::child_end() {
Sebastian Redld4575892008-12-03 23:17:54 +000036 return isTypeOperand() ? child_iterator() : &Operand.Ex+1;
Sebastian Redlc42e1182008-11-11 11:37:55 +000037}
Ted Kremeneka758d092007-08-24 20:21:10 +000038
Ted Kremeneka758d092007-08-24 20:21:10 +000039// CXXBoolLiteralExpr
Ted Kremenek9ac59282007-10-18 23:28:49 +000040Stmt::child_iterator CXXBoolLiteralExpr::child_begin() {
41 return child_iterator();
42}
43Stmt::child_iterator CXXBoolLiteralExpr::child_end() {
44 return child_iterator();
45}
Chris Lattner50dd2892008-02-26 00:51:44 +000046
Sebastian Redl6e8ed162009-05-10 18:38:11 +000047// CXXNullPtrLiteralExpr
48Stmt::child_iterator CXXNullPtrLiteralExpr::child_begin() {
49 return child_iterator();
50}
51Stmt::child_iterator CXXNullPtrLiteralExpr::child_end() {
52 return child_iterator();
53}
54
Douglas Gregor796da182008-11-04 14:32:21 +000055// CXXThisExpr
56Stmt::child_iterator CXXThisExpr::child_begin() { return child_iterator(); }
57Stmt::child_iterator CXXThisExpr::child_end() { return child_iterator(); }
58
Chris Lattner50dd2892008-02-26 00:51:44 +000059// CXXThrowExpr
Ted Kremenek1060aff2008-06-17 03:11:08 +000060Stmt::child_iterator CXXThrowExpr::child_begin() { return &Op; }
Chris Lattner50dd2892008-02-26 00:51:44 +000061Stmt::child_iterator CXXThrowExpr::child_end() {
62 // If Op is 0, we are processing throw; which has no children.
Ted Kremenek1060aff2008-06-17 03:11:08 +000063 return Op ? &Op+1 : &Op;
Chris Lattner50dd2892008-02-26 00:51:44 +000064}
Chris Lattner04421082008-04-08 04:40:51 +000065
66// CXXDefaultArgExpr
67Stmt::child_iterator CXXDefaultArgExpr::child_begin() {
Chris Lattner8123a952008-04-10 02:22:51 +000068 return child_iterator();
Chris Lattner04421082008-04-08 04:40:51 +000069}
70Stmt::child_iterator CXXDefaultArgExpr::child_end() {
Chris Lattner8123a952008-04-10 02:22:51 +000071 return child_iterator();
Chris Lattner04421082008-04-08 04:40:51 +000072}
Argyrios Kyrtzidis987a14b2008-08-22 15:38:55 +000073
74// CXXZeroInitValueExpr
75Stmt::child_iterator CXXZeroInitValueExpr::child_begin() {
76 return child_iterator();
77}
78Stmt::child_iterator CXXZeroInitValueExpr::child_end() {
79 return child_iterator();
80}
Argyrios Kyrtzidis9e922b12008-09-09 23:47:53 +000081
82// CXXConditionDeclExpr
83Stmt::child_iterator CXXConditionDeclExpr::child_begin() {
84 return getVarDecl();
85}
86Stmt::child_iterator CXXConditionDeclExpr::child_end() {
87 return child_iterator();
88}
Douglas Gregor49badde2008-10-27 19:41:14 +000089
Sebastian Redl4c5d3202008-11-21 19:14:01 +000090// CXXNewExpr
91CXXNewExpr::CXXNewExpr(bool globalNew, FunctionDecl *operatorNew,
92 Expr **placementArgs, unsigned numPlaceArgs,
Sebastian Redlcee63fb2008-12-02 14:43:59 +000093 bool parenTypeId, Expr *arraySize,
Sebastian Redl4c5d3202008-11-21 19:14:01 +000094 CXXConstructorDecl *constructor, bool initializer,
95 Expr **constructorArgs, unsigned numConsArgs,
96 FunctionDecl *operatorDelete, QualType ty,
97 SourceLocation startLoc, SourceLocation endLoc)
Sebastian Redl28507842009-02-26 14:39:58 +000098 : Expr(CXXNewExprClass, ty, ty->isDependentType(), ty->isDependentType()),
99 GlobalNew(globalNew), ParenTypeId(parenTypeId),
Sebastian Redlcee63fb2008-12-02 14:43:59 +0000100 Initializer(initializer), Array(arraySize), NumPlacementArgs(numPlaceArgs),
Sebastian Redl4c5d3202008-11-21 19:14:01 +0000101 NumConstructorArgs(numConsArgs), OperatorNew(operatorNew),
Sebastian Redlcee63fb2008-12-02 14:43:59 +0000102 OperatorDelete(operatorDelete), Constructor(constructor),
Sebastian Redl4c5d3202008-11-21 19:14:01 +0000103 StartLoc(startLoc), EndLoc(endLoc)
104{
Sebastian Redlcee63fb2008-12-02 14:43:59 +0000105 unsigned TotalSize = Array + NumPlacementArgs + NumConstructorArgs;
Sebastian Redl4c5d3202008-11-21 19:14:01 +0000106 SubExprs = new Stmt*[TotalSize];
107 unsigned i = 0;
Sebastian Redlcee63fb2008-12-02 14:43:59 +0000108 if (Array)
109 SubExprs[i++] = arraySize;
110 for (unsigned j = 0; j < NumPlacementArgs; ++j)
Sebastian Redl4c5d3202008-11-21 19:14:01 +0000111 SubExprs[i++] = placementArgs[j];
Sebastian Redlcee63fb2008-12-02 14:43:59 +0000112 for (unsigned j = 0; j < NumConstructorArgs; ++j)
Sebastian Redl4c5d3202008-11-21 19:14:01 +0000113 SubExprs[i++] = constructorArgs[j];
114 assert(i == TotalSize);
115}
116
117Stmt::child_iterator CXXNewExpr::child_begin() { return &SubExprs[0]; }
118Stmt::child_iterator CXXNewExpr::child_end() {
Sebastian Redlcee63fb2008-12-02 14:43:59 +0000119 return &SubExprs[0] + Array + getNumPlacementArgs() + getNumConstructorArgs();
Sebastian Redl4c5d3202008-11-21 19:14:01 +0000120}
121
122// CXXDeleteExpr
123Stmt::child_iterator CXXDeleteExpr::child_begin() { return &Argument; }
124Stmt::child_iterator CXXDeleteExpr::child_end() { return &Argument+1; }
125
Douglas Gregor17330012009-02-04 15:01:18 +0000126// UnresolvedFunctionNameExpr
127Stmt::child_iterator UnresolvedFunctionNameExpr::child_begin() {
Douglas Gregor5c37de72008-12-06 00:22:45 +0000128 return child_iterator();
129}
Douglas Gregor17330012009-02-04 15:01:18 +0000130Stmt::child_iterator UnresolvedFunctionNameExpr::child_end() {
Douglas Gregor5c37de72008-12-06 00:22:45 +0000131 return child_iterator();
132}
133
Douglas Gregor4a2487a2009-05-19 00:38:01 +0000134UnresolvedFunctionNameExpr*
135UnresolvedFunctionNameExpr::Clone(ASTContext &C) const {
136 return new (C) UnresolvedFunctionNameExpr(Name, getType(), Loc);
137}
138
Sebastian Redl64b45f72009-01-05 20:52:13 +0000139// UnaryTypeTraitExpr
140Stmt::child_iterator UnaryTypeTraitExpr::child_begin() {
141 return child_iterator();
142}
143Stmt::child_iterator UnaryTypeTraitExpr::child_end() {
144 return child_iterator();
145}
146
Douglas Gregor5953d8b2009-03-19 17:26:29 +0000147// UnresolvedDeclRefExpr
148StmtIterator UnresolvedDeclRefExpr::child_begin() {
149 return child_iterator();
150}
151
152StmtIterator UnresolvedDeclRefExpr::child_end() {
153 return child_iterator();
154}
155
Daniel Dunbarc87a2822009-02-17 23:20:26 +0000156bool UnaryTypeTraitExpr::EvaluateTrait() const {
Sebastian Redl64b45f72009-01-05 20:52:13 +0000157 switch(UTT) {
158 default: assert(false && "Unknown type trait or not implemented");
159 case UTT_IsPOD: return QueriedType->isPODType();
160 case UTT_IsClass: // Fallthrough
161 case UTT_IsUnion:
162 if (const RecordType *Record = QueriedType->getAsRecordType()) {
163 bool Union = Record->getDecl()->isUnion();
164 return UTT == UTT_IsUnion ? Union : !Union;
165 }
166 return false;
167 case UTT_IsEnum: return QueriedType->isEnumeralType();
168 case UTT_IsPolymorphic:
169 if (const RecordType *Record = QueriedType->getAsRecordType()) {
170 // Type traits are only parsed in C++, so we've got CXXRecords.
171 return cast<CXXRecordDecl>(Record->getDecl())->isPolymorphic();
172 }
173 return false;
Anders Carlsson67e4dd22009-03-22 01:52:17 +0000174 case UTT_IsAbstract:
175 if (const RecordType *RT = QueriedType->getAsRecordType())
176 return cast<CXXRecordDecl>(RT->getDecl())->isAbstract();
177 return false;
Anders Carlsson347ba892009-04-16 00:08:20 +0000178 case UTT_HasTrivialConstructor:
179 if (const RecordType *RT = QueriedType->getAsRecordType())
180 return cast<CXXRecordDecl>(RT->getDecl())->hasTrivialConstructor();
Anders Carlsson072abef2009-04-17 02:34:54 +0000181 return false;
182 case UTT_HasTrivialDestructor:
183 if (const RecordType *RT = QueriedType->getAsRecordType())
184 return cast<CXXRecordDecl>(RT->getDecl())->hasTrivialDestructor();
185 return false;
Sebastian Redl64b45f72009-01-05 20:52:13 +0000186 }
187}
188
Douglas Gregorb4609802008-11-14 16:09:21 +0000189SourceRange CXXOperatorCallExpr::getSourceRange() const {
190 OverloadedOperatorKind Kind = getOperator();
191 if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
192 if (getNumArgs() == 1)
193 // Prefix operator
194 return SourceRange(getOperatorLoc(),
195 getArg(0)->getSourceRange().getEnd());
196 else
197 // Postfix operator
198 return SourceRange(getArg(0)->getSourceRange().getEnd(),
199 getOperatorLoc());
200 } else if (Kind == OO_Call) {
201 return SourceRange(getArg(0)->getSourceRange().getBegin(), getRParenLoc());
202 } else if (Kind == OO_Subscript) {
203 return SourceRange(getArg(0)->getSourceRange().getBegin(), getRParenLoc());
204 } else if (getNumArgs() == 1) {
205 return SourceRange(getOperatorLoc(), getArg(0)->getSourceRange().getEnd());
206 } else if (getNumArgs() == 2) {
207 return SourceRange(getArg(0)->getSourceRange().getBegin(),
208 getArg(1)->getSourceRange().getEnd());
209 } else {
210 return SourceRange();
211 }
212}
213
Douglas Gregor88a35142008-12-22 05:46:06 +0000214Expr *CXXMemberCallExpr::getImplicitObjectArgument() {
215 if (MemberExpr *MemExpr = dyn_cast<MemberExpr>(getCallee()->IgnoreParens()))
216 return MemExpr->getBase();
217
218 // FIXME: Will eventually need to cope with member pointers.
219 return 0;
220}
221
Douglas Gregor49badde2008-10-27 19:41:14 +0000222//===----------------------------------------------------------------------===//
223// Named casts
224//===----------------------------------------------------------------------===//
225
226/// getCastName - Get the name of the C++ cast being used, e.g.,
227/// "static_cast", "dynamic_cast", "reinterpret_cast", or
228/// "const_cast". The returned pointer must not be freed.
229const char *CXXNamedCastExpr::getCastName() const {
230 switch (getStmtClass()) {
231 case CXXStaticCastExprClass: return "static_cast";
232 case CXXDynamicCastExprClass: return "dynamic_cast";
233 case CXXReinterpretCastExprClass: return "reinterpret_cast";
234 case CXXConstCastExprClass: return "const_cast";
235 default: return "<invalid cast>";
236 }
237}
Douglas Gregor506ae412009-01-16 18:33:17 +0000238
Anders Carlssonc1ce4772009-05-30 19:54:15 +0000239CXXTemporary *CXXTemporary::Create(ASTContext &C,
Anders Carlssonb859f352009-05-30 20:34:37 +0000240 const CXXDestructorDecl *Destructor) {
Anders Carlsson88eaf072009-05-30 22:38:53 +0000241 return new (C) CXXTemporary(Destructor);
242}
243
244void CXXTemporary::Destroy(ASTContext &C) {
245 this->~CXXTemporary();
246 C.Deallocate(this);
Anders Carlssonc1ce4772009-05-30 19:54:15 +0000247}
248
Anders Carlssonfceb0a82009-05-30 20:03:25 +0000249CXXBindTemporaryExpr *CXXBindTemporaryExpr::Create(ASTContext &C,
250 CXXTemporary *Temp,
251 Expr* SubExpr) {
252 assert(SubExpr->getType()->isRecordType() &&
253 "Expression bound to a temporary must have record type!");
254
Anders Carlssonb859f352009-05-30 20:34:37 +0000255 return new (C) CXXBindTemporaryExpr(Temp, SubExpr);
Anders Carlssonfceb0a82009-05-30 20:03:25 +0000256}
257
Anders Carlsson88eaf072009-05-30 22:38:53 +0000258void CXXBindTemporaryExpr::Destroy(ASTContext &C) {
259 Temp->Destroy(C);
260 this->~CXXBindTemporaryExpr();
261 C.Deallocate(this);
262}
263
Anders Carlsson8e587a12009-05-30 20:56:46 +0000264CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(ASTContext &C,
Anders Carlsson26de5492009-04-24 05:23:13 +0000265 CXXConstructorDecl *Cons,
Douglas Gregor506ae412009-01-16 18:33:17 +0000266 QualType writtenTy,
267 SourceLocation tyBeginLoc,
268 Expr **Args,
269 unsigned NumArgs,
270 SourceLocation rParenLoc)
Anders Carlsson8e587a12009-05-30 20:56:46 +0000271 : CXXConstructExpr(C, CXXTemporaryObjectExprClass, writtenTy, Cons,
Anders Carlsson524fa132009-04-24 17:34:38 +0000272 false, Args, NumArgs),
273 TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {
Douglas Gregor506ae412009-01-16 18:33:17 +0000274}
Anders Carlsson19d28a62009-04-21 02:22:11 +0000275
Anders Carlsson8e587a12009-05-30 20:56:46 +0000276CXXConstructExpr *CXXConstructExpr::Create(ASTContext &C, QualType T,
277 CXXConstructorDecl *D, bool Elidable,
Anders Carlssone349bea2009-04-23 02:32:43 +0000278 Expr **Args, unsigned NumArgs) {
Anders Carlsson8e587a12009-05-30 20:56:46 +0000279 return new (C) CXXConstructExpr(C, CXXConstructExprClass, T, D, Elidable,
Anders Carlssonbd6734e2009-04-24 05:04:04 +0000280 Args, NumArgs);
Anders Carlssone349bea2009-04-23 02:32:43 +0000281}
282
Anders Carlsson8e587a12009-05-30 20:56:46 +0000283CXXConstructExpr::CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
284 CXXConstructorDecl *D, bool elidable,
Anders Carlssone349bea2009-04-23 02:32:43 +0000285 Expr **args, unsigned numargs)
Anders Carlssonbd6734e2009-04-24 05:04:04 +0000286: Expr(SC, T,
Anders Carlssone349bea2009-04-23 02:32:43 +0000287 T->isDependentType(),
288 (T->isDependentType() ||
289 CallExpr::hasAnyValueDependentArguments(args, numargs))),
Anders Carlsson8e587a12009-05-30 20:56:46 +0000290 Constructor(D), Elidable(elidable), Args(0), NumArgs(numargs) {
Anders Carlssone349bea2009-04-23 02:32:43 +0000291 if (NumArgs > 0) {
292 Args = new (C) Stmt*[NumArgs];
293 for (unsigned i = 0; i < NumArgs; ++i)
294 Args[i] = args[i];
295 }
296}
297
298void CXXConstructExpr::Destroy(ASTContext &C) {
299 DestroyChildren(C);
300 if (Args)
301 C.Deallocate(Args);
302 this->~CXXConstructExpr();
303 C.Deallocate(this);
304}
305
Anders Carlsson2d44e8a2009-05-01 22:18:43 +0000306CXXExprWithTemporaries::CXXExprWithTemporaries(Expr *subexpr,
Anders Carlssonff6b3d62009-05-30 21:05:25 +0000307 CXXTemporary **temps,
Anders Carlsson99ba36d2009-06-05 15:38:08 +0000308 unsigned numtemps,
Anders Carlssonf54741e2009-06-16 03:37:31 +0000309 bool shoulddestroytemps)
Anders Carlsson2d44e8a2009-05-01 22:18:43 +0000310: Expr(CXXExprWithTemporariesClass, subexpr->getType(),
Anders Carlsson02bbfa32009-04-24 22:47:04 +0000311 subexpr->isTypeDependent(), subexpr->isValueDependent()),
Anders Carlssonf54741e2009-06-16 03:37:31 +0000312 SubExpr(subexpr), Temps(0), NumTemps(numtemps),
313 ShouldDestroyTemps(shoulddestroytemps) {
Anders Carlssonff6b3d62009-05-30 21:05:25 +0000314 if (NumTemps > 0) {
315 Temps = new CXXTemporary*[NumTemps];
316 for (unsigned i = 0; i < NumTemps; ++i)
317 Temps[i] = temps[i];
Anders Carlsson02bbfa32009-04-24 22:47:04 +0000318 }
319}
320
Anders Carlsson88eaf072009-05-30 22:38:53 +0000321CXXExprWithTemporaries *CXXExprWithTemporaries::Create(ASTContext &C,
322 Expr *SubExpr,
323 CXXTemporary **Temps,
Anders Carlsson99ba36d2009-06-05 15:38:08 +0000324 unsigned NumTemps,
Anders Carlssonf54741e2009-06-16 03:37:31 +0000325 bool ShouldDestroyTemps){
Anders Carlsson99ba36d2009-06-05 15:38:08 +0000326 return new (C) CXXExprWithTemporaries(SubExpr, Temps, NumTemps,
Anders Carlssonf54741e2009-06-16 03:37:31 +0000327 ShouldDestroyTemps);
Anders Carlsson88eaf072009-05-30 22:38:53 +0000328}
329
330void CXXExprWithTemporaries::Destroy(ASTContext &C) {
331 DestroyChildren(C);
332 this->~CXXExprWithTemporaries();
333 C.Deallocate(this);
334}
335
Anders Carlsson2d44e8a2009-05-01 22:18:43 +0000336CXXExprWithTemporaries::~CXXExprWithTemporaries() {
Anders Carlssonff6b3d62009-05-30 21:05:25 +0000337 delete[] Temps;
Anders Carlsson02bbfa32009-04-24 22:47:04 +0000338}
339
Anders Carlssonfceb0a82009-05-30 20:03:25 +0000340// CXXBindTemporaryExpr
341Stmt::child_iterator CXXBindTemporaryExpr::child_begin() {
342 return &SubExpr;
343}
344
345Stmt::child_iterator CXXBindTemporaryExpr::child_end() {
346 return &SubExpr + 1;
347}
348
Anders Carlssone349bea2009-04-23 02:32:43 +0000349// CXXConstructExpr
350Stmt::child_iterator CXXConstructExpr::child_begin() {
351 return &Args[0];
352}
353Stmt::child_iterator CXXConstructExpr::child_end() {
354 return &Args[0]+NumArgs;
355}
356
Anders Carlsson55674ac2009-05-01 22:21:22 +0000357// CXXExprWithTemporaries
358Stmt::child_iterator CXXExprWithTemporaries::child_begin() {
359 return &SubExpr;
Anders Carlsson19d28a62009-04-21 02:22:11 +0000360}
Anders Carlsson02bbfa32009-04-24 22:47:04 +0000361
Anders Carlsson55674ac2009-05-01 22:21:22 +0000362Stmt::child_iterator CXXExprWithTemporaries::child_end() {
363 return &SubExpr + 1;
364}
Anders Carlsson02bbfa32009-04-24 22:47:04 +0000365
Douglas Gregord81e6ca2009-05-20 18:46:25 +0000366CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(
367 SourceLocation TyBeginLoc,
368 QualType T,
369 SourceLocation LParenLoc,
370 Expr **Args,
371 unsigned NumArgs,
372 SourceLocation RParenLoc)
373 : Expr(CXXUnresolvedConstructExprClass, T.getNonReferenceType(),
374 T->isDependentType(), true),
375 TyBeginLoc(TyBeginLoc),
376 Type(T),
377 LParenLoc(LParenLoc),
378 RParenLoc(RParenLoc),
379 NumArgs(NumArgs) {
380 Stmt **StoredArgs = reinterpret_cast<Stmt **>(this + 1);
381 memcpy(StoredArgs, Args, sizeof(Expr *) * NumArgs);
382}
383
384CXXUnresolvedConstructExpr *
385CXXUnresolvedConstructExpr::Create(ASTContext &C,
386 SourceLocation TyBegin,
387 QualType T,
388 SourceLocation LParenLoc,
389 Expr **Args,
390 unsigned NumArgs,
391 SourceLocation RParenLoc) {
392 void *Mem = C.Allocate(sizeof(CXXUnresolvedConstructExpr) +
393 sizeof(Expr *) * NumArgs);
394 return new (Mem) CXXUnresolvedConstructExpr(TyBegin, T, LParenLoc,
395 Args, NumArgs, RParenLoc);
396}
397
398Stmt::child_iterator CXXUnresolvedConstructExpr::child_begin() {
399 return child_iterator(reinterpret_cast<Stmt **>(this + 1));
400}
401
402Stmt::child_iterator CXXUnresolvedConstructExpr::child_end() {
403 return child_iterator(reinterpret_cast<Stmt **>(this + 1) + NumArgs);
404}
Sebastian Redl8b0b4752009-05-16 18:50:46 +0000405
Douglas Gregor1c0ca592009-05-22 21:13:27 +0000406Stmt::child_iterator CXXUnresolvedMemberExpr::child_begin() {
407 return child_iterator(&Base);
408}
409
410Stmt::child_iterator CXXUnresolvedMemberExpr::child_end() {
411 return child_iterator(&Base + 1);
412}
413
Sebastian Redl8b0b4752009-05-16 18:50:46 +0000414//===----------------------------------------------------------------------===//
415// Cloners
416//===----------------------------------------------------------------------===//
417
418CXXBoolLiteralExpr* CXXBoolLiteralExpr::Clone(ASTContext &C) const {
419 return new (C) CXXBoolLiteralExpr(Value, getType(), Loc);
420}
421
422CXXNullPtrLiteralExpr* CXXNullPtrLiteralExpr::Clone(ASTContext &C) const {
423 return new (C) CXXNullPtrLiteralExpr(getType(), Loc);
424}
Douglas Gregord94546a2009-05-20 21:38:11 +0000425
426CXXZeroInitValueExpr* CXXZeroInitValueExpr::Clone(ASTContext &C) const {
427 return new (C) CXXZeroInitValueExpr(getType(), TyBeginLoc, RParenLoc);
428}