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 | |
Benjamin Kramer | 471c8b4 | 2012-07-04 20:19:54 +0000 | [diff] [blame] | 14 | #include "clang/AST/ASTContext.h" |
Benjamin Kramer | 2fa67ef | 2012-12-01 15:09:41 +0000 | [diff] [blame] | 15 | #include "clang/AST/Attr.h" |
Douglas Gregor | b460980 | 2008-11-14 16:09:21 +0000 | [diff] [blame] | 16 | #include "clang/AST/DeclCXX.h" |
Douglas Gregor | edce4dd | 2009-06-30 22:34:41 +0000 | [diff] [blame] | 17 | #include "clang/AST/DeclTemplate.h" |
Ted Kremenek | a758d09 | 2007-08-24 20:21:10 +0000 | [diff] [blame] | 18 | #include "clang/AST/ExprCXX.h" |
Douglas Gregor | 26d4ac9 | 2010-02-24 23:40:28 +0000 | [diff] [blame] | 19 | #include "clang/AST/TypeLoc.h" |
Benjamin Kramer | 2fa67ef | 2012-12-01 15:09:41 +0000 | [diff] [blame] | 20 | #include "clang/Basic/IdentifierTable.h" |
Ted Kremenek | a758d09 | 2007-08-24 20:21:10 +0000 | [diff] [blame] | 21 | using namespace clang; |
| 22 | |
Douglas Gregor | 57fdc8a | 2010-04-26 22:37:10 +0000 | [diff] [blame] | 23 | |
Ted Kremenek | a758d09 | 2007-08-24 20:21:10 +0000 | [diff] [blame] | 24 | //===----------------------------------------------------------------------===// |
| 25 | // Child Iterators for iterating over subexpressions/substatements |
| 26 | //===----------------------------------------------------------------------===// |
| 27 | |
Richard Smith | 0d72910 | 2012-08-13 20:08:14 +0000 | [diff] [blame] | 28 | bool CXXTypeidExpr::isPotentiallyEvaluated() const { |
| 29 | if (isTypeOperand()) |
| 30 | return false; |
| 31 | |
| 32 | // C++11 [expr.typeid]p3: |
| 33 | // When typeid is applied to an expression other than a glvalue of |
| 34 | // polymorphic class type, [...] the expression is an unevaluated operand. |
| 35 | const Expr *E = getExprOperand(); |
| 36 | if (const CXXRecordDecl *RD = E->getType()->getAsCXXRecordDecl()) |
| 37 | if (RD->isPolymorphic() && E->isGLValue()) |
| 38 | return true; |
| 39 | |
| 40 | return false; |
| 41 | } |
| 42 | |
Douglas Gregor | 57fdc8a | 2010-04-26 22:37:10 +0000 | [diff] [blame] | 43 | QualType CXXTypeidExpr::getTypeOperand() const { |
| 44 | assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); |
| 45 | return Operand.get<TypeSourceInfo *>()->getType().getNonReferenceType() |
| 46 | .getUnqualifiedType(); |
| 47 | } |
| 48 | |
Francois Pichet | 01b7c30 | 2010-09-08 12:20:18 +0000 | [diff] [blame] | 49 | QualType CXXUuidofExpr::getTypeOperand() const { |
| 50 | assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)"); |
| 51 | return Operand.get<TypeSourceInfo *>()->getType().getNonReferenceType() |
| 52 | .getUnqualifiedType(); |
| 53 | } |
| 54 | |
Nico Weber | c5f8046 | 2012-10-11 10:13:44 +0000 | [diff] [blame] | 55 | // static |
| 56 | UuidAttr *CXXUuidofExpr::GetUuidAttrOfType(QualType QT) { |
| 57 | // Optionally remove one level of pointer, reference or array indirection. |
| 58 | const Type *Ty = QT.getTypePtr(); |
| 59 | if (QT->isPointerType() || QT->isReferenceType()) |
| 60 | Ty = QT->getPointeeType().getTypePtr(); |
| 61 | else if (QT->isArrayType()) |
| 62 | Ty = cast<ArrayType>(QT)->getElementType().getTypePtr(); |
| 63 | |
| 64 | // Loop all record redeclaration looking for an uuid attribute. |
| 65 | CXXRecordDecl *RD = Ty->getAsCXXRecordDecl(); |
| 66 | for (CXXRecordDecl::redecl_iterator I = RD->redecls_begin(), |
| 67 | E = RD->redecls_end(); I != E; ++I) { |
| 68 | if (UuidAttr *Uuid = I->getAttr<UuidAttr>()) |
| 69 | return Uuid; |
| 70 | } |
| 71 | |
| 72 | return 0; |
| 73 | } |
| 74 | |
David Majnemer | c80eb46 | 2013-08-13 06:32:20 +0000 | [diff] [blame] | 75 | StringRef CXXUuidofExpr::getUuidAsStringRef(ASTContext &Context) const { |
| 76 | StringRef Uuid; |
| 77 | if (isTypeOperand()) |
| 78 | Uuid = CXXUuidofExpr::GetUuidAttrOfType(getTypeOperand())->getGuid(); |
| 79 | else { |
| 80 | // Special case: __uuidof(0) means an all-zero GUID. |
| 81 | Expr *Op = getExprOperand(); |
| 82 | if (!Op->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) |
| 83 | Uuid = CXXUuidofExpr::GetUuidAttrOfType(Op->getType())->getGuid(); |
| 84 | else |
| 85 | Uuid = "00000000-0000-0000-0000-000000000000"; |
| 86 | } |
| 87 | return Uuid; |
| 88 | } |
| 89 | |
Douglas Gregor | ed8abf1 | 2010-07-08 06:14:04 +0000 | [diff] [blame] | 90 | // CXXScalarValueInitExpr |
Erik Verbruggen | 65d7831 | 2012-12-25 14:51:39 +0000 | [diff] [blame] | 91 | SourceLocation CXXScalarValueInitExpr::getLocStart() const { |
| 92 | return TypeInfo ? TypeInfo->getTypeLoc().getBeginLoc() : RParenLoc; |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 93 | } |
| 94 | |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 95 | // CXXNewExpr |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 96 | CXXNewExpr::CXXNewExpr(const ASTContext &C, bool globalNew, |
| 97 | FunctionDecl *operatorNew, FunctionDecl *operatorDelete, |
Sebastian Redl | 2aed8b8 | 2012-02-16 12:22:20 +0000 | [diff] [blame] | 98 | bool usualArrayDeleteWantsSize, |
Benjamin Kramer | 3b6bef9 | 2012-08-24 11:54:20 +0000 | [diff] [blame] | 99 | ArrayRef<Expr*> placementArgs, |
Sebastian Redl | 2aed8b8 | 2012-02-16 12:22:20 +0000 | [diff] [blame] | 100 | SourceRange typeIdParens, Expr *arraySize, |
| 101 | InitializationStyle initializationStyle, |
| 102 | Expr *initializer, QualType ty, |
| 103 | TypeSourceInfo *allocatedTypeInfo, |
David Blaikie | 5305641 | 2012-11-07 00:12:38 +0000 | [diff] [blame] | 104 | SourceRange Range, SourceRange directInitRange) |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 105 | : Expr(CXXNewExprClass, ty, VK_RValue, OK_Ordinary, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 106 | ty->isDependentType(), ty->isDependentType(), |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 107 | ty->isInstantiationDependentType(), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 108 | ty->containsUnexpandedParameterPack()), |
Sebastian Redl | 2aed8b8 | 2012-02-16 12:22:20 +0000 | [diff] [blame] | 109 | SubExprs(0), OperatorNew(operatorNew), OperatorDelete(operatorDelete), |
| 110 | AllocatedTypeInfo(allocatedTypeInfo), TypeIdParens(typeIdParens), |
David Blaikie | 5305641 | 2012-11-07 00:12:38 +0000 | [diff] [blame] | 111 | Range(Range), DirectInitRange(directInitRange), |
Benjamin Kramer | d162cf1 | 2012-02-26 20:37:14 +0000 | [diff] [blame] | 112 | GlobalNew(globalNew), UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize) { |
Sebastian Redl | 2aed8b8 | 2012-02-16 12:22:20 +0000 | [diff] [blame] | 113 | assert((initializer != 0 || initializationStyle == NoInit) && |
| 114 | "Only NoInit can have no initializer."); |
| 115 | StoredInitializationStyle = initializer ? initializationStyle + 1 : 0; |
Benjamin Kramer | 3b6bef9 | 2012-08-24 11:54:20 +0000 | [diff] [blame] | 116 | AllocateArgsArray(C, arraySize != 0, placementArgs.size(), initializer != 0); |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 117 | unsigned i = 0; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 118 | if (Array) { |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 119 | if (arraySize->isInstantiationDependent()) |
| 120 | ExprBits.InstantiationDependent = true; |
| 121 | |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 122 | if (arraySize->containsUnexpandedParameterPack()) |
| 123 | ExprBits.ContainsUnexpandedParameterPack = true; |
| 124 | |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 125 | SubExprs[i++] = arraySize; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 126 | } |
| 127 | |
Sebastian Redl | 2aed8b8 | 2012-02-16 12:22:20 +0000 | [diff] [blame] | 128 | if (initializer) { |
| 129 | if (initializer->isInstantiationDependent()) |
| 130 | ExprBits.InstantiationDependent = true; |
| 131 | |
| 132 | if (initializer->containsUnexpandedParameterPack()) |
| 133 | ExprBits.ContainsUnexpandedParameterPack = true; |
| 134 | |
| 135 | SubExprs[i++] = initializer; |
| 136 | } |
| 137 | |
Benjamin Kramer | 3b6bef9 | 2012-08-24 11:54:20 +0000 | [diff] [blame] | 138 | for (unsigned j = 0; j != placementArgs.size(); ++j) { |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 139 | if (placementArgs[j]->isInstantiationDependent()) |
| 140 | ExprBits.InstantiationDependent = true; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 141 | if (placementArgs[j]->containsUnexpandedParameterPack()) |
| 142 | ExprBits.ContainsUnexpandedParameterPack = true; |
| 143 | |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 144 | SubExprs[i++] = placementArgs[j]; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 145 | } |
David Blaikie | c2fc67e | 2012-11-08 22:53:48 +0000 | [diff] [blame] | 146 | |
| 147 | switch (getInitializationStyle()) { |
| 148 | case CallInit: |
| 149 | this->Range.setEnd(DirectInitRange.getEnd()); break; |
| 150 | case ListInit: |
| 151 | this->Range.setEnd(getInitializer()->getSourceRange().getEnd()); break; |
Eli Friedman | 6e40c95 | 2013-06-17 22:35:10 +0000 | [diff] [blame] | 152 | default: |
| 153 | if (TypeIdParens.isValid()) |
| 154 | this->Range.setEnd(TypeIdParens.getEnd()); |
| 155 | break; |
David Blaikie | c2fc67e | 2012-11-08 22:53:48 +0000 | [diff] [blame] | 156 | } |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 157 | } |
| 158 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 159 | void CXXNewExpr::AllocateArgsArray(const ASTContext &C, bool isArray, |
Sebastian Redl | 2aed8b8 | 2012-02-16 12:22:20 +0000 | [diff] [blame] | 160 | unsigned numPlaceArgs, bool hasInitializer){ |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 161 | assert(SubExprs == 0 && "SubExprs already allocated"); |
| 162 | Array = isArray; |
| 163 | NumPlacementArgs = numPlaceArgs; |
Sebastian Redl | 2aed8b8 | 2012-02-16 12:22:20 +0000 | [diff] [blame] | 164 | |
| 165 | unsigned TotalSize = Array + hasInitializer + NumPlacementArgs; |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 166 | SubExprs = new (C) Stmt*[TotalSize]; |
| 167 | } |
| 168 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 169 | bool CXXNewExpr::shouldNullCheckAllocation(const ASTContext &Ctx) const { |
John McCall | c2f3e7f | 2011-03-07 03:12:35 +0000 | [diff] [blame] | 170 | return getOperatorNew()->getType()-> |
Sebastian Redl | 8026f6d | 2011-03-13 17:09:40 +0000 | [diff] [blame] | 171 | castAs<FunctionProtoType>()->isNothrow(Ctx); |
John McCall | c2f3e7f | 2011-03-07 03:12:35 +0000 | [diff] [blame] | 172 | } |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 173 | |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 174 | // CXXDeleteExpr |
Douglas Gregor | 5833b0b | 2010-09-14 22:55:20 +0000 | [diff] [blame] | 175 | QualType CXXDeleteExpr::getDestroyedType() const { |
| 176 | const Expr *Arg = getArgument(); |
Craig Silverstein | 0fa0b78 | 2010-10-20 00:38:15 +0000 | [diff] [blame] | 177 | // 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] | 178 | const QualType ArgType = Arg->getType(); |
Craig Silverstein | a437ad3 | 2010-11-16 07:16:25 +0000 | [diff] [blame] | 179 | |
| 180 | if (ArgType->isDependentType() && !ArgType->isPointerType()) |
| 181 | return QualType(); |
Douglas Gregor | 5833b0b | 2010-09-14 22:55:20 +0000 | [diff] [blame] | 182 | |
Craig Silverstein | 0fa0b78 | 2010-10-20 00:38:15 +0000 | [diff] [blame] | 183 | return ArgType->getAs<PointerType>()->getPointeeType(); |
Douglas Gregor | 5833b0b | 2010-09-14 22:55:20 +0000 | [diff] [blame] | 184 | } |
| 185 | |
Douglas Gregor | a71d819 | 2009-09-04 17:36:40 +0000 | [diff] [blame] | 186 | // CXXPseudoDestructorExpr |
Douglas Gregor | a2e7dd2 | 2010-02-25 01:56:36 +0000 | [diff] [blame] | 187 | PseudoDestructorTypeStorage::PseudoDestructorTypeStorage(TypeSourceInfo *Info) |
| 188 | : Type(Info) |
| 189 | { |
Abramo Bagnara | bd054db | 2010-05-20 10:00:11 +0000 | [diff] [blame] | 190 | Location = Info->getTypeLoc().getLocalSourceRange().getBegin(); |
Douglas Gregor | a2e7dd2 | 2010-02-25 01:56:36 +0000 | [diff] [blame] | 191 | } |
| 192 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 193 | CXXPseudoDestructorExpr::CXXPseudoDestructorExpr(const ASTContext &Context, |
Douglas Gregor | f3db29f | 2011-02-25 18:19:59 +0000 | [diff] [blame] | 194 | Expr *Base, bool isArrow, SourceLocation OperatorLoc, |
| 195 | NestedNameSpecifierLoc QualifierLoc, TypeSourceInfo *ScopeType, |
| 196 | SourceLocation ColonColonLoc, SourceLocation TildeLoc, |
| 197 | PseudoDestructorTypeStorage DestroyedType) |
John McCall | e23cf43 | 2010-12-14 08:05:40 +0000 | [diff] [blame] | 198 | : Expr(CXXPseudoDestructorExprClass, |
Reid Kleckner | ef07203 | 2013-08-27 23:08:25 +0000 | [diff] [blame^] | 199 | Context.getPointerType(Context.getFunctionType( |
| 200 | Context.VoidTy, None, |
| 201 | FunctionProtoType::ExtProtoInfo( |
| 202 | Context.getDefaultCallingConvention(false, true)))), |
John McCall | e23cf43 | 2010-12-14 08:05:40 +0000 | [diff] [blame] | 203 | VK_RValue, OK_Ordinary, |
| 204 | /*isTypeDependent=*/(Base->isTypeDependent() || |
| 205 | (DestroyedType.getTypeSourceInfo() && |
| 206 | DestroyedType.getTypeSourceInfo()->getType()->isDependentType())), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 207 | /*isValueDependent=*/Base->isValueDependent(), |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 208 | (Base->isInstantiationDependent() || |
| 209 | (QualifierLoc && |
| 210 | QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent()) || |
| 211 | (ScopeType && |
| 212 | ScopeType->getType()->isInstantiationDependentType()) || |
| 213 | (DestroyedType.getTypeSourceInfo() && |
| 214 | DestroyedType.getTypeSourceInfo()->getType() |
| 215 | ->isInstantiationDependentType())), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 216 | // ContainsUnexpandedParameterPack |
| 217 | (Base->containsUnexpandedParameterPack() || |
Douglas Gregor | f3db29f | 2011-02-25 18:19:59 +0000 | [diff] [blame] | 218 | (QualifierLoc && |
| 219 | QualifierLoc.getNestedNameSpecifier() |
| 220 | ->containsUnexpandedParameterPack()) || |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 221 | (ScopeType && |
| 222 | ScopeType->getType()->containsUnexpandedParameterPack()) || |
| 223 | (DestroyedType.getTypeSourceInfo() && |
| 224 | DestroyedType.getTypeSourceInfo()->getType() |
| 225 | ->containsUnexpandedParameterPack()))), |
John McCall | e23cf43 | 2010-12-14 08:05:40 +0000 | [diff] [blame] | 226 | Base(static_cast<Stmt *>(Base)), IsArrow(isArrow), |
Douglas Gregor | f3db29f | 2011-02-25 18:19:59 +0000 | [diff] [blame] | 227 | OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc), |
John McCall | e23cf43 | 2010-12-14 08:05:40 +0000 | [diff] [blame] | 228 | ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc), |
| 229 | DestroyedType(DestroyedType) { } |
| 230 | |
Douglas Gregor | a2e7dd2 | 2010-02-25 01:56:36 +0000 | [diff] [blame] | 231 | QualType CXXPseudoDestructorExpr::getDestroyedType() const { |
| 232 | if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo()) |
| 233 | return TInfo->getType(); |
| 234 | |
| 235 | return QualType(); |
| 236 | } |
| 237 | |
Erik Verbruggen | 65d7831 | 2012-12-25 14:51:39 +0000 | [diff] [blame] | 238 | SourceLocation CXXPseudoDestructorExpr::getLocEnd() const { |
Douglas Gregor | a2e7dd2 | 2010-02-25 01:56:36 +0000 | [diff] [blame] | 239 | SourceLocation End = DestroyedType.getLocation(); |
| 240 | if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo()) |
Abramo Bagnara | bd054db | 2010-05-20 10:00:11 +0000 | [diff] [blame] | 241 | End = TInfo->getTypeLoc().getLocalSourceRange().getEnd(); |
Erik Verbruggen | 65d7831 | 2012-12-25 14:51:39 +0000 | [diff] [blame] | 242 | return End; |
Douglas Gregor | 26d4ac9 | 2010-02-24 23:40:28 +0000 | [diff] [blame] | 243 | } |
| 244 | |
John McCall | ba13543 | 2009-11-21 08:51:07 +0000 | [diff] [blame] | 245 | // UnresolvedLookupExpr |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 246 | UnresolvedLookupExpr * |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 247 | UnresolvedLookupExpr::Create(const ASTContext &C, |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 248 | CXXRecordDecl *NamingClass, |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 249 | NestedNameSpecifierLoc QualifierLoc, |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 250 | SourceLocation TemplateKWLoc, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 251 | const DeclarationNameInfo &NameInfo, |
| 252 | bool ADL, |
Abramo Bagnara | 9d9922a | 2012-02-06 14:31:00 +0000 | [diff] [blame] | 253 | const TemplateArgumentListInfo *Args, |
| 254 | UnresolvedSetIterator Begin, |
| 255 | UnresolvedSetIterator End) |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 256 | { |
Abramo Bagnara | 9d9922a | 2012-02-06 14:31:00 +0000 | [diff] [blame] | 257 | assert(Args || TemplateKWLoc.isValid()); |
| 258 | unsigned num_args = Args ? Args->size() : 0; |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 259 | void *Mem = C.Allocate(sizeof(UnresolvedLookupExpr) + |
Abramo Bagnara | 9d9922a | 2012-02-06 14:31:00 +0000 | [diff] [blame] | 260 | ASTTemplateKWAndArgsInfo::sizeFor(num_args)); |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 261 | return new (Mem) UnresolvedLookupExpr(C, NamingClass, QualifierLoc, |
| 262 | TemplateKWLoc, NameInfo, |
Abramo Bagnara | 9d9922a | 2012-02-06 14:31:00 +0000 | [diff] [blame] | 263 | ADL, /*Overload*/ true, Args, |
Richard Smith | b1502bc | 2012-10-18 17:56:02 +0000 | [diff] [blame] | 264 | Begin, End); |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 265 | } |
| 266 | |
Argyrios Kyrtzidis | bd65bb5 | 2010-06-25 09:03:34 +0000 | [diff] [blame] | 267 | UnresolvedLookupExpr * |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 268 | UnresolvedLookupExpr::CreateEmpty(const ASTContext &C, |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 269 | bool HasTemplateKWAndArgsInfo, |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 270 | unsigned NumTemplateArgs) { |
Argyrios Kyrtzidis | bd65bb5 | 2010-06-25 09:03:34 +0000 | [diff] [blame] | 271 | std::size_t size = sizeof(UnresolvedLookupExpr); |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 272 | if (HasTemplateKWAndArgsInfo) |
| 273 | size += ASTTemplateKWAndArgsInfo::sizeFor(NumTemplateArgs); |
Argyrios Kyrtzidis | bd65bb5 | 2010-06-25 09:03:34 +0000 | [diff] [blame] | 274 | |
Chris Lattner | 3248854 | 2010-10-30 05:14:06 +0000 | [diff] [blame] | 275 | void *Mem = C.Allocate(size, llvm::alignOf<UnresolvedLookupExpr>()); |
Argyrios Kyrtzidis | bd65bb5 | 2010-06-25 09:03:34 +0000 | [diff] [blame] | 276 | UnresolvedLookupExpr *E = new (Mem) UnresolvedLookupExpr(EmptyShell()); |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 277 | E->HasTemplateKWAndArgsInfo = HasTemplateKWAndArgsInfo; |
Argyrios Kyrtzidis | bd65bb5 | 2010-06-25 09:03:34 +0000 | [diff] [blame] | 278 | return E; |
| 279 | } |
| 280 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 281 | OverloadExpr::OverloadExpr(StmtClass K, const ASTContext &C, |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 282 | NestedNameSpecifierLoc QualifierLoc, |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 283 | SourceLocation TemplateKWLoc, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 284 | const DeclarationNameInfo &NameInfo, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 285 | const TemplateArgumentListInfo *TemplateArgs, |
Douglas Gregor | 928e6fc | 2010-05-23 19:36:40 +0000 | [diff] [blame] | 286 | UnresolvedSetIterator Begin, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 287 | UnresolvedSetIterator End, |
| 288 | bool KnownDependent, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 289 | bool KnownInstantiationDependent, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 290 | bool KnownContainsUnexpandedParameterPack) |
| 291 | : Expr(K, C.OverloadTy, VK_LValue, OK_Ordinary, KnownDependent, |
| 292 | KnownDependent, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 293 | (KnownInstantiationDependent || |
| 294 | NameInfo.isInstantiationDependent() || |
| 295 | (QualifierLoc && |
| 296 | QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 297 | (KnownContainsUnexpandedParameterPack || |
| 298 | NameInfo.containsUnexpandedParameterPack() || |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 299 | (QualifierLoc && |
| 300 | QualifierLoc.getNestedNameSpecifier() |
| 301 | ->containsUnexpandedParameterPack()))), |
Benjamin Kramer | d162cf1 | 2012-02-26 20:37:14 +0000 | [diff] [blame] | 302 | NameInfo(NameInfo), QualifierLoc(QualifierLoc), |
| 303 | Results(0), NumResults(End - Begin), |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 304 | HasTemplateKWAndArgsInfo(TemplateArgs != 0 || TemplateKWLoc.isValid()) |
Douglas Gregor | 928e6fc | 2010-05-23 19:36:40 +0000 | [diff] [blame] | 305 | { |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 306 | NumResults = End - Begin; |
| 307 | if (NumResults) { |
| 308 | // Determine whether this expression is type-dependent. |
| 309 | for (UnresolvedSetImpl::const_iterator I = Begin; I != End; ++I) { |
| 310 | if ((*I)->getDeclContext()->isDependentContext() || |
| 311 | isa<UnresolvedUsingValueDecl>(*I)) { |
| 312 | ExprBits.TypeDependent = true; |
| 313 | ExprBits.ValueDependent = true; |
Richard Smith | 7657fd7 | 2012-08-13 21:29:18 +0000 | [diff] [blame] | 314 | ExprBits.InstantiationDependent = true; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 315 | } |
| 316 | } |
| 317 | |
| 318 | Results = static_cast<DeclAccessPair *>( |
| 319 | C.Allocate(sizeof(DeclAccessPair) * NumResults, |
| 320 | llvm::alignOf<DeclAccessPair>())); |
| 321 | memcpy(Results, &*Begin.getIterator(), |
| 322 | NumResults * sizeof(DeclAccessPair)); |
| 323 | } |
| 324 | |
| 325 | // If we have explicit template arguments, check for dependent |
| 326 | // template arguments and whether they contain any unexpanded pack |
| 327 | // expansions. |
| 328 | if (TemplateArgs) { |
| 329 | bool Dependent = false; |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 330 | bool InstantiationDependent = false; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 331 | bool ContainsUnexpandedParameterPack = false; |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 332 | getTemplateKWAndArgsInfo()->initializeFrom(TemplateKWLoc, *TemplateArgs, |
| 333 | Dependent, |
| 334 | InstantiationDependent, |
| 335 | ContainsUnexpandedParameterPack); |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 336 | |
| 337 | if (Dependent) { |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 338 | ExprBits.TypeDependent = true; |
| 339 | ExprBits.ValueDependent = true; |
| 340 | } |
| 341 | if (InstantiationDependent) |
| 342 | ExprBits.InstantiationDependent = true; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 343 | if (ContainsUnexpandedParameterPack) |
| 344 | ExprBits.ContainsUnexpandedParameterPack = true; |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 345 | } else if (TemplateKWLoc.isValid()) { |
| 346 | getTemplateKWAndArgsInfo()->initializeFrom(TemplateKWLoc); |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | if (isTypeDependent()) |
| 350 | setType(C.DependentTy); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 351 | } |
| 352 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 353 | void OverloadExpr::initializeResults(const ASTContext &C, |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 354 | UnresolvedSetIterator Begin, |
| 355 | UnresolvedSetIterator End) { |
| 356 | assert(Results == 0 && "Results already initialized!"); |
| 357 | NumResults = End - Begin; |
Douglas Gregor | 928e6fc | 2010-05-23 19:36:40 +0000 | [diff] [blame] | 358 | if (NumResults) { |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 359 | Results = static_cast<DeclAccessPair *>( |
| 360 | C.Allocate(sizeof(DeclAccessPair) * NumResults, |
| 361 | |
| 362 | llvm::alignOf<DeclAccessPair>())); |
| 363 | memcpy(Results, &*Begin.getIterator(), |
| 364 | NumResults * sizeof(DeclAccessPair)); |
Douglas Gregor | 928e6fc | 2010-05-23 19:36:40 +0000 | [diff] [blame] | 365 | } |
| 366 | } |
| 367 | |
John McCall | e9ee23e | 2010-04-22 18:44:12 +0000 | [diff] [blame] | 368 | CXXRecordDecl *OverloadExpr::getNamingClass() const { |
| 369 | if (isa<UnresolvedLookupExpr>(this)) |
| 370 | return cast<UnresolvedLookupExpr>(this)->getNamingClass(); |
| 371 | else |
| 372 | return cast<UnresolvedMemberExpr>(this)->getNamingClass(); |
| 373 | } |
| 374 | |
John McCall | 865d447 | 2009-11-19 22:55:06 +0000 | [diff] [blame] | 375 | // DependentScopeDeclRefExpr |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 376 | DependentScopeDeclRefExpr::DependentScopeDeclRefExpr(QualType T, |
Douglas Gregor | 00cf3cc | 2011-02-25 20:49:16 +0000 | [diff] [blame] | 377 | NestedNameSpecifierLoc QualifierLoc, |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 378 | SourceLocation TemplateKWLoc, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 379 | const DeclarationNameInfo &NameInfo, |
| 380 | const TemplateArgumentListInfo *Args) |
| 381 | : Expr(DependentScopeDeclRefExprClass, T, VK_LValue, OK_Ordinary, |
| 382 | true, true, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 383 | (NameInfo.isInstantiationDependent() || |
| 384 | (QualifierLoc && |
| 385 | QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 386 | (NameInfo.containsUnexpandedParameterPack() || |
Douglas Gregor | 00cf3cc | 2011-02-25 20:49:16 +0000 | [diff] [blame] | 387 | (QualifierLoc && |
| 388 | QualifierLoc.getNestedNameSpecifier() |
| 389 | ->containsUnexpandedParameterPack()))), |
| 390 | QualifierLoc(QualifierLoc), NameInfo(NameInfo), |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 391 | HasTemplateKWAndArgsInfo(Args != 0 || TemplateKWLoc.isValid()) |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 392 | { |
| 393 | if (Args) { |
| 394 | bool Dependent = true; |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 395 | bool InstantiationDependent = true; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 396 | bool ContainsUnexpandedParameterPack |
| 397 | = ExprBits.ContainsUnexpandedParameterPack; |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 398 | getTemplateKWAndArgsInfo()->initializeFrom(TemplateKWLoc, *Args, |
| 399 | Dependent, |
| 400 | InstantiationDependent, |
| 401 | ContainsUnexpandedParameterPack); |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 402 | ExprBits.ContainsUnexpandedParameterPack = ContainsUnexpandedParameterPack; |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 403 | } else if (TemplateKWLoc.isValid()) { |
| 404 | getTemplateKWAndArgsInfo()->initializeFrom(TemplateKWLoc); |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 405 | } |
| 406 | } |
| 407 | |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 408 | DependentScopeDeclRefExpr * |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 409 | DependentScopeDeclRefExpr::Create(const ASTContext &C, |
Douglas Gregor | 00cf3cc | 2011-02-25 20:49:16 +0000 | [diff] [blame] | 410 | NestedNameSpecifierLoc QualifierLoc, |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 411 | SourceLocation TemplateKWLoc, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 412 | const DeclarationNameInfo &NameInfo, |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 413 | const TemplateArgumentListInfo *Args) { |
| 414 | std::size_t size = sizeof(DependentScopeDeclRefExpr); |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 415 | if (Args) |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 416 | size += ASTTemplateKWAndArgsInfo::sizeFor(Args->size()); |
| 417 | else if (TemplateKWLoc.isValid()) |
| 418 | size += ASTTemplateKWAndArgsInfo::sizeFor(0); |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 419 | void *Mem = C.Allocate(size); |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 420 | return new (Mem) DependentScopeDeclRefExpr(C.DependentTy, QualifierLoc, |
| 421 | TemplateKWLoc, NameInfo, Args); |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 422 | } |
| 423 | |
Argyrios Kyrtzidis | 12dffcd | 2010-06-28 09:31:56 +0000 | [diff] [blame] | 424 | DependentScopeDeclRefExpr * |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 425 | DependentScopeDeclRefExpr::CreateEmpty(const ASTContext &C, |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 426 | bool HasTemplateKWAndArgsInfo, |
Argyrios Kyrtzidis | 12dffcd | 2010-06-28 09:31:56 +0000 | [diff] [blame] | 427 | unsigned NumTemplateArgs) { |
| 428 | std::size_t size = sizeof(DependentScopeDeclRefExpr); |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 429 | if (HasTemplateKWAndArgsInfo) |
| 430 | size += ASTTemplateKWAndArgsInfo::sizeFor(NumTemplateArgs); |
Argyrios Kyrtzidis | 12dffcd | 2010-06-28 09:31:56 +0000 | [diff] [blame] | 431 | void *Mem = C.Allocate(size); |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 432 | DependentScopeDeclRefExpr *E |
Douglas Gregor | 00cf3cc | 2011-02-25 20:49:16 +0000 | [diff] [blame] | 433 | = new (Mem) DependentScopeDeclRefExpr(QualType(), NestedNameSpecifierLoc(), |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 434 | SourceLocation(), |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 435 | DeclarationNameInfo(), 0); |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 436 | E->HasTemplateKWAndArgsInfo = HasTemplateKWAndArgsInfo; |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 437 | return E; |
Argyrios Kyrtzidis | 12dffcd | 2010-06-28 09:31:56 +0000 | [diff] [blame] | 438 | } |
| 439 | |
Erik Verbruggen | 65d7831 | 2012-12-25 14:51:39 +0000 | [diff] [blame] | 440 | SourceLocation CXXConstructExpr::getLocStart() const { |
John McCall | 2882eca | 2011-02-21 06:23:05 +0000 | [diff] [blame] | 441 | if (isa<CXXTemporaryObjectExpr>(this)) |
Erik Verbruggen | 65d7831 | 2012-12-25 14:51:39 +0000 | [diff] [blame] | 442 | return cast<CXXTemporaryObjectExpr>(this)->getLocStart(); |
| 443 | return Loc; |
| 444 | } |
| 445 | |
| 446 | SourceLocation CXXConstructExpr::getLocEnd() const { |
| 447 | if (isa<CXXTemporaryObjectExpr>(this)) |
| 448 | return cast<CXXTemporaryObjectExpr>(this)->getLocEnd(); |
John McCall | 2882eca | 2011-02-21 06:23:05 +0000 | [diff] [blame] | 449 | |
Douglas Gregor | 40749ee | 2010-11-03 00:35:38 +0000 | [diff] [blame] | 450 | if (ParenRange.isValid()) |
Erik Verbruggen | 65d7831 | 2012-12-25 14:51:39 +0000 | [diff] [blame] | 451 | return ParenRange.getEnd(); |
Douglas Gregor | 40749ee | 2010-11-03 00:35:38 +0000 | [diff] [blame] | 452 | |
| 453 | SourceLocation End = Loc; |
| 454 | for (unsigned I = getNumArgs(); I > 0; --I) { |
| 455 | const Expr *Arg = getArg(I-1); |
| 456 | if (!Arg->isDefaultArgument()) { |
| 457 | SourceLocation NewEnd = Arg->getLocEnd(); |
| 458 | if (NewEnd.isValid()) { |
| 459 | End = NewEnd; |
| 460 | break; |
| 461 | } |
| 462 | } |
| 463 | } |
| 464 | |
Erik Verbruggen | 65d7831 | 2012-12-25 14:51:39 +0000 | [diff] [blame] | 465 | return End; |
Ted Kremenek | e383768 | 2009-12-23 04:00:48 +0000 | [diff] [blame] | 466 | } |
| 467 | |
Argyrios Kyrtzidis | 4548ca2 | 2012-04-30 22:12:22 +0000 | [diff] [blame] | 468 | SourceRange CXXOperatorCallExpr::getSourceRangeImpl() const { |
Douglas Gregor | b460980 | 2008-11-14 16:09:21 +0000 | [diff] [blame] | 469 | OverloadedOperatorKind Kind = getOperator(); |
| 470 | if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) { |
| 471 | if (getNumArgs() == 1) |
| 472 | // Prefix operator |
Argyrios Kyrtzidis | 3539b0c | 2012-05-01 22:19:11 +0000 | [diff] [blame] | 473 | return SourceRange(getOperatorLoc(), getArg(0)->getLocEnd()); |
Douglas Gregor | b460980 | 2008-11-14 16:09:21 +0000 | [diff] [blame] | 474 | else |
| 475 | // Postfix operator |
Argyrios Kyrtzidis | 3539b0c | 2012-05-01 22:19:11 +0000 | [diff] [blame] | 476 | return SourceRange(getArg(0)->getLocStart(), getOperatorLoc()); |
Chandler Carruth | d765061 | 2011-04-02 09:47:38 +0000 | [diff] [blame] | 477 | } else if (Kind == OO_Arrow) { |
| 478 | return getArg(0)->getSourceRange(); |
Douglas Gregor | b460980 | 2008-11-14 16:09:21 +0000 | [diff] [blame] | 479 | } else if (Kind == OO_Call) { |
Argyrios Kyrtzidis | 3539b0c | 2012-05-01 22:19:11 +0000 | [diff] [blame] | 480 | return SourceRange(getArg(0)->getLocStart(), getRParenLoc()); |
Douglas Gregor | b460980 | 2008-11-14 16:09:21 +0000 | [diff] [blame] | 481 | } else if (Kind == OO_Subscript) { |
Argyrios Kyrtzidis | 3539b0c | 2012-05-01 22:19:11 +0000 | [diff] [blame] | 482 | return SourceRange(getArg(0)->getLocStart(), getRParenLoc()); |
Douglas Gregor | b460980 | 2008-11-14 16:09:21 +0000 | [diff] [blame] | 483 | } else if (getNumArgs() == 1) { |
Argyrios Kyrtzidis | 3539b0c | 2012-05-01 22:19:11 +0000 | [diff] [blame] | 484 | return SourceRange(getOperatorLoc(), getArg(0)->getLocEnd()); |
Douglas Gregor | b460980 | 2008-11-14 16:09:21 +0000 | [diff] [blame] | 485 | } else if (getNumArgs() == 2) { |
Argyrios Kyrtzidis | 3539b0c | 2012-05-01 22:19:11 +0000 | [diff] [blame] | 486 | return SourceRange(getArg(0)->getLocStart(), getArg(1)->getLocEnd()); |
Douglas Gregor | b460980 | 2008-11-14 16:09:21 +0000 | [diff] [blame] | 487 | } else { |
Argyrios Kyrtzidis | 4548ca2 | 2012-04-30 22:12:22 +0000 | [diff] [blame] | 488 | return getOperatorLoc(); |
Douglas Gregor | b460980 | 2008-11-14 16:09:21 +0000 | [diff] [blame] | 489 | } |
| 490 | } |
| 491 | |
Ted Kremenek | b277159 | 2011-03-30 17:41:19 +0000 | [diff] [blame] | 492 | Expr *CXXMemberCallExpr::getImplicitObjectArgument() const { |
Jordan Rose | 51e87c5 | 2012-08-03 23:08:39 +0000 | [diff] [blame] | 493 | const Expr *Callee = getCallee()->IgnoreParens(); |
| 494 | if (const MemberExpr *MemExpr = dyn_cast<MemberExpr>(Callee)) |
Douglas Gregor | 88a3514 | 2008-12-22 05:46:06 +0000 | [diff] [blame] | 495 | return MemExpr->getBase(); |
Jordan Rose | 51e87c5 | 2012-08-03 23:08:39 +0000 | [diff] [blame] | 496 | if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(Callee)) |
| 497 | if (BO->getOpcode() == BO_PtrMemD || BO->getOpcode() == BO_PtrMemI) |
| 498 | return BO->getLHS(); |
Douglas Gregor | 88a3514 | 2008-12-22 05:46:06 +0000 | [diff] [blame] | 499 | |
| 500 | // FIXME: Will eventually need to cope with member pointers. |
| 501 | return 0; |
| 502 | } |
| 503 | |
Ted Kremenek | b277159 | 2011-03-30 17:41:19 +0000 | [diff] [blame] | 504 | CXXMethodDecl *CXXMemberCallExpr::getMethodDecl() const { |
| 505 | if (const MemberExpr *MemExpr = |
| 506 | dyn_cast<MemberExpr>(getCallee()->IgnoreParens())) |
| 507 | return cast<CXXMethodDecl>(MemExpr->getMemberDecl()); |
| 508 | |
| 509 | // FIXME: Will eventually need to cope with member pointers. |
| 510 | return 0; |
| 511 | } |
| 512 | |
| 513 | |
David Blaikie | 0cf3c0e | 2012-05-03 16:25:49 +0000 | [diff] [blame] | 514 | CXXRecordDecl *CXXMemberCallExpr::getRecordDecl() const { |
Chandler Carruth | 007a9b1 | 2010-10-27 06:55:41 +0000 | [diff] [blame] | 515 | Expr* ThisArg = getImplicitObjectArgument(); |
| 516 | if (!ThisArg) |
| 517 | return 0; |
| 518 | |
| 519 | if (ThisArg->getType()->isAnyPointerType()) |
| 520 | return ThisArg->getType()->getPointeeType()->getAsCXXRecordDecl(); |
| 521 | |
| 522 | return ThisArg->getType()->getAsCXXRecordDecl(); |
| 523 | } |
| 524 | |
Douglas Gregor | 00b98c2 | 2009-11-12 15:31:47 +0000 | [diff] [blame] | 525 | |
Douglas Gregor | 49badde | 2008-10-27 19:41:14 +0000 | [diff] [blame] | 526 | //===----------------------------------------------------------------------===// |
| 527 | // Named casts |
| 528 | //===----------------------------------------------------------------------===// |
| 529 | |
| 530 | /// getCastName - Get the name of the C++ cast being used, e.g., |
| 531 | /// "static_cast", "dynamic_cast", "reinterpret_cast", or |
| 532 | /// "const_cast". The returned pointer must not be freed. |
| 533 | const char *CXXNamedCastExpr::getCastName() const { |
| 534 | switch (getStmtClass()) { |
| 535 | case CXXStaticCastExprClass: return "static_cast"; |
| 536 | case CXXDynamicCastExprClass: return "dynamic_cast"; |
| 537 | case CXXReinterpretCastExprClass: return "reinterpret_cast"; |
| 538 | case CXXConstCastExprClass: return "const_cast"; |
| 539 | default: return "<invalid cast>"; |
| 540 | } |
| 541 | } |
Douglas Gregor | 506ae41 | 2009-01-16 18:33:17 +0000 | [diff] [blame] | 542 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 543 | CXXStaticCastExpr *CXXStaticCastExpr::Create(const ASTContext &C, QualType T, |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 544 | ExprValueKind VK, |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 545 | CastKind K, Expr *Op, |
| 546 | const CXXCastPath *BasePath, |
| 547 | TypeSourceInfo *WrittenTy, |
Douglas Gregor | 1d5d0b9 | 2011-01-12 22:41:29 +0000 | [diff] [blame] | 548 | SourceLocation L, |
Fariborz Jahanian | f799ae1 | 2013-02-22 22:02:53 +0000 | [diff] [blame] | 549 | SourceLocation RParenLoc, |
| 550 | SourceRange AngleBrackets) { |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 551 | unsigned PathSize = (BasePath ? BasePath->size() : 0); |
| 552 | void *Buffer = C.Allocate(sizeof(CXXStaticCastExpr) |
| 553 | + PathSize * sizeof(CXXBaseSpecifier*)); |
| 554 | CXXStaticCastExpr *E = |
Douglas Gregor | 1d5d0b9 | 2011-01-12 22:41:29 +0000 | [diff] [blame] | 555 | new (Buffer) CXXStaticCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, |
Fariborz Jahanian | f799ae1 | 2013-02-22 22:02:53 +0000 | [diff] [blame] | 556 | RParenLoc, AngleBrackets); |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 557 | if (PathSize) E->setCastPath(*BasePath); |
| 558 | return E; |
| 559 | } |
| 560 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 561 | CXXStaticCastExpr *CXXStaticCastExpr::CreateEmpty(const ASTContext &C, |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 562 | unsigned PathSize) { |
| 563 | void *Buffer = |
| 564 | C.Allocate(sizeof(CXXStaticCastExpr) + PathSize * sizeof(CXXBaseSpecifier*)); |
| 565 | return new (Buffer) CXXStaticCastExpr(EmptyShell(), PathSize); |
| 566 | } |
| 567 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 568 | CXXDynamicCastExpr *CXXDynamicCastExpr::Create(const ASTContext &C, QualType T, |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 569 | ExprValueKind VK, |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 570 | CastKind K, Expr *Op, |
| 571 | const CXXCastPath *BasePath, |
| 572 | TypeSourceInfo *WrittenTy, |
Douglas Gregor | 1d5d0b9 | 2011-01-12 22:41:29 +0000 | [diff] [blame] | 573 | SourceLocation L, |
Fariborz Jahanian | f799ae1 | 2013-02-22 22:02:53 +0000 | [diff] [blame] | 574 | SourceLocation RParenLoc, |
| 575 | SourceRange AngleBrackets) { |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 576 | unsigned PathSize = (BasePath ? BasePath->size() : 0); |
| 577 | void *Buffer = C.Allocate(sizeof(CXXDynamicCastExpr) |
| 578 | + PathSize * sizeof(CXXBaseSpecifier*)); |
| 579 | CXXDynamicCastExpr *E = |
Douglas Gregor | 1d5d0b9 | 2011-01-12 22:41:29 +0000 | [diff] [blame] | 580 | new (Buffer) CXXDynamicCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, |
Fariborz Jahanian | f799ae1 | 2013-02-22 22:02:53 +0000 | [diff] [blame] | 581 | RParenLoc, AngleBrackets); |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 582 | if (PathSize) E->setCastPath(*BasePath); |
| 583 | return E; |
| 584 | } |
| 585 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 586 | CXXDynamicCastExpr *CXXDynamicCastExpr::CreateEmpty(const ASTContext &C, |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 587 | unsigned PathSize) { |
| 588 | void *Buffer = |
| 589 | C.Allocate(sizeof(CXXDynamicCastExpr) + PathSize * sizeof(CXXBaseSpecifier*)); |
| 590 | return new (Buffer) CXXDynamicCastExpr(EmptyShell(), PathSize); |
| 591 | } |
| 592 | |
Anders Carlsson | 0fee330 | 2011-04-11 01:43:55 +0000 | [diff] [blame] | 593 | /// isAlwaysNull - Return whether the result of the dynamic_cast is proven |
| 594 | /// to always be null. For example: |
| 595 | /// |
| 596 | /// struct A { }; |
| 597 | /// struct B final : A { }; |
| 598 | /// struct C { }; |
| 599 | /// |
| 600 | /// C *f(B* b) { return dynamic_cast<C*>(b); } |
| 601 | bool CXXDynamicCastExpr::isAlwaysNull() const |
| 602 | { |
| 603 | QualType SrcType = getSubExpr()->getType(); |
| 604 | QualType DestType = getType(); |
| 605 | |
| 606 | if (const PointerType *SrcPTy = SrcType->getAs<PointerType>()) { |
| 607 | SrcType = SrcPTy->getPointeeType(); |
| 608 | DestType = DestType->castAs<PointerType>()->getPointeeType(); |
| 609 | } |
| 610 | |
Sean Hunt | 5ca8639 | 2012-06-19 23:44:55 +0000 | [diff] [blame] | 611 | if (DestType->isVoidType()) |
| 612 | return false; |
| 613 | |
Anders Carlsson | 0fee330 | 2011-04-11 01:43:55 +0000 | [diff] [blame] | 614 | const CXXRecordDecl *SrcRD = |
| 615 | cast<CXXRecordDecl>(SrcType->castAs<RecordType>()->getDecl()); |
| 616 | |
Jakob Stoklund Olesen | 3532936 | 2012-06-19 21:48:43 +0000 | [diff] [blame] | 617 | if (!SrcRD->hasAttr<FinalAttr>()) |
| 618 | return false; |
| 619 | |
Anders Carlsson | 0fee330 | 2011-04-11 01:43:55 +0000 | [diff] [blame] | 620 | const CXXRecordDecl *DestRD = |
| 621 | cast<CXXRecordDecl>(DestType->castAs<RecordType>()->getDecl()); |
| 622 | |
| 623 | return !DestRD->isDerivedFrom(SrcRD); |
| 624 | } |
| 625 | |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 626 | CXXReinterpretCastExpr * |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 627 | CXXReinterpretCastExpr::Create(const ASTContext &C, QualType T, |
| 628 | ExprValueKind VK, CastKind K, Expr *Op, |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 629 | const CXXCastPath *BasePath, |
Douglas Gregor | 1d5d0b9 | 2011-01-12 22:41:29 +0000 | [diff] [blame] | 630 | TypeSourceInfo *WrittenTy, SourceLocation L, |
Fariborz Jahanian | f799ae1 | 2013-02-22 22:02:53 +0000 | [diff] [blame] | 631 | SourceLocation RParenLoc, |
| 632 | SourceRange AngleBrackets) { |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 633 | unsigned PathSize = (BasePath ? BasePath->size() : 0); |
| 634 | void *Buffer = |
| 635 | C.Allocate(sizeof(CXXReinterpretCastExpr) + PathSize * sizeof(CXXBaseSpecifier*)); |
| 636 | CXXReinterpretCastExpr *E = |
Douglas Gregor | 1d5d0b9 | 2011-01-12 22:41:29 +0000 | [diff] [blame] | 637 | new (Buffer) CXXReinterpretCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, |
Fariborz Jahanian | f799ae1 | 2013-02-22 22:02:53 +0000 | [diff] [blame] | 638 | RParenLoc, AngleBrackets); |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 639 | if (PathSize) E->setCastPath(*BasePath); |
| 640 | return E; |
| 641 | } |
| 642 | |
| 643 | CXXReinterpretCastExpr * |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 644 | CXXReinterpretCastExpr::CreateEmpty(const ASTContext &C, unsigned PathSize) { |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 645 | void *Buffer = C.Allocate(sizeof(CXXReinterpretCastExpr) |
| 646 | + PathSize * sizeof(CXXBaseSpecifier*)); |
| 647 | return new (Buffer) CXXReinterpretCastExpr(EmptyShell(), PathSize); |
| 648 | } |
| 649 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 650 | CXXConstCastExpr *CXXConstCastExpr::Create(const ASTContext &C, QualType T, |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 651 | ExprValueKind VK, Expr *Op, |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 652 | TypeSourceInfo *WrittenTy, |
Douglas Gregor | 1d5d0b9 | 2011-01-12 22:41:29 +0000 | [diff] [blame] | 653 | SourceLocation L, |
Fariborz Jahanian | f799ae1 | 2013-02-22 22:02:53 +0000 | [diff] [blame] | 654 | SourceLocation RParenLoc, |
| 655 | SourceRange AngleBrackets) { |
| 656 | return new (C) CXXConstCastExpr(T, VK, Op, WrittenTy, L, RParenLoc, AngleBrackets); |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 657 | } |
| 658 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 659 | CXXConstCastExpr *CXXConstCastExpr::CreateEmpty(const ASTContext &C) { |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 660 | return new (C) CXXConstCastExpr(EmptyShell()); |
| 661 | } |
| 662 | |
| 663 | CXXFunctionalCastExpr * |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 664 | CXXFunctionalCastExpr::Create(const ASTContext &C, QualType T, ExprValueKind VK, |
Eli Friedman | cdd4b78 | 2013-08-15 22:02:56 +0000 | [diff] [blame] | 665 | TypeSourceInfo *Written, CastKind K, Expr *Op, |
| 666 | const CXXCastPath *BasePath, |
| 667 | SourceLocation L, SourceLocation R) { |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 668 | unsigned PathSize = (BasePath ? BasePath->size() : 0); |
| 669 | void *Buffer = C.Allocate(sizeof(CXXFunctionalCastExpr) |
| 670 | + PathSize * sizeof(CXXBaseSpecifier*)); |
| 671 | CXXFunctionalCastExpr *E = |
Eli Friedman | cdd4b78 | 2013-08-15 22:02:56 +0000 | [diff] [blame] | 672 | new (Buffer) CXXFunctionalCastExpr(T, VK, Written, K, Op, PathSize, L, R); |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 673 | if (PathSize) E->setCastPath(*BasePath); |
| 674 | return E; |
| 675 | } |
| 676 | |
| 677 | CXXFunctionalCastExpr * |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 678 | CXXFunctionalCastExpr::CreateEmpty(const ASTContext &C, unsigned PathSize) { |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 679 | void *Buffer = C.Allocate(sizeof(CXXFunctionalCastExpr) |
| 680 | + PathSize * sizeof(CXXBaseSpecifier*)); |
| 681 | return new (Buffer) CXXFunctionalCastExpr(EmptyShell(), PathSize); |
| 682 | } |
| 683 | |
Eli Friedman | cdd4b78 | 2013-08-15 22:02:56 +0000 | [diff] [blame] | 684 | SourceLocation CXXFunctionalCastExpr::getLocStart() const { |
| 685 | return getTypeInfoAsWritten()->getTypeLoc().getLocStart(); |
| 686 | } |
| 687 | |
| 688 | SourceLocation CXXFunctionalCastExpr::getLocEnd() const { |
| 689 | return RParenLoc.isValid() ? RParenLoc : getSubExpr()->getLocEnd(); |
| 690 | } |
| 691 | |
Richard Smith | 9fcce65 | 2012-03-07 08:35:16 +0000 | [diff] [blame] | 692 | UserDefinedLiteral::LiteralOperatorKind |
| 693 | UserDefinedLiteral::getLiteralOperatorKind() const { |
| 694 | if (getNumArgs() == 0) |
| 695 | return LOK_Template; |
| 696 | if (getNumArgs() == 2) |
| 697 | return LOK_String; |
| 698 | |
| 699 | assert(getNumArgs() == 1 && "unexpected #args in literal operator call"); |
| 700 | QualType ParamTy = |
| 701 | cast<FunctionDecl>(getCalleeDecl())->getParamDecl(0)->getType(); |
| 702 | if (ParamTy->isPointerType()) |
| 703 | return LOK_Raw; |
| 704 | if (ParamTy->isAnyCharacterType()) |
| 705 | return LOK_Character; |
| 706 | if (ParamTy->isIntegerType()) |
| 707 | return LOK_Integer; |
| 708 | if (ParamTy->isFloatingType()) |
| 709 | return LOK_Floating; |
| 710 | |
| 711 | llvm_unreachable("unknown kind of literal operator"); |
| 712 | } |
| 713 | |
| 714 | Expr *UserDefinedLiteral::getCookedLiteral() { |
| 715 | #ifndef NDEBUG |
| 716 | LiteralOperatorKind LOK = getLiteralOperatorKind(); |
| 717 | assert(LOK != LOK_Template && LOK != LOK_Raw && "not a cooked literal"); |
| 718 | #endif |
| 719 | return getArg(0); |
| 720 | } |
| 721 | |
| 722 | const IdentifierInfo *UserDefinedLiteral::getUDSuffix() const { |
| 723 | return cast<FunctionDecl>(getCalleeDecl())->getLiteralIdentifier(); |
| 724 | } |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 725 | |
Douglas Gregor | 65222e8 | 2009-12-23 18:19:08 +0000 | [diff] [blame] | 726 | CXXDefaultArgExpr * |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 727 | CXXDefaultArgExpr::Create(const ASTContext &C, SourceLocation Loc, |
Douglas Gregor | 036aed1 | 2009-12-23 23:03:06 +0000 | [diff] [blame] | 728 | ParmVarDecl *Param, Expr *SubExpr) { |
Douglas Gregor | 65222e8 | 2009-12-23 18:19:08 +0000 | [diff] [blame] | 729 | void *Mem = C.Allocate(sizeof(CXXDefaultArgExpr) + sizeof(Stmt *)); |
Douglas Gregor | 036aed1 | 2009-12-23 23:03:06 +0000 | [diff] [blame] | 730 | return new (Mem) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param, |
| 731 | SubExpr); |
Douglas Gregor | 65222e8 | 2009-12-23 18:19:08 +0000 | [diff] [blame] | 732 | } |
| 733 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 734 | CXXDefaultInitExpr::CXXDefaultInitExpr(const ASTContext &C, SourceLocation Loc, |
Richard Smith | c3bf52c | 2013-04-20 22:23:05 +0000 | [diff] [blame] | 735 | FieldDecl *Field, QualType T) |
| 736 | : Expr(CXXDefaultInitExprClass, T.getNonLValueExprType(C), |
| 737 | T->isLValueReferenceType() ? VK_LValue : T->isRValueReferenceType() |
| 738 | ? VK_XValue |
| 739 | : VK_RValue, |
| 740 | /*FIXME*/ OK_Ordinary, false, false, false, false), |
| 741 | Field(Field), Loc(Loc) { |
| 742 | assert(Field->hasInClassInitializer()); |
| 743 | } |
| 744 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 745 | CXXTemporary *CXXTemporary::Create(const ASTContext &C, |
Anders Carlsson | b859f35 | 2009-05-30 20:34:37 +0000 | [diff] [blame] | 746 | const CXXDestructorDecl *Destructor) { |
Anders Carlsson | 88eaf07 | 2009-05-30 22:38:53 +0000 | [diff] [blame] | 747 | return new (C) CXXTemporary(Destructor); |
| 748 | } |
| 749 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 750 | CXXBindTemporaryExpr *CXXBindTemporaryExpr::Create(const ASTContext &C, |
Anders Carlsson | fceb0a8 | 2009-05-30 20:03:25 +0000 | [diff] [blame] | 751 | CXXTemporary *Temp, |
| 752 | Expr* SubExpr) { |
Peter Collingbourne | bceb755 | 2011-11-27 22:09:28 +0000 | [diff] [blame] | 753 | assert((SubExpr->getType()->isRecordType() || |
| 754 | SubExpr->getType()->isArrayType()) && |
| 755 | "Expression bound to a temporary must have record or array type!"); |
Anders Carlsson | fceb0a8 | 2009-05-30 20:03:25 +0000 | [diff] [blame] | 756 | |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 757 | return new (C) CXXBindTemporaryExpr(Temp, SubExpr); |
Anders Carlsson | fceb0a8 | 2009-05-30 20:03:25 +0000 | [diff] [blame] | 758 | } |
| 759 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 760 | CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(const ASTContext &C, |
Anders Carlsson | 26de549 | 2009-04-24 05:23:13 +0000 | [diff] [blame] | 761 | CXXConstructorDecl *Cons, |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 762 | TypeSourceInfo *Type, |
Benjamin Kramer | 3b6bef9 | 2012-08-24 11:54:20 +0000 | [diff] [blame] | 763 | ArrayRef<Expr*> Args, |
Chandler Carruth | 428edaf | 2010-10-25 08:47:36 +0000 | [diff] [blame] | 764 | SourceRange parenRange, |
Abramo Bagnara | 7cc58b4 | 2011-10-05 07:56:41 +0000 | [diff] [blame] | 765 | bool HadMultipleCandidates, |
Richard Smith | c83c230 | 2012-12-19 01:39:02 +0000 | [diff] [blame] | 766 | bool ListInitialization, |
Douglas Gregor | 1c63b9c | 2010-04-27 20:36:09 +0000 | [diff] [blame] | 767 | bool ZeroInitialization) |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 768 | : CXXConstructExpr(C, CXXTemporaryObjectExprClass, |
| 769 | Type->getType().getNonReferenceType(), |
| 770 | Type->getTypeLoc().getBeginLoc(), |
Benjamin Kramer | 3b6bef9 | 2012-08-24 11:54:20 +0000 | [diff] [blame] | 771 | Cons, false, Args, |
Richard Smith | c83c230 | 2012-12-19 01:39:02 +0000 | [diff] [blame] | 772 | HadMultipleCandidates, |
| 773 | ListInitialization, ZeroInitialization, |
Chandler Carruth | 428edaf | 2010-10-25 08:47:36 +0000 | [diff] [blame] | 774 | CXXConstructExpr::CK_Complete, parenRange), |
| 775 | Type(Type) { |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 776 | } |
| 777 | |
Erik Verbruggen | 65d7831 | 2012-12-25 14:51:39 +0000 | [diff] [blame] | 778 | SourceLocation CXXTemporaryObjectExpr::getLocStart() const { |
| 779 | return Type->getTypeLoc().getBeginLoc(); |
| 780 | } |
| 781 | |
| 782 | SourceLocation CXXTemporaryObjectExpr::getLocEnd() const { |
| 783 | return getParenRange().getEnd(); |
Douglas Gregor | 506ae41 | 2009-01-16 18:33:17 +0000 | [diff] [blame] | 784 | } |
Anders Carlsson | 19d28a6 | 2009-04-21 02:22:11 +0000 | [diff] [blame] | 785 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 786 | CXXConstructExpr *CXXConstructExpr::Create(const ASTContext &C, QualType T, |
Douglas Gregor | 99a2e60 | 2009-12-16 01:38:02 +0000 | [diff] [blame] | 787 | SourceLocation Loc, |
Anders Carlsson | 8e587a1 | 2009-05-30 20:56:46 +0000 | [diff] [blame] | 788 | CXXConstructorDecl *D, bool Elidable, |
Benjamin Kramer | 3b6bef9 | 2012-08-24 11:54:20 +0000 | [diff] [blame] | 789 | ArrayRef<Expr*> Args, |
Abramo Bagnara | 7cc58b4 | 2011-10-05 07:56:41 +0000 | [diff] [blame] | 790 | bool HadMultipleCandidates, |
Sebastian Redl | 5b9cc5d | 2012-02-11 23:51:47 +0000 | [diff] [blame] | 791 | bool ListInitialization, |
Douglas Gregor | 9db7dbb | 2010-01-31 09:12:51 +0000 | [diff] [blame] | 792 | bool ZeroInitialization, |
Chandler Carruth | 428edaf | 2010-10-25 08:47:36 +0000 | [diff] [blame] | 793 | ConstructionKind ConstructKind, |
| 794 | SourceRange ParenRange) { |
Douglas Gregor | 99a2e60 | 2009-12-16 01:38:02 +0000 | [diff] [blame] | 795 | return new (C) CXXConstructExpr(C, CXXConstructExprClass, T, Loc, D, |
Benjamin Kramer | 3b6bef9 | 2012-08-24 11:54:20 +0000 | [diff] [blame] | 796 | Elidable, Args, |
Sebastian Redl | 5b9cc5d | 2012-02-11 23:51:47 +0000 | [diff] [blame] | 797 | HadMultipleCandidates, ListInitialization, |
| 798 | ZeroInitialization, ConstructKind, |
| 799 | ParenRange); |
Anders Carlsson | e349bea | 2009-04-23 02:32:43 +0000 | [diff] [blame] | 800 | } |
| 801 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 802 | CXXConstructExpr::CXXConstructExpr(const ASTContext &C, StmtClass SC, |
| 803 | QualType T, SourceLocation Loc, |
Anders Carlsson | 8e587a1 | 2009-05-30 20:56:46 +0000 | [diff] [blame] | 804 | CXXConstructorDecl *D, bool elidable, |
Benjamin Kramer | 3b6bef9 | 2012-08-24 11:54:20 +0000 | [diff] [blame] | 805 | ArrayRef<Expr*> args, |
Abramo Bagnara | 7cc58b4 | 2011-10-05 07:56:41 +0000 | [diff] [blame] | 806 | bool HadMultipleCandidates, |
Sebastian Redl | 5b9cc5d | 2012-02-11 23:51:47 +0000 | [diff] [blame] | 807 | bool ListInitialization, |
Abramo Bagnara | 7cc58b4 | 2011-10-05 07:56:41 +0000 | [diff] [blame] | 808 | bool ZeroInitialization, |
Chandler Carruth | 428edaf | 2010-10-25 08:47:36 +0000 | [diff] [blame] | 809 | ConstructionKind ConstructKind, |
| 810 | SourceRange ParenRange) |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 811 | : Expr(SC, T, VK_RValue, OK_Ordinary, |
| 812 | T->isDependentType(), T->isDependentType(), |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 813 | T->isInstantiationDependentType(), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 814 | T->containsUnexpandedParameterPack()), |
Benjamin Kramer | 3b6bef9 | 2012-08-24 11:54:20 +0000 | [diff] [blame] | 815 | Constructor(D), Loc(Loc), ParenRange(ParenRange), NumArgs(args.size()), |
Abramo Bagnara | 7cc58b4 | 2011-10-05 07:56:41 +0000 | [diff] [blame] | 816 | Elidable(elidable), HadMultipleCandidates(HadMultipleCandidates), |
Sebastian Redl | 5b9cc5d | 2012-02-11 23:51:47 +0000 | [diff] [blame] | 817 | ListInitialization(ListInitialization), |
Abramo Bagnara | 7cc58b4 | 2011-10-05 07:56:41 +0000 | [diff] [blame] | 818 | ZeroInitialization(ZeroInitialization), |
Douglas Gregor | a48e676 | 2011-09-26 14:47:03 +0000 | [diff] [blame] | 819 | ConstructKind(ConstructKind), Args(0) |
Douglas Gregor | 16006c9 | 2009-12-16 18:50:27 +0000 | [diff] [blame] | 820 | { |
| 821 | if (NumArgs) { |
Benjamin Kramer | 3b6bef9 | 2012-08-24 11:54:20 +0000 | [diff] [blame] | 822 | Args = new (C) Stmt*[args.size()]; |
Douglas Gregor | 16006c9 | 2009-12-16 18:50:27 +0000 | [diff] [blame] | 823 | |
Benjamin Kramer | 3b6bef9 | 2012-08-24 11:54:20 +0000 | [diff] [blame] | 824 | for (unsigned i = 0; i != args.size(); ++i) { |
Douglas Gregor | 16006c9 | 2009-12-16 18:50:27 +0000 | [diff] [blame] | 825 | assert(args[i] && "NULL argument in CXXConstructExpr"); |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 826 | |
| 827 | if (args[i]->isValueDependent()) |
| 828 | ExprBits.ValueDependent = true; |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 829 | if (args[i]->isInstantiationDependent()) |
| 830 | ExprBits.InstantiationDependent = true; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 831 | if (args[i]->containsUnexpandedParameterPack()) |
| 832 | ExprBits.ContainsUnexpandedParameterPack = true; |
| 833 | |
Douglas Gregor | 16006c9 | 2009-12-16 18:50:27 +0000 | [diff] [blame] | 834 | Args[i] = args[i]; |
Anders Carlsson | e349bea | 2009-04-23 02:32:43 +0000 | [diff] [blame] | 835 | } |
Douglas Gregor | 16006c9 | 2009-12-16 18:50:27 +0000 | [diff] [blame] | 836 | } |
Anders Carlsson | e349bea | 2009-04-23 02:32:43 +0000 | [diff] [blame] | 837 | } |
| 838 | |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 839 | LambdaExpr::Capture::Capture(SourceLocation Loc, bool Implicit, |
| 840 | LambdaCaptureKind Kind, VarDecl *Var, |
| 841 | SourceLocation EllipsisLoc) |
Richard Smith | 0d8e964 | 2013-05-16 06:20:58 +0000 | [diff] [blame] | 842 | : DeclAndBits(Var, 0), Loc(Loc), EllipsisLoc(EllipsisLoc) |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 843 | { |
| 844 | unsigned Bits = 0; |
| 845 | if (Implicit) |
| 846 | Bits |= Capture_Implicit; |
| 847 | |
| 848 | switch (Kind) { |
| 849 | case LCK_This: |
| 850 | assert(Var == 0 && "'this' capture cannot have a variable!"); |
| 851 | break; |
| 852 | |
| 853 | case LCK_ByCopy: |
| 854 | Bits |= Capture_ByCopy; |
| 855 | // Fall through |
| 856 | case LCK_ByRef: |
| 857 | assert(Var && "capture must have a variable!"); |
| 858 | break; |
Richard Smith | 0d8e964 | 2013-05-16 06:20:58 +0000 | [diff] [blame] | 859 | |
| 860 | case LCK_Init: |
| 861 | llvm_unreachable("don't use this constructor for an init-capture"); |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 862 | } |
Richard Smith | 0d8e964 | 2013-05-16 06:20:58 +0000 | [diff] [blame] | 863 | DeclAndBits.setInt(Bits); |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 864 | } |
| 865 | |
Richard Smith | 0d8e964 | 2013-05-16 06:20:58 +0000 | [diff] [blame] | 866 | LambdaExpr::Capture::Capture(FieldDecl *Field) |
| 867 | : DeclAndBits(Field, |
| 868 | Field->getType()->isReferenceType() ? 0 : Capture_ByCopy), |
| 869 | Loc(Field->getLocation()), EllipsisLoc() {} |
| 870 | |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 871 | LambdaCaptureKind LambdaExpr::Capture::getCaptureKind() const { |
Richard Smith | 0d8e964 | 2013-05-16 06:20:58 +0000 | [diff] [blame] | 872 | Decl *D = DeclAndBits.getPointer(); |
| 873 | if (!D) |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 874 | return LCK_This; |
| 875 | |
Richard Smith | 0d8e964 | 2013-05-16 06:20:58 +0000 | [diff] [blame] | 876 | if (isa<FieldDecl>(D)) |
| 877 | return LCK_Init; |
| 878 | |
| 879 | return (DeclAndBits.getInt() & Capture_ByCopy) ? LCK_ByCopy : LCK_ByRef; |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 880 | } |
| 881 | |
James Dennett | f68af64 | 2013-08-09 23:08:25 +0000 | [diff] [blame] | 882 | LambdaExpr::LambdaExpr(QualType T, |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 883 | SourceRange IntroducerRange, |
| 884 | LambdaCaptureDefault CaptureDefault, |
James Dennett | f68af64 | 2013-08-09 23:08:25 +0000 | [diff] [blame] | 885 | SourceLocation CaptureDefaultLoc, |
| 886 | ArrayRef<Capture> Captures, |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 887 | bool ExplicitParams, |
Douglas Gregor | dfca6f5 | 2012-02-13 22:00:16 +0000 | [diff] [blame] | 888 | bool ExplicitResultType, |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 889 | ArrayRef<Expr *> CaptureInits, |
Douglas Gregor | 7ae282f | 2012-02-13 17:20:40 +0000 | [diff] [blame] | 890 | ArrayRef<VarDecl *> ArrayIndexVars, |
| 891 | ArrayRef<unsigned> ArrayIndexStarts, |
Richard Smith | 612409e | 2012-07-25 03:56:55 +0000 | [diff] [blame] | 892 | SourceLocation ClosingBrace, |
| 893 | bool ContainsUnexpandedParameterPack) |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 894 | : Expr(LambdaExprClass, T, VK_RValue, OK_Ordinary, |
| 895 | T->isDependentType(), T->isDependentType(), T->isDependentType(), |
Richard Smith | 612409e | 2012-07-25 03:56:55 +0000 | [diff] [blame] | 896 | ContainsUnexpandedParameterPack), |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 897 | IntroducerRange(IntroducerRange), |
James Dennett | f68af64 | 2013-08-09 23:08:25 +0000 | [diff] [blame] | 898 | CaptureDefaultLoc(CaptureDefaultLoc), |
Douglas Gregor | 7ae282f | 2012-02-13 17:20:40 +0000 | [diff] [blame] | 899 | NumCaptures(Captures.size()), |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 900 | CaptureDefault(CaptureDefault), |
| 901 | ExplicitParams(ExplicitParams), |
Douglas Gregor | dfca6f5 | 2012-02-13 22:00:16 +0000 | [diff] [blame] | 902 | ExplicitResultType(ExplicitResultType), |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 903 | ClosingBrace(ClosingBrace) |
| 904 | { |
| 905 | assert(CaptureInits.size() == Captures.size() && "Wrong number of arguments"); |
Douglas Gregor | da8962a | 2012-02-13 15:44:47 +0000 | [diff] [blame] | 906 | CXXRecordDecl *Class = getLambdaClass(); |
| 907 | CXXRecordDecl::LambdaDefinitionData &Data = Class->getLambdaData(); |
Douglas Gregor | da8962a | 2012-02-13 15:44:47 +0000 | [diff] [blame] | 908 | |
| 909 | // FIXME: Propagate "has unexpanded parameter pack" bit. |
Douglas Gregor | 7ae282f | 2012-02-13 17:20:40 +0000 | [diff] [blame] | 910 | |
| 911 | // Copy captures. |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 912 | const ASTContext &Context = Class->getASTContext(); |
Douglas Gregor | 7ae282f | 2012-02-13 17:20:40 +0000 | [diff] [blame] | 913 | Data.NumCaptures = NumCaptures; |
| 914 | Data.NumExplicitCaptures = 0; |
| 915 | Data.Captures = (Capture *)Context.Allocate(sizeof(Capture) * NumCaptures); |
| 916 | Capture *ToCapture = Data.Captures; |
| 917 | for (unsigned I = 0, N = Captures.size(); I != N; ++I) { |
| 918 | if (Captures[I].isExplicit()) |
| 919 | ++Data.NumExplicitCaptures; |
| 920 | |
| 921 | *ToCapture++ = Captures[I]; |
| 922 | } |
| 923 | |
| 924 | // Copy initialization expressions for the non-static data members. |
| 925 | Stmt **Stored = getStoredStmts(); |
| 926 | for (unsigned I = 0, N = CaptureInits.size(); I != N; ++I) |
| 927 | *Stored++ = CaptureInits[I]; |
| 928 | |
| 929 | // Copy the body of the lambda. |
| 930 | *Stored++ = getCallOperator()->getBody(); |
| 931 | |
| 932 | // Copy the array index variables, if any. |
| 933 | HasArrayIndexVars = !ArrayIndexVars.empty(); |
| 934 | if (HasArrayIndexVars) { |
| 935 | assert(ArrayIndexStarts.size() == NumCaptures); |
| 936 | memcpy(getArrayIndexVars(), ArrayIndexVars.data(), |
| 937 | sizeof(VarDecl *) * ArrayIndexVars.size()); |
| 938 | memcpy(getArrayIndexStarts(), ArrayIndexStarts.data(), |
| 939 | sizeof(unsigned) * Captures.size()); |
| 940 | getArrayIndexStarts()[Captures.size()] = ArrayIndexVars.size(); |
Douglas Gregor | 5878cbc | 2012-02-21 04:17:39 +0000 | [diff] [blame] | 941 | } |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 942 | } |
| 943 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 944 | LambdaExpr *LambdaExpr::Create(const ASTContext &Context, |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 945 | CXXRecordDecl *Class, |
| 946 | SourceRange IntroducerRange, |
| 947 | LambdaCaptureDefault CaptureDefault, |
James Dennett | f68af64 | 2013-08-09 23:08:25 +0000 | [diff] [blame] | 948 | SourceLocation CaptureDefaultLoc, |
| 949 | ArrayRef<Capture> Captures, |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 950 | bool ExplicitParams, |
Douglas Gregor | dfca6f5 | 2012-02-13 22:00:16 +0000 | [diff] [blame] | 951 | bool ExplicitResultType, |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 952 | ArrayRef<Expr *> CaptureInits, |
Douglas Gregor | 7ae282f | 2012-02-13 17:20:40 +0000 | [diff] [blame] | 953 | ArrayRef<VarDecl *> ArrayIndexVars, |
| 954 | ArrayRef<unsigned> ArrayIndexStarts, |
Richard Smith | 612409e | 2012-07-25 03:56:55 +0000 | [diff] [blame] | 955 | SourceLocation ClosingBrace, |
| 956 | bool ContainsUnexpandedParameterPack) { |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 957 | // Determine the type of the expression (i.e., the type of the |
| 958 | // function object we're creating). |
| 959 | QualType T = Context.getTypeDeclType(Class); |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 960 | |
Douglas Gregor | 7ae282f | 2012-02-13 17:20:40 +0000 | [diff] [blame] | 961 | unsigned Size = sizeof(LambdaExpr) + sizeof(Stmt *) * (Captures.size() + 1); |
Richard Smith | 88d2f67 | 2012-08-21 05:42:49 +0000 | [diff] [blame] | 962 | if (!ArrayIndexVars.empty()) { |
| 963 | Size += sizeof(unsigned) * (Captures.size() + 1); |
| 964 | // Realign for following VarDecl array. |
Richard Smith | a796b6c | 2012-08-21 18:18:06 +0000 | [diff] [blame] | 965 | Size = llvm::RoundUpToAlignment(Size, llvm::alignOf<VarDecl*>()); |
Richard Smith | 88d2f67 | 2012-08-21 05:42:49 +0000 | [diff] [blame] | 966 | Size += sizeof(VarDecl *) * ArrayIndexVars.size(); |
| 967 | } |
Douglas Gregor | 7ae282f | 2012-02-13 17:20:40 +0000 | [diff] [blame] | 968 | void *Mem = Context.Allocate(Size); |
James Dennett | f68af64 | 2013-08-09 23:08:25 +0000 | [diff] [blame] | 969 | return new (Mem) LambdaExpr(T, IntroducerRange, |
| 970 | CaptureDefault, CaptureDefaultLoc, Captures, |
| 971 | ExplicitParams, ExplicitResultType, |
Douglas Gregor | dfca6f5 | 2012-02-13 22:00:16 +0000 | [diff] [blame] | 972 | CaptureInits, ArrayIndexVars, ArrayIndexStarts, |
Richard Smith | 612409e | 2012-07-25 03:56:55 +0000 | [diff] [blame] | 973 | ClosingBrace, ContainsUnexpandedParameterPack); |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 974 | } |
| 975 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 976 | LambdaExpr *LambdaExpr::CreateDeserialized(const ASTContext &C, |
| 977 | unsigned NumCaptures, |
Douglas Gregor | 9d36f5d | 2012-02-14 17:54:36 +0000 | [diff] [blame] | 978 | unsigned NumArrayIndexVars) { |
| 979 | unsigned Size = sizeof(LambdaExpr) + sizeof(Stmt *) * (NumCaptures + 1); |
| 980 | if (NumArrayIndexVars) |
| 981 | Size += sizeof(VarDecl) * NumArrayIndexVars |
| 982 | + sizeof(unsigned) * (NumCaptures + 1); |
| 983 | void *Mem = C.Allocate(Size); |
| 984 | return new (Mem) LambdaExpr(EmptyShell(), NumCaptures, NumArrayIndexVars > 0); |
| 985 | } |
| 986 | |
Douglas Gregor | da8962a | 2012-02-13 15:44:47 +0000 | [diff] [blame] | 987 | LambdaExpr::capture_iterator LambdaExpr::capture_begin() const { |
Douglas Gregor | 7ae282f | 2012-02-13 17:20:40 +0000 | [diff] [blame] | 988 | return getLambdaClass()->getLambdaData().Captures; |
Douglas Gregor | da8962a | 2012-02-13 15:44:47 +0000 | [diff] [blame] | 989 | } |
| 990 | |
| 991 | LambdaExpr::capture_iterator LambdaExpr::capture_end() const { |
Douglas Gregor | 7ae282f | 2012-02-13 17:20:40 +0000 | [diff] [blame] | 992 | return capture_begin() + NumCaptures; |
Douglas Gregor | da8962a | 2012-02-13 15:44:47 +0000 | [diff] [blame] | 993 | } |
| 994 | |
| 995 | LambdaExpr::capture_iterator LambdaExpr::explicit_capture_begin() const { |
| 996 | return capture_begin(); |
| 997 | } |
| 998 | |
| 999 | LambdaExpr::capture_iterator LambdaExpr::explicit_capture_end() const { |
| 1000 | struct CXXRecordDecl::LambdaDefinitionData &Data |
| 1001 | = getLambdaClass()->getLambdaData(); |
Douglas Gregor | 7ae282f | 2012-02-13 17:20:40 +0000 | [diff] [blame] | 1002 | return Data.Captures + Data.NumExplicitCaptures; |
Douglas Gregor | da8962a | 2012-02-13 15:44:47 +0000 | [diff] [blame] | 1003 | } |
| 1004 | |
| 1005 | LambdaExpr::capture_iterator LambdaExpr::implicit_capture_begin() const { |
| 1006 | return explicit_capture_end(); |
| 1007 | } |
| 1008 | |
| 1009 | LambdaExpr::capture_iterator LambdaExpr::implicit_capture_end() const { |
| 1010 | return capture_end(); |
| 1011 | } |
| 1012 | |
Douglas Gregor | 9daa7bf | 2012-02-13 16:35:30 +0000 | [diff] [blame] | 1013 | ArrayRef<VarDecl *> |
| 1014 | LambdaExpr::getCaptureInitIndexVars(capture_init_iterator Iter) const { |
Douglas Gregor | 7ae282f | 2012-02-13 17:20:40 +0000 | [diff] [blame] | 1015 | assert(HasArrayIndexVars && "No array index-var data?"); |
Douglas Gregor | 9daa7bf | 2012-02-13 16:35:30 +0000 | [diff] [blame] | 1016 | |
| 1017 | unsigned Index = Iter - capture_init_begin(); |
Matt Beaumont-Gay | 43a1b00 | 2012-02-13 19:29:45 +0000 | [diff] [blame] | 1018 | assert(Index < getLambdaClass()->getLambdaData().NumCaptures && |
| 1019 | "Capture index out-of-range"); |
Douglas Gregor | 7ae282f | 2012-02-13 17:20:40 +0000 | [diff] [blame] | 1020 | VarDecl **IndexVars = getArrayIndexVars(); |
| 1021 | unsigned *IndexStarts = getArrayIndexStarts(); |
Douglas Gregor | 9daa7bf | 2012-02-13 16:35:30 +0000 | [diff] [blame] | 1022 | return ArrayRef<VarDecl *>(IndexVars + IndexStarts[Index], |
| 1023 | IndexVars + IndexStarts[Index + 1]); |
| 1024 | } |
| 1025 | |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 1026 | CXXRecordDecl *LambdaExpr::getLambdaClass() const { |
| 1027 | return getType()->getAsCXXRecordDecl(); |
| 1028 | } |
| 1029 | |
| 1030 | CXXMethodDecl *LambdaExpr::getCallOperator() const { |
| 1031 | CXXRecordDecl *Record = getLambdaClass(); |
Manuel Klimek | 152b4e4 | 2013-08-22 12:12:24 +0000 | [diff] [blame] | 1032 | DeclarationName Name |
| 1033 | = Record->getASTContext().DeclarationNames.getCXXOperatorName(OO_Call); |
| 1034 | DeclContext::lookup_result Calls = Record->lookup(Name); |
| 1035 | assert(!Calls.empty() && "Missing lambda call operator!"); |
| 1036 | assert(Calls.size() == 1 && "More than one lambda call operator!"); |
| 1037 | CXXMethodDecl *Result = cast<CXXMethodDecl>(Calls.front()); |
| 1038 | return Result; |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 1039 | } |
| 1040 | |
Douglas Gregor | 9d36f5d | 2012-02-14 17:54:36 +0000 | [diff] [blame] | 1041 | CompoundStmt *LambdaExpr::getBody() const { |
| 1042 | if (!getStoredStmts()[NumCaptures]) |
| 1043 | getStoredStmts()[NumCaptures] = getCallOperator()->getBody(); |
| 1044 | |
| 1045 | return reinterpret_cast<CompoundStmt *>(getStoredStmts()[NumCaptures]); |
| 1046 | } |
| 1047 | |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 1048 | bool LambdaExpr::isMutable() const { |
David Blaikie | 4ef832f | 2012-08-10 00:55:35 +0000 | [diff] [blame] | 1049 | return !getCallOperator()->isConst(); |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 1050 | } |
| 1051 | |
John McCall | 80ee6e8 | 2011-11-10 05:35:25 +0000 | [diff] [blame] | 1052 | ExprWithCleanups::ExprWithCleanups(Expr *subexpr, |
| 1053 | ArrayRef<CleanupObject> objects) |
John McCall | 4765fa0 | 2010-12-06 08:20:24 +0000 | [diff] [blame] | 1054 | : Expr(ExprWithCleanupsClass, subexpr->getType(), |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 1055 | subexpr->getValueKind(), subexpr->getObjectKind(), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 1056 | subexpr->isTypeDependent(), subexpr->isValueDependent(), |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 1057 | subexpr->isInstantiationDependent(), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 1058 | subexpr->containsUnexpandedParameterPack()), |
John McCall | 80ee6e8 | 2011-11-10 05:35:25 +0000 | [diff] [blame] | 1059 | SubExpr(subexpr) { |
| 1060 | ExprWithCleanupsBits.NumObjects = objects.size(); |
| 1061 | for (unsigned i = 0, e = objects.size(); i != e; ++i) |
| 1062 | getObjectsBuffer()[i] = objects[i]; |
Anders Carlsson | 02bbfa3 | 2009-04-24 22:47:04 +0000 | [diff] [blame] | 1063 | } |
| 1064 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 1065 | ExprWithCleanups *ExprWithCleanups::Create(const ASTContext &C, Expr *subexpr, |
John McCall | 80ee6e8 | 2011-11-10 05:35:25 +0000 | [diff] [blame] | 1066 | ArrayRef<CleanupObject> objects) { |
| 1067 | size_t size = sizeof(ExprWithCleanups) |
| 1068 | + objects.size() * sizeof(CleanupObject); |
| 1069 | void *buffer = C.Allocate(size, llvm::alignOf<ExprWithCleanups>()); |
| 1070 | return new (buffer) ExprWithCleanups(subexpr, objects); |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1071 | } |
| 1072 | |
John McCall | 80ee6e8 | 2011-11-10 05:35:25 +0000 | [diff] [blame] | 1073 | ExprWithCleanups::ExprWithCleanups(EmptyShell empty, unsigned numObjects) |
| 1074 | : Expr(ExprWithCleanupsClass, empty) { |
| 1075 | ExprWithCleanupsBits.NumObjects = numObjects; |
| 1076 | } |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1077 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 1078 | ExprWithCleanups *ExprWithCleanups::Create(const ASTContext &C, |
| 1079 | EmptyShell empty, |
John McCall | 80ee6e8 | 2011-11-10 05:35:25 +0000 | [diff] [blame] | 1080 | unsigned numObjects) { |
| 1081 | size_t size = sizeof(ExprWithCleanups) + numObjects * sizeof(CleanupObject); |
| 1082 | void *buffer = C.Allocate(size, llvm::alignOf<ExprWithCleanups>()); |
| 1083 | return new (buffer) ExprWithCleanups(empty, numObjects); |
Anders Carlsson | 88eaf07 | 2009-05-30 22:38:53 +0000 | [diff] [blame] | 1084 | } |
| 1085 | |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 1086 | CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(TypeSourceInfo *Type, |
Douglas Gregor | d81e6ca | 2009-05-20 18:46:25 +0000 | [diff] [blame] | 1087 | SourceLocation LParenLoc, |
Benjamin Kramer | 3b6bef9 | 2012-08-24 11:54:20 +0000 | [diff] [blame] | 1088 | ArrayRef<Expr*> Args, |
Douglas Gregor | d81e6ca | 2009-05-20 18:46:25 +0000 | [diff] [blame] | 1089 | SourceLocation RParenLoc) |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 1090 | : Expr(CXXUnresolvedConstructExprClass, |
| 1091 | Type->getType().getNonReferenceType(), |
Douglas Gregor | 032c869 | 2011-07-08 15:50:43 +0000 | [diff] [blame] | 1092 | (Type->getType()->isLValueReferenceType() ? VK_LValue |
| 1093 | :Type->getType()->isRValueReferenceType()? VK_XValue |
| 1094 | :VK_RValue), |
| 1095 | OK_Ordinary, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 1096 | Type->getType()->isDependentType(), true, true, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 1097 | Type->getType()->containsUnexpandedParameterPack()), |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 1098 | Type(Type), |
Douglas Gregor | d81e6ca | 2009-05-20 18:46:25 +0000 | [diff] [blame] | 1099 | LParenLoc(LParenLoc), |
| 1100 | RParenLoc(RParenLoc), |
Benjamin Kramer | 3b6bef9 | 2012-08-24 11:54:20 +0000 | [diff] [blame] | 1101 | NumArgs(Args.size()) { |
Douglas Gregor | d81e6ca | 2009-05-20 18:46:25 +0000 | [diff] [blame] | 1102 | Stmt **StoredArgs = reinterpret_cast<Stmt **>(this + 1); |
Benjamin Kramer | 3b6bef9 | 2012-08-24 11:54:20 +0000 | [diff] [blame] | 1103 | for (unsigned I = 0; I != Args.size(); ++I) { |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 1104 | if (Args[I]->containsUnexpandedParameterPack()) |
| 1105 | ExprBits.ContainsUnexpandedParameterPack = true; |
| 1106 | |
| 1107 | StoredArgs[I] = Args[I]; |
| 1108 | } |
Douglas Gregor | d81e6ca | 2009-05-20 18:46:25 +0000 | [diff] [blame] | 1109 | } |
| 1110 | |
| 1111 | CXXUnresolvedConstructExpr * |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 1112 | CXXUnresolvedConstructExpr::Create(const ASTContext &C, |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 1113 | TypeSourceInfo *Type, |
Douglas Gregor | d81e6ca | 2009-05-20 18:46:25 +0000 | [diff] [blame] | 1114 | SourceLocation LParenLoc, |
Benjamin Kramer | 3b6bef9 | 2012-08-24 11:54:20 +0000 | [diff] [blame] | 1115 | ArrayRef<Expr*> Args, |
Douglas Gregor | d81e6ca | 2009-05-20 18:46:25 +0000 | [diff] [blame] | 1116 | SourceLocation RParenLoc) { |
| 1117 | void *Mem = C.Allocate(sizeof(CXXUnresolvedConstructExpr) + |
Benjamin Kramer | 3b6bef9 | 2012-08-24 11:54:20 +0000 | [diff] [blame] | 1118 | sizeof(Expr *) * Args.size()); |
| 1119 | return new (Mem) CXXUnresolvedConstructExpr(Type, LParenLoc, Args, RParenLoc); |
Douglas Gregor | d81e6ca | 2009-05-20 18:46:25 +0000 | [diff] [blame] | 1120 | } |
| 1121 | |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1122 | CXXUnresolvedConstructExpr * |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 1123 | CXXUnresolvedConstructExpr::CreateEmpty(const ASTContext &C, unsigned NumArgs) { |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1124 | Stmt::EmptyShell Empty; |
| 1125 | void *Mem = C.Allocate(sizeof(CXXUnresolvedConstructExpr) + |
| 1126 | sizeof(Expr *) * NumArgs); |
| 1127 | return new (Mem) CXXUnresolvedConstructExpr(Empty, NumArgs); |
| 1128 | } |
| 1129 | |
Erik Verbruggen | 65d7831 | 2012-12-25 14:51:39 +0000 | [diff] [blame] | 1130 | SourceLocation CXXUnresolvedConstructExpr::getLocStart() const { |
| 1131 | return Type->getTypeLoc().getBeginLoc(); |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 1132 | } |
| 1133 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 1134 | CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(const ASTContext &C, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1135 | Expr *Base, QualType BaseType, |
| 1136 | bool IsArrow, |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 1137 | SourceLocation OperatorLoc, |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1138 | NestedNameSpecifierLoc QualifierLoc, |
| 1139 | SourceLocation TemplateKWLoc, |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 1140 | NamedDecl *FirstQualifierFoundInScope, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 1141 | DeclarationNameInfo MemberNameInfo, |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 1142 | const TemplateArgumentListInfo *TemplateArgs) |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 1143 | : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 1144 | VK_LValue, OK_Ordinary, true, true, true, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 1145 | ((Base && Base->containsUnexpandedParameterPack()) || |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 1146 | (QualifierLoc && |
| 1147 | QualifierLoc.getNestedNameSpecifier() |
| 1148 | ->containsUnexpandedParameterPack()) || |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 1149 | MemberNameInfo.containsUnexpandedParameterPack())), |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1150 | Base(Base), BaseType(BaseType), IsArrow(IsArrow), |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1151 | HasTemplateKWAndArgsInfo(TemplateArgs != 0 || TemplateKWLoc.isValid()), |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 1152 | OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc), |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 1153 | FirstQualifierFoundInScope(FirstQualifierFoundInScope), |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 1154 | MemberNameInfo(MemberNameInfo) { |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 1155 | if (TemplateArgs) { |
| 1156 | bool Dependent = true; |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 1157 | bool InstantiationDependent = true; |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 1158 | bool ContainsUnexpandedParameterPack = false; |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1159 | getTemplateKWAndArgsInfo()->initializeFrom(TemplateKWLoc, *TemplateArgs, |
| 1160 | Dependent, |
| 1161 | InstantiationDependent, |
| 1162 | ContainsUnexpandedParameterPack); |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 1163 | if (ContainsUnexpandedParameterPack) |
| 1164 | ExprBits.ContainsUnexpandedParameterPack = true; |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1165 | } else if (TemplateKWLoc.isValid()) { |
| 1166 | getTemplateKWAndArgsInfo()->initializeFrom(TemplateKWLoc); |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 1167 | } |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 1168 | } |
| 1169 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 1170 | CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(const ASTContext &C, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 1171 | Expr *Base, QualType BaseType, |
| 1172 | bool IsArrow, |
| 1173 | SourceLocation OperatorLoc, |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 1174 | NestedNameSpecifierLoc QualifierLoc, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 1175 | NamedDecl *FirstQualifierFoundInScope, |
| 1176 | DeclarationNameInfo MemberNameInfo) |
| 1177 | : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 1178 | VK_LValue, OK_Ordinary, true, true, true, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 1179 | ((Base && Base->containsUnexpandedParameterPack()) || |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 1180 | (QualifierLoc && |
| 1181 | QualifierLoc.getNestedNameSpecifier()-> |
| 1182 | containsUnexpandedParameterPack()) || |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 1183 | MemberNameInfo.containsUnexpandedParameterPack())), |
| 1184 | Base(Base), BaseType(BaseType), IsArrow(IsArrow), |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1185 | HasTemplateKWAndArgsInfo(false), |
| 1186 | OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 1187 | FirstQualifierFoundInScope(FirstQualifierFoundInScope), |
| 1188 | MemberNameInfo(MemberNameInfo) { } |
| 1189 | |
John McCall | 865d447 | 2009-11-19 22:55:06 +0000 | [diff] [blame] | 1190 | CXXDependentScopeMemberExpr * |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 1191 | CXXDependentScopeMemberExpr::Create(const ASTContext &C, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1192 | Expr *Base, QualType BaseType, bool IsArrow, |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 1193 | SourceLocation OperatorLoc, |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 1194 | NestedNameSpecifierLoc QualifierLoc, |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1195 | SourceLocation TemplateKWLoc, |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 1196 | NamedDecl *FirstQualifierFoundInScope, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 1197 | DeclarationNameInfo MemberNameInfo, |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 1198 | const TemplateArgumentListInfo *TemplateArgs) { |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1199 | if (!TemplateArgs && !TemplateKWLoc.isValid()) |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1200 | return new (C) CXXDependentScopeMemberExpr(C, Base, BaseType, |
| 1201 | IsArrow, OperatorLoc, |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 1202 | QualifierLoc, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1203 | FirstQualifierFoundInScope, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 1204 | MemberNameInfo); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1205 | |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1206 | unsigned NumTemplateArgs = TemplateArgs ? TemplateArgs->size() : 0; |
| 1207 | std::size_t size = sizeof(CXXDependentScopeMemberExpr) |
| 1208 | + ASTTemplateKWAndArgsInfo::sizeFor(NumTemplateArgs); |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 1209 | |
Chris Lattner | 3248854 | 2010-10-30 05:14:06 +0000 | [diff] [blame] | 1210 | void *Mem = C.Allocate(size, llvm::alignOf<CXXDependentScopeMemberExpr>()); |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1211 | return new (Mem) CXXDependentScopeMemberExpr(C, Base, BaseType, |
| 1212 | IsArrow, OperatorLoc, |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 1213 | QualifierLoc, |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1214 | TemplateKWLoc, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1215 | FirstQualifierFoundInScope, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 1216 | MemberNameInfo, TemplateArgs); |
Douglas Gregor | 3b6afbb | 2009-09-09 00:23:06 +0000 | [diff] [blame] | 1217 | } |
| 1218 | |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1219 | CXXDependentScopeMemberExpr * |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 1220 | CXXDependentScopeMemberExpr::CreateEmpty(const ASTContext &C, |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1221 | bool HasTemplateKWAndArgsInfo, |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1222 | unsigned NumTemplateArgs) { |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1223 | if (!HasTemplateKWAndArgsInfo) |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1224 | return new (C) CXXDependentScopeMemberExpr(C, 0, QualType(), |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1225 | 0, SourceLocation(), |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 1226 | NestedNameSpecifierLoc(), 0, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 1227 | DeclarationNameInfo()); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1228 | |
| 1229 | std::size_t size = sizeof(CXXDependentScopeMemberExpr) + |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1230 | ASTTemplateKWAndArgsInfo::sizeFor(NumTemplateArgs); |
Chris Lattner | 3248854 | 2010-10-30 05:14:06 +0000 | [diff] [blame] | 1231 | void *Mem = C.Allocate(size, llvm::alignOf<CXXDependentScopeMemberExpr>()); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1232 | CXXDependentScopeMemberExpr *E |
| 1233 | = new (Mem) CXXDependentScopeMemberExpr(C, 0, QualType(), |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1234 | 0, SourceLocation(), |
| 1235 | NestedNameSpecifierLoc(), |
| 1236 | SourceLocation(), 0, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 1237 | DeclarationNameInfo(), 0); |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1238 | E->HasTemplateKWAndArgsInfo = true; |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1239 | return E; |
| 1240 | } |
| 1241 | |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 1242 | bool CXXDependentScopeMemberExpr::isImplicitAccess() const { |
| 1243 | if (Base == 0) |
| 1244 | return true; |
| 1245 | |
Douglas Gregor | 75e8504 | 2011-03-02 21:06:53 +0000 | [diff] [blame] | 1246 | return cast<Expr>(Base)->isImplicitCXXThis(); |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 1247 | } |
| 1248 | |
John McCall | 864c041 | 2011-04-26 20:42:42 +0000 | [diff] [blame] | 1249 | static bool hasOnlyNonStaticMemberFunctions(UnresolvedSetIterator begin, |
| 1250 | UnresolvedSetIterator end) { |
| 1251 | do { |
| 1252 | NamedDecl *decl = *begin; |
| 1253 | if (isa<UnresolvedUsingValueDecl>(decl)) |
| 1254 | return false; |
| 1255 | if (isa<UsingShadowDecl>(decl)) |
| 1256 | decl = cast<UsingShadowDecl>(decl)->getUnderlyingDecl(); |
| 1257 | |
| 1258 | // Unresolved member expressions should only contain methods and |
| 1259 | // method templates. |
| 1260 | assert(isa<CXXMethodDecl>(decl) || isa<FunctionTemplateDecl>(decl)); |
| 1261 | |
| 1262 | if (isa<FunctionTemplateDecl>(decl)) |
| 1263 | decl = cast<FunctionTemplateDecl>(decl)->getTemplatedDecl(); |
| 1264 | if (cast<CXXMethodDecl>(decl)->isStatic()) |
| 1265 | return false; |
| 1266 | } while (++begin != end); |
| 1267 | |
| 1268 | return true; |
| 1269 | } |
| 1270 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 1271 | UnresolvedMemberExpr::UnresolvedMemberExpr(const ASTContext &C, |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1272 | bool HasUnresolvedUsing, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1273 | Expr *Base, QualType BaseType, |
| 1274 | bool IsArrow, |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1275 | SourceLocation OperatorLoc, |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 1276 | NestedNameSpecifierLoc QualifierLoc, |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1277 | SourceLocation TemplateKWLoc, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 1278 | const DeclarationNameInfo &MemberNameInfo, |
Douglas Gregor | 5a84dec | 2010-05-23 18:57:34 +0000 | [diff] [blame] | 1279 | const TemplateArgumentListInfo *TemplateArgs, |
| 1280 | UnresolvedSetIterator Begin, |
| 1281 | UnresolvedSetIterator End) |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1282 | : OverloadExpr(UnresolvedMemberExprClass, C, QualifierLoc, TemplateKWLoc, |
| 1283 | MemberNameInfo, TemplateArgs, Begin, End, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 1284 | // Dependent |
| 1285 | ((Base && Base->isTypeDependent()) || |
| 1286 | BaseType->isDependentType()), |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 1287 | ((Base && Base->isInstantiationDependent()) || |
| 1288 | BaseType->isInstantiationDependentType()), |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 1289 | // Contains unexpanded parameter pack |
| 1290 | ((Base && Base->containsUnexpandedParameterPack()) || |
| 1291 | BaseType->containsUnexpandedParameterPack())), |
John McCall | 7bb12da | 2010-02-02 06:20:04 +0000 | [diff] [blame] | 1292 | IsArrow(IsArrow), HasUnresolvedUsing(HasUnresolvedUsing), |
| 1293 | Base(Base), BaseType(BaseType), OperatorLoc(OperatorLoc) { |
John McCall | 864c041 | 2011-04-26 20:42:42 +0000 | [diff] [blame] | 1294 | |
| 1295 | // Check whether all of the members are non-static member functions, |
| 1296 | // and if so, mark give this bound-member type instead of overload type. |
| 1297 | if (hasOnlyNonStaticMemberFunctions(Begin, End)) |
| 1298 | setType(C.BoundMemberTy); |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1299 | } |
| 1300 | |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 1301 | bool UnresolvedMemberExpr::isImplicitAccess() const { |
| 1302 | if (Base == 0) |
| 1303 | return true; |
| 1304 | |
Douglas Gregor | 75e8504 | 2011-03-02 21:06:53 +0000 | [diff] [blame] | 1305 | return cast<Expr>(Base)->isImplicitCXXThis(); |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 1306 | } |
| 1307 | |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1308 | UnresolvedMemberExpr * |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 1309 | UnresolvedMemberExpr::Create(const ASTContext &C, bool HasUnresolvedUsing, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1310 | Expr *Base, QualType BaseType, bool IsArrow, |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1311 | SourceLocation OperatorLoc, |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 1312 | NestedNameSpecifierLoc QualifierLoc, |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1313 | SourceLocation TemplateKWLoc, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 1314 | const DeclarationNameInfo &MemberNameInfo, |
Douglas Gregor | 5a84dec | 2010-05-23 18:57:34 +0000 | [diff] [blame] | 1315 | const TemplateArgumentListInfo *TemplateArgs, |
| 1316 | UnresolvedSetIterator Begin, |
| 1317 | UnresolvedSetIterator End) { |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1318 | std::size_t size = sizeof(UnresolvedMemberExpr); |
| 1319 | if (TemplateArgs) |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1320 | size += ASTTemplateKWAndArgsInfo::sizeFor(TemplateArgs->size()); |
| 1321 | else if (TemplateKWLoc.isValid()) |
| 1322 | size += ASTTemplateKWAndArgsInfo::sizeFor(0); |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1323 | |
Chris Lattner | 3248854 | 2010-10-30 05:14:06 +0000 | [diff] [blame] | 1324 | void *Mem = C.Allocate(size, llvm::alignOf<UnresolvedMemberExpr>()); |
Douglas Gregor | 928e6fc | 2010-05-23 19:36:40 +0000 | [diff] [blame] | 1325 | return new (Mem) UnresolvedMemberExpr(C, |
Douglas Gregor | bebbe0d | 2010-12-15 01:34:56 +0000 | [diff] [blame] | 1326 | HasUnresolvedUsing, Base, BaseType, |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1327 | IsArrow, OperatorLoc, QualifierLoc, TemplateKWLoc, |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 1328 | MemberNameInfo, TemplateArgs, Begin, End); |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1329 | } |
| 1330 | |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1331 | UnresolvedMemberExpr * |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 1332 | UnresolvedMemberExpr::CreateEmpty(const ASTContext &C, |
| 1333 | bool HasTemplateKWAndArgsInfo, |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 1334 | unsigned NumTemplateArgs) { |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1335 | std::size_t size = sizeof(UnresolvedMemberExpr); |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1336 | if (HasTemplateKWAndArgsInfo) |
| 1337 | size += ASTTemplateKWAndArgsInfo::sizeFor(NumTemplateArgs); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1338 | |
Chris Lattner | 3248854 | 2010-10-30 05:14:06 +0000 | [diff] [blame] | 1339 | void *Mem = C.Allocate(size, llvm::alignOf<UnresolvedMemberExpr>()); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1340 | UnresolvedMemberExpr *E = new (Mem) UnresolvedMemberExpr(EmptyShell()); |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1341 | E->HasTemplateKWAndArgsInfo = HasTemplateKWAndArgsInfo; |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1342 | return E; |
| 1343 | } |
| 1344 | |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 1345 | CXXRecordDecl *UnresolvedMemberExpr::getNamingClass() const { |
| 1346 | // Unlike for UnresolvedLookupExpr, it is very easy to re-derive this. |
| 1347 | |
| 1348 | // If there was a nested name specifier, it names the naming class. |
| 1349 | // It can't be dependent: after all, we were actually able to do the |
| 1350 | // lookup. |
Douglas Gregor | c96be1e | 2010-04-27 18:19:34 +0000 | [diff] [blame] | 1351 | CXXRecordDecl *Record = 0; |
John McCall | 7bb12da | 2010-02-02 06:20:04 +0000 | [diff] [blame] | 1352 | if (getQualifier()) { |
John McCall | f4c7371 | 2011-01-19 06:33:43 +0000 | [diff] [blame] | 1353 | const Type *T = getQualifier()->getAsType(); |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 1354 | assert(T && "qualifier in member expression does not name type"); |
Douglas Gregor | c96be1e | 2010-04-27 18:19:34 +0000 | [diff] [blame] | 1355 | Record = T->getAsCXXRecordDecl(); |
| 1356 | assert(Record && "qualifier in member expression does not name record"); |
| 1357 | } |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 1358 | // Otherwise the naming class must have been the base class. |
Douglas Gregor | c96be1e | 2010-04-27 18:19:34 +0000 | [diff] [blame] | 1359 | else { |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 1360 | QualType BaseType = getBaseType().getNonReferenceType(); |
| 1361 | if (isArrow()) { |
| 1362 | const PointerType *PT = BaseType->getAs<PointerType>(); |
| 1363 | assert(PT && "base of arrow member access is not pointer"); |
| 1364 | BaseType = PT->getPointeeType(); |
| 1365 | } |
| 1366 | |
Douglas Gregor | c96be1e | 2010-04-27 18:19:34 +0000 | [diff] [blame] | 1367 | Record = BaseType->getAsCXXRecordDecl(); |
| 1368 | assert(Record && "base of member expression does not name record"); |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 1369 | } |
| 1370 | |
Douglas Gregor | c96be1e | 2010-04-27 18:19:34 +0000 | [diff] [blame] | 1371 | return Record; |
John McCall | c373d48 | 2010-01-27 01:50:18 +0000 | [diff] [blame] | 1372 | } |
| 1373 | |
Douglas Gregor | c7793c7 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 1374 | SubstNonTypeTemplateParmPackExpr:: |
| 1375 | SubstNonTypeTemplateParmPackExpr(QualType T, |
| 1376 | NonTypeTemplateParmDecl *Param, |
| 1377 | SourceLocation NameLoc, |
| 1378 | const TemplateArgument &ArgPack) |
| 1379 | : Expr(SubstNonTypeTemplateParmPackExprClass, T, VK_RValue, OK_Ordinary, |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 1380 | true, true, true, true), |
Douglas Gregor | c7793c7 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 1381 | Param(Param), Arguments(ArgPack.pack_begin()), |
| 1382 | NumArguments(ArgPack.pack_size()), NameLoc(NameLoc) { } |
| 1383 | |
| 1384 | TemplateArgument SubstNonTypeTemplateParmPackExpr::getArgumentPack() const { |
| 1385 | return TemplateArgument(Arguments, NumArguments); |
| 1386 | } |
| 1387 | |
Richard Smith | 9a4db03 | 2012-09-12 00:56:43 +0000 | [diff] [blame] | 1388 | FunctionParmPackExpr::FunctionParmPackExpr(QualType T, ParmVarDecl *ParamPack, |
| 1389 | SourceLocation NameLoc, |
| 1390 | unsigned NumParams, |
| 1391 | Decl * const *Params) |
| 1392 | : Expr(FunctionParmPackExprClass, T, VK_LValue, OK_Ordinary, |
| 1393 | true, true, true, true), |
| 1394 | ParamPack(ParamPack), NameLoc(NameLoc), NumParameters(NumParams) { |
| 1395 | if (Params) |
| 1396 | std::uninitialized_copy(Params, Params + NumParams, |
| 1397 | reinterpret_cast<Decl**>(this+1)); |
| 1398 | } |
| 1399 | |
| 1400 | FunctionParmPackExpr * |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 1401 | FunctionParmPackExpr::Create(const ASTContext &Context, QualType T, |
Richard Smith | 9a4db03 | 2012-09-12 00:56:43 +0000 | [diff] [blame] | 1402 | ParmVarDecl *ParamPack, SourceLocation NameLoc, |
Dmitri Gribenko | cfa88f8 | 2013-01-12 19:30:44 +0000 | [diff] [blame] | 1403 | ArrayRef<Decl *> Params) { |
Richard Smith | 9a4db03 | 2012-09-12 00:56:43 +0000 | [diff] [blame] | 1404 | return new (Context.Allocate(sizeof(FunctionParmPackExpr) + |
| 1405 | sizeof(ParmVarDecl*) * Params.size())) |
| 1406 | FunctionParmPackExpr(T, ParamPack, NameLoc, Params.size(), Params.data()); |
| 1407 | } |
| 1408 | |
| 1409 | FunctionParmPackExpr * |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 1410 | FunctionParmPackExpr::CreateEmpty(const ASTContext &Context, |
| 1411 | unsigned NumParams) { |
Richard Smith | 9a4db03 | 2012-09-12 00:56:43 +0000 | [diff] [blame] | 1412 | return new (Context.Allocate(sizeof(FunctionParmPackExpr) + |
| 1413 | sizeof(ParmVarDecl*) * NumParams)) |
| 1414 | FunctionParmPackExpr(QualType(), 0, SourceLocation(), 0, 0); |
| 1415 | } |
| 1416 | |
Douglas Gregor | 4ca8ac2 | 2012-02-24 07:38:34 +0000 | [diff] [blame] | 1417 | TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind, |
| 1418 | ArrayRef<TypeSourceInfo *> Args, |
| 1419 | SourceLocation RParenLoc, |
| 1420 | bool Value) |
| 1421 | : Expr(TypeTraitExprClass, T, VK_RValue, OK_Ordinary, |
| 1422 | /*TypeDependent=*/false, |
| 1423 | /*ValueDependent=*/false, |
| 1424 | /*InstantiationDependent=*/false, |
| 1425 | /*ContainsUnexpandedParameterPack=*/false), |
| 1426 | Loc(Loc), RParenLoc(RParenLoc) |
| 1427 | { |
| 1428 | TypeTraitExprBits.Kind = Kind; |
| 1429 | TypeTraitExprBits.Value = Value; |
| 1430 | TypeTraitExprBits.NumArgs = Args.size(); |
| 1431 | |
| 1432 | TypeSourceInfo **ToArgs = getTypeSourceInfos(); |
| 1433 | |
| 1434 | for (unsigned I = 0, N = Args.size(); I != N; ++I) { |
| 1435 | if (Args[I]->getType()->isDependentType()) |
| 1436 | setValueDependent(true); |
| 1437 | if (Args[I]->getType()->isInstantiationDependentType()) |
| 1438 | setInstantiationDependent(true); |
| 1439 | if (Args[I]->getType()->containsUnexpandedParameterPack()) |
| 1440 | setContainsUnexpandedParameterPack(true); |
| 1441 | |
| 1442 | ToArgs[I] = Args[I]; |
| 1443 | } |
| 1444 | } |
| 1445 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 1446 | TypeTraitExpr *TypeTraitExpr::Create(const ASTContext &C, QualType T, |
Douglas Gregor | 4ca8ac2 | 2012-02-24 07:38:34 +0000 | [diff] [blame] | 1447 | SourceLocation Loc, |
| 1448 | TypeTrait Kind, |
| 1449 | ArrayRef<TypeSourceInfo *> Args, |
| 1450 | SourceLocation RParenLoc, |
| 1451 | bool Value) { |
| 1452 | unsigned Size = sizeof(TypeTraitExpr) + sizeof(TypeSourceInfo*) * Args.size(); |
| 1453 | void *Mem = C.Allocate(Size); |
| 1454 | return new (Mem) TypeTraitExpr(T, Loc, Kind, Args, RParenLoc, Value); |
| 1455 | } |
| 1456 | |
Craig Topper | 32b5a1e | 2013-08-22 07:09:37 +0000 | [diff] [blame] | 1457 | TypeTraitExpr *TypeTraitExpr::CreateDeserialized(const ASTContext &C, |
Douglas Gregor | 4ca8ac2 | 2012-02-24 07:38:34 +0000 | [diff] [blame] | 1458 | unsigned NumArgs) { |
| 1459 | unsigned Size = sizeof(TypeTraitExpr) + sizeof(TypeSourceInfo*) * NumArgs; |
| 1460 | void *Mem = C.Allocate(Size); |
| 1461 | return new (Mem) TypeTraitExpr(EmptyShell()); |
| 1462 | } |
| 1463 | |
David Blaikie | 99ba9e3 | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 1464 | void ArrayTypeTraitExpr::anchor() { } |