]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/llvm/tools/clang/include/clang/Basic/Attr.td
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.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++11 allows alignas(...) to appertain
33 // to.
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 class Keyword<string name> : Spelling<name, "Keyword">;
95
96 class Accessor<string name, list<Spelling> spellings> {
97   string Name = name;
98   list<Spelling> Spellings = spellings;
99 }
100
101 class Attr {
102   // The various ways in which an attribute can be spelled in source
103   list<Spelling> Spellings;
104   // The things to which an attribute can appertain
105   list<AttrSubject> Subjects;
106   // The arguments allowed on an attribute
107   list<Argument> Args = [];
108   // Accessors which should be generated for the attribute.
109   list<Accessor> Accessors = [];
110   // Set to true for attributes with arguments which require delayed parsing.
111   bit LateParsed = 0;
112   // Set to false to prevent an attribute from being propagated from a template
113   // to the instantiation.
114   bit Clone = 1;
115   // Set to true for attributes which must be instantiated within templates
116   bit TemplateDependent = 0;
117   // Set to true for attributes that have a corresponding AST node.
118   bit ASTNode = 1;
119   // Set to true for attributes which have handler in Sema.
120   bit SemaHandler = 1;
121   // Set to true for attributes that are completely ignored.
122   bit Ignored = 0;
123   // Set to true if each of the spellings is a distinct attribute.
124   bit DistinctSpellings = 0;
125   // Any additional text that should be included verbatim in the class.
126   code AdditionalMembers = [{}];
127 }
128
129 /// An inheritable attribute is inherited by later redeclarations.
130 class InheritableAttr : Attr;
131
132 /// An inheritable parameter attribute is inherited by later
133 /// redeclarations, even when it's written on a parameter.
134 class InheritableParamAttr : InheritableAttr;
135
136 /// An ignored attribute, which we parse but discard with no checking.
137 class IgnoredAttr : Attr {
138   let Ignored = 1;
139   let ASTNode = 0;
140   let SemaHandler = 0;
141 }
142
143 //
144 // Attributes begin here
145 //
146
147 def AddressSpace : Attr {
148   let Spellings = [GNU<"address_space">];
149   let Args = [IntArgument<"AddressSpace">];
150   let ASTNode = 0;
151 }
152
153 def Alias : InheritableAttr {
154   let Spellings = [GNU<"alias">, CXX11<"gnu", "alias">];
155   let Args = [StringArgument<"Aliasee">];
156 }
157
158 def Aligned : InheritableAttr {
159   let Spellings = [GNU<"aligned">, Declspec<"align">, CXX11<"gnu", "aligned">,
160                    Keyword<"alignas">, Keyword<"_Alignas">];
161   let Subjects = [NonBitField, NormalVar, Tag];
162   let Args = [AlignedArgument<"Alignment">];
163   let Accessors = [Accessor<"isGNU", [GNU<"aligned">, CXX11<"gnu","aligned">]>,
164                    Accessor<"isC11", [Keyword<"_Alignas">]>,
165                    Accessor<"isAlignas", [Keyword<"alignas">,
166                                           Keyword<"_Alignas">]>,
167                    Accessor<"isDeclspec",[Declspec<"align">]>];
168 }
169
170 def AlignMac68k : InheritableAttr {
171   let Spellings = [];
172   let SemaHandler = 0;
173 }
174
175 def AllocSize : Attr {
176   let Spellings = [GNU<"alloc_size">, CXX11<"gnu", "alloc_size">];
177   let Args = [VariadicUnsignedArgument<"Args">];
178 }
179
180 def AlwaysInline : InheritableAttr {
181   let Spellings = [GNU<"always_inline">, CXX11<"gnu", "always_inline">];
182 }
183
184 def TLSModel : InheritableAttr {
185   let Spellings = [GNU<"tls_model">, CXX11<"gnu", "tls_model">];
186   let Subjects = [Var];
187   let Args = [StringArgument<"Model">];
188 }
189
190 def AnalyzerNoReturn : InheritableAttr {
191   let Spellings = [GNU<"analyzer_noreturn">];
192 }
193
194 def Annotate : InheritableParamAttr {
195   let Spellings = [GNU<"annotate">];
196   let Args = [StringArgument<"Annotation">];
197 }
198
199 def AsmLabel : InheritableAttr {
200   let Spellings = [];
201   let Args = [StringArgument<"Label">];
202   let SemaHandler = 0;
203 }
204
205 def Availability : InheritableAttr {
206   let Spellings = [GNU<"availability">];
207   let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
208               VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
209               BoolArgument<"unavailable">, StringArgument<"message">];
210   let AdditionalMembers =
211 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
212     return llvm::StringSwitch<llvm::StringRef>(Platform)
213              .Case("ios", "iOS")
214              .Case("macosx", "OS X")
215              .Default(llvm::StringRef());
216 } }];
217 }
218
219 def Blocks : InheritableAttr {
220   let Spellings = [GNU<"blocks">];
221   let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
222 }
223
224 def Bounded : IgnoredAttr {
225   let Spellings = [GNU<"bounded">];
226 }
227
228 def CarriesDependency : InheritableParamAttr {
229   let Spellings = [GNU<"carries_dependency">, CXX11<"","carries_dependency">,
230                    CXX11<"std","carries_dependency">];
231   let Subjects = [ParmVar, Function];
232 }
233
234 def CDecl : InheritableAttr {
235   let Spellings = [GNU<"cdecl">, CXX11<"gnu", "cdecl">, Keyword<"__cdecl">,
236                    Keyword<"_cdecl">];
237 }
238
239 // cf_audited_transfer indicates that the given function has been
240 // audited and has been marked with the appropriate cf_consumed and
241 // cf_returns_retained attributes.  It is generally applied by
242 // '#pragma clang arc_cf_code_audited' rather than explicitly.
243 def CFAuditedTransfer : InheritableAttr {
244   let Spellings = [GNU<"cf_audited_transfer">];
245   let Subjects = [Function];
246 }
247
248 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
249 // It indicates that the function has unknown or unautomatable
250 // transfer semantics.
251 def CFUnknownTransfer : InheritableAttr {
252   let Spellings = [GNU<"cf_unknown_transfer">];
253   let Subjects = [Function];
254 }
255
256 def CFReturnsRetained : InheritableAttr {
257   let Spellings = [GNU<"cf_returns_retained">];
258   let Subjects = [ObjCMethod, Function];
259 }
260
261 def CFReturnsNotRetained : InheritableAttr {
262   let Spellings = [GNU<"cf_returns_not_retained">];
263   let Subjects = [ObjCMethod, Function];
264 }
265
266 def CFConsumed : InheritableParamAttr {
267   let Spellings = [GNU<"cf_consumed">];
268   let Subjects = [ParmVar];
269 }
270
271 def Cleanup : InheritableAttr {
272   let Spellings = [GNU<"cleanup">, CXX11<"gnu", "cleanup">];
273   let Args = [FunctionArgument<"FunctionDecl">];
274 }
275
276 def Cold : InheritableAttr {
277   let Spellings = [GNU<"cold">, CXX11<"gnu", "cold">];
278 }
279
280 def Common : InheritableAttr {
281   let Spellings = [GNU<"common">, CXX11<"gnu", "common">];
282 }
283
284 def Const : InheritableAttr {
285   let Spellings = [GNU<"const">, GNU<"__const">, CXX11<"gnu", "const">];
286 }
287
288 def Constructor : InheritableAttr {
289   let Spellings = [GNU<"constructor">, CXX11<"gnu", "constructor">];
290   let Args = [IntArgument<"Priority">];
291 }
292
293 def CUDAConstant : InheritableAttr {
294   let Spellings = [GNU<"constant">];
295 }
296
297 def CUDADevice : InheritableAttr {
298   let Spellings = [GNU<"device">];
299 }
300
301 def CUDAGlobal : InheritableAttr {
302   let Spellings = [GNU<"global">];
303 }
304
305 def CUDAHost : InheritableAttr {
306   let Spellings = [GNU<"host">];
307 }
308
309 def CUDALaunchBounds : InheritableAttr {
310   let Spellings = [GNU<"launch_bounds">];
311   let Args = [IntArgument<"MaxThreads">, DefaultIntArgument<"MinBlocks", 0>];
312 }
313
314 def CUDAShared : InheritableAttr {
315   let Spellings = [GNU<"shared">];
316 }
317
318 def C11NoReturn : InheritableAttr {
319   let Spellings = [Keyword<"_Noreturn">];
320   let Subjects = [Function];
321   let SemaHandler = 0;
322 }
323
324 def CXX11NoReturn : InheritableAttr {
325   let Spellings = [CXX11<"","noreturn">, CXX11<"std","noreturn">];
326   let Subjects = [Function];
327 }
328
329 def OpenCLKernel : Attr {
330   let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
331 }
332
333 def OpenCLImageAccess : Attr {
334   let Spellings = [GNU<"opencl_image_access">];
335   let Args = [IntArgument<"Access">];
336 }
337
338 def Deprecated : InheritableAttr {
339   let Spellings = [GNU<"deprecated">, CXX11<"gnu", "deprecated">];
340   let Args = [StringArgument<"Message">];
341 }
342
343 def Destructor : InheritableAttr {
344   let Spellings = [GNU<"destructor">, CXX11<"gnu", "destructor">];
345   let Args = [IntArgument<"Priority">];
346 }
347
348 def ExtVectorType : Attr {
349   let Spellings = [GNU<"ext_vector_type">];
350   let Args = [ExprArgument<"NumElements">];
351   let ASTNode = 0;
352 }
353
354 def FallThrough : Attr {
355   let Spellings = [CXX11<"clang", "fallthrough">];
356   let Subjects = [NullStmt];
357 }
358
359 def FastCall : InheritableAttr {
360   let Spellings = [GNU<"fastcall">, CXX11<"gnu", "fastcall">,
361                    Keyword<"__fastcall">, Keyword<"_fastcall">];
362 }
363
364 def Final : InheritableAttr {
365   let Spellings = [];
366   let SemaHandler = 0;
367 }
368
369 def MinSize : InheritableAttr {
370   let Spellings = [GNU<"minsize">];
371   let Subjects = [Function];
372 }
373
374 def Format : InheritableAttr {
375   let Spellings = [GNU<"format">, CXX11<"gnu", "format">];
376   let Args = [StringArgument<"Type">, IntArgument<"FormatIdx">,
377               IntArgument<"FirstArg">];
378 }
379
380 def FormatArg : InheritableAttr {
381   let Spellings = [GNU<"format_arg">, CXX11<"gnu", "format_arg">];
382   let Args = [IntArgument<"FormatIdx">];
383 }
384
385 def GNUInline : InheritableAttr {
386   let Spellings = [GNU<"gnu_inline">, CXX11<"gnu", "gnu_inline">];
387 }
388
389 def Hot : InheritableAttr {
390   let Spellings = [GNU<"hot">, CXX11<"gnu", "hot">];
391 }
392
393 def IBAction : InheritableAttr {
394   let Spellings = [GNU<"ibaction">];
395 }
396
397 def IBOutlet : InheritableAttr {
398   let Spellings = [GNU<"iboutlet">];
399 }
400
401 def IBOutletCollection : InheritableAttr {
402   let Spellings = [GNU<"iboutletcollection">];
403   let Args = [TypeArgument<"Interface">, SourceLocArgument<"InterfaceLoc">];
404 }
405
406 def Malloc : InheritableAttr {
407   let Spellings = [GNU<"malloc">, CXX11<"gnu", "malloc">];
408 }
409
410 def MaxFieldAlignment : InheritableAttr {
411   let Spellings = [];
412   let Args = [UnsignedArgument<"Alignment">];
413   let SemaHandler = 0;
414 }
415
416 def MayAlias : InheritableAttr {
417   let Spellings = [GNU<"may_alias">, CXX11<"gnu", "may_alias">];
418 }
419
420 def MSP430Interrupt : InheritableAttr {
421   let Spellings = [];
422   let Args = [UnsignedArgument<"Number">];
423   let SemaHandler = 0;
424 }
425
426 def MBlazeInterruptHandler : InheritableAttr {
427   let Spellings = [];
428   let SemaHandler = 0;
429 }
430
431 def MBlazeSaveVolatiles : InheritableAttr {
432   let Spellings = [];
433   let SemaHandler = 0;
434 }
435
436 def Mips16 : InheritableAttr {
437   let Spellings = [GNU<"mips16">, CXX11<"gnu", "mips16">];
438   let Subjects = [Function];
439 }
440
441 def Mode : Attr {
442   let Spellings = [GNU<"mode">, CXX11<"gnu", "mode">];
443   let Args = [IdentifierArgument<"Mode">];
444   let ASTNode = 0;
445 }
446
447 def Naked : InheritableAttr {
448   let Spellings = [GNU<"naked">, CXX11<"gnu", "naked">];
449 }
450
451 def NeonPolyVectorType : Attr {
452   let Spellings = [GNU<"neon_polyvector_type">];
453   let Args = [IntArgument<"NumElements">];
454   let ASTNode = 0;
455 }
456
457 def NeonVectorType : Attr {
458   let Spellings = [GNU<"neon_vector_type">];
459   let Args = [IntArgument<"NumElements">];
460   let ASTNode = 0;
461 }
462
463 def ReturnsTwice : InheritableAttr {
464   let Spellings = [GNU<"returns_twice">, CXX11<"gnu", "returns_twice">];
465 }
466
467 def NoCommon : InheritableAttr {
468   let Spellings = [GNU<"nocommon">, CXX11<"gnu", "nocommon">];
469 }
470
471 def NoDebug : InheritableAttr {
472   let Spellings = [GNU<"nodebug">];
473 }
474
475 def NoInline : InheritableAttr {
476   let Spellings = [GNU<"noinline">, CXX11<"gnu", "noinline">];
477 }
478
479 def NoMips16 : InheritableAttr {
480   let Spellings = [GNU<"nomips16">, CXX11<"gnu", "nomips16">];
481   let Subjects = [Function];
482 }
483
484 def NonNull : InheritableAttr {
485   let Spellings = [GNU<"nonnull">, CXX11<"gnu", "nonnull">];
486   let Args = [VariadicUnsignedArgument<"Args">];
487   let AdditionalMembers =
488 [{bool isNonNull(unsigned idx) const {
489     for (args_iterator i = args_begin(), e = args_end();
490          i != e; ++i)
491       if (*i == idx)
492         return true;
493     return false;
494   } }];
495 }
496
497 def NoReturn : InheritableAttr {
498   let Spellings = [GNU<"noreturn">, CXX11<"gnu", "noreturn">];
499   // FIXME: Does GCC allow this on the function instead?
500   let Subjects = [Function];
501 }
502
503 def NoInstrumentFunction : InheritableAttr {
504   let Spellings = [GNU<"no_instrument_function">,
505                    CXX11<"gnu", "no_instrument_function">];
506   let Subjects = [Function];
507 }
508
509 def NoThrow : InheritableAttr {
510   let Spellings = [GNU<"nothrow">, CXX11<"gnu", "nothrow">];
511 }
512
513 def NSBridged : InheritableAttr {
514   let Spellings = [GNU<"ns_bridged">];
515   let Subjects = [Record];
516   let Args = [IdentifierArgument<"BridgedType">];
517 }
518
519 def NSReturnsRetained : InheritableAttr {
520   let Spellings = [GNU<"ns_returns_retained">];
521   let Subjects = [ObjCMethod, Function];
522 }
523
524 def NSReturnsNotRetained : InheritableAttr {
525   let Spellings = [GNU<"ns_returns_not_retained">];
526   let Subjects = [ObjCMethod, Function];
527 }
528
529 def NSReturnsAutoreleased : InheritableAttr {
530   let Spellings = [GNU<"ns_returns_autoreleased">];
531   let Subjects = [ObjCMethod, Function];
532 }
533
534 def NSConsumesSelf : InheritableAttr {
535   let Spellings = [GNU<"ns_consumes_self">];
536   let Subjects = [ObjCMethod];
537 }
538
539 def NSConsumed : InheritableParamAttr {
540   let Spellings = [GNU<"ns_consumed">];
541   let Subjects = [ParmVar];
542 }
543
544 def ObjCException : InheritableAttr {
545   let Spellings = [GNU<"objc_exception">];
546 }
547
548 def ObjCMethodFamily : InheritableAttr {
549   let Spellings = [GNU<"objc_method_family">];
550   let Subjects = [ObjCMethod];
551   let Args = [EnumArgument<"Family", "FamilyKind",
552                ["none", "alloc", "copy", "init", "mutableCopy", "new"],
553                ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
554                 "OMF_mutableCopy", "OMF_new"]>];
555 }
556
557 def ObjCNSObject : InheritableAttr {
558   let Spellings = [GNU<"NSObject">];
559 }
560
561 def ObjCPreciseLifetime : Attr {
562   let Spellings = [GNU<"objc_precise_lifetime">];
563   let Subjects = [Var];
564 }
565
566 def ObjCReturnsInnerPointer : Attr {
567   let Spellings = [GNU<"objc_returns_inner_pointer">];
568   let Subjects = [ObjCMethod];
569 }
570
571 def ObjCRequiresSuper : InheritableAttr {
572   let Spellings = [GNU<"objc_requires_super">];
573   let Subjects = [ObjCMethod];
574 }
575
576 def ObjCRootClass : Attr {
577   let Spellings = [GNU<"objc_root_class">];
578   let Subjects = [ObjCInterface];
579 }
580
581 def Overloadable : Attr {
582   let Spellings = [GNU<"overloadable">];
583 }
584
585 def Override : InheritableAttr { 
586   let Spellings = [];
587   let SemaHandler = 0;
588 }
589
590 def Ownership : InheritableAttr {
591   let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
592                    GNU<"ownership_takes">];
593   let DistinctSpellings = 1;
594   let Args = [EnumArgument<"OwnKind", "OwnershipKind",
595                     ["ownership_holds", "ownership_returns", "ownership_takes"],
596                     ["Holds", "Returns", "Takes"]>,
597               StringArgument<"Module">, VariadicUnsignedArgument<"Args">];
598 }
599
600 def Packed : InheritableAttr {
601   let Spellings = [GNU<"packed">, CXX11<"gnu", "packed">];
602 }
603
604 def PnaclCall : InheritableAttr {
605   let Spellings = [GNU<"pnaclcall">];
606 }
607
608 def IntelOclBicc : InheritableAttr {
609   let Spellings = [GNU<"intel_ocl_bicc">];
610 }
611
612 def Pcs : InheritableAttr {
613   let Spellings = [GNU<"pcs">, CXX11<"gnu", "pcs">];
614   let Args = [EnumArgument<"PCS", "PCSType",
615                            ["aapcs", "aapcs-vfp"],
616                            ["AAPCS", "AAPCS_VFP"]>];
617 }
618
619 def Pure : InheritableAttr {
620   let Spellings = [GNU<"pure">, CXX11<"gnu", "pure">];
621 }
622
623 def Regparm : InheritableAttr {
624   let Spellings = [GNU<"regparm">, CXX11<"gnu", "regparm">];
625   let Args = [UnsignedArgument<"NumParams">];
626 }
627
628 def ReqdWorkGroupSize : InheritableAttr {
629   let Spellings = [GNU<"reqd_work_group_size">];
630   let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
631               UnsignedArgument<"ZDim">];
632 }
633
634 def Endian : InheritableAttr {
635   let Spellings = [GNU<"endian">];
636   let Args = [IdentifierArgument<"platform">];
637 }
638
639 def WorkGroupSizeHint :  InheritableAttr {
640   let Spellings = [GNU<"work_group_size_hint">];
641   let Args = [UnsignedArgument<"XDim">, 
642               UnsignedArgument<"YDim">,
643               UnsignedArgument<"ZDim">];
644 }
645
646 def InitPriority : InheritableAttr {
647   let Spellings = [GNU<"init_priority">];
648   let Args = [UnsignedArgument<"Priority">];
649 }
650
651 def Section : InheritableAttr {
652   let Spellings = [GNU<"section">, CXX11<"gnu", "section">];
653   let Args = [StringArgument<"Name">];
654 }
655
656 def Sentinel : InheritableAttr {
657   let Spellings = [GNU<"sentinel">, CXX11<"gnu", "sentinel">];
658   let Args = [DefaultIntArgument<"Sentinel", 0>,
659               DefaultIntArgument<"NullPos", 0>];
660 }
661
662 def StdCall : InheritableAttr {
663   let Spellings = [GNU<"stdcall">, CXX11<"gnu", "stdcall">,
664                    Keyword<"__stdcall">, Keyword<"_stdcall">];
665 }
666
667 def ThisCall : InheritableAttr {
668   let Spellings = [GNU<"thiscall">, CXX11<"gnu", "thiscall">,
669                    Keyword<"__thiscall">, Keyword<"_thiscall">];
670 }
671
672 def Pascal : InheritableAttr {
673   let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
674 }
675
676 def TransparentUnion : InheritableAttr {
677   let Spellings = [GNU<"transparent_union">, CXX11<"gnu", "transparent_union">];
678 }
679
680 def Unavailable : InheritableAttr {
681   let Spellings = [GNU<"unavailable">];
682   let Args = [StringArgument<"Message">];
683 }
684
685 def ArcWeakrefUnavailable : InheritableAttr {
686   let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
687   let Subjects = [ObjCInterface];
688 }
689
690 def ObjCGC : Attr {
691   let Spellings = [GNU<"objc_gc">];
692   let Args = [IdentifierArgument<"Kind">];
693   let ASTNode = 0;
694 }
695
696 def ObjCOwnership : Attr {
697   let Spellings = [GNU<"objc_ownership">];
698   let Args = [IdentifierArgument<"Kind">];
699   let ASTNode = 0;
700 }
701
702 def ObjCRequiresPropertyDefs : InheritableAttr {
703   let Spellings = [GNU<"objc_requires_property_definitions">];
704   let Subjects = [ObjCInterface];
705 }
706
707 def Unused : InheritableAttr {
708   let Spellings = [GNU<"unused">, CXX11<"gnu", "unused">];
709 }
710
711 def Used : InheritableAttr {
712   let Spellings = [GNU<"used">, CXX11<"gnu", "used">];
713 }
714
715 def Uuid : InheritableAttr {
716   let Spellings = [GNU<"uuid">];
717   let Args = [StringArgument<"Guid">];
718   let Subjects = [CXXRecord];
719 }
720
721 def VectorSize : Attr {
722   let Spellings = [GNU<"vector_size">, CXX11<"gnu", "vector_size">];
723   let Args = [ExprArgument<"NumBytes">];
724   let ASTNode = 0;
725 }
726
727 def VecTypeHint : InheritableAttr {
728   let Spellings = [GNU<"vec_type_hint">];
729   let Args = [TypeArgument<"TypeHint">, SourceLocArgument<"TypeLoc">];
730 }
731
732 def Visibility : InheritableAttr {
733   let Clone = 0;
734   let Spellings = [GNU<"visibility">, CXX11<"gnu", "visibility">];
735   let Args = [EnumArgument<"Visibility", "VisibilityType",
736                            ["default", "hidden", "internal", "protected"],
737                            ["Default", "Hidden", "Hidden", "Protected"]>];
738 }
739
740 def TypeVisibility : InheritableAttr {
741   let Clone = 0;
742   let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">];
743   let Args = [EnumArgument<"Visibility", "VisibilityType",
744                            ["default", "hidden", "internal", "protected"],
745                            ["Default", "Hidden", "Hidden", "Protected"]>];
746 }
747
748 def VecReturn : InheritableAttr {
749   let Spellings = [GNU<"vecreturn">];
750   let Subjects = [CXXRecord];
751 }
752
753 def WarnUnusedResult : InheritableAttr {
754   let Spellings = [GNU<"warn_unused_result">,
755                    CXX11<"clang", "warn_unused_result">,
756                    CXX11<"gnu", "warn_unused_result">];
757 }
758
759 def Weak : InheritableAttr {
760   let Spellings = [GNU<"weak">, CXX11<"gnu", "weak">];
761 }
762
763 def WeakImport : InheritableAttr {
764   let Spellings = [GNU<"weak_import">];
765 }
766
767 def WeakRef : InheritableAttr {
768   let Spellings = [GNU<"weakref">, CXX11<"gnu", "weakref">];
769 }
770
771 def X86ForceAlignArgPointer : InheritableAttr {
772   let Spellings = [];
773 }
774
775 // Attribute to disable AddressSanitizer (or equivalent) checks.
776 def NoSanitizeAddress : InheritableAttr {
777   let Spellings = [GNU<"no_address_safety_analysis">,
778                    GNU<"no_sanitize_address">];
779 }
780
781 // Attribute to disable ThreadSanitizer checks.
782 def NoSanitizeThread : InheritableAttr {
783   let Spellings = [GNU<"no_sanitize_thread">];
784 }
785
786 // Attribute to disable MemorySanitizer checks.
787 def NoSanitizeMemory : InheritableAttr {
788   let Spellings = [GNU<"no_sanitize_memory">];
789 }
790
791 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
792
793 def GuardedVar : InheritableAttr {
794   let Spellings = [GNU<"guarded_var">];
795 }
796
797 def PtGuardedVar : InheritableAttr {
798   let Spellings = [GNU<"pt_guarded_var">];
799 }
800
801 def Lockable : InheritableAttr {
802   let Spellings = [GNU<"lockable">];
803 }
804
805 def ScopedLockable : InheritableAttr {
806   let Spellings = [GNU<"scoped_lockable">];
807 }
808
809 def NoThreadSafetyAnalysis : InheritableAttr {
810   let Spellings = [GNU<"no_thread_safety_analysis">];
811 }
812
813 def GuardedBy : InheritableAttr {
814   let Spellings = [GNU<"guarded_by">];
815   let Args = [ExprArgument<"Arg">];
816   let LateParsed = 1;
817   let TemplateDependent = 1;
818 }
819
820 def PtGuardedBy : InheritableAttr {
821   let Spellings = [GNU<"pt_guarded_by">];
822   let Args = [ExprArgument<"Arg">];
823   let LateParsed = 1;
824   let TemplateDependent = 1;
825 }
826
827 def AcquiredAfter : InheritableAttr {
828   let Spellings = [GNU<"acquired_after">];
829   let Args = [VariadicExprArgument<"Args">];
830   let LateParsed = 1;
831   let TemplateDependent = 1;
832 }
833
834 def AcquiredBefore : InheritableAttr {
835   let Spellings = [GNU<"acquired_before">];
836   let Args = [VariadicExprArgument<"Args">];
837   let LateParsed = 1;
838   let TemplateDependent = 1;
839 }
840
841 def ExclusiveLockFunction : InheritableAttr {
842   let Spellings = [GNU<"exclusive_lock_function">];
843   let Args = [VariadicExprArgument<"Args">];
844   let LateParsed = 1;
845   let TemplateDependent = 1;
846 }
847
848 def SharedLockFunction : InheritableAttr {
849   let Spellings = [GNU<"shared_lock_function">];
850   let Args = [VariadicExprArgument<"Args">];
851   let LateParsed = 1;
852   let TemplateDependent = 1;
853 }
854
855 // The first argument is an integer or boolean value specifying the return value
856 // of a successful lock acquisition.
857 def ExclusiveTrylockFunction : InheritableAttr {
858   let Spellings = [GNU<"exclusive_trylock_function">];
859   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
860   let LateParsed = 1;
861   let TemplateDependent = 1;
862 }
863
864 // The first argument is an integer or boolean value specifying the return value
865 // of a successful lock acquisition.
866 def SharedTrylockFunction : InheritableAttr {
867   let Spellings = [GNU<"shared_trylock_function">];
868   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
869   let LateParsed = 1;
870   let TemplateDependent = 1;
871 }
872
873 def UnlockFunction : InheritableAttr {
874   let Spellings = [GNU<"unlock_function">];
875   let Args = [VariadicExprArgument<"Args">];
876   let LateParsed = 1;
877   let TemplateDependent = 1;
878 }
879
880 def LockReturned : InheritableAttr {
881   let Spellings = [GNU<"lock_returned">];
882   let Args = [ExprArgument<"Arg">];
883   let LateParsed = 1;
884   let TemplateDependent = 1;
885 }
886
887 def LocksExcluded : InheritableAttr {
888   let Spellings = [GNU<"locks_excluded">];
889   let Args = [VariadicExprArgument<"Args">];
890   let LateParsed = 1;
891   let TemplateDependent = 1;
892 }
893
894 def ExclusiveLocksRequired : InheritableAttr {
895   let Spellings = [GNU<"exclusive_locks_required">];
896   let Args = [VariadicExprArgument<"Args">];
897   let LateParsed = 1;
898   let TemplateDependent = 1;
899 }
900
901 def SharedLocksRequired : InheritableAttr {
902   let Spellings = [GNU<"shared_locks_required">];
903   let Args = [VariadicExprArgument<"Args">];
904   let LateParsed = 1;
905   let TemplateDependent = 1;
906 }
907
908 // Type safety attributes for `void *' pointers and type tags.
909
910 def ArgumentWithTypeTag : InheritableAttr {
911   let Spellings = [GNU<"argument_with_type_tag">,
912                    GNU<"pointer_with_type_tag">];
913   let Args = [IdentifierArgument<"ArgumentKind">,
914               UnsignedArgument<"ArgumentIdx">,
915               UnsignedArgument<"TypeTagIdx">,
916               BoolArgument<"IsPointer">];
917   let Subjects = [Function];
918 }
919
920 def TypeTagForDatatype : InheritableAttr {
921   let Spellings = [GNU<"type_tag_for_datatype">];
922   let Args = [IdentifierArgument<"ArgumentKind">,
923               TypeArgument<"MatchingCType">,
924               BoolArgument<"LayoutCompatible">,
925               BoolArgument<"MustBeNull">];
926   let Subjects = [Var];
927 }
928
929 // Microsoft-related attributes
930
931 def MsProperty : Attr {
932   let Spellings = [Declspec<"property">];
933 }
934
935 def MsStruct : InheritableAttr {
936   let Spellings = [Declspec<"ms_struct">];
937 }
938
939 def DLLExport : InheritableAttr {
940   let Spellings = [Declspec<"dllexport">];
941 }
942
943 def DLLImport : InheritableAttr {
944   let Spellings = [Declspec<"dllimport">];
945 }
946
947 def ForceInline : InheritableAttr {
948   let Spellings = [Keyword<"__forceinline">];
949 }
950
951 def Win64 : InheritableAttr {
952   let Spellings = [Keyword<"__w64">];
953 }
954
955 def Ptr32 : InheritableAttr {
956   let Spellings = [Keyword<"__ptr32">];
957 }
958
959 def Ptr64 : InheritableAttr {
960   let Spellings = [Keyword<"__ptr64">];
961 }
962
963 class MSInheritanceAttr : InheritableAttr;
964
965 def SingleInheritance : MSInheritanceAttr {
966   let Spellings = [Keyword<"__single_inheritance">];
967 }
968
969 def MultipleInheritance : MSInheritanceAttr {
970   let Spellings = [Keyword<"__multiple_inheritance">];
971 }
972
973 def VirtualInheritance : MSInheritanceAttr {
974   let Spellings = [Keyword<"__virtual_inheritance">];
975 }
976
977 // This attribute doesn't have any spellings, but we can apply it implicitly to
978 // incomplete types that lack any of the other attributes.
979 def UnspecifiedInheritance : MSInheritanceAttr {
980   let Spellings = [];
981 }
982
983 def Unaligned : IgnoredAttr {
984   let Spellings = [Keyword<"__unaligned">];
985 }