clang: lib/Sema/DeclSpec.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
25#include
26using namespace clang;
27
28
30 assert(TemplateId && "NULL template-id annotation?");
32 "should not convert invalid template-ids to unqualified-ids");
33
38}
39
41 assert(TemplateId && "NULL template-id annotation?");
43 "should not convert invalid template-ids to unqualified-ids");
44
49}
50
53 Builder.Extend(Context, TemplateKWLoc, TL, ColonColonLoc);
56 Range.setEnd(ColonColonLoc);
57
59 "NestedNameSpecifierLoc range computation incorrect");
60}
61
66
69 Range.setEnd(ColonColonLoc);
70
72 "NestedNameSpecifierLoc range computation incorrect");
73}
74
78 Builder.Extend(Context, Namespace, NamespaceLoc, ColonColonLoc);
79
82 Range.setEnd(ColonColonLoc);
83
85 "NestedNameSpecifierLoc range computation incorrect");
86}
87
91 Builder.Extend(Context, Alias, AliasLoc, ColonColonLoc);
92
95 Range.setEnd(ColonColonLoc);
96
98 "NestedNameSpecifierLoc range computation incorrect");
99}
100
103 Builder.MakeGlobal(Context, ColonColonLoc);
104
106
108 "NestedNameSpecifierLoc range computation incorrect");
109}
110
114 Builder.MakeSuper(Context, RD, SuperLoc, ColonColonLoc);
115
117 Range.setEnd(ColonColonLoc);
118
120 "NestedNameSpecifierLoc range computation incorrect");
121}
122
125 Builder.MakeTrivial(Context, Qualifier, R);
126 Range = R;
127}
128
133 return;
134 }
135
136 Range = Other.getSourceRange();
139 "NestedNameSpecifierLoc range computation incorrect");
140}
141
146}
147
152
154}
155
156
157
159 bool isAmbiguous,
162 unsigned NumParams,
165 bool RefQualifierIsLvalueRef,
169 ESpecType,
173 unsigned NumExceptions,
174 Expr *NoexceptExpr,
177 DeclsInPrototype,
183 TrailingReturnTypeLoc,
184 DeclSpec *MethodQualifiers) {
186 "function cannot have _Atomic qualifier");
187
190 I.Loc = LocalRangeBegin;
191 I.EndLoc = LocalRangeEnd;
217
218 if (MethodQualifiers && (MethodQualifiers->getTypeQualifiers() ||
225 });
228 }
229
231
232
233 if (NumParams) {
234
235
236
237
238 if (!TheDeclarator.InlineStorageUsed &&
239 NumParams <= std::size(TheDeclarator.InlineParams)) {
243 TheDeclarator.InlineStorageUsed = true;
244 } else {
247 }
248 for (unsigned i = 0; i < NumParams; i++)
249 I.Fun.Params[i] = std::move(Params[i]);
250 }
251
252
253 switch (ESpecType) {
254 default: break;
256
257 if (NumExceptions) {
260 for (unsigned i = 0; i != NumExceptions; ++i) {
263 }
264 }
265 break;
266
271 break;
272
275 break;
276 }
277
278 if (!DeclsInPrototype.empty()) {
279 assert(ESpecType == EST_None && NumExceptions == 0 &&
280 "cannot have exception specifiers and decls in prototype");
282
284 for (size_t J = 0; J < DeclsInPrototype.size(); ++J)
286 }
287
288 return I;
289}
290
295 assert(() && "declarator given multiple names!");
296
297 BindingGroup.LSquareLoc = LSquareLoc;
298 BindingGroup.RSquareLoc = RSquareLoc;
299 BindingGroup.NumBindings = Bindings.size();
300 Range.setEnd(RSquareLoc);
301
302
305
306
310 BindingGroup.DeleteBindings = false;
311 InlineStorageUsed = true;
312 } else {
313 BindingGroup.Bindings =
315 BindingGroup.DeleteBindings = true;
316 }
318 BindingGroup.Bindings);
319 }
320}
321
323 for (unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) {
324 switch (DeclTypeInfo[i].Kind) {
326 return true;
328 continue;
335 return false;
336 }
337 llvm_unreachable("Invalid type chunk");
338 }
339
375#define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t:
376#include "clang/Basic/OpenCLImageTypes.def"
377#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case TST_##Name:
378#include "clang/Basic/HLSLIntangibleTypes.def"
379 return false;
380
382
383
384 return false;
385
391 return false;
392
393#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case TST_##Trait:
394#include "clang/Basic/TransformTypeTraits.def"
400 return false;
401
402 if (const LocInfoType *LIT = dyn_cast(QT))
403 QT = LIT->getType();
404
406 return false;
407
409 }
410 }
411
412 llvm_unreachable("Invalid TypeSpecType!");
413}
414
421 getName().OperatorFunctionId.Operator));
422}
423
426 return false;
429 auto *P = dyn_cast_or_null(Fun.Params[0].Param);
430 if (P && P->isExplicitObjectParameter())
431 return true;
432 }
433 return false;
434}
435
439}
440
442 llvm::function_ref<void(TQ, StringRef, SourceLocation)> Handle) {
443 if (TypeQualifiers & TQ_const)
444 Handle(TQ_const, "const", TQ_constLoc);
446 Handle(TQ_volatile, "volatile", TQ_volatileLoc);
448 Handle(TQ_restrict, "restrict", TQ_restrictLoc);
450 Handle(TQ_unaligned, "unaligned", TQ_unalignedLoc);
451}
452
454 llvm::function_ref<void(TQ, StringRef, SourceLocation)> Handle) {
456
457}
458
460 if (!TypeSpecOwned)
461 return false;
462 return cast(getRepAsDecl())->isCompleteDefinition();
463}
464
465
466
467
469 unsigned Res = 0;
473
476
479
481 FS_noreturn_specified || FS_forceinline_specified)
483 return Res;
484}
485
487 const char *&PrevSpec,
488 unsigned &DiagID,
489 bool IsExtension = true) {
491 if (TNew != TPrev)
492 DiagID = diag::err_invalid_decl_spec_combination;
493 else
494 DiagID = IsExtension ? diag::ext_warn_duplicate_declspec :
495 diag::warn_duplicate_declspec;
496 return true;
497}
498
500 switch (S) {
509 }
510 llvm_unreachable("Unknown typespec!");
511}
512
514 switch (S) {
519 }
520 llvm_unreachable("Unknown typespec!");
521}
522
524 switch (W) {
526 return "unspecified";
528 return "short";
530 return "long";
532 return "long long";
533 }
534 llvm_unreachable("Unknown typespec!");
535}
536
538 switch (C) {
542 }
543 llvm_unreachable("Unknown typespec!");
544}
545
547 switch (S) {
549 return "unspecified";
551 return "signed";
553 return "unsigned";
554 }
555 llvm_unreachable("Unknown typespec!");
556}
557
560 switch (T) {
590 return "type-name-pack-indexing";
599#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
600 case DeclSpec::TST_##Trait: \
601 return "__" #Trait;
602#include "clang/Basic/TransformTypeTraits.def"
606#define GENERIC_IMAGE_TYPE(ImgType, Id) \
607 case DeclSpec::TST_##ImgType##_t: \
608 return #ImgType "_t";
609#include "clang/Basic/OpenCLImageTypes.def"
610#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
611 case DeclSpec::TST_##Name: \
612 return #Name;
613#include "clang/Basic/HLSLIntangibleTypes.def"
615 }
616 llvm_unreachable("Unknown typespec!");
617}
618
620 switch (C) {
622 return "unspecified";
624 return "constexpr";
626 return "consteval";
628 return "constinit";
629 }
630 llvm_unreachable("Unknown ConstexprSpecKind");
631}
632
634 switch (T) {
641 }
642 llvm_unreachable("Unknown typespec!");
643}
644
646 const char *&PrevSpec,
647 unsigned &DiagID,
649
650
651
652
653
654
655
658 "cl_clang_storage_class_specifiers", S.getLangOpts())) {
659 switch (SC) {
664 DiagID = diag::err_opencl_unknown_type_specifier;
666 return true;
667 }
668 break;
671 DiagID = diag::err_opencl_unknown_type_specifier;
673 return true;
674 default:
675 break;
676 }
677 }
678
680
685 if (StorageClassSpec == SCS_auto) {
687 PrevSpec, DiagID, Policy);
688 assert( && "auto SCS -> TST recovery failed");
689 }
690 }
691
692
693
694
696 !(SCS_extern_in_linkage_spec &&
699 return BadSpecifier(SC, (SCS)StorageClassSpec, PrevSpec, DiagID);
700 }
701 StorageClassSpec = SC;
702 StorageClassSpecLoc = Loc;
703 assert((unsigned)SC == StorageClassSpec && "SCS constants overflow bitfield");
704 return false;
705}
706
708 const char *&PrevSpec,
709 unsigned &DiagID) {
711 return BadSpecifier(TSC, (TSCS)ThreadStorageClassSpec, PrevSpec, DiagID);
712
713 ThreadStorageClassSpec = TSC;
714 ThreadStorageClassSpecLoc = Loc;
715 return false;
716}
717
718
719
720
722 const char *&PrevSpec, unsigned &DiagID,
724
725
728
732 TypeSpecWidth = static_cast<unsigned>(W);
733
735 return false;
736}
737
739 const char *&PrevSpec,
740 unsigned &DiagID) {
742 return BadSpecifier(C, (TSC)TypeSpecComplex, PrevSpec, DiagID);
743 TypeSpecComplex = C;
744 TSCLoc = Loc;
745 return false;
746}
747
749 const char *&PrevSpec, unsigned &DiagID) {
752 TypeSpecSign = static_cast<unsigned>(S);
753 TSSLoc = Loc;
754 return false;
755}
756
758 const char *&PrevSpec,
759 unsigned &DiagID,
763}
764
767 const char *&PrevSpec,
768 unsigned &DiagID,
771 assert(isTypeRep(T) && "T does not store a type");
772 assert(Rep && "no type provided!");
774 return false;
777 DiagID = diag::err_invalid_decl_spec_combination;
778 return true;
779 }
780 TypeSpecType = T;
782 TSTLoc = TagKwLoc;
783 TSTNameLoc = TagNameLoc;
784 TypeSpecOwned = false;
785
787
788
793 }
794 return false;
795}
796
798 const char *&PrevSpec,
799 unsigned &DiagID,
802 assert(isExprRep(T) && "T does not store an expr");
803 assert(Rep && "no expression provided!");
805 return false;
808 DiagID = diag::err_invalid_decl_spec_combination;
809 return true;
810 }
811 TypeSpecType = T;
813 TSTLoc = Loc;
814 TSTNameLoc = Loc;
815 TypeSpecOwned = false;
816 return false;
817}
818
820 const char *&PrevSpec,
821 unsigned &DiagID,
822 Decl *Rep, bool Owned,
825}
826
829 const char *&PrevSpec,
830 unsigned &DiagID,
831 Decl *Rep, bool Owned,
833 assert(isDeclRep(T) && "T does not store a decl");
834
835
837 return false;
840 DiagID = diag::err_invalid_decl_spec_combination;
841 return true;
842 }
843 TypeSpecType = T;
845 TSTLoc = TagKwLoc;
846 TSTNameLoc = TagNameLoc;
847 TypeSpecOwned = Owned && Rep != nullptr;
848 return false;
849}
850
855 ConstrainedAuto = true;
858}
859
861 const char *&PrevSpec,
862 unsigned &DiagID,
865 "rep required for these type-spec kinds!");
867 return false;
870 DiagID = diag::err_invalid_decl_spec_combination;
871 return true;
872 }
873 TSTLoc = Loc;
874 TSTNameLoc = Loc;
875 if (TypeAltiVecVector && (T == TST_bool) && !TypeAltiVecBool) {
876 TypeAltiVecBool = true;
877 return false;
878 }
879 TypeSpecType = T;
880 TypeSpecOwned = false;
881 return false;
882}
883
885 unsigned &DiagID) {
886
887 if (TypeSpecSat) {
888 DiagID = diag::warn_duplicate_declspec;
889 PrevSpec = "_Sat";
890 return true;
891 }
892 TypeSpecSat = true;
893 TSSatLoc = Loc;
894 return false;
895}
896
898 const char *&PrevSpec, unsigned &DiagID,
901 return false;
904 DiagID = diag::err_invalid_vector_decl_spec_combination;
905 return true;
906 }
907 TypeAltiVecVector = isAltiVecVector;
908 AltiVecLoc = Loc;
909 return false;
910}
911
913 const char *&PrevSpec, unsigned &DiagID,
916 return false;
919 DiagID = diag::err_invalid_decl_spec_combination;
920 return true;
921 }
922
923 if (isPipe) {
925 }
926 return false;
927}
928
930 const char *&PrevSpec, unsigned &DiagID,
933 return false;
934 if (!TypeAltiVecVector || TypeAltiVecPixel ||
937 DiagID = diag::err_invalid_pixel_decl_spec_combination;
938 return true;
939 }
940 TypeAltiVecPixel = isAltiVecPixel;
941 TSTLoc = Loc;
942 TSTNameLoc = Loc;
943 return false;
944}
945
947 const char *&PrevSpec, unsigned &DiagID,
950 return false;
951 if (!TypeAltiVecVector || TypeAltiVecBool ||
954 DiagID = diag::err_invalid_vector_bool_decl_spec;
955 return true;
956 }
957 TypeAltiVecBool = isAltiVecBool;
958 TSTLoc = Loc;
959 TSTNameLoc = Loc;
960 return false;
961}
962
965 TypeSpecOwned = false;
968 return false;
969}
970
972 const char *&PrevSpec, unsigned &DiagID,
974 assert(BitsExpr && "no expression provided!");
976 return false;
977
980 DiagID = diag::err_invalid_decl_spec_combination;
981 return true;
982 }
983
986 TSTLoc = KWLoc;
987 TSTNameLoc = KWLoc;
988 TypeSpecOwned = false;
989 return false;
990}
991
993 Expr *IndexingExpr) {
995 "pack indexing can only be applied to typename");
998 this->EllipsisLoc = EllipsisLoc;
999}
1000
1002 unsigned &DiagID, const LangOptions &Lang) {
1003
1004
1005
1006
1007 if (TypeQualifiers & T) {
1008 bool IsExtension = true;
1009 if (Lang.C99)
1010 IsExtension = false;
1011 return BadSpecifier(T, T, PrevSpec, DiagID, IsExtension);
1012 }
1013
1015}
1016
1018 TypeQualifiers |= T;
1019
1020 switch (T) {
1022 case TQ_const: TQ_constLoc = Loc; return false;
1023 case TQ_restrict: TQ_restrictLoc = Loc; return false;
1024 case TQ_volatile: TQ_volatileLoc = Loc; return false;
1026 case TQ_atomic: TQ_atomicLoc = Loc; return false;
1027 }
1028
1029 llvm_unreachable("Unknown type qualifier!");
1030}
1031
1033 unsigned &DiagID) {
1034
1035
1036 if (FS_inline_specified) {
1037 DiagID = diag::warn_duplicate_declspec;
1038 PrevSpec = "inline";
1039 return true;
1040 }
1041 FS_inline_specified = true;
1042 FS_inlineLoc = Loc;
1043 return false;
1044}
1045
1047 unsigned &DiagID) {
1048 if (FS_forceinline_specified) {
1049 DiagID = diag::warn_duplicate_declspec;
1050 PrevSpec = "__forceinline";
1051 return true;
1052 }
1053 FS_forceinline_specified = true;
1054 FS_forceinlineLoc = Loc;
1055 return false;
1056}
1057
1059 const char *&PrevSpec,
1060 unsigned &DiagID) {
1061
1062
1063 if (FS_virtual_specified) {
1064 DiagID = diag::warn_duplicate_declspec;
1065 PrevSpec = "virtual";
1066 return true;
1067 }
1068 FS_virtual_specified = true;
1069 FS_virtualLoc = Loc;
1070 return false;
1071}
1072
1074 const char *&PrevSpec, unsigned &DiagID,
1077
1078
1080 DiagID = (ExplicitSpec.getExpr() || FS_explicit_specifier.getExpr())
1081 ? diag::err_duplicate_declspec
1082 : diag::ext_warn_duplicate_declspec;
1083 PrevSpec = "explicit";
1084 return true;
1085 }
1086 FS_explicit_specifier = ExplicitSpec;
1087 FS_explicitLoc = Loc;
1088 FS_explicitCloseParenLoc = CloseParenLoc;
1089 return false;
1090}
1091
1093 const char *&PrevSpec,
1094 unsigned &DiagID) {
1095
1096
1097 if (FS_noreturn_specified) {
1098 DiagID = diag::warn_duplicate_declspec;
1099 PrevSpec = "_Noreturn";
1100 return true;
1101 }
1102 FS_noreturn_specified = true;
1103 FS_noreturnLoc = Loc;
1104 return false;
1105}
1106
1108 unsigned &DiagID) {
1110 PrevSpec = "friend";
1111 DiagID = diag::warn_duplicate_declspec;
1112 return true;
1113 }
1114
1115 FriendSpecifiedFirst = isEmpty();
1116 FriendLoc = Loc;
1117 return false;
1118}
1119
1121 unsigned &DiagID) {
1123 PrevSpec = "__module_private__";
1124 DiagID = diag::ext_warn_duplicate_declspec;
1125 return true;
1126 }
1127
1128 ModulePrivateLoc = Loc;
1129 return false;
1130}
1131
1134 unsigned &DiagID) {
1137 DiagID);
1138 ConstexprSpecifier = static_cast<unsigned>(ConstexprKind);
1139 ConstexprLoc = Loc;
1140 return false;
1141}
1142
1143void DeclSpec::SaveWrittenBuiltinSpecs() {
1147
1149}
1150
1151
1152
1153
1155
1156 SaveWrittenBuiltinSpecs();
1157
1158
1159
1161 return;
1162
1163
1168 TypeAltiVecVector || TypeAltiVecPixel || TypeAltiVecBool ||
1169 TypeQualifiers)) {
1170 const unsigned NumLocs = 9;
1172 TSWRange.getBegin(), TSCLoc, TSSLoc,
1173 AltiVecLoc, TQ_constLoc, TQ_restrictLoc,
1174 TQ_volatileLoc, TQ_atomicLoc, TQ_unalignedLoc};
1177 for (unsigned I = 0; I != NumLocs; ++I) {
1178 if (ExtraLocs[I].isValid()) {
1181 FirstLoc))
1182 FirstLoc = ExtraLocs[I];
1184 }
1185 }
1189 TypeAltiVecVector = TypeAltiVecPixel = TypeAltiVecBool = false;
1190 TypeQualifiers = 0;
1191 S.Diag(TSTLoc, diag::err_decltype_auto_cannot_be_combined)
1192 << Hints[0] << Hints[1] << Hints[2] << Hints[3]
1193 << Hints[4] << Hints[5] << Hints[6] << Hints[7];
1194 }
1195
1196
1197 if (TypeAltiVecVector) {
1198
1202 S.Diag(TSWRange.getBegin(), diag::err_invalid_vector_long_long_decl_spec);
1203
1204
1208 S.Diag(TSTLoc, diag::err_invalid_vector_int128_decl_spec);
1209
1210
1212 S.Diag(TSCLoc, diag::err_invalid_vector_complex_decl_spec);
1213 else if (TypeAltiVecBool) {
1214
1216 S.Diag(TSSLoc, diag::err_invalid_vector_bool_decl_spec)
1218 }
1219
1220
1221
1224 TypeAltiVecPixel) {
1225 S.Diag(TSTLoc, diag::err_invalid_vector_bool_decl_spec)
1226 << (TypeAltiVecPixel ? "__pixel" :
1228 }
1229
1233 S.Diag(TSTLoc, diag::err_invalid_vector_bool_int128_decl_spec);
1234
1235
1239 S.Diag(TSWRange.getBegin(), diag::err_invalid_vector_bool_decl_spec)
1241
1242
1243 if ((TypeSpecType == TST_char) || (TypeSpecType == TST_int) ||
1247 } else if (TypeSpecType == TST_double) {
1248
1249
1253 diag::err_invalid_vector_long_double_decl_spec);
1256 S.Diag(TSTLoc, diag::err_invalid_vector_double_decl_spec);
1257 } else if (TypeSpecType == TST_float) {
1258
1259
1262 S.Diag(TSTLoc, diag::err_invalid_vector_float_decl_spec);
1264
1265
1266
1267
1268
1269
1270
1274 S.Diag(TSWRange.getBegin(), diag::err_invalid_vector_long_decl_spec);
1275 else
1277 diag::warn_vector_long_decl_spec_combination)
1279 }
1280
1281 if (TypeAltiVecPixel) {
1282
1286 TypeSpecOwned = false;
1287 }
1288 }
1289
1290 bool IsFixedPointType =
1292
1293
1296 TypeSpecType = TST_int;
1297 else if (TypeSpecType != TST_int && TypeSpecType != TST_int128 &&
1299 !IsFixedPointType && TypeSpecType != TST_bitint) {
1300 S.Diag(TSSLoc, diag::err_invalid_sign_spec)
1302
1304 }
1305 }
1306
1307
1310 break;
1314 TypeSpecType = TST_int;
1315 else if (!(TypeSpecType == TST_int ||
1316 (IsFixedPointType &&
1318 S.Diag(TSWRange.getBegin(), diag::err_invalid_width_spec)
1321 TypeSpecSat = false;
1322 TypeSpecOwned = false;
1323 }
1324 break;
1327 TypeSpecType = TST_int;
1328 else if (TypeSpecType != TST_int && TypeSpecType != TST_double &&
1329 !IsFixedPointType) {
1330 S.Diag(TSWRange.getBegin(), diag::err_invalid_width_spec)
1333 TypeSpecSat = false;
1334 TypeSpecOwned = false;
1335 }
1336 break;
1337 }
1338
1339
1340
1343 S.Diag(TSCLoc, diag::ext_plain_complex)
1346 " double");
1347 TypeSpecType = TST_double;
1348 } else if (TypeSpecType == TST_int || TypeSpecType == TST_char) {
1349
1351 S.Diag(TSTLoc, diag::ext_integer_complex);
1355
1356 S.Diag(TSCLoc, diag::err_invalid_complex_spec)
1359 }
1360 }
1361
1362
1363
1364
1366 switch (StorageClassSpec) {
1371 break;
1372 default:
1376 diag::err_invalid_decl_spec_combination)
1379 else
1381 diag::err_invalid_decl_spec_combination)
1384
1387 }
1390 S.Diag(ConstexprLoc, diag::err_invalid_decl_spec_combination)
1393 }
1394 }
1395
1399 S.Diag(ConstexprLoc, diag::err_invalid_decl_spec_combination)
1402 }
1403
1404
1405
1406
1407
1412 TSTLoc = TSTNameLoc = StorageClassSpecLoc;
1414 }
1415
1416
1419 S.Diag(TSTLoc, diag::ext_auto_type_specifier) << 0;
1423 S.Diag(TSTLoc, diag::ext_hlsl_auto_type_specifier) << 1;
1425 StorageClassSpec == SCS_auto)
1426 S.Diag(StorageClassSpecLoc, diag::warn_auto_storage_class)
1429 S.Diag(TSTLoc, diag::warn_cxx17_compat_unicode_type);
1431 S.Diag(TSTLoc, diag::warn_cxx98_compat_unicode_type)
1432 << (TypeSpecType == TST_char16 ? "char16_t" : "char32_t");
1434 S.Diag(ConstexprLoc, diag::warn_cxx98_compat_constexpr);
1436 S.Diag(ConstexprLoc, diag::warn_cxx20_compat_consteval);
1438 S.Diag(ConstexprLoc, diag::warn_cxx20_compat_constinit);
1439
1440
1441
1446 FixItHint StorageHint, ThreadHint;
1447
1452 }
1453
1455 if (!SpecName.empty()) SpecName += " ";
1459 }
1460
1461 S.Diag(SCLoc, diag::err_friend_decl_spec)
1462 << SpecName << StorageHint << ThreadHint;
1463
1465 }
1466
1467
1468
1469
1470
1471
1472
1473
1475 StringRef Keyword;
1478
1480 Keyword = "virtual";
1483 } else {
1484 Keyword = "explicit";
1487 }
1488
1489 S.Diag(SCLoc, diag::err_friend_decl_spec)
1490 << Keyword << Hint;
1491
1492 FS_virtual_specified = false;
1495 }
1496
1497 assert(!TypeSpecOwned || isDeclRep((TST) TypeSpecType));
1498
1499
1500
1501
1502
1503
1504}
1505
1510}
1511
1520 for (unsigned I = 0; I != 3; ++I) {
1522
1523 if (SymbolLocations[I].isValid())
1525 }
1526}
1527
1529 const char *&PrevSpec) {
1530 if (!FirstLocation.isValid())
1531 FirstLocation = Loc;
1532 LastLocation = Loc;
1533 LastSpecifier = VS;
1534
1535 if (Specifiers & VS) {
1537 return true;
1538 }
1539
1540 Specifiers |= VS;
1541
1542 switch (VS) {
1543 default: llvm_unreachable("Unknown specifier!");
1547 case VS_Final: VS_finalLoc = Loc; break;
1549 }
1550
1551 return false;
1552}
1553
1555 switch (VS) {
1556 default: llvm_unreachable("Unknown specifier");
1558 case VS_Final: return "final";
1560 case VS_Sealed: return "sealed";
1562 }
1563}
Defines the clang::ASTContext interface.
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
static bool BadSpecifier(T TNew, T TPrev, const char *&PrevSpec, unsigned &DiagID, bool IsExtension=true)
Defines the clang::LangOptions interface.
static bool isInvalid(LocType Loc, bool *Invalid)
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
Defines the clang::TypeLoc interface and its subclasses.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const TargetInfo & getTargetInfo() const
The result of parsing/analyzing an expression, statement etc.
void takeAllFrom(AttributePool &pool)
Take the given pool's allocations and add them to this pool.
static bool isStaticOverloadedOperator(OverloadedOperatorKind OOK)
Returns true if the given operator is implicitly static in a record context.
Represents a C++ struct/union/class.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
SourceLocation getLastQualifierNameLoc() const
Retrieve the location of the name in the last qualifier in this nested name specifier.
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'type...
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Captures information about "declaration specifiers".
bool isVirtualSpecified() const
bool setFunctionSpecExplicit(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, ExplicitSpecifier ExplicitSpec, SourceLocation CloseParenLoc)
bool isModulePrivateSpecified() const
static const TSCS TSCS___thread
static const TST TST_typeof_unqualType
bool SetTypePipe(bool isPipe, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
static const TST TST_typename
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec and return false if there was no error.
static const TST TST_char8
static const TST TST_BFloat16
void ClearStorageClassSpecs()
bool SetConstexprSpec(ConstexprSpecKind ConstexprKind, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
static const TSCS TSCS__Thread_local
bool SetTypeSpecWidth(TypeSpecifierWidth W, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec, but return true and ignore the request if ...
TST getTypeSpecType() const
SourceLocation getStorageClassSpecLoc() const
SCS getStorageClassSpec() const
bool setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
bool SetTypeSpecSat(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
void SetPackIndexingExpr(SourceLocation EllipsisLoc, Expr *Pack)
bool SetStorageClassSpecThread(TSCS TSC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
bool SetBitIntType(SourceLocation KWLoc, Expr *BitWidth, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
static const TST TST_auto_type
static const TST TST_interface
static const TST TST_double
static const TST TST_typeofExpr
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
bool SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
static const TST TST_union
static const TST TST_typename_pack_indexing
static const TST TST_char
static const TST TST_bool
static const TST TST_char16
SCS
storage-class-specifier
SourceLocation getExplicitSpecLoc() const
static const TST TST_unknown_anytype
void forEachCVRUQualifier(llvm::function_ref< void(TQ, StringRef, SourceLocation)> Handle)
This method calls the passed in handler on each CVRU qual being set.
bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
bool isMissingDeclaratorOk()
Checks if this DeclSpec can stand alone, without a Declarator.
ParsedType getRepAsType() const
TSCS getThreadStorageClassSpec() const
bool setFunctionSpecNoreturn(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
static const TST TST_accum
static const TST TST_half
ParsedAttributes & getAttributes()
SourceRange getExplicitSpecRange() const
static const TST TST_ibm128
Expr * getRepAsExpr() const
static const TST TST_enum
bool SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
AttributePool & getAttributePool() const
static const TST TST_float128
static const TST TST_decltype
static bool isDeclRep(TST T)
void Finish(Sema &S, const PrintingPolicy &Policy)
Finish - This does final analysis of the declspec, issuing diagnostics for things like "_Complex" (la...
static const TST TST_typeof_unqualExpr
static const TST TST_class
bool hasTagDefinition() const
static const TST TST_decimal64
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
bool SetTypeQual(TQ T, SourceLocation Loc)
static const TST TST_wchar
SourceLocation getTypeSpecComplexLoc() const
static const TST TST_void
static const TSCS TSCS_unspecified
static const TST TST_bitint
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
static const TST TST_float
static const TST TST_atomic
static const TST TST_fract
SourceLocation getThreadStorageClassSpecLoc() const
Decl * getRepAsDecl() const
static const TST TST_float16
static const TST TST_unspecified
SourceLocation getVirtualSpecLoc() const
TypeSpecifierSign getTypeSpecSign() const
bool isEmpty() const
isEmpty - Return true if this declaration specifier is completely empty: no tokens were parsed in the...
static const TST TST_decltype_auto
static const TSCS TSCS_thread_local
static const TST TST_error
void forEachQualifier(llvm::function_ref< void(TQ, StringRef, SourceLocation)> Handle)
This method calls the passed in handler on each qual being set.
bool setFunctionSpecVirtual(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
static const TST TST_decimal32
bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
TypeSpecifierWidth getTypeSpecWidth() const
static const TST TST_char32
bool setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
static const TST TST_decimal128
static const TST TST_int128
FriendSpecified isFriendSpecified() const
bool hasExplicitSpecifier() const
bool setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
static const TST TST_typeofType
TemplateIdAnnotation * TemplateIdRep
bool SetTypeSpecSign(TypeSpecifierSign S, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
static const TST TST_auto
@ PQ_StorageClassSpecifier
ConstexprSpecKind getConstexprSpecifier() const
static const TST TST_struct
Decl - This represents one declaration (or definition), e.g.
Information about one declarator, including the parsed type information and the identifier.
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
void SetIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
bool isFunctionDeclarator() const
isFunctionDeclarator - Once this declarator is fully parsed and formed, this method returns true if t...
void setDecompositionBindings(SourceLocation LSquareLoc, MutableArrayRef< DecompositionDeclarator::Binding > Bindings, SourceLocation RSquareLoc)
Set the decomposition bindings for this declarator.
DeclaratorChunk::ParamInfo InlineParams[16]
InlineParams - This is a local array used for the first function decl chunk to avoid going to the hea...
DeclaratorContext getContext() const
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
ArrayRef< TemplateParameterList * > getTemplateParameterLists() const
The template parameter lists that preceded the declarator.
bool isExplicitObjectMemberFunction()
bool isStaticMember()
Returns true if this declares a static member.
DecompositionDeclarator::Binding InlineBindings[16]
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
Store information needed for an explicit specifier.
const Expr * getExpr() const
This represents one expression.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
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.
One of these records is kept for each identifier that is lexed.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
Holds a QualType and a TypeSourceInfo* that came out of a declarator parsing.
This represents a decl that may have a name.
Represents a C++ namespace alias.
Represent a C++ namespace.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
void Clear()
Clear out this builder, and prepare it to build another nested-name-specifier with source-location in...
NestedNameSpecifierLoc getTemporary() const
Retrieve a nested-name-specifier with location information based on the information in this builder.
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covered by this nested-name-specifier.
NestedNameSpecifier * getRepresentation() const
Retrieve the representation of the nested-name-specifier.
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'type...
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
A C++ nested-name-specifier augmented with source location information.
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector::".
static OpaquePtr make(QualType P)
bool isAvailableOption(llvm::StringRef Ext, const LangOptions &LO) const
QualType getPattern() const
Expr * getIndexExpr() const
bool hasAttribute(ParsedAttr::Kind K) const
void takeAllFrom(ParsedAttributes &Other)
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
Sema - This implements semantic analysis and AST building for C.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
const LangOptions & getLangOpts() const
SourceManager & getSourceManager() const
OpenCLOptions & getOpenCLOptions()
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
A trivial tuple used to represent a source range.
void setBegin(SourceLocation b)
SourceLocation getEnd() const
SourceLocation getBegin() const
void setEnd(SourceLocation e)
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
Base wrapper for a particular "section" of type source info.
SourceLocation getBeginLoc() const
Get the begin source location.
bool isFunctionType() const
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
SourceLocation EndLocation
The location of the last token that describes this unqualified-id.
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
bool isValid() const
Determine whether this unqualified-id refers to a valid name.
void setTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id.
void setConstructorTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id that names a constructor.
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
static const char * getSpecifierName(Specifier VS)
bool SetSpecifier(Specifier VS, SourceLocation Loc, const char *&PrevSpec)
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.
TypeSpecifierType
Specifies the kind of type.
@ TST_typename_pack_indexing
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
ConstexprSpecKind
Define the kind of constexpr specifier.
@ IK_TemplateId
A template-id, e.g., f.
@ IK_ConstructorTemplateId
A constructor named via a template-id.
@ IK_ConstructorName
A constructor name.
@ IK_DestructorName
A destructor name.
@ IK_OperatorFunctionId
An overloaded operator name, e.g., operator+.
ThreadStorageClassSpecifier
Thread storage-class-specifier.
TypeSpecifierWidth
Specifies the width of a type, e.g., short, long, or long long.
TypeSpecifierSign
Specifies the signedness of a type, e.g., signed or unsigned.
const FunctionProtoType * T
@ Other
Other implicit parameter.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_DependentNoexcept
noexcept(expression), value-dependent
@ EST_Unparsed
not parsed yet
@ EST_None
no exception specification
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
@ EST_NoexceptTrue
noexcept(expression), evals to 'true'
@ EST_Dynamic
throw(T1, T2)
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)',...
CachedTokens * ExceptionSpecTokens
Pointer to the cached tokens for an exception-specification that has not yet been parsed.
SourceLocation MutableLoc
The location of the 'mutable' qualifer in a lambda-declarator, if any.
UnionParsedType TrailingReturnType
If HasTrailingReturnType is true, this is the trailing return type specified.
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...
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
NamedDecl ** DeclsInPrototype
Pointer to a new[]'d array of declarations that need to be available for lookup inside the function b...
AttributeFactory * QualAttrFactory
AttributeFactory for the MethodQualifiers.
SourceLocation ExceptionSpecLocEnd
The end location of the exception specification, if any.
SourceLocation EllipsisLoc
When isVariadic is true, the location of the ellipsis in the source.
unsigned DeleteParams
DeleteParams - If this is true, we need to delete[] Params.
DeclSpec * MethodQualifiers
DeclSpec for the function with the qualifier related info.
unsigned NumExceptionsOrDecls
NumExceptionsOrDecls - This is the number of types in the dynamic-exception-decl, if the function has...
SourceLocation RefQualifierLoc
The location of the ref-qualifier, if any.
SourceLocation RParenLoc
The location of the right parenthesis in the source.
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
unsigned HasTrailingReturnType
HasTrailingReturnType - If this is true, a trailing return type was specified.
unsigned isAmbiguous
Can this declaration be a constructor-style initializer?
unsigned hasPrototype
hasPrototype - This is true if the function had at least one typed parameter.
SourceLocation LParenLoc
The location of the left parenthesis in the source.
unsigned ExceptionSpecType
ExceptionSpecType - An ExceptionSpecificationType value.
SourceLocation ExceptionSpecLocBeg
The beginning location of the exception specification, if any.
SourceLocation TrailingReturnTypeLoc
If HasTrailingReturnType is true, this is the location of the trailing return type.
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed.
One instance of this struct is used for each type in a declarator that is parsed.
enum clang::DeclaratorChunk::@225 Kind
SourceLocation EndLoc
EndLoc - If valid, the place where this chunck ends.
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, ArrayRef< NamedDecl * > DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult(), SourceLocation TrailingReturnTypeLoc=SourceLocation(), DeclSpec *MethodQualifiers=nullptr)
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
SourceLocation Loc
Loc - The place where this type was defined.
Wraps an identifier and optional source location for the identifier.
Describes how types, statements, expressions, and declarations should be printed.
unsigned Bool
Whether we can use 'bool' rather than '_Bool' (even if the language doesn't actually have 'bool',...
unsigned MSWChar
When true, print the built-in wchar_t type as __wchar_t.
Information about a template-id annotation token.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
SourceLocation SymbolLocations[3]
The source locations of the individual tokens that name the operator, e.g., the "new",...
OverloadedOperatorKind Operator
The kind of overloaded operator.