clang: lib/Sema/SemaTemplateVariadic.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
23#include "llvm/Support/SaveAndRestore.h"
24#include
25
26using namespace clang;
27
28
29
30
31
32namespace {
33
34class CollectUnexpandedParameterPacksVisitor
36 SmallVectorImpl &Unexpanded;
37
38 bool InLambdaOrBlock = false;
39 unsigned DepthLimit = (unsigned)-1;
40
41#ifndef NDEBUG
42 bool ContainsIntermediatePacks = false;
43#endif
44
45 void addUnexpanded(NamedDecl *ND, SourceLocation Loc = SourceLocation()) {
46 if (auto *VD = dyn_cast(ND)) {
47
48
49
50 auto *FD = dyn_cast(VD->getDeclContext());
51 auto *FTD = FD ? FD->getDescribedFunctionTemplate() : nullptr;
52 if (FTD && FTD->getTemplateParameters()->getDepth() >= DepthLimit)
53 return;
56 return;
57 }
58
59 Unexpanded.push_back({ND, Loc});
60 }
61
62 void addUnexpanded(const TemplateTypeParmType *T,
63 SourceLocation Loc = SourceLocation()) {
64 if (T->getDepth() < DepthLimit)
65 Unexpanded.push_back({T, Loc});
66 }
67
68 bool addUnexpanded(const SubstBuiltinTemplatePackType *T,
69 SourceLocation Loc = SourceLocation()) {
70 Unexpanded.push_back({T, Loc});
71 return true;
72 }
73
74 bool addUnexpanded(const TemplateSpecializationType *T,
75 SourceLocation Loc = SourceLocation()) {
78 Unexpanded.push_back({T, Loc});
79 return true;
80 }
81
82
83
84 bool
85 TryTraverseSpecializationProducingPacks(const TemplateSpecializationType *T,
86 SourceLocation Loc) {
88 return false;
89
90
92 addUnexpanded(T, Loc);
93 return true;
94 }
95
96
97
98
100 return true;
101 }
102
103 public:
104 explicit CollectUnexpandedParameterPacksVisitor(
105 SmallVectorImpl &Unexpanded)
106 : Unexpanded(Unexpanded) {
107 ShouldWalkTypesOfTypeLocs = false;
108
109
110 ShouldVisitImplicitCode = true;
111 }
112
113
114
115
116
117
118 bool VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) override {
119 if (TL.getTypePtr()->isParameterPack())
121 return true;
122 }
123
124
125
126
127
128
129 bool VisitTemplateTypeParmType(TemplateTypeParmType *T) override {
130 if (T->isParameterPack())
131 addUnexpanded(T);
132
133 return true;
134 }
135
136
137
138 bool VisitDeclRefExpr(DeclRefExpr *E) override {
141
142 return true;
143 }
144
145
147 if (auto *TTP = dyn_cast_or_null(
148 Template.getAsTemplateDecl())) {
149 if (TTP->isParameterPack())
150 addUnexpanded(TTP);
151 }
152
153#ifndef NDEBUG
154 ContainsIntermediatePacks |=
155 (bool)Template.getAsSubstTemplateTemplateParmPack();
156#endif
157
159 }
160
161 bool
162 TraverseTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc T,
163 bool TraverseQualifier) override {
164 if (TryTraverseSpecializationProducingPacks(T.getTypePtr(),
165 T.getBeginLoc()))
166 return true;
167 return DynamicRecursiveASTVisitor::TraverseTemplateSpecializationTypeLoc(
168 T, TraverseQualifier);
169 }
170
171 bool TraverseTemplateSpecializationType(TemplateSpecializationType *T,
172 bool TraverseQualfier) override {
173 if (TryTraverseSpecializationProducingPacks(T, SourceLocation()))
174 return true;
175 return DynamicRecursiveASTVisitor::TraverseTemplateSpecializationType(T);
176 }
177
178
179
180 bool TraverseObjCDictionaryLiteral(ObjCDictionaryLiteral *E) override {
182 return true;
183
184 for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
187 continue;
188
189 TraverseStmt(Element.Key);
190 TraverseStmt(Element.Value);
191 }
192 return true;
193 }
194
195
196
197
198
199
200 bool TraverseStmt(Stmt *S) override {
201 Expr *E = dyn_cast_or_null(S);
204
205 return true;
206 }
207
208
209
210 bool TraverseType(QualType T, bool TraverseQualifier = true) override {
212 InLambdaOrBlock)
214
215 return true;
216 }
217
218
219
220 bool TraverseTypeLoc(TypeLoc TL, bool TraverseQualifier = true) override {
223 InLambdaOrBlock)
225 TraverseQualifier);
226
227 return true;
228 }
229
230
231 bool TraverseDecl(Decl *D) override {
232
233
234
236 return true;
237
239 }
240
241
242 bool TraverseAttr(Attr *A) override {
244 return true;
245
247 }
248
249
250
251 bool TraversePackExpansionType(PackExpansionType *T,
252 bool TraverseQualifier) override {
253 return true;
254 }
255 bool TraversePackExpansionTypeLoc(PackExpansionTypeLoc TL,
256 bool TraverseQualifier) override {
257 return true;
258 }
259 bool TraversePackExpansionExpr(PackExpansionExpr *E) override {
260 return true;
261 }
262 bool TraverseCXXFoldExpr(CXXFoldExpr *E) override { return true; }
263 bool TraversePackIndexingExpr(PackIndexingExpr *E) override {
265 }
266 bool TraversePackIndexingType(PackIndexingType *E,
267 bool TraverseQualifier) override {
269 }
270 bool TraversePackIndexingTypeLoc(PackIndexingTypeLoc TL,
271 bool TraverseQualifier) override {
273 }
274
275
276
277
278 bool
279 TraverseUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) override {
281 return true;
282
283 return DynamicRecursiveASTVisitor::TraverseUnresolvedUsingValueDecl(D);
284 }
285
286
287 bool TraverseUnresolvedUsingTypenameDecl(
288 UnresolvedUsingTypenameDecl *D) override {
290 return true;
291
292 return DynamicRecursiveASTVisitor::TraverseUnresolvedUsingTypenameDecl(D);
293 }
294
295
296 bool TraverseTemplateArgument(const TemplateArgument &Arg) override {
298 return true;
299
301 }
302
303
304 bool
305 TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc) override {
307 return true;
308
310 }
311
312
313 bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &Base) override {
314 if (Base.isPackExpansion())
315 return true;
316
318 }
319
320
321 bool TraverseConstructorInitializer(CXXCtorInitializer *Init) override {
322 if (Init->isPackExpansion())
323 return true;
324
326 }
327
328
329
330
331
332
333 bool TraverseLambdaExpr(LambdaExpr *Lambda) override {
334
335
337 return true;
338
339 SaveAndRestore _(InLambdaOrBlock, true);
340 unsigned OldDepthLimit = DepthLimit;
341
343 DepthLimit = TPL->getDepth();
344
345 DynamicRecursiveASTVisitor::TraverseLambdaExpr(Lambda);
346
347 DepthLimit = OldDepthLimit;
348 return true;
349 }
350
351
352 bool TraverseBlockExpr(BlockExpr *Block) override {
353 if (->containsUnexpandedParameterPack())
354 return true;
355
356 SaveAndRestore _(InLambdaOrBlock, true);
357 DynamicRecursiveASTVisitor::TraverseBlockExpr(Block);
358 return true;
359 }
360
361
362 bool TraverseLambdaCapture(LambdaExpr *Lambda, const LambdaCapture *C,
363 Expr *Init) override {
364 if (C->isPackExpansion())
365 return true;
366
368 }
369
370 bool TraverseUnresolvedLookupExpr(UnresolvedLookupExpr *E) override {
373 if (const auto *TTP = dyn_cast(ND);
374 TTP && TTP->isParameterPack())
376 }
377 return DynamicRecursiveASTVisitor::TraverseUnresolvedLookupExpr(E);
378 }
379
380 bool TraverseSubstBuiltinTemplatePackType(SubstBuiltinTemplatePackType *T,
381 bool TraverseQualifier) override {
382 addUnexpanded(T);
383
384
385 return true;
386 }
387
388#ifndef NDEBUG
389 bool TraverseFunctionParmPackExpr(FunctionParmPackExpr *) override {
390 ContainsIntermediatePacks = true;
391 return true;
392 }
393
394 bool TraverseSubstNonTypeTemplateParmPackExpr(
395 SubstNonTypeTemplateParmPackExpr *) override {
396 ContainsIntermediatePacks = true;
397 return true;
398 }
399
400 bool VisitSubstTemplateTypeParmPackType(
401 SubstTemplateTypeParmPackType *) override {
402 ContainsIntermediatePacks = true;
403 return true;
404 }
405
406 bool VisitSubstTemplateTypeParmPackTypeLoc(
407 SubstTemplateTypeParmPackTypeLoc) override {
408 ContainsIntermediatePacks = true;
409 return true;
410 }
411
412 bool containsIntermediatePacks() const { return ContainsIntermediatePacks; }
413#endif
414};
415}
416
417
418
419
420
421
422
423
427 return true;
428 return false;
429}
430
431
432
433bool
437 if (Unexpanded.empty())
438 return false;
439
440
441
442
443
444
447 for (auto &Pack : Unexpanded) {
448 auto DeclaresThisPack = [&](NamedDecl *LocalPack) {
449 if (auto *TTPT = Pack.first.dyn_cast<const TemplateTypeParmType *>()) {
450 auto *TTPD = dyn_cast(LocalPack);
451 return TTPD && TTPD->getTypeForDecl() == TTPT;
452 }
454 };
455 if (llvm::any_of(CSI->LocalPacks, DeclaresThisPack))
456 ParamPackReferences.push_back(Pack);
457 }
458
459 if (ParamPackReferences.empty()) {
460
461
462
463
464
465
466
467
468
469
470
471 bool EnclosingStmtExpr = false;
474 if (llvm::any_of(
475 Func->CompoundScopes,
477 EnclosingStmtExpr = true;
478 break;
479 }
480
481
482 if (Func == CSI)
483 break;
484 }
485
486 if (!EnclosingStmtExpr) {
487 CSI->ContainsUnexpandedParameterPack = true;
488 return false;
489 }
490 } else {
491 Unexpanded = ParamPackReferences;
492 }
493 }
494
498
499 for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
501 if (const TemplateTypeParmType *TTP
502 = Unexpanded[I].first.dyn_cast<const TemplateTypeParmType *>())
503 Name = TTP->getIdentifier();
504 else if (NamedDecl *ND = Unexpanded[I].first.dyn_cast<NamedDecl *>())
506
507 if (Name && NamesKnown.insert(Name).second)
508 Names.push_back(Name);
509
510 if (Unexpanded[I].second.isValid())
511 Locations.push_back(Unexpanded[I].second);
512 }
513
514 auto DB = Diag(Loc, diag::err_unexpanded_parameter_pack)
515 << (int)UPPC << (int)Names.size();
516 for (size_t I = 0, E = std::min(Names.size(), (size_t)2); I != E; ++I)
517 DB << Names[I];
518
519 for (unsigned I = 0, N = Locations.size(); I != N; ++I)
521 return true;
522}
523
527
528
529
530 if (->getType()->containsUnexpandedParameterPack())
531 return false;
532
534 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseTypeLoc(
535 T->getTypeLoc());
536 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
538}
539
542
543
544
546 return false;
547
549 CollectUnexpandedParameterPacksVisitor Visitor(Unexpanded);
550 Visitor.TraverseStmt(E);
551#ifndef NDEBUG
552
553
554
555
556
557 bool LambdaReferencingOuterPacks =
559 assert((!Unexpanded.empty() || LambdaReferencingOuterPacks) &&
560 "Unable to find unexpanded parameter packs");
561#endif
563}
564
567 return false;
568
570 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseStmt(RE);
571 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
572
573
574
578 for (auto Parm : Unexpanded)
579 if (ParmSet.contains(Parm.first.dyn_cast<NamedDecl *>()))
580 UnexpandedParms.push_back(Parm);
581 if (UnexpandedParms.empty())
582 return false;
583
585 UnexpandedParms);
586}
587
590
591
592
594 return false;
595
597 CollectUnexpandedParameterPacksVisitor(Unexpanded)
598 .TraverseNestedNameSpecifier(SS.getScopeRep());
599 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
601 UPPC, Unexpanded);
602}
603
606
607
608
618 return false;
619
623
626
628 return false;
629
630 break;
631 }
632
634 CollectUnexpandedParameterPacksVisitor(Unexpanded)
636 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
638}
639
643
644 if (Template.isNull() || .containsUnexpandedParameterPack())
645 return false;
646
648 CollectUnexpandedParameterPacksVisitor(Unexpanded)
649 .TraverseTemplateName(Template);
650 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
652}
653
658 return false;
659
661 CollectUnexpandedParameterPacksVisitor(Unexpanded)
662 .TraverseTemplateArgumentLoc(Arg);
663 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
665}
666
669 CollectUnexpandedParameterPacksVisitor(Unexpanded)
670 .TraverseTemplateArgument(Arg);
671}
672
675 CollectUnexpandedParameterPacksVisitor(Unexpanded)
676 .TraverseTemplateArgumentLoc(Arg);
677}
678
681 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(T);
682}
683
686 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseTypeLoc(TL);
687}
688
692 CollectUnexpandedParameterPacksVisitor(Unexpanded)
693 .TraverseNestedNameSpecifierLoc(NNS);
694}
695
699 CollectUnexpandedParameterPacksVisitor(Unexpanded)
700 .TraverseDeclarationNameInfo(NameInfo);
701}
702
705 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseStmt(E);
706}
707
711 return Arg;
712
713
714
715
716 auto *T = dyn_cast_or_null(
718 if (T && T->isPackProducingBuiltinTemplate())
721
722 return Arg;
723}
724
729 return Arg;
730
734 if (Result.isInvalid())
736
739 }
740
743 if (Result.isInvalid())
745
748 }
749
755 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
756 << R;
758 }
759
761 }
762 llvm_unreachable("Unhandled template argument kind?");
763}
764
769 if (!TSInfo)
770 return true;
771
774 if (!TSResult)
775 return true;
776
778}
779
783
786 EllipsisLoc, NumExpansions);
788 return nullptr;
789
794
796}
797
801
802
803
804
805
806
807
810 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
811 << PatternRange;
813 }
814
815 return Context.getPackExpansionType(Pattern, NumExpansions,
816 false);
817}
818
822
825 if (!Pattern)
827
828
829
830
831
833 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
836 }
837
838
840}
841
846 bool FailOnPackProducingTemplates, bool &ShouldExpand,
848 ShouldExpand = true;
849 RetainExpansion = false;
851 bool HaveFirstPack = false;
855
857
858 unsigned Depth = 0, Index = 0;
860 bool IsVarDeclPack = false;
862 std::optional NumPrecomputedArguments;
863
864 if (auto *TTP = ParmPack.first.dyn_cast<const TemplateTypeParmType *>()) {
865 Depth = TTP->getDepth();
866 Index = TTP->getIndex();
867 Name = TTP->getIdentifier();
868 } else if (auto *TST =
869 ParmPack.first
870 .dyn_cast<const TemplateSpecializationType *>()) {
872
873 ShouldExpand = false;
874 if (!FailOnPackProducingTemplates)
875 continue;
876
878 return true;
879
880
882 : EllipsisLoc,
883 diag::err_unsupported_builtin_template_pack_expansion)
884 << TST->getTemplateName();
885 } else if (auto *S =
886 ParmPack.first
887 .dyn_cast<const SubstBuiltinTemplatePackType *>()) {
888 Name = nullptr;
889 NumPrecomputedArguments = S->getNumArgs();
890 } else {
893 IsVarDeclPack = true;
895
896 llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation =
900 BindingPack = cast_if_present(BindingExpr);
901 if (!BindingPack) {
902 ShouldExpand = false;
903 continue;
904 }
905 } else
907
909 }
910
911
912 unsigned NewPackSize, PendingPackExpansionSize = 0;
913 if (IsVarDeclPack) {
914
915 llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation =
919
921 } else {
922
923
924 ShouldExpand = false;
925 continue;
926 }
927 } else if (BindingPack) {
929 } else if (NumPrecomputedArguments) {
930 NewPackSize = *NumPrecomputedArguments;
931 } else {
932
933
934
937 ShouldExpand = false;
938 continue;
939 }
940
941
943 TemplateArgs(Depth, Index).getPackAsArray();
944 NewPackSize = Pack.size();
945 PendingPackExpansionSize =
948 return false;
949
952 ->castAs()
953 ->getNumExpansions();
954
957 ->getNumExpansions();
958
960 });
961 }
962
963
964
965
966
970 unsigned PartialDepth, PartialIndex;
971 std::tie(PartialDepth, PartialIndex) = getDepthAndIndex(PartialPack);
972 if (PartialDepth == Depth && PartialIndex == Index) {
973 RetainExpansion = true;
974
975 NumPartialExpansions = NewPackSize;
976 PartiallySubstitutedPackLoc = ParmPack.second;
977 continue;
978 }
979 }
980 }
981
982 if (!NumExpansions) {
983
984
985 NumExpansions = NewPackSize;
986 FirstPack = IdentifierLoc(ParmPack.second, Name);
987 HaveFirstPack = true;
988 continue;
989 }
990
991 if (NewPackSize != *NumExpansions) {
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013 unsigned LeastNewPackSize = NewPackSize - PendingPackExpansionSize;
1014 if (PendingPackExpansionSize && LeastNewPackSize <= *NumExpansions) {
1015 ShouldExpand = false;
1016 continue;
1017 }
1018
1019
1020
1022 ;
1023 else if (HaveFirstPack)
1024 Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict)
1026 << (LeastNewPackSize != NewPackSize) << LeastNewPackSize
1028 else
1029 Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict_multilevel)
1030 << Name << *NumExpansions << (LeastNewPackSize != NewPackSize)
1031 << LeastNewPackSize << SourceRange(ParmPack.second);
1032 return true;
1033 }
1034 }
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045 if (NumPartialExpansions) {
1046 if (NumExpansions && *NumExpansions < *NumPartialExpansions) {
1050 return true;
1051 Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict_partial)
1052 << PartialPack << *NumPartialExpansions << *NumExpansions
1053 << SourceRange(PartiallySubstitutedPackLoc);
1054 return true;
1055 }
1056
1057 NumExpansions = NumPartialExpansions;
1058 }
1059
1060 return false;
1061}
1062
1067 for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
1068
1069 unsigned Depth;
1070 unsigned Index;
1071
1072 if (const TemplateTypeParmType *TTP =
1073 Unexpanded[I].first.dyn_cast<const TemplateTypeParmType *>()) {
1074 Depth = TTP->getDepth();
1075 Index = TTP->getIndex();
1076 } else if (auto *TST =
1077 Unexpanded[I]
1078 .first.dyn_cast<const TemplateSpecializationType *>()) {
1079
1081 (void)TST;
1082 return std::nullopt;
1083 } else if (auto *PST =
1084 Unexpanded[I]
1085 .first
1086 .dyn_cast<const SubstBuiltinTemplatePackType *>()) {
1087 assert(( || *Result == PST->getNumArgs()) &&
1088 "inconsistent pack sizes");
1089 Result = PST->getNumArgs();
1090 continue;
1091 } else {
1094
1096
1097 llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation =
1101
1102
1103 return std::nullopt;
1104
1106 assert(( || *Result == Size) && "inconsistent pack sizes");
1108 continue;
1109 }
1110
1112 }
1115
1116
1117 return std::nullopt;
1118
1119
1120 unsigned Size = TemplateArgs(Depth, Index).pack_size();
1121 assert(( || *Result == Size) && "inconsistent pack sizes");
1123 }
1124
1126}
1127
1132 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(Pattern);
1134}
1135
1143#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case TST_##Trait:
1144#include "clang/Basic/TransformTypeTraits.def"
1147 if (.isNull() && T->containsUnexpandedParameterPack())
1148 return true;
1149 break;
1150 }
1151
1158 return true;
1159 break;
1160
1191#define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t:
1192#include "clang/Basic/OpenCLImageTypes.def"
1193#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case TST_##Name:
1194#include "clang/Basic/HLSLIntangibleTypes.def"
1197 break;
1198 }
1199
1202 switch (Chunk.Kind) {
1208
1209 break;
1210
1214 return true;
1215 break;
1217 for (unsigned i = 0, e = Chunk.Fun.NumParams; i != e; ++i) {
1219 QualType ParamTy = Param->getType();
1220 assert(!ParamTy.isNull() && "Couldn't parse type?");
1222 }
1223
1229 return true;
1230 }
1233 return true;
1234
1237 if (.isNull() && T->containsUnexpandedParameterPack())
1238 return true;
1239 }
1240 break;
1241
1244 return true;
1245 break;
1246 }
1247 }
1248
1250 if (TRC->containsUnexpandedParameterPack())
1251 return true;
1252
1253 return false;
1254}
1255
1256namespace {
1257
1258
1260 public:
1261 bool ValidateCandidate(const TypoCorrection &candidate) override {
1264 }
1265
1266 std::unique_ptr clone() override {
1267 return std::make_unique(*this);
1268 }
1269};
1270
1271}
1272
1278
1279
1282
1283 NamedDecl *ParameterPack = nullptr;
1287 break;
1288
1291 ParameterPackValidatorCCC CCC{};
1296 PDiag(diag::err_sizeof_pack_no_pack_name_suggest) << &Name,
1297 PDiag(diag::note_parameter_pack_here));
1298 ParameterPack = Corrected.getCorrectionDecl();
1299 }
1300 break;
1301 }
1304 break;
1305
1309 }
1310
1311 if (!ParameterPack || !ParameterPack->isParameterPack()) {
1312 Diag(NameLoc, diag::err_expected_name_of_pack) << &Name;
1314 }
1315
1317
1319 RParenLoc);
1320}
1321
1323 if (auto *D = dyn_cast(PackExpression); D) {
1326 }
1327 return false;
1328}
1329
1333 Expr *IndexExpr,
1338 Diag(PackExpression->getBeginLoc(), diag::err_expected_name_of_pack)
1339 << PackExpression;
1341 }
1346 ? diag::warn_cxx23_pack_indexing
1347 : diag::ext_pack_indexing);
1348 return Res;
1349}
1350
1353 Expr *IndexExpr,
1356 bool FullySubstituted) {
1357
1358 std::optional<int64_t> Index;
1361
1366 Index = Value.getExtValue();
1367 IndexExpr = Res.get();
1368 }
1369
1370 if (Index && FullySubstituted) {
1371 if (*Index < 0 || *Index >= int64_t(ExpandedExprs.size())) {
1372 Diag(PackExpression->getBeginLoc(), diag::err_pack_index_out_of_bound)
1373 << *Index << PackExpression << ExpandedExprs.size();
1375 }
1376 }
1377
1379 PackExpression, IndexExpr, Index,
1380 ExpandedExprs, FullySubstituted);
1381}
1382
1388 switch (Argument.getKind()) {
1390
1391
1393 if (!ExpansionTSInfo)
1394 ExpansionTSInfo = Context.getTrivialTypeSourceInfo(Argument.getAsType(),
1395 Ellipsis);
1399
1401 NumExpansions = Expansion.getTypePtr()->getNumExpansions();
1402
1403
1404
1405
1411 PatternTSInfo);
1412 }
1413
1422 }
1423
1430
1439 }
1440
1441 llvm_unreachable("Invalid TemplateArgument Kind!");
1442}
1443
1446
1447
1448
1449
1450
1451
1453 switch (Arg.getKind()) {
1455 if (auto *Subst = Arg.getAsType()->getAs())
1456 Pack = Subst->getArgumentPack();
1457 else
1458 return std::nullopt;
1459 break;
1460
1462 if (auto *Subst =
1463 dyn_cast(Arg.getAsExpr()))
1464 Pack = Subst->getArgumentPack();
1465 else if (auto *Subst = dyn_cast(Arg.getAsExpr())) {
1467 if (PD->isParameterPack())
1468 return std::nullopt;
1469 return Subst->getNumExpansions();
1470 } else
1471 return std::nullopt;
1472 break;
1473
1477 Pack = Subst->getArgumentPack();
1478 else
1479 return std::nullopt;
1480 break;
1481
1489 return std::nullopt;
1490 }
1491
1492
1494
1495
1496 if (Elem.isPackExpansion())
1497 return std::nullopt;
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507 if (Elem.containsUnexpandedParameterPack())
1508 return std::nullopt;
1509 }
1511}
1512
1514 if (!E)
1515 return;
1516
1518 auto *OCE = dyn_cast(E);
1521 S.Diag(E->getExprLoc(), diag::err_fold_expression_bad_operand)
1525 ")");
1526 }
1527}
1528
1533
1534
1537
1538
1539
1540
1541
1542 if (LHS && RHS &&
1545 return Diag(EllipsisLoc,
1547 ? diag::err_fold_expression_packs_both_sides
1548 : diag::err_pack_expansion_without_parameter_packs)
1550 }
1551
1552
1553
1554
1555 if (!LHS || !RHS) {
1556 Expr *Pack = LHS ? LHS : RHS;
1557 assert(Pack && "fold expression with neither LHS nor RHS");
1559 return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
1561 }
1562 }
1563
1565
1566
1568 {
1570 LookupBinOp(S, EllipsisLoc, Opc, Functions);
1571 if (!Functions.empty()) {
1577 if (Callee.isInvalid())
1580 }
1581 }
1582
1583 return BuildCXXFoldExpr(ULE, LParenLoc, LHS, Opc, EllipsisLoc, RHS, RParenLoc,
1584 std::nullopt);
1585}
1586
1595 EllipsisLoc, RHS, RParenLoc, NumExpansions);
1596}
1597
1600
1601
1602
1603
1604
1605
1606
1607
1608
1610 switch (Operator) {
1611 case BO_LOr:
1613 case BO_LAnd:
1615 case BO_Comma:
1616 ScalarType = Context.VoidTy;
1617 break;
1618
1619 default:
1620 return Diag(EllipsisLoc, diag::err_fold_expression_empty)
1622 }
1623
1625 ScalarType, Context.getTrivialTypeSourceInfo(ScalarType, EllipsisLoc),
1626 EllipsisLoc);
1627}
static void CheckFoldOperand(Sema &S, Expr *E)
Definition SemaTemplateVariadic.cpp:1513
static bool isParameterPack(Expr *PackExpression)
Definition SemaTemplateVariadic.cpp:1322
Defines the clang::TypeLoc interface and its subclasses.
bool isPackExpansion() const
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
StringRef getOpcodeStr() const
Represents a folding of a pack over an operator.
An expression "T()" which creates an rvalue of a non-class type T.
Represents a C++ nested-name-specifier or a global scope specifier.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
SourceRange getRange() const
SourceLocation getBeginLoc() const
NestedNameSpecifier getScopeRep() const
Retrieve the representation of the nested-name-specifier.
const TypeClass * getTypePtr() const
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
SourceLocation getLocation() const
Captures information about "declaration specifiers".
TST getTypeSpecType() const
ParsedType getRepAsType() const
Expr * getRepAsExpr() const
Decl - This represents one declaration (or definition), e.g.
bool isParameterPack() const
Whether this declaration is a parameter pack.
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack.
The name of a declaration.
@ CXXConversionFunctionName
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function),...
NameKind getNameKind() const
Determine what kind of name this is.
Information about one declarator, including the parsed type information and the identifier.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Expr * getTrailingRequiresClause()
Sets a trailing requires clause for this declarator.
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
virtual bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc)
virtual bool TraverseConstructorInitializer(MaybeConst< CXXCtorInitializer > *Init)
virtual bool TraverseDecl(MaybeConst< Decl > *D)
virtual bool TraverseTypeLoc(TypeLoc TL, bool TraverseQualifier=true)
virtual bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &Base)
virtual bool TraverseStmt(MaybeConst< Stmt > *S)
virtual bool TraverseAttr(MaybeConst< Attr > *At)
virtual bool TraverseLambdaCapture(MaybeConst< LambdaExpr > *LE, const LambdaCapture *C, MaybeConst< Expr > *Init)
virtual bool TraverseTemplateName(TemplateName Template)
virtual bool TraverseType(QualType T, bool TraverseQualifier=true)
virtual bool TraverseTemplateArgument(const TemplateArgument &Arg)
This represents one expression.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates).
bool containsErrors() const
Whether this expression contains subexpressions which had errors.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
Represents a reference to a function parameter pack, init-capture pack, or binding pack that has been...
unsigned getNumExpansions() const
Get the number of parameters in this parameter pack.
One of these records is kept for each identifier that is lexed.
A simple pair of identifier info and location.
SourceLocation getLoc() const
IdentifierInfo * getIdentifierInfo() const
const TypeClass * getTypePtr() const
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it,...
SmallVector< ValueDecl *, 4 > DeclArgumentPack
A set of declarations.
Represents the results of name lookup.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
LookupResultKind getResultKind() const
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
Data structure that captures multiple levels of template argument lists for use in template instantia...
bool hasTemplateArgument(unsigned Depth, unsigned Index) const
Determine whether there is a non-NULL template argument at the given depth and index.
unsigned getNumLevels() const
Determine the number of levels in this template argument list.
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
A C++ nested-name-specifier augmented with source location information.
bool containsUnexpandedParameterPack() const
Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic template...
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
decls_iterator decls_begin() const
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
Represents a C++11 pack expansion that produces a sequence of expressions.
Expr * getPattern()
Retrieve the pattern of the pack expansion.
UnsignedOrNone getNumExpansions() const
Determine the number of expansions that will be produced when this pack expansion is instantiated,...
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
void setEllipsisLoc(SourceLocation Loc)
SourceLocation getEllipsisLoc() const
TypeLoc getPatternLoc() const
Expr * getIndexExpr() 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)
Expr * getIndexExpr() const
Represents a parameter to a function.
Represents the parsed form of a C++ template argument.
KindType getKind() const
Determine what kind of template argument we have.
ParsedTemplateTy getAsTemplate() const
Retrieve the template template argument's template name.
ParsedTemplateArgument getTemplatePackExpansion(SourceLocation EllipsisLoc) const
Retrieve a pack expansion of the given template template argument.
ParsedType getAsType() const
Retrieve the template type argument's type.
@ Type
A template type parameter, stored as a type.
@ Template
A template template argument, stored as a template name.
@ NonType
A non-type template parameter, stored as an expression.
bool isInvalid() const
Determine whether the given template argument is invalid.
Expr * getAsExpr() const
Retrieve the non-type template argument's expression.
SourceLocation getNameLoc() const
Retrieve the location of the template argument.
const CXXScopeSpec & getScopeSpec() const
Retrieve the nested-name-specifier that precedes the template name in a template template argument.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
SourceLocation getBeginLoc() const LLVM_READONLY
ArrayRef< ParmVarDecl * > getLocalParameters() const
Scope - A scope is a transient data structure that is used while parsing the program.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Sema - This implements semantic analysis and AST building for C.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
sema::CapturingScopeInfo * getEnclosingLambdaOrBlock() const
Get the innermost lambda or block enclosing the current location, if any.
bool containsUnexpandedParameterPacks(Declarator &D)
Determine whether the given declarator contains any unexpanded parameter packs.
Definition SemaTemplateVariadic.cpp:1136
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs, bool FailOnPackProducingTemplates, bool &ShouldExpand, bool &RetainExpansion, UnsignedOrNone &NumExpansions, bool Diagnose=true)
Determine whether we could expand a pack expansion with the given set of parameter packs into separat...
Definition SemaTemplateVariadic.cpp:842
ExprResult BuildPackIndexingExpr(Expr *PackExpression, SourceLocation EllipsisLoc, Expr *IndexExpr, SourceLocation RSquareLoc, ArrayRef< Expr * > ExpandedExprs={}, bool FullySubstituted=false)
Definition SemaTemplateVariadic.cpp:1351
ASTContext & getASTContext() const
bool DiagnoseUnexpandedParameterPackInRequiresExpr(RequiresExpr *RE)
If the given requirees-expression contains an unexpanded reference to one of its own parameter packs,...
Definition SemaTemplateVariadic.cpp:565
void LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, UnresolvedSetImpl &Functions)
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, UnsignedOrNone NumExpansions)
Definition SemaTemplateVariadic.cpp:1587
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
UnexpandedParameterPackContext
The context in which an unexpanded parameter pack is being diagnosed.
const LangOptions & getLangOpts() const
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
bool isUnexpandedParameterPackPermitted()
Determine whether an unexpanded parameter pack might be permitted in this location.
Definition SemaTemplateVariadic.cpp:424
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
Definition SemaTemplateVariadic.cpp:667
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
Definition SemaTemplateVariadic.cpp:524
ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnCXXBoolLiteral - Parse {true,false} literals.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
UnsignedOrNone getNumArgumentsInExpansion(QualType T, const MultiLevelTemplateArgumentList &TemplateArgs)
Determine the number of arguments in the given pack expansion type.
Definition SemaTemplateVariadic.cpp:1128
ParsedTemplateArgument ActOnTemplateTemplateArgument(const ParsedTemplateArgument &Arg)
Invoked when parsing a template argument.
Definition SemaTemplateVariadic.cpp:709
ExprResult ActOnPackIndexingExpr(Scope *S, Expr *PackExpression, SourceLocation EllipsisLoc, SourceLocation LSquareLoc, Expr *IndexExpr, SourceLocation RSquareLoc)
Definition SemaTemplateVariadic.cpp:1330
ExprResult CreateUnresolvedLookupExpr(CXXRecordDecl *NamingClass, NestedNameSpecifierLoc NNSLoc, DeclarationNameInfo DNI, const UnresolvedSetImpl &Fns, bool PerformADL=true)
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion.
Definition SemaTemplateVariadic.cpp:726
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
UnsignedOrNone getFullyPackExpandedSize(TemplateArgument Arg)
Given a template argument that contains an unexpanded parameter pack, but which has already been subs...
Definition SemaTemplateVariadic.cpp:1444
void DiagnoseAmbiguousLookup(LookupResult &Result)
Produce a diagnostic describing the ambiguity that resulted from name lookup.
ExprResult ActOnSizeofParameterPackExpr(Scope *S, SourceLocation OpLoc, IdentifierInfo &Name, SourceLocation NameLoc, SourceLocation RParenLoc)
Called when an expression computing the size of a parameter pack is parsed.
Definition SemaTemplateVariadic.cpp:1273
ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
Definition SemaTemplateVariadic.cpp:1598
void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc)
ExprResult ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS, tok::TokenKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc)
Handle a C++1z fold-expression: ( expr op ... op expr ).
Definition SemaTemplateVariadic.cpp:1529
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
UnsignedOrNone getNumArgumentsInExpansionFromUnexpanded(llvm::ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs)
Definition SemaTemplateVariadic.cpp:1063
bool DiagnoseUnexpandedParameterPacks(SourceLocation Loc, UnexpandedParameterPackContext UPPC, ArrayRef< UnexpandedParameterPack > Unexpanded)
Diagnose unexpanded parameter packs.
Definition SemaTemplateVariadic.cpp:434
TemplateArgumentLoc getTemplateArgumentPackExpansionPattern(TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis, UnsignedOrNone &NumExpansions) const
Returns the pattern of the pack expansion for a template argument.
Definition SemaTemplateVariadic.cpp:1383
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
Definition SemaTemplateVariadic.cpp:780
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs={})
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.
void setBegin(SourceLocation b)
SourceLocation getBegin() const
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
A structure for storing an already-substituted template template parameter pack.
Location wrapper for a TemplateArgument.
SourceLocation getLocation() const
SourceLocation getTemplateEllipsisLoc() const
const TemplateArgument & getArgument() const
SourceLocation getTemplateNameLoc() const
SourceLocation getTemplateKWLoc() const
TypeSourceInfo * getTypeSourceInfo() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Represents a template argument.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
UnsignedOrNone getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce,...
QualType getAsType() const
Retrieve the type for a type template argument.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
bool containsUnexpandedParameterPack() const
Whether this template argument contains an unexpanded parameter pack.
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
bool isNull() const
Determine whether this template argument has no value.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
bool isCanonicalExpr() const
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
bool containsUnexpandedParameterPack() const
Determines whether this template name contains an unexpanded parameter pack (for C++0x variadic templ...
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
QualType getType() const
Get the type for which this source info wrapper provides information.
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
SourceLocation getNameLoc() const
The base class of the type hierarchy.
const T * castAs() const
Member-template castAs.
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
const T * getAs() const
Member-template getAs'.
Simple class containing the result of Sema::CorrectTypo.
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
SourceLocation getBeginLoc() const LLVM_READONLY
A set of unresolved declarations.
bool isPackExpansion() const
Determine whether this is a pack expansion.
bool isPackExpansion() const
Determine whether this is a pack expansion.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
bool isParameterPack() const
Determine whether this value is actually a function parameter pack, init-capture pack,...
Contains information about the compound statement currently being parsed.
Retains information about a function, method, or block that is currently being parsed.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
@ TST_typename_pack_indexing
bool isa(CodeGen::Address addr)
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
@ NotFound
No entity found met the criteria.
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
@ Found
Name lookup found a single declaration that met the criteria.
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl *, const TemplateSpecializationType *, const SubstBuiltinTemplatePackType * >, SourceLocation > UnexpandedParameterPack
bool isPackProducingBuiltinTemplateName(TemplateName N)
@ Result
The result type of a method or function.
ActionResult< ParsedType > TypeResult
std::pair< unsigned, unsigned > getDepthAndIndex(const NamedDecl *ND)
Retrieve the depth and index of a template parameter.
const FunctionProtoType * T
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
@ Template
We are parsing a template declaration.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
DynamicRecursiveASTVisitorBase< false > DynamicRecursiveASTVisitor
U cast(CodeGen::Address addr)
@ ArrayBound
Array bound in array declarator or new-expression.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
ActionResult< Expr * > ExprResult
@ EST_Dynamic
throw(T1, T2)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
TypeSourceInfo * getNamedTypeInfo() const
getNamedTypeInfo - Returns the source type info associated to the name.
Expr * NumElts
This is the size of the array, or null if [] or [*] was specified.
bool hasTrailingReturnType() const
Determine whether this function declarator had a trailing-return-type.
TypeAndRange * Exceptions
Pointer to a new[]'d array of TypeAndRange objects that contain the types in the function's dynamic e...
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
ParsedType getTrailingReturnType() const
Get the trailing-return-type for this function declarator.
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
unsigned getNumExceptions() const
Get the number of dynamic exception specifications.
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
One instance of this struct is used for each type in a declarator that is parsed.
MemberPointerTypeInfo Mem
enum clang::DeclaratorChunk::@340323374315200305336204205154073066142310370142 Kind
Expr * Value
The value of the dictionary element.
bool isPackExpansion() const
Determines whether this dictionary element is a pack expansion.
Expr * Key
The key for the dictionary element.