]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/llvm/tools/clang/include/clang/Basic/Attr.td
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.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 MSABI : InheritableAttr {
421   let Spellings = [GNU<"ms_abi">, CXX11<"gnu", "ms_abi">];
422 }
423
424 def MSP430Interrupt : InheritableAttr {
425   let Spellings = [];
426   let Args = [UnsignedArgument<"Number">];
427   let SemaHandler = 0;
428 }
429
430 def MBlazeInterruptHandler : InheritableAttr {
431   let Spellings = [];
432   let SemaHandler = 0;
433 }
434
435 def MBlazeSaveVolatiles : InheritableAttr {
436   let Spellings = [];
437   let SemaHandler = 0;
438 }
439
440 def Mips16 : InheritableAttr {
441   let Spellings = [GNU<"mips16">, CXX11<"gnu", "mips16">];
442   let Subjects = [Function];
443 }
444
445 def Mode : Attr {
446   let Spellings = [GNU<"mode">, CXX11<"gnu", "mode">];
447   let Args = [IdentifierArgument<"Mode">];
448   let ASTNode = 0;
449 }
450
451 def Naked : InheritableAttr {
452   let Spellings = [GNU<"naked">, CXX11<"gnu", "naked">];
453 }
454
455 def NeonPolyVectorType : Attr {
456   let Spellings = [GNU<"neon_polyvector_type">];
457   let Args = [IntArgument<"NumElements">];
458   let ASTNode = 0;
459 }
460
461 def NeonVectorType : Attr {
462   let Spellings = [GNU<"neon_vector_type">];
463   let Args = [IntArgument<"NumElements">];
464   let ASTNode = 0;
465 }
466
467 def ReturnsTwice : InheritableAttr {
468   let Spellings = [GNU<"returns_twice">, CXX11<"gnu", "returns_twice">];
469 }
470
471 def NoCommon : InheritableAttr {
472   let Spellings = [GNU<"nocommon">, CXX11<"gnu", "nocommon">];
473 }
474
475 def NoDebug : InheritableAttr {
476   let Spellings = [GNU<"nodebug">];
477 }
478
479 def NoInline : InheritableAttr {
480   let Spellings = [GNU<"noinline">, CXX11<"gnu", "noinline">];
481 }
482
483 def NoMips16 : InheritableAttr {
484   let Spellings = [GNU<"nomips16">, CXX11<"gnu", "nomips16">];
485   let Subjects = [Function];
486 }
487
488 def NonNull : InheritableAttr {
489   let Spellings = [GNU<"nonnull">, CXX11<"gnu", "nonnull">];
490   let Args = [VariadicUnsignedArgument<"Args">];
491   let AdditionalMembers =
492 [{bool isNonNull(unsigned idx) const {
493     for (args_iterator i = args_begin(), e = args_end();
494          i != e; ++i)
495       if (*i == idx)
496         return true;
497     return false;
498   } }];
499 }
500
501 def NoReturn : InheritableAttr {
502   let Spellings = [GNU<"noreturn">, CXX11<"gnu", "noreturn">];
503   // FIXME: Does GCC allow this on the function instead?
504   let Subjects = [Function];
505 }
506
507 def NoInstrumentFunction : InheritableAttr {
508   let Spellings = [GNU<"no_instrument_function">,
509                    CXX11<"gnu", "no_instrument_function">];
510   let Subjects = [Function];
511 }
512
513 def NoThrow : InheritableAttr {
514   let Spellings = [GNU<"nothrow">, CXX11<"gnu", "nothrow">];
515 }
516
517 def NSBridged : InheritableAttr {
518   let Spellings = [GNU<"ns_bridged">];
519   let Subjects = [Record];
520   let Args = [IdentifierArgument<"BridgedType">];
521 }
522
523 def NSReturnsRetained : InheritableAttr {
524   let Spellings = [GNU<"ns_returns_retained">];
525   let Subjects = [ObjCMethod, Function];
526 }
527
528 def NSReturnsNotRetained : InheritableAttr {
529   let Spellings = [GNU<"ns_returns_not_retained">];
530   let Subjects = [ObjCMethod, Function];
531 }
532
533 def NSReturnsAutoreleased : InheritableAttr {
534   let Spellings = [GNU<"ns_returns_autoreleased">];
535   let Subjects = [ObjCMethod, Function];
536 }
537
538 def NSConsumesSelf : InheritableAttr {
539   let Spellings = [GNU<"ns_consumes_self">];
540   let Subjects = [ObjCMethod];
541 }
542
543 def NSConsumed : InheritableParamAttr {
544   let Spellings = [GNU<"ns_consumed">];
545   let Subjects = [ParmVar];
546 }
547
548 def ObjCException : InheritableAttr {
549   let Spellings = [GNU<"objc_exception">];
550 }
551
552 def ObjCMethodFamily : InheritableAttr {
553   let Spellings = [GNU<"objc_method_family">];
554   let Subjects = [ObjCMethod];
555   let Args = [EnumArgument<"Family", "FamilyKind",
556                ["none", "alloc", "copy", "init", "mutableCopy", "new"],
557                ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
558                 "OMF_mutableCopy", "OMF_new"]>];
559 }
560
561 def ObjCNSObject : InheritableAttr {
562   let Spellings = [GNU<"NSObject">];
563 }
564
565 def ObjCPreciseLifetime : Attr {
566   let Spellings = [GNU<"objc_precise_lifetime">];
567   let Subjects = [Var];
568 }
569
570 def ObjCReturnsInnerPointer : Attr {
571   let Spellings = [GNU<"objc_returns_inner_pointer">];
572   let Subjects = [ObjCMethod];
573 }
574
575 def ObjCRequiresSuper : InheritableAttr {
576   let Spellings = [GNU<"objc_requires_super">];
577   let Subjects = [ObjCMethod];
578 }
579
580 def ObjCRootClass : Attr {
581   let Spellings = [GNU<"objc_root_class">];
582   let Subjects = [ObjCInterface];
583 }
584
585 def Overloadable : Attr {
586   let Spellings = [GNU<"overloadable">];
587 }
588
589 def Override : InheritableAttr { 
590   let Spellings = [];
591   let SemaHandler = 0;
592 }
593
594 def Ownership : InheritableAttr {
595   let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
596                    GNU<"ownership_takes">];
597   let DistinctSpellings = 1;
598   let Args = [EnumArgument<"OwnKind", "OwnershipKind",
599                     ["ownership_holds", "ownership_returns", "ownership_takes"],
600                     ["Holds", "Returns", "Takes"]>,
601               StringArgument<"Module">, VariadicUnsignedArgument<"Args">];
602 }
603
604 def Packed : InheritableAttr {
605   let Spellings = [GNU<"packed">, CXX11<"gnu", "packed">];
606 }
607
608 def PnaclCall : InheritableAttr {
609   let Spellings = [GNU<"pnaclcall">];
610 }
611
612 def IntelOclBicc : InheritableAttr {
613   let Spellings = [GNU<"intel_ocl_bicc">];
614 }
615
616 def Pcs : InheritableAttr {
617   let Spellings = [GNU<"pcs">, CXX11<"gnu", "pcs">];
618   let Args = [EnumArgument<"PCS", "PCSType",
619                            ["aapcs", "aapcs-vfp"],
620                            ["AAPCS", "AAPCS_VFP"]>];
621 }
622
623 def Pure : InheritableAttr {
624   let Spellings = [GNU<"pure">, CXX11<"gnu", "pure">];
625 }
626
627 def Regparm : InheritableAttr {
628   let Spellings = [GNU<"regparm">, CXX11<"gnu", "regparm">];
629   let Args = [UnsignedArgument<"NumParams">];
630 }
631
632 def ReqdWorkGroupSize : InheritableAttr {
633   let Spellings = [GNU<"reqd_work_group_size">];
634   let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
635               UnsignedArgument<"ZDim">];
636 }
637
638 def Endian : InheritableAttr {
639   let Spellings = [GNU<"endian">];
640   let Args = [IdentifierArgument<"platform">];
641 }
642
643 def WorkGroupSizeHint :  InheritableAttr {
644   let Spellings = [GNU<"work_group_size_hint">];
645   let Args = [UnsignedArgument<"XDim">, 
646               UnsignedArgument<"YDim">,
647               UnsignedArgument<"ZDim">];
648 }
649
650 def InitPriority : InheritableAttr {
651   let Spellings = [GNU<"init_priority">];
652   let Args = [UnsignedArgument<"Priority">];
653 }
654
655 def Section : InheritableAttr {
656   let Spellings = [GNU<"section">, CXX11<"gnu", "section">];
657   let Args = [StringArgument<"Name">];
658 }
659
660 def Sentinel : InheritableAttr {
661   let Spellings = [GNU<"sentinel">, CXX11<"gnu", "sentinel">];
662   let Args = [DefaultIntArgument<"Sentinel", 0>,
663               DefaultIntArgument<"NullPos", 0>];
664 }
665
666 def StdCall : InheritableAttr {
667   let Spellings = [GNU<"stdcall">, CXX11<"gnu", "stdcall">,
668                    Keyword<"__stdcall">, Keyword<"_stdcall">];
669 }
670
671 def SysVABI : InheritableAttr {
672   let Spellings = [GNU<"sysv_abi">, CXX11<"gnu", "sysv_abi">];
673 }
674
675 def ThisCall : InheritableAttr {
676   let Spellings = [GNU<"thiscall">, CXX11<"gnu", "thiscall">,
677                    Keyword<"__thiscall">, Keyword<"_thiscall">];
678 }
679
680 def Pascal : InheritableAttr {
681   let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
682 }
683
684 def TransparentUnion : InheritableAttr {
685   let Spellings = [GNU<"transparent_union">, CXX11<"gnu", "transparent_union">];
686 }
687
688 def Unavailable : InheritableAttr {
689   let Spellings = [GNU<"unavailable">];
690   let Args = [StringArgument<"Message">];
691 }
692
693 def ArcWeakrefUnavailable : InheritableAttr {
694   let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
695   let Subjects = [ObjCInterface];
696 }
697
698 def ObjCGC : Attr {
699   let Spellings = [GNU<"objc_gc">];
700   let Args = [IdentifierArgument<"Kind">];
701   let ASTNode = 0;
702 }
703
704 def ObjCOwnership : Attr {
705   let Spellings = [GNU<"objc_ownership">];
706   let Args = [IdentifierArgument<"Kind">];
707   let ASTNode = 0;
708 }
709
710 def ObjCRequiresPropertyDefs : InheritableAttr {
711   let Spellings = [GNU<"objc_requires_property_definitions">];
712   let Subjects = [ObjCInterface];
713 }
714
715 def Unused : InheritableAttr {
716   let Spellings = [GNU<"unused">, CXX11<"gnu", "unused">];
717 }
718
719 def Used : InheritableAttr {
720   let Spellings = [GNU<"used">, CXX11<"gnu", "used">];
721 }
722
723 def Uuid : InheritableAttr {
724   let Spellings = [GNU<"uuid">];
725   let Args = [StringArgument<"Guid">];
726   let Subjects = [CXXRecord];
727 }
728
729 def VectorSize : Attr {
730   let Spellings = [GNU<"vector_size">, CXX11<"gnu", "vector_size">];
731   let Args = [ExprArgument<"NumBytes">];
732   let ASTNode = 0;
733 }
734
735 def VecTypeHint : InheritableAttr {
736   let Spellings = [GNU<"vec_type_hint">];
737   let Args = [TypeArgument<"TypeHint">, SourceLocArgument<"TypeLoc">];
738 }
739
740 def Visibility : InheritableAttr {
741   let Clone = 0;
742   let Spellings = [GNU<"visibility">, CXX11<"gnu", "visibility">];
743   let Args = [EnumArgument<"Visibility", "VisibilityType",
744                            ["default", "hidden", "internal", "protected"],
745                            ["Default", "Hidden", "Hidden", "Protected"]>];
746 }
747
748 def TypeVisibility : InheritableAttr {
749   let Clone = 0;
750   let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">];
751   let Args = [EnumArgument<"Visibility", "VisibilityType",
752                            ["default", "hidden", "internal", "protected"],
753                            ["Default", "Hidden", "Hidden", "Protected"]>];
754 }
755
756 def VecReturn : InheritableAttr {
757   let Spellings = [GNU<"vecreturn">];
758   let Subjects = [CXXRecord];
759 }
760
761 def WarnUnusedResult : InheritableAttr {
762   let Spellings = [GNU<"warn_unused_result">,
763                    CXX11<"clang", "warn_unused_result">,
764                    CXX11<"gnu", "warn_unused_result">];
765 }
766
767 def Weak : InheritableAttr {
768   let Spellings = [GNU<"weak">, CXX11<"gnu", "weak">];
769 }
770
771 def WeakImport : InheritableAttr {
772   let Spellings = [GNU<"weak_import">];
773 }
774
775 def WeakRef : InheritableAttr {
776   let Spellings = [GNU<"weakref">, CXX11<"gnu", "weakref">];
777 }
778
779 def X86ForceAlignArgPointer : InheritableAttr {
780   let Spellings = [];
781 }
782
783 // Attribute to disable AddressSanitizer (or equivalent) checks.
784 def NoSanitizeAddress : InheritableAttr {
785   let Spellings = [GNU<"no_address_safety_analysis">,
786                    GNU<"no_sanitize_address">];
787 }
788
789 // Attribute to disable ThreadSanitizer checks.
790 def NoSanitizeThread : InheritableAttr {
791   let Spellings = [GNU<"no_sanitize_thread">];
792 }
793
794 // Attribute to disable MemorySanitizer checks.
795 def NoSanitizeMemory : InheritableAttr {
796   let Spellings = [GNU<"no_sanitize_memory">];
797 }
798
799 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
800
801 def GuardedVar : InheritableAttr {
802   let Spellings = [GNU<"guarded_var">];
803 }
804
805 def PtGuardedVar : InheritableAttr {
806   let Spellings = [GNU<"pt_guarded_var">];
807 }
808
809 def Lockable : InheritableAttr {
810   let Spellings = [GNU<"lockable">];
811 }
812
813 def ScopedLockable : InheritableAttr {
814   let Spellings = [GNU<"scoped_lockable">];
815 }
816
817 def NoThreadSafetyAnalysis : InheritableAttr {
818   let Spellings = [GNU<"no_thread_safety_analysis">];
819 }
820
821 def GuardedBy : InheritableAttr {
822   let Spellings = [GNU<"guarded_by">];
823   let Args = [ExprArgument<"Arg">];
824   let LateParsed = 1;
825   let TemplateDependent = 1;
826 }
827
828 def PtGuardedBy : InheritableAttr {
829   let Spellings = [GNU<"pt_guarded_by">];
830   let Args = [ExprArgument<"Arg">];
831   let LateParsed = 1;
832   let TemplateDependent = 1;
833 }
834
835 def AcquiredAfter : InheritableAttr {
836   let Spellings = [GNU<"acquired_after">];
837   let Args = [VariadicExprArgument<"Args">];
838   let LateParsed = 1;
839   let TemplateDependent = 1;
840 }
841
842 def AcquiredBefore : InheritableAttr {
843   let Spellings = [GNU<"acquired_before">];
844   let Args = [VariadicExprArgument<"Args">];
845   let LateParsed = 1;
846   let TemplateDependent = 1;
847 }
848
849 def ExclusiveLockFunction : InheritableAttr {
850   let Spellings = [GNU<"exclusive_lock_function">];
851   let Args = [VariadicExprArgument<"Args">];
852   let LateParsed = 1;
853   let TemplateDependent = 1;
854 }
855
856 def SharedLockFunction : InheritableAttr {
857   let Spellings = [GNU<"shared_lock_function">];
858   let Args = [VariadicExprArgument<"Args">];
859   let LateParsed = 1;
860   let TemplateDependent = 1;
861 }
862
863 // The first argument is an integer or boolean value specifying the return value
864 // of a successful lock acquisition.
865 def ExclusiveTrylockFunction : InheritableAttr {
866   let Spellings = [GNU<"exclusive_trylock_function">];
867   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
868   let LateParsed = 1;
869   let TemplateDependent = 1;
870 }
871
872 // The first argument is an integer or boolean value specifying the return value
873 // of a successful lock acquisition.
874 def SharedTrylockFunction : InheritableAttr {
875   let Spellings = [GNU<"shared_trylock_function">];
876   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
877   let LateParsed = 1;
878   let TemplateDependent = 1;
879 }
880
881 def UnlockFunction : InheritableAttr {
882   let Spellings = [GNU<"unlock_function">];
883   let Args = [VariadicExprArgument<"Args">];
884   let LateParsed = 1;
885   let TemplateDependent = 1;
886 }
887
888 def LockReturned : InheritableAttr {
889   let Spellings = [GNU<"lock_returned">];
890   let Args = [ExprArgument<"Arg">];
891   let LateParsed = 1;
892   let TemplateDependent = 1;
893 }
894
895 def LocksExcluded : InheritableAttr {
896   let Spellings = [GNU<"locks_excluded">];
897   let Args = [VariadicExprArgument<"Args">];
898   let LateParsed = 1;
899   let TemplateDependent = 1;
900 }
901
902 def ExclusiveLocksRequired : InheritableAttr {
903   let Spellings = [GNU<"exclusive_locks_required">];
904   let Args = [VariadicExprArgument<"Args">];
905   let LateParsed = 1;
906   let TemplateDependent = 1;
907 }
908
909 def SharedLocksRequired : InheritableAttr {
910   let Spellings = [GNU<"shared_locks_required">];
911   let Args = [VariadicExprArgument<"Args">];
912   let LateParsed = 1;
913   let TemplateDependent = 1;
914 }
915
916 // Type safety attributes for `void *' pointers and type tags.
917
918 def ArgumentWithTypeTag : InheritableAttr {
919   let Spellings = [GNU<"argument_with_type_tag">,
920                    GNU<"pointer_with_type_tag">];
921   let Args = [IdentifierArgument<"ArgumentKind">,
922               UnsignedArgument<"ArgumentIdx">,
923               UnsignedArgument<"TypeTagIdx">,
924               BoolArgument<"IsPointer">];
925   let Subjects = [Function];
926 }
927
928 def TypeTagForDatatype : InheritableAttr {
929   let Spellings = [GNU<"type_tag_for_datatype">];
930   let Args = [IdentifierArgument<"ArgumentKind">,
931               TypeArgument<"MatchingCType">,
932               BoolArgument<"LayoutCompatible">,
933               BoolArgument<"MustBeNull">];
934   let Subjects = [Var];
935 }
936
937 // Microsoft-related attributes
938
939 def MsProperty : Attr {
940   let Spellings = [Declspec<"property">];
941 }
942
943 def MsStruct : InheritableAttr {
944   let Spellings = [Declspec<"ms_struct">];
945 }
946
947 def DLLExport : InheritableAttr {
948   let Spellings = [Declspec<"dllexport">];
949 }
950
951 def DLLImport : InheritableAttr {
952   let Spellings = [Declspec<"dllimport">];
953 }
954
955 def ForceInline : InheritableAttr {
956   let Spellings = [Keyword<"__forceinline">];
957 }
958
959 def Win64 : InheritableAttr {
960   let Spellings = [Keyword<"__w64">];
961 }
962
963 def Ptr32 : InheritableAttr {
964   let Spellings = [Keyword<"__ptr32">];
965 }
966
967 def Ptr64 : InheritableAttr {
968   let Spellings = [Keyword<"__ptr64">];
969 }
970
971 class MSInheritanceAttr : InheritableAttr;
972
973 def SingleInheritance : MSInheritanceAttr {
974   let Spellings = [Keyword<"__single_inheritance">];
975 }
976
977 def MultipleInheritance : MSInheritanceAttr {
978   let Spellings = [Keyword<"__multiple_inheritance">];
979 }
980
981 def VirtualInheritance : MSInheritanceAttr {
982   let Spellings = [Keyword<"__virtual_inheritance">];
983 }
984
985 // This attribute doesn't have any spellings, but we can apply it implicitly to
986 // incomplete types that lack any of the other attributes.
987 def UnspecifiedInheritance : MSInheritanceAttr {
988   let Spellings = [];
989 }
990
991 def Unaligned : IgnoredAttr {
992   let Spellings = [Keyword<"__unaligned">];
993 }