Mercurial > hg > CbC > CbC_llvm
comparison clang/lib/AST/ExprCXX.cpp @ 236:c4bab56944e8 llvm-original
LLVM 16
author | kono |
---|---|
date | Wed, 09 Nov 2022 17:45:10 +0900 (2022-11-09) |
parents | 5f17cb93ff66 |
children | 1f2b6ac9f198 |
comparison
equal
deleted
inserted
replaced
232:70dce7da266c | 236:c4bab56944e8 |
---|---|
194 | 194 |
195 assert((Initializer != nullptr || InitializationStyle == NoInit) && | 195 assert((Initializer != nullptr || InitializationStyle == NoInit) && |
196 "Only NoInit can have no initializer!"); | 196 "Only NoInit can have no initializer!"); |
197 | 197 |
198 CXXNewExprBits.IsGlobalNew = IsGlobalNew; | 198 CXXNewExprBits.IsGlobalNew = IsGlobalNew; |
199 CXXNewExprBits.IsArray = ArraySize.hasValue(); | 199 CXXNewExprBits.IsArray = ArraySize.has_value(); |
200 CXXNewExprBits.ShouldPassAlignment = ShouldPassAlignment; | 200 CXXNewExprBits.ShouldPassAlignment = ShouldPassAlignment; |
201 CXXNewExprBits.UsualArrayDeleteWantsSize = UsualArrayDeleteWantsSize; | 201 CXXNewExprBits.UsualArrayDeleteWantsSize = UsualArrayDeleteWantsSize; |
202 CXXNewExprBits.StoredInitializationStyle = | 202 CXXNewExprBits.StoredInitializationStyle = |
203 Initializer ? InitializationStyle + 1 : 0; | 203 Initializer ? InitializationStyle + 1 : 0; |
204 bool IsParenTypeId = TypeIdParens.isValid(); | 204 bool IsParenTypeId = TypeIdParens.isValid(); |
246 ArrayRef<Expr *> PlacementArgs, SourceRange TypeIdParens, | 246 ArrayRef<Expr *> PlacementArgs, SourceRange TypeIdParens, |
247 Optional<Expr *> ArraySize, | 247 Optional<Expr *> ArraySize, |
248 InitializationStyle InitializationStyle, Expr *Initializer, | 248 InitializationStyle InitializationStyle, Expr *Initializer, |
249 QualType Ty, TypeSourceInfo *AllocatedTypeInfo, | 249 QualType Ty, TypeSourceInfo *AllocatedTypeInfo, |
250 SourceRange Range, SourceRange DirectInitRange) { | 250 SourceRange Range, SourceRange DirectInitRange) { |
251 bool IsArray = ArraySize.hasValue(); | 251 bool IsArray = ArraySize.has_value(); |
252 bool HasInit = Initializer != nullptr; | 252 bool HasInit = Initializer != nullptr; |
253 unsigned NumPlacementArgs = PlacementArgs.size(); | 253 unsigned NumPlacementArgs = PlacementArgs.size(); |
254 bool IsParenTypeId = TypeIdParens.isValid(); | 254 bool IsParenTypeId = TypeIdParens.isValid(); |
255 void *Mem = | 255 void *Mem = |
256 Ctx.Allocate(totalSizeToAlloc<Stmt *, SourceRange>( | 256 Ctx.Allocate(totalSizeToAlloc<Stmt *, SourceRange>( |
312 } | 312 } |
313 | 313 |
314 // CXXPseudoDestructorExpr | 314 // CXXPseudoDestructorExpr |
315 PseudoDestructorTypeStorage::PseudoDestructorTypeStorage(TypeSourceInfo *Info) | 315 PseudoDestructorTypeStorage::PseudoDestructorTypeStorage(TypeSourceInfo *Info) |
316 : Type(Info) { | 316 : Type(Info) { |
317 Location = Info->getTypeLoc().getLocalSourceRange().getBegin(); | 317 Location = Info->getTypeLoc().getBeginLoc(); |
318 } | 318 } |
319 | 319 |
320 CXXPseudoDestructorExpr::CXXPseudoDestructorExpr( | 320 CXXPseudoDestructorExpr::CXXPseudoDestructorExpr( |
321 const ASTContext &Context, Expr *Base, bool isArrow, | 321 const ASTContext &Context, Expr *Base, bool isArrow, |
322 SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, | 322 SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, |
339 } | 339 } |
340 | 340 |
341 SourceLocation CXXPseudoDestructorExpr::getEndLoc() const { | 341 SourceLocation CXXPseudoDestructorExpr::getEndLoc() const { |
342 SourceLocation End = DestroyedType.getLocation(); | 342 SourceLocation End = DestroyedType.getLocation(); |
343 if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo()) | 343 if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo()) |
344 End = TInfo->getTypeLoc().getLocalSourceRange().getEnd(); | 344 End = TInfo->getTypeLoc().getSourceRange().getEnd(); |
345 return End; | 345 return End; |
346 } | 346 } |
347 | 347 |
348 // UnresolvedLookupExpr | 348 // UnresolvedLookupExpr |
349 UnresolvedLookupExpr::UnresolvedLookupExpr( | 349 UnresolvedLookupExpr::UnresolvedLookupExpr( |
987 : CXXConstructExpr( | 987 : CXXConstructExpr( |
988 CXXTemporaryObjectExprClass, Ty, TSI->getTypeLoc().getBeginLoc(), | 988 CXXTemporaryObjectExprClass, Ty, TSI->getTypeLoc().getBeginLoc(), |
989 Cons, /* Elidable=*/false, Args, HadMultipleCandidates, | 989 Cons, /* Elidable=*/false, Args, HadMultipleCandidates, |
990 ListInitialization, StdInitListInitialization, ZeroInitialization, | 990 ListInitialization, StdInitListInitialization, ZeroInitialization, |
991 CXXConstructExpr::CK_Complete, ParenOrBraceRange), | 991 CXXConstructExpr::CK_Complete, ParenOrBraceRange), |
992 TSI(TSI) {} | 992 TSI(TSI) { |
993 setDependence(computeDependence(this)); | |
994 } | |
993 | 995 |
994 CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(EmptyShell Empty, | 996 CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(EmptyShell Empty, |
995 unsigned NumArgs) | 997 unsigned NumArgs) |
996 : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty, NumArgs) {} | 998 : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty, NumArgs) {} |
997 | 999 |
1073 for (unsigned I = 0, N = Args.size(); I != N; ++I) { | 1075 for (unsigned I = 0, N = Args.size(); I != N; ++I) { |
1074 assert(Args[I] && "NULL argument in CXXConstructExpr!"); | 1076 assert(Args[I] && "NULL argument in CXXConstructExpr!"); |
1075 TrailingArgs[I] = Args[I]; | 1077 TrailingArgs[I] = Args[I]; |
1076 } | 1078 } |
1077 | 1079 |
1078 setDependence(computeDependence(this)); | 1080 // CXXTemporaryObjectExpr does this itself after setting its TypeSourceInfo. |
1081 if (SC == CXXConstructExprClass) | |
1082 setDependence(computeDependence(this)); | |
1079 } | 1083 } |
1080 | 1084 |
1081 CXXConstructExpr::CXXConstructExpr(StmtClass SC, EmptyShell Empty, | 1085 CXXConstructExpr::CXXConstructExpr(StmtClass SC, EmptyShell Empty, |
1082 unsigned NumArgs) | 1086 unsigned NumArgs) |
1083 : Expr(SC, Empty), NumArgs(NumArgs) {} | 1087 : Expr(SC, Empty), NumArgs(NumArgs) {} |
1084 | 1088 |
1085 LambdaCapture::LambdaCapture(SourceLocation Loc, bool Implicit, | 1089 LambdaCapture::LambdaCapture(SourceLocation Loc, bool Implicit, |
1086 LambdaCaptureKind Kind, VarDecl *Var, | 1090 LambdaCaptureKind Kind, ValueDecl *Var, |
1087 SourceLocation EllipsisLoc) | 1091 SourceLocation EllipsisLoc) |
1088 : DeclAndBits(Var, 0), Loc(Loc), EllipsisLoc(EllipsisLoc) { | 1092 : DeclAndBits(Var, 0), Loc(Loc), EllipsisLoc(EllipsisLoc) { |
1089 unsigned Bits = 0; | 1093 unsigned Bits = 0; |
1090 if (Implicit) | 1094 if (Implicit) |
1091 Bits |= Capture_Implicit; | 1095 Bits |= Capture_Implicit; |
1092 | 1096 |
1093 switch (Kind) { | 1097 switch (Kind) { |
1094 case LCK_StarThis: | 1098 case LCK_StarThis: |
1095 Bits |= Capture_ByCopy; | 1099 Bits |= Capture_ByCopy; |
1096 LLVM_FALLTHROUGH; | 1100 [[fallthrough]]; |
1097 case LCK_This: | 1101 case LCK_This: |
1098 assert(!Var && "'this' capture cannot have a variable!"); | 1102 assert(!Var && "'this' capture cannot have a variable!"); |
1099 Bits |= Capture_This; | 1103 Bits |= Capture_This; |
1100 break; | 1104 break; |
1101 | 1105 |
1102 case LCK_ByCopy: | 1106 case LCK_ByCopy: |
1103 Bits |= Capture_ByCopy; | 1107 Bits |= Capture_ByCopy; |
1104 LLVM_FALLTHROUGH; | 1108 [[fallthrough]]; |
1105 case LCK_ByRef: | 1109 case LCK_ByRef: |
1106 assert(Var && "capture must have a variable!"); | 1110 assert(Var && "capture must have a variable!"); |
1107 break; | 1111 break; |
1108 case LCK_VLAType: | 1112 case LCK_VLAType: |
1109 assert(!Var && "VLA type capture cannot have a variable!"); | 1113 assert(!Var && "VLA type capture cannot have a variable!"); |
1205 return cast<CompoundStmt>(CoroBody->getBody()); | 1209 return cast<CompoundStmt>(CoroBody->getBody()); |
1206 return cast<CompoundStmt>(Body); | 1210 return cast<CompoundStmt>(Body); |
1207 } | 1211 } |
1208 | 1212 |
1209 bool LambdaExpr::isInitCapture(const LambdaCapture *C) const { | 1213 bool LambdaExpr::isInitCapture(const LambdaCapture *C) const { |
1210 return (C->capturesVariable() && C->getCapturedVar()->isInitCapture() && | 1214 return C->capturesVariable() && C->getCapturedVar()->isInitCapture() && |
1211 (getCallOperator() == C->getCapturedVar()->getDeclContext())); | 1215 getCallOperator() == C->getCapturedVar()->getDeclContext(); |
1212 } | 1216 } |
1213 | 1217 |
1214 LambdaExpr::capture_iterator LambdaExpr::capture_begin() const { | 1218 LambdaExpr::capture_iterator LambdaExpr::capture_begin() const { |
1215 return getLambdaClass()->getLambdaData().Captures; | 1219 return getLambdaClass()->getLambdaData().Captures; |
1216 } | 1220 } |
1568 void *Storage = | 1572 void *Storage = |
1569 Context.Allocate(totalSizeToAlloc<TemplateArgument>(NumPartialArgs)); | 1573 Context.Allocate(totalSizeToAlloc<TemplateArgument>(NumPartialArgs)); |
1570 return new (Storage) SizeOfPackExpr(EmptyShell(), NumPartialArgs); | 1574 return new (Storage) SizeOfPackExpr(EmptyShell(), NumPartialArgs); |
1571 } | 1575 } |
1572 | 1576 |
1577 NonTypeTemplateParmDecl *SubstNonTypeTemplateParmExpr::getParameter() const { | |
1578 return cast<NonTypeTemplateParmDecl>( | |
1579 getReplacedTemplateParameterList(getAssociatedDecl())->asArray()[Index]); | |
1580 } | |
1581 | |
1573 QualType SubstNonTypeTemplateParmExpr::getParameterType( | 1582 QualType SubstNonTypeTemplateParmExpr::getParameterType( |
1574 const ASTContext &Context) const { | 1583 const ASTContext &Context) const { |
1575 // Note that, for a class type NTTP, we will have an lvalue of type 'const | 1584 // Note that, for a class type NTTP, we will have an lvalue of type 'const |
1576 // T', so we can't just compute this from the type and value category. | 1585 // T', so we can't just compute this from the type and value category. |
1577 if (isReferenceParameter()) | 1586 if (isReferenceParameter()) |
1578 return Context.getLValueReferenceType(getType()); | 1587 return Context.getLValueReferenceType(getType()); |
1579 return getType().getUnqualifiedType(); | 1588 return getType().getUnqualifiedType(); |
1580 } | 1589 } |
1581 | 1590 |
1582 SubstNonTypeTemplateParmPackExpr::SubstNonTypeTemplateParmPackExpr( | 1591 SubstNonTypeTemplateParmPackExpr::SubstNonTypeTemplateParmPackExpr( |
1583 QualType T, ExprValueKind ValueKind, NonTypeTemplateParmDecl *Param, | 1592 QualType T, ExprValueKind ValueKind, SourceLocation NameLoc, |
1584 SourceLocation NameLoc, const TemplateArgument &ArgPack) | 1593 const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index) |
1585 : Expr(SubstNonTypeTemplateParmPackExprClass, T, ValueKind, OK_Ordinary), | 1594 : Expr(SubstNonTypeTemplateParmPackExprClass, T, ValueKind, OK_Ordinary), |
1586 Param(Param), Arguments(ArgPack.pack_begin()), | 1595 AssociatedDecl(AssociatedDecl), Arguments(ArgPack.pack_begin()), |
1587 NumArguments(ArgPack.pack_size()), NameLoc(NameLoc) { | 1596 NumArguments(ArgPack.pack_size()), Index(Index), NameLoc(NameLoc) { |
1597 assert(AssociatedDecl != nullptr); | |
1588 setDependence(ExprDependence::TypeValueInstantiation | | 1598 setDependence(ExprDependence::TypeValueInstantiation | |
1589 ExprDependence::UnexpandedPack); | 1599 ExprDependence::UnexpandedPack); |
1600 } | |
1601 | |
1602 NonTypeTemplateParmDecl * | |
1603 SubstNonTypeTemplateParmPackExpr::getParameterPack() const { | |
1604 return cast<NonTypeTemplateParmDecl>( | |
1605 getReplacedTemplateParameterList(getAssociatedDecl())->asArray()[Index]); | |
1590 } | 1606 } |
1591 | 1607 |
1592 TemplateArgument SubstNonTypeTemplateParmPackExpr::getArgumentPack() const { | 1608 TemplateArgument SubstNonTypeTemplateParmPackExpr::getArgumentPack() const { |
1593 return TemplateArgument(llvm::makeArrayRef(Arguments, NumArguments)); | 1609 return TemplateArgument(llvm::makeArrayRef(Arguments, NumArguments)); |
1594 } | 1610 } |