@@ -42,39 +42,40 @@ def NonBitField : SubsetSubject<Field, "non-bit field",
42
42
[{!S->isBitField()}]>;
43
43
44
44
// A single argument to an attribute
45
- class Argument<string name> {
45
+ class Argument<string name, bit optional > {
46
46
string Name = name;
47
+ bit Optional = optional;
47
48
}
48
49
49
- class BoolArgument<string name> : Argument<name>;
50
- class IdentifierArgument<string name> : Argument<name>;
51
- class IntArgument<string name> : Argument<name>;
52
- class StringArgument<string name> : Argument<name>;
53
- class ExprArgument<string name> : Argument<name>;
54
- class FunctionArgument<string name> : Argument<name>;
55
- class TypeArgument<string name> : Argument<name>;
56
- class UnsignedArgument<string name> : Argument<name>;
57
- class SourceLocArgument<string name> : Argument<name>;
58
- class VariadicUnsignedArgument<string name> : Argument<name>;
59
- class VariadicExprArgument<string name> : Argument<name>;
50
+ class BoolArgument<string name, bit opt = 0 > : Argument<name, opt >;
51
+ class IdentifierArgument<string name, bit opt = 0 > : Argument<name, opt >;
52
+ class IntArgument<string name, bit opt = 0 > : Argument<name, opt >;
53
+ class StringArgument<string name, bit opt = 0 > : Argument<name, opt >;
54
+ class ExprArgument<string name, bit opt = 0 > : Argument<name, opt >;
55
+ class FunctionArgument<string name, bit opt = 0 > : Argument<name, opt >;
56
+ class TypeArgument<string name, bit opt = 0 > : Argument<name, opt >;
57
+ class UnsignedArgument<string name, bit opt = 0 > : Argument<name, opt >;
58
+ class SourceLocArgument<string name, bit opt = 0 > : Argument<name, opt >;
59
+ class VariadicUnsignedArgument<string name> : Argument<name, 1 >;
60
+ class VariadicExprArgument<string name> : Argument<name, 1 >;
60
61
61
62
// A version of the form major.minor[.subminor].
62
- class VersionArgument<string name> : Argument<name>;
63
+ class VersionArgument<string name, bit opt = 0 > : Argument<name, opt >;
63
64
64
65
// This one's a doozy, so it gets its own special type
65
66
// It can be an unsigned integer, or a type. Either can
66
67
// be dependent.
67
- class AlignedArgument<string name> : Argument<name>;
68
+ class AlignedArgument<string name, bit opt = 0 > : Argument<name, opt >;
68
69
69
70
// An integer argument with a default value
70
- class DefaultIntArgument<string name, int default> : IntArgument<name> {
71
+ class DefaultIntArgument<string name, int default> : IntArgument<name, 1 > {
71
72
int Default = default;
72
73
}
73
74
74
75
// This argument is more complex, it includes the enumerator type name,
75
76
// a list of strings to accept, and a list of enumerators to map them to.
76
77
class EnumArgument<string name, string type, list<string> values,
77
- list<string> enums> : Argument<name> {
78
+ list<string> enums, bit opt = 0 > : Argument<name, opt > {
78
79
string Type = type;
79
80
list<string> Values = values;
80
81
list<string> Enums = enums;
@@ -122,6 +123,10 @@ class Attr {
122
123
bit Ignored = 0;
123
124
// Set to true if each of the spellings is a distinct attribute.
124
125
bit DistinctSpellings = 0;
126
+ // Set to true if the attribute's parsing does not match its semantic
127
+ // content. Eg) It parses 3 args, but semantically takes 4 args. Opts out of
128
+ // common attribute error checking.
129
+ bit HasCustomParsing = 0;
125
130
// Any additional text that should be included verbatim in the class.
126
131
code AdditionalMembers = [{}];
127
132
}
@@ -168,7 +173,7 @@ def Aligned : InheritableAttr {
168
173
let Spellings = [GNU<"aligned">, Declspec<"align">, CXX11<"gnu", "aligned">,
169
174
Keyword<"alignas">, Keyword<"_Alignas">];
170
175
let Subjects = [NonBitField, NormalVar, Tag];
171
- let Args = [AlignedArgument<"Alignment">];
176
+ let Args = [AlignedArgument<"Alignment", 1 >];
172
177
let Accessors = [Accessor<"isGNU", [GNU<"aligned">, CXX11<"gnu","aligned">]>,
173
178
Accessor<"isC11", [Keyword<"_Alignas">]>,
174
179
Accessor<"isAlignas", [Keyword<"alignas">,
@@ -223,6 +228,7 @@ def Availability : InheritableAttr {
223
228
.Case("macosx", "OS X")
224
229
.Default(llvm::StringRef());
225
230
} }];
231
+ let HasCustomParsing = 1;
226
232
}
227
233
228
234
def Blocks : InheritableAttr {
@@ -296,7 +302,7 @@ def Const : InheritableAttr {
296
302
297
303
def Constructor : InheritableAttr {
298
304
let Spellings = [GNU<"constructor">, CXX11<"gnu", "constructor">];
299
- let Args = [IntArgument<"Priority">];
305
+ let Args = [IntArgument<"Priority", 1 >];
300
306
}
301
307
302
308
def CUDAConstant : InheritableAttr {
@@ -346,12 +352,12 @@ def OpenCLImageAccess : Attr {
346
352
347
353
def Deprecated : InheritableAttr {
348
354
let Spellings = [GNU<"deprecated">, CXX11<"gnu", "deprecated">];
349
- let Args = [StringArgument<"Message">];
355
+ let Args = [StringArgument<"Message", 1 >];
350
356
}
351
357
352
358
def Destructor : InheritableAttr {
353
359
let Spellings = [GNU<"destructor">, CXX11<"gnu", "destructor">];
354
- let Args = [IntArgument<"Priority">];
360
+ let Args = [IntArgument<"Priority", 1 >];
355
361
}
356
362
357
363
def ExtVectorType : Attr {
@@ -409,7 +415,7 @@ def IBOutlet : InheritableAttr {
409
415
410
416
def IBOutletCollection : InheritableAttr {
411
417
let Spellings = [GNU<"iboutletcollection">];
412
- let Args = [TypeArgument<"Interface">, SourceLocArgument<"InterfaceLoc">];
418
+ let Args = [TypeArgument<"Interface", 1 >, SourceLocArgument<"InterfaceLoc">];
413
419
}
414
420
415
421
def Malloc : InheritableAttr {
@@ -513,7 +519,7 @@ def NoThrow : InheritableAttr {
513
519
def NSBridged : InheritableAttr {
514
520
let Spellings = [GNU<"ns_bridged">];
515
521
let Subjects = [Record];
516
- let Args = [IdentifierArgument<"BridgedType">];
522
+ let Args = [IdentifierArgument<"BridgedType", 1 >];
517
523
}
518
524
519
525
def NSReturnsRetained : InheritableAttr {
@@ -678,7 +684,7 @@ def TransparentUnion : InheritableAttr {
678
684
679
685
def Unavailable : InheritableAttr {
680
686
let Spellings = [GNU<"unavailable">];
681
- let Args = [StringArgument<"Message">];
687
+ let Args = [StringArgument<"Message", 1 >];
682
688
}
683
689
684
690
def ArcWeakrefUnavailable : InheritableAttr {
@@ -724,6 +730,7 @@ def VectorSize : TypeAttr {
724
730
def VecTypeHint : InheritableAttr {
725
731
let Spellings = [GNU<"vec_type_hint">];
726
732
let Args = [TypeArgument<"TypeHint">, SourceLocArgument<"TypeLoc">];
733
+ let HasCustomParsing = 1;
727
734
}
728
735
729
736
def Visibility : InheritableAttr {
@@ -768,6 +775,8 @@ def WeakImport : InheritableAttr {
768
775
769
776
def WeakRef : InheritableAttr {
770
777
let Spellings = [GNU<"weakref">, CXX11<"gnu", "weakref">];
778
+ // A WeakRef that has an argument is treated as being an AliasAttr
779
+ let Args = [StringArgument<"Aliasee", 1>];
771
780
}
772
781
773
782
def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr {
@@ -969,6 +978,7 @@ def ArgumentWithTypeTag : InheritableAttr {
969
978
UnsignedArgument<"TypeTagIdx">,
970
979
BoolArgument<"IsPointer">];
971
980
let Subjects = [Function];
981
+ let HasCustomParsing = 1;
972
982
}
973
983
974
984
def TypeTagForDatatype : InheritableAttr {
@@ -978,6 +988,7 @@ def TypeTagForDatatype : InheritableAttr {
978
988
BoolArgument<"LayoutCompatible">,
979
989
BoolArgument<"MustBeNull">];
980
990
let Subjects = [Var];
991
+ let HasCustomParsing = 1;
981
992
}
982
993
983
994
// Microsoft-related attributes
0 commit comments