@@ -554,6 +554,11 @@ class Attr {
554554 list<Documentation> Documentation;
555555}
556556
557+ /// Used to define a set of mutually exclusive attributes.
558+ class MutualExclusions<list<Attr> Ex> {
559+ list<Attr> Exclusions = Ex;
560+ }
561+
557562/// A type attribute is not processed on a declaration or a statement.
558563class TypeAttr : Attr;
559564
@@ -918,6 +923,7 @@ def CFAuditedTransfer : InheritableAttr {
918923 let Spellings = [Clang<"cf_audited_transfer">];
919924 let Subjects = SubjectList<[Function], ErrorDiag>;
920925 let Documentation = [Undocumented];
926+ let SimpleHandler = 1;
921927}
922928
923929// cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
@@ -927,7 +933,9 @@ def CFUnknownTransfer : InheritableAttr {
927933 let Spellings = [Clang<"cf_unknown_transfer">];
928934 let Subjects = SubjectList<[Function], ErrorDiag>;
929935 let Documentation = [Undocumented];
936+ let SimpleHandler = 1;
930937}
938+ def : MutualExclusions<[CFAuditedTransfer, CFUnknownTransfer]>;
931939
932940def CFReturnsRetained : InheritableAttr {
933941 let Spellings = [Clang<"cf_returns_retained">];
@@ -1009,6 +1017,7 @@ def Cold : InheritableAttr {
10091017 let Spellings = [GCC<"cold">];
10101018 let Subjects = SubjectList<[Function]>;
10111019 let Documentation = [Undocumented];
1020+ let SimpleHandler = 1;
10121021}
10131022
10141023def Common : InheritableAttr {
@@ -1094,6 +1103,7 @@ def CUDADeviceBuiltinSurfaceType : InheritableAttr {
10941103 let Subjects = SubjectList<[CXXRecord]>;
10951104 let Documentation = [CUDADeviceBuiltinSurfaceTypeDocs];
10961105 let MeaningfulToClassTemplateDefinition = 1;
1106+ let SimpleHandler = 1;
10971107}
10981108
10991109def CUDADeviceBuiltinTextureType : InheritableAttr {
@@ -1103,21 +1113,27 @@ def CUDADeviceBuiltinTextureType : InheritableAttr {
11031113 let Subjects = SubjectList<[CXXRecord]>;
11041114 let Documentation = [CUDADeviceBuiltinTextureTypeDocs];
11051115 let MeaningfulToClassTemplateDefinition = 1;
1116+ let SimpleHandler = 1;
11061117}
1118+ def : MutualExclusions<[CUDADeviceBuiltinSurfaceType,
1119+ CUDADeviceBuiltinTextureType]>;
11071120
11081121def CUDAGlobal : InheritableAttr {
11091122 let Spellings = [GNU<"global">, Declspec<"__global__">];
11101123 let Subjects = SubjectList<[Function]>;
11111124 let LangOpts = [CUDA];
11121125 let Documentation = [Undocumented];
11131126}
1127+ def : MutualExclusions<[CUDADevice, CUDAGlobal]>;
11141128
11151129def CUDAHost : InheritableAttr {
11161130 let Spellings = [GNU<"host">, Declspec<"__host__">];
11171131 let Subjects = SubjectList<[Function]>;
11181132 let LangOpts = [CUDA];
11191133 let Documentation = [Undocumented];
1134+ let SimpleHandler = 1;
11201135}
1136+ def : MutualExclusions<[CUDAGlobal, CUDAHost]>;
11211137
11221138def HIPManaged : InheritableAttr {
11231139 let Spellings = [GNU<"managed">, Declspec<"__managed__">];
@@ -1150,6 +1166,7 @@ def CUDAShared : InheritableAttr {
11501166 let LangOpts = [CUDA];
11511167 let Documentation = [Undocumented];
11521168}
1169+ def : MutualExclusions<[CUDAConstant, CUDAShared, HIPManaged]>;
11531170
11541171def SYCLKernel : InheritableAttr {
11551172 let Spellings = [Clang<"sycl_kernel">];
@@ -1342,6 +1359,7 @@ def Unlikely : StmtAttr {
13421359 let Spellings = [CXX11<"", "unlikely", 201803>, C2x<"clang", "unlikely">];
13431360 let Documentation = [LikelihoodDocs];
13441361}
1362+ def : MutualExclusions<[Likely, Unlikely]>;
13451363
13461364def NoMerge : DeclOrStmtAttr {
13471365 let Spellings = [Clang<"nomerge">];
@@ -1433,7 +1451,9 @@ def Hot : InheritableAttr {
14331451 // An AST node is created for this attribute, but not actually used beyond
14341452 // semantic checking for mutual exclusion with the Cold attribute.
14351453 let Documentation = [Undocumented];
1454+ let SimpleHandler = 1;
14361455}
1456+ def : MutualExclusions<[Hot, Cold]>;
14371457
14381458def IBAction : InheritableAttr {
14391459 let Spellings = [Clang<"ibaction">];
@@ -1544,6 +1564,7 @@ def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
15441564 let Spellings = [GCC<"mips16">];
15451565 let Subjects = SubjectList<[Function], ErrorDiag>;
15461566 let Documentation = [Undocumented];
1567+ let SimpleHandler = 1;
15471568}
15481569
15491570def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips32> {
@@ -1562,24 +1583,30 @@ def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips32> {
15621583 let ParseKind = "Interrupt";
15631584 let Documentation = [MipsInterruptDocs];
15641585}
1586+ def : MutualExclusions<[Mips16, MipsInterrupt]>;
15651587
15661588def MicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> {
15671589 let Spellings = [GCC<"micromips">];
15681590 let Subjects = SubjectList<[Function], ErrorDiag>;
15691591 let Documentation = [MicroMipsDocs];
1592+ let SimpleHandler = 1;
15701593}
1594+ def : MutualExclusions<[Mips16, MicroMips]>;
15711595
15721596def MipsLongCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
15731597 let Spellings = [GCC<"long_call">, GCC<"far">];
15741598 let Subjects = SubjectList<[Function]>;
15751599 let Documentation = [MipsLongCallStyleDocs];
1600+ let SimpleHandler = 1;
15761601}
15771602
15781603def MipsShortCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
15791604 let Spellings = [GCC<"short_call">, GCC<"near">];
15801605 let Subjects = SubjectList<[Function]>;
15811606 let Documentation = [MipsShortCallStyleDocs];
1607+ let SimpleHandler = 1;
15821608}
1609+ def : MutualExclusions<[MipsLongCall, MipsShortCall]>;
15831610
15841611def M68kInterrupt : InheritableAttr, TargetSpecificAttr<TargetM68k> {
15851612 // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's
@@ -1656,7 +1683,9 @@ def DisableTailCalls : InheritableAttr {
16561683 let Spellings = [Clang<"disable_tail_calls">];
16571684 let Subjects = SubjectList<[Function, ObjCMethod]>;
16581685 let Documentation = [DisableTailCallsDocs];
1686+ let SimpleHandler = 1;
16591687}
1688+ def : MutualExclusions<[Naked, DisableTailCalls]>;
16601689
16611690def NoAlias : InheritableAttr {
16621691 let Spellings = [Declspec<"noalias">];
@@ -1930,7 +1959,9 @@ def NotTailCalled : InheritableAttr {
19301959 let Spellings = [Clang<"not_tail_called">];
19311960 let Subjects = SubjectList<[Function]>;
19321961 let Documentation = [NotTailCalledDocs];
1962+ let SimpleHandler = 1;
19331963}
1964+ def : MutualExclusions<[AlwaysInline, NotTailCalled]>;
19341965
19351966def NoStackProtector : InheritableAttr {
19361967 let Spellings = [Clang<"no_stack_protector">];
@@ -3248,6 +3279,7 @@ def Pointer : InheritableAttr {
32483279 let Args = [TypeArgument<"DerefType", /*opt=*/1>];
32493280 let Documentation = [LifetimePointerDocs];
32503281}
3282+ def : MutualExclusions<[Owner, Pointer]>;
32513283
32523284// Microsoft-related attributes
32533285
@@ -3620,6 +3652,7 @@ def InternalLinkage : InheritableAttr {
36203652 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
36213653 let Documentation = [InternalLinkageDocs];
36223654}
3655+ def : MutualExclusions<[Common, InternalLinkage]>;
36233656
36243657def ExcludeFromExplicitInstantiation : InheritableAttr {
36253658 let Spellings = [Clang<"exclude_from_explicit_instantiation">];
@@ -3647,18 +3680,22 @@ def AlwaysDestroy : InheritableAttr {
36473680 let Subjects = SubjectList<[Var]>;
36483681 let Documentation = [AlwaysDestroyDocs];
36493682}
3683+ def : MutualExclusions<[NoDestroy, AlwaysDestroy]>;
36503684
36513685def SpeculativeLoadHardening : InheritableAttr {
36523686 let Spellings = [Clang<"speculative_load_hardening">];
36533687 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
36543688 let Documentation = [SpeculativeLoadHardeningDocs];
3689+ let SimpleHandler = 1;
36553690}
36563691
36573692def NoSpeculativeLoadHardening : InheritableAttr {
36583693 let Spellings = [Clang<"no_speculative_load_hardening">];
36593694 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
36603695 let Documentation = [NoSpeculativeLoadHardeningDocs];
3696+ let SimpleHandler = 1;
36613697}
3698+ def : MutualExclusions<[SpeculativeLoadHardening, NoSpeculativeLoadHardening]>;
36623699
36633700def Uninitialized : InheritableAttr {
36643701 let Spellings = [Clang<"uninitialized", 0>];
0 commit comments