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) + |
Argyrios Kyrtzidis | b0c3e09 | 2011-09-22 20:07:03 +0000 | [diff] [blame] | 205 | ASTTemplateArgumentListInfo::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 | b0c3e09 | 2011-09-22 20:07:03 +0000 | [diff] [blame] | 216 | size += ASTTemplateArgumentListInfo::sizeFor(NumTemplateArgs); |
Argyrios Kyrtzidis | bd65bb5 | 2010-06-25 09:03:34 +0000 | [diff] [blame] | 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 | |
Argyrios Kyrtzidis | b0c3e09 | 2011-09-22 20:07:03 +0000 | [diff] [blame] | 335 | reinterpret_cast<ASTTemplateArgumentListInfo*>(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) |
Argyrios Kyrtzidis | b0c3e09 | 2011-09-22 20:07:03 +0000 | [diff] [blame] | 350 | size += ASTTemplateArgumentListInfo::sizeFor(*Args); |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 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 | b0c3e09 | 2011-09-22 20:07:03 +0000 | [diff] [blame] | 362 | size += ASTTemplateArgumentListInfo::sizeFor(NumTemplateArgs); |
Argyrios Kyrtzidis | 12dffcd | 2010-06-28 09:31:56 +0000 | [diff] [blame] | 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()), |
Douglas Gregor | a48e676 | 2011-09-26 14:47:03 +0000 | [diff] [blame^] | 668 | Constructor(D), Loc(Loc), ParenRange(ParenRange), NumArgs(numargs), |
| 669 | Elidable(elidable), ZeroInitialization(ZeroInitialization), |
| 670 | ConstructKind(ConstructKind), Args(0) |
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(), |
Douglas Gregor | 032c869 | 2011-07-08 15:50:43 +0000 | [diff] [blame] | 728 | (Type->getType()->isLValueReferenceType() ? VK_LValue |
| 729 | :Type->getType()->isRValueReferenceType()? VK_XValue |
| 730 | :VK_RValue), |
| 731 | OK_Ordinary, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 732 | Type->getType()->isDependentType(), true, true, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 733 | Type->getType()->containsUnexpandedParameterPack()), |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 734 | Type(Type), |
Douglas Gregor | d81e6ca | 2009-05-20 18:46:25 +0000 | [diff] [blame] | 735 | LParenLoc(LParenLoc), |
| 736 | RParenLoc(RParenLoc), |
| 737 | NumArgs(NumArgs) { |
| 738 | Stmt **StoredArgs = reinterpret_cast<Stmt **>(this + 1); |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 739 | for (unsigned I = 0; I != NumArgs; ++I) { |
| 740 | if (Args[I]->containsUnexpandedParameterPack()) |
| 741 | ExprBits.ContainsUnexpandedParameterPack = true; |
| 742 | |
| 743 | StoredArgs[I] = Args[I]; |
| 744 | } |
Douglas Gregor | d81e6ca | 2009-05-20 18:46:25 +0000 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | CXXUnresolvedConstructExpr * |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 748 | CXXUnresolvedConstructExpr::Create(ASTContext &C, |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 749 | TypeSourceInfo *Type, |
Douglas Gregor | d81e6ca | 2009-05-20 18:46:25 +0000 | [diff] [blame] | 750 | SourceLocation LParenLoc, |
| 751 | Expr **Args, |
| 752 | unsigned NumArgs, |
| 753 | SourceLocation RParenLoc) { |
| 754 | void *Mem = C.Allocate(sizeof(CXXUnresolvedConstructExpr) + |
| 755 | sizeof(Expr *) * NumArgs); |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 756 | return new (Mem) CXXUnresolvedConstructExpr(Type, LParenLoc, |
Douglas Gregor | d81e6ca | 2009-05-20 18:46:25 +0000 | [diff] [blame] | 757 | Args, NumArgs, RParenLoc); |
| 758 | } |
| 759 | |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 760 | CXXUnresolvedConstructExpr * |
| 761 | CXXUnresolvedConstructExpr::CreateEmpty(ASTContext &C, unsigned NumArgs) { |
| 762 | Stmt::EmptyShell Empty; |
| 763 | void *Mem = C.Allocate(sizeof(CXXUnresolvedConstructExpr) + |
| 764 | sizeof(Expr *) * NumArgs); |
| 765 | return new (Mem) CXXUnresolvedConstructExpr(Empty, NumArgs); |
| 766 | } |
| 767 | |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 768 | SourceRange CXXUnresolvedConstructExpr::getSourceRange() const { |
| 769 | return SourceRange(Type->getTypeLoc().getBeginLoc(), RParenLoc); |
| 770 | } |
| 771 | |
John McCall | 865d447 | 2009-11-19 22:55:06 +0000 | [diff] [blame] | 772 | CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(ASTContext &C, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 773 | Expr *Base, QualType BaseType, |
| 774 | bool IsArrow, |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 775 | SourceLocation OperatorLoc, |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 776 | NestedNameSpecifierLoc QualifierLoc, |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 777 | NamedDecl *FirstQualifierFoundInScope, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 778 | DeclarationNameInfo MemberNameInfo, |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 779 | const TemplateArgumentListInfo *TemplateArgs) |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 780 | : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 781 | VK_LValue, OK_Ordinary, true, true, true, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 782 | ((Base && Base->containsUnexpandedParameterPack()) || |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 783 | (QualifierLoc && |
| 784 | QualifierLoc.getNestedNameSpecifier() |
| 785 | ->containsUnexpandedParameterPack()) || |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 786 | MemberNameInfo.containsUnexpandedParameterPack())), |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 787 | Base(Base), BaseType(BaseType), IsArrow(IsArrow), |
| 788 | HasExplicitTemplateArgs(TemplateArgs != 0), |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 789 | OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc), |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 790 | FirstQualifierFoundInScope(FirstQualifierFoundInScope), |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 791 | MemberNameInfo(MemberNameInfo) { |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 792 | if (TemplateArgs) { |
| 793 | bool Dependent = true; |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 794 | bool InstantiationDependent = true; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 795 | bool ContainsUnexpandedParameterPack = false; |
| 796 | getExplicitTemplateArgs().initializeFrom(*TemplateArgs, Dependent, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 797 | InstantiationDependent, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 798 | ContainsUnexpandedParameterPack); |
| 799 | if (ContainsUnexpandedParameterPack) |
| 800 | ExprBits.ContainsUnexpandedParameterPack = true; |
| 801 | } |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 802 | } |
| 803 | |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 804 | CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(ASTContext &C, |
| 805 | Expr *Base, QualType BaseType, |
| 806 | bool IsArrow, |
| 807 | SourceLocation OperatorLoc, |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 808 | NestedNameSpecifierLoc QualifierLoc, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 809 | NamedDecl *FirstQualifierFoundInScope, |
| 810 | DeclarationNameInfo MemberNameInfo) |
| 811 | : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 812 | VK_LValue, OK_Ordinary, true, true, true, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 813 | ((Base && Base->containsUnexpandedParameterPack()) || |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 814 | (QualifierLoc && |
| 815 | QualifierLoc.getNestedNameSpecifier()-> |
| 816 | containsUnexpandedParameterPack()) || |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 817 | MemberNameInfo.containsUnexpandedParameterPack())), |
| 818 | Base(Base), BaseType(BaseType), IsArrow(IsArrow), |
| 819 | HasExplicitTemplateArgs(false), OperatorLoc(OperatorLoc), |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 820 | QualifierLoc(QualifierLoc), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 821 | FirstQualifierFoundInScope(FirstQualifierFoundInScope), |
| 822 | MemberNameInfo(MemberNameInfo) { } |
| 823 | |
John McCall | 865d447 | 2009-11-19 22:55:06 +0000 | [diff] [blame] | 824 | CXXDependentScopeMemberExpr * |
| 825 | CXXDependentScopeMemberExpr::Create(ASTContext &C, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 826 | Expr *Base, QualType BaseType, bool IsArrow, |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 827 | SourceLocation OperatorLoc, |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 828 | NestedNameSpecifierLoc QualifierLoc, |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 829 | NamedDecl *FirstQualifierFoundInScope, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 830 | DeclarationNameInfo MemberNameInfo, |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 831 | const TemplateArgumentListInfo *TemplateArgs) { |
| 832 | if (!TemplateArgs) |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 833 | return new (C) CXXDependentScopeMemberExpr(C, Base, BaseType, |
| 834 | IsArrow, OperatorLoc, |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 835 | QualifierLoc, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 836 | FirstQualifierFoundInScope, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 837 | MemberNameInfo); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 838 | |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 839 | std::size_t size = sizeof(CXXDependentScopeMemberExpr); |
| 840 | if (TemplateArgs) |
Argyrios Kyrtzidis | b0c3e09 | 2011-09-22 20:07:03 +0000 | [diff] [blame] | 841 | size += ASTTemplateArgumentListInfo::sizeFor(*TemplateArgs); |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 842 | |
Chris Lattner | 3248854 | 2010-10-30 05:14:06 +0000 | [diff] [blame] | 843 | void *Mem = C.Allocate(size, llvm::alignOf<CXXDependentScopeMemberExpr>()); |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 844 | return new (Mem) CXXDependentScopeMemberExpr(C, Base, BaseType, |
| 845 | IsArrow, OperatorLoc, |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 846 | QualifierLoc, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 847 | FirstQualifierFoundInScope, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 848 | MemberNameInfo, TemplateArgs); |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 849 | } |
| 850 | |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 851 | CXXDependentScopeMemberExpr * |
| 852 | CXXDependentScopeMemberExpr::CreateEmpty(ASTContext &C, |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 853 | bool HasExplicitTemplateArgs, |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 854 | unsigned NumTemplateArgs) { |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 855 | if (!HasExplicitTemplateArgs) |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 856 | return new (C) CXXDependentScopeMemberExpr(C, 0, QualType(), |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 857 | 0, SourceLocation(), |
| 858 | NestedNameSpecifierLoc(), 0, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 859 | DeclarationNameInfo()); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 860 | |
| 861 | std::size_t size = sizeof(CXXDependentScopeMemberExpr) + |
Argyrios Kyrtzidis | b0c3e09 | 2011-09-22 20:07:03 +0000 | [diff] [blame] | 862 | ASTTemplateArgumentListInfo::sizeFor(NumTemplateArgs); |
Chris Lattner | 3248854 | 2010-10-30 05:14:06 +0000 | [diff] [blame] | 863 | void *Mem = C.Allocate(size, llvm::alignOf<CXXDependentScopeMemberExpr>()); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 864 | CXXDependentScopeMemberExpr *E |
| 865 | = new (Mem) CXXDependentScopeMemberExpr(C, 0, QualType(), |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 866 | 0, SourceLocation(), |
| 867 | NestedNameSpecifierLoc(), 0, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 868 | DeclarationNameInfo(), 0); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 869 | E->HasExplicitTemplateArgs = true; |
| 870 | return E; |
| 871 | } |
| 872 | |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 873 | bool CXXDependentScopeMemberExpr::isImplicitAccess() const { |
| 874 | if (Base == 0) |
| 875 | return true; |
| 876 | |
Douglas Gregor | 75e8504 | 2011-03-02 21:06:53 +0000 | [diff] [blame] | 877 | return cast<Expr>(Base)->isImplicitCXXThis(); |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 878 | } |
| 879 | |
John McCall | 864c041 | 2011-04-26 20:42:42 +0000 | [diff] [blame] | 880 | static bool hasOnlyNonStaticMemberFunctions(UnresolvedSetIterator begin, |
| 881 | UnresolvedSetIterator end) { |
| 882 | do { |
| 883 | NamedDecl *decl = *begin; |
| 884 | if (isa<UnresolvedUsingValueDecl>(decl)) |
| 885 | return false; |
| 886 | if (isa<UsingShadowDecl>(decl)) |
| 887 | decl = cast<UsingShadowDecl>(decl)->getUnderlyingDecl(); |
| 888 | |
| 889 | // Unresolved member expressions should only contain methods and |
| 890 | // method templates. |
| 891 | assert(isa<CXXMethodDecl>(decl) || isa<FunctionTemplateDecl>(decl)); |
| 892 | |
| 893 | if (isa<FunctionTemplateDecl>(decl)) |
| 894 | decl = cast<FunctionTemplateDecl>(decl)->getTemplatedDecl(); |
| 895 | if (cast<CXXMethodDecl>(decl)->isStatic()) |
| 896 | return false; |
| 897 | } while (++begin != end); |
| 898 | |
| 899 | return true; |
| 900 | } |
| 901 | |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 902 | UnresolvedMemberExpr::UnresolvedMemberExpr(ASTContext &C, |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 903 | bool HasUnresolvedUsing, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 904 | Expr *Base, QualType BaseType, |
| 905 | bool IsArrow, |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 906 | SourceLocation OperatorLoc, |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 907 | NestedNameSpecifierLoc QualifierLoc, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 908 | const DeclarationNameInfo &MemberNameInfo, |
Douglas Gregor | 5a84dec | 2010-05-23 18:57:34 +0000 | [diff] [blame] | 909 | const TemplateArgumentListInfo *TemplateArgs, |
| 910 | UnresolvedSetIterator Begin, |
| 911 | UnresolvedSetIterator End) |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 912 | : OverloadExpr(UnresolvedMemberExprClass, C, QualifierLoc, MemberNameInfo, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 913 | TemplateArgs, Begin, End, |
| 914 | // Dependent |
| 915 | ((Base && Base->isTypeDependent()) || |
| 916 | BaseType->isDependentType()), |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 917 | ((Base && Base->isInstantiationDependent()) || |
| 918 | BaseType->isInstantiationDependentType()), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 919 | // Contains unexpanded parameter pack |
| 920 | ((Base && Base->containsUnexpandedParameterPack()) || |
| 921 | BaseType->containsUnexpandedParameterPack())), |
John McCall | 7bb12da | 2010-02-02 06:20:04 +0000 | [diff] [blame] | 922 | IsArrow(IsArrow), HasUnresolvedUsing(HasUnresolvedUsing), |
| 923 | Base(Base), BaseType(BaseType), OperatorLoc(OperatorLoc) { |
John McCall | 864c041 | 2011-04-26 20:42:42 +0000 | [diff] [blame] | 924 | |
| 925 | // Check whether all of the members are non-static member functions, |
| 926 | // and if so, mark give this bound-member type instead of overload type. |
| 927 | if (hasOnlyNonStaticMemberFunctions(Begin, End)) |
| 928 | setType(C.BoundMemberTy); |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 929 | } |
| 930 | |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 931 | bool UnresolvedMemberExpr::isImplicitAccess() const { |
| 932 | if (Base == 0) |
| 933 | return true; |
| 934 | |
Douglas Gregor | 75e8504 | 2011-03-02 21:06:53 +0000 | [diff] [blame] | 935 | return cast<Expr>(Base)->isImplicitCXXThis(); |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 936 | } |
| 937 | |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 938 | UnresolvedMemberExpr * |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 939 | UnresolvedMemberExpr::Create(ASTContext &C, |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 940 | bool HasUnresolvedUsing, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 941 | Expr *Base, QualType BaseType, bool IsArrow, |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 942 | SourceLocation OperatorLoc, |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 943 | NestedNameSpecifierLoc QualifierLoc, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 944 | const DeclarationNameInfo &MemberNameInfo, |
Douglas Gregor | 5a84dec | 2010-05-23 18:57:34 +0000 | [diff] [blame] | 945 | const TemplateArgumentListInfo *TemplateArgs, |
| 946 | UnresolvedSetIterator Begin, |
| 947 | UnresolvedSetIterator End) { |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 948 | std::size_t size = sizeof(UnresolvedMemberExpr); |
| 949 | if (TemplateArgs) |
Argyrios Kyrtzidis | b0c3e09 | 2011-09-22 20:07:03 +0000 | [diff] [blame] | 950 | size += ASTTemplateArgumentListInfo::sizeFor(*TemplateArgs); |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 951 | |
Chris Lattner | 3248854 | 2010-10-30 05:14:06 +0000 | [diff] [blame] | 952 | void *Mem = C.Allocate(size, llvm::alignOf<UnresolvedMemberExpr>()); |
Douglas Gregor | 928e6fc | 2010-05-23 19:36:40 +0000 | [diff] [blame] | 953 | return new (Mem) UnresolvedMemberExpr(C, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 954 | HasUnresolvedUsing, Base, BaseType, |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 955 | IsArrow, OperatorLoc, QualifierLoc, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 956 | MemberNameInfo, TemplateArgs, Begin, End); |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 957 | } |
| 958 | |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 959 | UnresolvedMemberExpr * |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 960 | UnresolvedMemberExpr::CreateEmpty(ASTContext &C, bool HasExplicitTemplateArgs, |
| 961 | unsigned NumTemplateArgs) { |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 962 | std::size_t size = sizeof(UnresolvedMemberExpr); |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 963 | if (HasExplicitTemplateArgs) |
Argyrios Kyrtzidis | b0c3e09 | 2011-09-22 20:07:03 +0000 | [diff] [blame] | 964 | size += ASTTemplateArgumentListInfo::sizeFor(NumTemplateArgs); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 965 | |
Chris Lattner | 3248854 | 2010-10-30 05:14:06 +0000 | [diff] [blame] | 966 | void *Mem = C.Allocate(size, llvm::alignOf<UnresolvedMemberExpr>()); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 967 | UnresolvedMemberExpr *E = new (Mem) UnresolvedMemberExpr(EmptyShell()); |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 968 | E->HasExplicitTemplateArgs = HasExplicitTemplateArgs; |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 969 | return E; |
| 970 | } |
| 971 | |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 972 | CXXRecordDecl *UnresolvedMemberExpr::getNamingClass() const { |
| 973 | // Unlike for UnresolvedLookupExpr, it is very easy to re-derive this. |
| 974 | |
| 975 | // If there was a nested name specifier, it names the naming class. |
| 976 | // It can't be dependent: after all, we were actually able to do the |
| 977 | // lookup. |
Douglas Gregor | c96be1e | 2010-04-27 18:19:34 +0000 | [diff] [blame] | 978 | CXXRecordDecl *Record = 0; |
John McCall | 7bb12da | 2010-02-02 06:20:04 +0000 | [diff] [blame] | 979 | if (getQualifier()) { |
John McCall | f4c7371 | 2011-01-19 06:33:43 +0000 | [diff] [blame] | 980 | const Type *T = getQualifier()->getAsType(); |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 981 | assert(T && "qualifier in member expression does not name type"); |
Douglas Gregor | c96be1e | 2010-04-27 18:19:34 +0000 | [diff] [blame] | 982 | Record = T->getAsCXXRecordDecl(); |
| 983 | assert(Record && "qualifier in member expression does not name record"); |
| 984 | } |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 985 | // Otherwise the naming class must have been the base class. |
Douglas Gregor | c96be1e | 2010-04-27 18:19:34 +0000 | [diff] [blame] | 986 | else { |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 987 | QualType BaseType = getBaseType().getNonReferenceType(); |
| 988 | if (isArrow()) { |
| 989 | const PointerType *PT = BaseType->getAs<PointerType>(); |
| 990 | assert(PT && "base of arrow member access is not pointer"); |
| 991 | BaseType = PT->getPointeeType(); |
| 992 | } |
| 993 | |
Douglas Gregor | c96be1e | 2010-04-27 18:19:34 +0000 | [diff] [blame] | 994 | Record = BaseType->getAsCXXRecordDecl(); |
| 995 | assert(Record && "base of member expression does not name record"); |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 996 | } |
| 997 | |
Douglas Gregor | c96be1e | 2010-04-27 18:19:34 +0000 | [diff] [blame] | 998 | return Record; |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 999 | } |
| 1000 | |
Douglas Gregor | c7793c7 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 1001 | SubstNonTypeTemplateParmPackExpr:: |
| 1002 | SubstNonTypeTemplateParmPackExpr(QualType T, |
| 1003 | NonTypeTemplateParmDecl *Param, |
| 1004 | SourceLocation NameLoc, |
| 1005 | const TemplateArgument &ArgPack) |
| 1006 | : Expr(SubstNonTypeTemplateParmPackExprClass, T, VK_RValue, OK_Ordinary, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 1007 | true, true, true, true), |
Douglas Gregor | c7793c7 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 1008 | Param(Param), Arguments(ArgPack.pack_begin()), |
| 1009 | NumArguments(ArgPack.pack_size()), NameLoc(NameLoc) { } |
| 1010 | |
| 1011 | TemplateArgument SubstNonTypeTemplateParmPackExpr::getArgumentPack() const { |
| 1012 | return TemplateArgument(Arguments, NumArguments); |
| 1013 | } |
| 1014 | |
Douglas Gregor | c7793c7 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 1015 | |