]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - contrib/llvm/tools/clang/include/clang/Basic/Attr.td
MFC r244628:
[FreeBSD/stable/9.git] / contrib / llvm / tools / clang / include / clang / Basic / Attr.td
1 ////////////////////////////////////////////////////////////////////////////////
2 // Note: This file is a work in progress. Please do not apply non-trivial
3 // updates unless you have talked to Sean Hunt <rideau3@gmail.com> prior.
4 // Merely adding a new attribute is a trivial update.
5 ////////////////////////////////////////////////////////////////////////////////
6
7 // An attribute's subject is whatever it appertains to. In this file, it is
8 // more accurately a list of things that an attribute can appertain to. All
9 // Decls and Stmts are possibly AttrSubjects (even though the syntax may not
10 // allow attributes on a given Decl or Stmt).
11 class AttrSubject;
12
13 include "clang/Basic/DeclNodes.td"
14 include "clang/Basic/StmtNodes.td"
15
16 // A subset-subject is an AttrSubject constrained to operate only on some subset
17 // of that subject.
18 //
19 // The description is used in output messages to specify what the subject
20 // represents. FIXME: Deal with translation issues.
21 //
22 // The code fragment is a boolean expression that will confirm that the subject
23 // meets the requirements; the subject will have the name S, and will have the
24 // type specified by the base. It should be a simple boolean expression.
25 class SubsetSubject<AttrSubject base, string description, code check>
26     : AttrSubject {
27   AttrSubject Base = base;
28   string Description = description;
29   code CheckCode = check;
30 }
31
32 // This is the type of a variable which C++0x defines [[aligned()]] as being
33 // a possible subject.
34 def NormalVar : SubsetSubject<Var, "non-register, non-parameter variable",
35                               [{S->getStorageClass() != VarDecl::Register &&
36                                 S->getKind() != Decl::ImplicitParam &&
37                                 S->getKind() != Decl::ParmVar &&
38                                 S->getKind() != Decl::NonTypeTemplateParm}]>;
39 def CXXVirtualMethod : SubsetSubject<CXXRecord, "virtual member function",
40                                      [{S->isVirtual()}]>;
41 def NonBitField : SubsetSubject<Field, "non-bit field",
42                                 [{!S->isBitField()}]>;
43
44 // A single argument to an attribute
45 class Argument<string name> {
46   string Name = name;
47 }
48
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>;
60
61 // A version of the form major.minor[.subminor].
62 class VersionArgument<string name> : Argument<name>;
63
64 // This one's a doozy, so it gets its own special type
65 // It can be an unsigned integer, or a type. Either can
66 // be dependent.
67 class AlignedArgument<string name> : Argument<name>;
68
69 // An integer argument with a default value
70 class DefaultIntArgument<string name, int default> : IntArgument<name> {
71   int Default = default;
72 }
73
74 // This argument is more complex, it includes the enumerator type name,
75 // a list of strings to accept, and a list of enumerators to map them to.
76 class EnumArgument<string name, string type, list<string> values,
77                          list<string> enums> : Argument<name> {
78   string Type = type;
79   list<string> Values = values;
80   list<string> Enums = enums;
81 }
82
83 // This handles one spelling of an attribute.
84 class Spelling<string name, string variety> {
85   string Name = name;
86   string Variety = variety;
87 }
88
89 class GNU<string name> : Spelling<name, "GNU">;
90 class Declspec<string name> : Spelling<name, "Declspec">;
91 class CXX11<string namespace, string name> : Spelling<name, "CXX11"> {
92   string Namespace = namespace;
93 }
94
95 class Attr {
96   // The various ways in which an attribute can be spelled in source
97   list<Spelling> Spellings;
98   // The things to which an attribute can appertain
99   list<AttrSubject> Subjects;
100   // The arguments allowed on an attribute
101   list<Argument> Args = [];
102   // Set to true for attributes with arguments which require delayed parsing. 
103   bit LateParsed = 0;  
104   // Set to false to prevent an attribute from being propagated from a template
105   // to the instantiation.
106   bit Clone = 1;
107   // Set to true for attributes which must be instantiated within templates
108   bit TemplateDependent = 0;
109   // Set to true for attributes that have a corresponding AST node.
110   bit ASTNode = 1;
111   // Set to true for attributes which have handler in Sema.
112   bit SemaHandler = 1;
113   // Set to true for attributes that are completely ignored.
114   bit Ignored = 0;
115   // Set to true if each of the spellings is a distinct attribute.
116   bit DistinctSpellings = 0;
117   // Any additional text that should be included verbatim in the class.  
118   code AdditionalMembers = [{}];
119 }
120
121 /// An inheritable attribute is inherited by later redeclarations.
122 class InheritableAttr : Attr;
123
124 /// An inheritable parameter attribute is inherited by later
125 /// redeclarations, even when it's written on a parameter.
126 class InheritableParamAttr : InheritableAttr;
127
128 //
129 // Attributes begin here
130 //
131
132 def AddressSpace : Attr {
133   let Spellings = [GNU<"address_space">];
134   let Args = [IntArgument<"AddressSpace">];
135   let ASTNode = 0;  
136 }
137
138 def Alias : InheritableAttr {
139   let Spellings = [GNU<"alias">];
140   let Args = [StringArgument<"Aliasee">];
141 }
142
143 def Aligned : InheritableAttr {
144   let Spellings = [GNU<"aligned">, GNU<"align">];
145   let Subjects = [NonBitField, NormalVar, Tag];
146   let Args = [AlignedArgument<"Alignment">, BoolArgument<"IsMSDeclSpec">];
147 }
148
149 def AlignMac68k : InheritableAttr {
150   let Spellings = [];
151   let SemaHandler = 0;
152 }
153
154 def AllocSize : Attr {
155   let Spellings = [GNU<"alloc_size">];
156   let Args = [VariadicUnsignedArgument<"Args">];
157 }
158
159 def AlwaysInline : InheritableAttr {
160   let Spellings = [GNU<"always_inline">];
161 }
162
163 def TLSModel : InheritableAttr {
164   let Spellings = [GNU<"tls_model">];
165   let Subjects = [Var];
166   let Args = [StringArgument<"Model">];
167 }
168
169 def AnalyzerNoReturn : InheritableAttr {
170   let Spellings = [GNU<"analyzer_noreturn">];
171 }
172
173 def Annotate : InheritableParamAttr {
174   let Spellings = [GNU<"annotate">];
175   let Args = [StringArgument<"Annotation">];
176 }
177
178 def AsmLabel : InheritableAttr {
179   let Spellings = [];
180   let Args = [StringArgument<"Label">];
181   let SemaHandler = 0;
182 }
183
184 def Availability : InheritableAttr {
185   let Spellings = [GNU<"availability">];
186   let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
187               VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
188               BoolArgument<"unavailable">, StringArgument<"message">];
189   let AdditionalMembers =
190 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
191     return llvm::StringSwitch<llvm::StringRef>(Platform)
192              .Case("ios", "iOS")
193              .Case("macosx", "OS X")
194              .Default(llvm::StringRef());
195 } }];
196 }
197
198 def Blocks : InheritableAttr {
199   let Spellings = [GNU<"blocks">];
200   let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
201 }
202
203 def Bounded : Attr {
204   let Spellings = [GNU<"bounded">];
205   let ASTNode = 0;
206   let SemaHandler = 0;
207   let Ignored = 1;
208 }
209
210 def CarriesDependency : InheritableParamAttr {
211   let Spellings = [GNU<"carries_dependency">, CXX11<"","carries_dependency">,
212                    CXX11<"std","carries_dependency">];
213   let Subjects = [ParmVar, Function];
214 }
215
216 def CDecl : InheritableAttr {
217   let Spellings = [GNU<"cdecl">, GNU<"__cdecl">];
218 }
219
220 // cf_audited_transfer indicates that the given function has been
221 // audited and has been marked with the appropriate cf_consumed and
222 // cf_returns_retained attributes.  It is generally applied by
223 // '#pragma clang arc_cf_code_audited' rather than explicitly.
224 def CFAuditedTransfer : InheritableAttr {
225   let Spellings = [GNU<"cf_audited_transfer">];
226   let Subjects = [Function];
227 }
228
229 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
230 // It indicates that the function has unknown or unautomatable
231 // transfer semantics.
232 def CFUnknownTransfer : InheritableAttr {
233   let Spellings = [GNU<"cf_unknown_transfer">];
234   let Subjects = [Function];
235 }
236
237 def CFReturnsAutoreleased : Attr {
238   let Spellings = [GNU<"cf_returns_autoreleased">];
239   let ASTNode = 0;
240 }
241
242 def CFReturnsRetained : InheritableAttr {
243   let Spellings = [GNU<"cf_returns_retained">];
244   let Subjects = [ObjCMethod, Function];
245 }
246
247 def CFReturnsNotRetained : InheritableAttr {
248   let Spellings = [GNU<"cf_returns_not_retained">];
249   let Subjects = [ObjCMethod, Function];
250 }
251
252 def CFConsumed : InheritableParamAttr {
253   let Spellings = [GNU<"cf_consumed">];
254   let Subjects = [ParmVar];
255 }
256
257 def Cleanup : InheritableAttr {
258   let Spellings = [GNU<"cleanup">];
259   let Args = [FunctionArgument<"FunctionDecl">];
260 }
261
262 def Cold : InheritableAttr {
263   let Spellings = [GNU<"cold">];
264 }
265
266 def Common : InheritableAttr {
267   let Spellings = [GNU<"common">];
268 }
269
270 def Const : InheritableAttr {
271   let Spellings = [GNU<"const">, GNU<"__const">];
272 }
273
274 def Constructor : InheritableAttr {
275   let Spellings = [GNU<"constructor">];
276   let Args = [IntArgument<"Priority">];
277 }
278
279 def CUDAConstant : InheritableAttr {
280   let Spellings = [GNU<"constant">];
281 }
282
283 def CUDADevice : InheritableAttr {
284   let Spellings = [GNU<"device">];
285 }
286
287 def CUDAGlobal : InheritableAttr {
288   let Spellings = [GNU<"global">];
289 }
290
291 def CUDAHost : InheritableAttr {
292   let Spellings = [GNU<"host">];
293 }
294
295 def CUDALaunchBounds : InheritableAttr {
296   let Spellings = [GNU<"launch_bounds">];
297   let Args = [IntArgument<"MaxThreads">, DefaultIntArgument<"MinBlocks", 0>];
298 }
299
300 def CUDAShared : InheritableAttr {
301   let Spellings = [GNU<"shared">];
302 }
303
304 def OpenCLKernel : Attr {
305   let Spellings = [GNU<"opencl_kernel_function">];
306 }
307
308 def OpenCLImageAccess : Attr {
309   let Spellings = [GNU<"opencl_image_access">];
310   let Args = [IntArgument<"Access">];
311   let ASTNode = 0;
312 }
313
314 def Deprecated : InheritableAttr {
315   let Spellings = [GNU<"deprecated">];
316   let Args = [StringArgument<"Message">];
317 }
318
319 def Destructor : InheritableAttr {
320   let Spellings = [GNU<"destructor">];
321   let Args = [IntArgument<"Priority">];
322 }
323
324 def ExtVectorType : Attr {
325   let Spellings = [GNU<"ext_vector_type">];
326   let Args = [ExprArgument<"NumElements">];
327   let ASTNode = 0;
328 }
329
330 def FallThrough : Attr {
331   let Spellings = [CXX11<"clang","fallthrough">];
332   let Subjects = [NullStmt];
333 }
334
335 def FastCall : InheritableAttr {
336   let Spellings = [GNU<"fastcall">, GNU<"__fastcall">];
337 }
338
339 def Final : InheritableAttr {
340   let Spellings = [];
341   let SemaHandler = 0;
342 }
343
344 def MinSize : InheritableAttr {
345   let Spellings = [GNU<"minsize">];
346   let Subjects = [Function];
347 }
348
349 def Format : InheritableAttr {
350   let Spellings = [GNU<"format">];
351   let Args = [StringArgument<"Type">, IntArgument<"FormatIdx">,
352               IntArgument<"FirstArg">];
353 }
354
355 def FormatArg : InheritableAttr {
356   let Spellings = [GNU<"format_arg">];
357   let Args = [IntArgument<"FormatIdx">];
358 }
359
360 def GNUInline : InheritableAttr {
361   let Spellings = [GNU<"gnu_inline">];
362 }
363
364 def Hot : InheritableAttr {
365   let Spellings = [GNU<"hot">];
366 }
367
368 def IBAction : InheritableAttr {
369   let Spellings = [GNU<"ibaction">];
370 }
371
372 def IBOutlet : InheritableAttr {
373   let Spellings = [GNU<"iboutlet">];
374 }
375
376 def IBOutletCollection : InheritableAttr {
377   let Spellings = [GNU<"iboutletcollection">];
378   let Args = [TypeArgument<"Interface">, SourceLocArgument<"InterfaceLoc">];
379 }
380
381 def Malloc : InheritableAttr {
382   let Spellings = [GNU<"malloc">];
383 }
384
385 def MaxFieldAlignment : InheritableAttr {
386   let Spellings = [];
387   let Args = [UnsignedArgument<"Alignment">];
388   let SemaHandler = 0;
389 }
390
391 def MayAlias : InheritableAttr {
392   let Spellings = [GNU<"may_alias">];
393 }
394
395 def MSP430Interrupt : InheritableAttr {
396   let Spellings = [];
397   let Args = [UnsignedArgument<"Number">];
398   let SemaHandler = 0;
399 }
400
401 def MBlazeInterruptHandler : InheritableAttr {
402   let Spellings = [];
403   let SemaHandler = 0;
404 }
405
406 def MBlazeSaveVolatiles : InheritableAttr {
407   let Spellings = [];
408   let SemaHandler = 0;
409 }
410
411 def Mode : Attr {
412   let Spellings = [GNU<"mode">];
413   let Args = [IdentifierArgument<"Mode">];
414   let ASTNode = 0;
415 }
416
417 def Naked : InheritableAttr {
418   let Spellings = [GNU<"naked">];
419 }
420
421 def NeonPolyVectorType : Attr {
422   let Spellings = [GNU<"neon_polyvector_type">];
423   let Args = [IntArgument<"NumElements">];
424   let ASTNode = 0;
425 }
426
427 def NeonVectorType : Attr {
428   let Spellings = [GNU<"neon_vector_type">];
429   let Args = [IntArgument<"NumElements">];
430   let ASTNode = 0;
431 }
432
433 def ReturnsTwice : InheritableAttr {
434   let Spellings = [GNU<"returns_twice">];
435 }
436
437 def NoCommon : InheritableAttr {
438   let Spellings = [GNU<"nocommon">];
439 }
440
441 def NoDebug : InheritableAttr {
442   let Spellings = [GNU<"nodebug">];
443 }
444
445 def NoInline : InheritableAttr {
446   let Spellings = [GNU<"noinline">];
447 }
448
449 def NonNull : InheritableAttr {
450   let Spellings = [GNU<"nonnull">];
451   let Args = [VariadicUnsignedArgument<"Args">];
452   let AdditionalMembers =
453 [{bool isNonNull(unsigned idx) const {
454     for (args_iterator i = args_begin(), e = args_end();
455          i != e; ++i)
456       if (*i == idx)
457         return true;
458     return false;
459   } }];
460 }
461
462 def NoReturn : InheritableAttr {
463   let Spellings = [GNU<"noreturn">, CXX11<"","noreturn">,
464                    CXX11<"std","noreturn">];
465   // FIXME: Does GCC allow this on the function instead?
466   let Subjects = [Function];
467 }
468
469 def NoInstrumentFunction : InheritableAttr {
470   let Spellings = [GNU<"no_instrument_function">];
471   let Subjects = [Function];
472 }
473
474 def NoThrow : InheritableAttr {
475   let Spellings = [GNU<"nothrow">];
476 }
477
478 def NSBridged : InheritableAttr {
479   let Spellings = [GNU<"ns_bridged">];
480   let Subjects = [Record];
481   let Args = [IdentifierArgument<"BridgedType">];
482 }
483
484 def NSReturnsRetained : InheritableAttr {
485   let Spellings = [GNU<"ns_returns_retained">];
486   let Subjects = [ObjCMethod, Function];
487 }
488
489 def NSReturnsNotRetained : InheritableAttr {
490   let Spellings = [GNU<"ns_returns_not_retained">];
491   let Subjects = [ObjCMethod, Function];
492 }
493
494 def NSReturnsAutoreleased : InheritableAttr {
495   let Spellings = [GNU<"ns_returns_autoreleased">];
496   let Subjects = [ObjCMethod, Function];
497 }
498
499 def NSConsumesSelf : InheritableAttr {
500   let Spellings = [GNU<"ns_consumes_self">];
501   let Subjects = [ObjCMethod];
502 }
503
504 def NSConsumed : InheritableParamAttr {
505   let Spellings = [GNU<"ns_consumed">];
506   let Subjects = [ParmVar];
507 }
508
509 def ObjCException : InheritableAttr {
510   let Spellings = [GNU<"objc_exception">];
511 }
512
513 def ObjCMethodFamily : InheritableAttr {
514   let Spellings = [GNU<"objc_method_family">];
515   let Subjects = [ObjCMethod];
516   let Args = [EnumArgument<"Family", "FamilyKind",
517                ["none", "alloc", "copy", "init", "mutableCopy", "new"],
518                ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
519                 "OMF_mutableCopy", "OMF_new"]>];
520 }
521
522 def ObjCNSObject : InheritableAttr {
523   let Spellings = [GNU<"NSObject">];
524 }
525
526 def ObjCPreciseLifetime : Attr {
527   let Spellings = [GNU<"objc_precise_lifetime">];
528   let Subjects = [Var];
529 }
530
531 def ObjCReturnsInnerPointer : Attr {
532   let Spellings = [GNU<"objc_returns_inner_pointer">];
533   let Subjects = [ObjCMethod];
534 }
535
536 def ObjCRequiresSuper : InheritableAttr {
537   let Spellings = [GNU<"objc_requires_super">];
538   let Subjects = [ObjCMethod];
539 }
540
541 def ObjCRootClass : Attr {
542   let Spellings = [GNU<"objc_root_class">];
543   let Subjects = [ObjCInterface];
544 }
545
546 def Overloadable : Attr {
547   let Spellings = [GNU<"overloadable">];
548 }
549
550 def Override : InheritableAttr { 
551   let Spellings = [];
552   let SemaHandler = 0;
553 }
554
555 def Ownership : InheritableAttr {
556   let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
557                    GNU<"ownership_takes">];
558   let DistinctSpellings = 1;
559   let Args = [EnumArgument<"OwnKind", "OwnershipKind",
560                     ["ownership_holds", "ownership_returns", "ownership_takes"],
561                     ["Holds", "Returns", "Takes"]>,
562               StringArgument<"Module">, VariadicUnsignedArgument<"Args">];
563 }
564
565 def Packed : InheritableAttr {
566   let Spellings = [GNU<"packed">];
567 }
568
569 def PnaclCall : InheritableAttr {
570   let Spellings = [GNU<"pnaclcall">];
571 }
572
573 def Pcs : InheritableAttr {
574   let Spellings = [GNU<"pcs">];
575   let Args = [EnumArgument<"PCS", "PCSType",
576                            ["aapcs", "aapcs-vfp"],
577                            ["AAPCS", "AAPCS_VFP"]>];
578 }
579
580 def Pure : InheritableAttr {
581   let Spellings = [GNU<"pure">];
582 }
583
584 def Regparm : InheritableAttr {
585   let Spellings = [GNU<"regparm">];
586   let Args = [UnsignedArgument<"NumParams">];
587 }
588
589 def ReqdWorkGroupSize : InheritableAttr {
590   let Spellings = [GNU<"reqd_work_group_size">];
591   let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
592               UnsignedArgument<"ZDim">];
593 }
594
595 def WorkGroupSizeHint :  InheritableAttr {
596   let Spellings = [GNU<"work_group_size_hint">];
597   let Args = [UnsignedArgument<"XDim">, 
598               UnsignedArgument<"YDim">,
599               UnsignedArgument<"ZDim">];
600 }
601
602 def InitPriority : InheritableAttr {
603   let Spellings = [GNU<"init_priority">];
604   let Args = [UnsignedArgument<"Priority">];
605 }
606
607 def Section : InheritableAttr {
608   let Spellings = [GNU<"section">];
609   let Args = [StringArgument<"Name">];
610 }
611
612 def Sentinel : InheritableAttr {
613   let Spellings = [GNU<"sentinel">];
614   let Args = [DefaultIntArgument<"Sentinel", 0>,
615               DefaultIntArgument<"NullPos", 0>];
616 }
617
618 def StdCall : InheritableAttr {
619   let Spellings = [GNU<"stdcall">, GNU<"__stdcall">];
620 }
621
622 def ThisCall : InheritableAttr {
623   let Spellings = [GNU<"thiscall">, GNU<"__thiscall">];
624 }
625
626 def Pascal : InheritableAttr {
627   let Spellings = [GNU<"pascal">];
628 }
629
630 def TransparentUnion : InheritableAttr {
631   let Spellings = [GNU<"transparent_union">];
632 }
633
634 def Unavailable : InheritableAttr {
635   let Spellings = [GNU<"unavailable">];
636   let Args = [StringArgument<"Message">];
637 }
638
639 def ArcWeakrefUnavailable : InheritableAttr {
640   let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
641   let Subjects = [ObjCInterface];
642 }
643
644 def ObjCGC : Attr {
645   let Spellings = [GNU<"objc_gc">];
646   let Args = [IdentifierArgument<"Kind">];
647   let ASTNode = 0;
648 }
649
650 def ObjCOwnership : Attr {
651   let Spellings = [GNU<"objc_ownership">];
652   let Args = [IdentifierArgument<"Kind">];
653   let ASTNode = 0;
654 }
655
656 def ObjCRequiresPropertyDefs : InheritableAttr {
657   let Spellings = [GNU<"objc_requires_property_definitions">];
658   let Subjects = [ObjCInterface];
659 }
660
661 def Unused : InheritableAttr {
662   let Spellings = [GNU<"unused">];
663 }
664
665 def Used : InheritableAttr {
666   let Spellings = [GNU<"used">];
667 }
668
669 def Uuid : InheritableAttr {
670   let Spellings = [GNU<"uuid">];
671   let Args = [StringArgument<"Guid">];
672   let Subjects = [CXXRecord];
673 }
674
675 def VectorSize : Attr {
676   let Spellings = [GNU<"vector_size">];
677   let Args = [ExprArgument<"NumBytes">];
678   let ASTNode = 0;
679 }
680
681 def VecTypeHint : Attr {
682   let Spellings = [GNU<"vec_type_hint">];
683   let ASTNode = 0;
684   let SemaHandler = 0;
685   let Ignored = 1;
686 }
687
688 def Visibility : InheritableAttr {
689   let Clone = 0;
690   let Spellings = [GNU<"visibility">];
691   let Args = [EnumArgument<"Visibility", "VisibilityType",
692                            ["default", "hidden", "internal", "protected"],
693                            ["Default", "Hidden", "Hidden", "Protected"]>];
694 }
695
696 def VecReturn : InheritableAttr {
697   let Spellings = [GNU<"vecreturn">];
698   let Subjects = [CXXRecord];
699 }
700
701 def WarnUnusedResult : InheritableAttr {
702   let Spellings = [GNU<"warn_unused_result">];
703 }
704
705 def Weak : InheritableAttr {
706   let Spellings = [GNU<"weak">];
707 }
708
709 def WeakImport : InheritableAttr {
710   let Spellings = [GNU<"weak_import">];
711 }
712
713 def WeakRef : InheritableAttr {
714   let Spellings = [GNU<"weakref">];
715 }
716
717 def X86ForceAlignArgPointer : InheritableAttr {
718   let Spellings = [];
719 }
720
721 // AddressSafety attribute (e.g. for AddressSanitizer)
722 def NoAddressSafetyAnalysis : InheritableAttr {
723   let Spellings = [GNU<"no_address_safety_analysis">];
724 }
725
726 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
727
728 def GuardedVar : InheritableAttr {
729   let Spellings = [GNU<"guarded_var">];
730 }
731
732 def PtGuardedVar : InheritableAttr {
733   let Spellings = [GNU<"pt_guarded_var">];
734 }
735
736 def Lockable : InheritableAttr {
737   let Spellings = [GNU<"lockable">];
738 }
739
740 def ScopedLockable : InheritableAttr {
741   let Spellings = [GNU<"scoped_lockable">];
742 }
743
744 def NoThreadSafetyAnalysis : InheritableAttr {
745   let Spellings = [GNU<"no_thread_safety_analysis">];
746 }
747
748 def GuardedBy : InheritableAttr {
749   let Spellings = [GNU<"guarded_by">];
750   let Args = [ExprArgument<"Arg">];
751   let LateParsed = 1;
752   let TemplateDependent = 1;
753 }
754
755 def PtGuardedBy : InheritableAttr {
756   let Spellings = [GNU<"pt_guarded_by">];
757   let Args = [ExprArgument<"Arg">];
758   let LateParsed = 1;
759   let TemplateDependent = 1;
760 }
761
762 def AcquiredAfter : InheritableAttr {
763   let Spellings = [GNU<"acquired_after">];
764   let Args = [VariadicExprArgument<"Args">];
765   let LateParsed = 1;
766   let TemplateDependent = 1;
767 }
768
769 def AcquiredBefore : InheritableAttr {
770   let Spellings = [GNU<"acquired_before">];
771   let Args = [VariadicExprArgument<"Args">];
772   let LateParsed = 1;
773   let TemplateDependent = 1;
774 }
775
776 def ExclusiveLockFunction : InheritableAttr {
777   let Spellings = [GNU<"exclusive_lock_function">];
778   let Args = [VariadicExprArgument<"Args">];
779   let LateParsed = 1;
780   let TemplateDependent = 1;
781 }
782
783 def SharedLockFunction : InheritableAttr {
784   let Spellings = [GNU<"shared_lock_function">];
785   let Args = [VariadicExprArgument<"Args">];
786   let LateParsed = 1;
787   let TemplateDependent = 1;
788 }
789
790 // The first argument is an integer or boolean value specifying the return value
791 // of a successful lock acquisition.
792 def ExclusiveTrylockFunction : InheritableAttr {
793   let Spellings = [GNU<"exclusive_trylock_function">];
794   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
795   let LateParsed = 1;
796   let TemplateDependent = 1;
797 }
798
799 // The first argument is an integer or boolean value specifying the return value
800 // of a successful lock acquisition.
801 def SharedTrylockFunction : InheritableAttr {
802   let Spellings = [GNU<"shared_trylock_function">];
803   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
804   let LateParsed = 1;
805   let TemplateDependent = 1;
806 }
807
808 def UnlockFunction : InheritableAttr {
809   let Spellings = [GNU<"unlock_function">];
810   let Args = [VariadicExprArgument<"Args">];
811   let LateParsed = 1;
812   let TemplateDependent = 1;
813 }
814
815 def LockReturned : InheritableAttr {
816   let Spellings = [GNU<"lock_returned">];
817   let Args = [ExprArgument<"Arg">];
818   let LateParsed = 1;
819   let TemplateDependent = 1;
820 }
821
822 def LocksExcluded : InheritableAttr {
823   let Spellings = [GNU<"locks_excluded">];
824   let Args = [VariadicExprArgument<"Args">];
825   let LateParsed = 1;
826   let TemplateDependent = 1;
827 }
828
829 def ExclusiveLocksRequired : InheritableAttr {
830   let Spellings = [GNU<"exclusive_locks_required">];
831   let Args = [VariadicExprArgument<"Args">];
832   let LateParsed = 1;
833   let TemplateDependent = 1;
834 }
835
836 def SharedLocksRequired : InheritableAttr {
837   let Spellings = [GNU<"shared_locks_required">];
838   let Args = [VariadicExprArgument<"Args">];
839   let LateParsed = 1;
840   let TemplateDependent = 1;
841 }
842
843 // Type safety attributes for `void *' pointers and type tags.
844
845 def ArgumentWithTypeTag : InheritableAttr {
846   let Spellings = [GNU<"argument_with_type_tag">,
847                    GNU<"pointer_with_type_tag">];
848   let Args = [IdentifierArgument<"ArgumentKind">,
849               UnsignedArgument<"ArgumentIdx">,
850               UnsignedArgument<"TypeTagIdx">,
851               BoolArgument<"IsPointer">];
852   let Subjects = [Function];
853 }
854
855 def TypeTagForDatatype : InheritableAttr {
856   let Spellings = [GNU<"type_tag_for_datatype">];
857   let Args = [IdentifierArgument<"ArgumentKind">,
858               TypeArgument<"MatchingCType">,
859               BoolArgument<"LayoutCompatible">,
860               BoolArgument<"MustBeNull">];
861   let Subjects = [Var];
862 }
863
864 // Microsoft-related attributes
865
866 def MsStruct : InheritableAttr {
867   let Spellings = [Declspec<"ms_struct">];
868 }
869
870 def DLLExport : InheritableAttr {
871   let Spellings = [Declspec<"dllexport">];
872 }
873
874 def DLLImport : InheritableAttr {
875   let Spellings = [Declspec<"dllimport">];
876 }
877
878 def ForceInline : InheritableAttr {
879   let Spellings = [Declspec<"__forceinline">];
880 }
881
882 def Win64 : InheritableAttr {
883   let Spellings = [Declspec<"w64">];
884 }
885
886 def Ptr32 : InheritableAttr {
887   let Spellings = [Declspec<"__ptr32">];
888 }
889
890 def Ptr64 : InheritableAttr {
891   let Spellings = [Declspec<"__ptr64">];
892 }
893
894 def SingleInheritance : InheritableAttr {
895   let Spellings = [Declspec<"__single_inheritance">];
896 }
897
898 def MultipleInheritance : InheritableAttr {
899   let Spellings = [Declspec<"__multiple_inheritance">];
900 }
901
902 def VirtualInheritance : InheritableAttr {
903   let Spellings = [Declspec<"__virtual_inheritance">];
904 }