]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Basic/Attr.td
Merge ^/head r285153 through r285283.
[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 AssumeAligned : InheritableAttr {
980   let Spellings = [GCC<"assume_aligned">];
981   let Subjects = SubjectList<[ObjCMethod, Function]>;
982   let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>];
983   let Documentation = [AssumeAlignedDocs];
984 }
985
986 def NoReturn : InheritableAttr {
987   let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
988   // FIXME: Does GCC allow this on the function instead?
989   let Documentation = [Undocumented];
990 }
991
992 def NoInstrumentFunction : InheritableAttr {
993   let Spellings = [GCC<"no_instrument_function">];
994   let Subjects = SubjectList<[Function]>;
995   let Documentation = [Undocumented];
996 }
997
998 def NoThrow : InheritableAttr {
999   let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
1000   let Documentation = [Undocumented];
1001 }
1002
1003 def ObjCBridge : InheritableAttr {
1004   let Spellings = [GNU<"objc_bridge">];
1005   let Subjects = SubjectList<[Record, TypedefName], ErrorDiag,
1006                              "ExpectedStructOrUnionOrTypedef">;
1007   let Args = [IdentifierArgument<"BridgedType">];
1008   let Documentation = [Undocumented];
1009 }
1010
1011 def ObjCBridgeMutable : InheritableAttr {
1012   let Spellings = [GNU<"objc_bridge_mutable">];
1013   let Subjects = SubjectList<[Record], ErrorDiag>;
1014   let Args = [IdentifierArgument<"BridgedType">];
1015   let Documentation = [Undocumented];
1016 }
1017
1018 def ObjCBridgeRelated : InheritableAttr {
1019   let Spellings = [GNU<"objc_bridge_related">];
1020   let Subjects = SubjectList<[Record], ErrorDiag>;
1021   let Args = [IdentifierArgument<"RelatedClass">,
1022           IdentifierArgument<"ClassMethod">,
1023           IdentifierArgument<"InstanceMethod">];
1024   let HasCustomParsing = 1;
1025   let Documentation = [Undocumented];
1026 }
1027
1028 def NSReturnsRetained : InheritableAttr {
1029   let Spellings = [GNU<"ns_returns_retained">];
1030 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1031   let Documentation = [Undocumented];
1032 }
1033
1034 def NSReturnsNotRetained : InheritableAttr {
1035   let Spellings = [GNU<"ns_returns_not_retained">];
1036 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1037   let Documentation = [Undocumented];
1038 }
1039
1040 def NSReturnsAutoreleased : InheritableAttr {
1041   let Spellings = [GNU<"ns_returns_autoreleased">];
1042 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1043   let Documentation = [Undocumented];
1044 }
1045
1046 def NSConsumesSelf : InheritableAttr {
1047   let Spellings = [GNU<"ns_consumes_self">];
1048   let Subjects = SubjectList<[ObjCMethod]>;
1049   let Documentation = [Undocumented];
1050 }
1051
1052 def NSConsumed : InheritableParamAttr {
1053   let Spellings = [GNU<"ns_consumed">];
1054   let Subjects = SubjectList<[ParmVar]>;
1055   let Documentation = [Undocumented];
1056 }
1057
1058 def ObjCException : InheritableAttr {
1059   let Spellings = [GNU<"objc_exception">];
1060   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1061   let Documentation = [Undocumented];
1062 }
1063
1064 def ObjCMethodFamily : InheritableAttr {
1065   let Spellings = [GNU<"objc_method_family">];
1066   let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1067   let Args = [EnumArgument<"Family", "FamilyKind",
1068                ["none", "alloc", "copy", "init", "mutableCopy", "new"],
1069                ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
1070                 "OMF_mutableCopy", "OMF_new"]>];
1071   let Documentation = [ObjCMethodFamilyDocs];
1072 }
1073
1074 def ObjCNSObject : InheritableAttr {
1075   let Spellings = [GNU<"NSObject">];
1076   let Documentation = [Undocumented];
1077 }
1078
1079 def ObjCIndependentClass : InheritableAttr {
1080   let Spellings = [GNU<"objc_independent_class">];
1081   let Documentation = [Undocumented];
1082 }
1083
1084 def ObjCPreciseLifetime : InheritableAttr {
1085   let Spellings = [GNU<"objc_precise_lifetime">];
1086   let Subjects = SubjectList<[Var], ErrorDiag>;
1087   let Documentation = [Undocumented];
1088 }
1089
1090 def ObjCReturnsInnerPointer : InheritableAttr {
1091   let Spellings = [GNU<"objc_returns_inner_pointer">];
1092   let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
1093   let Documentation = [Undocumented];
1094 }
1095
1096 def ObjCRequiresSuper : InheritableAttr {
1097   let Spellings = [GNU<"objc_requires_super">];
1098   let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1099   let Documentation = [ObjCRequiresSuperDocs];
1100 }
1101
1102 def ObjCRootClass : InheritableAttr {
1103   let Spellings = [GNU<"objc_root_class">];
1104   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1105   let Documentation = [Undocumented];
1106 }
1107
1108 def ObjCExplicitProtocolImpl : InheritableAttr {
1109   let Spellings = [GNU<"objc_protocol_requires_explicit_implementation">];
1110   let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
1111   let Documentation = [Undocumented];
1112 }
1113
1114 def ObjCDesignatedInitializer : Attr {
1115   let Spellings = [GNU<"objc_designated_initializer">];
1116   let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag,
1117                              "ExpectedObjCInterfaceDeclInitMethod">;
1118   let Documentation = [Undocumented];
1119 }
1120
1121 def ObjCRuntimeName : Attr {
1122   let Spellings = [GNU<"objc_runtime_name">];
1123   let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
1124   let Args = [StringArgument<"MetadataName">];
1125   let Documentation = [ObjCRuntimeNameDocs];
1126 }
1127
1128 def ObjCBoxable : Attr {
1129   let Spellings = [GNU<"objc_boxable">];
1130   let Subjects = SubjectList<[Record], ErrorDiag, "ExpectedStructOrUnion">;
1131   let Documentation = [Undocumented];
1132 }
1133
1134 def OptimizeNone : InheritableAttr {
1135   let Spellings = [GNU<"optnone">, CXX11<"clang", "optnone">];
1136   let Subjects = SubjectList<[Function, ObjCMethod]>;
1137   let Documentation = [OptnoneDocs];
1138 }
1139
1140 def Overloadable : Attr {
1141   let Spellings = [GNU<"overloadable">];
1142   let Subjects = SubjectList<[Function], ErrorDiag>;
1143   let Documentation = [OverloadableDocs];
1144 }
1145
1146 def Override : InheritableAttr { 
1147   let Spellings = [Keyword<"override">];
1148   let SemaHandler = 0;
1149   let Documentation = [Undocumented];
1150 }
1151
1152 def Ownership : InheritableAttr {
1153   let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
1154                    GNU<"ownership_takes">];
1155   let Accessors = [Accessor<"isHolds", [GNU<"ownership_holds">]>,
1156                    Accessor<"isReturns", [GNU<"ownership_returns">]>,
1157                    Accessor<"isTakes", [GNU<"ownership_takes">]>];
1158   let AdditionalMembers = [{
1159     enum OwnershipKind { Holds, Returns, Takes };
1160     OwnershipKind getOwnKind() const {
1161       return isHolds() ? Holds :
1162              isTakes() ? Takes :
1163              Returns;
1164     }
1165   }];
1166   let Args = [IdentifierArgument<"Module">, VariadicUnsignedArgument<"Args">];
1167   let Subjects = SubjectList<[HasFunctionProto], WarnDiag, "ExpectedFunction">;
1168   let Documentation = [Undocumented];
1169 }
1170
1171 def Packed : InheritableAttr {
1172   let Spellings = [GCC<"packed">];
1173 //  let Subjects = [Tag, Field];
1174   let Documentation = [Undocumented];
1175 }
1176
1177 def IntelOclBicc : InheritableAttr {
1178   let Spellings = [GNU<"intel_ocl_bicc">];
1179 //  let Subjects = [Function, ObjCMethod];
1180   let Documentation = [Undocumented];
1181 }
1182
1183 def Pcs : InheritableAttr {
1184   let Spellings = [GCC<"pcs">];
1185   let Args = [EnumArgument<"PCS", "PCSType",
1186                            ["aapcs", "aapcs-vfp"],
1187                            ["AAPCS", "AAPCS_VFP"]>];
1188 //  let Subjects = [Function, ObjCMethod];
1189   let Documentation = [PcsDocs];
1190 }
1191
1192 def Pure : InheritableAttr {
1193   let Spellings = [GCC<"pure">];
1194   let Documentation = [Undocumented];
1195 }
1196
1197 def Regparm : TypeAttr {
1198   let Spellings = [GCC<"regparm">];
1199   let Args = [UnsignedArgument<"NumParams">];
1200   let Documentation = [RegparmDocs];
1201 }
1202
1203 def ReqdWorkGroupSize : InheritableAttr {
1204   let Spellings = [GNU<"reqd_work_group_size">];
1205   let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
1206               UnsignedArgument<"ZDim">];
1207   let Subjects = SubjectList<[Function], ErrorDiag>;
1208   let Documentation = [Undocumented];
1209 }
1210
1211 def WorkGroupSizeHint :  InheritableAttr {
1212   let Spellings = [GNU<"work_group_size_hint">];
1213   let Args = [UnsignedArgument<"XDim">, 
1214               UnsignedArgument<"YDim">,
1215               UnsignedArgument<"ZDim">];
1216   let Subjects = SubjectList<[Function], ErrorDiag>;
1217   let Documentation = [Undocumented];
1218 }
1219
1220 def InitPriority : InheritableAttr {
1221   let Spellings = [GNU<"init_priority">];
1222   let Args = [UnsignedArgument<"Priority">];
1223   let Subjects = SubjectList<[Var], ErrorDiag>;
1224   let Documentation = [Undocumented];
1225 }
1226
1227 def Section : InheritableAttr {
1228   let Spellings = [GCC<"section">, Declspec<"allocate">];
1229   let Args = [StringArgument<"Name">];
1230   let Subjects = SubjectList<[Function, GlobalVar,
1231                               ObjCMethod, ObjCProperty], ErrorDiag,
1232                              "ExpectedFunctionGlobalVarMethodOrProperty">;
1233   let Documentation = [SectionDocs];
1234 }
1235
1236 def Sentinel : InheritableAttr {
1237   let Spellings = [GCC<"sentinel">];
1238   let Args = [DefaultIntArgument<"Sentinel", 0>,
1239               DefaultIntArgument<"NullPos", 0>];
1240 //  let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
1241   let Documentation = [Undocumented];
1242 }
1243
1244 def StdCall : InheritableAttr {
1245   let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
1246 //  let Subjects = [Function, ObjCMethod];
1247   let Documentation = [StdCallDocs];
1248 }
1249
1250 def SysVABI : InheritableAttr {
1251   let Spellings = [GCC<"sysv_abi">];
1252 //  let Subjects = [Function, ObjCMethod];
1253   let Documentation = [Undocumented];
1254 }
1255
1256 def ThisCall : InheritableAttr {
1257   let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
1258                    Keyword<"_thiscall">];
1259 //  let Subjects = [Function, ObjCMethod];
1260   let Documentation = [ThisCallDocs];
1261 }
1262
1263 def VectorCall : InheritableAttr {
1264   let Spellings = [GNU<"vectorcall">, Keyword<"__vectorcall">,
1265                    Keyword<"_vectorcall">];
1266 //  let Subjects = [Function, ObjCMethod];
1267   let Documentation = [VectorCallDocs];
1268 }
1269
1270 def Pascal : InheritableAttr {
1271   let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
1272 //  let Subjects = [Function, ObjCMethod];
1273   let Documentation = [Undocumented];
1274 }
1275
1276 def Target : InheritableAttr {
1277   let Spellings = [GCC<"target">];
1278   let Args = [StringArgument<"features">];
1279   let Subjects =
1280       SubjectList<[Function], ErrorDiag, "ExpectedFunctionMethodOrClass">;
1281   let Documentation = [Undocumented];
1282 }
1283
1284 def TransparentUnion : InheritableAttr {
1285   let Spellings = [GCC<"transparent_union">];
1286 //  let Subjects = SubjectList<[Record, TypedefName]>;
1287   let Documentation = [Undocumented];
1288 }
1289
1290 def Unavailable : InheritableAttr {
1291   let Spellings = [GNU<"unavailable">];
1292   let Args = [StringArgument<"Message", 1>];
1293   let Documentation = [Undocumented];
1294 }
1295
1296 def ArcWeakrefUnavailable : InheritableAttr {
1297   let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
1298   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1299   let Documentation = [Undocumented];
1300 }
1301
1302 def ObjCGC : TypeAttr {
1303   let Spellings = [GNU<"objc_gc">];
1304   let Args = [IdentifierArgument<"Kind">];
1305   let Documentation = [Undocumented];
1306 }
1307
1308 def ObjCOwnership : InheritableAttr {
1309   let Spellings = [GNU<"objc_ownership">];
1310   let Args = [IdentifierArgument<"Kind">];
1311   let ASTNode = 0;
1312   let Documentation = [Undocumented];
1313 }
1314
1315 def ObjCRequiresPropertyDefs : InheritableAttr {
1316   let Spellings = [GNU<"objc_requires_property_definitions">];
1317   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1318   let Documentation = [Undocumented];
1319 }
1320
1321 def Unused : InheritableAttr {
1322   let Spellings = [GCC<"unused">];
1323   let Subjects = SubjectList<[Var, ObjCIvar, Type, Label, Field, ObjCMethod,
1324                               FunctionLike], WarnDiag,
1325                              "ExpectedVariableFunctionOrLabel">;
1326   let Documentation = [Undocumented];
1327 }
1328
1329 def Used : InheritableAttr {
1330   let Spellings = [GCC<"used">];
1331   let Documentation = [Undocumented];
1332 }
1333
1334 def Uuid : InheritableAttr {
1335   let Spellings = [Declspec<"uuid">];
1336   let Args = [StringArgument<"Guid">];
1337 //  let Subjects = SubjectList<[CXXRecord]>;
1338   let LangOpts = [MicrosoftExt, Borland];
1339   let Documentation = [Undocumented];
1340 }
1341
1342 def VectorSize : TypeAttr {
1343   let Spellings = [GCC<"vector_size">];
1344   let Args = [ExprArgument<"NumBytes">];
1345   let Documentation = [Undocumented];
1346 }
1347
1348 def VecTypeHint : InheritableAttr {
1349   let Spellings = [GNU<"vec_type_hint">];
1350   let Args = [TypeArgument<"TypeHint">];
1351   let Subjects = SubjectList<[Function], ErrorDiag>;
1352   let Documentation = [Undocumented];
1353 }
1354
1355 def Visibility : InheritableAttr {
1356   let Clone = 0;
1357   let Spellings = [GCC<"visibility">];
1358   let Args = [EnumArgument<"Visibility", "VisibilityType",
1359                            ["default", "hidden", "internal", "protected"],
1360                            ["Default", "Hidden", "Hidden", "Protected"]>];
1361   let Documentation = [Undocumented];
1362 }
1363
1364 def TypeVisibility : InheritableAttr {
1365   let Clone = 0;
1366   let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">];
1367   let Args = [EnumArgument<"Visibility", "VisibilityType",
1368                            ["default", "hidden", "internal", "protected"],
1369                            ["Default", "Hidden", "Hidden", "Protected"]>];
1370 //  let Subjects = [Tag, ObjCInterface, Namespace];
1371   let Documentation = [Undocumented];
1372 }
1373
1374 def VecReturn : InheritableAttr {
1375   let Spellings = [GNU<"vecreturn">];
1376   let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
1377   let Documentation = [Undocumented];
1378 }
1379
1380 def WarnUnused : InheritableAttr {
1381   let Spellings = [GNU<"warn_unused">];
1382   let Subjects = SubjectList<[Record]>;
1383   let Documentation = [Undocumented];
1384 }
1385
1386 def WarnUnusedResult : InheritableAttr {
1387   let Spellings = [GCC<"warn_unused_result">,
1388                    CXX11<"clang", "warn_unused_result">];
1389   let Subjects = SubjectList<[ObjCMethod, CXXRecord, FunctionLike], WarnDiag,
1390                              "ExpectedFunctionMethodOrClass">;
1391   let Documentation = [Undocumented];
1392 }
1393
1394 def Weak : InheritableAttr {
1395   let Spellings = [GCC<"weak">];
1396   let Subjects = SubjectList<[Var, Function, CXXRecord]>;
1397   let Documentation = [Undocumented];
1398 }
1399
1400 def WeakImport : InheritableAttr {
1401   let Spellings = [GNU<"weak_import">];
1402   let Documentation = [Undocumented];
1403 }
1404
1405 def WeakRef : InheritableAttr {
1406   let Spellings = [GCC<"weakref">];
1407   // A WeakRef that has an argument is treated as being an AliasAttr
1408   let Args = [StringArgument<"Aliasee", 1>];
1409   let Subjects = SubjectList<[Var, Function], ErrorDiag>;
1410   let Documentation = [Undocumented];
1411 }
1412
1413 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetX86> {
1414   let Spellings = [GNU<"force_align_arg_pointer">];
1415   // Technically, this appertains to a FunctionDecl, but the target-specific
1416   // code silently allows anything function-like (such as typedefs or function
1417   // pointers), but does not apply the attribute to them.
1418   let Documentation = [Undocumented];
1419 }
1420
1421 def NoSanitize : InheritableAttr {
1422   let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">];
1423   let Args = [VariadicStringArgument<"Sanitizers">];
1424   let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
1425   let Documentation = [NoSanitizeDocs];
1426   let AdditionalMembers = [{
1427     SanitizerMask getMask() const {
1428       SanitizerMask Mask = 0;
1429       for (auto SanitizerName : sanitizers()) {
1430         SanitizerMask ParsedMask =
1431             parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
1432         Mask |= expandSanitizerGroups(ParsedMask);
1433       }
1434       return Mask;
1435     }
1436   }];
1437 }
1438
1439 // Attributes to disable a specific sanitizer. No new sanitizers should be added
1440 // to this list; the no_sanitize attribute should be extended instead.
1441 def NoSanitizeSpecific : InheritableAttr {
1442   let Spellings = [GCC<"no_address_safety_analysis">,
1443                    GCC<"no_sanitize_address">,
1444                    GCC<"no_sanitize_thread">,
1445                    GNU<"no_sanitize_memory">];
1446   let Subjects = SubjectList<[Function], ErrorDiag>;
1447   let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
1448                        NoSanitizeMemoryDocs];
1449   let ASTNode = 0;
1450 }
1451
1452 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
1453
1454 def GuardedVar : InheritableAttr {
1455   let Spellings = [GNU<"guarded_var">];
1456   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1457                              "ExpectedFieldOrGlobalVar">;
1458   let Documentation = [Undocumented];
1459 }
1460
1461 def PtGuardedVar : InheritableAttr {
1462   let Spellings = [GNU<"pt_guarded_var">];
1463   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1464                              "ExpectedFieldOrGlobalVar">;
1465   let Documentation = [Undocumented];
1466 }
1467
1468 def Lockable : InheritableAttr {
1469   let Spellings = [GNU<"lockable">];
1470   let Subjects = SubjectList<[Record]>;
1471   let Documentation = [Undocumented];
1472   let ASTNode = 0;  // Replaced by Capability
1473 }
1474
1475 def ScopedLockable : InheritableAttr {
1476   let Spellings = [GNU<"scoped_lockable">];
1477   let Subjects = SubjectList<[Record]>;
1478   let Documentation = [Undocumented];
1479 }
1480
1481 def Capability : InheritableAttr {
1482   let Spellings = [GNU<"capability">, CXX11<"clang", "capability">,
1483                    GNU<"shared_capability">,
1484                    CXX11<"clang", "shared_capability">];
1485   let Subjects = SubjectList<[Struct, TypedefName], ErrorDiag,
1486                              "ExpectedStructOrTypedef">;
1487   let Args = [StringArgument<"Name">];
1488   let Accessors = [Accessor<"isShared",
1489                     [GNU<"shared_capability">,
1490                      CXX11<"clang","shared_capability">]>];
1491   let Documentation = [Undocumented];
1492   let AdditionalMembers = [{
1493     bool isMutex() const { return getName().equals_lower("mutex"); }
1494     bool isRole() const { return getName().equals_lower("role"); }
1495   }];
1496 }
1497
1498 def AssertCapability : InheritableAttr {
1499   let Spellings = [GNU<"assert_capability">,
1500                    CXX11<"clang", "assert_capability">,
1501                    GNU<"assert_shared_capability">,
1502                    CXX11<"clang", "assert_shared_capability">];
1503   let Subjects = SubjectList<[Function]>;
1504   let LateParsed = 1;
1505   let TemplateDependent = 1;
1506   let ParseArgumentsAsUnevaluated = 1;
1507   let DuplicatesAllowedWhileMerging = 1;
1508   let Args = [ExprArgument<"Expr">];
1509   let Accessors = [Accessor<"isShared",
1510                     [GNU<"assert_shared_capability">,
1511                      CXX11<"clang", "assert_shared_capability">]>];
1512   let Documentation = [AssertCapabilityDocs];
1513 }
1514
1515 def AcquireCapability : InheritableAttr {
1516   let Spellings = [GNU<"acquire_capability">,
1517                    CXX11<"clang", "acquire_capability">,
1518                    GNU<"acquire_shared_capability">,
1519                    CXX11<"clang", "acquire_shared_capability">,
1520                    GNU<"exclusive_lock_function">,
1521                    GNU<"shared_lock_function">];
1522   let Subjects = SubjectList<[Function]>;
1523   let LateParsed = 1;
1524   let TemplateDependent = 1;
1525   let ParseArgumentsAsUnevaluated = 1;
1526   let DuplicatesAllowedWhileMerging = 1;
1527   let Args = [VariadicExprArgument<"Args">];
1528   let Accessors = [Accessor<"isShared",
1529                     [GNU<"acquire_shared_capability">,
1530                      CXX11<"clang", "acquire_shared_capability">,
1531                      GNU<"shared_lock_function">]>];
1532   let Documentation = [AcquireCapabilityDocs];
1533 }
1534
1535 def TryAcquireCapability : InheritableAttr {
1536   let Spellings = [GNU<"try_acquire_capability">,
1537                    CXX11<"clang", "try_acquire_capability">,
1538                    GNU<"try_acquire_shared_capability">,
1539                    CXX11<"clang", "try_acquire_shared_capability">];
1540   let Subjects = SubjectList<[Function],
1541                              ErrorDiag>;
1542   let LateParsed = 1;
1543   let TemplateDependent = 1;
1544   let ParseArgumentsAsUnevaluated = 1;
1545   let DuplicatesAllowedWhileMerging = 1;
1546   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1547   let Accessors = [Accessor<"isShared",
1548                     [GNU<"try_acquire_shared_capability">,
1549                      CXX11<"clang", "try_acquire_shared_capability">]>];
1550   let Documentation = [TryAcquireCapabilityDocs];
1551 }
1552
1553 def ReleaseCapability : InheritableAttr {
1554   let Spellings = [GNU<"release_capability">,
1555                    CXX11<"clang", "release_capability">,
1556                    GNU<"release_shared_capability">,
1557                    CXX11<"clang", "release_shared_capability">,
1558                    GNU<"release_generic_capability">,
1559                    CXX11<"clang", "release_generic_capability">,
1560                    GNU<"unlock_function">];
1561   let Subjects = SubjectList<[Function]>;
1562   let LateParsed = 1;
1563   let TemplateDependent = 1;
1564   let ParseArgumentsAsUnevaluated = 1;
1565   let DuplicatesAllowedWhileMerging = 1;
1566   let Args = [VariadicExprArgument<"Args">];
1567   let Accessors = [Accessor<"isShared",
1568                     [GNU<"release_shared_capability">,
1569                      CXX11<"clang", "release_shared_capability">]>,
1570                    Accessor<"isGeneric",
1571                      [GNU<"release_generic_capability">,
1572                       CXX11<"clang", "release_generic_capability">,
1573                       GNU<"unlock_function">]>];
1574   let Documentation = [ReleaseCapabilityDocs];
1575 }
1576
1577 def RequiresCapability : InheritableAttr {
1578   let Spellings = [GNU<"requires_capability">,
1579                    CXX11<"clang", "requires_capability">,
1580                    GNU<"exclusive_locks_required">,
1581                    GNU<"requires_shared_capability">,
1582                    CXX11<"clang", "requires_shared_capability">,
1583                    GNU<"shared_locks_required">];
1584   let Args = [VariadicExprArgument<"Args">];
1585   let LateParsed = 1;
1586   let TemplateDependent = 1;
1587   let ParseArgumentsAsUnevaluated = 1;
1588   let DuplicatesAllowedWhileMerging = 1;
1589   let Subjects = SubjectList<[Function]>;
1590   let Accessors = [Accessor<"isShared", [GNU<"requires_shared_capability">,
1591                                          GNU<"shared_locks_required">,
1592                                 CXX11<"clang","requires_shared_capability">]>];
1593   let Documentation = [Undocumented];
1594 }
1595
1596 def NoThreadSafetyAnalysis : InheritableAttr {
1597   let Spellings = [GNU<"no_thread_safety_analysis">];
1598   let Subjects = SubjectList<[Function]>;
1599   let Documentation = [Undocumented];
1600 }
1601
1602 def GuardedBy : InheritableAttr {
1603   let Spellings = [GNU<"guarded_by">];
1604   let Args = [ExprArgument<"Arg">];
1605   let LateParsed = 1;
1606   let TemplateDependent = 1;
1607   let ParseArgumentsAsUnevaluated = 1;
1608   let DuplicatesAllowedWhileMerging = 1;
1609   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1610                              "ExpectedFieldOrGlobalVar">;
1611   let Documentation = [Undocumented];
1612 }
1613
1614 def PtGuardedBy : InheritableAttr {
1615   let Spellings = [GNU<"pt_guarded_by">];
1616   let Args = [ExprArgument<"Arg">];
1617   let LateParsed = 1;
1618   let TemplateDependent = 1;
1619   let ParseArgumentsAsUnevaluated = 1;
1620   let DuplicatesAllowedWhileMerging = 1;
1621   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1622                              "ExpectedFieldOrGlobalVar">;
1623   let Documentation = [Undocumented];
1624 }
1625
1626 def AcquiredAfter : InheritableAttr {
1627   let Spellings = [GNU<"acquired_after">];
1628   let Args = [VariadicExprArgument<"Args">];
1629   let LateParsed = 1;
1630   let TemplateDependent = 1;
1631   let ParseArgumentsAsUnevaluated = 1;
1632   let DuplicatesAllowedWhileMerging = 1;
1633   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1634                              "ExpectedFieldOrGlobalVar">;
1635   let Documentation = [Undocumented];
1636 }
1637
1638 def AcquiredBefore : InheritableAttr {
1639   let Spellings = [GNU<"acquired_before">];
1640   let Args = [VariadicExprArgument<"Args">];
1641   let LateParsed = 1;
1642   let TemplateDependent = 1;
1643   let ParseArgumentsAsUnevaluated = 1;
1644   let DuplicatesAllowedWhileMerging = 1;
1645   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1646                              "ExpectedFieldOrGlobalVar">;
1647   let Documentation = [Undocumented];
1648 }
1649
1650 def AssertExclusiveLock : InheritableAttr {
1651   let Spellings = [GNU<"assert_exclusive_lock">];
1652   let Args = [VariadicExprArgument<"Args">];
1653   let LateParsed = 1;
1654   let TemplateDependent = 1;
1655   let ParseArgumentsAsUnevaluated = 1;
1656   let DuplicatesAllowedWhileMerging = 1;
1657   let Subjects = SubjectList<[Function]>;
1658   let Documentation = [Undocumented];
1659 }
1660
1661 def AssertSharedLock : InheritableAttr {
1662   let Spellings = [GNU<"assert_shared_lock">];
1663   let Args = [VariadicExprArgument<"Args">];
1664   let LateParsed = 1;
1665   let TemplateDependent = 1;
1666   let ParseArgumentsAsUnevaluated = 1;
1667   let DuplicatesAllowedWhileMerging = 1;
1668   let Subjects = SubjectList<[Function]>;
1669   let Documentation = [Undocumented];
1670 }
1671
1672 // The first argument is an integer or boolean value specifying the return value
1673 // of a successful lock acquisition.
1674 def ExclusiveTrylockFunction : InheritableAttr {
1675   let Spellings = [GNU<"exclusive_trylock_function">];
1676   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1677   let LateParsed = 1;
1678   let TemplateDependent = 1;
1679   let ParseArgumentsAsUnevaluated = 1;
1680   let DuplicatesAllowedWhileMerging = 1;
1681   let Subjects = SubjectList<[Function]>;
1682   let Documentation = [Undocumented];
1683 }
1684
1685 // The first argument is an integer or boolean value specifying the return value
1686 // of a successful lock acquisition.
1687 def SharedTrylockFunction : InheritableAttr {
1688   let Spellings = [GNU<"shared_trylock_function">];
1689   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1690   let LateParsed = 1;
1691   let TemplateDependent = 1;
1692   let ParseArgumentsAsUnevaluated = 1;
1693   let DuplicatesAllowedWhileMerging = 1;
1694   let Subjects = SubjectList<[Function]>;
1695   let Documentation = [Undocumented];
1696 }
1697
1698 def LockReturned : InheritableAttr {
1699   let Spellings = [GNU<"lock_returned">];
1700   let Args = [ExprArgument<"Arg">];
1701   let LateParsed = 1;
1702   let TemplateDependent = 1;
1703   let ParseArgumentsAsUnevaluated = 1;
1704   let Subjects = SubjectList<[Function]>;
1705   let Documentation = [Undocumented];
1706 }
1707
1708 def LocksExcluded : InheritableAttr {
1709   let Spellings = [GNU<"locks_excluded">];
1710   let Args = [VariadicExprArgument<"Args">];
1711   let LateParsed = 1;
1712   let TemplateDependent = 1;
1713   let ParseArgumentsAsUnevaluated = 1;
1714   let DuplicatesAllowedWhileMerging = 1;
1715   let Subjects = SubjectList<[Function]>;
1716   let Documentation = [Undocumented];
1717 }
1718
1719 // C/C++ consumed attributes.
1720
1721 def Consumable : InheritableAttr {
1722   let Spellings = [GNU<"consumable">];
1723   let Subjects = SubjectList<[CXXRecord]>;
1724   let Args = [EnumArgument<"DefaultState", "ConsumedState",
1725                            ["unknown", "consumed", "unconsumed"],
1726                            ["Unknown", "Consumed", "Unconsumed"]>];
1727   let Documentation = [ConsumableDocs];
1728 }
1729
1730 def ConsumableAutoCast : InheritableAttr {
1731   let Spellings = [GNU<"consumable_auto_cast_state">];
1732   let Subjects = SubjectList<[CXXRecord]>;
1733   let Documentation = [Undocumented];
1734 }
1735
1736 def ConsumableSetOnRead : InheritableAttr {
1737   let Spellings = [GNU<"consumable_set_state_on_read">];
1738   let Subjects = SubjectList<[CXXRecord]>;
1739   let Documentation = [Undocumented];
1740 }
1741
1742 def CallableWhen : InheritableAttr {
1743   let Spellings = [GNU<"callable_when">];
1744   let Subjects = SubjectList<[CXXMethod]>;
1745   let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
1746                                    ["unknown", "consumed", "unconsumed"],
1747                                    ["Unknown", "Consumed", "Unconsumed"]>];
1748   let Documentation = [CallableWhenDocs];
1749 }
1750
1751 def ParamTypestate : InheritableAttr {
1752   let Spellings = [GNU<"param_typestate">];
1753   let Subjects = SubjectList<[ParmVar]>;
1754   let Args = [EnumArgument<"ParamState", "ConsumedState",
1755                            ["unknown", "consumed", "unconsumed"],
1756                            ["Unknown", "Consumed", "Unconsumed"]>];
1757   let Documentation = [ParamTypestateDocs];
1758 }
1759
1760 def ReturnTypestate : InheritableAttr {
1761   let Spellings = [GNU<"return_typestate">];
1762   let Subjects = SubjectList<[Function, ParmVar]>;
1763   let Args = [EnumArgument<"State", "ConsumedState",
1764                            ["unknown", "consumed", "unconsumed"],
1765                            ["Unknown", "Consumed", "Unconsumed"]>];
1766   let Documentation = [ReturnTypestateDocs];
1767 }
1768
1769 def SetTypestate : InheritableAttr {
1770   let Spellings = [GNU<"set_typestate">];
1771   let Subjects = SubjectList<[CXXMethod]>;
1772   let Args = [EnumArgument<"NewState", "ConsumedState",
1773                            ["unknown", "consumed", "unconsumed"],
1774                            ["Unknown", "Consumed", "Unconsumed"]>];
1775   let Documentation = [SetTypestateDocs];
1776 }
1777
1778 def TestTypestate : InheritableAttr {
1779   let Spellings = [GNU<"test_typestate">];
1780   let Subjects = SubjectList<[CXXMethod]>;
1781   let Args = [EnumArgument<"TestState", "ConsumedState",
1782                            ["consumed", "unconsumed"],
1783                            ["Consumed", "Unconsumed"]>];
1784   let Documentation = [TestTypestateDocs];
1785 }
1786
1787 // Type safety attributes for `void *' pointers and type tags.
1788
1789 def ArgumentWithTypeTag : InheritableAttr {
1790   let Spellings = [GNU<"argument_with_type_tag">,
1791                    GNU<"pointer_with_type_tag">];
1792   let Args = [IdentifierArgument<"ArgumentKind">,
1793               UnsignedArgument<"ArgumentIdx">,
1794               UnsignedArgument<"TypeTagIdx">,
1795               BoolArgument<"IsPointer">];
1796   let HasCustomParsing = 1;
1797   let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
1798 }
1799
1800 def TypeTagForDatatype : InheritableAttr {
1801   let Spellings = [GNU<"type_tag_for_datatype">];
1802   let Args = [IdentifierArgument<"ArgumentKind">,
1803               TypeArgument<"MatchingCType">,
1804               BoolArgument<"LayoutCompatible">,
1805               BoolArgument<"MustBeNull">];
1806 //  let Subjects = SubjectList<[Var], ErrorDiag>;
1807   let HasCustomParsing = 1;
1808   let Documentation = [TypeTagForDatatypeDocs];
1809 }
1810
1811 // Microsoft-related attributes
1812
1813 def MSNoVTable : InheritableAttr {
1814   let Spellings = [Declspec<"novtable">];
1815   let Subjects = SubjectList<[CXXRecord]>;
1816   let Documentation = [MSNoVTableDocs];
1817 }
1818
1819 def : IgnoredAttr {
1820   let Spellings = [Declspec<"property">];
1821 }
1822
1823 def MSStruct : InheritableAttr {
1824   let Spellings = [GCC<"ms_struct">];
1825   let Subjects = SubjectList<[Record]>;
1826   let Documentation = [Undocumented];
1827 }
1828
1829 def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
1830   let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
1831   let Subjects = SubjectList<[Function, Var, CXXRecord]>;
1832   let Documentation = [Undocumented];
1833 }
1834
1835 def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
1836   let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
1837   let Subjects = SubjectList<[Function, Var, CXXRecord]>;
1838   let Documentation = [Undocumented];
1839 }
1840
1841 def SelectAny : InheritableAttr {
1842   let Spellings = [Declspec<"selectany">];
1843   let LangOpts = [MicrosoftExt];
1844   let Documentation = [Undocumented];
1845 }
1846
1847 def Thread : Attr {
1848   let Spellings = [Declspec<"thread">];
1849   let LangOpts = [MicrosoftExt];
1850   let Documentation = [ThreadDocs];
1851   let Subjects = SubjectList<[Var]>;
1852 }
1853
1854 def Win64 : IgnoredAttr {
1855   let Spellings = [Keyword<"__w64">];
1856   let LangOpts = [MicrosoftExt];
1857 }
1858
1859 def Ptr32 : TypeAttr {
1860   let Spellings = [Keyword<"__ptr32">];
1861   let Documentation = [Undocumented];
1862 }
1863
1864 def Ptr64 : TypeAttr {
1865   let Spellings = [Keyword<"__ptr64">];
1866   let Documentation = [Undocumented];
1867 }
1868
1869 def SPtr : TypeAttr {
1870   let Spellings = [Keyword<"__sptr">];
1871   let Documentation = [Undocumented];
1872 }
1873
1874 def UPtr : TypeAttr {
1875   let Spellings = [Keyword<"__uptr">];
1876   let Documentation = [Undocumented];
1877 }
1878
1879 def MSInheritance : InheritableAttr {
1880   let LangOpts = [MicrosoftExt];
1881   let Args = [DefaultBoolArgument<"BestCase", 1>];
1882   let Spellings = [Keyword<"__single_inheritance">,
1883                    Keyword<"__multiple_inheritance">,
1884                    Keyword<"__virtual_inheritance">,
1885                    Keyword<"__unspecified_inheritance">];
1886   let AdditionalMembers = [{
1887   static bool hasVBPtrOffsetField(Spelling Inheritance) {
1888     return Inheritance == Keyword_unspecified_inheritance;
1889   }
1890
1891   // Only member pointers to functions need a this adjustment, since it can be
1892   // combined with the field offset for data pointers.
1893   static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
1894     return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
1895   }
1896
1897   static bool hasVBTableOffsetField(Spelling Inheritance) {
1898     return Inheritance >= Keyword_virtual_inheritance;
1899   }
1900
1901   static bool hasOnlyOneField(bool IsMemberFunction,
1902                               Spelling Inheritance) {
1903     if (IsMemberFunction)
1904       return Inheritance <= Keyword_single_inheritance;
1905     return Inheritance <= Keyword_multiple_inheritance;
1906   }
1907   }];
1908   let Documentation = [MSInheritanceDocs];
1909 }
1910
1911 def MSVtorDisp : InheritableAttr {
1912   // This attribute has no spellings as it is only ever created implicitly.
1913   let Spellings = [];
1914   let Args = [UnsignedArgument<"vdm">];
1915   let SemaHandler = 0;
1916
1917   let AdditionalMembers = [{
1918   enum Mode {
1919     Never,
1920     ForVBaseOverride,
1921     ForVFTable
1922   };
1923
1924   Mode getVtorDispMode() const { return Mode(vdm); }
1925   }];
1926   let Documentation = [Undocumented];
1927 }
1928
1929 def InitSeg : Attr {
1930   let Spellings = [Pragma<"", "init_seg">];
1931   let Args = [StringArgument<"Section">];
1932   let SemaHandler = 0;
1933   let Documentation = [InitSegDocs];
1934   let AdditionalMembers = [{
1935   void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
1936     OS << '(' << getSection() << ')';
1937   }
1938   }];
1939 }
1940
1941 def Unaligned : IgnoredAttr {
1942   let Spellings = [Keyword<"__unaligned">];
1943 }
1944
1945 def LoopHint : Attr {
1946   /// #pragma clang loop <option> directive
1947   /// vectorize: vectorizes loop operations if State == Enable.
1948   /// vectorize_width: vectorize loop operations with width 'Value'.
1949   /// interleave: interleave multiple loop iterations if State == Enable.
1950   /// interleave_count: interleaves 'Value' loop interations.
1951   /// unroll: fully unroll loop if State == Enable.
1952   /// unroll_count: unrolls loop 'Value' times.
1953
1954   /// #pragma unroll <argument> directive
1955   /// <no arg>: fully unrolls loop.
1956   /// boolean: fully unrolls loop if State == Enable.
1957   /// expression: unrolls loop 'Value' times.
1958
1959   let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">,
1960                    Pragma<"", "nounroll">];
1961
1962   /// State of the loop optimization specified by the spelling.
1963   let Args = [EnumArgument<"Option", "OptionType",
1964                           ["vectorize", "vectorize_width", "interleave", "interleave_count",
1965                            "unroll", "unroll_count"],
1966                           ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
1967                            "Unroll", "UnrollCount"]>,
1968               EnumArgument<"State", "LoopHintState",
1969                            ["default", "enable", "disable", "assume_safety"],
1970                            ["Default", "Enable", "Disable", "AssumeSafety"]>,
1971               ExprArgument<"Value">];
1972
1973   let AdditionalMembers = [{
1974   static const char *getOptionName(int Option) {
1975     switch(Option) {
1976     case Vectorize: return "vectorize";
1977     case VectorizeWidth: return "vectorize_width";
1978     case Interleave: return "interleave";
1979     case InterleaveCount: return "interleave_count";
1980     case Unroll: return "unroll";
1981     case UnrollCount: return "unroll_count";
1982     }
1983     llvm_unreachable("Unhandled LoopHint option.");
1984   }
1985
1986   void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
1987     unsigned SpellingIndex = getSpellingListIndex();
1988     // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
1989     // "nounroll" is already emitted as the pragma name.
1990     if (SpellingIndex == Pragma_nounroll) {
1991       OS << "\n";
1992       return;
1993     }
1994     else if (SpellingIndex == Pragma_unroll) {
1995       OS << getValueString(Policy) << "\n";
1996       return;
1997     }
1998
1999     assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2000     OS << getOptionName(option) << getValueString(Policy) << "\n";
2001   }
2002
2003   // Return a string containing the loop hint argument including the
2004   // enclosing parentheses.
2005   std::string getValueString(const PrintingPolicy &Policy) const {
2006     std::string ValueName;
2007     llvm::raw_string_ostream OS(ValueName);
2008     OS << "(";
2009     if (option == VectorizeWidth || option == InterleaveCount ||
2010         option == UnrollCount)
2011       value->printPretty(OS, nullptr, Policy);
2012     else if (state == Default)
2013       return "";
2014     else if (state == Enable)
2015       OS << (option == Unroll ? "full" : "enable");
2016     else if (state == AssumeSafety)
2017       OS << "assume_safety";
2018     else
2019       OS << "disable";
2020     OS << ")";
2021     return OS.str();
2022   }
2023
2024   // Return a string suitable for identifying this attribute in diagnostics.
2025   std::string getDiagnosticName(const PrintingPolicy &Policy) const {
2026     unsigned SpellingIndex = getSpellingListIndex();
2027     if (SpellingIndex == Pragma_nounroll)
2028       return "#pragma nounroll";
2029     else if (SpellingIndex == Pragma_unroll)
2030       return "#pragma unroll" + getValueString(Policy);
2031
2032     assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2033     return getOptionName(option) + getValueString(Policy);
2034   }
2035   }];
2036
2037   let Documentation = [LoopHintDocs, UnrollHintDocs];
2038 }
2039
2040 def CapturedRecord : InheritableAttr {
2041   // This attribute has no spellings as it is only ever created implicitly.
2042   let Spellings = [];
2043   let SemaHandler = 0;
2044   let Documentation = [Undocumented];
2045 }
2046
2047 def OMPThreadPrivateDecl : InheritableAttr {
2048   // This attribute has no spellings as it is only ever created implicitly.
2049   let Spellings = [];
2050   let SemaHandler = 0;
2051   let Documentation = [Undocumented];
2052 }