]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Basic/Attr.td
Update llvm, clang and lldb to 3.7.0 release.
[FreeBSD/FreeBSD.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 // The documentation is organized by category. Attributes can have category-
11 // specific documentation that is collated within the larger document.
12 class DocumentationCategory<string name> {
13   string Name = name;
14   code Content = [{}];
15 }
16 def DocCatFunction : DocumentationCategory<"Function Attributes">;
17 def DocCatVariable : DocumentationCategory<"Variable Attributes">;
18 def DocCatType : DocumentationCategory<"Type Attributes">;
19 def DocCatStmt : DocumentationCategory<"Statement Attributes">;
20 // Attributes listed under the Undocumented category do not generate any public
21 // documentation. Ideally, this category should be used for internal-only
22 // attributes which contain no spellings.
23 def DocCatUndocumented : DocumentationCategory<"Undocumented">;
24
25 class DocDeprecated<string replacement = ""> {
26   // If the Replacement field is empty, no replacement will be listed with the
27   // documentation. Otherwise, the documentation will specify the attribute has
28   // been superseded by this replacement.
29   string Replacement = replacement;
30 }
31
32 // Specifies the documentation to be associated with the given category.
33 class Documentation {
34   DocumentationCategory Category;
35   code Content;
36
37   // If the heading is empty, one may be picked automatically. If the attribute
38   // only has one spelling, no heading is required as the attribute's sole
39   // spelling is sufficient. If all spellings are semantically common, the
40   // heading will be the semantic spelling. If the spellings are not
41   // semantically common and no heading is provided, an error will be emitted.
42   string Heading = "";
43
44   // When set, specifies that the attribute is deprecated and can optionally
45   // specify a replacement attribute.
46   DocDeprecated Deprecated;
47 }
48
49 // Specifies that the attribute is explicitly undocumented. This can be a
50 // helpful placeholder for the attribute while working on the implementation,
51 // but should not be used once feature work has been completed.
52 def Undocumented : Documentation {
53   let Category = DocCatUndocumented;
54 }
55
56 include "clang/Basic/AttrDocs.td"
57
58 // An attribute's subject is whatever it appertains to. In this file, it is
59 // more accurately a list of things that an attribute can appertain to. All
60 // Decls and Stmts are possibly AttrSubjects (even though the syntax may not
61 // allow attributes on a given Decl or Stmt).
62 class AttrSubject;
63
64 include "clang/Basic/DeclNodes.td"
65 include "clang/Basic/StmtNodes.td"
66
67 // A subset-subject is an AttrSubject constrained to operate only on some subset
68 // of that subject.
69 //
70 // The code fragment is a boolean expression that will confirm that the subject
71 // meets the requirements; the subject will have the name S, and will have the
72 // type specified by the base. It should be a simple boolean expression.
73 class SubsetSubject<AttrSubject base, code check> : AttrSubject {
74   AttrSubject Base = base;
75   code CheckCode = check;
76 }
77
78 // This is the type of a variable which C++11 allows alignas(...) to appertain
79 // to.
80 def NormalVar : SubsetSubject<Var,
81                               [{S->getStorageClass() != VarDecl::Register &&
82                                 S->getKind() != Decl::ImplicitParam &&
83                                 S->getKind() != Decl::ParmVar &&
84                                 S->getKind() != Decl::NonTypeTemplateParm}]>;
85 def NonBitField : SubsetSubject<Field,
86                                 [{!S->isBitField()}]>;
87
88 def ObjCInstanceMethod : SubsetSubject<ObjCMethod,
89                                        [{S->isInstanceMethod()}]>;
90
91 def ObjCInterfaceDeclInitMethod : SubsetSubject<ObjCMethod,
92                                [{S->getMethodFamily() == OMF_init &&
93                                  (isa<ObjCInterfaceDecl>(S->getDeclContext()) ||
94                                   (isa<ObjCCategoryDecl>(S->getDeclContext()) &&
95             cast<ObjCCategoryDecl>(S->getDeclContext())->IsClassExtension()))}]>;
96
97 def Struct : SubsetSubject<Record,
98                            [{!S->isUnion()}]>;
99
100 def TLSVar : SubsetSubject<Var,
101                            [{S->getTLSKind() != 0}]>;
102
103 def SharedVar : SubsetSubject<Var,
104                               [{S->hasGlobalStorage() && !S->getTLSKind()}]>;
105
106 def GlobalVar : SubsetSubject<Var,
107                              [{S->hasGlobalStorage()}]>;
108
109 // FIXME: this hack is needed because DeclNodes.td defines the base Decl node
110 // type to be a class, not a definition. This makes it impossible to create an
111 // attribute subject which accepts a Decl. Normally, this is not a problem,
112 // because the attribute can have no Subjects clause to accomplish this. But in
113 // the case of a SubsetSubject, there's no way to express it without this hack.
114 def DeclBase : AttrSubject;
115 def FunctionLike : SubsetSubject<DeclBase,
116                                   [{S->getFunctionType(false) != NULL}]>;
117
118 def OpenCLKernelFunction : SubsetSubject<Function, [{
119   S->hasAttr<OpenCLKernelAttr>()
120 }]>;
121
122 // HasFunctionProto is a more strict version of FunctionLike, so it should
123 // never be specified in a Subjects list along with FunctionLike (due to the
124 // inclusive nature of subject testing).
125 def HasFunctionProto : SubsetSubject<DeclBase,
126                                      [{(S->getFunctionType(true) != NULL &&
127                               isa<FunctionProtoType>(S->getFunctionType())) ||
128                                        isa<ObjCMethodDecl>(S) ||
129                                        isa<BlockDecl>(S)}]>;
130
131 // A single argument to an attribute
132 class Argument<string name, bit optional> {
133   string Name = name;
134   bit Optional = optional;
135 }
136
137 class BoolArgument<string name, bit opt = 0> : Argument<name, opt>;
138 class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>;
139 class IntArgument<string name, bit opt = 0> : Argument<name, opt>;
140 class StringArgument<string name, bit opt = 0> : Argument<name, opt>;
141 class ExprArgument<string name, bit opt = 0> : Argument<name, opt>;
142 class FunctionArgument<string name, bit opt = 0> : Argument<name, opt>;
143 class TypeArgument<string name, bit opt = 0> : Argument<name, opt>;
144 class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>;
145 class VariadicUnsignedArgument<string name> : Argument<name, 1>;
146 class VariadicExprArgument<string name> : Argument<name, 1>;
147 class VariadicStringArgument<string name> : Argument<name, 1>;
148
149 // A version of the form major.minor[.subminor].
150 class VersionArgument<string name, bit opt = 0> : Argument<name, opt>;
151
152 // This one's a doozy, so it gets its own special type
153 // It can be an unsigned integer, or a type. Either can
154 // be dependent.
155 class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>;
156
157 // A bool argument with a default value
158 class DefaultBoolArgument<string name, bit default> : BoolArgument<name, 1> {
159   bit Default = default;
160 }
161
162 // An integer argument with a default value
163 class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
164   int Default = default;
165 }
166
167 // This argument is more complex, it includes the enumerator type name,
168 // a list of strings to accept, and a list of enumerators to map them to.
169 class EnumArgument<string name, string type, list<string> values,
170                    list<string> enums, bit opt = 0> : Argument<name, opt> {
171   string Type = type;
172   list<string> Values = values;
173   list<string> Enums = enums;
174 }
175
176 // FIXME: There should be a VariadicArgument type that takes any other type
177 //        of argument and generates the appropriate type.
178 class VariadicEnumArgument<string name, string type, list<string> values,
179                            list<string> enums> : Argument<name, 1>  {
180   string Type = type;
181   list<string> Values = values;
182   list<string> Enums = enums;
183 }
184
185 // This handles one spelling of an attribute.
186 class Spelling<string name, string variety> {
187   string Name = name;
188   string Variety = variety;
189   bit KnownToGCC;
190 }
191
192 class GNU<string name> : Spelling<name, "GNU">;
193 class Declspec<string name> : Spelling<name, "Declspec">;
194 class CXX11<string namespace, string name, int version = 1>
195     : Spelling<name, "CXX11"> {
196   string Namespace = namespace;
197   int Version = version;
198 }
199 class Keyword<string name> : Spelling<name, "Keyword">;
200 class Pragma<string namespace, string name> : Spelling<name, "Pragma"> {
201   string Namespace = namespace;
202 }
203
204 // The GCC spelling implies GNU<name, "GNU"> and CXX11<"gnu", name> and also
205 // sets KnownToGCC to 1. This spelling should be used for any GCC-compatible
206 // attributes.
207 class GCC<string name> : Spelling<name, "GCC"> {
208   let KnownToGCC = 1;
209 }
210
211 class Accessor<string name, list<Spelling> spellings> {
212   string Name = name;
213   list<Spelling> Spellings = spellings;
214 }
215
216 class SubjectDiag<bit warn> {
217   bit Warn = warn;
218 }
219 def WarnDiag : SubjectDiag<1>;
220 def ErrorDiag : SubjectDiag<0>;
221
222 class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag,
223                   string customDiag = ""> {
224   list<AttrSubject> Subjects = subjects;
225   SubjectDiag Diag = diag;
226   string CustomDiag = customDiag;
227 }
228
229 class LangOpt<string name, bit negated = 0> {
230   string Name = name;
231   bit Negated = negated;
232 }
233 def MicrosoftExt : LangOpt<"MicrosoftExt">;
234 def Borland : LangOpt<"Borland">;
235 def CUDA : LangOpt<"CUDA">;
236 def COnly : LangOpt<"CPlusPlus", 1>;
237
238 // Defines targets for target-specific attributes. The list of strings should
239 // specify architectures for which the target applies, based off the ArchType
240 // enumeration in Triple.h.
241 class TargetArch<list<string> arches> {
242   list<string> Arches = arches;
243   list<string> OSes;
244 }
245 def TargetARM : TargetArch<["arm", "thumb"]>;
246 def TargetMSP430 : TargetArch<["msp430"]>;
247 def TargetX86 : TargetArch<["x86"]>;
248 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
249   let OSes = ["Win32"];
250 }
251 def TargetMips : TargetArch<["mips", "mipsel"]>;
252
253 class Attr {
254   // The various ways in which an attribute can be spelled in source
255   list<Spelling> Spellings;
256   // The things to which an attribute can appertain
257   SubjectList Subjects;
258   // The arguments allowed on an attribute
259   list<Argument> Args = [];
260   // Accessors which should be generated for the attribute.
261   list<Accessor> Accessors = [];
262   // Set to true for attributes with arguments which require delayed parsing.
263   bit LateParsed = 0;
264   // Set to false to prevent an attribute from being propagated from a template
265   // to the instantiation.
266   bit Clone = 1;
267   // Set to true for attributes which must be instantiated within templates
268   bit TemplateDependent = 0;
269   // Set to true for attributes that have a corresponding AST node.
270   bit ASTNode = 1;
271   // Set to true for attributes which have handler in Sema.
272   bit SemaHandler = 1;
273   // Set to true for attributes that are completely ignored.
274   bit Ignored = 0;
275   // Set to true if the attribute's parsing does not match its semantic
276   // content. Eg) It parses 3 args, but semantically takes 4 args.  Opts out of
277   // common attribute error checking.
278   bit HasCustomParsing = 0;
279   // Set to true if all of the attribute's arguments should be parsed in an
280   // unevaluated context.
281   bit ParseArgumentsAsUnevaluated = 0;
282   // Set to true if this attribute can be duplicated on a subject when merging
283   // attributes. By default, attributes are not merged.
284   bit DuplicatesAllowedWhileMerging = 0;
285   // Lists language options, one of which is required to be true for the
286   // attribute to be applicable. If empty, no language options are required.
287   list<LangOpt> LangOpts = [];
288   // Any additional text that should be included verbatim in the class.
289   code AdditionalMembers = [{}];
290   // Any documentation that should be associated with the attribute. Since an
291   // attribute may be documented under multiple categories, more than one
292   // Documentation entry may be listed.
293   list<Documentation> Documentation;
294 }
295
296 /// A type attribute is not processed on a declaration or a statement.
297 class TypeAttr : Attr {
298   // By default, type attributes do not get an AST node.
299   let ASTNode = 0;
300 }
301
302 /// An inheritable attribute is inherited by later redeclarations.
303 class InheritableAttr : Attr;
304
305 /// A target-specific attribute.  This class is meant to be used as a mixin
306 /// with InheritableAttr or Attr depending on the attribute's needs.
307 class TargetSpecificAttr<TargetArch target> {
308   TargetArch Target = target;
309   // Attributes are generally required to have unique spellings for their names
310   // so that the parser can determine what kind of attribute it has parsed.
311   // However, target-specific attributes are special in that the attribute only
312   // "exists" for a given target. So two target-specific attributes can share
313   // the same name when they exist in different targets. To support this, a
314   // Kind can be explicitly specified for a target-specific attribute. This
315   // corresponds to the AttributeList::AT_* enum that is generated and it
316   // should contain a shared value between the attributes.
317   //
318   // Target-specific attributes which use this feature should ensure that the
319   // spellings match exactly betweeen the attributes, and if the arguments or
320   // subjects differ, should specify HasCustomParsing = 1 and implement their
321   // own parsing and semantic handling requirements as-needed.
322   string ParseKind;
323 }
324
325 /// An inheritable parameter attribute is inherited by later
326 /// redeclarations, even when it's written on a parameter.
327 class InheritableParamAttr : InheritableAttr;
328
329 /// An ignored attribute, which we parse but discard with no checking.
330 class IgnoredAttr : Attr {
331   let Ignored = 1;
332   let ASTNode = 0;
333   let SemaHandler = 0;
334   let Documentation = [Undocumented];
335 }
336
337 //
338 // Attributes begin here
339 //
340
341 def AddressSpace : TypeAttr {
342   let Spellings = [GNU<"address_space">];
343   let Args = [IntArgument<"AddressSpace">];
344   let Documentation = [Undocumented];
345 }
346
347 def Alias : Attr {
348   let Spellings = [GCC<"alias">];
349   let Args = [StringArgument<"Aliasee">];
350   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
351                              "ExpectedFunctionGlobalVarMethodOrProperty">;
352   let Documentation = [Undocumented];
353 }
354
355 def Aligned : InheritableAttr {
356   let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">,
357                    Keyword<"_Alignas">];
358 //  let Subjects = SubjectList<[NonBitField, NormalVar, Tag]>;
359   let Args = [AlignedArgument<"Alignment", 1>];
360   let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
361                    Accessor<"isC11", [Keyword<"_Alignas">]>,
362                    Accessor<"isAlignas", [Keyword<"alignas">,
363                                           Keyword<"_Alignas">]>,
364                    Accessor<"isDeclspec",[Declspec<"align">]>];
365   let Documentation = [Undocumented];
366 }
367
368 def AlignValue : Attr {
369   let Spellings = [
370     // Unfortunately, this is semantically an assertion, not a directive
371     // (something else must ensure the alignment), so aligned_value is a
372     // probably a better name. We might want to add an aligned_value spelling in
373     // the future (and a corresponding C++ attribute), but this can be done
374     // later once we decide if we also want them to have slightly-different
375     // semantics than Intel's align_value.
376     GNU<"align_value">
377     // Intel's compiler on Windows also supports:
378     // , Declspec<"align_value">
379   ];
380   let Args = [ExprArgument<"Alignment">];
381   let Subjects = SubjectList<[Var, TypedefName], WarnDiag,
382                              "ExpectedVariableOrTypedef">;
383   let Documentation = [AlignValueDocs];
384 }
385
386 def AlignMac68k : InheritableAttr {
387   // This attribute has no spellings as it is only ever created implicitly.
388   let Spellings = [];
389   let SemaHandler = 0;
390   let Documentation = [Undocumented];
391 }
392
393 def AlwaysInline : InheritableAttr {
394   let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
395   let Subjects = SubjectList<[Function]>;
396   let Documentation = [Undocumented];
397 }
398
399 def TLSModel : InheritableAttr {
400   let Spellings = [GCC<"tls_model">];
401   let Subjects = SubjectList<[TLSVar], ErrorDiag, "ExpectedTLSVar">;
402   let Args = [StringArgument<"Model">];
403   let Documentation = [TLSModelDocs];
404 }
405
406 def AnalyzerNoReturn : InheritableAttr {
407   let Spellings = [GNU<"analyzer_noreturn">];
408   let Documentation = [Undocumented];
409 }
410
411 def Annotate : InheritableParamAttr {
412   let Spellings = [GNU<"annotate">];
413   let Args = [StringArgument<"Annotation">];
414   let Documentation = [Undocumented];
415 }
416
417 def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> {
418   // NOTE: If you add any additional spellings, MSP430Interrupt's spellings
419   // must match.
420   let Spellings = [GNU<"interrupt">];
421   let Args = [EnumArgument<"Interrupt", "InterruptType",
422                            ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
423                            ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
424                            1>];
425   let ParseKind = "Interrupt";
426   let HasCustomParsing = 1;
427   let Documentation = [ARMInterruptDocs];
428 }
429
430 def AsmLabel : InheritableAttr {
431   let Spellings = [Keyword<"asm">, Keyword<"__asm__">];
432   let Args = [StringArgument<"Label">];
433   let SemaHandler = 0;
434   let Documentation = [Undocumented];
435 }
436
437 def Availability : InheritableAttr {
438   let Spellings = [GNU<"availability">];
439   let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
440               VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
441               BoolArgument<"unavailable">, StringArgument<"message">];
442   let AdditionalMembers =
443 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
444     return llvm::StringSwitch<llvm::StringRef>(Platform)
445              .Case("android", "Android")
446              .Case("ios", "iOS")
447              .Case("macosx", "OS X")
448              .Case("ios_app_extension", "iOS (App Extension)")
449              .Case("macosx_app_extension", "OS X (App Extension)")
450              .Default(llvm::StringRef());
451 } }];
452   let HasCustomParsing = 1;
453   let DuplicatesAllowedWhileMerging = 1;
454 //  let Subjects = SubjectList<[Named]>;
455   let Documentation = [AvailabilityDocs];
456 }
457
458 def Blocks : InheritableAttr {
459   let Spellings = [GNU<"blocks">];
460   let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
461   let Documentation = [Undocumented];
462 }
463
464 def Bounded : IgnoredAttr {
465   let Spellings = [GNU<"bounded">];
466 }
467
468 def CarriesDependency : InheritableParamAttr {
469   let Spellings = [GNU<"carries_dependency">,
470                    CXX11<"","carries_dependency", 200809>];
471   let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>;
472   let Documentation = [CarriesDependencyDocs];
473 }
474
475 def CDecl : InheritableAttr {
476   let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">];
477 //  let Subjects = [Function, ObjCMethod];
478   let Documentation = [Undocumented];
479 }
480
481 // cf_audited_transfer indicates that the given function has been
482 // audited and has been marked with the appropriate cf_consumed and
483 // cf_returns_retained attributes.  It is generally applied by
484 // '#pragma clang arc_cf_code_audited' rather than explicitly.
485 def CFAuditedTransfer : InheritableAttr {
486   let Spellings = [GNU<"cf_audited_transfer">];
487   let Subjects = SubjectList<[Function], ErrorDiag>;
488   let Documentation = [Undocumented];
489 }
490
491 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
492 // It indicates that the function has unknown or unautomatable
493 // transfer semantics.
494 def CFUnknownTransfer : InheritableAttr {
495   let Spellings = [GNU<"cf_unknown_transfer">];
496   let Subjects = SubjectList<[Function], ErrorDiag>;
497   let Documentation = [Undocumented];
498 }
499
500 def CFReturnsRetained : InheritableAttr {
501   let Spellings = [GNU<"cf_returns_retained">];
502 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
503   let Documentation = [Undocumented];
504 }
505
506 def CFReturnsNotRetained : InheritableAttr {
507   let Spellings = [GNU<"cf_returns_not_retained">];
508 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
509   let Documentation = [Undocumented];
510 }
511
512 def CFConsumed : InheritableParamAttr {
513   let Spellings = [GNU<"cf_consumed">];
514   let Subjects = SubjectList<[ParmVar]>;
515   let Documentation = [Undocumented];
516 }
517
518 def Cleanup : InheritableAttr {
519   let Spellings = [GCC<"cleanup">];
520   let Args = [FunctionArgument<"FunctionDecl">];
521   let Subjects = SubjectList<[Var]>;
522   let Documentation = [Undocumented];
523 }
524
525 def Cold : InheritableAttr {
526   let Spellings = [GCC<"cold">];
527   let Subjects = SubjectList<[Function]>;
528   let Documentation = [Undocumented];
529 }
530
531 def Common : InheritableAttr {
532   let Spellings = [GCC<"common">];
533   let Subjects = SubjectList<[Var]>;
534   let Documentation = [Undocumented];
535 }
536
537 def Const : InheritableAttr {
538   let Spellings = [GCC<"const">, GCC<"__const">];
539   let Documentation = [Undocumented];
540 }
541
542 def Constructor : InheritableAttr {
543   let Spellings = [GCC<"constructor">];
544   let Args = [DefaultIntArgument<"Priority", 65535>];
545   let Subjects = SubjectList<[Function]>;
546   let Documentation = [Undocumented];
547 }
548
549 def CUDAConstant : InheritableAttr {
550   let Spellings = [GNU<"constant">];
551   let Subjects = SubjectList<[Var]>;
552   let LangOpts = [CUDA];
553   let Documentation = [Undocumented];
554 }
555
556 def CUDADevice : InheritableAttr {
557   let Spellings = [GNU<"device">];
558   let Subjects = SubjectList<[Function, Var]>;
559   let LangOpts = [CUDA];
560   let Documentation = [Undocumented];
561 }
562
563 def CUDAGlobal : InheritableAttr {
564   let Spellings = [GNU<"global">];
565   let Subjects = SubjectList<[Function]>;
566   let LangOpts = [CUDA];
567   let Documentation = [Undocumented];
568 }
569
570 def CUDAHost : InheritableAttr {
571   let Spellings = [GNU<"host">];
572   let Subjects = SubjectList<[Function]>;
573   let LangOpts = [CUDA];
574   let Documentation = [Undocumented];
575 }
576
577 def CUDAInvalidTarget : InheritableAttr {
578   let Spellings = [];
579   let Subjects = SubjectList<[Function]>;
580   let LangOpts = [CUDA];
581   let Documentation = [Undocumented];
582 }
583
584 def CUDALaunchBounds : InheritableAttr {
585   let Spellings = [GNU<"launch_bounds">];
586   let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>];
587   let LangOpts = [CUDA];
588   let Subjects = SubjectList<[ObjCMethod, FunctionLike], WarnDiag,
589                              "ExpectedFunctionOrMethod">;
590   // An AST node is created for this attribute, but is not used by other parts
591   // of the compiler. However, this node needs to exist in the AST because
592   // non-LLVM backends may be relying on the attribute's presence.
593   let Documentation = [Undocumented];
594 }
595
596 def CUDAShared : InheritableAttr {
597   let Spellings = [GNU<"shared">];
598   let Subjects = SubjectList<[Var]>;
599   let LangOpts = [CUDA];
600   let Documentation = [Undocumented];
601 }
602
603 def C11NoReturn : InheritableAttr {
604   let Spellings = [Keyword<"_Noreturn">];
605   let Subjects = SubjectList<[Function], ErrorDiag>;
606   let SemaHandler = 0;
607   let Documentation = [C11NoReturnDocs];
608 }
609
610 def CXX11NoReturn : InheritableAttr {
611   let Spellings = [CXX11<"","noreturn", 200809>];
612   let Subjects = SubjectList<[Function], ErrorDiag>;
613   let Documentation = [CXX11NoReturnDocs];
614 }
615
616 def OpenCLKernel : InheritableAttr {
617   let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
618   let Subjects = SubjectList<[Function], ErrorDiag>;
619   let Documentation = [Undocumented];
620 }
621
622 // This attribute is both a type attribute, and a declaration attribute (for
623 // parameter variables).
624 def OpenCLImageAccess : Attr {
625   let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
626                    Keyword<"__write_only">, Keyword<"write_only">,
627                    Keyword<"__read_write">, Keyword<"read_write">];
628   let Subjects = SubjectList<[ParmVar], ErrorDiag>;
629   let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
630                                            Keyword<"read_only">]>,
631                    Accessor<"isReadWrite", [Keyword<"__read_write">,
632                                             Keyword<"read_write">]>,
633                    Accessor<"isWriteOnly", [Keyword<"__write_only">,
634                                             Keyword<"write_only">]>];
635   let Documentation = [Undocumented];
636 }
637
638 def OpenCLPrivateAddressSpace : TypeAttr {
639   let Spellings = [Keyword<"__private">, Keyword<"private">];
640   let Documentation = [OpenCLAddressSpacePrivateDocs];
641 }
642
643 def OpenCLGlobalAddressSpace : TypeAttr {
644   let Spellings = [Keyword<"__global">, Keyword<"global">];
645   let Documentation = [OpenCLAddressSpaceGlobalDocs];
646 }
647
648 def OpenCLLocalAddressSpace : TypeAttr {
649   let Spellings = [Keyword<"__local">, Keyword<"local">];
650   let Documentation = [OpenCLAddressSpaceLocalDocs];
651 }
652
653 def OpenCLConstantAddressSpace : TypeAttr {
654   let Spellings = [Keyword<"__constant">, Keyword<"constant">];
655   let Documentation = [OpenCLAddressSpaceConstantDocs];
656 }
657
658 def OpenCLGenericAddressSpace : TypeAttr {
659   let Spellings = [Keyword<"__generic">, Keyword<"generic">];
660   let Documentation = [OpenCLAddressSpaceGenericDocs];
661 }
662
663 def Deprecated : InheritableAttr {
664   let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
665                    CXX11<"","deprecated", 201309>];
666   let Args = [StringArgument<"Message", 1>];
667   let Documentation = [Undocumented];
668 }
669
670 def Destructor : InheritableAttr {
671   let Spellings = [GCC<"destructor">];
672   let Args = [DefaultIntArgument<"Priority", 65535>];
673   let Subjects = SubjectList<[Function]>;
674   let Documentation = [Undocumented];
675 }
676
677 def EnableIf : InheritableAttr {
678   let Spellings = [GNU<"enable_if">];
679   let Subjects = SubjectList<[Function]>;
680   let Args = [ExprArgument<"Cond">, StringArgument<"Message">];
681   let TemplateDependent = 1;
682   let Documentation = [EnableIfDocs];
683 }
684
685 def ExtVectorType : Attr {
686   let Spellings = [GNU<"ext_vector_type">];
687   let Subjects = SubjectList<[TypedefName], ErrorDiag>;
688   let Args = [ExprArgument<"NumElements">];
689   let ASTNode = 0;
690   let Documentation = [Undocumented];
691 }
692
693 def FallThrough : Attr {
694   let Spellings = [CXX11<"clang", "fallthrough">];
695 //  let Subjects = [NullStmt];
696   let Documentation = [FallthroughDocs];
697 }
698
699 def FastCall : InheritableAttr {
700   let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
701                    Keyword<"_fastcall">];
702 //  let Subjects = [Function, ObjCMethod];
703   let Documentation = [FastCallDocs];
704 }
705
706 def Final : InheritableAttr {
707   let Spellings = [Keyword<"final">, Keyword<"sealed">];
708   let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
709   let SemaHandler = 0;
710   let Documentation = [Undocumented];
711 }
712
713 def MinSize : InheritableAttr {
714   let Spellings = [GNU<"minsize">];
715   let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
716   let Documentation = [Undocumented];
717 }
718
719 def FlagEnum : InheritableAttr {
720   let Spellings = [GNU<"flag_enum">];
721   let Subjects = SubjectList<[Enum]>;
722   let Documentation = [FlagEnumDocs];
723   let LangOpts = [COnly];
724   let AdditionalMembers = [{
725 private:
726     llvm::APInt FlagBits;
727 public:
728     llvm::APInt &getFlagBits() {
729       return FlagBits;
730     }
731
732     const llvm::APInt &getFlagBits() const {
733       return FlagBits;
734     }
735 }];
736 }
737
738 def Flatten : InheritableAttr {
739   let Spellings = [GCC<"flatten">];
740   let Subjects = SubjectList<[Function], ErrorDiag>;
741   let Documentation = [FlattenDocs];
742 }
743
744 def Format : InheritableAttr {
745   let Spellings = [GCC<"format">];
746   let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
747               IntArgument<"FirstArg">];
748   let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto], WarnDiag,
749                              "ExpectedFunction">;
750   let Documentation = [FormatDocs];
751 }
752
753 def FormatArg : InheritableAttr {
754   let Spellings = [GCC<"format_arg">];
755   let Args = [IntArgument<"FormatIdx">];
756   let Subjects = SubjectList<[ObjCMethod, HasFunctionProto], WarnDiag,
757                              "ExpectedFunction">;
758   let Documentation = [Undocumented];
759 }
760
761 def GNUInline : InheritableAttr {
762   let Spellings = [GCC<"gnu_inline">];
763   let Subjects = SubjectList<[Function]>;
764   let Documentation = [Undocumented];
765 }
766
767 def Hot : InheritableAttr {
768   let Spellings = [GCC<"hot">];
769   let Subjects = SubjectList<[Function]>;
770   // An AST node is created for this attribute, but not actually used beyond
771   // semantic checking for mutual exclusion with the Cold attribute.
772   let Documentation = [Undocumented];
773 }
774
775 def IBAction : InheritableAttr {
776   let Spellings = [GNU<"ibaction">];
777   let Subjects = SubjectList<[ObjCInstanceMethod], WarnDiag,
778                              "ExpectedObjCInstanceMethod">;
779   // An AST node is created for this attribute, but is not used by other parts
780   // of the compiler. However, this node needs to exist in the AST because
781   // external tools rely on it.
782   let Documentation = [Undocumented];
783 }
784
785 def IBOutlet : InheritableAttr {
786   let Spellings = [GNU<"iboutlet">];
787 //  let Subjects = [ObjCIvar, ObjCProperty];
788   let Documentation = [Undocumented];
789 }
790
791 def IBOutletCollection : InheritableAttr {
792   let Spellings = [GNU<"iboutletcollection">];
793   let Args = [TypeArgument<"Interface", 1>];
794 //  let Subjects = [ObjCIvar, ObjCProperty];
795   let Documentation = [Undocumented];
796 }
797
798 def Restrict : InheritableAttr {
799   let Spellings = [Declspec<"restrict">, GCC<"malloc">];
800   let Subjects = SubjectList<[Function]>;
801   let Documentation = [Undocumented];
802 }
803
804 def MaxFieldAlignment : InheritableAttr {
805   // This attribute has no spellings as it is only ever created implicitly.
806   let Spellings = [];
807   let Args = [UnsignedArgument<"Alignment">];
808   let SemaHandler = 0;
809   let Documentation = [Undocumented];
810 }
811
812 def MayAlias : InheritableAttr {
813   // FIXME: this is a type attribute in GCC, but a declaration attribute here.
814   let Spellings = [GCC<"may_alias">];
815   let Documentation = [Undocumented];
816 }
817
818 def MSABI : InheritableAttr {
819   let Spellings = [GCC<"ms_abi">];
820 //  let Subjects = [Function, ObjCMethod];
821   let Documentation = [MSABIDocs];
822 }
823
824 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
825   // NOTE: If you add any additional spellings, ARMInterrupt's spellings must
826   // match.
827   let Spellings = [GNU<"interrupt">];
828   let Args = [UnsignedArgument<"Number">];
829   let ParseKind = "Interrupt";
830   let HasCustomParsing = 1;
831   let Documentation = [Undocumented];
832 }
833
834 def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
835   let Spellings = [GCC<"mips16">];
836   let Subjects = SubjectList<[Function], ErrorDiag>;
837   let Documentation = [Undocumented];
838 }
839
840 def Mode : Attr {
841   let Spellings = [GCC<"mode">];
842   let Args = [IdentifierArgument<"Mode">];
843   let Documentation = [Undocumented];
844 }
845
846 def Naked : InheritableAttr {
847   let Spellings = [GCC<"naked">, Declspec<"naked">];
848   let Subjects = SubjectList<[Function]>;
849   let Documentation = [Undocumented];
850 }
851
852 def NeonPolyVectorType : TypeAttr {
853   let Spellings = [GNU<"neon_polyvector_type">];
854   let Args = [IntArgument<"NumElements">];
855   let Documentation = [Undocumented];
856 }
857
858 def NeonVectorType : TypeAttr {
859   let Spellings = [GNU<"neon_vector_type">];
860   let Args = [IntArgument<"NumElements">];
861   let Documentation = [Undocumented];
862 }
863
864 def ReturnsTwice : InheritableAttr {
865   let Spellings = [GCC<"returns_twice">];
866   let Subjects = SubjectList<[Function]>;
867   let Documentation = [Undocumented];
868 }
869
870 def NoCommon : InheritableAttr {
871   let Spellings = [GCC<"nocommon">];
872   let Subjects = SubjectList<[Var]>;
873   let Documentation = [Undocumented];
874 }
875
876 def NoDebug : InheritableAttr {
877   let Spellings = [GCC<"nodebug">];
878   let Documentation = [Undocumented];
879 }
880
881 def NoDuplicate : InheritableAttr {
882   let Spellings = [GNU<"noduplicate">, CXX11<"clang", "noduplicate">];
883   let Subjects = SubjectList<[Function]>;
884   let Documentation = [NoDuplicateDocs];
885 }
886
887 def NoInline : InheritableAttr {
888   let Spellings = [GCC<"noinline">, Declspec<"noinline">];
889   let Subjects = SubjectList<[Function]>;
890   let Documentation = [Undocumented];
891 }
892
893 def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
894   let Spellings = [GCC<"nomips16">];
895   let Subjects = SubjectList<[Function], ErrorDiag>;
896   let Documentation = [Undocumented];
897 }
898
899 // This is not a TargetSpecificAttr so that is silently accepted and
900 // ignored on other targets as encouraged by the OpenCL spec.
901 //
902 // See OpenCL 1.2 6.11.5: "It is our intention that a particular
903 // implementation of OpenCL be free to ignore all attributes and the
904 // resulting executable binary will produce the same result."
905 //
906 // However, only AMD GPU targets will emit the corresponding IR
907 // attribute.
908 //
909 // FIXME: This provides a sub-optimal error message if you attempt to
910 // use this in CUDA, since CUDA does not use the same terminology.
911 def AMDGPUNumVGPR : InheritableAttr {
912   let Spellings = [GNU<"amdgpu_num_vgpr">];
913   let Args = [UnsignedArgument<"NumVGPR">];
914   let Documentation = [AMDGPUNumVGPRDocs];
915
916 // FIXME: This should be for OpenCLKernelFunction, but is not to
917 // workaround needing to see kernel attribute before others to know if
918 // this should be rejected on non-kernels.
919   let Subjects = SubjectList<[Function], ErrorDiag,
920                              "ExpectedKernelFunction">;
921 }
922
923 def AMDGPUNumSGPR : InheritableAttr {
924   let Spellings = [GNU<"amdgpu_num_sgpr">];
925   let Args = [UnsignedArgument<"NumSGPR">];
926   let Documentation = [AMDGPUNumSGPRDocs];
927   let Subjects = SubjectList<[Function], ErrorDiag,
928                               "ExpectedKernelFunction">;
929 }
930
931 def NoSplitStack : InheritableAttr {
932   let Spellings = [GCC<"no_split_stack">];
933   let Subjects = SubjectList<[Function], ErrorDiag>;
934   let Documentation = [NoSplitStackDocs];
935 }
936
937 def NonNull : InheritableAttr {
938   let Spellings = [GCC<"nonnull">];
939   let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
940                              "ExpectedFunctionMethodOrParameter">;
941   let Args = [VariadicUnsignedArgument<"Args">];
942   let AdditionalMembers =
943 [{bool isNonNull(unsigned idx) const {
944     if (!args_size())
945       return true;
946     for (const auto &V : args())
947       if (V == idx)
948         return true;
949     return false;
950   } }];
951   // FIXME: We should merge duplicates into a single nonnull attribute.
952   let DuplicatesAllowedWhileMerging = 1;
953   let Documentation = [NonNullDocs];
954 }
955
956 def ReturnsNonNull : InheritableAttr {
957   let Spellings = [GCC<"returns_nonnull">];
958   let Subjects = SubjectList<[ObjCMethod, Function], WarnDiag,
959                              "ExpectedFunctionOrMethod">;
960   let Documentation = [ReturnsNonNullDocs];
961 }
962
963 // Nullability type attributes.
964 def TypeNonNull : TypeAttr {
965   let Spellings = [Keyword<"_Nonnull">];
966   let Documentation = [TypeNonNullDocs];
967 }
968
969 def TypeNullable : TypeAttr {
970   let Spellings = [Keyword<"_Nullable">];
971   let Documentation = [TypeNullableDocs];
972 }
973
974 def TypeNullUnspecified : TypeAttr {
975   let Spellings = [Keyword<"_Null_unspecified">];
976   let Documentation = [TypeNullUnspecifiedDocs];
977 }
978
979 def ObjCKindOf : TypeAttr {
980   let Spellings = [Keyword<"__kindof">];
981   let Documentation = [Undocumented];
982 }
983
984 def AssumeAligned : InheritableAttr {
985   let Spellings = [GCC<"assume_aligned">];
986   let Subjects = SubjectList<[ObjCMethod, Function]>;
987   let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>];
988   let Documentation = [AssumeAlignedDocs];
989 }
990
991 def NoReturn : InheritableAttr {
992   let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
993   // FIXME: Does GCC allow this on the function instead?
994   let Documentation = [Undocumented];
995 }
996
997 def NoInstrumentFunction : InheritableAttr {
998   let Spellings = [GCC<"no_instrument_function">];
999   let Subjects = SubjectList<[Function]>;
1000   let Documentation = [Undocumented];
1001 }
1002
1003 def NoThrow : InheritableAttr {
1004   let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
1005   let Documentation = [Undocumented];
1006 }
1007
1008 def ObjCBridge : InheritableAttr {
1009   let Spellings = [GNU<"objc_bridge">];
1010   let Subjects = SubjectList<[Record, TypedefName], ErrorDiag,
1011                              "ExpectedStructOrUnionOrTypedef">;
1012   let Args = [IdentifierArgument<"BridgedType">];
1013   let Documentation = [Undocumented];
1014 }
1015
1016 def ObjCBridgeMutable : InheritableAttr {
1017   let Spellings = [GNU<"objc_bridge_mutable">];
1018   let Subjects = SubjectList<[Record], ErrorDiag>;
1019   let Args = [IdentifierArgument<"BridgedType">];
1020   let Documentation = [Undocumented];
1021 }
1022
1023 def ObjCBridgeRelated : InheritableAttr {
1024   let Spellings = [GNU<"objc_bridge_related">];
1025   let Subjects = SubjectList<[Record], ErrorDiag>;
1026   let Args = [IdentifierArgument<"RelatedClass">,
1027           IdentifierArgument<"ClassMethod">,
1028           IdentifierArgument<"InstanceMethod">];
1029   let HasCustomParsing = 1;
1030   let Documentation = [Undocumented];
1031 }
1032
1033 def NSReturnsRetained : InheritableAttr {
1034   let Spellings = [GNU<"ns_returns_retained">];
1035 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1036   let Documentation = [Undocumented];
1037 }
1038
1039 def NSReturnsNotRetained : InheritableAttr {
1040   let Spellings = [GNU<"ns_returns_not_retained">];
1041 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1042   let Documentation = [Undocumented];
1043 }
1044
1045 def NSReturnsAutoreleased : InheritableAttr {
1046   let Spellings = [GNU<"ns_returns_autoreleased">];
1047 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1048   let Documentation = [Undocumented];
1049 }
1050
1051 def NSConsumesSelf : InheritableAttr {
1052   let Spellings = [GNU<"ns_consumes_self">];
1053   let Subjects = SubjectList<[ObjCMethod]>;
1054   let Documentation = [Undocumented];
1055 }
1056
1057 def NSConsumed : InheritableParamAttr {
1058   let Spellings = [GNU<"ns_consumed">];
1059   let Subjects = SubjectList<[ParmVar]>;
1060   let Documentation = [Undocumented];
1061 }
1062
1063 def ObjCException : InheritableAttr {
1064   let Spellings = [GNU<"objc_exception">];
1065   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1066   let Documentation = [Undocumented];
1067 }
1068
1069 def ObjCMethodFamily : InheritableAttr {
1070   let Spellings = [GNU<"objc_method_family">];
1071   let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1072   let Args = [EnumArgument<"Family", "FamilyKind",
1073                ["none", "alloc", "copy", "init", "mutableCopy", "new"],
1074                ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
1075                 "OMF_mutableCopy", "OMF_new"]>];
1076   let Documentation = [ObjCMethodFamilyDocs];
1077 }
1078
1079 def ObjCNSObject : InheritableAttr {
1080   let Spellings = [GNU<"NSObject">];
1081   let Documentation = [Undocumented];
1082 }
1083
1084 def ObjCIndependentClass : InheritableAttr {
1085   let Spellings = [GNU<"objc_independent_class">];
1086   let Documentation = [Undocumented];
1087 }
1088
1089 def ObjCPreciseLifetime : InheritableAttr {
1090   let Spellings = [GNU<"objc_precise_lifetime">];
1091   let Subjects = SubjectList<[Var], ErrorDiag>;
1092   let Documentation = [Undocumented];
1093 }
1094
1095 def ObjCReturnsInnerPointer : InheritableAttr {
1096   let Spellings = [GNU<"objc_returns_inner_pointer">];
1097   let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
1098   let Documentation = [Undocumented];
1099 }
1100
1101 def ObjCRequiresSuper : InheritableAttr {
1102   let Spellings = [GNU<"objc_requires_super">];
1103   let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1104   let Documentation = [ObjCRequiresSuperDocs];
1105 }
1106
1107 def ObjCRootClass : InheritableAttr {
1108   let Spellings = [GNU<"objc_root_class">];
1109   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1110   let Documentation = [Undocumented];
1111 }
1112
1113 def ObjCExplicitProtocolImpl : InheritableAttr {
1114   let Spellings = [GNU<"objc_protocol_requires_explicit_implementation">];
1115   let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
1116   let Documentation = [Undocumented];
1117 }
1118
1119 def ObjCDesignatedInitializer : Attr {
1120   let Spellings = [GNU<"objc_designated_initializer">];
1121   let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag,
1122                              "ExpectedObjCInterfaceDeclInitMethod">;
1123   let Documentation = [Undocumented];
1124 }
1125
1126 def ObjCRuntimeName : Attr {
1127   let Spellings = [GNU<"objc_runtime_name">];
1128   let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
1129   let Args = [StringArgument<"MetadataName">];
1130   let Documentation = [ObjCRuntimeNameDocs];
1131 }
1132
1133 def ObjCBoxable : Attr {
1134   let Spellings = [GNU<"objc_boxable">];
1135   let Subjects = SubjectList<[Record], ErrorDiag, "ExpectedStructOrUnion">;
1136   let Documentation = [ObjCBoxableDocs];
1137 }
1138
1139 def OptimizeNone : InheritableAttr {
1140   let Spellings = [GNU<"optnone">, CXX11<"clang", "optnone">];
1141   let Subjects = SubjectList<[Function, ObjCMethod]>;
1142   let Documentation = [OptnoneDocs];
1143 }
1144
1145 def Overloadable : Attr {
1146   let Spellings = [GNU<"overloadable">];
1147   let Subjects = SubjectList<[Function], ErrorDiag>;
1148   let Documentation = [OverloadableDocs];
1149 }
1150
1151 def Override : InheritableAttr { 
1152   let Spellings = [Keyword<"override">];
1153   let SemaHandler = 0;
1154   let Documentation = [Undocumented];
1155 }
1156
1157 def Ownership : InheritableAttr {
1158   let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
1159                    GNU<"ownership_takes">];
1160   let Accessors = [Accessor<"isHolds", [GNU<"ownership_holds">]>,
1161                    Accessor<"isReturns", [GNU<"ownership_returns">]>,
1162                    Accessor<"isTakes", [GNU<"ownership_takes">]>];
1163   let AdditionalMembers = [{
1164     enum OwnershipKind { Holds, Returns, Takes };
1165     OwnershipKind getOwnKind() const {
1166       return isHolds() ? Holds :
1167              isTakes() ? Takes :
1168              Returns;
1169     }
1170   }];
1171   let Args = [IdentifierArgument<"Module">, VariadicUnsignedArgument<"Args">];
1172   let Subjects = SubjectList<[HasFunctionProto], WarnDiag, "ExpectedFunction">;
1173   let Documentation = [Undocumented];
1174 }
1175
1176 def Packed : InheritableAttr {
1177   let Spellings = [GCC<"packed">];
1178 //  let Subjects = [Tag, Field];
1179   let Documentation = [Undocumented];
1180 }
1181
1182 def IntelOclBicc : InheritableAttr {
1183   let Spellings = [GNU<"intel_ocl_bicc">];
1184 //  let Subjects = [Function, ObjCMethod];
1185   let Documentation = [Undocumented];
1186 }
1187
1188 def Pcs : InheritableAttr {
1189   let Spellings = [GCC<"pcs">];
1190   let Args = [EnumArgument<"PCS", "PCSType",
1191                            ["aapcs", "aapcs-vfp"],
1192                            ["AAPCS", "AAPCS_VFP"]>];
1193 //  let Subjects = [Function, ObjCMethod];
1194   let Documentation = [PcsDocs];
1195 }
1196
1197 def Pure : InheritableAttr {
1198   let Spellings = [GCC<"pure">];
1199   let Documentation = [Undocumented];
1200 }
1201
1202 def Regparm : TypeAttr {
1203   let Spellings = [GCC<"regparm">];
1204   let Args = [UnsignedArgument<"NumParams">];
1205   let Documentation = [RegparmDocs];
1206 }
1207
1208 def ReqdWorkGroupSize : InheritableAttr {
1209   let Spellings = [GNU<"reqd_work_group_size">];
1210   let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
1211               UnsignedArgument<"ZDim">];
1212   let Subjects = SubjectList<[Function], ErrorDiag>;
1213   let Documentation = [Undocumented];
1214 }
1215
1216 def WorkGroupSizeHint :  InheritableAttr {
1217   let Spellings = [GNU<"work_group_size_hint">];
1218   let Args = [UnsignedArgument<"XDim">, 
1219               UnsignedArgument<"YDim">,
1220               UnsignedArgument<"ZDim">];
1221   let Subjects = SubjectList<[Function], ErrorDiag>;
1222   let Documentation = [Undocumented];
1223 }
1224
1225 def InitPriority : InheritableAttr {
1226   let Spellings = [GNU<"init_priority">];
1227   let Args = [UnsignedArgument<"Priority">];
1228   let Subjects = SubjectList<[Var], ErrorDiag>;
1229   let Documentation = [Undocumented];
1230 }
1231
1232 def Section : InheritableAttr {
1233   let Spellings = [GCC<"section">, Declspec<"allocate">];
1234   let Args = [StringArgument<"Name">];
1235   let Subjects = SubjectList<[Function, GlobalVar,
1236                               ObjCMethod, ObjCProperty], ErrorDiag,
1237                              "ExpectedFunctionGlobalVarMethodOrProperty">;
1238   let Documentation = [SectionDocs];
1239 }
1240
1241 def Sentinel : InheritableAttr {
1242   let Spellings = [GCC<"sentinel">];
1243   let Args = [DefaultIntArgument<"Sentinel", 0>,
1244               DefaultIntArgument<"NullPos", 0>];
1245 //  let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
1246   let Documentation = [Undocumented];
1247 }
1248
1249 def StdCall : InheritableAttr {
1250   let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
1251 //  let Subjects = [Function, ObjCMethod];
1252   let Documentation = [StdCallDocs];
1253 }
1254
1255 def SysVABI : InheritableAttr {
1256   let Spellings = [GCC<"sysv_abi">];
1257 //  let Subjects = [Function, ObjCMethod];
1258   let Documentation = [Undocumented];
1259 }
1260
1261 def ThisCall : InheritableAttr {
1262   let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
1263                    Keyword<"_thiscall">];
1264 //  let Subjects = [Function, ObjCMethod];
1265   let Documentation = [ThisCallDocs];
1266 }
1267
1268 def VectorCall : InheritableAttr {
1269   let Spellings = [GNU<"vectorcall">, Keyword<"__vectorcall">,
1270                    Keyword<"_vectorcall">];
1271 //  let Subjects = [Function, ObjCMethod];
1272   let Documentation = [VectorCallDocs];
1273 }
1274
1275 def Pascal : InheritableAttr {
1276   let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
1277 //  let Subjects = [Function, ObjCMethod];
1278   let Documentation = [Undocumented];
1279 }
1280
1281 def Target : InheritableAttr {
1282   let Spellings = [GCC<"target">];
1283   let Args = [StringArgument<"features">];
1284   let Subjects = SubjectList<[Function], ErrorDiag>;
1285   let Documentation = [TargetDocs];
1286 }
1287
1288 def TransparentUnion : InheritableAttr {
1289   let Spellings = [GCC<"transparent_union">];
1290 //  let Subjects = SubjectList<[Record, TypedefName]>;
1291   let Documentation = [Undocumented];
1292 }
1293
1294 def Unavailable : InheritableAttr {
1295   let Spellings = [GNU<"unavailable">];
1296   let Args = [StringArgument<"Message", 1>];
1297   let Documentation = [Undocumented];
1298 }
1299
1300 def ArcWeakrefUnavailable : InheritableAttr {
1301   let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
1302   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1303   let Documentation = [Undocumented];
1304 }
1305
1306 def ObjCGC : TypeAttr {
1307   let Spellings = [GNU<"objc_gc">];
1308   let Args = [IdentifierArgument<"Kind">];
1309   let Documentation = [Undocumented];
1310 }
1311
1312 def ObjCOwnership : InheritableAttr {
1313   let Spellings = [GNU<"objc_ownership">];
1314   let Args = [IdentifierArgument<"Kind">];
1315   let ASTNode = 0;
1316   let Documentation = [Undocumented];
1317 }
1318
1319 def ObjCRequiresPropertyDefs : InheritableAttr {
1320   let Spellings = [GNU<"objc_requires_property_definitions">];
1321   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1322   let Documentation = [Undocumented];
1323 }
1324
1325 def Unused : InheritableAttr {
1326   let Spellings = [GCC<"unused">];
1327   let Subjects = SubjectList<[Var, ObjCIvar, Type, Label, Field, ObjCMethod,
1328                               FunctionLike], WarnDiag,
1329                              "ExpectedVariableFunctionOrLabel">;
1330   let Documentation = [Undocumented];
1331 }
1332
1333 def Used : InheritableAttr {
1334   let Spellings = [GCC<"used">];
1335   let Documentation = [Undocumented];
1336 }
1337
1338 def Uuid : InheritableAttr {
1339   let Spellings = [Declspec<"uuid">];
1340   let Args = [StringArgument<"Guid">];
1341 //  let Subjects = SubjectList<[CXXRecord]>;
1342   let LangOpts = [MicrosoftExt, Borland];
1343   let Documentation = [Undocumented];
1344 }
1345
1346 def VectorSize : TypeAttr {
1347   let Spellings = [GCC<"vector_size">];
1348   let Args = [ExprArgument<"NumBytes">];
1349   let Documentation = [Undocumented];
1350 }
1351
1352 def VecTypeHint : InheritableAttr {
1353   let Spellings = [GNU<"vec_type_hint">];
1354   let Args = [TypeArgument<"TypeHint">];
1355   let Subjects = SubjectList<[Function], ErrorDiag>;
1356   let Documentation = [Undocumented];
1357 }
1358
1359 def Visibility : InheritableAttr {
1360   let Clone = 0;
1361   let Spellings = [GCC<"visibility">];
1362   let Args = [EnumArgument<"Visibility", "VisibilityType",
1363                            ["default", "hidden", "internal", "protected"],
1364                            ["Default", "Hidden", "Hidden", "Protected"]>];
1365   let Documentation = [Undocumented];
1366 }
1367
1368 def TypeVisibility : InheritableAttr {
1369   let Clone = 0;
1370   let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">];
1371   let Args = [EnumArgument<"Visibility", "VisibilityType",
1372                            ["default", "hidden", "internal", "protected"],
1373                            ["Default", "Hidden", "Hidden", "Protected"]>];
1374 //  let Subjects = [Tag, ObjCInterface, Namespace];
1375   let Documentation = [Undocumented];
1376 }
1377
1378 def VecReturn : InheritableAttr {
1379   let Spellings = [GNU<"vecreturn">];
1380   let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
1381   let Documentation = [Undocumented];
1382 }
1383
1384 def WarnUnused : InheritableAttr {
1385   let Spellings = [GNU<"warn_unused">];
1386   let Subjects = SubjectList<[Record]>;
1387   let Documentation = [Undocumented];
1388 }
1389
1390 def WarnUnusedResult : InheritableAttr {
1391   let Spellings = [GCC<"warn_unused_result">,
1392                    CXX11<"clang", "warn_unused_result">];
1393   let Subjects = SubjectList<[ObjCMethod, CXXRecord, FunctionLike], WarnDiag,
1394                              "ExpectedFunctionMethodOrClass">;
1395   let Documentation = [Undocumented];
1396 }
1397
1398 def Weak : InheritableAttr {
1399   let Spellings = [GCC<"weak">];
1400   let Subjects = SubjectList<[Var, Function, CXXRecord]>;
1401   let Documentation = [Undocumented];
1402 }
1403
1404 def WeakImport : InheritableAttr {
1405   let Spellings = [GNU<"weak_import">];
1406   let Documentation = [Undocumented];
1407 }
1408
1409 def WeakRef : InheritableAttr {
1410   let Spellings = [GCC<"weakref">];
1411   // A WeakRef that has an argument is treated as being an AliasAttr
1412   let Args = [StringArgument<"Aliasee", 1>];
1413   let Subjects = SubjectList<[Var, Function], ErrorDiag>;
1414   let Documentation = [Undocumented];
1415 }
1416
1417 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetX86> {
1418   let Spellings = [GNU<"force_align_arg_pointer">];
1419   // Technically, this appertains to a FunctionDecl, but the target-specific
1420   // code silently allows anything function-like (such as typedefs or function
1421   // pointers), but does not apply the attribute to them.
1422   let Documentation = [Undocumented];
1423 }
1424
1425 def NoSanitize : InheritableAttr {
1426   let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">];
1427   let Args = [VariadicStringArgument<"Sanitizers">];
1428   let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
1429   let Documentation = [NoSanitizeDocs];
1430   let AdditionalMembers = [{
1431     SanitizerMask getMask() const {
1432       SanitizerMask Mask = 0;
1433       for (auto SanitizerName : sanitizers()) {
1434         SanitizerMask ParsedMask =
1435             parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
1436         Mask |= expandSanitizerGroups(ParsedMask);
1437       }
1438       return Mask;
1439     }
1440   }];
1441 }
1442
1443 // Attributes to disable a specific sanitizer. No new sanitizers should be added
1444 // to this list; the no_sanitize attribute should be extended instead.
1445 def NoSanitizeSpecific : InheritableAttr {
1446   let Spellings = [GCC<"no_address_safety_analysis">,
1447                    GCC<"no_sanitize_address">,
1448                    GCC<"no_sanitize_thread">,
1449                    GNU<"no_sanitize_memory">];
1450   let Subjects = SubjectList<[Function], ErrorDiag>;
1451   let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
1452                        NoSanitizeMemoryDocs];
1453   let ASTNode = 0;
1454 }
1455
1456 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
1457
1458 def GuardedVar : InheritableAttr {
1459   let Spellings = [GNU<"guarded_var">];
1460   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1461                              "ExpectedFieldOrGlobalVar">;
1462   let Documentation = [Undocumented];
1463 }
1464
1465 def PtGuardedVar : InheritableAttr {
1466   let Spellings = [GNU<"pt_guarded_var">];
1467   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1468                              "ExpectedFieldOrGlobalVar">;
1469   let Documentation = [Undocumented];
1470 }
1471
1472 def Lockable : InheritableAttr {
1473   let Spellings = [GNU<"lockable">];
1474   let Subjects = SubjectList<[Record]>;
1475   let Documentation = [Undocumented];
1476   let ASTNode = 0;  // Replaced by Capability
1477 }
1478
1479 def ScopedLockable : InheritableAttr {
1480   let Spellings = [GNU<"scoped_lockable">];
1481   let Subjects = SubjectList<[Record]>;
1482   let Documentation = [Undocumented];
1483 }
1484
1485 def Capability : InheritableAttr {
1486   let Spellings = [GNU<"capability">, CXX11<"clang", "capability">,
1487                    GNU<"shared_capability">,
1488                    CXX11<"clang", "shared_capability">];
1489   let Subjects = SubjectList<[Struct, TypedefName], ErrorDiag,
1490                              "ExpectedStructOrTypedef">;
1491   let Args = [StringArgument<"Name">];
1492   let Accessors = [Accessor<"isShared",
1493                     [GNU<"shared_capability">,
1494                      CXX11<"clang","shared_capability">]>];
1495   let Documentation = [Undocumented];
1496   let AdditionalMembers = [{
1497     bool isMutex() const { return getName().equals_lower("mutex"); }
1498     bool isRole() const { return getName().equals_lower("role"); }
1499   }];
1500 }
1501
1502 def AssertCapability : InheritableAttr {
1503   let Spellings = [GNU<"assert_capability">,
1504                    CXX11<"clang", "assert_capability">,
1505                    GNU<"assert_shared_capability">,
1506                    CXX11<"clang", "assert_shared_capability">];
1507   let Subjects = SubjectList<[Function]>;
1508   let LateParsed = 1;
1509   let TemplateDependent = 1;
1510   let ParseArgumentsAsUnevaluated = 1;
1511   let DuplicatesAllowedWhileMerging = 1;
1512   let Args = [ExprArgument<"Expr">];
1513   let Accessors = [Accessor<"isShared",
1514                     [GNU<"assert_shared_capability">,
1515                      CXX11<"clang", "assert_shared_capability">]>];
1516   let Documentation = [AssertCapabilityDocs];
1517 }
1518
1519 def AcquireCapability : InheritableAttr {
1520   let Spellings = [GNU<"acquire_capability">,
1521                    CXX11<"clang", "acquire_capability">,
1522                    GNU<"acquire_shared_capability">,
1523                    CXX11<"clang", "acquire_shared_capability">,
1524                    GNU<"exclusive_lock_function">,
1525                    GNU<"shared_lock_function">];
1526   let Subjects = SubjectList<[Function]>;
1527   let LateParsed = 1;
1528   let TemplateDependent = 1;
1529   let ParseArgumentsAsUnevaluated = 1;
1530   let DuplicatesAllowedWhileMerging = 1;
1531   let Args = [VariadicExprArgument<"Args">];
1532   let Accessors = [Accessor<"isShared",
1533                     [GNU<"acquire_shared_capability">,
1534                      CXX11<"clang", "acquire_shared_capability">,
1535                      GNU<"shared_lock_function">]>];
1536   let Documentation = [AcquireCapabilityDocs];
1537 }
1538
1539 def TryAcquireCapability : InheritableAttr {
1540   let Spellings = [GNU<"try_acquire_capability">,
1541                    CXX11<"clang", "try_acquire_capability">,
1542                    GNU<"try_acquire_shared_capability">,
1543                    CXX11<"clang", "try_acquire_shared_capability">];
1544   let Subjects = SubjectList<[Function],
1545                              ErrorDiag>;
1546   let LateParsed = 1;
1547   let TemplateDependent = 1;
1548   let ParseArgumentsAsUnevaluated = 1;
1549   let DuplicatesAllowedWhileMerging = 1;
1550   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1551   let Accessors = [Accessor<"isShared",
1552                     [GNU<"try_acquire_shared_capability">,
1553                      CXX11<"clang", "try_acquire_shared_capability">]>];
1554   let Documentation = [TryAcquireCapabilityDocs];
1555 }
1556
1557 def ReleaseCapability : InheritableAttr {
1558   let Spellings = [GNU<"release_capability">,
1559                    CXX11<"clang", "release_capability">,
1560                    GNU<"release_shared_capability">,
1561                    CXX11<"clang", "release_shared_capability">,
1562                    GNU<"release_generic_capability">,
1563                    CXX11<"clang", "release_generic_capability">,
1564                    GNU<"unlock_function">];
1565   let Subjects = SubjectList<[Function]>;
1566   let LateParsed = 1;
1567   let TemplateDependent = 1;
1568   let ParseArgumentsAsUnevaluated = 1;
1569   let DuplicatesAllowedWhileMerging = 1;
1570   let Args = [VariadicExprArgument<"Args">];
1571   let Accessors = [Accessor<"isShared",
1572                     [GNU<"release_shared_capability">,
1573                      CXX11<"clang", "release_shared_capability">]>,
1574                    Accessor<"isGeneric",
1575                      [GNU<"release_generic_capability">,
1576                       CXX11<"clang", "release_generic_capability">,
1577                       GNU<"unlock_function">]>];
1578   let Documentation = [ReleaseCapabilityDocs];
1579 }
1580
1581 def RequiresCapability : InheritableAttr {
1582   let Spellings = [GNU<"requires_capability">,
1583                    CXX11<"clang", "requires_capability">,
1584                    GNU<"exclusive_locks_required">,
1585                    GNU<"requires_shared_capability">,
1586                    CXX11<"clang", "requires_shared_capability">,
1587                    GNU<"shared_locks_required">];
1588   let Args = [VariadicExprArgument<"Args">];
1589   let LateParsed = 1;
1590   let TemplateDependent = 1;
1591   let ParseArgumentsAsUnevaluated = 1;
1592   let DuplicatesAllowedWhileMerging = 1;
1593   let Subjects = SubjectList<[Function]>;
1594   let Accessors = [Accessor<"isShared", [GNU<"requires_shared_capability">,
1595                                          GNU<"shared_locks_required">,
1596                                 CXX11<"clang","requires_shared_capability">]>];
1597   let Documentation = [Undocumented];
1598 }
1599
1600 def NoThreadSafetyAnalysis : InheritableAttr {
1601   let Spellings = [GNU<"no_thread_safety_analysis">];
1602   let Subjects = SubjectList<[Function]>;
1603   let Documentation = [Undocumented];
1604 }
1605
1606 def GuardedBy : InheritableAttr {
1607   let Spellings = [GNU<"guarded_by">];
1608   let Args = [ExprArgument<"Arg">];
1609   let LateParsed = 1;
1610   let TemplateDependent = 1;
1611   let ParseArgumentsAsUnevaluated = 1;
1612   let DuplicatesAllowedWhileMerging = 1;
1613   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1614                              "ExpectedFieldOrGlobalVar">;
1615   let Documentation = [Undocumented];
1616 }
1617
1618 def PtGuardedBy : InheritableAttr {
1619   let Spellings = [GNU<"pt_guarded_by">];
1620   let Args = [ExprArgument<"Arg">];
1621   let LateParsed = 1;
1622   let TemplateDependent = 1;
1623   let ParseArgumentsAsUnevaluated = 1;
1624   let DuplicatesAllowedWhileMerging = 1;
1625   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1626                              "ExpectedFieldOrGlobalVar">;
1627   let Documentation = [Undocumented];
1628 }
1629
1630 def AcquiredAfter : InheritableAttr {
1631   let Spellings = [GNU<"acquired_after">];
1632   let Args = [VariadicExprArgument<"Args">];
1633   let LateParsed = 1;
1634   let TemplateDependent = 1;
1635   let ParseArgumentsAsUnevaluated = 1;
1636   let DuplicatesAllowedWhileMerging = 1;
1637   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1638                              "ExpectedFieldOrGlobalVar">;
1639   let Documentation = [Undocumented];
1640 }
1641
1642 def AcquiredBefore : InheritableAttr {
1643   let Spellings = [GNU<"acquired_before">];
1644   let Args = [VariadicExprArgument<"Args">];
1645   let LateParsed = 1;
1646   let TemplateDependent = 1;
1647   let ParseArgumentsAsUnevaluated = 1;
1648   let DuplicatesAllowedWhileMerging = 1;
1649   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1650                              "ExpectedFieldOrGlobalVar">;
1651   let Documentation = [Undocumented];
1652 }
1653
1654 def AssertExclusiveLock : InheritableAttr {
1655   let Spellings = [GNU<"assert_exclusive_lock">];
1656   let Args = [VariadicExprArgument<"Args">];
1657   let LateParsed = 1;
1658   let TemplateDependent = 1;
1659   let ParseArgumentsAsUnevaluated = 1;
1660   let DuplicatesAllowedWhileMerging = 1;
1661   let Subjects = SubjectList<[Function]>;
1662   let Documentation = [Undocumented];
1663 }
1664
1665 def AssertSharedLock : InheritableAttr {
1666   let Spellings = [GNU<"assert_shared_lock">];
1667   let Args = [VariadicExprArgument<"Args">];
1668   let LateParsed = 1;
1669   let TemplateDependent = 1;
1670   let ParseArgumentsAsUnevaluated = 1;
1671   let DuplicatesAllowedWhileMerging = 1;
1672   let Subjects = SubjectList<[Function]>;
1673   let Documentation = [Undocumented];
1674 }
1675
1676 // The first argument is an integer or boolean value specifying the return value
1677 // of a successful lock acquisition.
1678 def ExclusiveTrylockFunction : InheritableAttr {
1679   let Spellings = [GNU<"exclusive_trylock_function">];
1680   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1681   let LateParsed = 1;
1682   let TemplateDependent = 1;
1683   let ParseArgumentsAsUnevaluated = 1;
1684   let DuplicatesAllowedWhileMerging = 1;
1685   let Subjects = SubjectList<[Function]>;
1686   let Documentation = [Undocumented];
1687 }
1688
1689 // The first argument is an integer or boolean value specifying the return value
1690 // of a successful lock acquisition.
1691 def SharedTrylockFunction : InheritableAttr {
1692   let Spellings = [GNU<"shared_trylock_function">];
1693   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1694   let LateParsed = 1;
1695   let TemplateDependent = 1;
1696   let ParseArgumentsAsUnevaluated = 1;
1697   let DuplicatesAllowedWhileMerging = 1;
1698   let Subjects = SubjectList<[Function]>;
1699   let Documentation = [Undocumented];
1700 }
1701
1702 def LockReturned : InheritableAttr {
1703   let Spellings = [GNU<"lock_returned">];
1704   let Args = [ExprArgument<"Arg">];
1705   let LateParsed = 1;
1706   let TemplateDependent = 1;
1707   let ParseArgumentsAsUnevaluated = 1;
1708   let Subjects = SubjectList<[Function]>;
1709   let Documentation = [Undocumented];
1710 }
1711
1712 def LocksExcluded : InheritableAttr {
1713   let Spellings = [GNU<"locks_excluded">];
1714   let Args = [VariadicExprArgument<"Args">];
1715   let LateParsed = 1;
1716   let TemplateDependent = 1;
1717   let ParseArgumentsAsUnevaluated = 1;
1718   let DuplicatesAllowedWhileMerging = 1;
1719   let Subjects = SubjectList<[Function]>;
1720   let Documentation = [Undocumented];
1721 }
1722
1723 // C/C++ consumed attributes.
1724
1725 def Consumable : InheritableAttr {
1726   let Spellings = [GNU<"consumable">];
1727   let Subjects = SubjectList<[CXXRecord]>;
1728   let Args = [EnumArgument<"DefaultState", "ConsumedState",
1729                            ["unknown", "consumed", "unconsumed"],
1730                            ["Unknown", "Consumed", "Unconsumed"]>];
1731   let Documentation = [ConsumableDocs];
1732 }
1733
1734 def ConsumableAutoCast : InheritableAttr {
1735   let Spellings = [GNU<"consumable_auto_cast_state">];
1736   let Subjects = SubjectList<[CXXRecord]>;
1737   let Documentation = [Undocumented];
1738 }
1739
1740 def ConsumableSetOnRead : InheritableAttr {
1741   let Spellings = [GNU<"consumable_set_state_on_read">];
1742   let Subjects = SubjectList<[CXXRecord]>;
1743   let Documentation = [Undocumented];
1744 }
1745
1746 def CallableWhen : InheritableAttr {
1747   let Spellings = [GNU<"callable_when">];
1748   let Subjects = SubjectList<[CXXMethod]>;
1749   let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
1750                                    ["unknown", "consumed", "unconsumed"],
1751                                    ["Unknown", "Consumed", "Unconsumed"]>];
1752   let Documentation = [CallableWhenDocs];
1753 }
1754
1755 def ParamTypestate : InheritableAttr {
1756   let Spellings = [GNU<"param_typestate">];
1757   let Subjects = SubjectList<[ParmVar]>;
1758   let Args = [EnumArgument<"ParamState", "ConsumedState",
1759                            ["unknown", "consumed", "unconsumed"],
1760                            ["Unknown", "Consumed", "Unconsumed"]>];
1761   let Documentation = [ParamTypestateDocs];
1762 }
1763
1764 def ReturnTypestate : InheritableAttr {
1765   let Spellings = [GNU<"return_typestate">];
1766   let Subjects = SubjectList<[Function, ParmVar]>;
1767   let Args = [EnumArgument<"State", "ConsumedState",
1768                            ["unknown", "consumed", "unconsumed"],
1769                            ["Unknown", "Consumed", "Unconsumed"]>];
1770   let Documentation = [ReturnTypestateDocs];
1771 }
1772
1773 def SetTypestate : InheritableAttr {
1774   let Spellings = [GNU<"set_typestate">];
1775   let Subjects = SubjectList<[CXXMethod]>;
1776   let Args = [EnumArgument<"NewState", "ConsumedState",
1777                            ["unknown", "consumed", "unconsumed"],
1778                            ["Unknown", "Consumed", "Unconsumed"]>];
1779   let Documentation = [SetTypestateDocs];
1780 }
1781
1782 def TestTypestate : InheritableAttr {
1783   let Spellings = [GNU<"test_typestate">];
1784   let Subjects = SubjectList<[CXXMethod]>;
1785   let Args = [EnumArgument<"TestState", "ConsumedState",
1786                            ["consumed", "unconsumed"],
1787                            ["Consumed", "Unconsumed"]>];
1788   let Documentation = [TestTypestateDocs];
1789 }
1790
1791 // Type safety attributes for `void *' pointers and type tags.
1792
1793 def ArgumentWithTypeTag : InheritableAttr {
1794   let Spellings = [GNU<"argument_with_type_tag">,
1795                    GNU<"pointer_with_type_tag">];
1796   let Args = [IdentifierArgument<"ArgumentKind">,
1797               UnsignedArgument<"ArgumentIdx">,
1798               UnsignedArgument<"TypeTagIdx">,
1799               BoolArgument<"IsPointer">];
1800   let HasCustomParsing = 1;
1801   let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
1802 }
1803
1804 def TypeTagForDatatype : InheritableAttr {
1805   let Spellings = [GNU<"type_tag_for_datatype">];
1806   let Args = [IdentifierArgument<"ArgumentKind">,
1807               TypeArgument<"MatchingCType">,
1808               BoolArgument<"LayoutCompatible">,
1809               BoolArgument<"MustBeNull">];
1810 //  let Subjects = SubjectList<[Var], ErrorDiag>;
1811   let HasCustomParsing = 1;
1812   let Documentation = [TypeTagForDatatypeDocs];
1813 }
1814
1815 // Microsoft-related attributes
1816
1817 def MSNoVTable : InheritableAttr {
1818   let Spellings = [Declspec<"novtable">];
1819   let Subjects = SubjectList<[CXXRecord]>;
1820   let Documentation = [MSNoVTableDocs];
1821 }
1822
1823 def : IgnoredAttr {
1824   let Spellings = [Declspec<"property">];
1825 }
1826
1827 def MSStruct : InheritableAttr {
1828   let Spellings = [GCC<"ms_struct">];
1829   let Subjects = SubjectList<[Record]>;
1830   let Documentation = [Undocumented];
1831 }
1832
1833 def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
1834   let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
1835   let Subjects = SubjectList<[Function, Var, CXXRecord]>;
1836   let Documentation = [Undocumented];
1837 }
1838
1839 def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
1840   let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
1841   let Subjects = SubjectList<[Function, Var, CXXRecord]>;
1842   let Documentation = [Undocumented];
1843 }
1844
1845 def SelectAny : InheritableAttr {
1846   let Spellings = [Declspec<"selectany">];
1847   let LangOpts = [MicrosoftExt];
1848   let Documentation = [Undocumented];
1849 }
1850
1851 def Thread : Attr {
1852   let Spellings = [Declspec<"thread">];
1853   let LangOpts = [MicrosoftExt];
1854   let Documentation = [ThreadDocs];
1855   let Subjects = SubjectList<[Var]>;
1856 }
1857
1858 def Win64 : IgnoredAttr {
1859   let Spellings = [Keyword<"__w64">];
1860   let LangOpts = [MicrosoftExt];
1861 }
1862
1863 def Ptr32 : TypeAttr {
1864   let Spellings = [Keyword<"__ptr32">];
1865   let Documentation = [Undocumented];
1866 }
1867
1868 def Ptr64 : TypeAttr {
1869   let Spellings = [Keyword<"__ptr64">];
1870   let Documentation = [Undocumented];
1871 }
1872
1873 def SPtr : TypeAttr {
1874   let Spellings = [Keyword<"__sptr">];
1875   let Documentation = [Undocumented];
1876 }
1877
1878 def UPtr : TypeAttr {
1879   let Spellings = [Keyword<"__uptr">];
1880   let Documentation = [Undocumented];
1881 }
1882
1883 def MSInheritance : InheritableAttr {
1884   let LangOpts = [MicrosoftExt];
1885   let Args = [DefaultBoolArgument<"BestCase", 1>];
1886   let Spellings = [Keyword<"__single_inheritance">,
1887                    Keyword<"__multiple_inheritance">,
1888                    Keyword<"__virtual_inheritance">,
1889                    Keyword<"__unspecified_inheritance">];
1890   let AdditionalMembers = [{
1891   static bool hasVBPtrOffsetField(Spelling Inheritance) {
1892     return Inheritance == Keyword_unspecified_inheritance;
1893   }
1894
1895   // Only member pointers to functions need a this adjustment, since it can be
1896   // combined with the field offset for data pointers.
1897   static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
1898     return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
1899   }
1900
1901   static bool hasVBTableOffsetField(Spelling Inheritance) {
1902     return Inheritance >= Keyword_virtual_inheritance;
1903   }
1904
1905   static bool hasOnlyOneField(bool IsMemberFunction,
1906                               Spelling Inheritance) {
1907     if (IsMemberFunction)
1908       return Inheritance <= Keyword_single_inheritance;
1909     return Inheritance <= Keyword_multiple_inheritance;
1910   }
1911   }];
1912   let Documentation = [MSInheritanceDocs];
1913 }
1914
1915 def MSVtorDisp : InheritableAttr {
1916   // This attribute has no spellings as it is only ever created implicitly.
1917   let Spellings = [];
1918   let Args = [UnsignedArgument<"vdm">];
1919   let SemaHandler = 0;
1920
1921   let AdditionalMembers = [{
1922   enum Mode {
1923     Never,
1924     ForVBaseOverride,
1925     ForVFTable
1926   };
1927
1928   Mode getVtorDispMode() const { return Mode(vdm); }
1929   }];
1930   let Documentation = [Undocumented];
1931 }
1932
1933 def InitSeg : Attr {
1934   let Spellings = [Pragma<"", "init_seg">];
1935   let Args = [StringArgument<"Section">];
1936   let SemaHandler = 0;
1937   let Documentation = [InitSegDocs];
1938   let AdditionalMembers = [{
1939   void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
1940     OS << '(' << getSection() << ')';
1941   }
1942   }];
1943 }
1944
1945 def Unaligned : IgnoredAttr {
1946   let Spellings = [Keyword<"__unaligned">];
1947 }
1948
1949 def LoopHint : Attr {
1950   /// #pragma clang loop <option> directive
1951   /// vectorize: vectorizes loop operations if State == Enable.
1952   /// vectorize_width: vectorize loop operations with width 'Value'.
1953   /// interleave: interleave multiple loop iterations if State == Enable.
1954   /// interleave_count: interleaves 'Value' loop interations.
1955   /// unroll: fully unroll loop if State == Enable.
1956   /// unroll_count: unrolls loop 'Value' times.
1957
1958   /// #pragma unroll <argument> directive
1959   /// <no arg>: fully unrolls loop.
1960   /// boolean: fully unrolls loop if State == Enable.
1961   /// expression: unrolls loop 'Value' times.
1962
1963   let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">,
1964                    Pragma<"", "nounroll">];
1965
1966   /// State of the loop optimization specified by the spelling.
1967   let Args = [EnumArgument<"Option", "OptionType",
1968                           ["vectorize", "vectorize_width", "interleave", "interleave_count",
1969                            "unroll", "unroll_count"],
1970                           ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
1971                            "Unroll", "UnrollCount"]>,
1972               EnumArgument<"State", "LoopHintState",
1973                            ["default", "enable", "disable", "assume_safety"],
1974                            ["Default", "Enable", "Disable", "AssumeSafety"]>,
1975               ExprArgument<"Value">];
1976
1977   let AdditionalMembers = [{
1978   static const char *getOptionName(int Option) {
1979     switch(Option) {
1980     case Vectorize: return "vectorize";
1981     case VectorizeWidth: return "vectorize_width";
1982     case Interleave: return "interleave";
1983     case InterleaveCount: return "interleave_count";
1984     case Unroll: return "unroll";
1985     case UnrollCount: return "unroll_count";
1986     }
1987     llvm_unreachable("Unhandled LoopHint option.");
1988   }
1989
1990   void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
1991     unsigned SpellingIndex = getSpellingListIndex();
1992     // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
1993     // "nounroll" is already emitted as the pragma name.
1994     if (SpellingIndex == Pragma_nounroll) {
1995       OS << "\n";
1996       return;
1997     }
1998     else if (SpellingIndex == Pragma_unroll) {
1999       OS << getValueString(Policy) << "\n";
2000       return;
2001     }
2002
2003     assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2004     OS << getOptionName(option) << getValueString(Policy) << "\n";
2005   }
2006
2007   // Return a string containing the loop hint argument including the
2008   // enclosing parentheses.
2009   std::string getValueString(const PrintingPolicy &Policy) const {
2010     std::string ValueName;
2011     llvm::raw_string_ostream OS(ValueName);
2012     OS << "(";
2013     if (option == VectorizeWidth || option == InterleaveCount ||
2014         option == UnrollCount)
2015       value->printPretty(OS, nullptr, Policy);
2016     else if (state == Default)
2017       return "";
2018     else if (state == Enable)
2019       OS << (option == Unroll ? "full" : "enable");
2020     else if (state == AssumeSafety)
2021       OS << "assume_safety";
2022     else
2023       OS << "disable";
2024     OS << ")";
2025     return OS.str();
2026   }
2027
2028   // Return a string suitable for identifying this attribute in diagnostics.
2029   std::string getDiagnosticName(const PrintingPolicy &Policy) const {
2030     unsigned SpellingIndex = getSpellingListIndex();
2031     if (SpellingIndex == Pragma_nounroll)
2032       return "#pragma nounroll";
2033     else if (SpellingIndex == Pragma_unroll)
2034       return "#pragma unroll" + getValueString(Policy);
2035
2036     assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2037     return getOptionName(option) + getValueString(Policy);
2038   }
2039   }];
2040
2041   let Documentation = [LoopHintDocs, UnrollHintDocs];
2042 }
2043
2044 def CapturedRecord : InheritableAttr {
2045   // This attribute has no spellings as it is only ever created implicitly.
2046   let Spellings = [];
2047   let SemaHandler = 0;
2048   let Documentation = [Undocumented];
2049 }
2050
2051 def OMPThreadPrivateDecl : InheritableAttr {
2052   // This attribute has no spellings as it is only ever created implicitly.
2053   let Spellings = [];
2054   let SemaHandler = 0;
2055   let Documentation = [Undocumented];
2056 }