@@ -554,6 +554,11 @@ class Attr {
554
554
list<Documentation> Documentation;
555
555
}
556
556
557
+ /// Used to define a set of mutually exclusive attributes.
558
+ class MutualExclusions<list<Attr> Ex> {
559
+ list<Attr> Exclusions = Ex;
560
+ }
561
+
557
562
/// A type attribute is not processed on a declaration or a statement.
558
563
class TypeAttr : Attr;
559
564
@@ -918,6 +923,7 @@ def CFAuditedTransfer : InheritableAttr {
918
923
let Spellings = [Clang<"cf_audited_transfer">];
919
924
let Subjects = SubjectList<[Function], ErrorDiag>;
920
925
let Documentation = [Undocumented];
926
+ let SimpleHandler = 1;
921
927
}
922
928
923
929
// cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
@@ -927,7 +933,9 @@ def CFUnknownTransfer : InheritableAttr {
927
933
let Spellings = [Clang<"cf_unknown_transfer">];
928
934
let Subjects = SubjectList<[Function], ErrorDiag>;
929
935
let Documentation = [Undocumented];
936
+ let SimpleHandler = 1;
930
937
}
938
+ def : MutualExclusions<[CFAuditedTransfer, CFUnknownTransfer]>;
931
939
932
940
def CFReturnsRetained : InheritableAttr {
933
941
let Spellings = [Clang<"cf_returns_retained">];
@@ -1009,6 +1017,7 @@ def Cold : InheritableAttr {
1009
1017
let Spellings = [GCC<"cold">];
1010
1018
let Subjects = SubjectList<[Function]>;
1011
1019
let Documentation = [Undocumented];
1020
+ let SimpleHandler = 1;
1012
1021
}
1013
1022
1014
1023
def Common : InheritableAttr {
@@ -1094,6 +1103,7 @@ def CUDADeviceBuiltinSurfaceType : InheritableAttr {
1094
1103
let Subjects = SubjectList<[CXXRecord]>;
1095
1104
let Documentation = [CUDADeviceBuiltinSurfaceTypeDocs];
1096
1105
let MeaningfulToClassTemplateDefinition = 1;
1106
+ let SimpleHandler = 1;
1097
1107
}
1098
1108
1099
1109
def CUDADeviceBuiltinTextureType : InheritableAttr {
@@ -1103,21 +1113,27 @@ def CUDADeviceBuiltinTextureType : InheritableAttr {
1103
1113
let Subjects = SubjectList<[CXXRecord]>;
1104
1114
let Documentation = [CUDADeviceBuiltinTextureTypeDocs];
1105
1115
let MeaningfulToClassTemplateDefinition = 1;
1116
+ let SimpleHandler = 1;
1106
1117
}
1118
+ def : MutualExclusions<[CUDADeviceBuiltinSurfaceType,
1119
+ CUDADeviceBuiltinTextureType]>;
1107
1120
1108
1121
def CUDAGlobal : InheritableAttr {
1109
1122
let Spellings = [GNU<"global">, Declspec<"__global__">];
1110
1123
let Subjects = SubjectList<[Function]>;
1111
1124
let LangOpts = [CUDA];
1112
1125
let Documentation = [Undocumented];
1113
1126
}
1127
+ def : MutualExclusions<[CUDADevice, CUDAGlobal]>;
1114
1128
1115
1129
def CUDAHost : InheritableAttr {
1116
1130
let Spellings = [GNU<"host">, Declspec<"__host__">];
1117
1131
let Subjects = SubjectList<[Function]>;
1118
1132
let LangOpts = [CUDA];
1119
1133
let Documentation = [Undocumented];
1134
+ let SimpleHandler = 1;
1120
1135
}
1136
+ def : MutualExclusions<[CUDAGlobal, CUDAHost]>;
1121
1137
1122
1138
def HIPManaged : InheritableAttr {
1123
1139
let Spellings = [GNU<"managed">, Declspec<"__managed__">];
@@ -1150,6 +1166,7 @@ def CUDAShared : InheritableAttr {
1150
1166
let LangOpts = [CUDA];
1151
1167
let Documentation = [Undocumented];
1152
1168
}
1169
+ def : MutualExclusions<[CUDAConstant, CUDAShared, HIPManaged]>;
1153
1170
1154
1171
def SYCLKernel : InheritableAttr {
1155
1172
let Spellings = [Clang<"sycl_kernel">];
@@ -1342,6 +1359,7 @@ def Unlikely : StmtAttr {
1342
1359
let Spellings = [CXX11<"", "unlikely", 201803>, C2x<"clang", "unlikely">];
1343
1360
let Documentation = [LikelihoodDocs];
1344
1361
}
1362
+ def : MutualExclusions<[Likely, Unlikely]>;
1345
1363
1346
1364
def NoMerge : DeclOrStmtAttr {
1347
1365
let Spellings = [Clang<"nomerge">];
@@ -1433,7 +1451,9 @@ def Hot : InheritableAttr {
1433
1451
// An AST node is created for this attribute, but not actually used beyond
1434
1452
// semantic checking for mutual exclusion with the Cold attribute.
1435
1453
let Documentation = [Undocumented];
1454
+ let SimpleHandler = 1;
1436
1455
}
1456
+ def : MutualExclusions<[Hot, Cold]>;
1437
1457
1438
1458
def IBAction : InheritableAttr {
1439
1459
let Spellings = [Clang<"ibaction">];
@@ -1544,6 +1564,7 @@ def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1544
1564
let Spellings = [GCC<"mips16">];
1545
1565
let Subjects = SubjectList<[Function], ErrorDiag>;
1546
1566
let Documentation = [Undocumented];
1567
+ let SimpleHandler = 1;
1547
1568
}
1548
1569
1549
1570
def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips32> {
@@ -1562,24 +1583,30 @@ def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1562
1583
let ParseKind = "Interrupt";
1563
1584
let Documentation = [MipsInterruptDocs];
1564
1585
}
1586
+ def : MutualExclusions<[Mips16, MipsInterrupt]>;
1565
1587
1566
1588
def MicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1567
1589
let Spellings = [GCC<"micromips">];
1568
1590
let Subjects = SubjectList<[Function], ErrorDiag>;
1569
1591
let Documentation = [MicroMipsDocs];
1592
+ let SimpleHandler = 1;
1570
1593
}
1594
+ def : MutualExclusions<[Mips16, MicroMips]>;
1571
1595
1572
1596
def MipsLongCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
1573
1597
let Spellings = [GCC<"long_call">, GCC<"far">];
1574
1598
let Subjects = SubjectList<[Function]>;
1575
1599
let Documentation = [MipsLongCallStyleDocs];
1600
+ let SimpleHandler = 1;
1576
1601
}
1577
1602
1578
1603
def MipsShortCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
1579
1604
let Spellings = [GCC<"short_call">, GCC<"near">];
1580
1605
let Subjects = SubjectList<[Function]>;
1581
1606
let Documentation = [MipsShortCallStyleDocs];
1607
+ let SimpleHandler = 1;
1582
1608
}
1609
+ def : MutualExclusions<[MipsLongCall, MipsShortCall]>;
1583
1610
1584
1611
def M68kInterrupt : InheritableAttr, TargetSpecificAttr<TargetM68k> {
1585
1612
// NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's
@@ -1656,7 +1683,9 @@ def DisableTailCalls : InheritableAttr {
1656
1683
let Spellings = [Clang<"disable_tail_calls">];
1657
1684
let Subjects = SubjectList<[Function, ObjCMethod]>;
1658
1685
let Documentation = [DisableTailCallsDocs];
1686
+ let SimpleHandler = 1;
1659
1687
}
1688
+ def : MutualExclusions<[Naked, DisableTailCalls]>;
1660
1689
1661
1690
def NoAlias : InheritableAttr {
1662
1691
let Spellings = [Declspec<"noalias">];
@@ -1930,7 +1959,9 @@ def NotTailCalled : InheritableAttr {
1930
1959
let Spellings = [Clang<"not_tail_called">];
1931
1960
let Subjects = SubjectList<[Function]>;
1932
1961
let Documentation = [NotTailCalledDocs];
1962
+ let SimpleHandler = 1;
1933
1963
}
1964
+ def : MutualExclusions<[AlwaysInline, NotTailCalled]>;
1934
1965
1935
1966
def NoStackProtector : InheritableAttr {
1936
1967
let Spellings = [Clang<"no_stack_protector">];
@@ -3248,6 +3279,7 @@ def Pointer : InheritableAttr {
3248
3279
let Args = [TypeArgument<"DerefType", /*opt=*/1>];
3249
3280
let Documentation = [LifetimePointerDocs];
3250
3281
}
3282
+ def : MutualExclusions<[Owner, Pointer]>;
3251
3283
3252
3284
// Microsoft-related attributes
3253
3285
@@ -3620,6 +3652,7 @@ def InternalLinkage : InheritableAttr {
3620
3652
let Subjects = SubjectList<[Var, Function, CXXRecord]>;
3621
3653
let Documentation = [InternalLinkageDocs];
3622
3654
}
3655
+ def : MutualExclusions<[Common, InternalLinkage]>;
3623
3656
3624
3657
def ExcludeFromExplicitInstantiation : InheritableAttr {
3625
3658
let Spellings = [Clang<"exclude_from_explicit_instantiation">];
@@ -3647,18 +3680,22 @@ def AlwaysDestroy : InheritableAttr {
3647
3680
let Subjects = SubjectList<[Var]>;
3648
3681
let Documentation = [AlwaysDestroyDocs];
3649
3682
}
3683
+ def : MutualExclusions<[NoDestroy, AlwaysDestroy]>;
3650
3684
3651
3685
def SpeculativeLoadHardening : InheritableAttr {
3652
3686
let Spellings = [Clang<"speculative_load_hardening">];
3653
3687
let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
3654
3688
let Documentation = [SpeculativeLoadHardeningDocs];
3689
+ let SimpleHandler = 1;
3655
3690
}
3656
3691
3657
3692
def NoSpeculativeLoadHardening : InheritableAttr {
3658
3693
let Spellings = [Clang<"no_speculative_load_hardening">];
3659
3694
let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
3660
3695
let Documentation = [NoSpeculativeLoadHardeningDocs];
3696
+ let SimpleHandler = 1;
3661
3697
}
3698
+ def : MutualExclusions<[SpeculativeLoadHardening, NoSpeculativeLoadHardening]>;
3662
3699
3663
3700
def Uninitialized : InheritableAttr {
3664
3701
let Spellings = [Clang<"uninitialized", 0>];
0 commit comments