]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/clang/include/clang/Basic/Attr.td
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / tools / clang / include / clang / Basic / Attr.td
1 //==--- Attr.td - attribute definitions -----------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // An attribute's subject is whatever it appertains to. In this file, it is
11 // more accurately a list of things that an attribute can appertain to. All
12 // Decls and Stmts are possibly AttrSubjects (even though the syntax may not
13 // allow attributes on a given Decl or Stmt).
14 class AttrSubject;
15
16 include "clang/Basic/DeclNodes.td"
17 include "clang/Basic/StmtNodes.td"
18
19 // A subset-subject is an AttrSubject constrained to operate only on some subset
20 // of that subject.
21 //
22 // The description is used in output messages to specify what the subject
23 // represents. FIXME: Deal with translation issues.
24 //
25 // The code fragment is a boolean expression that will confirm that the subject
26 // meets the requirements; the subject will have the name S, and will have the
27 // type specified by the base. It should be a simple boolean expression.
28 class SubsetSubject<AttrSubject base, string description, code check>
29     : AttrSubject {
30   AttrSubject Base = base;
31   string Description = description;
32   code CheckCode = check;
33 }
34
35 // This is the type of a variable which C++11 allows alignas(...) to appertain
36 // to.
37 def NormalVar : SubsetSubject<Var, "non-register, non-parameter variable",
38                               [{S->getStorageClass() != VarDecl::Register &&
39                                 S->getKind() != Decl::ImplicitParam &&
40                                 S->getKind() != Decl::ParmVar &&
41                                 S->getKind() != Decl::NonTypeTemplateParm}]>;
42 def NonBitField : SubsetSubject<Field, "non-bit field",
43                                 [{!S->isBitField()}]>;
44
45 // A single argument to an attribute
46 class Argument<string name, bit optional> {
47   string Name = name;
48   bit Optional = optional;
49 }
50
51 class BoolArgument<string name, bit opt = 0> : Argument<name, opt>;
52 class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>;
53 class IntArgument<string name, bit opt = 0> : Argument<name, opt>;
54 class StringArgument<string name, bit opt = 0> : Argument<name, opt>;
55 class ExprArgument<string name, bit opt = 0> : Argument<name, opt>;
56 class FunctionArgument<string name, bit opt = 0> : Argument<name, opt>;
57 class TypeArgument<string name, bit opt = 0> : Argument<name, opt>;
58 class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>;
59 class SourceLocArgument<string name, bit opt = 0> : Argument<name, opt>;
60 class VariadicUnsignedArgument<string name> : Argument<name, 1>;
61 class VariadicExprArgument<string name> : Argument<name, 1>;
62
63 // A version of the form major.minor[.subminor].
64 class VersionArgument<string name, bit opt = 0> : Argument<name, opt>;
65
66 // This one's a doozy, so it gets its own special type
67 // It can be an unsigned integer, or a type. Either can
68 // be dependent.
69 class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>;
70
71 // An integer argument with a default value
72 class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
73   int Default = default;
74 }
75
76 // This argument is more complex, it includes the enumerator type name,
77 // a list of strings to accept, and a list of enumerators to map them to.
78 class EnumArgument<string name, string type, list<string> values,
79                    list<string> enums, bit opt = 0> : Argument<name, opt> {
80   string Type = type;
81   list<string> Values = values;
82   list<string> Enums = enums;
83 }
84
85 // FIXME: There should be a VariadicArgument type that takes any other type
86 //        of argument and generates the appropriate type.
87 class VariadicEnumArgument<string name, string type, list<string> values,
88                            list<string> enums> : Argument<name, 1>  {
89   string Type = type;
90   list<string> Values = values;
91   list<string> Enums = enums;
92 }
93
94 // This handles one spelling of an attribute.
95 class Spelling<string name, string variety> {
96   string Name = name;
97   string Variety = variety;
98 }
99
100 class GNU<string name> : Spelling<name, "GNU">;
101 class Declspec<string name> : Spelling<name, "Declspec">;
102 class CXX11<string namespace, string name> : Spelling<name, "CXX11"> {
103   string Namespace = namespace;
104 }
105 class Keyword<string name> : Spelling<name, "Keyword">;
106
107 class Accessor<string name, list<Spelling> spellings> {
108   string Name = name;
109   list<Spelling> Spellings = spellings;
110 }
111
112 class Attr {
113   // The various ways in which an attribute can be spelled in source
114   list<Spelling> Spellings;
115   // The things to which an attribute can appertain
116   list<AttrSubject> Subjects;
117   // The arguments allowed on an attribute
118   list<Argument> Args = [];
119   // Accessors which should be generated for the attribute.
120   list<Accessor> Accessors = [];
121   // Set to true for attributes with arguments which require delayed parsing.
122   bit LateParsed = 0;
123   // Set to false to prevent an attribute from being propagated from a template
124   // to the instantiation.
125   bit Clone = 1;
126   // Set to true for attributes which must be instantiated within templates
127   bit TemplateDependent = 0;
128   // Set to true for attributes that have a corresponding AST node.
129   bit ASTNode = 1;
130   // Set to true for attributes which have handler in Sema.
131   bit SemaHandler = 1;
132   // Set to true for attributes that are completely ignored.
133   bit Ignored = 0;
134   // Set to true if each of the spellings is a distinct attribute.
135   bit DistinctSpellings = 0;
136   // Set to true if the attribute's parsing does not match its semantic
137   // content. Eg) It parses 3 args, but semantically takes 4 args.  Opts out of
138   // common attribute error checking.
139   bit HasCustomParsing = 0;
140   // Any additional text that should be included verbatim in the class.
141   code AdditionalMembers = [{}];
142 }
143
144 /// A type attribute is not processed on a declaration or a statement.
145 class TypeAttr : Attr {
146   let ASTNode = 0;
147 }
148
149 /// An inheritable attribute is inherited by later redeclarations.
150 class InheritableAttr : Attr;
151
152 /// A target-specific attribute that is meant to be processed via
153 /// TargetAttributesSema::ProcessDeclAttribute.  This class is meant to be used
154 /// as a mixin with InheritableAttr or Attr depending on the attribute's needs.
155 class TargetSpecificAttr;
156
157 /// An inheritable parameter attribute is inherited by later
158 /// redeclarations, even when it's written on a parameter.
159 class InheritableParamAttr : InheritableAttr;
160
161 /// An ignored attribute, which we parse but discard with no checking.
162 class IgnoredAttr : Attr {
163   let Ignored = 1;
164   let ASTNode = 0;
165   let SemaHandler = 0;
166 }
167
168 //
169 // Attributes begin here
170 //
171
172 def AddressSpace : TypeAttr {
173   let Spellings = [GNU<"address_space">];
174   let Args = [IntArgument<"AddressSpace">];
175 }
176
177 def Alias : Attr {
178   let Spellings = [GNU<"alias">, CXX11<"gnu", "alias">];
179   let Args = [StringArgument<"Aliasee">];
180 }
181
182 def Aligned : InheritableAttr {
183   let Spellings = [GNU<"aligned">, Declspec<"align">, CXX11<"gnu", "aligned">,
184                    Keyword<"alignas">, Keyword<"_Alignas">];
185   let Subjects = [NonBitField, NormalVar, Tag];
186   let Args = [AlignedArgument<"Alignment", 1>];
187   let Accessors = [Accessor<"isGNU", [GNU<"aligned">, CXX11<"gnu","aligned">]>,
188                    Accessor<"isC11", [Keyword<"_Alignas">]>,
189                    Accessor<"isAlignas", [Keyword<"alignas">,
190                                           Keyword<"_Alignas">]>,
191                    Accessor<"isDeclspec",[Declspec<"align">]>];
192 }
193
194 def AlignMac68k : InheritableAttr {
195   let Spellings = [];
196   let SemaHandler = 0;
197 }
198
199 def AllocSize : InheritableAttr {
200   let Spellings = [GNU<"alloc_size">, CXX11<"gnu", "alloc_size">];
201   let Args = [VariadicUnsignedArgument<"Args">];
202 }
203
204 def AlwaysInline : InheritableAttr {
205   let Spellings = [GNU<"always_inline">, CXX11<"gnu", "always_inline">];
206 }
207
208 def TLSModel : InheritableAttr {
209   let Spellings = [GNU<"tls_model">, CXX11<"gnu", "tls_model">];
210   let Subjects = [Var];
211   let Args = [StringArgument<"Model">];
212 }
213
214 def AnalyzerNoReturn : InheritableAttr {
215   let Spellings = [GNU<"analyzer_noreturn">];
216 }
217
218 def Annotate : InheritableParamAttr {
219   let Spellings = [GNU<"annotate">];
220   let Args = [StringArgument<"Annotation">];
221 }
222
223 def ARMInterrupt : InheritableAttr, TargetSpecificAttr {
224   let Spellings = [GNU<"interrupt">];
225   let Args = [EnumArgument<"Interrupt", "InterruptType",
226                            ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
227                            ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
228                            1>];
229 }
230
231 def AsmLabel : InheritableAttr {
232   let Spellings = [];
233   let Args = [StringArgument<"Label">];
234   let SemaHandler = 0;
235 }
236
237 def Availability : InheritableAttr {
238   let Spellings = [GNU<"availability">];
239   let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
240               VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
241               BoolArgument<"unavailable">, StringArgument<"message">];
242   let AdditionalMembers =
243 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
244     return llvm::StringSwitch<llvm::StringRef>(Platform)
245              .Case("ios", "iOS")
246              .Case("macosx", "OS X")
247              .Default(llvm::StringRef());
248 } }];
249   let HasCustomParsing = 1;
250 }
251
252 def Blocks : InheritableAttr {
253   let Spellings = [GNU<"blocks">];
254   let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
255 }
256
257 def Bounded : IgnoredAttr {
258   let Spellings = [GNU<"bounded">];
259 }
260
261 def CarriesDependency : InheritableParamAttr {
262   let Spellings = [GNU<"carries_dependency">, CXX11<"","carries_dependency">,
263                    CXX11<"std","carries_dependency">];
264   let Subjects = [ParmVar, Function];
265 }
266
267 def CDecl : InheritableAttr {
268   let Spellings = [GNU<"cdecl">, CXX11<"gnu", "cdecl">, Keyword<"__cdecl">,
269                    Keyword<"_cdecl">];
270 }
271
272 // cf_audited_transfer indicates that the given function has been
273 // audited and has been marked with the appropriate cf_consumed and
274 // cf_returns_retained attributes.  It is generally applied by
275 // '#pragma clang arc_cf_code_audited' rather than explicitly.
276 def CFAuditedTransfer : InheritableAttr {
277   let Spellings = [GNU<"cf_audited_transfer">];
278   let Subjects = [Function];
279 }
280
281 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
282 // It indicates that the function has unknown or unautomatable
283 // transfer semantics.
284 def CFUnknownTransfer : InheritableAttr {
285   let Spellings = [GNU<"cf_unknown_transfer">];
286   let Subjects = [Function];
287 }
288
289 def CFReturnsRetained : InheritableAttr {
290   let Spellings = [GNU<"cf_returns_retained">];
291   let Subjects = [ObjCMethod, Function];
292 }
293
294 def CFReturnsNotRetained : InheritableAttr {
295   let Spellings = [GNU<"cf_returns_not_retained">];
296   let Subjects = [ObjCMethod, Function];
297 }
298
299 def CFConsumed : InheritableParamAttr {
300   let Spellings = [GNU<"cf_consumed">];
301   let Subjects = [ParmVar];
302 }
303
304 def Cleanup : InheritableAttr {
305   let Spellings = [GNU<"cleanup">, CXX11<"gnu", "cleanup">];
306   let Args = [FunctionArgument<"FunctionDecl">];
307 }
308
309 def Cold : InheritableAttr {
310   let Spellings = [GNU<"cold">, CXX11<"gnu", "cold">];
311 }
312
313 def Common : InheritableAttr {
314   let Spellings = [GNU<"common">, CXX11<"gnu", "common">];
315 }
316
317 def Const : InheritableAttr {
318   let Spellings = [GNU<"const">, GNU<"__const">,
319                    CXX11<"gnu", "const">, CXX11<"gnu", "__const">];
320 }
321
322 def Constructor : InheritableAttr {
323   let Spellings = [GNU<"constructor">, CXX11<"gnu", "constructor">];
324   let Args = [IntArgument<"Priority", 1>];
325 }
326
327 def CUDAConstant : InheritableAttr {
328   let Spellings = [GNU<"constant">];
329 }
330
331 def CUDADevice : InheritableAttr {
332   let Spellings = [GNU<"device">];
333 }
334
335 def CUDAGlobal : InheritableAttr {
336   let Spellings = [GNU<"global">];
337 }
338
339 def CUDAHost : InheritableAttr {
340   let Spellings = [GNU<"host">];
341 }
342
343 def CUDALaunchBounds : InheritableAttr {
344   let Spellings = [GNU<"launch_bounds">];
345   let Args = [IntArgument<"MaxThreads">, DefaultIntArgument<"MinBlocks", 0>];
346 }
347
348 def CUDAShared : InheritableAttr {
349   let Spellings = [GNU<"shared">];
350 }
351
352 def C11NoReturn : InheritableAttr {
353   let Spellings = [Keyword<"_Noreturn">];
354   let Subjects = [Function];
355   let SemaHandler = 0;
356 }
357
358 def CXX11NoReturn : InheritableAttr {
359   let Spellings = [CXX11<"","noreturn">, CXX11<"std","noreturn">];
360   let Subjects = [Function];
361 }
362
363 def OpenCLKernel : InheritableAttr {
364   let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
365 }
366
367 def OpenCLImageAccess : Attr {
368   let Spellings = [GNU<"opencl_image_access">];
369   let Args = [IntArgument<"Access">];
370 }
371
372 def Deprecated : InheritableAttr {
373   let Spellings = [GNU<"deprecated">,
374                    CXX11<"gnu", "deprecated">, CXX11<"","deprecated">];
375   let Args = [StringArgument<"Message", 1>];
376 }
377
378 def Destructor : InheritableAttr {
379   let Spellings = [GNU<"destructor">, CXX11<"gnu", "destructor">];
380   let Args = [IntArgument<"Priority", 1>];
381 }
382
383 def ExtVectorType : Attr {
384   let Spellings = [GNU<"ext_vector_type">];
385   let Args = [ExprArgument<"NumElements">];
386   let ASTNode = 0;
387 }
388
389 def FallThrough : Attr {
390   let Spellings = [CXX11<"clang", "fallthrough">];
391   let Subjects = [NullStmt];
392 }
393
394 def FastCall : InheritableAttr {
395   let Spellings = [GNU<"fastcall">, CXX11<"gnu", "fastcall">,
396                    Keyword<"__fastcall">, Keyword<"_fastcall">];
397 }
398
399 def Final : InheritableAttr {
400   let Spellings = [Keyword<"final">, Keyword<"sealed">];
401   let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
402   let SemaHandler = 0;
403 }
404
405 def MinSize : InheritableAttr {
406   let Spellings = [GNU<"minsize">];
407   let Subjects = [Function];
408 }
409
410 def Format : InheritableAttr {
411   let Spellings = [GNU<"format">, CXX11<"gnu", "format">];
412   let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
413               IntArgument<"FirstArg">];
414 }
415
416 def FormatArg : InheritableAttr {
417   let Spellings = [GNU<"format_arg">, CXX11<"gnu", "format_arg">];
418   let Args = [IntArgument<"FormatIdx">];
419 }
420
421 def GNUInline : InheritableAttr {
422   let Spellings = [GNU<"gnu_inline">, CXX11<"gnu", "gnu_inline">];
423 }
424
425 def Hot : InheritableAttr {
426   let Spellings = [GNU<"hot">, CXX11<"gnu", "hot">];
427 }
428
429 def IBAction : InheritableAttr {
430   let Spellings = [GNU<"ibaction">];
431 }
432
433 def IBOutlet : InheritableAttr {
434   let Spellings = [GNU<"iboutlet">];
435 }
436
437 def IBOutletCollection : InheritableAttr {
438   let Spellings = [GNU<"iboutletcollection">];
439   let Args = [TypeArgument<"Interface", 1>];
440 }
441
442 def Malloc : InheritableAttr {
443   let Spellings = [GNU<"malloc">, CXX11<"gnu", "malloc">];
444 }
445
446 def MaxFieldAlignment : InheritableAttr {
447   let Spellings = [];
448   let Args = [UnsignedArgument<"Alignment">];
449   let SemaHandler = 0;
450 }
451
452 def MayAlias : InheritableAttr {
453   let Spellings = [GNU<"may_alias">, CXX11<"gnu", "may_alias">];
454 }
455
456 def MSABI : InheritableAttr {
457   let Spellings = [GNU<"ms_abi">, CXX11<"gnu", "ms_abi">];
458 }
459
460 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr {
461   let Spellings = [];
462   let Args = [UnsignedArgument<"Number">];
463   let SemaHandler = 0;
464 }
465
466 def Mips16 : InheritableAttr, TargetSpecificAttr {
467   let Spellings = [GNU<"mips16">, CXX11<"gnu", "mips16">];
468   let Subjects = [Function];
469 }
470
471 def Mode : Attr {
472   let Spellings = [GNU<"mode">, CXX11<"gnu", "mode">];
473   let Args = [IdentifierArgument<"Mode">];
474 }
475
476 def Naked : InheritableAttr {
477   let Spellings = [GNU<"naked">, CXX11<"gnu", "naked">];
478 }
479
480 def NeonPolyVectorType : TypeAttr {
481   let Spellings = [GNU<"neon_polyvector_type">];
482   let Args = [IntArgument<"NumElements">];
483 }
484
485 def NeonVectorType : TypeAttr {
486   let Spellings = [GNU<"neon_vector_type">];
487   let Args = [IntArgument<"NumElements">];
488 }
489
490 def ReturnsTwice : InheritableAttr {
491   let Spellings = [GNU<"returns_twice">, CXX11<"gnu", "returns_twice">];
492 }
493
494 def NoCommon : InheritableAttr {
495   let Spellings = [GNU<"nocommon">, CXX11<"gnu", "nocommon">];
496 }
497
498 def NoDebug : InheritableAttr {
499   let Spellings = [GNU<"nodebug">];
500 }
501
502 def NoInline : InheritableAttr {
503   let Spellings = [GNU<"noinline">, CXX11<"gnu", "noinline">];
504 }
505
506 def NoMips16 : InheritableAttr, TargetSpecificAttr {
507   let Spellings = [GNU<"nomips16">, CXX11<"gnu", "nomips16">];
508   let Subjects = [Function];
509 }
510
511 def NonNull : InheritableAttr {
512   let Spellings = [GNU<"nonnull">, CXX11<"gnu", "nonnull">];
513   let Args = [VariadicUnsignedArgument<"Args">];
514   let AdditionalMembers =
515 [{bool isNonNull(unsigned idx) const {
516     for (args_iterator i = args_begin(), e = args_end();
517          i != e; ++i)
518       if (*i == idx)
519         return true;
520     return false;
521   } }];
522 }
523
524 def NoReturn : InheritableAttr {
525   let Spellings = [GNU<"noreturn">, CXX11<"gnu", "noreturn">];
526   // FIXME: Does GCC allow this on the function instead?
527   let Subjects = [Function];
528 }
529
530 def NoInstrumentFunction : InheritableAttr {
531   let Spellings = [GNU<"no_instrument_function">,
532                    CXX11<"gnu", "no_instrument_function">];
533   let Subjects = [Function];
534 }
535
536 def NoThrow : InheritableAttr {
537   let Spellings = [GNU<"nothrow">, CXX11<"gnu", "nothrow">];
538 }
539
540 def NSBridged : InheritableAttr {
541   let Spellings = [GNU<"ns_bridged">];
542   let Subjects = [Record];
543   let Args = [IdentifierArgument<"BridgedType", 1>];
544 }
545
546 def ObjCBridge : InheritableAttr {
547   let Spellings = [GNU<"objc_bridge">];
548   let Subjects = [Record];
549   let Args = [IdentifierArgument<"BridgedType", 1>];
550 }
551
552 def NSReturnsRetained : InheritableAttr {
553   let Spellings = [GNU<"ns_returns_retained">];
554   let Subjects = [ObjCMethod, Function];
555 }
556
557 def NSReturnsNotRetained : InheritableAttr {
558   let Spellings = [GNU<"ns_returns_not_retained">];
559   let Subjects = [ObjCMethod, Function];
560 }
561
562 def NSReturnsAutoreleased : InheritableAttr {
563   let Spellings = [GNU<"ns_returns_autoreleased">];
564   let Subjects = [ObjCMethod, Function];
565 }
566
567 def NSConsumesSelf : InheritableAttr {
568   let Spellings = [GNU<"ns_consumes_self">];
569   let Subjects = [ObjCMethod];
570 }
571
572 def NSConsumed : InheritableParamAttr {
573   let Spellings = [GNU<"ns_consumed">];
574   let Subjects = [ParmVar];
575 }
576
577 def ObjCException : InheritableAttr {
578   let Spellings = [GNU<"objc_exception">];
579 }
580
581 def ObjCMethodFamily : InheritableAttr {
582   let Spellings = [GNU<"objc_method_family">];
583   let Subjects = [ObjCMethod];
584   let Args = [EnumArgument<"Family", "FamilyKind",
585                ["none", "alloc", "copy", "init", "mutableCopy", "new"],
586                ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
587                 "OMF_mutableCopy", "OMF_new"]>];
588 }
589
590 def ObjCNSObject : InheritableAttr {
591   let Spellings = [GNU<"NSObject">];
592 }
593
594 def ObjCPreciseLifetime : InheritableAttr {
595   let Spellings = [GNU<"objc_precise_lifetime">];
596   let Subjects = [Var];
597 }
598
599 def ObjCReturnsInnerPointer : InheritableAttr {
600   let Spellings = [GNU<"objc_returns_inner_pointer">];
601   let Subjects = [ObjCMethod, ObjCProperty];
602 }
603
604 def ObjCRequiresSuper : InheritableAttr {
605   let Spellings = [GNU<"objc_requires_super">];
606   let Subjects = [ObjCMethod];
607 }
608
609 def ObjCRootClass : InheritableAttr {
610   let Spellings = [GNU<"objc_root_class">];
611   let Subjects = [ObjCInterface];
612 }
613
614 def Overloadable : Attr {
615   let Spellings = [GNU<"overloadable">];
616 }
617
618 def Override : InheritableAttr { 
619   let Spellings = [];
620   let SemaHandler = 0;
621 }
622
623 def Ownership : InheritableAttr {
624   let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
625                    GNU<"ownership_takes">];
626   let DistinctSpellings = 1;
627   let Args = [EnumArgument<"OwnKind", "OwnershipKind",
628                     ["ownership_holds", "ownership_returns", "ownership_takes"],
629                     ["Holds", "Returns", "Takes"]>,
630               StringArgument<"Module">, VariadicUnsignedArgument<"Args">];
631   let HasCustomParsing = 1;
632 }
633
634 def Packed : InheritableAttr {
635   let Spellings = [GNU<"packed">, CXX11<"gnu", "packed">];
636 }
637
638 def PnaclCall : InheritableAttr {
639   let Spellings = [GNU<"pnaclcall">];
640 }
641
642 def IntelOclBicc : InheritableAttr {
643   let Spellings = [GNU<"intel_ocl_bicc">];
644 }
645
646 def Pcs : InheritableAttr {
647   let Spellings = [GNU<"pcs">, CXX11<"gnu", "pcs">];
648   let Args = [EnumArgument<"PCS", "PCSType",
649                            ["aapcs", "aapcs-vfp"],
650                            ["AAPCS", "AAPCS_VFP"]>];
651 }
652
653 def Pure : InheritableAttr {
654   let Spellings = [GNU<"pure">, CXX11<"gnu", "pure">];
655 }
656
657 def Regparm : InheritableAttr {
658   let Spellings = [GNU<"regparm">, CXX11<"gnu", "regparm">];
659   let Args = [UnsignedArgument<"NumParams">];
660 }
661
662 def ReqdWorkGroupSize : InheritableAttr {
663   let Spellings = [GNU<"reqd_work_group_size">];
664   let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
665               UnsignedArgument<"ZDim">];
666 }
667
668 def WorkGroupSizeHint :  InheritableAttr {
669   let Spellings = [GNU<"work_group_size_hint">];
670   let Args = [UnsignedArgument<"XDim">, 
671               UnsignedArgument<"YDim">,
672               UnsignedArgument<"ZDim">];
673 }
674
675 def InitPriority : InheritableAttr {
676   let Spellings = [GNU<"init_priority">];
677   let Args = [UnsignedArgument<"Priority">];
678 }
679
680 def Section : InheritableAttr {
681   let Spellings = [GNU<"section">, CXX11<"gnu", "section">];
682   let Args = [StringArgument<"Name">];
683 }
684
685 def Sentinel : InheritableAttr {
686   let Spellings = [GNU<"sentinel">, CXX11<"gnu", "sentinel">];
687   let Args = [DefaultIntArgument<"Sentinel", 0>,
688               DefaultIntArgument<"NullPos", 0>];
689 }
690
691 def StdCall : InheritableAttr {
692   let Spellings = [GNU<"stdcall">, CXX11<"gnu", "stdcall">,
693                    Keyword<"__stdcall">, Keyword<"_stdcall">];
694 }
695
696 def SysVABI : InheritableAttr {
697   let Spellings = [GNU<"sysv_abi">, CXX11<"gnu", "sysv_abi">];
698 }
699
700 def ThisCall : InheritableAttr {
701   let Spellings = [GNU<"thiscall">, CXX11<"gnu", "thiscall">,
702                    Keyword<"__thiscall">, Keyword<"_thiscall">];
703 }
704
705 def Pascal : InheritableAttr {
706   let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
707 }
708
709 def TransparentUnion : InheritableAttr {
710   let Spellings = [GNU<"transparent_union">, CXX11<"gnu", "transparent_union">];
711 }
712
713 def Unavailable : InheritableAttr {
714   let Spellings = [GNU<"unavailable">];
715   let Args = [StringArgument<"Message", 1>];
716 }
717
718 def ArcWeakrefUnavailable : InheritableAttr {
719   let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
720   let Subjects = [ObjCInterface];
721 }
722
723 def ObjCGC : TypeAttr {
724   let Spellings = [GNU<"objc_gc">];
725   let Args = [IdentifierArgument<"Kind">];
726 }
727
728 def ObjCOwnership : InheritableAttr {
729   let Spellings = [GNU<"objc_ownership">];
730   let Args = [IdentifierArgument<"Kind">];
731   let ASTNode = 0;
732 }
733
734 def ObjCRequiresPropertyDefs : InheritableAttr {
735   let Spellings = [GNU<"objc_requires_property_definitions">];
736   let Subjects = [ObjCInterface];
737 }
738
739 def Unused : InheritableAttr {
740   let Spellings = [GNU<"unused">, CXX11<"gnu", "unused">];
741 }
742
743 def Used : InheritableAttr {
744   let Spellings = [GNU<"used">, CXX11<"gnu", "used">];
745 }
746
747 def Uuid : InheritableAttr {
748   let Spellings = [GNU<"uuid">];
749   let Args = [StringArgument<"Guid">];
750   let Subjects = [CXXRecord];
751 }
752
753 def VectorSize : TypeAttr {
754   let Spellings = [GNU<"vector_size">, CXX11<"gnu", "vector_size">];
755   let Args = [ExprArgument<"NumBytes">];
756 }
757
758 def VecTypeHint : InheritableAttr {
759   let Spellings = [GNU<"vec_type_hint">];
760   let Args = [TypeArgument<"TypeHint">];
761 }
762
763 def Visibility : InheritableAttr {
764   let Clone = 0;
765   let Spellings = [GNU<"visibility">, CXX11<"gnu", "visibility">];
766   let Args = [EnumArgument<"Visibility", "VisibilityType",
767                            ["default", "hidden", "internal", "protected"],
768                            ["Default", "Hidden", "Hidden", "Protected"]>];
769 }
770
771 def TypeVisibility : InheritableAttr {
772   let Clone = 0;
773   let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">];
774   let Args = [EnumArgument<"Visibility", "VisibilityType",
775                            ["default", "hidden", "internal", "protected"],
776                            ["Default", "Hidden", "Hidden", "Protected"]>];
777 }
778
779 def VecReturn : InheritableAttr {
780   let Spellings = [GNU<"vecreturn">];
781   let Subjects = [CXXRecord];
782 }
783
784 def WarnUnused : InheritableAttr {
785   let Spellings = [GNU<"warn_unused">];
786   let Subjects = [Record];
787 }
788
789 def WarnUnusedResult : InheritableAttr {
790   let Spellings = [GNU<"warn_unused_result">,
791                    CXX11<"clang", "warn_unused_result">,
792                    CXX11<"gnu", "warn_unused_result">];
793 }
794
795 def Weak : InheritableAttr {
796   let Spellings = [GNU<"weak">, CXX11<"gnu", "weak">];
797 }
798
799 def WeakImport : InheritableAttr {
800   let Spellings = [GNU<"weak_import">];
801 }
802
803 def WeakRef : InheritableAttr {
804   let Spellings = [GNU<"weakref">, CXX11<"gnu", "weakref">];
805   // A WeakRef that has an argument is treated as being an AliasAttr
806   let Args = [StringArgument<"Aliasee", 1>];
807 }
808
809 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr {
810   let Spellings = [];
811 }
812
813 // Attribute to disable AddressSanitizer (or equivalent) checks.
814 def NoSanitizeAddress : InheritableAttr {
815   let Spellings = [GNU<"no_address_safety_analysis">,
816                    GNU<"no_sanitize_address">,
817                    CXX11<"gnu", "no_address_safety_analysis">,
818                    CXX11<"gnu", "no_sanitize_address">];
819 }
820
821 // Attribute to disable ThreadSanitizer checks.
822 def NoSanitizeThread : InheritableAttr {
823   let Spellings = [GNU<"no_sanitize_thread">];
824 }
825
826 // Attribute to disable MemorySanitizer checks.
827 def NoSanitizeMemory : InheritableAttr {
828   let Spellings = [GNU<"no_sanitize_memory">];
829 }
830
831 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
832
833 def GuardedVar : InheritableAttr {
834   let Spellings = [GNU<"guarded_var">];
835 }
836
837 def PtGuardedVar : InheritableAttr {
838   let Spellings = [GNU<"pt_guarded_var">];
839 }
840
841 def Lockable : InheritableAttr {
842   let Spellings = [GNU<"lockable">];
843 }
844
845 def ScopedLockable : InheritableAttr {
846   let Spellings = [GNU<"scoped_lockable">];
847 }
848
849 def NoThreadSafetyAnalysis : InheritableAttr {
850   let Spellings = [GNU<"no_thread_safety_analysis">];
851 }
852
853 def GuardedBy : InheritableAttr {
854   let Spellings = [GNU<"guarded_by">];
855   let Args = [ExprArgument<"Arg">];
856   let LateParsed = 1;
857   let TemplateDependent = 1;
858 }
859
860 def PtGuardedBy : InheritableAttr {
861   let Spellings = [GNU<"pt_guarded_by">];
862   let Args = [ExprArgument<"Arg">];
863   let LateParsed = 1;
864   let TemplateDependent = 1;
865 }
866
867 def AcquiredAfter : InheritableAttr {
868   let Spellings = [GNU<"acquired_after">];
869   let Args = [VariadicExprArgument<"Args">];
870   let LateParsed = 1;
871   let TemplateDependent = 1;
872 }
873
874 def AcquiredBefore : InheritableAttr {
875   let Spellings = [GNU<"acquired_before">];
876   let Args = [VariadicExprArgument<"Args">];
877   let LateParsed = 1;
878   let TemplateDependent = 1;
879 }
880
881 def ExclusiveLockFunction : InheritableAttr {
882   let Spellings = [GNU<"exclusive_lock_function">];
883   let Args = [VariadicExprArgument<"Args">];
884   let LateParsed = 1;
885   let TemplateDependent = 1;
886 }
887
888 def SharedLockFunction : InheritableAttr {
889   let Spellings = [GNU<"shared_lock_function">];
890   let Args = [VariadicExprArgument<"Args">];
891   let LateParsed = 1;
892   let TemplateDependent = 1;
893 }
894
895 def AssertExclusiveLock : InheritableAttr {
896   let Spellings = [GNU<"assert_exclusive_lock">];
897   let Args = [VariadicExprArgument<"Args">];
898   let LateParsed = 1;
899   let TemplateDependent = 1;
900 }
901
902 def AssertSharedLock : InheritableAttr {
903   let Spellings = [GNU<"assert_shared_lock">];
904   let Args = [VariadicExprArgument<"Args">];
905   let LateParsed = 1;
906   let TemplateDependent = 1;
907 }
908
909 // The first argument is an integer or boolean value specifying the return value
910 // of a successful lock acquisition.
911 def ExclusiveTrylockFunction : InheritableAttr {
912   let Spellings = [GNU<"exclusive_trylock_function">];
913   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
914   let LateParsed = 1;
915   let TemplateDependent = 1;
916 }
917
918 // The first argument is an integer or boolean value specifying the return value
919 // of a successful lock acquisition.
920 def SharedTrylockFunction : InheritableAttr {
921   let Spellings = [GNU<"shared_trylock_function">];
922   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
923   let LateParsed = 1;
924   let TemplateDependent = 1;
925 }
926
927 def UnlockFunction : InheritableAttr {
928   let Spellings = [GNU<"unlock_function">];
929   let Args = [VariadicExprArgument<"Args">];
930   let LateParsed = 1;
931   let TemplateDependent = 1;
932 }
933
934 def LockReturned : InheritableAttr {
935   let Spellings = [GNU<"lock_returned">];
936   let Args = [ExprArgument<"Arg">];
937   let LateParsed = 1;
938   let TemplateDependent = 1;
939 }
940
941 def LocksExcluded : InheritableAttr {
942   let Spellings = [GNU<"locks_excluded">];
943   let Args = [VariadicExprArgument<"Args">];
944   let LateParsed = 1;
945   let TemplateDependent = 1;
946 }
947
948 def ExclusiveLocksRequired : InheritableAttr {
949   let Spellings = [GNU<"exclusive_locks_required">];
950   let Args = [VariadicExprArgument<"Args">];
951   let LateParsed = 1;
952   let TemplateDependent = 1;
953 }
954
955 def SharedLocksRequired : InheritableAttr {
956   let Spellings = [GNU<"shared_locks_required">];
957   let Args = [VariadicExprArgument<"Args">];
958   let LateParsed = 1;
959   let TemplateDependent = 1;
960 }
961
962 // C/C++ consumed attributes.
963
964 def Consumable : InheritableAttr {
965   let Spellings = [GNU<"consumable">];
966   let Subjects = [CXXRecord];
967   let Args = [EnumArgument<"DefaultState", "ConsumedState",
968                            ["unknown", "consumed", "unconsumed"],
969                            ["Unknown", "Consumed", "Unconsumed"]>];
970 }
971
972 def CallableWhen : InheritableAttr {
973   let Spellings = [GNU<"callable_when">];
974   let Subjects = [CXXMethod];
975   let Args = [VariadicEnumArgument<"CallableState", "ConsumedState",
976                                    ["unknown", "consumed", "unconsumed"],
977                                    ["Unknown", "Consumed", "Unconsumed"]>];
978 }
979
980 def ParamTypestate : InheritableAttr {
981   let Spellings = [GNU<"param_typestate">];
982   let Subjects = [ParmVar];
983   let Args = [EnumArgument<"ParamState", "ConsumedState",
984                            ["unknown", "consumed", "unconsumed"],
985                            ["Unknown", "Consumed", "Unconsumed"]>];
986 }
987
988 def ReturnTypestate : InheritableAttr {
989   let Spellings = [GNU<"return_typestate">];
990   let Subjects = [Function, ParmVar];
991   let Args = [EnumArgument<"State", "ConsumedState",
992                            ["unknown", "consumed", "unconsumed"],
993                            ["Unknown", "Consumed", "Unconsumed"]>];
994 }
995
996 def SetTypestate : InheritableAttr {
997   let Spellings = [GNU<"set_typestate">];
998   let Subjects = [CXXMethod];
999   let Args = [EnumArgument<"NewState", "ConsumedState",
1000                            ["unknown", "consumed", "unconsumed"],
1001                            ["Unknown", "Consumed", "Unconsumed"]>];
1002 }
1003
1004 def TestTypestate : InheritableAttr {
1005   let Spellings = [GNU<"test_typestate">];
1006   let Subjects = [CXXMethod];
1007   let Args = [EnumArgument<"TestState", "ConsumedState",
1008                            ["consumed", "unconsumed"],
1009                            ["Consumed", "Unconsumed"]>];
1010 }
1011
1012 // Type safety attributes for `void *' pointers and type tags.
1013
1014 def ArgumentWithTypeTag : InheritableAttr {
1015   let Spellings = [GNU<"argument_with_type_tag">,
1016                    GNU<"pointer_with_type_tag">];
1017   let Args = [IdentifierArgument<"ArgumentKind">,
1018               UnsignedArgument<"ArgumentIdx">,
1019               UnsignedArgument<"TypeTagIdx">,
1020               BoolArgument<"IsPointer">];
1021   let Subjects = [Function];
1022   let HasCustomParsing = 1;
1023 }
1024
1025 def TypeTagForDatatype : InheritableAttr {
1026   let Spellings = [GNU<"type_tag_for_datatype">];
1027   let Args = [IdentifierArgument<"ArgumentKind">,
1028               TypeArgument<"MatchingCType">,
1029               BoolArgument<"LayoutCompatible">,
1030               BoolArgument<"MustBeNull">];
1031   let Subjects = [Var];
1032   let HasCustomParsing = 1;
1033 }
1034
1035 // Microsoft-related attributes
1036
1037 def MsProperty : IgnoredAttr {
1038   let Spellings = [Declspec<"property">];
1039 }
1040
1041 def MsStruct : InheritableAttr {
1042   let Spellings = [Declspec<"ms_struct">];
1043 }
1044
1045 def DLLExport : InheritableAttr, TargetSpecificAttr {
1046   let Spellings = [Declspec<"dllexport">];
1047 }
1048
1049 def DLLImport : InheritableAttr, TargetSpecificAttr {
1050   let Spellings = [Declspec<"dllimport">];
1051 }
1052
1053 def ForceInline : InheritableAttr {
1054   let Spellings = [Keyword<"__forceinline">];
1055 }
1056
1057 def SelectAny : InheritableAttr {
1058   let Spellings = [Declspec<"selectany">];
1059 }
1060
1061 def Win64 : InheritableAttr {
1062   let Spellings = [Keyword<"__w64">];
1063 }
1064
1065 def Ptr32 : TypeAttr {
1066   let Spellings = [Keyword<"__ptr32">];
1067 }
1068
1069 def Ptr64 : TypeAttr {
1070   let Spellings = [Keyword<"__ptr64">];
1071 }
1072
1073 def SPtr : TypeAttr {
1074   let Spellings = [Keyword<"__sptr">];
1075 }
1076
1077 def UPtr : TypeAttr {
1078   let Spellings = [Keyword<"__uptr">];
1079 }
1080
1081 class MSInheritanceAttr : InheritableAttr;
1082
1083 def SingleInheritance : MSInheritanceAttr {
1084   let Spellings = [Keyword<"__single_inheritance">];
1085 }
1086
1087 def MultipleInheritance : MSInheritanceAttr {
1088   let Spellings = [Keyword<"__multiple_inheritance">];
1089 }
1090
1091 def VirtualInheritance : MSInheritanceAttr {
1092   let Spellings = [Keyword<"__virtual_inheritance">];
1093 }
1094
1095 // This attribute doesn't have any spellings, but we can apply it implicitly to
1096 // incomplete types that lack any of the other attributes.
1097 def UnspecifiedInheritance : MSInheritanceAttr {
1098   let Spellings = [];
1099 }
1100
1101 def Unaligned : IgnoredAttr {
1102   let Spellings = [Keyword<"__unaligned">];
1103 }