clang: lib/AST/ExprCXX.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
34#include "llvm/ADT/ArrayRef.h"
35#include "llvm/Support/ErrorHandling.h"
36#include
37#include
38#include
39#include
40#include
41
42using namespace clang;
43
44
45
46
47
49
50
51
52
54 return false;
55
57 case OO_Call: case OO_Subscript:
58 return false;
59 default:
60 return true;
61 }
62}
63
68
69
70 bool SkippedNot = false;
71 if (auto *NotEq = dyn_cast(E)) {
72 assert(NotEq->getOpcode() == UO_LNot);
74 SkippedNot = true;
75 }
76
77
78 if (auto *BO = dyn_cast(E)) {
79 assert(!SkippedNot || BO->getOpcode() == BO_EQ);
80 Result.Opcode = SkippedNot ? BO_NE : BO->getOpcode();
81 Result.LHS = BO->getLHS();
82 Result.RHS = BO->getRHS();
83 Result.InnerBinOp = BO;
84 } else if (auto *BO = dyn_cast(E)) {
85 assert(!SkippedNot || BO->getOperator() == OO_EqualEqual);
86 assert(BO->isInfixBinaryOp());
87 switch (BO->getOperator()) {
88 case OO_Less: Result.Opcode = BO_LT; break;
89 case OO_LessEqual: Result.Opcode = BO_LE; break;
90 case OO_Greater: Result.Opcode = BO_GT; break;
91 case OO_GreaterEqual: Result.Opcode = BO_GE; break;
92 case OO_Spaceship: Result.Opcode = BO_Cmp; break;
93 case OO_EqualEqual: Result.Opcode = SkippedNot ? BO_NE : BO_EQ; break;
94 default: llvm_unreachable("unexpected binop in rewritten operator expr");
95 }
96 Result.LHS = BO->getArg(0);
97 Result.RHS = BO->getArg(1);
98 Result.InnerBinOp = BO;
99 } else {
100 llvm_unreachable("unexpected rewritten operator form");
101 }
102
103
104
107
108
109 if (Result.Opcode == BO_EQ || Result.Opcode == BO_NE)
111
112
113 E = Result.LHS->IgnoreUnlessSpelledInSource();
114 if (auto *BO = dyn_cast(E)) {
115 assert(BO->getOpcode() == BO_Cmp);
116 Result.LHS = BO->getLHS();
117 Result.RHS = BO->getRHS();
118 Result.InnerBinOp = BO;
119 } else if (auto *BO = dyn_cast(E)) {
120 assert(BO->getOperator() == OO_Spaceship);
121 Result.LHS = BO->getArg(0);
122 Result.RHS = BO->getArg(1);
123 Result.InnerBinOp = BO;
124 } else {
125 llvm_unreachable("unexpected rewritten operator form");
126 }
127
128
132}
133
136 return false;
137
138
139
140
143 if (RD->isPolymorphic() && E->isGLValue())
144 return true;
145
146 return false;
147}
148
150 assert(() && "Cannot call isMostDerived for typeid(type)");
152 if (const auto *DRE = dyn_cast(E)) {
153 QualType Ty = DRE->getDecl()->getType();
155 return true;
156 }
157
158 return false;
159}
160
162 assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
164 return Context.getUnqualifiedArrayType(
166}
167
170
171 if (const auto *CE = dyn_cast(E)) {
172 if (!CE->getSubExpr()->isGLValue())
173 return false;
175 }
176
177 if (const auto *OVE = dyn_cast(E))
179
180 if (const auto *BO = dyn_cast(E))
181 if (BO->getOpcode() == BO_Comma)
183
184 if (const auto *ACO = dyn_cast(E))
187
188
189
191 return true;
192
193 if (const auto *UO = dyn_cast(E))
194 if (UO->getOpcode() == UO_Deref)
195 return true;
196
197 return false;
198}
199
202 return false;
203
204
205
206
207
208
209
210
211
213}
214
216 assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
218 return Context.getUnqualifiedArrayType(
220}
221
222
224 return TypeInfo ? TypeInfo->getTypeLoc().getBeginLoc() : getRParenLoc();
225}
226
227
228CXXNewExpr::CXXNewExpr(bool IsGlobalNew, FunctionDecl *OperatorNew,
231 bool UsualArrayDeleteWantsSize,
233 std::optional<Expr *> ArraySize,
239 OperatorNew(OperatorNew), OperatorDelete(OperatorDelete),
240 AllocatedTypeInfo(AllocatedTypeInfo), Range(Range),
241 DirectInitRange(DirectInitRange) {
242
245 "Only CXXNewInitializationStyle::None can have no initializer!");
246
252 CXXNewExprBits.UsualArrayDeleteWantsSize = UsualArrayDeleteWantsSize;
255 llvm::to_underlying(InitializationStyle);
256 bool IsParenTypeId = TypeIdParens.isValid();
258 CXXNewExprBits.NumPlacementArgs = PlacementArgs.size();
259
260 if (ArraySize)
261 getTrailingObjects<Stmt *>()[arraySizeOffset()] = *ArraySize;
263 getTrailingObjects<Stmt *>()[initExprOffset()] = Initializer;
264 llvm::copy(PlacementArgs,
265 getTrailingObjects<Stmt *>() + placementNewArgsOffset());
266 if (IsParenTypeId)
267 getTrailingObjects()[0] = TypeIdParens;
268
269 switch (getInitializationStyle()) {
271 this->Range.setEnd(DirectInitRange.getEnd());
272 break;
275 break;
276 default:
277 if (IsParenTypeId)
279 break;
280 }
281
283}
284
285CXXNewExpr::CXXNewExpr(EmptyShell Empty, bool IsArray,
286 unsigned NumPlacementArgs, bool IsParenTypeId)
291}
292
296 bool UsualArrayDeleteWantsSize, ArrayRef<Expr *> PlacementArgs,
297 SourceRange TypeIdParens, std::optional<Expr *> ArraySize,
301 bool IsArray = ArraySize.has_value();
303 unsigned NumPlacementArgs = PlacementArgs.size();
304 bool IsParenTypeId = TypeIdParens.isValid();
305 void *Mem =
306 Ctx.Allocate(totalSizeToAlloc<Stmt *, SourceRange>(
307 IsArray + HasInit + NumPlacementArgs, IsParenTypeId),
308 alignof(CXXNewExpr));
309 return new (Mem) CXXNewExpr(
310 IsGlobalNew, OperatorNew, OperatorDelete, IAP, UsualArrayDeleteWantsSize,
311 PlacementArgs, TypeIdParens, ArraySize, InitializationStyle, Initializer,
312 Ty, AllocatedTypeInfo, Range, DirectInitRange);
313}
314
316 bool HasInit, unsigned NumPlacementArgs,
317 bool IsParenTypeId) {
318 void *Mem =
319 Ctx.Allocate(totalSizeToAlloc<Stmt *, SourceRange>(
320 IsArray + HasInit + NumPlacementArgs, IsParenTypeId),
321 alignof(CXXNewExpr));
322 return new (Mem)
323 CXXNewExpr(EmptyShell(), IsArray, NumPlacementArgs, IsParenTypeId);
324}
325
328 return true;
333 ->isNothrow() &&
335}
336
337
340
341
342
343
344 while (const auto *ICE = dyn_cast(Arg)) {
345 if (ICE->getCastKind() == CK_DerivedToBase ||
346 ICE->getCastKind() == CK_UncheckedDerivedToBase ||
347 ICE->getCastKind() == CK_NoOp) {
348 assert((ICE->getCastKind() == CK_NoOp ||
350 "only a destroying operator delete can have a converted arg");
351 Arg = ICE->getSubExpr();
352 } else
353 break;
354 }
355
356
358
359 if (ArgType->isDependentType() && ->isPointerType())
361
363}
364
365
367 : Type(Info) {
368 Location = Info->getTypeLoc().getBeginLoc();
369}
370
376 : Expr(CXXPseudoDestructorExprClass, Context.BoundMemberTy, VK_PRValue,
378 Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
379 OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc),
380 ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc),
381 DestroyedType(DestroyedType) {
383}
384
386 if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo())
387 return TInfo->getType();
388
390}
391
394 if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo())
395 End = TInfo->getTypeLoc().getSourceRange().getEnd();
396 return End;
397}
398
401 if (std::distance(Begin, End) != 1)
402 return false;
404 if (const auto *TTP = llvm::dyn_cast(ND))
406 return false;
407}
408
409
410UnresolvedLookupExpr::UnresolvedLookupExpr(
416 bool KnownInstantiationDependent)
418 UnresolvedLookupExprClass, Context, QualifierLoc, TemplateKWLoc,
419 NameInfo, TemplateArgs, Begin, End, KnownDependent,
420 KnownInstantiationDependent,
422 NamingClass(NamingClass) {
423 UnresolvedLookupExprBits.RequiresADL = RequiresADL;
424}
425
426UnresolvedLookupExpr::UnresolvedLookupExpr(EmptyShell Empty,
427 unsigned NumResults,
428 bool HasTemplateKWAndArgsInfo)
430 HasTemplateKWAndArgsInfo) {}
431
436 bool KnownDependent, bool KnownInstantiationDependent) {
437 unsigned NumResults = End - Begin;
440 void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
441 return new (Mem) UnresolvedLookupExpr(
442 Context, NamingClass, QualifierLoc,
443 SourceLocation(), NameInfo, RequiresADL,
444 nullptr, Begin, End, KnownDependent,
445 KnownInstantiationDependent);
446}
447
454 bool KnownInstantiationDependent) {
455 unsigned NumResults = End - Begin;
456 bool HasTemplateKWAndArgsInfo = Args || TemplateKWLoc.isValid();
457 unsigned NumTemplateArgs = Args ? Args->size() : 0;
460 NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
461 void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
462 return new (Mem) UnresolvedLookupExpr(
463 Context, NamingClass, QualifierLoc, TemplateKWLoc, NameInfo, RequiresADL,
464 Args, Begin, End, KnownDependent, KnownInstantiationDependent);
465}
466
468 const ASTContext &Context, unsigned NumResults,
469 bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs) {
470 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
473 NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
474 void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
475 return new (Mem)
476 UnresolvedLookupExpr(EmptyShell(), NumResults, HasTemplateKWAndArgsInfo);
477}
478
486 bool KnownInstantiationDependent,
487 bool KnownContainsUnexpandedParameterPack)
489 QualifierLoc(QualifierLoc) {
490 unsigned NumResults = End - Begin;
493 (TemplateArgs != nullptr ) || TemplateKWLoc.isValid();
494
495 if (NumResults) {
496
497
500 }
501
502 if (TemplateArgs) {
503 auto Deps = TemplateArgumentDependence::None;
506 } else if (TemplateKWLoc.isValid()) {
507 getTrailingASTTemplateKWAndArgsInfo()->initializeFrom(TemplateKWLoc);
508 }
509
511 KnownInstantiationDependent,
512 KnownContainsUnexpandedParameterPack));
514 setType(Context.DependentTy);
515}
516
518 bool HasTemplateKWAndArgsInfo)
521 OverloadExprBits.HasTemplateKWAndArgsInfo = HasTemplateKWAndArgsInfo;
522}
523
524
525DependentScopeDeclRefExpr::DependentScopeDeclRefExpr(
530 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {
532 (Args != nullptr) || TemplateKWLoc.isValid();
533 if (Args) {
534 auto Deps = TemplateArgumentDependence::None;
535 getTrailingObjects()->initializeFrom(
536 TemplateKWLoc, *Args, getTrailingObjects(), Deps);
537 } else if (TemplateKWLoc.isValid()) {
538 getTrailingObjects()->initializeFrom(
539 TemplateKWLoc);
540 }
542}
543
548 assert(QualifierLoc && "should be created for dependent qualifiers");
549 bool HasTemplateKWAndArgsInfo = Args || TemplateKWLoc.isValid();
550 std::size_t Size =
551 totalSizeToAlloc<ASTTemplateKWAndArgsInfo, TemplateArgumentLoc>(
552 HasTemplateKWAndArgsInfo, Args ? Args->size() : 0);
553 void *Mem = Context.Allocate(Size);
554 return new (Mem) DependentScopeDeclRefExpr(Context.DependentTy, QualifierLoc,
555 TemplateKWLoc, NameInfo, Args);
556}
557
560 bool HasTemplateKWAndArgsInfo,
561 unsigned NumTemplateArgs) {
562 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
563 std::size_t Size =
564 totalSizeToAlloc<ASTTemplateKWAndArgsInfo, TemplateArgumentLoc>(
565 HasTemplateKWAndArgsInfo, NumTemplateArgs);
566 void *Mem = Context.Allocate(Size);
567 auto *E = new (Mem) DependentScopeDeclRefExpr(
570 E->DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo =
571 HasTemplateKWAndArgsInfo;
572 return E;
573}
574
576 if (const auto *TOE = dyn_cast(this))
577 return TOE->getBeginLoc();
579}
580
582 if (const auto *TOE = dyn_cast(this))
583 return TOE->getEndLoc();
584
585 if (ParenOrBraceRange.isValid())
586 return ParenOrBraceRange.getEnd();
587
589 for (unsigned I = getNumArgs(); I > 0; --I) {
594 End = NewEnd;
595 break;
596 }
597 }
598 }
599
600 return End;
601}
602
608 ADLCallKind UsesADL)
609 : CallExpr(CXXOperatorCallExprClass, Fn, {}, Args, Ty, VK,
610 OperatorLoc, FPFeatures, 0, UsesADL) {
611 CXXOperatorCallExprBits.OperatorKind = OpKind;
612 assert(
613 (CXXOperatorCallExprBits.OperatorKind == static_cast<unsigned>(OpKind)) &&
614 "OperatorKind overflow!");
615 BeginLoc = getSourceRangeImpl().getBegin();
616}
617
618CXXOperatorCallExpr::CXXOperatorCallExpr(unsigned NumArgs, bool HasFPFeatures,
619 EmptyShell Empty)
620 : CallExpr(CXXOperatorCallExprClass, 0, NumArgs,
621 HasFPFeatures, Empty) {}
622
629
630 unsigned NumArgs = Args.size();
633 void *Mem =
635 SizeOfTrailingObjects),
636 alignof(CXXOperatorCallExpr));
637 return new (Mem) CXXOperatorCallExpr(OpKind, Fn, Args, Ty, VK, OperatorLoc,
639}
640
642 unsigned NumArgs,
643 bool HasFPFeatures,
645
646 unsigned SizeOfTrailingObjects =
648 void *Mem =
650 SizeOfTrailingObjects),
651 alignof(CXXOperatorCallExpr));
652 return new (Mem) CXXOperatorCallExpr(NumArgs, HasFPFeatures, Empty);
653}
654
655SourceRange CXXOperatorCallExpr::getSourceRangeImpl() const {
657 if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
659
661 else
662
664 } else if (Kind == OO_Arrow) {
666 } else if (Kind == OO_Call) {
668 } else if (Kind == OO_Subscript) {
674 } else {
676 }
677}
678
683 unsigned MinNumArgs)
684 : CallExpr(CXXMemberCallExprClass, Fn, {}, Args, Ty, VK, RP,
685 FPOptions, MinNumArgs, NotADL) {}
686
687CXXMemberCallExpr::CXXMemberCallExpr(unsigned NumArgs, bool HasFPFeatures,
688 EmptyShell Empty)
689 : CallExpr(CXXMemberCallExprClass, 0, NumArgs, HasFPFeatures,
691
697 unsigned MinNumArgs) {
698
699 unsigned NumArgs = std::max(Args.size(), MinNumArgs);
703 SizeOfTrailingObjects),
704 alignof(CXXMemberCallExpr));
705 return new (Mem)
706 CXXMemberCallExpr(Fn, Args, Ty, VK, RP, FPFeatures, MinNumArgs);
707}
708
710 unsigned NumArgs,
711 bool HasFPFeatures,
713
714 unsigned SizeOfTrailingObjects =
717 SizeOfTrailingObjects),
718 alignof(CXXMemberCallExpr));
719 return new (Mem) CXXMemberCallExpr(NumArgs, HasFPFeatures, Empty);
720}
721
724 if (const auto *MemExpr = dyn_cast(Callee))
725 return MemExpr->getBase();
726 if (const auto *BO = dyn_cast(Callee))
727 if (BO->getOpcode() == BO_PtrMemD || BO->getOpcode() == BO_PtrMemI)
728 return BO->getLHS();
729
730
731 return nullptr;
732}
733
740
744
745
746
747 return nullptr;
748}
749
752 if (!ThisArg)
753 return nullptr;
754
757
759}
760
761
762
763
764
765
766
767
770 case CXXStaticCastExprClass: return "static_cast";
771 case CXXDynamicCastExprClass: return "dynamic_cast";
772 case CXXReinterpretCastExprClass: return "reinterpret_cast";
773 case CXXConstCastExprClass: return "const_cast";
774 case CXXAddrspaceCastExprClass: return "addrspace_cast";
775 default: return "";
776 }
777}
778
785 unsigned PathSize = (BasePath ? BasePath->size() : 0);
786 void *Buffer =
787 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
789 auto *E = new (Buffer) CXXStaticCastExpr(T, VK, K, Op, PathSize, WrittenTy,
790 FPO, L, RParenLoc, AngleBrackets);
791 if (PathSize)
792 llvm::uninitialized_copy(*BasePath,
794 return E;
795}
796
798 unsigned PathSize,
799 bool HasFPFeatures) {
800 void *Buffer =
801 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
802 PathSize, HasFPFeatures));
803 return new (Buffer) CXXStaticCastExpr(EmptyShell(), PathSize, HasFPFeatures);
804}
805
814 unsigned PathSize = (BasePath ? BasePath->size() : 0);
815 void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
816 auto *E =
817 new (Buffer) CXXDynamicCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
818 RParenLoc, AngleBrackets);
819 if (PathSize)
820 llvm::uninitialized_copy(*BasePath, E->getTrailingObjects());
821 return E;
822}
823
825 unsigned PathSize) {
826 void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
827 return new (Buffer) CXXDynamicCastExpr(EmptyShell(), PathSize);
828}
829
830
831
832
833
834
835
836
837
840 return false;
841
844
846 return false;
847
851 }
852
855 assert(SrcRD && DestRD);
856
857 if (SrcRD->isEffectivelyFinal()) {
858 assert(!SrcRD->isDerivedFrom(DestRD) &&
859 "upcasts should not use CK_Dynamic");
860 return true;
861 }
862
863 if (DestRD->isEffectivelyFinal() && !DestRD->isDerivedFrom(SrcRD))
864 return true;
865
866 return false;
867}
868
876 unsigned PathSize = (BasePath ? BasePath->size() : 0);
877 void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
878 auto *E =
879 new (Buffer) CXXReinterpretCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
880 RParenLoc, AngleBrackets);
881 if (PathSize)
882 llvm::uninitialized_copy(*BasePath, E->getTrailingObjects());
883 return E;
884}
885
888 void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
889 return new (Buffer) CXXReinterpretCastExpr(EmptyShell(), PathSize);
890}
891
898 return new (C) CXXConstCastExpr(T, VK, Op, WrittenTy, L, RParenLoc, AngleBrackets);
899}
900
902 return new (C) CXXConstCastExpr(EmptyShell());
903}
904
910 return new (C) CXXAddrspaceCastExpr(T, VK, K, Op, WrittenTy, L, RParenLoc,
911 AngleBrackets);
912}
913
915 return new (C) CXXAddrspaceCastExpr(EmptyShell());
916}
917
922 unsigned PathSize = (BasePath ? BasePath->size() : 0);
923 void *Buffer =
924 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
926 auto *E = new (Buffer)
927 CXXFunctionalCastExpr(T, VK, Written, K, Op, PathSize, FPO, L, R);
928 if (PathSize)
929 llvm::uninitialized_copy(*BasePath,
931 return E;
932}
933
935 unsigned PathSize,
936 bool HasFPFeatures) {
937 void *Buffer =
938 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
939 PathSize, HasFPFeatures));
940 return new (Buffer)
941 CXXFunctionalCastExpr(EmptyShell(), PathSize, HasFPFeatures);
942}
943
947
951
957 : CallExpr(UserDefinedLiteralClass, Fn, {}, Args, Ty, VK,
958 LitEndLoc, FPFeatures, 0, NotADL),
959 UDSuffixLoc(SuffixLoc) {}
960
961UserDefinedLiteral::UserDefinedLiteral(unsigned NumArgs, bool HasFPFeatures,
962 EmptyShell Empty)
963 : CallExpr(UserDefinedLiteralClass, 0, NumArgs,
964 HasFPFeatures, Empty) {}
965
972
973 unsigned NumArgs = Args.size();
976 void *Mem =
978 SizeOfTrailingObjects),
979 alignof(UserDefinedLiteral));
980 return new (Mem)
981 UserDefinedLiteral(Fn, Args, Ty, VK, LitEndLoc, SuffixLoc, FPFeatures);
982}
983
985 unsigned NumArgs,
986 bool HasFPOptions,
988
989 unsigned SizeOfTrailingObjects =
991 void *Mem =
993 SizeOfTrailingObjects),
994 alignof(UserDefinedLiteral));
995 return new (Mem) UserDefinedLiteral(NumArgs, HasFPOptions, Empty);
996}
997
1004
1005 assert(getNumArgs() == 1 && "unexpected #args in literal operator call");
1016
1017 llvm_unreachable("unknown kind of literal operator");
1018}
1019
1021#ifndef NDEBUG
1023 assert(LOK != LOK_Template && LOK != LOK_Raw && "not a cooked literal");
1024#endif
1026}
1027
1031
1033 bool HasRewrittenInit) {
1034 size_t Size = totalSizeToAlloc<Expr *>(HasRewrittenInit);
1035 auto *Mem = C.Allocate(Size, alignof(CXXDefaultArgExpr));
1036 return new (Mem) CXXDefaultArgExpr(EmptyShell(), HasRewrittenInit);
1037}
1038
1042 Expr *RewrittenExpr,
1044 size_t Size = totalSizeToAlloc<Expr *>(RewrittenExpr != nullptr);
1045 auto *Mem = C.Allocate(Size, alignof(CXXDefaultArgExpr));
1046 return new (Mem) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param,
1047 RewrittenExpr, UsedContext);
1048}
1049
1054
1057 "expected this CXXDefaultArgExpr to have a rewritten init.");
1059 if (auto *E = dyn_cast_if_present(Init))
1061 return E->getSubExpr();
1062 return Init;
1063}
1064
1065CXXDefaultInitExpr::CXXDefaultInitExpr(const ASTContext &Ctx,
1068 Expr *RewrittenInitExpr)
1069 : Expr(CXXDefaultInitExprClass, Ty.getNonLValueExprType(Ctx),
1070 Ty->isLValueReferenceType() ? VK_LValue
1071 : Ty->isRValueReferenceType() ? VK_XValue
1074 Field(Field), UsedContext(UsedContext) {
1077
1079 *getTrailingObjects() = RewrittenInitExpr;
1080
1081 assert(Field->hasInClassInitializer());
1082
1084}
1085
1087 bool HasRewrittenInit) {
1088 size_t Size = totalSizeToAlloc<Expr *>(HasRewrittenInit);
1089 auto *Mem = C.Allocate(Size, alignof(CXXDefaultInitExpr));
1090 return new (Mem) CXXDefaultInitExpr(EmptyShell(), HasRewrittenInit);
1091}
1092
1097 Expr *RewrittenInitExpr) {
1098
1099 size_t Size = totalSizeToAlloc<Expr *>(RewrittenInitExpr != nullptr);
1100 auto *Mem = Ctx.Allocate(Size, alignof(CXXDefaultInitExpr));
1101 return new (Mem) CXXDefaultInitExpr(Ctx, Loc, Field, Field->getType(),
1102 UsedContext, RewrittenInitExpr);
1103}
1104
1106 assert(Field->getInClassInitializer() && "initializer hasn't been parsed");
1109
1110 return Field->getInClassInitializer();
1111}
1112
1115 return new (C) CXXTemporary(Destructor);
1116}
1117
1120 Expr* SubExpr) {
1121 assert((SubExpr->getType()->isRecordType() ||
1122 SubExpr->getType()->isArrayType()) &&
1123 "Expression bound to a temporary must have record or array type!");
1124
1125 return new (C) CXXBindTemporaryExpr(Temp, SubExpr);
1126}
1127
1128CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(
1131 bool HadMultipleCandidates, bool ListInitialization,
1132 bool StdInitListInitialization, bool ZeroInitialization)
1134 CXXTemporaryObjectExprClass, Ty, TSI->getTypeLoc().getBeginLoc(),
1135 Cons, false, Args, HadMultipleCandidates,
1136 ListInitialization, StdInitListInitialization, ZeroInitialization,
1138 TSI(TSI) {
1140}
1141
1142CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(EmptyShell Empty,
1143 unsigned NumArgs)
1145
1149 bool HadMultipleCandidates, bool ListInitialization,
1150 bool StdInitListInitialization, bool ZeroInitialization) {
1152 void *Mem =
1153 Ctx.Allocate(sizeof(CXXTemporaryObjectExpr) + SizeOfTrailingObjects,
1154 alignof(CXXTemporaryObjectExpr));
1155 return new (Mem) CXXTemporaryObjectExpr(
1156 Cons, Ty, TSI, Args, ParenOrBraceRange, HadMultipleCandidates,
1157 ListInitialization, StdInitListInitialization, ZeroInitialization);
1158}
1159
1163 void *Mem =
1164 Ctx.Allocate(sizeof(CXXTemporaryObjectExpr) + SizeOfTrailingObjects,
1165 alignof(CXXTemporaryObjectExpr));
1166 return new (Mem) CXXTemporaryObjectExpr(EmptyShell(), NumArgs);
1167}
1168
1172
1179
1183 bool HadMultipleCandidates, bool ListInitialization,
1184 bool StdInitListInitialization, bool ZeroInitialization,
1190 CXXConstructExprClass, Ty, Loc, Ctor, Elidable, Args,
1191 HadMultipleCandidates, ListInitialization, StdInitListInitialization,
1192 ZeroInitialization, ConstructKind, ParenOrBraceRange);
1193}
1194
1196 unsigned NumArgs) {
1200 return new (Mem)
1202}
1203
1206 bool Elidable, ArrayRef<Expr *> Args, bool HadMultipleCandidates,
1207 bool ListInitialization, bool StdInitListInitialization,
1211 ParenOrBraceRange(ParenOrBraceRange), NumArgs(Args.size()) {
1220
1221 Stmt **TrailingArgs = getTrailingArgs();
1222 llvm::copy(Args, TrailingArgs);
1223 assert(!llvm::is_contained(Args, nullptr));
1224
1225
1226 if (SC == CXXConstructExprClass)
1228}
1229
1231 unsigned NumArgs)
1232 : Expr(SC, Empty), NumArgs(NumArgs) {}
1233
1237 : DeclAndBits(Var, 0), Loc(Loc), EllipsisLoc(EllipsisLoc) {
1238 unsigned Bits = 0;
1240 Bits |= Capture_Implicit;
1241
1242 switch (Kind) {
1244 Bits |= Capture_ByCopy;
1245 [[fallthrough]];
1247 assert(!Var && "'this' capture cannot have a variable!");
1248 Bits |= Capture_This;
1249 break;
1250
1252 Bits |= Capture_ByCopy;
1253 [[fallthrough]];
1255 assert(Var && "capture must have a variable!");
1256 break;
1258 assert(!Var && "VLA type capture cannot have a variable!");
1259 break;
1260 }
1261 DeclAndBits.setInt(Bits);
1262}
1263
1267 bool CapByCopy = DeclAndBits.getInt() & Capture_ByCopy;
1271}
1272
1275 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
1278 bool ContainsUnexpandedParameterPack)
1280 IntroducerRange(IntroducerRange), CaptureDefaultLoc(CaptureDefaultLoc),
1281 ClosingBrace(ClosingBrace) {
1282 LambdaExprBits.NumCaptures = CaptureInits.size();
1283 LambdaExprBits.CaptureDefault = CaptureDefault;
1284 LambdaExprBits.ExplicitParams = ExplicitParams;
1285 LambdaExprBits.ExplicitResultType = ExplicitResultType;
1286
1289 assert(capture_size() == Class->capture_size() && "Wrong number of captures");
1290 assert(getCaptureDefault() == Class->getLambdaCaptureDefault());
1291
1292
1293 Stmt **Stored = getStoredStmts();
1294 for (unsigned I = 0, N = CaptureInits.size(); I != N; ++I)
1295 *Stored++ = CaptureInits[I];
1296
1297
1298 *Stored++ = getCallOperator()->getBody();
1299
1300 setDependence(computeDependence(this, ContainsUnexpandedParameterPack));
1301}
1302
1303LambdaExpr::LambdaExpr(EmptyShell Empty, unsigned NumCaptures)
1304 : Expr(LambdaExprClass, Empty) {
1305 LambdaExprBits.NumCaptures = NumCaptures;
1306
1307
1308
1309 getStoredStmts()[NumCaptures] = nullptr;
1310}
1311
1316 bool ExplicitParams, bool ExplicitResultType,
1319 bool ContainsUnexpandedParameterPack) {
1320
1321
1323
1324 unsigned Size = totalSizeToAlloc<Stmt *>(CaptureInits.size() + 1);
1325 void *Mem = Context.Allocate(Size);
1326 return new (Mem)
1327 LambdaExpr(T, IntroducerRange, CaptureDefault, CaptureDefaultLoc,
1328 ExplicitParams, ExplicitResultType, CaptureInits, ClosingBrace,
1329 ContainsUnexpandedParameterPack);
1330}
1331
1333 unsigned NumCaptures) {
1334 unsigned Size = totalSizeToAlloc<Stmt *>(NumCaptures + 1);
1335 void *Mem = C.Allocate(Size);
1337}
1338
1339void LambdaExpr::initBodyIfNeeded() const {
1343 }
1344}
1345
1347 initBodyIfNeeded();
1349}
1350
1353 if (const auto *CoroBody = dyn_cast(Body))
1356}
1357
1359 return C->capturesVariable() && C->getCapturedVar()->isInitCapture() &&
1361}
1362
1366
1370
1374
1378
1383
1387
1391
1395
1399
1403
1406 return Record->getLambdaCallOperator();
1407}
1408
1411 return Record->getDependentLambdaCallOperator();
1412}
1413
1416 return Record->getGenericLambdaTemplateParameterList();
1417}
1418
1421 return Record->getLambdaExplicitTemplateParameters();
1422}
1423
1427
1429
1431 initBodyIfNeeded();
1433}
1434
1436 initBodyIfNeeded();
1439}
1440
1441ExprWithCleanups::ExprWithCleanups(Expr *subexpr,
1442 bool CleanupsHaveSideEffects,
1444 : FullExpr(ExprWithCleanupsClass, subexpr) {
1447 llvm::copy(objects, getTrailingObjects());
1448}
1449
1451 bool CleanupsHaveSideEffects,
1453 void *buffer = C.Allocate(totalSizeToAlloc(objects.size()),
1454 alignof(ExprWithCleanups));
1455 return new (buffer)
1456 ExprWithCleanups(subexpr, CleanupsHaveSideEffects, objects);
1457}
1458
1459ExprWithCleanups::ExprWithCleanups(EmptyShell empty, unsigned numObjects)
1460 : FullExpr(ExprWithCleanupsClass, empty) {
1462}
1463
1466 unsigned numObjects) {
1467 void *buffer = C.Allocate(totalSizeToAlloc(numObjects),
1468 alignof(ExprWithCleanups));
1469 return new (buffer) ExprWithCleanups(empty, numObjects);
1470}
1471
1472CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(
1475 : Expr(CXXUnresolvedConstructExprClass, T,
1480 TypeAndInitForm(TSI, IsListInit), LParenLoc(LParenLoc),
1481 RParenLoc(RParenLoc) {
1483 auto **StoredArgs = getTrailingObjects();
1484 llvm::copy(Args, StoredArgs);
1486}
1487
1491 bool IsListInit) {
1492 void *Mem = Context.Allocate(totalSizeToAlloc<Expr *>(Args.size()));
1493 return new (Mem) CXXUnresolvedConstructExpr(T, TSI, LParenLoc, Args,
1494 RParenLoc, IsListInit);
1495}
1496
1499 unsigned NumArgs) {
1500 void *Mem = Context.Allocate(totalSizeToAlloc<Expr *>(NumArgs));
1501 return new (Mem) CXXUnresolvedConstructExpr(EmptyShell(), NumArgs);
1502}
1503
1505 return TypeAndInitForm.getPointer()->getTypeLoc().getBeginLoc();
1506}
1507
1508CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(
1514 : Expr(CXXDependentScopeMemberExprClass, Ctx.DependentTy, VK_LValue,
1516 Base(Base), BaseType(BaseType), QualifierLoc(QualifierLoc),
1517 MemberNameInfo(MemberNameInfo) {
1520 (TemplateArgs != nullptr) || TemplateKWLoc.isValid();
1522 FirstQualifierFoundInScope != nullptr;
1524
1525 if (TemplateArgs) {
1526 auto Deps = TemplateArgumentDependence::None;
1527 getTrailingObjects()->initializeFrom(
1528 TemplateKWLoc, *TemplateArgs, getTrailingObjects(),
1529 Deps);
1530 } else if (TemplateKWLoc.isValid()) {
1531 getTrailingObjects()->initializeFrom(
1532 TemplateKWLoc);
1533 }
1534
1535 if (hasFirstQualifierFoundInScope())
1536 *getTrailingObjects<NamedDecl *>() = FirstQualifierFoundInScope;
1538}
1539
1540CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(
1541 EmptyShell Empty, bool HasTemplateKWAndArgsInfo,
1542 bool HasFirstQualifierFoundInScope)
1543 : Expr(CXXDependentScopeMemberExprClass, Empty) {
1545 HasTemplateKWAndArgsInfo;
1547 HasFirstQualifierFoundInScope;
1548}
1549
1556 bool HasTemplateKWAndArgsInfo =
1557 (TemplateArgs != nullptr) || TemplateKWLoc.isValid();
1558 unsigned NumTemplateArgs = TemplateArgs ? TemplateArgs->size() : 0;
1559 bool HasFirstQualifierFoundInScope = FirstQualifierFoundInScope != nullptr;
1560
1563 HasTemplateKWAndArgsInfo, NumTemplateArgs, HasFirstQualifierFoundInScope);
1564
1565 void *Mem = Ctx.Allocate(Size, alignof(CXXDependentScopeMemberExpr));
1566 return new (Mem) CXXDependentScopeMemberExpr(
1567 Ctx, Base, BaseType, IsArrow, OperatorLoc, QualifierLoc, TemplateKWLoc,
1568 FirstQualifierFoundInScope, MemberNameInfo, TemplateArgs);
1569}
1570
1572 const ASTContext &Ctx, bool HasTemplateKWAndArgsInfo,
1573 unsigned NumTemplateArgs, bool HasFirstQualifierFoundInScope) {
1574 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
1575
1578 HasTemplateKWAndArgsInfo, NumTemplateArgs, HasFirstQualifierFoundInScope);
1579
1580 void *Mem = Ctx.Allocate(Size, alignof(CXXDependentScopeMemberExpr));
1581 return new (Mem) CXXDependentScopeMemberExpr(
1582 EmptyShell(), HasTemplateKWAndArgsInfo, HasFirstQualifierFoundInScope);
1583}
1584
1586 QualType Ty, bool IsImplicit) {
1587 return new (Ctx) CXXThisExpr(L, Ty, IsImplicit,
1589}
1590
1592 return new (Ctx) CXXThisExpr(EmptyShell());
1593}
1594
1597 do {
1600 return false;
1601
1602
1603
1605 ->isStatic())
1606 return false;
1607 } while (++begin != end);
1608
1609 return true;
1610}
1611
1612UnresolvedMemberExpr::UnresolvedMemberExpr(
1613 const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base,
1620 UnresolvedMemberExprClass, Context, QualifierLoc, TemplateKWLoc,
1621 MemberNameInfo, TemplateArgs, Begin, End,
1622
1623 ((Base && Base->isTypeDependent()) || BaseType->isDependentType()),
1624 ((Base && Base->isInstantiationDependent()) ||
1625 BaseType->isInstantiationDependentType()),
1626
1627 ((Base && Base->containsUnexpandedParameterPack()) ||
1628 BaseType->containsUnexpandedParameterPack())),
1629 Base(Base), BaseType(BaseType), OperatorLoc(OperatorLoc) {
1630 UnresolvedMemberExprBits.IsArrow = IsArrow;
1631 UnresolvedMemberExprBits.HasUnresolvedUsing = HasUnresolvedUsing;
1632
1633
1634
1636 setType(Context.BoundMemberTy);
1637}
1638
1639UnresolvedMemberExpr::UnresolvedMemberExpr(EmptyShell Empty,
1640 unsigned NumResults,
1641 bool HasTemplateKWAndArgsInfo)
1643 HasTemplateKWAndArgsInfo) {}
1644
1646 if (!Base)
1647 return true;
1648
1649 return cast(Base)->isImplicitCXXThis();
1650}
1651
1653 const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base,
1659 unsigned NumResults = End - Begin;
1660 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.isValid();
1661 unsigned NumTemplateArgs = TemplateArgs ? TemplateArgs->size() : 0;
1664 NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
1665 void *Mem = Context.Allocate(Size, alignof(UnresolvedMemberExpr));
1666 return new (Mem) UnresolvedMemberExpr(
1667 Context, HasUnresolvedUsing, Base, BaseType, IsArrow, OperatorLoc,
1668 QualifierLoc, TemplateKWLoc, MemberNameInfo, TemplateArgs, Begin, End);
1669}
1670
1672 const ASTContext &Context, unsigned NumResults,
1673 bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs) {
1674 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
1677 NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
1678 void *Mem = Context.Allocate(Size, alignof(UnresolvedMemberExpr));
1679 return new (Mem)
1680 UnresolvedMemberExpr(EmptyShell(), NumResults, HasTemplateKWAndArgsInfo);
1681}
1682
1684
1685
1686
1687
1688
1693 Record = T->getAsCXXRecordDecl();
1694 assert(Record && "qualifier in member expression does not name record");
1695 }
1696
1697 else {
1701
1702 Record = BaseType->getAsCXXRecordDecl();
1703 assert(Record && "base of member expression does not name record");
1704 }
1705
1707}
1708
1715 void *Storage =
1716 Context.Allocate(totalSizeToAlloc(PartialArgs.size()));
1717 return new (Storage) SizeOfPackExpr(Context.getSizeType(), OperatorLoc, Pack,
1718 PackLoc, RParenLoc, Length, PartialArgs);
1719}
1720
1722 unsigned NumPartialArgs) {
1723 void *Storage =
1724 Context.Allocate(totalSizeToAlloc(NumPartialArgs));
1725 return new (Storage) SizeOfPackExpr(EmptyShell(), NumPartialArgs);
1726}
1727
1732
1735 Expr *PackIdExpr, Expr *IndexExpr, std::optional<int64_t> Index,
1738 if (Index && FullySubstituted && !SubstitutedExprs.empty())
1739 Type = SubstitutedExprs[*Index]->getType();
1740 else
1742
1743 void *Storage =
1744 Context.Allocate(totalSizeToAlloc<Expr *>(SubstitutedExprs.size()));
1745 return new (Storage)
1746 PackIndexingExpr(Type, EllipsisLoc, RSquareLoc, PackIdExpr, IndexExpr,
1747 SubstitutedExprs, FullySubstituted);
1748}
1749
1752 NamedDecl *ND = dyn_cast(D->getDecl());
1753 assert(ND && "exected a named decl");
1754 return ND;
1755 }
1756 assert(false && "invalid declaration kind in pack indexing expression");
1757 return nullptr;
1758}
1759
1762 unsigned NumTransformedExprs) {
1763 void *Storage =
1764 Context.Allocate(totalSizeToAlloc<Expr *>(NumTransformedExprs));
1765 return new (Storage) PackIndexingExpr(EmptyShell{});
1766}
1767
1770
1771
1772
1774
1776 return Context.getLValueReferenceType(Type);
1777 return Type.getUnqualifiedType();
1778}
1779
1780SubstNonTypeTemplateParmPackExpr::SubstNonTypeTemplateParmPackExpr(
1783 bool Final)
1784 : Expr(SubstNonTypeTemplateParmPackExprClass, T, ValueKind, OK_Ordinary),
1785 AssociatedDecl(AssociatedDecl), Arguments(ArgPack.pack_begin()),
1786 NumArguments(ArgPack.pack_size()), Final(Final), Index(Index),
1787 NameLoc(NameLoc) {
1788 assert(AssociatedDecl != nullptr);
1789 setDependence(ExprDependence::TypeValueInstantiation |
1790 ExprDependence::UnexpandedPack);
1791}
1792
1798
1802
1803FunctionParmPackExpr::FunctionParmPackExpr(QualType T, ValueDecl *ParamPack,
1805 unsigned NumParams,
1808 ParamPack(ParamPack), NameLoc(NameLoc), NumParameters(NumParams) {
1809 if (Params)
1810 std::uninitialized_copy(Params, Params + NumParams, getTrailingObjects());
1811 setDependence(ExprDependence::TypeValueInstantiation |
1812 ExprDependence::UnexpandedPack);
1813}
1814
1819 return new (Context.Allocate(totalSizeToAlloc<ValueDecl *>(Params.size())))
1820 FunctionParmPackExpr(T, ParamPack, NameLoc, Params.size(), Params.data());
1821}
1822
1825 unsigned NumParams) {
1826 return new (Context.Allocate(totalSizeToAlloc<ValueDecl *>(NumParams)))
1828}
1829
1831 QualType T, Expr *Temporary, bool BoundToLvalueReference,
1833 : Expr(MaterializeTemporaryExprClass, T,
1835 if (MTD) {
1836 State = MTD;
1837 MTD->ExprWithTemporary = Temporary;
1838 return;
1839 }
1840 State = Temporary;
1842}
1843
1845 unsigned ManglingNumber) {
1846
1847 if (!ExtendedBy)
1848 return;
1849
1850
1851
1855
1857 ES->ExtendingDecl = ExtendedBy;
1858 ES->ManglingNumber = ManglingNumber;
1859}
1860
1863
1864
1865
1866
1867
1872 VD->isUsableInConstantExpressions(Context);
1873}
1874
1878 std::variant<bool, APValue> Value)
1880 RParenLoc(RParenLoc) {
1881 assert(Kind <= TT_Last && "invalid enum value!");
1882
1885 "TypeTraitExprBits.Kind overflow!");
1886
1890 else
1891 ::new (getTrailingObjects())
1893
1896 "TypeTraitExprBits.NumArgs overflow!");
1897 auto **ToArgs = getTrailingObjects<TypeSourceInfo *>();
1898 llvm::copy(Args, ToArgs);
1899
1901
1903 getAPValue().isInt() || getAPValue().isAbsent()) &&
1904 "Only int values are supported by clang");
1905}
1906
1908 : Expr(TypeTraitExprClass, Empty) {
1910 if (!IsStoredAsBool)
1911 ::new (getTrailingObjects()) APValue();
1912}
1913
1920 void *Mem =
1921 C.Allocate(totalSizeToAlloc<APValue, TypeSourceInfo *>(0, Args.size()));
1922 return new (Mem) TypeTraitExpr(T, Loc, Kind, Args, RParenLoc, Value);
1923}
1924
1929 void *Mem =
1930 C.Allocate(totalSizeToAlloc<APValue, TypeSourceInfo *>(1, Args.size()));
1931 return new (Mem) TypeTraitExpr(T, Loc, Kind, Args, RParenLoc, Value);
1932}
1933
1935 bool IsStoredAsBool,
1936 unsigned NumArgs) {
1937 void *Mem = C.Allocate(totalSizeToAlloc<APValue, TypeSourceInfo *>(
1938 IsStoredAsBool ? 0 : 1, NumArgs));
1939 return new (Mem) TypeTraitExpr(EmptyShell(), IsStoredAsBool);
1940}
1941
1942CUDAKernelCallExpr::CUDAKernelCallExpr(Expr *Fn, CallExpr *Config,
1946 unsigned MinNumArgs)
1947 : CallExpr(CUDAKernelCallExprClass, Fn, Config, Args, Ty, VK,
1948 RP, FPFeatures, MinNumArgs, NotADL) {}
1949
1950CUDAKernelCallExpr::CUDAKernelCallExpr(unsigned NumArgs, bool HasFPFeatures,
1951 EmptyShell Empty)
1952 : CallExpr(CUDAKernelCallExprClass, END_PREARG, NumArgs,
1953 HasFPFeatures, Empty) {}
1954
1959 unsigned MinNumArgs) {
1960
1961 unsigned NumArgs = std::max(Args.size(), MinNumArgs);
1964 void *Mem =
1966 SizeOfTrailingObjects),
1967 alignof(CUDAKernelCallExpr));
1968 return new (Mem)
1969 CUDAKernelCallExpr(Fn, Config, Args, Ty, VK, RP, FPFeatures, MinNumArgs);
1970}
1971
1973 unsigned NumArgs,
1974 bool HasFPFeatures,
1976
1978 END_PREARG, NumArgs, HasFPFeatures);
1979 void *Mem =
1981 SizeOfTrailingObjects),
1982 alignof(CUDAKernelCallExpr));
1983 return new (Mem) CUDAKernelCallExpr(NumArgs, HasFPFeatures, Empty);
1984}
1985
1988 unsigned NumUserSpecifiedExprs,
1991 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(Args.size()));
1992 return new (Mem) CXXParenListInitExpr(Args, T, NumUserSpecifiedExprs, InitLoc,
1993 LParenLoc, RParenLoc);
1994}
1995
1997 unsigned NumExprs,
1999 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumExprs),
2000 alignof(CXXParenListInitExpr));
2001 return new (Mem) CXXParenListInitExpr(Empty, NumExprs);
2002}
2003
2010 EllipsisLoc(EllipsisLoc), RParenLoc(RParenLoc),
2011 NumExpansions(NumExpansions) {
2013
2014 if (LHS && RHS)
2015 assert(LHS->containsUnexpandedParameterPack() !=
2016 RHS->containsUnexpandedParameterPack() &&
2017 "Exactly one of LHS or RHS should contain an unexpanded pack");
2018 SubExprs[SubExpr::Callee] = Callee;
2019 SubExprs[SubExpr::LHS] = LHS;
2020 SubExprs[SubExpr::RHS] = RHS;
2022}
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
static bool hasOnlyNonStaticMemberFunctions(UnresolvedSetIterator begin, UnresolvedSetIterator end)
Definition ExprCXX.cpp:1595
static bool isGLValueFromPointerDeref(const Expr *E)
Definition ExprCXX.cpp:168
static bool UnresolvedLookupExprIsVariableOrConceptParameterPack(UnresolvedSetIterator Begin, UnresolvedSetIterator End)
Definition ExprCXX.cpp:399
Defines the clang::Expr interface and subclasses for C++ expressions.
TokenType getType() const
Returns the token's type, e.g.
void setType(TokenType T)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the LambdaCapture class.
llvm::MachO::Record Record
Defines an enumeration for C++ overloaded operators.
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
a trap message and trap category.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const LangOptions & getLangOpts() const
void * Allocate(size_t Size, unsigned Align=8) const
Represents a call to a CUDA kernel function.
static CUDAKernelCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Definition ExprCXX.cpp:1972
static CUDAKernelCallExpr * Create(const ASTContext &Ctx, Expr *Fn, CallExpr *Config, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RP, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0)
Definition ExprCXX.cpp:1956
A C++ addrspace_cast expression (currently only enabled for OpenCL).
static CXXAddrspaceCastExpr * CreateEmpty(const ASTContext &Context)
Definition ExprCXX.cpp:914
static CXXAddrspaceCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind, Expr *Op, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Definition ExprCXX.cpp:906
Represents a base class of a C++ class.
static CXXBindTemporaryExpr * Create(const ASTContext &C, CXXTemporary *Temp, Expr *SubExpr)
Definition ExprCXX.cpp:1118
static CXXConstCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, Expr *Op, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Definition ExprCXX.cpp:892
static CXXConstCastExpr * CreateEmpty(const ASTContext &Context)
Definition ExprCXX.cpp:901
Represents a call to a C++ constructor.
SourceRange getParenOrBraceRange() const
static CXXConstructExpr * Create(const ASTContext &Ctx, QualType Ty, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr * > Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, CXXConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
Create a C++ construction expression.
Definition ExprCXX.cpp:1180
Expr * getArg(unsigned Arg)
Return the specified argument.
CXXConstructExpr(StmtClass SC, QualType Ty, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr * > Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, CXXConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
Build a C++ construction expression.
Definition ExprCXX.cpp:1204
SourceLocation getLocation() const
static unsigned sizeOfTrailingObjects(unsigned NumArgs)
Return the size in bytes of the trailing objects.
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.cpp:581
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:575
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
static CXXConstructExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs)
Create an empty C++ construction expression.
Definition ExprCXX.cpp:1195
Represents a C++ constructor within a class.
Expr * getExpr()
Definition ExprCXX.cpp:1050
const ParmVarDecl * getParam() const
Expr * getRewrittenExpr()
Expr * getAdjustedRewrittenExpr()
Definition ExprCXX.cpp:1055
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
Definition ExprCXX.cpp:1039
static CXXDefaultArgExpr * CreateEmpty(const ASTContext &C, bool HasRewrittenInit)
Definition ExprCXX.cpp:1032
bool hasRewrittenInit() const
static CXXDefaultInitExpr * Create(const ASTContext &Ctx, SourceLocation Loc, FieldDecl *Field, DeclContext *UsedContext, Expr *RewrittenInitExpr)
Field is the non-static data member whose default initializer is used by this expression.
Definition ExprCXX.cpp:1093
const Expr * getRewrittenExpr() const
Retrieve the initializing expression with evaluated immediate calls, if any.
bool hasRewrittenInit() const
Expr * getExpr()
Get the initialization expression that will be used.
Definition ExprCXX.cpp:1105
static CXXDefaultInitExpr * CreateEmpty(const ASTContext &C, bool HasRewrittenInit)
Definition ExprCXX.cpp:1086
FunctionDecl * getOperatorDelete() const
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition ExprCXX.cpp:338
static CXXDependentScopeMemberExpr * Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Definition ExprCXX.cpp:1550
static CXXDependentScopeMemberExpr * CreateEmpty(const ASTContext &Ctx, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs, bool HasFirstQualifierFoundInScope)
Definition ExprCXX.cpp:1571
Represents a C++ destructor within a class.
static CXXDynamicCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Definition ExprCXX.cpp:806
static CXXDynamicCastExpr * CreateEmpty(const ASTContext &Context, unsigned pathSize)
Definition ExprCXX.cpp:824
bool isAlwaysNull() const
isAlwaysNull - Return whether the result of the dynamic_cast is proven to always be null.
Definition ExprCXX.cpp:838
CXXFoldExpr(QualType T, UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Opcode, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, UnsignedOrNone NumExpansions)
Definition ExprCXX.cpp:2004
static CXXFunctionalCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize, bool HasFPFeatures)
Definition ExprCXX.cpp:934
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:944
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.cpp:948
static CXXFunctionalCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, TypeSourceInfo *Written, CastKind Kind, Expr *Op, const CXXCastPath *Path, FPOptionsOverride FPO, SourceLocation LPLoc, SourceLocation RPLoc)
Definition ExprCXX.cpp:918
CXXMethodDecl * getMethodDecl() const
Retrieve the declaration of the called method.
Definition ExprCXX.cpp:741
Expr * getImplicitObjectArgument() const
Retrieve the implicit object argument for the member call.
Definition ExprCXX.cpp:722
static CXXMemberCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Definition ExprCXX.cpp:709
static CXXMemberCallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RP, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0)
Definition ExprCXX.cpp:692
QualType getObjectType() const
Retrieve the type of the object argument.
Definition ExprCXX.cpp:734
CXXRecordDecl * getRecordDecl() const
Retrieve the CXXRecordDecl for the underlying type of the implicit object argument.
Definition ExprCXX.cpp:750
Represents a static or instance method of a struct/union/class.
const char * getCastName() const
getCastName - Get the name of the C++ cast being used, e.g., "static_cast", "dynamic_cast",...
Definition ExprCXX.cpp:768
static CXXNewExpr * Create(const ASTContext &Ctx, bool IsGlobalNew, FunctionDecl *OperatorNew, FunctionDecl *OperatorDelete, const ImplicitAllocationParameters &IAP, bool UsualArrayDeleteWantsSize, ArrayRef< Expr * > PlacementArgs, SourceRange TypeIdParens, std::optional< Expr * > ArraySize, CXXNewInitializationStyle InitializationStyle, Expr *Initializer, QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range, SourceRange DirectInitRange)
Create a c++ new expression.
Definition ExprCXX.cpp:293
static CXXNewExpr * CreateEmpty(const ASTContext &Ctx, bool IsArray, bool HasInit, unsigned NumPlacementArgs, bool IsParenTypeId)
Create an empty c++ new expression.
Definition ExprCXX.cpp:315
bool shouldNullCheckAllocation() const
True if the allocation result needs to be null-checked.
Definition ExprCXX.cpp:326
FunctionDecl * getOperatorNew() const
A call to an overloaded operator written using operator syntax.
bool isInfixBinaryOp() const
Is this written as an infix binary operator?
Definition ExprCXX.cpp:48
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
SourceLocation getEndLoc() const
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
static CXXOperatorCallExpr * Create(const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation OperatorLoc, FPOptionsOverride FPFeatures, ADLCallKind UsesADL=NotADL)
Definition ExprCXX.cpp:624
static CXXOperatorCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Definition ExprCXX.cpp:641
SourceLocation getBeginLoc() const
Represents a list-initialization with parenthesis.
static CXXParenListInitExpr * Create(ASTContext &C, ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Definition ExprCXX.cpp:1987
static CXXParenListInitExpr * CreateEmpty(ASTContext &C, unsigned numExprs, EmptyShell Empty)
Definition ExprCXX.cpp:1996
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an '->' (otherwise,...
CXXPseudoDestructorExpr(const ASTContext &Context, Expr *Base, bool isArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, TypeSourceInfo *ScopeType, SourceLocation ColonColonLoc, SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType)
Definition ExprCXX.cpp:371
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.cpp:392
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition ExprCXX.cpp:385
Represents a C++ struct/union/class.
capture_const_iterator captures_end() const
capture_const_iterator captures_begin() const
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
static CXXReinterpretCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Definition ExprCXX.cpp:870
static CXXReinterpretCastExpr * CreateEmpty(const ASTContext &Context, unsigned pathSize)
Definition ExprCXX.cpp:887
Expr * getSemanticForm()
Get an equivalent semantic form for this expression.
bool isReversed() const
Determine whether this expression was rewritten in reverse form.
DecomposedForm getDecomposedForm() const LLVM_READONLY
Decompose this operator into its syntactic form.
Definition ExprCXX.cpp:65
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:223
SourceLocation getRParenLoc() const
A C++ static_cast expression (C++ [expr.static.cast]).
static CXXStaticCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written, FPOptionsOverride FPO, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Definition ExprCXX.cpp:780
static CXXStaticCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize, bool hasFPFeatures)
Definition ExprCXX.cpp:797
Represents a C++ functional cast expression that builds a temporary object.
static CXXTemporaryObjectExpr * Create(const ASTContext &Ctx, CXXConstructorDecl *Cons, QualType Ty, TypeSourceInfo *TSI, ArrayRef< Expr * > Args, SourceRange ParenOrBraceRange, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization)
Definition ExprCXX.cpp:1146
TypeSourceInfo * getTypeSourceInfo() const
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.cpp:1173
static CXXTemporaryObjectExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs)
Definition ExprCXX.cpp:1161
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:1169
Represents a C++ temporary.
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
Definition ExprCXX.cpp:1113
static CXXThisExpr * CreateEmpty(const ASTContext &Ctx)
Definition ExprCXX.cpp:1591
static CXXThisExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType Ty, bool IsImplicit)
Definition ExprCXX.cpp:1585
bool isTypeOperand() const
QualType getTypeOperand(const ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
Definition ExprCXX.cpp:161
Expr * getExprOperand() const
bool isMostDerived(const ASTContext &Context) const
Best-effort check if the expression operand refers to a most derived object.
Definition ExprCXX.cpp:149
bool isPotentiallyEvaluated() const
Determine whether this typeid has a type operand which is potentially evaluated, per C++11 [expr....
Definition ExprCXX.cpp:134
bool hasNullCheck() const
Whether this is of a form like "typeid(*ptr)" that can throw a std::bad_typeid if a pointer is a null...
Definition ExprCXX.cpp:200
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
static CXXUnresolvedConstructExpr * Create(const ASTContext &Context, QualType T, TypeSourceInfo *TSI, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool IsListInit)
Definition ExprCXX.cpp:1488
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:1504
static CXXUnresolvedConstructExpr * CreateEmpty(const ASTContext &Context, unsigned NumArgs)
Definition ExprCXX.cpp:1498
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this __uuidof() expression after various required adjustments (removing...
Definition ExprCXX.cpp:215
bool isTypeOperand() const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
static unsigned sizeOfTrailingObjects(unsigned NumPreArgs, unsigned NumArgs, bool HasFPFeatures)
Return the size in bytes needed for the trailing objects.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
CallExpr(StmtClass SC, Expr *Fn, ArrayRef< Expr * > PreArgs, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs, ADLCallKind UsesADL)
Build a call expression, assuming that appropriate storage has been allocated for the trailing object...
static constexpr unsigned sizeToAllocateForCallExprSubclass(unsigned SizeOfTrailingObjects)
SourceLocation getRParenLoc() const
static constexpr ADLCallKind UsesADL
CastKind getCastKind() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
A POD class for pairing a NamedDecl* with an access specifier.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Decl - This represents one declaration (or definition), e.g.
bool isParameterPack() const
Whether this declaration is a parameter pack.
const AssociatedConstraint & getTrailingRequiresClause() const
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
A qualified reference to a name whose declaration cannot yet be resolved.
static DependentScopeDeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Definition ExprCXX.cpp:544
static DependentScopeDeclRefExpr * CreateEmpty(const ASTContext &Context, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition ExprCXX.cpp:559
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to.
static ExprWithCleanups * Create(const ASTContext &C, EmptyShell empty, unsigned numObjects)
Definition ExprCXX.cpp:1464
This represents one expression.
Expr * IgnoreParenNoopCasts(const ASTContext &Ctx) LLVM_READONLY
Skip past any parentheses and casts which do not change the value (including ptr->int casts of the sa...
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
void setDependence(ExprDependence Deps)
Each concrete expr subclass is expected to compute its dependence and call this in the constructor.
Represents difference between two FPOptions values.
bool requiresTrailingStorage() const
Represents a member of a struct/union/class.
FullExpr - Represents a "full-expression" node.
Represents a function declaration or definition.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
bool isReservedGlobalPlacementOperator() const
Determines whether this operator new or delete is one of the reserved global placement operators: voi...
Represents a reference to a function parameter pack, init-capture pack, or binding pack that has been...
static FunctionParmPackExpr * Create(const ASTContext &Context, QualType T, ValueDecl *ParamPack, SourceLocation NameLoc, ArrayRef< ValueDecl * > Params)
Definition ExprCXX.cpp:1816
static FunctionParmPackExpr * CreateEmpty(const ASTContext &Context, unsigned NumParams)
Definition ExprCXX.cpp:1824
Represents a prototype with parameter type info, e.g.
Declaration of a template function.
One of these records is kept for each identifier that is lexed.
Describes the capture of a variable or of this, or of a C++1y init-capture.
bool capturesVLAType() const
Determine whether this captures a variable length array bound expression.
LambdaCapture(SourceLocation Loc, bool Implicit, LambdaCaptureKind Kind, ValueDecl *Var=nullptr, SourceLocation EllipsisLoc=SourceLocation())
Create a new capture of a variable or of this.
Definition ExprCXX.cpp:1234
LambdaCaptureKind getCaptureKind() const
Determine the kind of capture.
Definition ExprCXX.cpp:1264
bool capturesThis() const
Determine whether this capture handles the C++ this pointer.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Definition ExprCXX.cpp:1363
static LambdaExpr * CreateDeserialized(const ASTContext &C, unsigned NumCaptures)
Construct a new lambda expression that will be deserialized from an external source.
Definition ExprCXX.cpp:1332
static LambdaExpr * Create(const ASTContext &C, CXXRecordDecl *Class, SourceRange IntroducerRange, LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc, bool ExplicitParams, bool ExplicitResultType, ArrayRef< Expr * > CaptureInits, SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack)
Construct a new lambda expression.
Definition ExprCXX.cpp:1312
Stmt * getBody() const
Retrieve the body of the lambda.
Definition ExprCXX.cpp:1346
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
Definition ExprCXX.cpp:1428
capture_iterator implicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of implicit lambda captures.
Definition ExprCXX.cpp:1392
unsigned capture_size() const
Determine the number of captures in this lambda.
capture_range explicit_captures() const
Retrieve this lambda's explicit captures.
Definition ExprCXX.cpp:1384
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
Definition ExprCXX.cpp:1358
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
Definition ExprCXX.cpp:1404
const CompoundStmt * getCompoundStmtBody() const
Retrieve the CompoundStmt representing the body of the lambda.
Definition ExprCXX.cpp:1351
capture_range implicit_captures() const
Retrieve this lambda's implicit captures.
Definition ExprCXX.cpp:1396
const AssociatedConstraint & getTrailingRequiresClause() const
Get the trailing requires clause, if any.
Definition ExprCXX.cpp:1424
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it,...
Definition ExprCXX.cpp:1414
ArrayRef< NamedDecl * > getExplicitTemplateParameters() const
Get the template parameters were explicitly specified (as opposed to being invented by use of an auto...
Definition ExprCXX.cpp:1419
capture_iterator implicit_capture_begin() const
Retrieve an iterator pointing to the first implicit lambda capture.
Definition ExprCXX.cpp:1388
capture_iterator explicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
Definition ExprCXX.cpp:1379
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition ExprCXX.cpp:1367
llvm::iterator_range< capture_iterator > capture_range
An iterator over a range of lambda captures.
const LambdaCapture * capture_iterator
An iterator that walks over the captures of the lambda, both implicit and explicit.
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
Definition ExprCXX.cpp:1375
child_range children()
Includes the captures and the body of the lambda.
Definition ExprCXX.cpp:1430
FunctionTemplateDecl * getDependentCallOperator() const
Retrieve the function template call operator associated with this lambda expression.
Definition ExprCXX.cpp:1409
capture_range captures() const
Retrieve this lambda's captures.
Definition ExprCXX.cpp:1371
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Definition ExprCXX.cpp:1400
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
static LifetimeExtendedTemporaryDecl * Create(Expr *Temp, ValueDecl *EDec, unsigned Mangling)
MaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference, LifetimeExtendedTemporaryDecl *MTD=nullptr)
Definition ExprCXX.cpp:1830
ValueDecl * getExtendingDecl()
Get the declaration which triggered the lifetime-extension of this temporary, if any.
bool isUsableInConstantExpressions(const ASTContext &Context) const
Determine whether this temporary object is usable in constant expressions, as specified in C++20 [exp...
Definition ExprCXX.cpp:1861
void setExtendingDecl(ValueDecl *ExtendedBy, unsigned ManglingNumber)
Definition ExprCXX.cpp:1844
This represents a decl that may have a name.
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector::".
const Type * getAsType() const
@ Type
A type, stored as a Type*.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
ASTTemplateKWAndArgsInfo * getTrailingASTTemplateKWAndArgsInfo()
Return the optional template keyword and arguments info.
NestedNameSpecifier getQualifier() const
Fetches the nested-name qualifier, if one was given.
TemplateArgumentLoc * getTrailingTemplateArgumentLoc()
Return the optional template arguments.
DeclAccessPair * getTrailingResults()
Return the results. Defined after UnresolvedMemberExpr.
OverloadExpr(StmtClass SC, const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent, bool KnownContainsUnexpandedParameterPack)
Definition ExprCXX.cpp:479
NamedDecl * getPackDecl() const
Definition ExprCXX.cpp:1750
static PackIndexingExpr * CreateDeserialized(ASTContext &Context, unsigned NumTransformedExprs)
Definition ExprCXX.cpp:1761
Expr * getPackIdExpression() const
static PackIndexingExpr * Create(ASTContext &Context, SourceLocation EllipsisLoc, SourceLocation RSquareLoc, Expr *PackIdExpr, Expr *IndexExpr, std::optional< int64_t > Index, ArrayRef< Expr * > SubstitutedExprs={}, bool FullySubstituted=false)
Definition ExprCXX.cpp:1733
Represents a parameter to a function.
PointerType - C99 6.7.5.1 - Pointer Declarators.
Stores the type being destroyed by a pseudo-destructor expression.
PseudoDestructorTypeStorage()=default
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isConstant(const ASTContext &Ctx) const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
The collection of all-type qualifiers we support.
static SizeOfPackExpr * CreateDeserialized(ASTContext &Context, unsigned NumPartialArgs)
Definition ExprCXX.cpp:1721
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs={})
Definition ExprCXX.cpp:1709
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
void setEnd(SourceLocation e)
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
CXXUnresolvedConstructExprBitfields CXXUnresolvedConstructExprBits
ExprWithCleanupsBitfields ExprWithCleanupsBits
StmtClass getStmtClass() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
OverloadExprBitfields OverloadExprBits
CXXConstructExprBitfields CXXConstructExprBits
CXXDependentScopeMemberExprBitfields CXXDependentScopeMemberExprBits
TypeTraitExprBitfields TypeTraitExprBits
CXXNewExprBitfields CXXNewExprBits
llvm::iterator_range< child_iterator > child_range
CXXFoldExprBitfields CXXFoldExprBits
CXXDefaultInitExprBitfields CXXDefaultInitExprBits
DependentScopeDeclRefExprBitfields DependentScopeDeclRefExprBits
llvm::iterator_range< const_child_iterator > const_child_range
CXXDefaultArgExprBitfields CXXDefaultArgExprBits
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
QualType getParameterType(const ASTContext &Ctx) const
Determine the substituted type of the template parameter.
Definition ExprCXX.cpp:1768
bool isReferenceParameter() const
NonTypeTemplateParmDecl * getParameter() const
Definition ExprCXX.cpp:1728
TemplateArgument getArgumentPack() const
Retrieve the template argument pack containing the substituted template arguments.
Definition ExprCXX.cpp:1799
NonTypeTemplateParmDecl * getParameterPack() const
Retrieve the non-type template parameter pack being substituted.
Definition ExprCXX.cpp:1794
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
A convenient class for passing around template argument information.
Location wrapper for a TemplateArgument.
Represents a template argument.
Stores a list of template parameters for a TemplateDecl and its derived classes.
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
static TypeTraitExpr * Create(const ASTContext &C, QualType T, SourceLocation Loc, TypeTrait Kind, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc, bool Value)
Create a new type trait expression.
Definition ExprCXX.cpp:1914
static TypeTraitExpr * CreateDeserialized(const ASTContext &C, bool IsStoredAsBool, unsigned NumArgs)
Definition ExprCXX.cpp:1934
The base class of the type hierarchy.
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isVoidPointerType() const
bool isPointerType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
bool isPointerOrReferenceType() const
bool isFloatingType() const
bool isAnyPointerType() const
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
static UnresolvedLookupExpr * CreateEmpty(const ASTContext &Context, unsigned NumResults, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition ExprCXX.cpp:467
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
Definition ExprCXX.cpp:432
QualType getBaseType() const
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
static UnresolvedMemberExpr * Create(const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
Definition ExprCXX.cpp:1652
CXXRecordDecl * getNamingClass()
Retrieve the naming class of this lookup.
Definition ExprCXX.cpp:1683
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
Definition ExprCXX.cpp:1645
static UnresolvedMemberExpr * CreateEmpty(const ASTContext &Context, unsigned NumResults, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition ExprCXX.cpp:1671
The iterator over UnresolvedSets.
LiteralOperatorKind getLiteralOperatorKind() const
Returns the kind of literal operator invocation which this expression represents.
Definition ExprCXX.cpp:999
const IdentifierInfo * getUDSuffix() const
Returns the ud-suffix specified for this literal.
Definition ExprCXX.cpp:1028
static UserDefinedLiteral * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation LitEndLoc, SourceLocation SuffixLoc, FPOptionsOverride FPFeatures)
Definition ExprCXX.cpp:966
static UserDefinedLiteral * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPOptions, EmptyShell Empty)
Definition ExprCXX.cpp:984
Expr * getCookedLiteral()
If this is not a raw user-defined literal, get the underlying cooked literal (representing the litera...
Definition ExprCXX.cpp:1020
LiteralOperatorKind
The kind of literal operator which is invoked.
@ LOK_String
operator "" X (const CharT *, size_t)
@ LOK_Raw
Raw form: operator "" X (const char *)
@ LOK_Floating
operator "" X (long double)
@ LOK_Integer
operator "" X (unsigned long long)
@ LOK_Template
Raw form: operator "" X<cs...> ()
@ LOK_Character
operator "" X (CharT)
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
bool isa(CodeGen::Address addr)
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
@ OK_Ordinary
An ordinary object is located at an address in memory.
LambdaCaptureKind
The different capture forms in a lambda introducer.
@ LCK_ByCopy
Capturing by copy (a.k.a., by value)
@ LCK_ByRef
Capturing by reference.
@ LCK_VLAType
Capturing variable-length array type.
@ LCK_StarThis
Capturing the *this object by copy.
@ LCK_This
Capturing the *this object by reference.
ExprDependence computeDependence(FullExpr *E)
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
bool isAlignedAllocation(AlignedAllocationMode Mode)
@ Result
The result type of a method or function.
const FunctionProtoType * T
bool isTypeAwareAllocation(TypeAwareAllocationMode Mode)
CastKind
CastKind - The kind of operation required for a conversion.
std::tuple< NamedDecl *, TemplateArgument > getReplacedTemplateParameter(Decl *D, unsigned Index)
Internal helper used by Subst* nodes to retrieve a parameter from the AssociatedDecl,...
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
U cast(CodeGen::Address addr)
@ Class
The "class" keyword introduces the elaborated-type-specifier.
TypeTrait
Names for traits that operate specifically on types.
CXXNewInitializationStyle
@ Parens
New-expression has a C++98 paren-delimited initializer.
@ None
New-expression has no initializer as written.
@ Braces
New-expression has a C++11 list-initializer.
@ Implicit
An implicit conversion.
Diagnostic wrappers for TextAPI types for error reporting.
Represents an explicit template argument list in C++, e.g., the "" in "sort".
void initializeFrom(SourceLocation TemplateKWLoc, const TemplateArgumentListInfo &List, TemplateArgumentLoc *OutArgArray)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
AlignedAllocationMode PassAlignment
TypeAwareAllocationMode PassTypeIdentity
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....