@@ -311,7 +311,13 @@ class C2x<string namespace, string name, int version = 1>
311
311
string Namespace = namespace;
312
312
}
313
313
314
- class Keyword<string name> : Spelling<name, "Keyword">;
314
+ class Keyword<string name, bit hasOwnParseRules>
315
+ : Spelling<name, "Keyword"> {
316
+ bit HasOwnParseRules = hasOwnParseRules;
317
+ }
318
+ // A keyword that has its own individual parsing rules.
319
+ class CustomKeyword<string name> : Keyword<name, 1> {}
320
+
315
321
class Pragma<string namespace, string name> : Spelling<name, "Pragma"> {
316
322
string Namespace = namespace;
317
323
}
@@ -709,13 +715,13 @@ def ArmBuiltinAlias : InheritableAttr, TargetSpecificAttr<TargetAnyArm> {
709
715
}
710
716
711
717
def Aligned : InheritableAttr {
712
- let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword <"alignas">,
713
- Keyword <"_Alignas">];
718
+ let Spellings = [GCC<"aligned">, Declspec<"align">, CustomKeyword <"alignas">,
719
+ CustomKeyword <"_Alignas">];
714
720
let Args = [AlignedArgument<"Alignment", 1>];
715
721
let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
716
- Accessor<"isC11", [Keyword <"_Alignas">]>,
717
- Accessor<"isAlignas", [Keyword <"alignas">,
718
- Keyword <"_Alignas">]>,
722
+ Accessor<"isC11", [CustomKeyword <"_Alignas">]>,
723
+ Accessor<"isAlignas", [CustomKeyword <"alignas">,
724
+ CustomKeyword <"_Alignas">]>,
719
725
Accessor<"isDeclspec",[Declspec<"align">]>];
720
726
let Documentation = [Undocumented];
721
727
}
@@ -756,7 +762,7 @@ def AlignNatural : InheritableAttr {
756
762
757
763
def AlwaysInline : DeclOrStmtAttr {
758
764
let Spellings = [GCC<"always_inline">, CXX11<"clang", "always_inline">,
759
- C2x<"clang", "always_inline">, Keyword <"__forceinline">];
765
+ C2x<"clang", "always_inline">, CustomKeyword <"__forceinline">];
760
766
let Accessors = [Accessor<"isClangAlwaysInline", [CXX11<"clang", "always_inline">,
761
767
C2x<"clang", "always_inline">]>];
762
768
let Subjects = SubjectList<[Function, Stmt], WarnDiag,
@@ -879,7 +885,7 @@ def AVRSignal : InheritableAttr, TargetSpecificAttr<TargetAVR> {
879
885
}
880
886
881
887
def AsmLabel : InheritableAttr {
882
- let Spellings = [Keyword <"asm">, Keyword <"__asm__">];
888
+ let Spellings = [CustomKeyword <"asm">, CustomKeyword <"__asm__">];
883
889
let Args = [
884
890
// Label specifies the mangled name for the decl.
885
891
StringArgument<"Label">,
@@ -997,7 +1003,7 @@ def CarriesDependency : InheritableParamAttr {
997
1003
}
998
1004
999
1005
def CDecl : DeclOrTypeAttr {
1000
- let Spellings = [GCC<"cdecl">, Keyword <"__cdecl">, Keyword <"_cdecl">];
1006
+ let Spellings = [GCC<"cdecl">, CustomKeyword <"__cdecl">, CustomKeyword <"_cdecl">];
1001
1007
// let Subjects = [Function, ObjCMethod];
1002
1008
let Documentation = [Undocumented];
1003
1009
}
@@ -1122,10 +1128,10 @@ def Const : InheritableAttr {
1122
1128
def ConstInit : InheritableAttr {
1123
1129
// This attribute does not have a C [[]] spelling because it requires the
1124
1130
// CPlusPlus language option.
1125
- let Spellings = [Keyword <"constinit">,
1131
+ let Spellings = [CustomKeyword <"constinit">,
1126
1132
Clang<"require_constant_initialization", 0>];
1127
1133
let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
1128
- let Accessors = [Accessor<"isConstinit", [Keyword <"constinit">]>];
1134
+ let Accessors = [Accessor<"isConstinit", [CustomKeyword <"constinit">]>];
1129
1135
let Documentation = [ConstInitDocs];
1130
1136
let LangOpts = [CPlusPlus];
1131
1137
let SimpleHandler = 1;
@@ -1276,7 +1282,7 @@ def SYCLSpecialClass: InheritableAttr {
1276
1282
}
1277
1283
1278
1284
def C11NoReturn : InheritableAttr {
1279
- let Spellings = [Keyword <"_Noreturn">];
1285
+ let Spellings = [CustomKeyword <"_Noreturn">];
1280
1286
let Subjects = SubjectList<[Function], ErrorDiag>;
1281
1287
let SemaHandler = 0;
1282
1288
let Documentation = [C11NoReturnDocs];
@@ -1292,7 +1298,7 @@ def CXX11NoReturn : InheritableAttr {
1292
1298
// Similar to CUDA, OpenCL attributes do not receive a [[]] spelling because
1293
1299
// the specification does not expose them with one currently.
1294
1300
def OpenCLKernel : InheritableAttr {
1295
- let Spellings = [Keyword <"__kernel">, Keyword <"kernel">];
1301
+ let Spellings = [CustomKeyword <"__kernel">, CustomKeyword <"kernel">];
1296
1302
let Subjects = SubjectList<[Function], ErrorDiag>;
1297
1303
let Documentation = [Undocumented];
1298
1304
let SimpleHandler = 1;
@@ -1316,26 +1322,28 @@ def OpenCLIntelReqdSubGroupSize: InheritableAttr {
1316
1322
// This attribute is both a type attribute, and a declaration attribute (for
1317
1323
// parameter variables).
1318
1324
def OpenCLAccess : Attr {
1319
- let Spellings = [Keyword <"__read_only">, Keyword <"read_only">,
1320
- Keyword <"__write_only">, Keyword <"write_only">,
1321
- Keyword <"__read_write">, Keyword <"read_write">];
1325
+ let Spellings = [CustomKeyword <"__read_only">, CustomKeyword <"read_only">,
1326
+ CustomKeyword <"__write_only">, CustomKeyword <"write_only">,
1327
+ CustomKeyword <"__read_write">, CustomKeyword <"read_write">];
1322
1328
let Subjects = SubjectList<[ParmVar, TypedefName], ErrorDiag>;
1323
- let Accessors = [Accessor<"isReadOnly", [Keyword <"__read_only">,
1324
- Keyword <"read_only">]>,
1325
- Accessor<"isReadWrite", [Keyword <"__read_write">,
1326
- Keyword <"read_write">]>,
1327
- Accessor<"isWriteOnly", [Keyword <"__write_only">,
1328
- Keyword <"write_only">]>];
1329
+ let Accessors = [Accessor<"isReadOnly", [CustomKeyword <"__read_only">,
1330
+ CustomKeyword <"read_only">]>,
1331
+ Accessor<"isReadWrite", [CustomKeyword <"__read_write">,
1332
+ CustomKeyword <"read_write">]>,
1333
+ Accessor<"isWriteOnly", [CustomKeyword <"__write_only">,
1334
+ CustomKeyword <"write_only">]>];
1329
1335
let Documentation = [OpenCLAccessDocs];
1330
1336
}
1331
1337
1332
1338
def OpenCLPrivateAddressSpace : TypeAttr {
1333
- let Spellings = [Keyword<"__private">, Keyword<"private">, Clang<"opencl_private">];
1339
+ let Spellings = [CustomKeyword<"__private">, CustomKeyword<"private">,
1340
+ Clang<"opencl_private">];
1334
1341
let Documentation = [OpenCLAddressSpacePrivateDocs];
1335
1342
}
1336
1343
1337
1344
def OpenCLGlobalAddressSpace : TypeAttr {
1338
- let Spellings = [Keyword<"__global">, Keyword<"global">, Clang<"opencl_global">];
1345
+ let Spellings = [CustomKeyword<"__global">, CustomKeyword<"global">,
1346
+ Clang<"opencl_global">];
1339
1347
let Documentation = [OpenCLAddressSpaceGlobalDocs];
1340
1348
}
1341
1349
@@ -1350,17 +1358,20 @@ def OpenCLGlobalHostAddressSpace : TypeAttr {
1350
1358
}
1351
1359
1352
1360
def OpenCLLocalAddressSpace : TypeAttr {
1353
- let Spellings = [Keyword<"__local">, Keyword<"local">, Clang<"opencl_local">];
1361
+ let Spellings = [CustomKeyword<"__local">, CustomKeyword<"local">,
1362
+ Clang<"opencl_local">];
1354
1363
let Documentation = [OpenCLAddressSpaceLocalDocs];
1355
1364
}
1356
1365
1357
1366
def OpenCLConstantAddressSpace : TypeAttr {
1358
- let Spellings = [Keyword<"__constant">, Keyword<"constant">, Clang<"opencl_constant">];
1367
+ let Spellings = [CustomKeyword<"__constant">, CustomKeyword<"constant">,
1368
+ Clang<"opencl_constant">];
1359
1369
let Documentation = [OpenCLAddressSpaceConstantDocs];
1360
1370
}
1361
1371
1362
1372
def OpenCLGenericAddressSpace : TypeAttr {
1363
- let Spellings = [Keyword<"__generic">, Keyword<"generic">, Clang<"opencl_generic">];
1373
+ let Spellings = [CustomKeyword<"__generic">, CustomKeyword<"generic">,
1374
+ Clang<"opencl_generic">];
1364
1375
let Documentation = [OpenCLAddressSpaceGenericDocs];
1365
1376
}
1366
1377
@@ -1476,20 +1487,20 @@ def MustTail : StmtAttr {
1476
1487
}
1477
1488
1478
1489
def FastCall : DeclOrTypeAttr {
1479
- let Spellings = [GCC<"fastcall">, Keyword <"__fastcall">,
1480
- Keyword <"_fastcall">];
1490
+ let Spellings = [GCC<"fastcall">, CustomKeyword <"__fastcall">,
1491
+ CustomKeyword <"_fastcall">];
1481
1492
// let Subjects = [Function, ObjCMethod];
1482
1493
let Documentation = [FastCallDocs];
1483
1494
}
1484
1495
1485
1496
def RegCall : DeclOrTypeAttr {
1486
- let Spellings = [GCC<"regcall">, Keyword <"__regcall">];
1497
+ let Spellings = [GCC<"regcall">, CustomKeyword <"__regcall">];
1487
1498
let Documentation = [RegCallDocs];
1488
1499
}
1489
1500
1490
1501
def Final : InheritableAttr {
1491
- let Spellings = [Keyword <"final">, Keyword <"sealed">];
1492
- let Accessors = [Accessor<"isSpelledAsSealed", [Keyword <"sealed">]>];
1502
+ let Spellings = [CustomKeyword <"final">, CustomKeyword <"sealed">];
1503
+ let Accessors = [Accessor<"isSpelledAsSealed", [CustomKeyword <"sealed">]>];
1493
1504
let SemaHandler = 0;
1494
1505
// Omitted from docs, since this is language syntax, not an attribute, as far
1495
1506
// as users are concerned.
@@ -1835,7 +1846,7 @@ def Convergent : InheritableAttr {
1835
1846
}
1836
1847
1837
1848
def NoInline : DeclOrStmtAttr {
1838
- let Spellings = [Keyword <"__noinline__">, GCC<"noinline">,
1849
+ let Spellings = [CustomKeyword <"__noinline__">, GCC<"noinline">,
1839
1850
CXX11<"clang", "noinline">, C2x<"clang", "noinline">,
1840
1851
Declspec<"noinline">];
1841
1852
let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">,
@@ -2031,35 +2042,35 @@ def PassObjectSize : InheritableParamAttr {
2031
2042
2032
2043
// Nullability type attributes.
2033
2044
def TypeNonNull : TypeAttr {
2034
- let Spellings = [Keyword <"_Nonnull">];
2045
+ let Spellings = [CustomKeyword <"_Nonnull">];
2035
2046
let Documentation = [TypeNonNullDocs];
2036
2047
}
2037
2048
2038
2049
def TypeNullable : TypeAttr {
2039
- let Spellings = [Keyword <"_Nullable">];
2050
+ let Spellings = [CustomKeyword <"_Nullable">];
2040
2051
let Documentation = [TypeNullableDocs];
2041
2052
}
2042
2053
2043
2054
def TypeNullableResult : TypeAttr {
2044
- let Spellings = [Keyword <"_Nullable_result">];
2055
+ let Spellings = [CustomKeyword <"_Nullable_result">];
2045
2056
let Documentation = [TypeNullableResultDocs];
2046
2057
}
2047
2058
2048
2059
def TypeNullUnspecified : TypeAttr {
2049
- let Spellings = [Keyword <"_Null_unspecified">];
2060
+ let Spellings = [CustomKeyword <"_Null_unspecified">];
2050
2061
let Documentation = [TypeNullUnspecifiedDocs];
2051
2062
}
2052
2063
2053
2064
// This is a marker used to indicate that an __unsafe_unretained qualifier was
2054
2065
// ignored because ARC is not enabled. The usual representation for this
2055
2066
// qualifier is as an ObjCOwnership attribute with Kind == "none".
2056
2067
def ObjCInertUnsafeUnretained : TypeAttr {
2057
- let Spellings = [Keyword <"__unsafe_unretained">];
2068
+ let Spellings = [CustomKeyword <"__unsafe_unretained">];
2058
2069
let Documentation = [InternalOnly];
2059
2070
}
2060
2071
2061
2072
def ObjCKindOf : TypeAttr {
2062
- let Spellings = [Keyword <"__kindof">];
2073
+ let Spellings = [CustomKeyword <"__kindof">];
2063
2074
let Documentation = [Undocumented];
2064
2075
}
2065
2076
@@ -2358,7 +2369,7 @@ def Overloadable : Attr {
2358
2369
}
2359
2370
2360
2371
def Override : InheritableAttr {
2361
- let Spellings = [Keyword <"override">];
2372
+ let Spellings = [CustomKeyword <"override">];
2362
2373
let SemaHandler = 0;
2363
2374
// Omitted from docs, since this is language syntax, not an attribute, as far
2364
2375
// as users are concerned.
@@ -2603,7 +2614,8 @@ def Sentinel : InheritableAttr {
2603
2614
}
2604
2615
2605
2616
def StdCall : DeclOrTypeAttr {
2606
- let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
2617
+ let Spellings = [GCC<"stdcall">, CustomKeyword<"__stdcall">,
2618
+ CustomKeyword<"_stdcall">];
2607
2619
// let Subjects = [Function, ObjCMethod];
2608
2620
let Documentation = [StdCallDocs];
2609
2621
}
@@ -2672,15 +2684,15 @@ def SysVABI : DeclOrTypeAttr {
2672
2684
}
2673
2685
2674
2686
def ThisCall : DeclOrTypeAttr {
2675
- let Spellings = [GCC<"thiscall">, Keyword <"__thiscall">,
2676
- Keyword <"_thiscall">];
2687
+ let Spellings = [GCC<"thiscall">, CustomKeyword <"__thiscall">,
2688
+ CustomKeyword <"_thiscall">];
2677
2689
// let Subjects = [Function, ObjCMethod];
2678
2690
let Documentation = [ThisCallDocs];
2679
2691
}
2680
2692
2681
2693
def VectorCall : DeclOrTypeAttr {
2682
- let Spellings = [Clang<"vectorcall">, Keyword <"__vectorcall">,
2683
- Keyword <"_vectorcall">];
2694
+ let Spellings = [Clang<"vectorcall">, CustomKeyword <"__vectorcall">,
2695
+ CustomKeyword <"_vectorcall">];
2684
2696
// let Subjects = [Function, ObjCMethod];
2685
2697
let Documentation = [VectorCallDocs];
2686
2698
}
@@ -2699,7 +2711,8 @@ def ZeroCallUsedRegs : InheritableAttr {
2699
2711
}
2700
2712
2701
2713
def Pascal : DeclOrTypeAttr {
2702
- let Spellings = [Clang<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
2714
+ let Spellings = [Clang<"pascal">, CustomKeyword<"__pascal">,
2715
+ CustomKeyword<"_pascal">];
2703
2716
// let Subjects = [Function, ObjCMethod];
2704
2717
let Documentation = [Undocumented];
2705
2718
}
@@ -3596,37 +3609,37 @@ def Thread : Attr {
3596
3609
}
3597
3610
3598
3611
def Win64 : IgnoredAttr {
3599
- let Spellings = [Keyword <"__w64">];
3612
+ let Spellings = [CustomKeyword <"__w64">];
3600
3613
let LangOpts = [MicrosoftExt];
3601
3614
}
3602
3615
3603
3616
def Ptr32 : TypeAttr {
3604
- let Spellings = [Keyword <"__ptr32">];
3617
+ let Spellings = [CustomKeyword <"__ptr32">];
3605
3618
let Documentation = [Ptr32Docs];
3606
3619
}
3607
3620
3608
3621
def Ptr64 : TypeAttr {
3609
- let Spellings = [Keyword <"__ptr64">];
3622
+ let Spellings = [CustomKeyword <"__ptr64">];
3610
3623
let Documentation = [Ptr64Docs];
3611
3624
}
3612
3625
3613
3626
def SPtr : TypeAttr {
3614
- let Spellings = [Keyword <"__sptr">];
3627
+ let Spellings = [CustomKeyword <"__sptr">];
3615
3628
let Documentation = [SPtrDocs];
3616
3629
}
3617
3630
3618
3631
def UPtr : TypeAttr {
3619
- let Spellings = [Keyword <"__uptr">];
3632
+ let Spellings = [CustomKeyword <"__uptr">];
3620
3633
let Documentation = [UPtrDocs];
3621
3634
}
3622
3635
3623
3636
def MSInheritance : InheritableAttr {
3624
3637
let LangOpts = [MicrosoftExt];
3625
3638
let Args = [DefaultBoolArgument<"BestCase", /*default*/1, /*fake*/1>];
3626
- let Spellings = [Keyword <"__single_inheritance">,
3627
- Keyword <"__multiple_inheritance">,
3628
- Keyword <"__virtual_inheritance">,
3629
- Keyword <"__unspecified_inheritance">];
3639
+ let Spellings = [CustomKeyword <"__single_inheritance">,
3640
+ CustomKeyword <"__multiple_inheritance">,
3641
+ CustomKeyword <"__virtual_inheritance">,
3642
+ CustomKeyword <"__unspecified_inheritance">];
3630
3643
let AdditionalMembers = [{
3631
3644
MSInheritanceModel getInheritanceModel() const {
3632
3645
// The spelling enum should agree with MSInheritanceModel.
@@ -4126,7 +4139,7 @@ def HLSLResource : InheritableAttr {
4126
4139
}
4127
4140
4128
4141
def HLSLGroupSharedAddressSpace : TypeAttr {
4129
- let Spellings = [Keyword <"groupshared">];
4142
+ let Spellings = [CustomKeyword <"groupshared">];
4130
4143
let Subjects = SubjectList<[Var]>;
4131
4144
let Documentation = [HLSLGroupSharedAddressSpaceDocs];
4132
4145
}
@@ -4158,7 +4171,7 @@ def FunctionReturnThunks : InheritableAttr,
4158
4171
}
4159
4172
4160
4173
def WebAssemblyFuncref : TypeAttr, TargetSpecificAttr<TargetWebAssembly> {
4161
- let Spellings = [Keyword <"__funcref">];
4174
+ let Spellings = [CustomKeyword <"__funcref">];
4162
4175
let Documentation = [WebAssemblyExportNameDocs];
4163
4176
let Subjects = SubjectList<[FunctionPointer], ErrorDiag>;
4164
4177
}
0 commit comments