clang API Documentation
00001 //===--- ExprCXX.cpp - (C++) Expression AST Node Implementation -----------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file implements the subclesses of Expr class declared in ExprCXX.h 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #include "clang/AST/ASTContext.h" 00015 #include "clang/AST/Attr.h" 00016 #include "clang/AST/DeclCXX.h" 00017 #include "clang/AST/DeclTemplate.h" 00018 #include "clang/AST/ExprCXX.h" 00019 #include "clang/AST/TypeLoc.h" 00020 #include "clang/Basic/IdentifierTable.h" 00021 using namespace clang; 00022 00023 00024 //===----------------------------------------------------------------------===// 00025 // Child Iterators for iterating over subexpressions/substatements 00026 //===----------------------------------------------------------------------===// 00027 00028 bool CXXTypeidExpr::isPotentiallyEvaluated() const { 00029 if (isTypeOperand()) 00030 return false; 00031 00032 // C++11 [expr.typeid]p3: 00033 // When typeid is applied to an expression other than a glvalue of 00034 // polymorphic class type, [...] the expression is an unevaluated operand. 00035 const Expr *E = getExprOperand(); 00036 if (const CXXRecordDecl *RD = E->getType()->getAsCXXRecordDecl()) 00037 if (RD->isPolymorphic() && E->isGLValue()) 00038 return true; 00039 00040 return false; 00041 } 00042 00043 QualType CXXTypeidExpr::getTypeOperand(ASTContext &Context) const { 00044 assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 00045 Qualifiers Quals; 00046 return Context.getUnqualifiedArrayType( 00047 Operand.get<TypeSourceInfo *>()->getType().getNonReferenceType(), Quals); 00048 } 00049 00050 QualType CXXUuidofExpr::getTypeOperand(ASTContext &Context) const { 00051 assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)"); 00052 Qualifiers Quals; 00053 return Context.getUnqualifiedArrayType( 00054 Operand.get<TypeSourceInfo *>()->getType().getNonReferenceType(), Quals); 00055 } 00056 00057 // static 00058 const UuidAttr *CXXUuidofExpr::GetUuidAttrOfType(QualType QT, 00059 bool *RDHasMultipleGUIDsPtr) { 00060 // Optionally remove one level of pointer, reference or array indirection. 00061 const Type *Ty = QT.getTypePtr(); 00062 if (QT->isPointerType() || QT->isReferenceType()) 00063 Ty = QT->getPointeeType().getTypePtr(); 00064 else if (QT->isArrayType()) 00065 Ty = Ty->getBaseElementTypeUnsafe(); 00066 00067 const CXXRecordDecl *RD = Ty->getAsCXXRecordDecl(); 00068 if (!RD) 00069 return nullptr; 00070 00071 if (const UuidAttr *Uuid = RD->getMostRecentDecl()->getAttr<UuidAttr>()) 00072 return Uuid; 00073 00074 // __uuidof can grab UUIDs from template arguments. 00075 if (const ClassTemplateSpecializationDecl *CTSD = 00076 dyn_cast<ClassTemplateSpecializationDecl>(RD)) { 00077 const TemplateArgumentList &TAL = CTSD->getTemplateArgs(); 00078 const UuidAttr *UuidForRD = nullptr; 00079 00080 for (const TemplateArgument &TA : TAL.asArray()) { 00081 bool SeenMultipleGUIDs = false; 00082 00083 const UuidAttr *UuidForTA = nullptr; 00084 if (TA.getKind() == TemplateArgument::Type) 00085 UuidForTA = GetUuidAttrOfType(TA.getAsType(), &SeenMultipleGUIDs); 00086 else if (TA.getKind() == TemplateArgument::Declaration) 00087 UuidForTA = 00088 GetUuidAttrOfType(TA.getAsDecl()->getType(), &SeenMultipleGUIDs); 00089 00090 // If the template argument has a UUID, there are three cases: 00091 // - This is the first UUID seen for this RecordDecl. 00092 // - This is a different UUID than previously seen for this RecordDecl. 00093 // - This is the same UUID than previously seen for this RecordDecl. 00094 if (UuidForTA) { 00095 if (!UuidForRD) 00096 UuidForRD = UuidForTA; 00097 else if (UuidForRD != UuidForTA) 00098 SeenMultipleGUIDs = true; 00099 } 00100 00101 // Seeing multiple UUIDs means that we couldn't find a UUID 00102 if (SeenMultipleGUIDs) { 00103 if (RDHasMultipleGUIDsPtr) 00104 *RDHasMultipleGUIDsPtr = true; 00105 return nullptr; 00106 } 00107 } 00108 00109 return UuidForRD; 00110 } 00111 00112 return nullptr; 00113 } 00114 00115 StringRef CXXUuidofExpr::getUuidAsStringRef(ASTContext &Context) const { 00116 StringRef Uuid; 00117 if (isTypeOperand()) 00118 Uuid = CXXUuidofExpr::GetUuidAttrOfType(getTypeOperand(Context))->getGuid(); 00119 else { 00120 // Special case: __uuidof(0) means an all-zero GUID. 00121 Expr *Op = getExprOperand(); 00122 if (!Op->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) 00123 Uuid = CXXUuidofExpr::GetUuidAttrOfType(Op->getType())->getGuid(); 00124 else 00125 Uuid = "00000000-0000-0000-0000-000000000000"; 00126 } 00127 return Uuid; 00128 } 00129 00130 // CXXScalarValueInitExpr 00131 SourceLocation CXXScalarValueInitExpr::getLocStart() const { 00132 return TypeInfo ? TypeInfo->getTypeLoc().getBeginLoc() : RParenLoc; 00133 } 00134 00135 // CXXNewExpr 00136 CXXNewExpr::CXXNewExpr(const ASTContext &C, bool globalNew, 00137 FunctionDecl *operatorNew, FunctionDecl *operatorDelete, 00138 bool usualArrayDeleteWantsSize, 00139 ArrayRef<Expr*> placementArgs, 00140 SourceRange typeIdParens, Expr *arraySize, 00141 InitializationStyle initializationStyle, 00142 Expr *initializer, QualType ty, 00143 TypeSourceInfo *allocatedTypeInfo, 00144 SourceRange Range, SourceRange directInitRange) 00145 : Expr(CXXNewExprClass, ty, VK_RValue, OK_Ordinary, 00146 ty->isDependentType(), ty->isDependentType(), 00147 ty->isInstantiationDependentType(), 00148 ty->containsUnexpandedParameterPack()), 00149 SubExprs(nullptr), OperatorNew(operatorNew), OperatorDelete(operatorDelete), 00150 AllocatedTypeInfo(allocatedTypeInfo), TypeIdParens(typeIdParens), 00151 Range(Range), DirectInitRange(directInitRange), 00152 GlobalNew(globalNew), UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize) { 00153 assert((initializer != nullptr || initializationStyle == NoInit) && 00154 "Only NoInit can have no initializer."); 00155 StoredInitializationStyle = initializer ? initializationStyle + 1 : 0; 00156 AllocateArgsArray(C, arraySize != nullptr, placementArgs.size(), 00157 initializer != nullptr); 00158 unsigned i = 0; 00159 if (Array) { 00160 if (arraySize->isInstantiationDependent()) 00161 ExprBits.InstantiationDependent = true; 00162 00163 if (arraySize->containsUnexpandedParameterPack()) 00164 ExprBits.ContainsUnexpandedParameterPack = true; 00165 00166 SubExprs[i++] = arraySize; 00167 } 00168 00169 if (initializer) { 00170 if (initializer->isInstantiationDependent()) 00171 ExprBits.InstantiationDependent = true; 00172 00173 if (initializer->containsUnexpandedParameterPack()) 00174 ExprBits.ContainsUnexpandedParameterPack = true; 00175 00176 SubExprs[i++] = initializer; 00177 } 00178 00179 for (unsigned j = 0; j != placementArgs.size(); ++j) { 00180 if (placementArgs[j]->isInstantiationDependent()) 00181 ExprBits.InstantiationDependent = true; 00182 if (placementArgs[j]->containsUnexpandedParameterPack()) 00183 ExprBits.ContainsUnexpandedParameterPack = true; 00184 00185 SubExprs[i++] = placementArgs[j]; 00186 } 00187 00188 switch (getInitializationStyle()) { 00189 case CallInit: 00190 this->Range.setEnd(DirectInitRange.getEnd()); break; 00191 case ListInit: 00192 this->Range.setEnd(getInitializer()->getSourceRange().getEnd()); break; 00193 default: 00194 if (TypeIdParens.isValid()) 00195 this->Range.setEnd(TypeIdParens.getEnd()); 00196 break; 00197 } 00198 } 00199 00200 void CXXNewExpr::AllocateArgsArray(const ASTContext &C, bool isArray, 00201 unsigned numPlaceArgs, bool hasInitializer){ 00202 assert(SubExprs == nullptr && "SubExprs already allocated"); 00203 Array = isArray; 00204 NumPlacementArgs = numPlaceArgs; 00205 00206 unsigned TotalSize = Array + hasInitializer + NumPlacementArgs; 00207 SubExprs = new (C) Stmt*[TotalSize]; 00208 } 00209 00210 bool CXXNewExpr::shouldNullCheckAllocation(const ASTContext &Ctx) const { 00211 return getOperatorNew()->getType()-> 00212 castAs<FunctionProtoType>()->isNothrow(Ctx); 00213 } 00214 00215 // CXXDeleteExpr 00216 QualType CXXDeleteExpr::getDestroyedType() const { 00217 const Expr *Arg = getArgument(); 00218 // The type-to-delete may not be a pointer if it's a dependent type. 00219 const QualType ArgType = Arg->getType(); 00220 00221 if (ArgType->isDependentType() && !ArgType->isPointerType()) 00222 return QualType(); 00223 00224 return ArgType->getAs<PointerType>()->getPointeeType(); 00225 } 00226 00227 // CXXPseudoDestructorExpr 00228 PseudoDestructorTypeStorage::PseudoDestructorTypeStorage(TypeSourceInfo *Info) 00229 : Type(Info) 00230 { 00231 Location = Info->getTypeLoc().getLocalSourceRange().getBegin(); 00232 } 00233 00234 CXXPseudoDestructorExpr::CXXPseudoDestructorExpr(const ASTContext &Context, 00235 Expr *Base, bool isArrow, SourceLocation OperatorLoc, 00236 NestedNameSpecifierLoc QualifierLoc, TypeSourceInfo *ScopeType, 00237 SourceLocation ColonColonLoc, SourceLocation TildeLoc, 00238 PseudoDestructorTypeStorage DestroyedType) 00239 : Expr(CXXPseudoDestructorExprClass, 00240 Context.getPointerType(Context.getFunctionType( 00241 Context.VoidTy, None, 00242 FunctionProtoType::ExtProtoInfo( 00243 Context.getDefaultCallingConvention(false, true)))), 00244 VK_RValue, OK_Ordinary, 00245 /*isTypeDependent=*/(Base->isTypeDependent() || 00246 (DestroyedType.getTypeSourceInfo() && 00247 DestroyedType.getTypeSourceInfo()->getType()->isDependentType())), 00248 /*isValueDependent=*/Base->isValueDependent(), 00249 (Base->isInstantiationDependent() || 00250 (QualifierLoc && 00251 QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent()) || 00252 (ScopeType && 00253 ScopeType->getType()->isInstantiationDependentType()) || 00254 (DestroyedType.getTypeSourceInfo() && 00255 DestroyedType.getTypeSourceInfo()->getType() 00256 ->isInstantiationDependentType())), 00257 // ContainsUnexpandedParameterPack 00258 (Base->containsUnexpandedParameterPack() || 00259 (QualifierLoc && 00260 QualifierLoc.getNestedNameSpecifier() 00261 ->containsUnexpandedParameterPack()) || 00262 (ScopeType && 00263 ScopeType->getType()->containsUnexpandedParameterPack()) || 00264 (DestroyedType.getTypeSourceInfo() && 00265 DestroyedType.getTypeSourceInfo()->getType() 00266 ->containsUnexpandedParameterPack()))), 00267 Base(static_cast<Stmt *>(Base)), IsArrow(isArrow), 00268 OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc), 00269 ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc), 00270 DestroyedType(DestroyedType) { } 00271 00272 QualType CXXPseudoDestructorExpr::getDestroyedType() const { 00273 if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo()) 00274 return TInfo->getType(); 00275 00276 return QualType(); 00277 } 00278 00279 SourceLocation CXXPseudoDestructorExpr::getLocEnd() const { 00280 SourceLocation End = DestroyedType.getLocation(); 00281 if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo()) 00282 End = TInfo->getTypeLoc().getLocalSourceRange().getEnd(); 00283 return End; 00284 } 00285 00286 // UnresolvedLookupExpr 00287 UnresolvedLookupExpr * 00288 UnresolvedLookupExpr::Create(const ASTContext &C, 00289 CXXRecordDecl *NamingClass, 00290 NestedNameSpecifierLoc QualifierLoc, 00291 SourceLocation TemplateKWLoc, 00292 const DeclarationNameInfo &NameInfo, 00293 bool ADL, 00294 const TemplateArgumentListInfo *Args, 00295 UnresolvedSetIterator Begin, 00296 UnresolvedSetIterator End) 00297 { 00298 assert(Args || TemplateKWLoc.isValid()); 00299 unsigned num_args = Args ? Args->size() : 0; 00300 void *Mem = C.Allocate(sizeof(UnresolvedLookupExpr) + 00301 ASTTemplateKWAndArgsInfo::sizeFor(num_args)); 00302 return new (Mem) UnresolvedLookupExpr(C, NamingClass, QualifierLoc, 00303 TemplateKWLoc, NameInfo, 00304 ADL, /*Overload*/ true, Args, 00305 Begin, End); 00306 } 00307 00308 UnresolvedLookupExpr * 00309 UnresolvedLookupExpr::CreateEmpty(const ASTContext &C, 00310 bool HasTemplateKWAndArgsInfo, 00311 unsigned NumTemplateArgs) { 00312 std::size_t size = sizeof(UnresolvedLookupExpr); 00313 if (HasTemplateKWAndArgsInfo) 00314 size += ASTTemplateKWAndArgsInfo::sizeFor(NumTemplateArgs); 00315 00316 void *Mem = C.Allocate(size, llvm::alignOf<UnresolvedLookupExpr>()); 00317 UnresolvedLookupExpr *E = new (Mem) UnresolvedLookupExpr(EmptyShell()); 00318 E->HasTemplateKWAndArgsInfo = HasTemplateKWAndArgsInfo; 00319 return E; 00320 } 00321 00322 OverloadExpr::OverloadExpr(StmtClass K, const ASTContext &C, 00323 NestedNameSpecifierLoc QualifierLoc, 00324 SourceLocation TemplateKWLoc, 00325 const DeclarationNameInfo &NameInfo, 00326 const TemplateArgumentListInfo *TemplateArgs, 00327 UnresolvedSetIterator Begin, 00328 UnresolvedSetIterator End, 00329 bool KnownDependent, 00330 bool KnownInstantiationDependent, 00331 bool KnownContainsUnexpandedParameterPack) 00332 : Expr(K, C.OverloadTy, VK_LValue, OK_Ordinary, KnownDependent, 00333 KnownDependent, 00334 (KnownInstantiationDependent || 00335 NameInfo.isInstantiationDependent() || 00336 (QualifierLoc && 00337 QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())), 00338 (KnownContainsUnexpandedParameterPack || 00339 NameInfo.containsUnexpandedParameterPack() || 00340 (QualifierLoc && 00341 QualifierLoc.getNestedNameSpecifier() 00342 ->containsUnexpandedParameterPack()))), 00343 NameInfo(NameInfo), QualifierLoc(QualifierLoc), 00344 Results(nullptr), NumResults(End - Begin), 00345 HasTemplateKWAndArgsInfo(TemplateArgs != nullptr || 00346 TemplateKWLoc.isValid()) { 00347 NumResults = End - Begin; 00348 if (NumResults) { 00349 // Determine whether this expression is type-dependent. 00350 for (UnresolvedSetImpl::const_iterator I = Begin; I != End; ++I) { 00351 if ((*I)->getDeclContext()->isDependentContext() || 00352 isa<UnresolvedUsingValueDecl>(*I)) { 00353 ExprBits.TypeDependent = true; 00354 ExprBits.ValueDependent = true; 00355 ExprBits.InstantiationDependent = true; 00356 } 00357 } 00358 00359 Results = static_cast<DeclAccessPair *>( 00360 C.Allocate(sizeof(DeclAccessPair) * NumResults, 00361 llvm::alignOf<DeclAccessPair>())); 00362 memcpy(Results, &*Begin.getIterator(), 00363 NumResults * sizeof(DeclAccessPair)); 00364 } 00365 00366 // If we have explicit template arguments, check for dependent 00367 // template arguments and whether they contain any unexpanded pack 00368 // expansions. 00369 if (TemplateArgs) { 00370 bool Dependent = false; 00371 bool InstantiationDependent = false; 00372 bool ContainsUnexpandedParameterPack = false; 00373 getTemplateKWAndArgsInfo()->initializeFrom(TemplateKWLoc, *TemplateArgs, 00374 Dependent, 00375 InstantiationDependent, 00376 ContainsUnexpandedParameterPack); 00377 00378 if (Dependent) { 00379 ExprBits.TypeDependent = true; 00380 ExprBits.ValueDependent = true; 00381 } 00382 if (InstantiationDependent) 00383 ExprBits.InstantiationDependent = true; 00384 if (ContainsUnexpandedParameterPack) 00385 ExprBits.ContainsUnexpandedParameterPack = true; 00386 } else if (TemplateKWLoc.isValid()) { 00387 getTemplateKWAndArgsInfo()->initializeFrom(TemplateKWLoc); 00388 } 00389 00390 if (isTypeDependent()) 00391 setType(C.DependentTy); 00392 } 00393 00394 void OverloadExpr::initializeResults(const ASTContext &C, 00395 UnresolvedSetIterator Begin, 00396 UnresolvedSetIterator End) { 00397 assert(!Results && "Results already initialized!"); 00398 NumResults = End - Begin; 00399 if (NumResults) { 00400 Results = static_cast<DeclAccessPair *>( 00401 C.Allocate(sizeof(DeclAccessPair) * NumResults, 00402 00403 llvm::alignOf<DeclAccessPair>())); 00404 memcpy(Results, &*Begin.getIterator(), 00405 NumResults * sizeof(DeclAccessPair)); 00406 } 00407 } 00408 00409 CXXRecordDecl *OverloadExpr::getNamingClass() const { 00410 if (isa<UnresolvedLookupExpr>(this)) 00411 return cast<UnresolvedLookupExpr>(this)->getNamingClass(); 00412 else 00413 return cast<UnresolvedMemberExpr>(this)->getNamingClass(); 00414 } 00415 00416 // DependentScopeDeclRefExpr 00417 DependentScopeDeclRefExpr::DependentScopeDeclRefExpr(QualType T, 00418 NestedNameSpecifierLoc QualifierLoc, 00419 SourceLocation TemplateKWLoc, 00420 const DeclarationNameInfo &NameInfo, 00421 const TemplateArgumentListInfo *Args) 00422 : Expr(DependentScopeDeclRefExprClass, T, VK_LValue, OK_Ordinary, 00423 true, true, 00424 (NameInfo.isInstantiationDependent() || 00425 (QualifierLoc && 00426 QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())), 00427 (NameInfo.containsUnexpandedParameterPack() || 00428 (QualifierLoc && 00429 QualifierLoc.getNestedNameSpecifier() 00430 ->containsUnexpandedParameterPack()))), 00431 QualifierLoc(QualifierLoc), NameInfo(NameInfo), 00432 HasTemplateKWAndArgsInfo(Args != nullptr || TemplateKWLoc.isValid()) 00433 { 00434 if (Args) { 00435 bool Dependent = true; 00436 bool InstantiationDependent = true; 00437 bool ContainsUnexpandedParameterPack 00438 = ExprBits.ContainsUnexpandedParameterPack; 00439 getTemplateKWAndArgsInfo()->initializeFrom(TemplateKWLoc, *Args, 00440 Dependent, 00441 InstantiationDependent, 00442 ContainsUnexpandedParameterPack); 00443 ExprBits.ContainsUnexpandedParameterPack = ContainsUnexpandedParameterPack; 00444 } else if (TemplateKWLoc.isValid()) { 00445 getTemplateKWAndArgsInfo()->initializeFrom(TemplateKWLoc); 00446 } 00447 } 00448 00449 DependentScopeDeclRefExpr * 00450 DependentScopeDeclRefExpr::Create(const ASTContext &C, 00451 NestedNameSpecifierLoc QualifierLoc, 00452 SourceLocation TemplateKWLoc, 00453 const DeclarationNameInfo &NameInfo, 00454 const TemplateArgumentListInfo *Args) { 00455 assert(QualifierLoc && "should be created for dependent qualifiers"); 00456 std::size_t size = sizeof(DependentScopeDeclRefExpr); 00457 if (Args) 00458 size += ASTTemplateKWAndArgsInfo::sizeFor(Args->size()); 00459 else if (TemplateKWLoc.isValid()) 00460 size += ASTTemplateKWAndArgsInfo::sizeFor(0); 00461 void *Mem = C.Allocate(size); 00462 return new (Mem) DependentScopeDeclRefExpr(C.DependentTy, QualifierLoc, 00463 TemplateKWLoc, NameInfo, Args); 00464 } 00465 00466 DependentScopeDeclRefExpr * 00467 DependentScopeDeclRefExpr::CreateEmpty(const ASTContext &C, 00468 bool HasTemplateKWAndArgsInfo, 00469 unsigned NumTemplateArgs) { 00470 std::size_t size = sizeof(DependentScopeDeclRefExpr); 00471 if (HasTemplateKWAndArgsInfo) 00472 size += ASTTemplateKWAndArgsInfo::sizeFor(NumTemplateArgs); 00473 void *Mem = C.Allocate(size); 00474 DependentScopeDeclRefExpr *E 00475 = new (Mem) DependentScopeDeclRefExpr(QualType(), NestedNameSpecifierLoc(), 00476 SourceLocation(), 00477 DeclarationNameInfo(), nullptr); 00478 E->HasTemplateKWAndArgsInfo = HasTemplateKWAndArgsInfo; 00479 return E; 00480 } 00481 00482 SourceLocation CXXConstructExpr::getLocStart() const { 00483 if (isa<CXXTemporaryObjectExpr>(this)) 00484 return cast<CXXTemporaryObjectExpr>(this)->getLocStart(); 00485 return Loc; 00486 } 00487 00488 SourceLocation CXXConstructExpr::getLocEnd() const { 00489 if (isa<CXXTemporaryObjectExpr>(this)) 00490 return cast<CXXTemporaryObjectExpr>(this)->getLocEnd(); 00491 00492 if (ParenOrBraceRange.isValid()) 00493 return ParenOrBraceRange.getEnd(); 00494 00495 SourceLocation End = Loc; 00496 for (unsigned I = getNumArgs(); I > 0; --I) { 00497 const Expr *Arg = getArg(I-1); 00498 if (!Arg->isDefaultArgument()) { 00499 SourceLocation NewEnd = Arg->getLocEnd(); 00500 if (NewEnd.isValid()) { 00501 End = NewEnd; 00502 break; 00503 } 00504 } 00505 } 00506 00507 return End; 00508 } 00509 00510 SourceRange CXXOperatorCallExpr::getSourceRangeImpl() const { 00511 OverloadedOperatorKind Kind = getOperator(); 00512 if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) { 00513 if (getNumArgs() == 1) 00514 // Prefix operator 00515 return SourceRange(getOperatorLoc(), getArg(0)->getLocEnd()); 00516 else 00517 // Postfix operator 00518 return SourceRange(getArg(0)->getLocStart(), getOperatorLoc()); 00519 } else if (Kind == OO_Arrow) { 00520 return getArg(0)->getSourceRange(); 00521 } else if (Kind == OO_Call) { 00522 return SourceRange(getArg(0)->getLocStart(), getRParenLoc()); 00523 } else if (Kind == OO_Subscript) { 00524 return SourceRange(getArg(0)->getLocStart(), getRParenLoc()); 00525 } else if (getNumArgs() == 1) { 00526 return SourceRange(getOperatorLoc(), getArg(0)->getLocEnd()); 00527 } else if (getNumArgs() == 2) { 00528 return SourceRange(getArg(0)->getLocStart(), getArg(1)->getLocEnd()); 00529 } else { 00530 return getOperatorLoc(); 00531 } 00532 } 00533 00534 Expr *CXXMemberCallExpr::getImplicitObjectArgument() const { 00535 const Expr *Callee = getCallee()->IgnoreParens(); 00536 if (const MemberExpr *MemExpr = dyn_cast<MemberExpr>(Callee)) 00537 return MemExpr->getBase(); 00538 if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(Callee)) 00539 if (BO->getOpcode() == BO_PtrMemD || BO->getOpcode() == BO_PtrMemI) 00540 return BO->getLHS(); 00541 00542 // FIXME: Will eventually need to cope with member pointers. 00543 return nullptr; 00544 } 00545 00546 CXXMethodDecl *CXXMemberCallExpr::getMethodDecl() const { 00547 if (const MemberExpr *MemExpr = 00548 dyn_cast<MemberExpr>(getCallee()->IgnoreParens())) 00549 return cast<CXXMethodDecl>(MemExpr->getMemberDecl()); 00550 00551 // FIXME: Will eventually need to cope with member pointers. 00552 return nullptr; 00553 } 00554 00555 00556 CXXRecordDecl *CXXMemberCallExpr::getRecordDecl() const { 00557 Expr* ThisArg = getImplicitObjectArgument(); 00558 if (!ThisArg) 00559 return nullptr; 00560 00561 if (ThisArg->getType()->isAnyPointerType()) 00562 return ThisArg->getType()->getPointeeType()->getAsCXXRecordDecl(); 00563 00564 return ThisArg->getType()->getAsCXXRecordDecl(); 00565 } 00566 00567 00568 //===----------------------------------------------------------------------===// 00569 // Named casts 00570 //===----------------------------------------------------------------------===// 00571 00572 /// getCastName - Get the name of the C++ cast being used, e.g., 00573 /// "static_cast", "dynamic_cast", "reinterpret_cast", or 00574 /// "const_cast". The returned pointer must not be freed. 00575 const char *CXXNamedCastExpr::getCastName() const { 00576 switch (getStmtClass()) { 00577 case CXXStaticCastExprClass: return "static_cast"; 00578 case CXXDynamicCastExprClass: return "dynamic_cast"; 00579 case CXXReinterpretCastExprClass: return "reinterpret_cast"; 00580 case CXXConstCastExprClass: return "const_cast"; 00581 default: return "<invalid cast>"; 00582 } 00583 } 00584 00585 CXXStaticCastExpr *CXXStaticCastExpr::Create(const ASTContext &C, QualType T, 00586 ExprValueKind VK, 00587 CastKind K, Expr *Op, 00588 const CXXCastPath *BasePath, 00589 TypeSourceInfo *WrittenTy, 00590 SourceLocation L, 00591 SourceLocation RParenLoc, 00592 SourceRange AngleBrackets) { 00593 unsigned PathSize = (BasePath ? BasePath->size() : 0); 00594 void *Buffer = C.Allocate(sizeof(CXXStaticCastExpr) 00595 + PathSize * sizeof(CXXBaseSpecifier*)); 00596 CXXStaticCastExpr *E = 00597 new (Buffer) CXXStaticCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, 00598 RParenLoc, AngleBrackets); 00599 if (PathSize) E->setCastPath(*BasePath); 00600 return E; 00601 } 00602 00603 CXXStaticCastExpr *CXXStaticCastExpr::CreateEmpty(const ASTContext &C, 00604 unsigned PathSize) { 00605 void *Buffer = 00606 C.Allocate(sizeof(CXXStaticCastExpr) + PathSize * sizeof(CXXBaseSpecifier*)); 00607 return new (Buffer) CXXStaticCastExpr(EmptyShell(), PathSize); 00608 } 00609 00610 CXXDynamicCastExpr *CXXDynamicCastExpr::Create(const ASTContext &C, QualType T, 00611 ExprValueKind VK, 00612 CastKind K, Expr *Op, 00613 const CXXCastPath *BasePath, 00614 TypeSourceInfo *WrittenTy, 00615 SourceLocation L, 00616 SourceLocation RParenLoc, 00617 SourceRange AngleBrackets) { 00618 unsigned PathSize = (BasePath ? BasePath->size() : 0); 00619 void *Buffer = C.Allocate(sizeof(CXXDynamicCastExpr) 00620 + PathSize * sizeof(CXXBaseSpecifier*)); 00621 CXXDynamicCastExpr *E = 00622 new (Buffer) CXXDynamicCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, 00623 RParenLoc, AngleBrackets); 00624 if (PathSize) E->setCastPath(*BasePath); 00625 return E; 00626 } 00627 00628 CXXDynamicCastExpr *CXXDynamicCastExpr::CreateEmpty(const ASTContext &C, 00629 unsigned PathSize) { 00630 void *Buffer = 00631 C.Allocate(sizeof(CXXDynamicCastExpr) + PathSize * sizeof(CXXBaseSpecifier*)); 00632 return new (Buffer) CXXDynamicCastExpr(EmptyShell(), PathSize); 00633 } 00634 00635 /// isAlwaysNull - Return whether the result of the dynamic_cast is proven 00636 /// to always be null. For example: 00637 /// 00638 /// struct A { }; 00639 /// struct B final : A { }; 00640 /// struct C { }; 00641 /// 00642 /// C *f(B* b) { return dynamic_cast<C*>(b); } 00643 bool CXXDynamicCastExpr::isAlwaysNull() const 00644 { 00645 QualType SrcType = getSubExpr()->getType(); 00646 QualType DestType = getType(); 00647 00648 if (const PointerType *SrcPTy = SrcType->getAs<PointerType>()) { 00649 SrcType = SrcPTy->getPointeeType(); 00650 DestType = DestType->castAs<PointerType>()->getPointeeType(); 00651 } 00652 00653 if (DestType->isVoidType()) 00654 return false; 00655 00656 const CXXRecordDecl *SrcRD = 00657 cast<CXXRecordDecl>(SrcType->castAs<RecordType>()->getDecl()); 00658 00659 if (!SrcRD->hasAttr<FinalAttr>()) 00660 return false; 00661 00662 const CXXRecordDecl *DestRD = 00663 cast<CXXRecordDecl>(DestType->castAs<RecordType>()->getDecl()); 00664 00665 return !DestRD->isDerivedFrom(SrcRD); 00666 } 00667 00668 CXXReinterpretCastExpr * 00669 CXXReinterpretCastExpr::Create(const ASTContext &C, QualType T, 00670 ExprValueKind VK, CastKind K, Expr *Op, 00671 const CXXCastPath *BasePath, 00672 TypeSourceInfo *WrittenTy, SourceLocation L, 00673 SourceLocation RParenLoc, 00674 SourceRange AngleBrackets) { 00675 unsigned PathSize = (BasePath ? BasePath->size() : 0); 00676 void *Buffer = 00677 C.Allocate(sizeof(CXXReinterpretCastExpr) + PathSize * sizeof(CXXBaseSpecifier*)); 00678 CXXReinterpretCastExpr *E = 00679 new (Buffer) CXXReinterpretCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, 00680 RParenLoc, AngleBrackets); 00681 if (PathSize) E->setCastPath(*BasePath); 00682 return E; 00683 } 00684 00685 CXXReinterpretCastExpr * 00686 CXXReinterpretCastExpr::CreateEmpty(const ASTContext &C, unsigned PathSize) { 00687 void *Buffer = C.Allocate(sizeof(CXXReinterpretCastExpr) 00688 + PathSize * sizeof(CXXBaseSpecifier*)); 00689 return new (Buffer) CXXReinterpretCastExpr(EmptyShell(), PathSize); 00690 } 00691 00692 CXXConstCastExpr *CXXConstCastExpr::Create(const ASTContext &C, QualType T, 00693 ExprValueKind VK, Expr *Op, 00694 TypeSourceInfo *WrittenTy, 00695 SourceLocation L, 00696 SourceLocation RParenLoc, 00697 SourceRange AngleBrackets) { 00698 return new (C) CXXConstCastExpr(T, VK, Op, WrittenTy, L, RParenLoc, AngleBrackets); 00699 } 00700 00701 CXXConstCastExpr *CXXConstCastExpr::CreateEmpty(const ASTContext &C) { 00702 return new (C) CXXConstCastExpr(EmptyShell()); 00703 } 00704 00705 CXXFunctionalCastExpr * 00706 CXXFunctionalCastExpr::Create(const ASTContext &C, QualType T, ExprValueKind VK, 00707 TypeSourceInfo *Written, CastKind K, Expr *Op, 00708 const CXXCastPath *BasePath, 00709 SourceLocation L, SourceLocation R) { 00710 unsigned PathSize = (BasePath ? BasePath->size() : 0); 00711 void *Buffer = C.Allocate(sizeof(CXXFunctionalCastExpr) 00712 + PathSize * sizeof(CXXBaseSpecifier*)); 00713 CXXFunctionalCastExpr *E = 00714 new (Buffer) CXXFunctionalCastExpr(T, VK, Written, K, Op, PathSize, L, R); 00715 if (PathSize) E->setCastPath(*BasePath); 00716 return E; 00717 } 00718 00719 CXXFunctionalCastExpr * 00720 CXXFunctionalCastExpr::CreateEmpty(const ASTContext &C, unsigned PathSize) { 00721 void *Buffer = C.Allocate(sizeof(CXXFunctionalCastExpr) 00722 + PathSize * sizeof(CXXBaseSpecifier*)); 00723 return new (Buffer) CXXFunctionalCastExpr(EmptyShell(), PathSize); 00724 } 00725 00726 SourceLocation CXXFunctionalCastExpr::getLocStart() const { 00727 return getTypeInfoAsWritten()->getTypeLoc().getLocStart(); 00728 } 00729 00730 SourceLocation CXXFunctionalCastExpr::getLocEnd() const { 00731 return RParenLoc.isValid() ? RParenLoc : getSubExpr()->getLocEnd(); 00732 } 00733 00734 UserDefinedLiteral::LiteralOperatorKind 00735 UserDefinedLiteral::getLiteralOperatorKind() const { 00736 if (getNumArgs() == 0) 00737 return LOK_Template; 00738 if (getNumArgs() == 2) 00739 return LOK_String; 00740 00741 assert(getNumArgs() == 1 && "unexpected #args in literal operator call"); 00742 QualType ParamTy = 00743 cast<FunctionDecl>(getCalleeDecl())->getParamDecl(0)->getType(); 00744 if (ParamTy->isPointerType()) 00745 return LOK_Raw; 00746 if (ParamTy->isAnyCharacterType()) 00747 return LOK_Character; 00748 if (ParamTy->isIntegerType()) 00749 return LOK_Integer; 00750 if (ParamTy->isFloatingType()) 00751 return LOK_Floating; 00752 00753 llvm_unreachable("unknown kind of literal operator"); 00754 } 00755 00756 Expr *UserDefinedLiteral::getCookedLiteral() { 00757 #ifndef NDEBUG 00758 LiteralOperatorKind LOK = getLiteralOperatorKind(); 00759 assert(LOK != LOK_Template && LOK != LOK_Raw && "not a cooked literal"); 00760 #endif 00761 return getArg(0); 00762 } 00763 00764 const IdentifierInfo *UserDefinedLiteral::getUDSuffix() const { 00765 return cast<FunctionDecl>(getCalleeDecl())->getLiteralIdentifier(); 00766 } 00767 00768 CXXDefaultArgExpr * 00769 CXXDefaultArgExpr::Create(const ASTContext &C, SourceLocation Loc, 00770 ParmVarDecl *Param, Expr *SubExpr) { 00771 void *Mem = C.Allocate(sizeof(CXXDefaultArgExpr) + sizeof(Stmt *)); 00772 return new (Mem) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param, 00773 SubExpr); 00774 } 00775 00776 CXXDefaultInitExpr::CXXDefaultInitExpr(const ASTContext &C, SourceLocation Loc, 00777 FieldDecl *Field, QualType T) 00778 : Expr(CXXDefaultInitExprClass, T.getNonLValueExprType(C), 00779 T->isLValueReferenceType() ? VK_LValue : T->isRValueReferenceType() 00780 ? VK_XValue 00781 : VK_RValue, 00782 /*FIXME*/ OK_Ordinary, false, false, false, false), 00783 Field(Field), Loc(Loc) { 00784 assert(Field->hasInClassInitializer()); 00785 } 00786 00787 CXXTemporary *CXXTemporary::Create(const ASTContext &C, 00788 const CXXDestructorDecl *Destructor) { 00789 return new (C) CXXTemporary(Destructor); 00790 } 00791 00792 CXXBindTemporaryExpr *CXXBindTemporaryExpr::Create(const ASTContext &C, 00793 CXXTemporary *Temp, 00794 Expr* SubExpr) { 00795 assert((SubExpr->getType()->isRecordType() || 00796 SubExpr->getType()->isArrayType()) && 00797 "Expression bound to a temporary must have record or array type!"); 00798 00799 return new (C) CXXBindTemporaryExpr(Temp, SubExpr); 00800 } 00801 00802 CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(const ASTContext &C, 00803 CXXConstructorDecl *Cons, 00804 TypeSourceInfo *Type, 00805 ArrayRef<Expr*> Args, 00806 SourceRange ParenOrBraceRange, 00807 bool HadMultipleCandidates, 00808 bool ListInitialization, 00809 bool StdInitListInitialization, 00810 bool ZeroInitialization) 00811 : CXXConstructExpr(C, CXXTemporaryObjectExprClass, 00812 Type->getType().getNonReferenceType(), 00813 Type->getTypeLoc().getBeginLoc(), 00814 Cons, false, Args, 00815 HadMultipleCandidates, 00816 ListInitialization, 00817 StdInitListInitialization, 00818 ZeroInitialization, 00819 CXXConstructExpr::CK_Complete, ParenOrBraceRange), 00820 Type(Type) { 00821 } 00822 00823 SourceLocation CXXTemporaryObjectExpr::getLocStart() const { 00824 return Type->getTypeLoc().getBeginLoc(); 00825 } 00826 00827 SourceLocation CXXTemporaryObjectExpr::getLocEnd() const { 00828 SourceLocation Loc = getParenOrBraceRange().getEnd(); 00829 if (Loc.isInvalid() && getNumArgs()) 00830 Loc = getArg(getNumArgs()-1)->getLocEnd(); 00831 return Loc; 00832 } 00833 00834 CXXConstructExpr *CXXConstructExpr::Create(const ASTContext &C, QualType T, 00835 SourceLocation Loc, 00836 CXXConstructorDecl *D, bool Elidable, 00837 ArrayRef<Expr*> Args, 00838 bool HadMultipleCandidates, 00839 bool ListInitialization, 00840 bool StdInitListInitialization, 00841 bool ZeroInitialization, 00842 ConstructionKind ConstructKind, 00843 SourceRange ParenOrBraceRange) { 00844 return new (C) CXXConstructExpr(C, CXXConstructExprClass, T, Loc, D, 00845 Elidable, Args, 00846 HadMultipleCandidates, ListInitialization, 00847 StdInitListInitialization, 00848 ZeroInitialization, ConstructKind, 00849 ParenOrBraceRange); 00850 } 00851 00852 CXXConstructExpr::CXXConstructExpr(const ASTContext &C, StmtClass SC, 00853 QualType T, SourceLocation Loc, 00854 CXXConstructorDecl *D, bool elidable, 00855 ArrayRef<Expr*> args, 00856 bool HadMultipleCandidates, 00857 bool ListInitialization, 00858 bool StdInitListInitialization, 00859 bool ZeroInitialization, 00860 ConstructionKind ConstructKind, 00861 SourceRange ParenOrBraceRange) 00862 : Expr(SC, T, VK_RValue, OK_Ordinary, 00863 T->isDependentType(), T->isDependentType(), 00864 T->isInstantiationDependentType(), 00865 T->containsUnexpandedParameterPack()), 00866 Constructor(D), Loc(Loc), ParenOrBraceRange(ParenOrBraceRange), 00867 NumArgs(args.size()), 00868 Elidable(elidable), HadMultipleCandidates(HadMultipleCandidates), 00869 ListInitialization(ListInitialization), 00870 StdInitListInitialization(StdInitListInitialization), 00871 ZeroInitialization(ZeroInitialization), 00872 ConstructKind(ConstructKind), Args(nullptr) 00873 { 00874 if (NumArgs) { 00875 Args = new (C) Stmt*[args.size()]; 00876 00877 for (unsigned i = 0; i != args.size(); ++i) { 00878 assert(args[i] && "NULL argument in CXXConstructExpr"); 00879 00880 if (args[i]->isValueDependent()) 00881 ExprBits.ValueDependent = true; 00882 if (args[i]->isInstantiationDependent()) 00883 ExprBits.InstantiationDependent = true; 00884 if (args[i]->containsUnexpandedParameterPack()) 00885 ExprBits.ContainsUnexpandedParameterPack = true; 00886 00887 Args[i] = args[i]; 00888 } 00889 } 00890 } 00891 00892 LambdaCapture::LambdaCapture(SourceLocation Loc, bool Implicit, 00893 LambdaCaptureKind Kind, VarDecl *Var, 00894 SourceLocation EllipsisLoc) 00895 : DeclAndBits(Var, 0), Loc(Loc), EllipsisLoc(EllipsisLoc) 00896 { 00897 unsigned Bits = 0; 00898 if (Implicit) 00899 Bits |= Capture_Implicit; 00900 00901 switch (Kind) { 00902 case LCK_This: 00903 assert(!Var && "'this' capture cannot have a variable!"); 00904 break; 00905 00906 case LCK_ByCopy: 00907 Bits |= Capture_ByCopy; 00908 // Fall through 00909 case LCK_ByRef: 00910 assert(Var && "capture must have a variable!"); 00911 break; 00912 case LCK_VLAType: 00913 assert(!Var && "VLA type capture cannot have a variable!"); 00914 Bits |= Capture_ByCopy; 00915 break; 00916 } 00917 DeclAndBits.setInt(Bits); 00918 } 00919 00920 LambdaCaptureKind LambdaCapture::getCaptureKind() const { 00921 Decl *D = DeclAndBits.getPointer(); 00922 bool CapByCopy = DeclAndBits.getInt() & Capture_ByCopy; 00923 if (!D) 00924 return CapByCopy ? LCK_VLAType : LCK_This; 00925 00926 return CapByCopy ? LCK_ByCopy : LCK_ByRef; 00927 } 00928 00929 LambdaExpr::LambdaExpr(QualType T, 00930 SourceRange IntroducerRange, 00931 LambdaCaptureDefault CaptureDefault, 00932 SourceLocation CaptureDefaultLoc, 00933 ArrayRef<Capture> Captures, 00934 bool ExplicitParams, 00935 bool ExplicitResultType, 00936 ArrayRef<Expr *> CaptureInits, 00937 ArrayRef<VarDecl *> ArrayIndexVars, 00938 ArrayRef<unsigned> ArrayIndexStarts, 00939 SourceLocation ClosingBrace, 00940 bool ContainsUnexpandedParameterPack) 00941 : Expr(LambdaExprClass, T, VK_RValue, OK_Ordinary, 00942 T->isDependentType(), T->isDependentType(), T->isDependentType(), 00943 ContainsUnexpandedParameterPack), 00944 IntroducerRange(IntroducerRange), 00945 CaptureDefaultLoc(CaptureDefaultLoc), 00946 NumCaptures(Captures.size()), 00947 CaptureDefault(CaptureDefault), 00948 ExplicitParams(ExplicitParams), 00949 ExplicitResultType(ExplicitResultType), 00950 ClosingBrace(ClosingBrace) 00951 { 00952 assert(CaptureInits.size() == Captures.size() && "Wrong number of arguments"); 00953 CXXRecordDecl *Class = getLambdaClass(); 00954 CXXRecordDecl::LambdaDefinitionData &Data = Class->getLambdaData(); 00955 00956 // FIXME: Propagate "has unexpanded parameter pack" bit. 00957 00958 // Copy captures. 00959 const ASTContext &Context = Class->getASTContext(); 00960 Data.NumCaptures = NumCaptures; 00961 Data.NumExplicitCaptures = 0; 00962 Data.Captures = (Capture *)Context.Allocate(sizeof(Capture) * NumCaptures); 00963 Capture *ToCapture = Data.Captures; 00964 for (unsigned I = 0, N = Captures.size(); I != N; ++I) { 00965 if (Captures[I].isExplicit()) 00966 ++Data.NumExplicitCaptures; 00967 00968 *ToCapture++ = Captures[I]; 00969 } 00970 00971 // Copy initialization expressions for the non-static data members. 00972 Stmt **Stored = getStoredStmts(); 00973 for (unsigned I = 0, N = CaptureInits.size(); I != N; ++I) 00974 *Stored++ = CaptureInits[I]; 00975 00976 // Copy the body of the lambda. 00977 *Stored++ = getCallOperator()->getBody(); 00978 00979 // Copy the array index variables, if any. 00980 HasArrayIndexVars = !ArrayIndexVars.empty(); 00981 if (HasArrayIndexVars) { 00982 assert(ArrayIndexStarts.size() == NumCaptures); 00983 memcpy(getArrayIndexVars(), ArrayIndexVars.data(), 00984 sizeof(VarDecl *) * ArrayIndexVars.size()); 00985 memcpy(getArrayIndexStarts(), ArrayIndexStarts.data(), 00986 sizeof(unsigned) * Captures.size()); 00987 getArrayIndexStarts()[Captures.size()] = ArrayIndexVars.size(); 00988 } 00989 } 00990 00991 LambdaExpr *LambdaExpr::Create(const ASTContext &Context, 00992 CXXRecordDecl *Class, 00993 SourceRange IntroducerRange, 00994 LambdaCaptureDefault CaptureDefault, 00995 SourceLocation CaptureDefaultLoc, 00996 ArrayRef<Capture> Captures, 00997 bool ExplicitParams, 00998 bool ExplicitResultType, 00999 ArrayRef<Expr *> CaptureInits, 01000 ArrayRef<VarDecl *> ArrayIndexVars, 01001 ArrayRef<unsigned> ArrayIndexStarts, 01002 SourceLocation ClosingBrace, 01003 bool ContainsUnexpandedParameterPack) { 01004 // Determine the type of the expression (i.e., the type of the 01005 // function object we're creating). 01006 QualType T = Context.getTypeDeclType(Class); 01007 01008 unsigned Size = sizeof(LambdaExpr) + sizeof(Stmt *) * (Captures.size() + 1); 01009 if (!ArrayIndexVars.empty()) { 01010 Size += sizeof(unsigned) * (Captures.size() + 1); 01011 // Realign for following VarDecl array. 01012 Size = llvm::RoundUpToAlignment(Size, llvm::alignOf<VarDecl*>()); 01013 Size += sizeof(VarDecl *) * ArrayIndexVars.size(); 01014 } 01015 void *Mem = Context.Allocate(Size); 01016 return new (Mem) LambdaExpr(T, IntroducerRange, 01017 CaptureDefault, CaptureDefaultLoc, Captures, 01018 ExplicitParams, ExplicitResultType, 01019 CaptureInits, ArrayIndexVars, ArrayIndexStarts, 01020 ClosingBrace, ContainsUnexpandedParameterPack); 01021 } 01022 01023 LambdaExpr *LambdaExpr::CreateDeserialized(const ASTContext &C, 01024 unsigned NumCaptures, 01025 unsigned NumArrayIndexVars) { 01026 unsigned Size = sizeof(LambdaExpr) + sizeof(Stmt *) * (NumCaptures + 1); 01027 if (NumArrayIndexVars) 01028 Size += sizeof(VarDecl) * NumArrayIndexVars 01029 + sizeof(unsigned) * (NumCaptures + 1); 01030 void *Mem = C.Allocate(Size); 01031 return new (Mem) LambdaExpr(EmptyShell(), NumCaptures, NumArrayIndexVars > 0); 01032 } 01033 01034 LambdaExpr::capture_iterator LambdaExpr::capture_begin() const { 01035 return getLambdaClass()->getLambdaData().Captures; 01036 } 01037 01038 LambdaExpr::capture_iterator LambdaExpr::capture_end() const { 01039 return capture_begin() + NumCaptures; 01040 } 01041 01042 LambdaExpr::capture_range LambdaExpr::captures() const { 01043 return capture_range(capture_begin(), capture_end()); 01044 } 01045 01046 LambdaExpr::capture_iterator LambdaExpr::explicit_capture_begin() const { 01047 return capture_begin(); 01048 } 01049 01050 LambdaExpr::capture_iterator LambdaExpr::explicit_capture_end() const { 01051 struct CXXRecordDecl::LambdaDefinitionData &Data 01052 = getLambdaClass()->getLambdaData(); 01053 return Data.Captures + Data.NumExplicitCaptures; 01054 } 01055 01056 LambdaExpr::capture_range LambdaExpr::explicit_captures() const { 01057 return capture_range(explicit_capture_begin(), explicit_capture_end()); 01058 } 01059 01060 LambdaExpr::capture_iterator LambdaExpr::implicit_capture_begin() const { 01061 return explicit_capture_end(); 01062 } 01063 01064 LambdaExpr::capture_iterator LambdaExpr::implicit_capture_end() const { 01065 return capture_end(); 01066 } 01067 01068 LambdaExpr::capture_range LambdaExpr::implicit_captures() const { 01069 return capture_range(implicit_capture_begin(), implicit_capture_end()); 01070 } 01071 01072 ArrayRef<VarDecl *> 01073 LambdaExpr::getCaptureInitIndexVars(capture_init_iterator Iter) const { 01074 assert(HasArrayIndexVars && "No array index-var data?"); 01075 01076 unsigned Index = Iter - capture_init_begin(); 01077 assert(Index < getLambdaClass()->getLambdaData().NumCaptures && 01078 "Capture index out-of-range"); 01079 VarDecl **IndexVars = getArrayIndexVars(); 01080 unsigned *IndexStarts = getArrayIndexStarts(); 01081 return llvm::makeArrayRef(IndexVars + IndexStarts[Index], 01082 IndexVars + IndexStarts[Index + 1]); 01083 } 01084 01085 CXXRecordDecl *LambdaExpr::getLambdaClass() const { 01086 return getType()->getAsCXXRecordDecl(); 01087 } 01088 01089 CXXMethodDecl *LambdaExpr::getCallOperator() const { 01090 CXXRecordDecl *Record = getLambdaClass(); 01091 return Record->getLambdaCallOperator(); 01092 } 01093 01094 TemplateParameterList *LambdaExpr::getTemplateParameterList() const { 01095 CXXRecordDecl *Record = getLambdaClass(); 01096 return Record->getGenericLambdaTemplateParameterList(); 01097 01098 } 01099 01100 CompoundStmt *LambdaExpr::getBody() const { 01101 if (!getStoredStmts()[NumCaptures]) 01102 getStoredStmts()[NumCaptures] = getCallOperator()->getBody(); 01103 01104 return reinterpret_cast<CompoundStmt *>(getStoredStmts()[NumCaptures]); 01105 } 01106 01107 bool LambdaExpr::isMutable() const { 01108 return !getCallOperator()->isConst(); 01109 } 01110 01111 ExprWithCleanups::ExprWithCleanups(Expr *subexpr, 01112 ArrayRef<CleanupObject> objects) 01113 : Expr(ExprWithCleanupsClass, subexpr->getType(), 01114 subexpr->getValueKind(), subexpr->getObjectKind(), 01115 subexpr->isTypeDependent(), subexpr->isValueDependent(), 01116 subexpr->isInstantiationDependent(), 01117 subexpr->containsUnexpandedParameterPack()), 01118 SubExpr(subexpr) { 01119 ExprWithCleanupsBits.NumObjects = objects.size(); 01120 for (unsigned i = 0, e = objects.size(); i != e; ++i) 01121 getObjectsBuffer()[i] = objects[i]; 01122 } 01123 01124 ExprWithCleanups *ExprWithCleanups::Create(const ASTContext &C, Expr *subexpr, 01125 ArrayRef<CleanupObject> objects) { 01126 size_t size = sizeof(ExprWithCleanups) 01127 + objects.size() * sizeof(CleanupObject); 01128 void *buffer = C.Allocate(size, llvm::alignOf<ExprWithCleanups>()); 01129 return new (buffer) ExprWithCleanups(subexpr, objects); 01130 } 01131 01132 ExprWithCleanups::ExprWithCleanups(EmptyShell empty, unsigned numObjects) 01133 : Expr(ExprWithCleanupsClass, empty) { 01134 ExprWithCleanupsBits.NumObjects = numObjects; 01135 } 01136 01137 ExprWithCleanups *ExprWithCleanups::Create(const ASTContext &C, 01138 EmptyShell empty, 01139 unsigned numObjects) { 01140 size_t size = sizeof(ExprWithCleanups) + numObjects * sizeof(CleanupObject); 01141 void *buffer = C.Allocate(size, llvm::alignOf<ExprWithCleanups>()); 01142 return new (buffer) ExprWithCleanups(empty, numObjects); 01143 } 01144 01145 CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(TypeSourceInfo *Type, 01146 SourceLocation LParenLoc, 01147 ArrayRef<Expr*> Args, 01148 SourceLocation RParenLoc) 01149 : Expr(CXXUnresolvedConstructExprClass, 01150 Type->getType().getNonReferenceType(), 01151 (Type->getType()->isLValueReferenceType() ? VK_LValue 01152 :Type->getType()->isRValueReferenceType()? VK_XValue 01153 :VK_RValue), 01154 OK_Ordinary, 01155 Type->getType()->isDependentType(), true, true, 01156 Type->getType()->containsUnexpandedParameterPack()), 01157 Type(Type), 01158 LParenLoc(LParenLoc), 01159 RParenLoc(RParenLoc), 01160 NumArgs(Args.size()) { 01161 Stmt **StoredArgs = reinterpret_cast<Stmt **>(this + 1); 01162 for (unsigned I = 0; I != Args.size(); ++I) { 01163 if (Args[I]->containsUnexpandedParameterPack()) 01164 ExprBits.ContainsUnexpandedParameterPack = true; 01165 01166 StoredArgs[I] = Args[I]; 01167 } 01168 } 01169 01170 CXXUnresolvedConstructExpr * 01171 CXXUnresolvedConstructExpr::Create(const ASTContext &C, 01172 TypeSourceInfo *Type, 01173 SourceLocation LParenLoc, 01174 ArrayRef<Expr*> Args, 01175 SourceLocation RParenLoc) { 01176 void *Mem = C.Allocate(sizeof(CXXUnresolvedConstructExpr) + 01177 sizeof(Expr *) * Args.size()); 01178 return new (Mem) CXXUnresolvedConstructExpr(Type, LParenLoc, Args, RParenLoc); 01179 } 01180 01181 CXXUnresolvedConstructExpr * 01182 CXXUnresolvedConstructExpr::CreateEmpty(const ASTContext &C, unsigned NumArgs) { 01183 Stmt::EmptyShell Empty; 01184 void *Mem = C.Allocate(sizeof(CXXUnresolvedConstructExpr) + 01185 sizeof(Expr *) * NumArgs); 01186 return new (Mem) CXXUnresolvedConstructExpr(Empty, NumArgs); 01187 } 01188 01189 SourceLocation CXXUnresolvedConstructExpr::getLocStart() const { 01190 return Type->getTypeLoc().getBeginLoc(); 01191 } 01192 01193 CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(const ASTContext &C, 01194 Expr *Base, QualType BaseType, 01195 bool IsArrow, 01196 SourceLocation OperatorLoc, 01197 NestedNameSpecifierLoc QualifierLoc, 01198 SourceLocation TemplateKWLoc, 01199 NamedDecl *FirstQualifierFoundInScope, 01200 DeclarationNameInfo MemberNameInfo, 01201 const TemplateArgumentListInfo *TemplateArgs) 01202 : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, 01203 VK_LValue, OK_Ordinary, true, true, true, 01204 ((Base && Base->containsUnexpandedParameterPack()) || 01205 (QualifierLoc && 01206 QualifierLoc.getNestedNameSpecifier() 01207 ->containsUnexpandedParameterPack()) || 01208 MemberNameInfo.containsUnexpandedParameterPack())), 01209 Base(Base), BaseType(BaseType), IsArrow(IsArrow), 01210 HasTemplateKWAndArgsInfo(TemplateArgs != nullptr || 01211 TemplateKWLoc.isValid()), 01212 OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc), 01213 FirstQualifierFoundInScope(FirstQualifierFoundInScope), 01214 MemberNameInfo(MemberNameInfo) { 01215 if (TemplateArgs) { 01216 bool Dependent = true; 01217 bool InstantiationDependent = true; 01218 bool ContainsUnexpandedParameterPack = false; 01219 getTemplateKWAndArgsInfo()->initializeFrom(TemplateKWLoc, *TemplateArgs, 01220 Dependent, 01221 InstantiationDependent, 01222 ContainsUnexpandedParameterPack); 01223 if (ContainsUnexpandedParameterPack) 01224 ExprBits.ContainsUnexpandedParameterPack = true; 01225 } else if (TemplateKWLoc.isValid()) { 01226 getTemplateKWAndArgsInfo()->initializeFrom(TemplateKWLoc); 01227 } 01228 } 01229 01230 CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(const ASTContext &C, 01231 Expr *Base, QualType BaseType, 01232 bool IsArrow, 01233 SourceLocation OperatorLoc, 01234 NestedNameSpecifierLoc QualifierLoc, 01235 NamedDecl *FirstQualifierFoundInScope, 01236 DeclarationNameInfo MemberNameInfo) 01237 : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, 01238 VK_LValue, OK_Ordinary, true, true, true, 01239 ((Base && Base->containsUnexpandedParameterPack()) || 01240 (QualifierLoc && 01241 QualifierLoc.getNestedNameSpecifier()-> 01242 containsUnexpandedParameterPack()) || 01243 MemberNameInfo.containsUnexpandedParameterPack())), 01244 Base(Base), BaseType(BaseType), IsArrow(IsArrow), 01245 HasTemplateKWAndArgsInfo(false), 01246 OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc), 01247 FirstQualifierFoundInScope(FirstQualifierFoundInScope), 01248 MemberNameInfo(MemberNameInfo) { } 01249 01250 CXXDependentScopeMemberExpr * 01251 CXXDependentScopeMemberExpr::Create(const ASTContext &C, 01252 Expr *Base, QualType BaseType, bool IsArrow, 01253 SourceLocation OperatorLoc, 01254 NestedNameSpecifierLoc QualifierLoc, 01255 SourceLocation TemplateKWLoc, 01256 NamedDecl *FirstQualifierFoundInScope, 01257 DeclarationNameInfo MemberNameInfo, 01258 const TemplateArgumentListInfo *TemplateArgs) { 01259 if (!TemplateArgs && !TemplateKWLoc.isValid()) 01260 return new (C) CXXDependentScopeMemberExpr(C, Base, BaseType, 01261 IsArrow, OperatorLoc, 01262 QualifierLoc, 01263 FirstQualifierFoundInScope, 01264 MemberNameInfo); 01265 01266 unsigned NumTemplateArgs = TemplateArgs ? TemplateArgs->size() : 0; 01267 std::size_t size = sizeof(CXXDependentScopeMemberExpr) 01268 + ASTTemplateKWAndArgsInfo::sizeFor(NumTemplateArgs); 01269 01270 void *Mem = C.Allocate(size, llvm::alignOf<CXXDependentScopeMemberExpr>()); 01271 return new (Mem) CXXDependentScopeMemberExpr(C, Base, BaseType, 01272 IsArrow, OperatorLoc, 01273 QualifierLoc, 01274 TemplateKWLoc, 01275 FirstQualifierFoundInScope, 01276 MemberNameInfo, TemplateArgs); 01277 } 01278 01279 CXXDependentScopeMemberExpr * 01280 CXXDependentScopeMemberExpr::CreateEmpty(const ASTContext &C, 01281 bool HasTemplateKWAndArgsInfo, 01282 unsigned NumTemplateArgs) { 01283 if (!HasTemplateKWAndArgsInfo) 01284 return new (C) CXXDependentScopeMemberExpr(C, nullptr, QualType(), 01285 0, SourceLocation(), 01286 NestedNameSpecifierLoc(), 01287 nullptr, DeclarationNameInfo()); 01288 01289 std::size_t size = sizeof(CXXDependentScopeMemberExpr) + 01290 ASTTemplateKWAndArgsInfo::sizeFor(NumTemplateArgs); 01291 void *Mem = C.Allocate(size, llvm::alignOf<CXXDependentScopeMemberExpr>()); 01292 CXXDependentScopeMemberExpr *E 01293 = new (Mem) CXXDependentScopeMemberExpr(C, nullptr, QualType(), 01294 0, SourceLocation(), 01295 NestedNameSpecifierLoc(), 01296 SourceLocation(), nullptr, 01297 DeclarationNameInfo(), nullptr); 01298 E->HasTemplateKWAndArgsInfo = true; 01299 return E; 01300 } 01301 01302 bool CXXDependentScopeMemberExpr::isImplicitAccess() const { 01303 if (!Base) 01304 return true; 01305 01306 return cast<Expr>(Base)->isImplicitCXXThis(); 01307 } 01308 01309 static bool hasOnlyNonStaticMemberFunctions(UnresolvedSetIterator begin, 01310 UnresolvedSetIterator end) { 01311 do { 01312 NamedDecl *decl = *begin; 01313 if (isa<UnresolvedUsingValueDecl>(decl)) 01314 return false; 01315 01316 // Unresolved member expressions should only contain methods and 01317 // method templates. 01318 if (cast<CXXMethodDecl>(decl->getUnderlyingDecl()->getAsFunction()) 01319 ->isStatic()) 01320 return false; 01321 } while (++begin != end); 01322 01323 return true; 01324 } 01325 01326 UnresolvedMemberExpr::UnresolvedMemberExpr(const ASTContext &C, 01327 bool HasUnresolvedUsing, 01328 Expr *Base, QualType BaseType, 01329 bool IsArrow, 01330 SourceLocation OperatorLoc, 01331 NestedNameSpecifierLoc QualifierLoc, 01332 SourceLocation TemplateKWLoc, 01333 const DeclarationNameInfo &MemberNameInfo, 01334 const TemplateArgumentListInfo *TemplateArgs, 01335 UnresolvedSetIterator Begin, 01336 UnresolvedSetIterator End) 01337 : OverloadExpr(UnresolvedMemberExprClass, C, QualifierLoc, TemplateKWLoc, 01338 MemberNameInfo, TemplateArgs, Begin, End, 01339 // Dependent 01340 ((Base && Base->isTypeDependent()) || 01341 BaseType->isDependentType()), 01342 ((Base && Base->isInstantiationDependent()) || 01343 BaseType->isInstantiationDependentType()), 01344 // Contains unexpanded parameter pack 01345 ((Base && Base->containsUnexpandedParameterPack()) || 01346 BaseType->containsUnexpandedParameterPack())), 01347 IsArrow(IsArrow), HasUnresolvedUsing(HasUnresolvedUsing), 01348 Base(Base), BaseType(BaseType), OperatorLoc(OperatorLoc) { 01349 01350 // Check whether all of the members are non-static member functions, 01351 // and if so, mark give this bound-member type instead of overload type. 01352 if (hasOnlyNonStaticMemberFunctions(Begin, End)) 01353 setType(C.BoundMemberTy); 01354 } 01355 01356 bool UnresolvedMemberExpr::isImplicitAccess() const { 01357 if (!Base) 01358 return true; 01359 01360 return cast<Expr>(Base)->isImplicitCXXThis(); 01361 } 01362 01363 UnresolvedMemberExpr * 01364 UnresolvedMemberExpr::Create(const ASTContext &C, bool HasUnresolvedUsing, 01365 Expr *Base, QualType BaseType, bool IsArrow, 01366 SourceLocation OperatorLoc, 01367 NestedNameSpecifierLoc QualifierLoc, 01368 SourceLocation TemplateKWLoc, 01369 const DeclarationNameInfo &MemberNameInfo, 01370 const TemplateArgumentListInfo *TemplateArgs, 01371 UnresolvedSetIterator Begin, 01372 UnresolvedSetIterator End) { 01373 std::size_t size = sizeof(UnresolvedMemberExpr); 01374 if (TemplateArgs) 01375 size += ASTTemplateKWAndArgsInfo::sizeFor(TemplateArgs->size()); 01376 else if (TemplateKWLoc.isValid()) 01377 size += ASTTemplateKWAndArgsInfo::sizeFor(0); 01378 01379 void *Mem = C.Allocate(size, llvm::alignOf<UnresolvedMemberExpr>()); 01380 return new (Mem) UnresolvedMemberExpr(C, 01381 HasUnresolvedUsing, Base, BaseType, 01382 IsArrow, OperatorLoc, QualifierLoc, TemplateKWLoc, 01383 MemberNameInfo, TemplateArgs, Begin, End); 01384 } 01385 01386 UnresolvedMemberExpr * 01387 UnresolvedMemberExpr::CreateEmpty(const ASTContext &C, 01388 bool HasTemplateKWAndArgsInfo, 01389 unsigned NumTemplateArgs) { 01390 std::size_t size = sizeof(UnresolvedMemberExpr); 01391 if (HasTemplateKWAndArgsInfo) 01392 size += ASTTemplateKWAndArgsInfo::sizeFor(NumTemplateArgs); 01393 01394 void *Mem = C.Allocate(size, llvm::alignOf<UnresolvedMemberExpr>()); 01395 UnresolvedMemberExpr *E = new (Mem) UnresolvedMemberExpr(EmptyShell()); 01396 E->HasTemplateKWAndArgsInfo = HasTemplateKWAndArgsInfo; 01397 return E; 01398 } 01399 01400 CXXRecordDecl *UnresolvedMemberExpr::getNamingClass() const { 01401 // Unlike for UnresolvedLookupExpr, it is very easy to re-derive this. 01402 01403 // If there was a nested name specifier, it names the naming class. 01404 // It can't be dependent: after all, we were actually able to do the 01405 // lookup. 01406 CXXRecordDecl *Record = nullptr; 01407 auto *NNS = getQualifier(); 01408 if (NNS && NNS->getKind() != NestedNameSpecifier::Super) { 01409 const Type *T = getQualifier()->getAsType(); 01410 assert(T && "qualifier in member expression does not name type"); 01411 Record = T->getAsCXXRecordDecl(); 01412 assert(Record && "qualifier in member expression does not name record"); 01413 } 01414 // Otherwise the naming class must have been the base class. 01415 else { 01416 QualType BaseType = getBaseType().getNonReferenceType(); 01417 if (isArrow()) { 01418 const PointerType *PT = BaseType->getAs<PointerType>(); 01419 assert(PT && "base of arrow member access is not pointer"); 01420 BaseType = PT->getPointeeType(); 01421 } 01422 01423 Record = BaseType->getAsCXXRecordDecl(); 01424 assert(Record && "base of member expression does not name record"); 01425 } 01426 01427 return Record; 01428 } 01429 01430 SubstNonTypeTemplateParmPackExpr:: 01431 SubstNonTypeTemplateParmPackExpr(QualType T, 01432 NonTypeTemplateParmDecl *Param, 01433 SourceLocation NameLoc, 01434 const TemplateArgument &ArgPack) 01435 : Expr(SubstNonTypeTemplateParmPackExprClass, T, VK_RValue, OK_Ordinary, 01436 true, true, true, true), 01437 Param(Param), Arguments(ArgPack.pack_begin()), 01438 NumArguments(ArgPack.pack_size()), NameLoc(NameLoc) { } 01439 01440 TemplateArgument SubstNonTypeTemplateParmPackExpr::getArgumentPack() const { 01441 return TemplateArgument(Arguments, NumArguments); 01442 } 01443 01444 FunctionParmPackExpr::FunctionParmPackExpr(QualType T, ParmVarDecl *ParamPack, 01445 SourceLocation NameLoc, 01446 unsigned NumParams, 01447 Decl * const *Params) 01448 : Expr(FunctionParmPackExprClass, T, VK_LValue, OK_Ordinary, 01449 true, true, true, true), 01450 ParamPack(ParamPack), NameLoc(NameLoc), NumParameters(NumParams) { 01451 if (Params) 01452 std::uninitialized_copy(Params, Params + NumParams, 01453 reinterpret_cast<Decl**>(this+1)); 01454 } 01455 01456 FunctionParmPackExpr * 01457 FunctionParmPackExpr::Create(const ASTContext &Context, QualType T, 01458 ParmVarDecl *ParamPack, SourceLocation NameLoc, 01459 ArrayRef<Decl *> Params) { 01460 return new (Context.Allocate(sizeof(FunctionParmPackExpr) + 01461 sizeof(ParmVarDecl*) * Params.size())) 01462 FunctionParmPackExpr(T, ParamPack, NameLoc, Params.size(), Params.data()); 01463 } 01464 01465 FunctionParmPackExpr * 01466 FunctionParmPackExpr::CreateEmpty(const ASTContext &Context, 01467 unsigned NumParams) { 01468 return new (Context.Allocate(sizeof(FunctionParmPackExpr) + 01469 sizeof(ParmVarDecl*) * NumParams)) 01470 FunctionParmPackExpr(QualType(), nullptr, SourceLocation(), 0, nullptr); 01471 } 01472 01473 void MaterializeTemporaryExpr::setExtendingDecl(const ValueDecl *ExtendedBy, 01474 unsigned ManglingNumber) { 01475 // We only need extra state if we have to remember more than just the Stmt. 01476 if (!ExtendedBy) 01477 return; 01478 01479 // We may need to allocate extra storage for the mangling number and the 01480 // extended-by ValueDecl. 01481 if (!State.is<ExtraState *>()) { 01482 auto ES = new (ExtendedBy->getASTContext()) ExtraState; 01483 ES->Temporary = State.get<Stmt *>(); 01484 State = ES; 01485 } 01486 01487 auto ES = State.get<ExtraState *>(); 01488 ES->ExtendingDecl = ExtendedBy; 01489 ES->ManglingNumber = ManglingNumber; 01490 } 01491 01492 TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind, 01493 ArrayRef<TypeSourceInfo *> Args, 01494 SourceLocation RParenLoc, 01495 bool Value) 01496 : Expr(TypeTraitExprClass, T, VK_RValue, OK_Ordinary, 01497 /*TypeDependent=*/false, 01498 /*ValueDependent=*/false, 01499 /*InstantiationDependent=*/false, 01500 /*ContainsUnexpandedParameterPack=*/false), 01501 Loc(Loc), RParenLoc(RParenLoc) 01502 { 01503 TypeTraitExprBits.Kind = Kind; 01504 TypeTraitExprBits.Value = Value; 01505 TypeTraitExprBits.NumArgs = Args.size(); 01506 01507 TypeSourceInfo **ToArgs = getTypeSourceInfos(); 01508 01509 for (unsigned I = 0, N = Args.size(); I != N; ++I) { 01510 if (Args[I]->getType()->isDependentType()) 01511 setValueDependent(true); 01512 if (Args[I]->getType()->isInstantiationDependentType()) 01513 setInstantiationDependent(true); 01514 if (Args[I]->getType()->containsUnexpandedParameterPack()) 01515 setContainsUnexpandedParameterPack(true); 01516 01517 ToArgs[I] = Args[I]; 01518 } 01519 } 01520 01521 TypeTraitExpr *TypeTraitExpr::Create(const ASTContext &C, QualType T, 01522 SourceLocation Loc, 01523 TypeTrait Kind, 01524 ArrayRef<TypeSourceInfo *> Args, 01525 SourceLocation RParenLoc, 01526 bool Value) { 01527 unsigned Size = sizeof(TypeTraitExpr) + sizeof(TypeSourceInfo*) * Args.size(); 01528 void *Mem = C.Allocate(Size); 01529 return new (Mem) TypeTraitExpr(T, Loc, Kind, Args, RParenLoc, Value); 01530 } 01531 01532 TypeTraitExpr *TypeTraitExpr::CreateDeserialized(const ASTContext &C, 01533 unsigned NumArgs) { 01534 unsigned Size = sizeof(TypeTraitExpr) + sizeof(TypeSourceInfo*) * NumArgs; 01535 void *Mem = C.Allocate(Size); 01536 return new (Mem) TypeTraitExpr(EmptyShell()); 01537 } 01538 01539 void ArrayTypeTraitExpr::anchor() { }