Ted Kremenek | a758d09 | 2007-08-24 20:21:10 +0000 | [diff] [blame] | 1 | //===--- ExprCXX.cpp - (C++) Expression AST Node Implementation -----------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 0bc735f | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Ted Kremenek | a758d09 | 2007-08-24 20:21:10 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the subclesses of Expr class declared in ExprCXX.h |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Douglas Gregor | b460980 | 2008-11-14 16:09:21 +0000 | [diff] [blame] | 14 | #include "clang/Basic/IdentifierTable.h" |
| 15 | #include "clang/AST/DeclCXX.h" |
Douglas Gregor | edce4dd | 2009-06-30 22:34:41 +0000 | [diff] [blame] | 16 | #include "clang/AST/DeclTemplate.h" |
Ted Kremenek | a758d09 | 2007-08-24 20:21:10 +0000 | [diff] [blame] | 17 | #include "clang/AST/ExprCXX.h" |
Douglas Gregor | 26d4ac9 | 2010-02-24 23:40:28 +0000 | [diff] [blame] | 18 | #include "clang/AST/TypeLoc.h" |
Ted Kremenek | a758d09 | 2007-08-24 20:21:10 +0000 | [diff] [blame] | 19 | using namespace clang; |
| 20 | |
Douglas Gregor | 57fdc8a | 2010-04-26 22:37:10 +0000 | [diff] [blame] | 21 | |
Ted Kremenek | a758d09 | 2007-08-24 20:21:10 +0000 | [diff] [blame] | 22 | //===----------------------------------------------------------------------===// |
| 23 | // Child Iterators for iterating over subexpressions/substatements |
| 24 | //===----------------------------------------------------------------------===// |
| 25 | |
Douglas Gregor | 57fdc8a | 2010-04-26 22:37:10 +0000 | [diff] [blame] | 26 | QualType CXXTypeidExpr::getTypeOperand() const { |
| 27 | assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); |
| 28 | return Operand.get<TypeSourceInfo *>()->getType().getNonReferenceType() |
| 29 | .getUnqualifiedType(); |
| 30 | } |
| 31 | |
Francois Pichet | 01b7c30 | 2010-09-08 12:20:18 +0000 | [diff] [blame] | 32 | QualType CXXUuidofExpr::getTypeOperand() const { |
| 33 | assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)"); |
| 34 | return Operand.get<TypeSourceInfo *>()->getType().getNonReferenceType() |
| 35 | .getUnqualifiedType(); |
| 36 | } |
| 37 | |
Douglas Gregor | ed8abf1 | 2010-07-08 06:14:04 +0000 | [diff] [blame] | 38 | // CXXScalarValueInitExpr |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 39 | SourceRange CXXScalarValueInitExpr::getSourceRange() const { |
| 40 | SourceLocation Start = RParenLoc; |
| 41 | if (TypeInfo) |
| 42 | Start = TypeInfo->getTypeLoc().getBeginLoc(); |
| 43 | return SourceRange(Start, RParenLoc); |
| 44 | } |
| 45 | |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 46 | // CXXNewExpr |
Ted Kremenek | ad7fe86 | 2010-02-11 22:51:03 +0000 | [diff] [blame] | 47 | CXXNewExpr::CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew, |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 48 | Expr **placementArgs, unsigned numPlaceArgs, |
Douglas Gregor | 4bd4031 | 2010-07-13 15:54:32 +0000 | [diff] [blame] | 49 | SourceRange TypeIdParens, Expr *arraySize, |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 50 | CXXConstructorDecl *constructor, bool initializer, |
| 51 | Expr **constructorArgs, unsigned numConsArgs, |
John McCall | 6ec278d | 2011-01-27 09:37:56 +0000 | [diff] [blame] | 52 | FunctionDecl *operatorDelete, |
| 53 | bool usualArrayDeleteWantsSize, QualType ty, |
Douglas Gregor | 1bb2a93 | 2010-09-07 21:49:58 +0000 | [diff] [blame] | 54 | TypeSourceInfo *AllocatedTypeInfo, |
Chandler Carruth | 428edaf | 2010-10-25 08:47:36 +0000 | [diff] [blame] | 55 | SourceLocation startLoc, SourceLocation endLoc, |
| 56 | SourceLocation constructorLParen, |
| 57 | SourceLocation constructorRParen) |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 58 | : Expr(CXXNewExprClass, ty, VK_RValue, OK_Ordinary, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 59 | ty->isDependentType(), ty->isDependentType(), |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 60 | ty->isInstantiationDependentType(), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 61 | ty->containsUnexpandedParameterPack()), |
John McCall | 6ec278d | 2011-01-27 09:37:56 +0000 | [diff] [blame] | 62 | GlobalNew(globalNew), Initializer(initializer), |
| 63 | UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize), |
| 64 | SubExprs(0), OperatorNew(operatorNew), |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 65 | OperatorDelete(operatorDelete), Constructor(constructor), |
Douglas Gregor | 1bb2a93 | 2010-09-07 21:49:58 +0000 | [diff] [blame] | 66 | AllocatedTypeInfo(AllocatedTypeInfo), TypeIdParens(TypeIdParens), |
Chandler Carruth | 428edaf | 2010-10-25 08:47:36 +0000 | [diff] [blame] | 67 | StartLoc(startLoc), EndLoc(endLoc), ConstructorLParen(constructorLParen), |
| 68 | ConstructorRParen(constructorRParen) { |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 69 | AllocateArgsArray(C, arraySize != 0, numPlaceArgs, numConsArgs); |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 70 | unsigned i = 0; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 71 | if (Array) { |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 72 | if (arraySize->isInstantiationDependent()) |
| 73 | ExprBits.InstantiationDependent = true; |
| 74 | |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 75 | if (arraySize->containsUnexpandedParameterPack()) |
| 76 | ExprBits.ContainsUnexpandedParameterPack = true; |
| 77 | |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 78 | SubExprs[i++] = arraySize; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | for (unsigned j = 0; j < NumPlacementArgs; ++j) { |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 82 | if (placementArgs[j]->isInstantiationDependent()) |
| 83 | ExprBits.InstantiationDependent = true; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 84 | if (placementArgs[j]->containsUnexpandedParameterPack()) |
| 85 | ExprBits.ContainsUnexpandedParameterPack = true; |
| 86 | |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 87 | SubExprs[i++] = placementArgs[j]; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | for (unsigned j = 0; j < NumConstructorArgs; ++j) { |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 91 | if (constructorArgs[j]->isInstantiationDependent()) |
| 92 | ExprBits.InstantiationDependent = true; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 93 | if (constructorArgs[j]->containsUnexpandedParameterPack()) |
| 94 | ExprBits.ContainsUnexpandedParameterPack = true; |
| 95 | |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 96 | SubExprs[i++] = constructorArgs[j]; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 97 | } |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 98 | } |
| 99 | |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 100 | void CXXNewExpr::AllocateArgsArray(ASTContext &C, bool isArray, |
| 101 | unsigned numPlaceArgs, unsigned numConsArgs){ |
| 102 | assert(SubExprs == 0 && "SubExprs already allocated"); |
| 103 | Array = isArray; |
| 104 | NumPlacementArgs = numPlaceArgs; |
| 105 | NumConstructorArgs = numConsArgs; |
| 106 | |
| 107 | unsigned TotalSize = Array + NumPlacementArgs + NumConstructorArgs; |
| 108 | SubExprs = new (C) Stmt*[TotalSize]; |
| 109 | } |
| 110 | |
Sebastian Redl | 8026f6d | 2011-03-13 17:09:40 +0000 | [diff] [blame] | 111 | bool CXXNewExpr::shouldNullCheckAllocation(ASTContext &Ctx) const { |
John McCall | c2f3e7f | 2011-03-07 03:12:35 +0000 | [diff] [blame] | 112 | return getOperatorNew()->getType()-> |
Sebastian Redl | 8026f6d | 2011-03-13 17:09:40 +0000 | [diff] [blame] | 113 | castAs<FunctionProtoType>()->isNothrow(Ctx); |
John McCall | c2f3e7f | 2011-03-07 03:12:35 +0000 | [diff] [blame] | 114 | } |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 115 | |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 116 | // CXXDeleteExpr |
Douglas Gregor | 5833b0b | 2010-09-14 22:55:20 +0000 | [diff] [blame] | 117 | QualType CXXDeleteExpr::getDestroyedType() const { |
| 118 | const Expr *Arg = getArgument(); |
| 119 | while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Arg)) { |
| 120 | if (ICE->getCastKind() != CK_UserDefinedConversion && |
| 121 | ICE->getType()->isVoidPointerType()) |
| 122 | Arg = ICE->getSubExpr(); |
| 123 | else |
| 124 | break; |
| 125 | } |
Craig Silverstein | 0fa0b78 | 2010-10-20 00:38:15 +0000 | [diff] [blame] | 126 | // The type-to-delete may not be a pointer if it's a dependent type. |
Craig Silverstein | c87fa06 | 2010-10-20 00:56:01 +0000 | [diff] [blame] | 127 | const QualType ArgType = Arg->getType(); |
Craig Silverstein | a437ad3 | 2010-11-16 07:16:25 +0000 | [diff] [blame] | 128 | |
| 129 | if (ArgType->isDependentType() && !ArgType->isPointerType()) |
| 130 | return QualType(); |
Douglas Gregor | 5833b0b | 2010-09-14 22:55:20 +0000 | [diff] [blame] | 131 | |
Craig Silverstein | 0fa0b78 | 2010-10-20 00:38:15 +0000 | [diff] [blame] | 132 | return ArgType->getAs<PointerType>()->getPointeeType(); |
Douglas Gregor | 5833b0b | 2010-09-14 22:55:20 +0000 | [diff] [blame] | 133 | } |
| 134 | |
Douglas Gregor | a71d819 | 2009-09-04 17:36:40 +0000 | [diff] [blame] | 135 | // CXXPseudoDestructorExpr |
Douglas Gregor | a2e7dd2 | 2010-02-25 01:56:36 +0000 | [diff] [blame] | 136 | PseudoDestructorTypeStorage::PseudoDestructorTypeStorage(TypeSourceInfo *Info) |
| 137 | : Type(Info) |
| 138 | { |
Abramo Bagnara | bd054db | 2010-05-20 10:00:11 +0000 | [diff] [blame] | 139 | Location = Info->getTypeLoc().getLocalSourceRange().getBegin(); |
Douglas Gregor | a2e7dd2 | 2010-02-25 01:56:36 +0000 | [diff] [blame] | 140 | } |
| 141 | |
John McCall | e23cf43 | 2010-12-14 08:05:40 +0000 | [diff] [blame] | 142 | CXXPseudoDestructorExpr::CXXPseudoDestructorExpr(ASTContext &Context, |
Douglas Gregor | f3db29f | 2011-02-25 18:19:59 +0000 | [diff] [blame] | 143 | Expr *Base, bool isArrow, SourceLocation OperatorLoc, |
| 144 | NestedNameSpecifierLoc QualifierLoc, TypeSourceInfo *ScopeType, |
| 145 | SourceLocation ColonColonLoc, SourceLocation TildeLoc, |
| 146 | PseudoDestructorTypeStorage DestroyedType) |
John McCall | e23cf43 | 2010-12-14 08:05:40 +0000 | [diff] [blame] | 147 | : Expr(CXXPseudoDestructorExprClass, |
| 148 | Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0, |
| 149 | FunctionProtoType::ExtProtoInfo())), |
| 150 | VK_RValue, OK_Ordinary, |
| 151 | /*isTypeDependent=*/(Base->isTypeDependent() || |
| 152 | (DestroyedType.getTypeSourceInfo() && |
| 153 | DestroyedType.getTypeSourceInfo()->getType()->isDependentType())), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 154 | /*isValueDependent=*/Base->isValueDependent(), |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 155 | (Base->isInstantiationDependent() || |
| 156 | (QualifierLoc && |
| 157 | QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent()) || |
| 158 | (ScopeType && |
| 159 | ScopeType->getType()->isInstantiationDependentType()) || |
| 160 | (DestroyedType.getTypeSourceInfo() && |
| 161 | DestroyedType.getTypeSourceInfo()->getType() |
| 162 | ->isInstantiationDependentType())), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 163 | // ContainsUnexpandedParameterPack |
| 164 | (Base->containsUnexpandedParameterPack() || |
Douglas Gregor | f3db29f | 2011-02-25 18:19:59 +0000 | [diff] [blame] | 165 | (QualifierLoc && |
| 166 | QualifierLoc.getNestedNameSpecifier() |
| 167 | ->containsUnexpandedParameterPack()) || |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 168 | (ScopeType && |
| 169 | ScopeType->getType()->containsUnexpandedParameterPack()) || |
| 170 | (DestroyedType.getTypeSourceInfo() && |
| 171 | DestroyedType.getTypeSourceInfo()->getType() |
| 172 | ->containsUnexpandedParameterPack()))), |
John McCall | e23cf43 | 2010-12-14 08:05:40 +0000 | [diff] [blame] | 173 | Base(static_cast<Stmt *>(Base)), IsArrow(isArrow), |
Douglas Gregor | f3db29f | 2011-02-25 18:19:59 +0000 | [diff] [blame] | 174 | OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc), |
John McCall | e23cf43 | 2010-12-14 08:05:40 +0000 | [diff] [blame] | 175 | ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc), |
| 176 | DestroyedType(DestroyedType) { } |
| 177 | |
Douglas Gregor | a2e7dd2 | 2010-02-25 01:56:36 +0000 | [diff] [blame] | 178 | QualType CXXPseudoDestructorExpr::getDestroyedType() const { |
| 179 | if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo()) |
| 180 | return TInfo->getType(); |
| 181 | |
| 182 | return QualType(); |
| 183 | } |
| 184 | |
Douglas Gregor | 26d4ac9 | 2010-02-24 23:40:28 +0000 | [diff] [blame] | 185 | SourceRange CXXPseudoDestructorExpr::getSourceRange() const { |
Douglas Gregor | a2e7dd2 | 2010-02-25 01:56:36 +0000 | [diff] [blame] | 186 | SourceLocation End = DestroyedType.getLocation(); |
| 187 | if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo()) |
Abramo Bagnara | bd054db | 2010-05-20 10:00:11 +0000 | [diff] [blame] | 188 | End = TInfo->getTypeLoc().getLocalSourceRange().getEnd(); |
Douglas Gregor | a2e7dd2 | 2010-02-25 01:56:36 +0000 | [diff] [blame] | 189 | return SourceRange(Base->getLocStart(), End); |
Douglas Gregor | 26d4ac9 | 2010-02-24 23:40:28 +0000 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | |
John McCall | ba13543 | 2009-11-21 08:51:07 +0000 | [diff] [blame] | 193 | // UnresolvedLookupExpr |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 194 | UnresolvedLookupExpr * |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 195 | UnresolvedLookupExpr::Create(ASTContext &C, |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 196 | CXXRecordDecl *NamingClass, |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 197 | NestedNameSpecifierLoc QualifierLoc, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 198 | const DeclarationNameInfo &NameInfo, |
| 199 | bool ADL, |
Douglas Gregor | 5a84dec | 2010-05-23 18:57:34 +0000 | [diff] [blame] | 200 | const TemplateArgumentListInfo &Args, |
| 201 | UnresolvedSetIterator Begin, |
| 202 | UnresolvedSetIterator End) |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 203 | { |
| 204 | void *Mem = C.Allocate(sizeof(UnresolvedLookupExpr) + |
| 205 | ExplicitTemplateArgumentList::sizeFor(Args)); |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 206 | return new (Mem) UnresolvedLookupExpr(C, NamingClass, QualifierLoc, NameInfo, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 207 | ADL, /*Overload*/ true, &Args, |
Richard Smith | ad762fc | 2011-04-14 22:09:26 +0000 | [diff] [blame] | 208 | Begin, End, /*StdIsAssociated=*/false); |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 209 | } |
| 210 | |
Argyrios Kyrtzidis | bd65bb5 | 2010-06-25 09:03:34 +0000 | [diff] [blame] | 211 | UnresolvedLookupExpr * |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 212 | UnresolvedLookupExpr::CreateEmpty(ASTContext &C, bool HasExplicitTemplateArgs, |
| 213 | unsigned NumTemplateArgs) { |
Argyrios Kyrtzidis | bd65bb5 | 2010-06-25 09:03:34 +0000 | [diff] [blame] | 214 | std::size_t size = sizeof(UnresolvedLookupExpr); |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 215 | if (HasExplicitTemplateArgs) |
Argyrios Kyrtzidis | bd65bb5 | 2010-06-25 09:03:34 +0000 | [diff] [blame] | 216 | size += ExplicitTemplateArgumentList::sizeFor(NumTemplateArgs); |
| 217 | |
Chris Lattner | 3248854 | 2010-10-30 05:14:06 +0000 | [diff] [blame] | 218 | void *Mem = C.Allocate(size, llvm::alignOf<UnresolvedLookupExpr>()); |
Argyrios Kyrtzidis | bd65bb5 | 2010-06-25 09:03:34 +0000 | [diff] [blame] | 219 | UnresolvedLookupExpr *E = new (Mem) UnresolvedLookupExpr(EmptyShell()); |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 220 | E->HasExplicitTemplateArgs = HasExplicitTemplateArgs; |
Argyrios Kyrtzidis | bd65bb5 | 2010-06-25 09:03:34 +0000 | [diff] [blame] | 221 | return E; |
| 222 | } |
| 223 | |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 224 | OverloadExpr::OverloadExpr(StmtClass K, ASTContext &C, |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 225 | NestedNameSpecifierLoc QualifierLoc, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 226 | const DeclarationNameInfo &NameInfo, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 227 | const TemplateArgumentListInfo *TemplateArgs, |
Douglas Gregor | 928e6fc | 2010-05-23 19:36:40 +0000 | [diff] [blame] | 228 | UnresolvedSetIterator Begin, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 229 | UnresolvedSetIterator End, |
| 230 | bool KnownDependent, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 231 | bool KnownInstantiationDependent, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 232 | bool KnownContainsUnexpandedParameterPack) |
| 233 | : Expr(K, C.OverloadTy, VK_LValue, OK_Ordinary, KnownDependent, |
| 234 | KnownDependent, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 235 | (KnownInstantiationDependent || |
| 236 | NameInfo.isInstantiationDependent() || |
| 237 | (QualifierLoc && |
| 238 | QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 239 | (KnownContainsUnexpandedParameterPack || |
| 240 | NameInfo.containsUnexpandedParameterPack() || |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 241 | (QualifierLoc && |
| 242 | QualifierLoc.getNestedNameSpecifier() |
| 243 | ->containsUnexpandedParameterPack()))), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 244 | Results(0), NumResults(End - Begin), NameInfo(NameInfo), |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 245 | QualifierLoc(QualifierLoc), HasExplicitTemplateArgs(TemplateArgs != 0) |
Douglas Gregor | 928e6fc | 2010-05-23 19:36:40 +0000 | [diff] [blame] | 246 | { |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 247 | NumResults = End - Begin; |
| 248 | if (NumResults) { |
| 249 | // Determine whether this expression is type-dependent. |
| 250 | for (UnresolvedSetImpl::const_iterator I = Begin; I != End; ++I) { |
| 251 | if ((*I)->getDeclContext()->isDependentContext() || |
| 252 | isa<UnresolvedUsingValueDecl>(*I)) { |
| 253 | ExprBits.TypeDependent = true; |
| 254 | ExprBits.ValueDependent = true; |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | Results = static_cast<DeclAccessPair *>( |
| 259 | C.Allocate(sizeof(DeclAccessPair) * NumResults, |
| 260 | llvm::alignOf<DeclAccessPair>())); |
| 261 | memcpy(Results, &*Begin.getIterator(), |
| 262 | NumResults * sizeof(DeclAccessPair)); |
| 263 | } |
| 264 | |
| 265 | // If we have explicit template arguments, check for dependent |
| 266 | // template arguments and whether they contain any unexpanded pack |
| 267 | // expansions. |
| 268 | if (TemplateArgs) { |
| 269 | bool Dependent = false; |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 270 | bool InstantiationDependent = false; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 271 | bool ContainsUnexpandedParameterPack = false; |
| 272 | getExplicitTemplateArgs().initializeFrom(*TemplateArgs, Dependent, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 273 | InstantiationDependent, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 274 | ContainsUnexpandedParameterPack); |
| 275 | |
| 276 | if (Dependent) { |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 277 | ExprBits.TypeDependent = true; |
| 278 | ExprBits.ValueDependent = true; |
| 279 | } |
| 280 | if (InstantiationDependent) |
| 281 | ExprBits.InstantiationDependent = true; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 282 | if (ContainsUnexpandedParameterPack) |
| 283 | ExprBits.ContainsUnexpandedParameterPack = true; |
| 284 | } |
| 285 | |
| 286 | if (isTypeDependent()) |
| 287 | setType(C.DependentTy); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | void OverloadExpr::initializeResults(ASTContext &C, |
| 291 | UnresolvedSetIterator Begin, |
| 292 | UnresolvedSetIterator End) { |
| 293 | assert(Results == 0 && "Results already initialized!"); |
| 294 | NumResults = End - Begin; |
Douglas Gregor | 928e6fc | 2010-05-23 19:36:40 +0000 | [diff] [blame] | 295 | if (NumResults) { |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 296 | Results = static_cast<DeclAccessPair *>( |
| 297 | C.Allocate(sizeof(DeclAccessPair) * NumResults, |
| 298 | |
| 299 | llvm::alignOf<DeclAccessPair>())); |
| 300 | memcpy(Results, &*Begin.getIterator(), |
| 301 | NumResults * sizeof(DeclAccessPair)); |
Douglas Gregor | 928e6fc | 2010-05-23 19:36:40 +0000 | [diff] [blame] | 302 | } |
| 303 | } |
| 304 | |
John McCall | e9ee23e | 2010-04-22 18:44:12 +0000 | [diff] [blame] | 305 | CXXRecordDecl *OverloadExpr::getNamingClass() const { |
| 306 | if (isa<UnresolvedLookupExpr>(this)) |
| 307 | return cast<UnresolvedLookupExpr>(this)->getNamingClass(); |
| 308 | else |
| 309 | return cast<UnresolvedMemberExpr>(this)->getNamingClass(); |
| 310 | } |
| 311 | |
John McCall | 865d447 | 2009-11-19 22:55:06 +0000 | [diff] [blame] | 312 | // DependentScopeDeclRefExpr |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 313 | DependentScopeDeclRefExpr::DependentScopeDeclRefExpr(QualType T, |
Douglas Gregor | 00cf3cc | 2011-02-25 20:49:16 +0000 | [diff] [blame] | 314 | NestedNameSpecifierLoc QualifierLoc, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 315 | const DeclarationNameInfo &NameInfo, |
| 316 | const TemplateArgumentListInfo *Args) |
| 317 | : Expr(DependentScopeDeclRefExprClass, T, VK_LValue, OK_Ordinary, |
| 318 | true, true, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 319 | (NameInfo.isInstantiationDependent() || |
| 320 | (QualifierLoc && |
| 321 | QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 322 | (NameInfo.containsUnexpandedParameterPack() || |
Douglas Gregor | 00cf3cc | 2011-02-25 20:49:16 +0000 | [diff] [blame] | 323 | (QualifierLoc && |
| 324 | QualifierLoc.getNestedNameSpecifier() |
| 325 | ->containsUnexpandedParameterPack()))), |
| 326 | QualifierLoc(QualifierLoc), NameInfo(NameInfo), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 327 | HasExplicitTemplateArgs(Args != 0) |
| 328 | { |
| 329 | if (Args) { |
| 330 | bool Dependent = true; |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 331 | bool InstantiationDependent = true; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 332 | bool ContainsUnexpandedParameterPack |
| 333 | = ExprBits.ContainsUnexpandedParameterPack; |
| 334 | |
| 335 | reinterpret_cast<ExplicitTemplateArgumentList*>(this+1) |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 336 | ->initializeFrom(*Args, Dependent, InstantiationDependent, |
| 337 | ContainsUnexpandedParameterPack); |
| 338 | |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 339 | ExprBits.ContainsUnexpandedParameterPack = ContainsUnexpandedParameterPack; |
| 340 | } |
| 341 | } |
| 342 | |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 343 | DependentScopeDeclRefExpr * |
| 344 | DependentScopeDeclRefExpr::Create(ASTContext &C, |
Douglas Gregor | 00cf3cc | 2011-02-25 20:49:16 +0000 | [diff] [blame] | 345 | NestedNameSpecifierLoc QualifierLoc, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 346 | const DeclarationNameInfo &NameInfo, |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 347 | const TemplateArgumentListInfo *Args) { |
| 348 | std::size_t size = sizeof(DependentScopeDeclRefExpr); |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 349 | if (Args) |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 350 | size += ExplicitTemplateArgumentList::sizeFor(*Args); |
| 351 | void *Mem = C.Allocate(size); |
Douglas Gregor | 00cf3cc | 2011-02-25 20:49:16 +0000 | [diff] [blame] | 352 | return new (Mem) DependentScopeDeclRefExpr(C.DependentTy, QualifierLoc, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 353 | NameInfo, Args); |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 354 | } |
| 355 | |
Argyrios Kyrtzidis | 12dffcd | 2010-06-28 09:31:56 +0000 | [diff] [blame] | 356 | DependentScopeDeclRefExpr * |
| 357 | DependentScopeDeclRefExpr::CreateEmpty(ASTContext &C, |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 358 | bool HasExplicitTemplateArgs, |
Argyrios Kyrtzidis | 12dffcd | 2010-06-28 09:31:56 +0000 | [diff] [blame] | 359 | unsigned NumTemplateArgs) { |
| 360 | std::size_t size = sizeof(DependentScopeDeclRefExpr); |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 361 | if (HasExplicitTemplateArgs) |
Argyrios Kyrtzidis | 12dffcd | 2010-06-28 09:31:56 +0000 | [diff] [blame] | 362 | size += ExplicitTemplateArgumentList::sizeFor(NumTemplateArgs); |
| 363 | void *Mem = C.Allocate(size); |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 364 | DependentScopeDeclRefExpr *E |
Douglas Gregor | 00cf3cc | 2011-02-25 20:49:16 +0000 | [diff] [blame] | 365 | = new (Mem) DependentScopeDeclRefExpr(QualType(), NestedNameSpecifierLoc(), |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 366 | DeclarationNameInfo(), 0); |
| 367 | E->HasExplicitTemplateArgs = HasExplicitTemplateArgs; |
| 368 | return E; |
Argyrios Kyrtzidis | 12dffcd | 2010-06-28 09:31:56 +0000 | [diff] [blame] | 369 | } |
| 370 | |
Chandler Carruth | 428edaf | 2010-10-25 08:47:36 +0000 | [diff] [blame] | 371 | SourceRange CXXConstructExpr::getSourceRange() const { |
John McCall | 2882eca | 2011-02-21 06:23:05 +0000 | [diff] [blame] | 372 | if (isa<CXXTemporaryObjectExpr>(this)) |
| 373 | return cast<CXXTemporaryObjectExpr>(this)->getSourceRange(); |
| 374 | |
Douglas Gregor | 40749ee | 2010-11-03 00:35:38 +0000 | [diff] [blame] | 375 | if (ParenRange.isValid()) |
| 376 | return SourceRange(Loc, ParenRange.getEnd()); |
| 377 | |
| 378 | SourceLocation End = Loc; |
| 379 | for (unsigned I = getNumArgs(); I > 0; --I) { |
| 380 | const Expr *Arg = getArg(I-1); |
| 381 | if (!Arg->isDefaultArgument()) { |
| 382 | SourceLocation NewEnd = Arg->getLocEnd(); |
| 383 | if (NewEnd.isValid()) { |
| 384 | End = NewEnd; |
| 385 | break; |
| 386 | } |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | return SourceRange(Loc, End); |
Ted Kremenek | e383768 | 2009-12-23 04:00:48 +0000 | [diff] [blame] | 391 | } |
| 392 | |
Douglas Gregor | b460980 | 2008-11-14 16:09:21 +0000 | [diff] [blame] | 393 | SourceRange CXXOperatorCallExpr::getSourceRange() const { |
| 394 | OverloadedOperatorKind Kind = getOperator(); |
| 395 | if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) { |
| 396 | if (getNumArgs() == 1) |
| 397 | // Prefix operator |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 398 | return SourceRange(getOperatorLoc(), |
Douglas Gregor | b460980 | 2008-11-14 16:09:21 +0000 | [diff] [blame] | 399 | getArg(0)->getSourceRange().getEnd()); |
| 400 | else |
| 401 | // Postfix operator |
Chandler Carruth | d765061 | 2011-04-02 09:47:38 +0000 | [diff] [blame] | 402 | return SourceRange(getArg(0)->getSourceRange().getBegin(), |
Douglas Gregor | b460980 | 2008-11-14 16:09:21 +0000 | [diff] [blame] | 403 | getOperatorLoc()); |
Chandler Carruth | d765061 | 2011-04-02 09:47:38 +0000 | [diff] [blame] | 404 | } else if (Kind == OO_Arrow) { |
| 405 | return getArg(0)->getSourceRange(); |
Douglas Gregor | b460980 | 2008-11-14 16:09:21 +0000 | [diff] [blame] | 406 | } else if (Kind == OO_Call) { |
| 407 | return SourceRange(getArg(0)->getSourceRange().getBegin(), getRParenLoc()); |
| 408 | } else if (Kind == OO_Subscript) { |
| 409 | return SourceRange(getArg(0)->getSourceRange().getBegin(), getRParenLoc()); |
| 410 | } else if (getNumArgs() == 1) { |
| 411 | return SourceRange(getOperatorLoc(), getArg(0)->getSourceRange().getEnd()); |
| 412 | } else if (getNumArgs() == 2) { |
| 413 | return SourceRange(getArg(0)->getSourceRange().getBegin(), |
| 414 | getArg(1)->getSourceRange().getEnd()); |
| 415 | } else { |
| 416 | return SourceRange(); |
| 417 | } |
| 418 | } |
| 419 | |
Ted Kremenek | b277159 | 2011-03-30 17:41:19 +0000 | [diff] [blame] | 420 | Expr *CXXMemberCallExpr::getImplicitObjectArgument() const { |
| 421 | if (const MemberExpr *MemExpr = |
| 422 | dyn_cast<MemberExpr>(getCallee()->IgnoreParens())) |
Douglas Gregor | 88a3514 | 2008-12-22 05:46:06 +0000 | [diff] [blame] | 423 | return MemExpr->getBase(); |
| 424 | |
| 425 | // FIXME: Will eventually need to cope with member pointers. |
| 426 | return 0; |
| 427 | } |
| 428 | |
Ted Kremenek | b277159 | 2011-03-30 17:41:19 +0000 | [diff] [blame] | 429 | CXXMethodDecl *CXXMemberCallExpr::getMethodDecl() const { |
| 430 | if (const MemberExpr *MemExpr = |
| 431 | dyn_cast<MemberExpr>(getCallee()->IgnoreParens())) |
| 432 | return cast<CXXMethodDecl>(MemExpr->getMemberDecl()); |
| 433 | |
| 434 | // FIXME: Will eventually need to cope with member pointers. |
| 435 | return 0; |
| 436 | } |
| 437 | |
| 438 | |
Chandler Carruth | 007a9b1 | 2010-10-27 06:55:41 +0000 | [diff] [blame] | 439 | CXXRecordDecl *CXXMemberCallExpr::getRecordDecl() { |
| 440 | Expr* ThisArg = getImplicitObjectArgument(); |
| 441 | if (!ThisArg) |
| 442 | return 0; |
| 443 | |
| 444 | if (ThisArg->getType()->isAnyPointerType()) |
| 445 | return ThisArg->getType()->getPointeeType()->getAsCXXRecordDecl(); |
| 446 | |
| 447 | return ThisArg->getType()->getAsCXXRecordDecl(); |
| 448 | } |
| 449 | |
Douglas Gregor | 00b98c2 | 2009-11-12 15:31:47 +0000 | [diff] [blame] | 450 | |
Douglas Gregor | 49badde | 2008-10-27 19:41:14 +0000 | [diff] [blame] | 451 | //===----------------------------------------------------------------------===// |
| 452 | // Named casts |
| 453 | //===----------------------------------------------------------------------===// |
| 454 | |
| 455 | /// getCastName - Get the name of the C++ cast being used, e.g., |
| 456 | /// "static_cast", "dynamic_cast", "reinterpret_cast", or |
| 457 | /// "const_cast". The returned pointer must not be freed. |
| 458 | const char *CXXNamedCastExpr::getCastName() const { |
| 459 | switch (getStmtClass()) { |
| 460 | case CXXStaticCastExprClass: return "static_cast"; |
| 461 | case CXXDynamicCastExprClass: return "dynamic_cast"; |
| 462 | case CXXReinterpretCastExprClass: return "reinterpret_cast"; |
| 463 | case CXXConstCastExprClass: return "const_cast"; |
| 464 | default: return "<invalid cast>"; |
| 465 | } |
| 466 | } |
Douglas Gregor | 506ae41 | 2009-01-16 18:33:17 +0000 | [diff] [blame] | 467 | |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 468 | CXXStaticCastExpr *CXXStaticCastExpr::Create(ASTContext &C, QualType T, |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 469 | ExprValueKind VK, |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 470 | CastKind K, Expr *Op, |
| 471 | const CXXCastPath *BasePath, |
| 472 | TypeSourceInfo *WrittenTy, |
Douglas Gregor | 1d5d0b9 | 2011-01-12 22:41:29 +0000 | [diff] [blame] | 473 | SourceLocation L, |
| 474 | SourceLocation RParenLoc) { |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 475 | unsigned PathSize = (BasePath ? BasePath->size() : 0); |
| 476 | void *Buffer = C.Allocate(sizeof(CXXStaticCastExpr) |
| 477 | + PathSize * sizeof(CXXBaseSpecifier*)); |
| 478 | CXXStaticCastExpr *E = |
Douglas Gregor | 1d5d0b9 | 2011-01-12 22:41:29 +0000 | [diff] [blame] | 479 | new (Buffer) CXXStaticCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, |
| 480 | RParenLoc); |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 481 | if (PathSize) E->setCastPath(*BasePath); |
| 482 | return E; |
| 483 | } |
| 484 | |
| 485 | CXXStaticCastExpr *CXXStaticCastExpr::CreateEmpty(ASTContext &C, |
| 486 | unsigned PathSize) { |
| 487 | void *Buffer = |
| 488 | C.Allocate(sizeof(CXXStaticCastExpr) + PathSize * sizeof(CXXBaseSpecifier*)); |
| 489 | return new (Buffer) CXXStaticCastExpr(EmptyShell(), PathSize); |
| 490 | } |
| 491 | |
| 492 | CXXDynamicCastExpr *CXXDynamicCastExpr::Create(ASTContext &C, QualType T, |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 493 | ExprValueKind VK, |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 494 | CastKind K, Expr *Op, |
| 495 | const CXXCastPath *BasePath, |
| 496 | TypeSourceInfo *WrittenTy, |
Douglas Gregor | 1d5d0b9 | 2011-01-12 22:41:29 +0000 | [diff] [blame] | 497 | SourceLocation L, |
| 498 | SourceLocation RParenLoc) { |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 499 | unsigned PathSize = (BasePath ? BasePath->size() : 0); |
| 500 | void *Buffer = C.Allocate(sizeof(CXXDynamicCastExpr) |
| 501 | + PathSize * sizeof(CXXBaseSpecifier*)); |
| 502 | CXXDynamicCastExpr *E = |
Douglas Gregor | 1d5d0b9 | 2011-01-12 22:41:29 +0000 | [diff] [blame] | 503 | new (Buffer) CXXDynamicCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, |
| 504 | RParenLoc); |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 505 | if (PathSize) E->setCastPath(*BasePath); |
| 506 | return E; |
| 507 | } |
| 508 | |
| 509 | CXXDynamicCastExpr *CXXDynamicCastExpr::CreateEmpty(ASTContext &C, |
| 510 | unsigned PathSize) { |
| 511 | void *Buffer = |
| 512 | C.Allocate(sizeof(CXXDynamicCastExpr) + PathSize * sizeof(CXXBaseSpecifier*)); |
| 513 | return new (Buffer) CXXDynamicCastExpr(EmptyShell(), PathSize); |
| 514 | } |
| 515 | |
Anders Carlsson | 0fee330 | 2011-04-11 01:43:55 +0000 | [diff] [blame] | 516 | /// isAlwaysNull - Return whether the result of the dynamic_cast is proven |
| 517 | /// to always be null. For example: |
| 518 | /// |
| 519 | /// struct A { }; |
| 520 | /// struct B final : A { }; |
| 521 | /// struct C { }; |
| 522 | /// |
| 523 | /// C *f(B* b) { return dynamic_cast<C*>(b); } |
| 524 | bool CXXDynamicCastExpr::isAlwaysNull() const |
| 525 | { |
| 526 | QualType SrcType = getSubExpr()->getType(); |
| 527 | QualType DestType = getType(); |
| 528 | |
| 529 | if (const PointerType *SrcPTy = SrcType->getAs<PointerType>()) { |
| 530 | SrcType = SrcPTy->getPointeeType(); |
| 531 | DestType = DestType->castAs<PointerType>()->getPointeeType(); |
| 532 | } |
| 533 | |
| 534 | const CXXRecordDecl *SrcRD = |
| 535 | cast<CXXRecordDecl>(SrcType->castAs<RecordType>()->getDecl()); |
| 536 | |
| 537 | if (!SrcRD->hasAttr<FinalAttr>()) |
| 538 | return false; |
| 539 | |
| 540 | const CXXRecordDecl *DestRD = |
| 541 | cast<CXXRecordDecl>(DestType->castAs<RecordType>()->getDecl()); |
| 542 | |
| 543 | return !DestRD->isDerivedFrom(SrcRD); |
| 544 | } |
| 545 | |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 546 | CXXReinterpretCastExpr * |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 547 | CXXReinterpretCastExpr::Create(ASTContext &C, QualType T, ExprValueKind VK, |
| 548 | CastKind K, Expr *Op, |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 549 | const CXXCastPath *BasePath, |
Douglas Gregor | 1d5d0b9 | 2011-01-12 22:41:29 +0000 | [diff] [blame] | 550 | TypeSourceInfo *WrittenTy, SourceLocation L, |
| 551 | SourceLocation RParenLoc) { |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 552 | unsigned PathSize = (BasePath ? BasePath->size() : 0); |
| 553 | void *Buffer = |
| 554 | C.Allocate(sizeof(CXXReinterpretCastExpr) + PathSize * sizeof(CXXBaseSpecifier*)); |
| 555 | CXXReinterpretCastExpr *E = |
Douglas Gregor | 1d5d0b9 | 2011-01-12 22:41:29 +0000 | [diff] [blame] | 556 | new (Buffer) CXXReinterpretCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, |
| 557 | RParenLoc); |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 558 | if (PathSize) E->setCastPath(*BasePath); |
| 559 | return E; |
| 560 | } |
| 561 | |
| 562 | CXXReinterpretCastExpr * |
| 563 | CXXReinterpretCastExpr::CreateEmpty(ASTContext &C, unsigned PathSize) { |
| 564 | void *Buffer = C.Allocate(sizeof(CXXReinterpretCastExpr) |
| 565 | + PathSize * sizeof(CXXBaseSpecifier*)); |
| 566 | return new (Buffer) CXXReinterpretCastExpr(EmptyShell(), PathSize); |
| 567 | } |
| 568 | |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 569 | CXXConstCastExpr *CXXConstCastExpr::Create(ASTContext &C, QualType T, |
| 570 | ExprValueKind VK, Expr *Op, |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 571 | TypeSourceInfo *WrittenTy, |
Douglas Gregor | 1d5d0b9 | 2011-01-12 22:41:29 +0000 | [diff] [blame] | 572 | SourceLocation L, |
| 573 | SourceLocation RParenLoc) { |
| 574 | return new (C) CXXConstCastExpr(T, VK, Op, WrittenTy, L, RParenLoc); |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | CXXConstCastExpr *CXXConstCastExpr::CreateEmpty(ASTContext &C) { |
| 578 | return new (C) CXXConstCastExpr(EmptyShell()); |
| 579 | } |
| 580 | |
| 581 | CXXFunctionalCastExpr * |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 582 | CXXFunctionalCastExpr::Create(ASTContext &C, QualType T, ExprValueKind VK, |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 583 | TypeSourceInfo *Written, SourceLocation L, |
| 584 | CastKind K, Expr *Op, const CXXCastPath *BasePath, |
| 585 | SourceLocation R) { |
| 586 | unsigned PathSize = (BasePath ? BasePath->size() : 0); |
| 587 | void *Buffer = C.Allocate(sizeof(CXXFunctionalCastExpr) |
| 588 | + PathSize * sizeof(CXXBaseSpecifier*)); |
| 589 | CXXFunctionalCastExpr *E = |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 590 | new (Buffer) CXXFunctionalCastExpr(T, VK, Written, L, K, Op, PathSize, R); |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 591 | if (PathSize) E->setCastPath(*BasePath); |
| 592 | return E; |
| 593 | } |
| 594 | |
| 595 | CXXFunctionalCastExpr * |
| 596 | CXXFunctionalCastExpr::CreateEmpty(ASTContext &C, unsigned PathSize) { |
| 597 | void *Buffer = C.Allocate(sizeof(CXXFunctionalCastExpr) |
| 598 | + PathSize * sizeof(CXXBaseSpecifier*)); |
| 599 | return new (Buffer) CXXFunctionalCastExpr(EmptyShell(), PathSize); |
| 600 | } |
| 601 | |
| 602 | |
Douglas Gregor | 65222e8 | 2009-12-23 18:19:08 +0000 | [diff] [blame] | 603 | CXXDefaultArgExpr * |
Douglas Gregor | 036aed1 | 2009-12-23 23:03:06 +0000 | [diff] [blame] | 604 | CXXDefaultArgExpr::Create(ASTContext &C, SourceLocation Loc, |
| 605 | ParmVarDecl *Param, Expr *SubExpr) { |
Douglas Gregor | 65222e8 | 2009-12-23 18:19:08 +0000 | [diff] [blame] | 606 | void *Mem = C.Allocate(sizeof(CXXDefaultArgExpr) + sizeof(Stmt *)); |
Douglas Gregor | 036aed1 | 2009-12-23 23:03:06 +0000 | [diff] [blame] | 607 | return new (Mem) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param, |
| 608 | SubExpr); |
Douglas Gregor | 65222e8 | 2009-12-23 18:19:08 +0000 | [diff] [blame] | 609 | } |
| 610 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 611 | CXXTemporary *CXXTemporary::Create(ASTContext &C, |
Anders Carlsson | b859f35 | 2009-05-30 20:34:37 +0000 | [diff] [blame] | 612 | const CXXDestructorDecl *Destructor) { |
Anders Carlsson | 88eaf07 | 2009-05-30 22:38:53 +0000 | [diff] [blame] | 613 | return new (C) CXXTemporary(Destructor); |
| 614 | } |
| 615 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 616 | CXXBindTemporaryExpr *CXXBindTemporaryExpr::Create(ASTContext &C, |
Anders Carlsson | fceb0a8 | 2009-05-30 20:03:25 +0000 | [diff] [blame] | 617 | CXXTemporary *Temp, |
| 618 | Expr* SubExpr) { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 619 | assert(SubExpr->getType()->isRecordType() && |
Anders Carlsson | fceb0a8 | 2009-05-30 20:03:25 +0000 | [diff] [blame] | 620 | "Expression bound to a temporary must have record type!"); |
| 621 | |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 622 | return new (C) CXXBindTemporaryExpr(Temp, SubExpr); |
Anders Carlsson | fceb0a8 | 2009-05-30 20:03:25 +0000 | [diff] [blame] | 623 | } |
| 624 | |
Anders Carlsson | 8e587a1 | 2009-05-30 20:56:46 +0000 | [diff] [blame] | 625 | CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(ASTContext &C, |
Anders Carlsson | 26de549 | 2009-04-24 05:23:13 +0000 | [diff] [blame] | 626 | CXXConstructorDecl *Cons, |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 627 | TypeSourceInfo *Type, |
Douglas Gregor | 506ae41 | 2009-01-16 18:33:17 +0000 | [diff] [blame] | 628 | Expr **Args, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 629 | unsigned NumArgs, |
Chandler Carruth | 428edaf | 2010-10-25 08:47:36 +0000 | [diff] [blame] | 630 | SourceRange parenRange, |
Douglas Gregor | 1c63b9c | 2010-04-27 20:36:09 +0000 | [diff] [blame] | 631 | bool ZeroInitialization) |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 632 | : CXXConstructExpr(C, CXXTemporaryObjectExprClass, |
| 633 | Type->getType().getNonReferenceType(), |
| 634 | Type->getTypeLoc().getBeginLoc(), |
Chandler Carruth | 428edaf | 2010-10-25 08:47:36 +0000 | [diff] [blame] | 635 | Cons, false, Args, NumArgs, ZeroInitialization, |
| 636 | CXXConstructExpr::CK_Complete, parenRange), |
| 637 | Type(Type) { |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 638 | } |
| 639 | |
| 640 | SourceRange CXXTemporaryObjectExpr::getSourceRange() const { |
Chandler Carruth | 428edaf | 2010-10-25 08:47:36 +0000 | [diff] [blame] | 641 | return SourceRange(Type->getTypeLoc().getBeginLoc(), |
| 642 | getParenRange().getEnd()); |
Douglas Gregor | 506ae41 | 2009-01-16 18:33:17 +0000 | [diff] [blame] | 643 | } |
Anders Carlsson | 19d28a6 | 2009-04-21 02:22:11 +0000 | [diff] [blame] | 644 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 645 | CXXConstructExpr *CXXConstructExpr::Create(ASTContext &C, QualType T, |
Douglas Gregor | 99a2e60 | 2009-12-16 01:38:02 +0000 | [diff] [blame] | 646 | SourceLocation Loc, |
Anders Carlsson | 8e587a1 | 2009-05-30 20:56:46 +0000 | [diff] [blame] | 647 | CXXConstructorDecl *D, bool Elidable, |
Douglas Gregor | 16006c9 | 2009-12-16 18:50:27 +0000 | [diff] [blame] | 648 | Expr **Args, unsigned NumArgs, |
Douglas Gregor | 9db7dbb | 2010-01-31 09:12:51 +0000 | [diff] [blame] | 649 | bool ZeroInitialization, |
Chandler Carruth | 428edaf | 2010-10-25 08:47:36 +0000 | [diff] [blame] | 650 | ConstructionKind ConstructKind, |
| 651 | SourceRange ParenRange) { |
Douglas Gregor | 99a2e60 | 2009-12-16 01:38:02 +0000 | [diff] [blame] | 652 | return new (C) CXXConstructExpr(C, CXXConstructExprClass, T, Loc, D, |
Douglas Gregor | 9db7dbb | 2010-01-31 09:12:51 +0000 | [diff] [blame] | 653 | Elidable, Args, NumArgs, ZeroInitialization, |
Chandler Carruth | 428edaf | 2010-10-25 08:47:36 +0000 | [diff] [blame] | 654 | ConstructKind, ParenRange); |
Anders Carlsson | e349bea | 2009-04-23 02:32:43 +0000 | [diff] [blame] | 655 | } |
| 656 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 657 | CXXConstructExpr::CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T, |
Douglas Gregor | 99a2e60 | 2009-12-16 01:38:02 +0000 | [diff] [blame] | 658 | SourceLocation Loc, |
Anders Carlsson | 8e587a1 | 2009-05-30 20:56:46 +0000 | [diff] [blame] | 659 | CXXConstructorDecl *D, bool elidable, |
Douglas Gregor | 16006c9 | 2009-12-16 18:50:27 +0000 | [diff] [blame] | 660 | Expr **args, unsigned numargs, |
Anders Carlsson | 72e96fd | 2010-05-02 22:54:08 +0000 | [diff] [blame] | 661 | bool ZeroInitialization, |
Chandler Carruth | 428edaf | 2010-10-25 08:47:36 +0000 | [diff] [blame] | 662 | ConstructionKind ConstructKind, |
| 663 | SourceRange ParenRange) |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 664 | : Expr(SC, T, VK_RValue, OK_Ordinary, |
| 665 | T->isDependentType(), T->isDependentType(), |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 666 | T->isInstantiationDependentType(), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 667 | T->containsUnexpandedParameterPack()), |
| 668 | Constructor(D), Loc(Loc), ParenRange(ParenRange), Elidable(elidable), |
| 669 | ZeroInitialization(ZeroInitialization), ConstructKind(ConstructKind), |
| 670 | Args(0), NumArgs(numargs) |
Douglas Gregor | 16006c9 | 2009-12-16 18:50:27 +0000 | [diff] [blame] | 671 | { |
| 672 | if (NumArgs) { |
| 673 | Args = new (C) Stmt*[NumArgs]; |
| 674 | |
| 675 | for (unsigned i = 0; i != NumArgs; ++i) { |
| 676 | assert(args[i] && "NULL argument in CXXConstructExpr"); |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 677 | |
| 678 | if (args[i]->isValueDependent()) |
| 679 | ExprBits.ValueDependent = true; |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 680 | if (args[i]->isInstantiationDependent()) |
| 681 | ExprBits.InstantiationDependent = true; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 682 | if (args[i]->containsUnexpandedParameterPack()) |
| 683 | ExprBits.ContainsUnexpandedParameterPack = true; |
| 684 | |
Douglas Gregor | 16006c9 | 2009-12-16 18:50:27 +0000 | [diff] [blame] | 685 | Args[i] = args[i]; |
Anders Carlsson | e349bea | 2009-04-23 02:32:43 +0000 | [diff] [blame] | 686 | } |
Douglas Gregor | 16006c9 | 2009-12-16 18:50:27 +0000 | [diff] [blame] | 687 | } |
Anders Carlsson | e349bea | 2009-04-23 02:32:43 +0000 | [diff] [blame] | 688 | } |
| 689 | |
John McCall | 4765fa0 | 2010-12-06 08:20:24 +0000 | [diff] [blame] | 690 | ExprWithCleanups::ExprWithCleanups(ASTContext &C, |
| 691 | Expr *subexpr, |
| 692 | CXXTemporary **temps, |
| 693 | unsigned numtemps) |
| 694 | : Expr(ExprWithCleanupsClass, subexpr->getType(), |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 695 | subexpr->getValueKind(), subexpr->getObjectKind(), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 696 | subexpr->isTypeDependent(), subexpr->isValueDependent(), |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 697 | subexpr->isInstantiationDependent(), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 698 | subexpr->containsUnexpandedParameterPack()), |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 699 | SubExpr(subexpr), Temps(0), NumTemps(0) { |
Chris Lattner | aff32cb | 2010-05-10 00:45:12 +0000 | [diff] [blame] | 700 | if (numtemps) { |
Ted Kremenek | d04ed41 | 2010-05-10 20:06:30 +0000 | [diff] [blame] | 701 | setNumTemporaries(C, numtemps); |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 702 | for (unsigned i = 0; i != numtemps; ++i) |
Anders Carlsson | ff6b3d6 | 2009-05-30 21:05:25 +0000 | [diff] [blame] | 703 | Temps[i] = temps[i]; |
Anders Carlsson | 02bbfa3 | 2009-04-24 22:47:04 +0000 | [diff] [blame] | 704 | } |
| 705 | } |
| 706 | |
John McCall | 4765fa0 | 2010-12-06 08:20:24 +0000 | [diff] [blame] | 707 | void ExprWithCleanups::setNumTemporaries(ASTContext &C, unsigned N) { |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 708 | assert(Temps == 0 && "Cannot resize with this"); |
Daniel Dunbar | 90556d4 | 2010-05-10 15:59:37 +0000 | [diff] [blame] | 709 | NumTemps = N; |
Ted Kremenek | d04ed41 | 2010-05-10 20:06:30 +0000 | [diff] [blame] | 710 | Temps = new (C) CXXTemporary*[NumTemps]; |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 711 | } |
| 712 | |
| 713 | |
John McCall | 4765fa0 | 2010-12-06 08:20:24 +0000 | [diff] [blame] | 714 | ExprWithCleanups *ExprWithCleanups::Create(ASTContext &C, |
| 715 | Expr *SubExpr, |
| 716 | CXXTemporary **Temps, |
| 717 | unsigned NumTemps) { |
| 718 | return new (C) ExprWithCleanups(C, SubExpr, Temps, NumTemps); |
Anders Carlsson | 88eaf07 | 2009-05-30 22:38:53 +0000 | [diff] [blame] | 719 | } |
| 720 | |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 721 | CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(TypeSourceInfo *Type, |
Douglas Gregor | d81e6ca | 2009-05-20 18:46:25 +0000 | [diff] [blame] | 722 | SourceLocation LParenLoc, |
| 723 | Expr **Args, |
| 724 | unsigned NumArgs, |
| 725 | SourceLocation RParenLoc) |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 726 | : Expr(CXXUnresolvedConstructExprClass, |
| 727 | Type->getType().getNonReferenceType(), |
John McCall | 0943168 | 2010-11-18 19:01:18 +0000 | [diff] [blame] | 728 | VK_LValue, OK_Ordinary, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 729 | Type->getType()->isDependentType(), true, true, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 730 | Type->getType()->containsUnexpandedParameterPack()), |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 731 | Type(Type), |
Douglas Gregor | d81e6ca | 2009-05-20 18:46:25 +0000 | [diff] [blame] | 732 | LParenLoc(LParenLoc), |
| 733 | RParenLoc(RParenLoc), |
| 734 | NumArgs(NumArgs) { |
| 735 | Stmt **StoredArgs = reinterpret_cast<Stmt **>(this + 1); |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 736 | for (unsigned I = 0; I != NumArgs; ++I) { |
| 737 | if (Args[I]->containsUnexpandedParameterPack()) |
| 738 | ExprBits.ContainsUnexpandedParameterPack = true; |
| 739 | |
| 740 | StoredArgs[I] = Args[I]; |
| 741 | } |
Douglas Gregor | d81e6ca | 2009-05-20 18:46:25 +0000 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | CXXUnresolvedConstructExpr * |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 745 | CXXUnresolvedConstructExpr::Create(ASTContext &C, |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 746 | TypeSourceInfo *Type, |
Douglas Gregor | d81e6ca | 2009-05-20 18:46:25 +0000 | [diff] [blame] | 747 | SourceLocation LParenLoc, |
| 748 | Expr **Args, |
| 749 | unsigned NumArgs, |
| 750 | SourceLocation RParenLoc) { |
| 751 | void *Mem = C.Allocate(sizeof(CXXUnresolvedConstructExpr) + |
| 752 | sizeof(Expr *) * NumArgs); |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 753 | return new (Mem) CXXUnresolvedConstructExpr(Type, LParenLoc, |
Douglas Gregor | d81e6ca | 2009-05-20 18:46:25 +0000 | [diff] [blame] | 754 | Args, NumArgs, RParenLoc); |
| 755 | } |
| 756 | |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 757 | CXXUnresolvedConstructExpr * |
| 758 | CXXUnresolvedConstructExpr::CreateEmpty(ASTContext &C, unsigned NumArgs) { |
| 759 | Stmt::EmptyShell Empty; |
| 760 | void *Mem = C.Allocate(sizeof(CXXUnresolvedConstructExpr) + |
| 761 | sizeof(Expr *) * NumArgs); |
| 762 | return new (Mem) CXXUnresolvedConstructExpr(Empty, NumArgs); |
| 763 | } |
| 764 | |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 765 | SourceRange CXXUnresolvedConstructExpr::getSourceRange() const { |
| 766 | return SourceRange(Type->getTypeLoc().getBeginLoc(), RParenLoc); |
| 767 | } |
| 768 | |
John McCall | 865d447 | 2009-11-19 22:55:06 +0000 | [diff] [blame] | 769 | CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(ASTContext &C, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 770 | Expr *Base, QualType BaseType, |
| 771 | bool IsArrow, |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 772 | SourceLocation OperatorLoc, |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 773 | NestedNameSpecifierLoc QualifierLoc, |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 774 | NamedDecl *FirstQualifierFoundInScope, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 775 | DeclarationNameInfo MemberNameInfo, |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 776 | const TemplateArgumentListInfo *TemplateArgs) |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 777 | : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 778 | VK_LValue, OK_Ordinary, true, true, true, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 779 | ((Base && Base->containsUnexpandedParameterPack()) || |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 780 | (QualifierLoc && |
| 781 | QualifierLoc.getNestedNameSpecifier() |
| 782 | ->containsUnexpandedParameterPack()) || |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 783 | MemberNameInfo.containsUnexpandedParameterPack())), |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 784 | Base(Base), BaseType(BaseType), IsArrow(IsArrow), |
| 785 | HasExplicitTemplateArgs(TemplateArgs != 0), |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 786 | OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc), |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 787 | FirstQualifierFoundInScope(FirstQualifierFoundInScope), |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 788 | MemberNameInfo(MemberNameInfo) { |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 789 | if (TemplateArgs) { |
| 790 | bool Dependent = true; |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 791 | bool InstantiationDependent = true; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 792 | bool ContainsUnexpandedParameterPack = false; |
| 793 | getExplicitTemplateArgs().initializeFrom(*TemplateArgs, Dependent, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 794 | InstantiationDependent, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 795 | ContainsUnexpandedParameterPack); |
| 796 | if (ContainsUnexpandedParameterPack) |
| 797 | ExprBits.ContainsUnexpandedParameterPack = true; |
| 798 | } |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 799 | } |
| 800 | |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 801 | CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(ASTContext &C, |
| 802 | Expr *Base, QualType BaseType, |
| 803 | bool IsArrow, |
| 804 | SourceLocation OperatorLoc, |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 805 | NestedNameSpecifierLoc QualifierLoc, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 806 | NamedDecl *FirstQualifierFoundInScope, |
| 807 | DeclarationNameInfo MemberNameInfo) |
| 808 | : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 809 | VK_LValue, OK_Ordinary, true, true, true, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 810 | ((Base && Base->containsUnexpandedParameterPack()) || |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 811 | (QualifierLoc && |
| 812 | QualifierLoc.getNestedNameSpecifier()-> |
| 813 | containsUnexpandedParameterPack()) || |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 814 | MemberNameInfo.containsUnexpandedParameterPack())), |
| 815 | Base(Base), BaseType(BaseType), IsArrow(IsArrow), |
| 816 | HasExplicitTemplateArgs(false), OperatorLoc(OperatorLoc), |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 817 | QualifierLoc(QualifierLoc), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 818 | FirstQualifierFoundInScope(FirstQualifierFoundInScope), |
| 819 | MemberNameInfo(MemberNameInfo) { } |
| 820 | |
John McCall | 865d447 | 2009-11-19 22:55:06 +0000 | [diff] [blame] | 821 | CXXDependentScopeMemberExpr * |
| 822 | CXXDependentScopeMemberExpr::Create(ASTContext &C, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 823 | Expr *Base, QualType BaseType, bool IsArrow, |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 824 | SourceLocation OperatorLoc, |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 825 | NestedNameSpecifierLoc QualifierLoc, |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 826 | NamedDecl *FirstQualifierFoundInScope, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 827 | DeclarationNameInfo MemberNameInfo, |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 828 | const TemplateArgumentListInfo *TemplateArgs) { |
| 829 | if (!TemplateArgs) |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 830 | return new (C) CXXDependentScopeMemberExpr(C, Base, BaseType, |
| 831 | IsArrow, OperatorLoc, |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 832 | QualifierLoc, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 833 | FirstQualifierFoundInScope, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 834 | MemberNameInfo); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 835 | |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 836 | std::size_t size = sizeof(CXXDependentScopeMemberExpr); |
| 837 | if (TemplateArgs) |
| 838 | size += ExplicitTemplateArgumentList::sizeFor(*TemplateArgs); |
| 839 | |
Chris Lattner | 3248854 | 2010-10-30 05:14:06 +0000 | [diff] [blame] | 840 | void *Mem = C.Allocate(size, llvm::alignOf<CXXDependentScopeMemberExpr>()); |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 841 | return new (Mem) CXXDependentScopeMemberExpr(C, Base, BaseType, |
| 842 | IsArrow, OperatorLoc, |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 843 | QualifierLoc, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 844 | FirstQualifierFoundInScope, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 845 | MemberNameInfo, TemplateArgs); |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 846 | } |
| 847 | |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 848 | CXXDependentScopeMemberExpr * |
| 849 | CXXDependentScopeMemberExpr::CreateEmpty(ASTContext &C, |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 850 | bool HasExplicitTemplateArgs, |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 851 | unsigned NumTemplateArgs) { |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 852 | if (!HasExplicitTemplateArgs) |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 853 | return new (C) CXXDependentScopeMemberExpr(C, 0, QualType(), |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 854 | 0, SourceLocation(), |
| 855 | NestedNameSpecifierLoc(), 0, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 856 | DeclarationNameInfo()); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 857 | |
| 858 | std::size_t size = sizeof(CXXDependentScopeMemberExpr) + |
| 859 | ExplicitTemplateArgumentList::sizeFor(NumTemplateArgs); |
Chris Lattner | 3248854 | 2010-10-30 05:14:06 +0000 | [diff] [blame] | 860 | void *Mem = C.Allocate(size, llvm::alignOf<CXXDependentScopeMemberExpr>()); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 861 | CXXDependentScopeMemberExpr *E |
| 862 | = new (Mem) CXXDependentScopeMemberExpr(C, 0, QualType(), |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 863 | 0, SourceLocation(), |
| 864 | NestedNameSpecifierLoc(), 0, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 865 | DeclarationNameInfo(), 0); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 866 | E->HasExplicitTemplateArgs = true; |
| 867 | return E; |
| 868 | } |
| 869 | |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 870 | bool CXXDependentScopeMemberExpr::isImplicitAccess() const { |
| 871 | if (Base == 0) |
| 872 | return true; |
| 873 | |
Douglas Gregor | 75e8504 | 2011-03-02 21:06:53 +0000 | [diff] [blame] | 874 | return cast<Expr>(Base)->isImplicitCXXThis(); |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 875 | } |
| 876 | |
John McCall | 864c041 | 2011-04-26 20:42:42 +0000 | [diff] [blame] | 877 | static bool hasOnlyNonStaticMemberFunctions(UnresolvedSetIterator begin, |
| 878 | UnresolvedSetIterator end) { |
| 879 | do { |
| 880 | NamedDecl *decl = *begin; |
| 881 | if (isa<UnresolvedUsingValueDecl>(decl)) |
| 882 | return false; |
| 883 | if (isa<UsingShadowDecl>(decl)) |
| 884 | decl = cast<UsingShadowDecl>(decl)->getUnderlyingDecl(); |
| 885 | |
| 886 | // Unresolved member expressions should only contain methods and |
| 887 | // method templates. |
| 888 | assert(isa<CXXMethodDecl>(decl) || isa<FunctionTemplateDecl>(decl)); |
| 889 | |
| 890 | if (isa<FunctionTemplateDecl>(decl)) |
| 891 | decl = cast<FunctionTemplateDecl>(decl)->getTemplatedDecl(); |
| 892 | if (cast<CXXMethodDecl>(decl)->isStatic()) |
| 893 | return false; |
| 894 | } while (++begin != end); |
| 895 | |
| 896 | return true; |
| 897 | } |
| 898 | |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 899 | UnresolvedMemberExpr::UnresolvedMemberExpr(ASTContext &C, |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 900 | bool HasUnresolvedUsing, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 901 | Expr *Base, QualType BaseType, |
| 902 | bool IsArrow, |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 903 | SourceLocation OperatorLoc, |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 904 | NestedNameSpecifierLoc QualifierLoc, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 905 | const DeclarationNameInfo &MemberNameInfo, |
Douglas Gregor | 5a84dec | 2010-05-23 18:57:34 +0000 | [diff] [blame] | 906 | const TemplateArgumentListInfo *TemplateArgs, |
| 907 | UnresolvedSetIterator Begin, |
| 908 | UnresolvedSetIterator End) |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 909 | : OverloadExpr(UnresolvedMemberExprClass, C, QualifierLoc, MemberNameInfo, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 910 | TemplateArgs, Begin, End, |
| 911 | // Dependent |
| 912 | ((Base && Base->isTypeDependent()) || |
| 913 | BaseType->isDependentType()), |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 914 | ((Base && Base->isInstantiationDependent()) || |
| 915 | BaseType->isInstantiationDependentType()), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 916 | // Contains unexpanded parameter pack |
| 917 | ((Base && Base->containsUnexpandedParameterPack()) || |
| 918 | BaseType->containsUnexpandedParameterPack())), |
John McCall | 7bb12da | 2010-02-02 06:20:04 +0000 | [diff] [blame] | 919 | IsArrow(IsArrow), HasUnresolvedUsing(HasUnresolvedUsing), |
| 920 | Base(Base), BaseType(BaseType), OperatorLoc(OperatorLoc) { |
John McCall | 864c041 | 2011-04-26 20:42:42 +0000 | [diff] [blame] | 921 | |
| 922 | // Check whether all of the members are non-static member functions, |
| 923 | // and if so, mark give this bound-member type instead of overload type. |
| 924 | if (hasOnlyNonStaticMemberFunctions(Begin, End)) |
| 925 | setType(C.BoundMemberTy); |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 926 | } |
| 927 | |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 928 | bool UnresolvedMemberExpr::isImplicitAccess() const { |
| 929 | if (Base == 0) |
| 930 | return true; |
| 931 | |
Douglas Gregor | 75e8504 | 2011-03-02 21:06:53 +0000 | [diff] [blame] | 932 | return cast<Expr>(Base)->isImplicitCXXThis(); |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 933 | } |
| 934 | |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 935 | UnresolvedMemberExpr * |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 936 | UnresolvedMemberExpr::Create(ASTContext &C, |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 937 | bool HasUnresolvedUsing, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 938 | Expr *Base, QualType BaseType, bool IsArrow, |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 939 | SourceLocation OperatorLoc, |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 940 | NestedNameSpecifierLoc QualifierLoc, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 941 | const DeclarationNameInfo &MemberNameInfo, |
Douglas Gregor | 5a84dec | 2010-05-23 18:57:34 +0000 | [diff] [blame] | 942 | const TemplateArgumentListInfo *TemplateArgs, |
| 943 | UnresolvedSetIterator Begin, |
| 944 | UnresolvedSetIterator End) { |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 945 | std::size_t size = sizeof(UnresolvedMemberExpr); |
| 946 | if (TemplateArgs) |
| 947 | size += ExplicitTemplateArgumentList::sizeFor(*TemplateArgs); |
| 948 | |
Chris Lattner | 3248854 | 2010-10-30 05:14:06 +0000 | [diff] [blame] | 949 | void *Mem = C.Allocate(size, llvm::alignOf<UnresolvedMemberExpr>()); |
Douglas Gregor | 928e6fc | 2010-05-23 19:36:40 +0000 | [diff] [blame] | 950 | return new (Mem) UnresolvedMemberExpr(C, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 951 | HasUnresolvedUsing, Base, BaseType, |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 952 | IsArrow, OperatorLoc, QualifierLoc, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 953 | MemberNameInfo, TemplateArgs, Begin, End); |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 954 | } |
| 955 | |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 956 | UnresolvedMemberExpr * |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 957 | UnresolvedMemberExpr::CreateEmpty(ASTContext &C, bool HasExplicitTemplateArgs, |
| 958 | unsigned NumTemplateArgs) { |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 959 | std::size_t size = sizeof(UnresolvedMemberExpr); |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 960 | if (HasExplicitTemplateArgs) |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 961 | size += ExplicitTemplateArgumentList::sizeFor(NumTemplateArgs); |
| 962 | |
Chris Lattner | 3248854 | 2010-10-30 05:14:06 +0000 | [diff] [blame] | 963 | void *Mem = C.Allocate(size, llvm::alignOf<UnresolvedMemberExpr>()); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 964 | UnresolvedMemberExpr *E = new (Mem) UnresolvedMemberExpr(EmptyShell()); |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 965 | E->HasExplicitTemplateArgs = HasExplicitTemplateArgs; |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 966 | return E; |
| 967 | } |
| 968 | |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 969 | CXXRecordDecl *UnresolvedMemberExpr::getNamingClass() const { |
| 970 | // Unlike for UnresolvedLookupExpr, it is very easy to re-derive this. |
| 971 | |
| 972 | // If there was a nested name specifier, it names the naming class. |
| 973 | // It can't be dependent: after all, we were actually able to do the |
| 974 | // lookup. |
Douglas Gregor | c96be1e | 2010-04-27 18:19:34 +0000 | [diff] [blame] | 975 | CXXRecordDecl *Record = 0; |
John McCall | 7bb12da | 2010-02-02 06:20:04 +0000 | [diff] [blame] | 976 | if (getQualifier()) { |
John McCall | f4c7371 | 2011-01-19 06:33:43 +0000 | [diff] [blame] | 977 | const Type *T = getQualifier()->getAsType(); |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 978 | assert(T && "qualifier in member expression does not name type"); |
Douglas Gregor | c96be1e | 2010-04-27 18:19:34 +0000 | [diff] [blame] | 979 | Record = T->getAsCXXRecordDecl(); |
| 980 | assert(Record && "qualifier in member expression does not name record"); |
| 981 | } |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 982 | // Otherwise the naming class must have been the base class. |
Douglas Gregor | c96be1e | 2010-04-27 18:19:34 +0000 | [diff] [blame] | 983 | else { |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 984 | QualType BaseType = getBaseType().getNonReferenceType(); |
| 985 | if (isArrow()) { |
| 986 | const PointerType *PT = BaseType->getAs<PointerType>(); |
| 987 | assert(PT && "base of arrow member access is not pointer"); |
| 988 | BaseType = PT->getPointeeType(); |
| 989 | } |
| 990 | |
Douglas Gregor | c96be1e | 2010-04-27 18:19:34 +0000 | [diff] [blame] | 991 | Record = BaseType->getAsCXXRecordDecl(); |
| 992 | assert(Record && "base of member expression does not name record"); |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 993 | } |
| 994 | |
Douglas Gregor | c96be1e | 2010-04-27 18:19:34 +0000 | [diff] [blame] | 995 | return Record; |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 996 | } |
| 997 | |
Douglas Gregor | c7793c7 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 998 | SubstNonTypeTemplateParmPackExpr:: |
| 999 | SubstNonTypeTemplateParmPackExpr(QualType T, |
| 1000 | NonTypeTemplateParmDecl *Param, |
| 1001 | SourceLocation NameLoc, |
| 1002 | const TemplateArgument &ArgPack) |
| 1003 | : Expr(SubstNonTypeTemplateParmPackExprClass, T, VK_RValue, OK_Ordinary, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame^] | 1004 | true, true, true, true), |
Douglas Gregor | c7793c7 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 1005 | Param(Param), Arguments(ArgPack.pack_begin()), |
| 1006 | NumArguments(ArgPack.pack_size()), NameLoc(NameLoc) { } |
| 1007 | |
| 1008 | TemplateArgument SubstNonTypeTemplateParmPackExpr::getArgumentPack() const { |
| 1009 | return TemplateArgument(Arguments, NumArguments); |
| 1010 | } |
| 1011 | |
Douglas Gregor | c7793c7 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 1012 | |