]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Basic/Attr.td
Merge ^/head r311314 through r311459.
[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 NonParmVar : SubsetSubject<Var,
86                                [{S->getKind() != Decl::ParmVar}]>;
87 def NonBitField : SubsetSubject<Field,
88                                 [{!S->isBitField()}]>;
89
90 def ObjCInstanceMethod : SubsetSubject<ObjCMethod,
91                                        [{S->isInstanceMethod()}]>;
92
93 def ObjCInterfaceDeclInitMethod : SubsetSubject<ObjCMethod,
94                                [{S->getMethodFamily() == OMF_init &&
95                                  (isa<ObjCInterfaceDecl>(S->getDeclContext()) ||
96                                   (isa<ObjCCategoryDecl>(S->getDeclContext()) &&
97             cast<ObjCCategoryDecl>(S->getDeclContext())->IsClassExtension()))}]>;
98
99 def Struct : SubsetSubject<Record,
100                            [{!S->isUnion()}]>;
101
102 def TLSVar : SubsetSubject<Var,
103                            [{S->getTLSKind() != 0}]>;
104
105 def SharedVar : SubsetSubject<Var,
106                               [{S->hasGlobalStorage() && !S->getTLSKind()}]>;
107
108 def GlobalVar : SubsetSubject<Var,
109                              [{S->hasGlobalStorage()}]>;
110
111 // FIXME: this hack is needed because DeclNodes.td defines the base Decl node
112 // type to be a class, not a definition. This makes it impossible to create an
113 // attribute subject which accepts a Decl. Normally, this is not a problem,
114 // because the attribute can have no Subjects clause to accomplish this. But in
115 // the case of a SubsetSubject, there's no way to express it without this hack.
116 def DeclBase : AttrSubject;
117 def FunctionLike : SubsetSubject<DeclBase,
118                                   [{S->getFunctionType(false) != nullptr}]>;
119
120 def OpenCLKernelFunction : SubsetSubject<Function, [{
121   S->hasAttr<OpenCLKernelAttr>()
122 }]>;
123
124 // HasFunctionProto is a more strict version of FunctionLike, so it should
125 // never be specified in a Subjects list along with FunctionLike (due to the
126 // inclusive nature of subject testing).
127 def HasFunctionProto : SubsetSubject<DeclBase,
128                                      [{(S->getFunctionType(true) != nullptr &&
129                               isa<FunctionProtoType>(S->getFunctionType())) ||
130                                        isa<ObjCMethodDecl>(S) ||
131                                        isa<BlockDecl>(S)}]>;
132
133 // A single argument to an attribute
134 class Argument<string name, bit optional, bit fake = 0> {
135   string Name = name;
136   bit Optional = optional;
137
138   /// A fake argument is used to store and serialize additional information
139   /// in an attribute without actually changing its parsing or pretty-printing.
140   bit Fake = fake;
141 }
142
143 class BoolArgument<string name, bit opt = 0> : Argument<name, opt>;
144 class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>;
145 class IntArgument<string name, bit opt = 0> : Argument<name, opt>;
146 class StringArgument<string name, bit opt = 0> : Argument<name, opt>;
147 class ExprArgument<string name, bit opt = 0> : Argument<name, opt>;
148 class FunctionArgument<string name, bit opt = 0> : Argument<name, opt>;
149 class TypeArgument<string name, bit opt = 0> : Argument<name, opt>;
150 class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>;
151 class VariadicUnsignedArgument<string name> : Argument<name, 1>;
152 class VariadicExprArgument<string name> : Argument<name, 1>;
153 class VariadicStringArgument<string name> : Argument<name, 1>;
154
155 // A version of the form major.minor[.subminor].
156 class VersionArgument<string name, bit opt = 0> : Argument<name, opt>;
157
158 // This one's a doozy, so it gets its own special type
159 // It can be an unsigned integer, or a type. Either can
160 // be dependent.
161 class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>;
162
163 // A bool argument with a default value
164 class DefaultBoolArgument<string name, bit default> : BoolArgument<name, 1> {
165   bit Default = default;
166 }
167
168 // An integer argument with a default value
169 class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
170   int Default = default;
171 }
172
173 // This argument is more complex, it includes the enumerator type name,
174 // a list of strings to accept, and a list of enumerators to map them to.
175 class EnumArgument<string name, string type, list<string> values,
176                    list<string> enums, bit opt = 0, bit fake = 0>
177     : Argument<name, opt, fake> {
178   string Type = type;
179   list<string> Values = values;
180   list<string> Enums = enums;
181 }
182
183 // FIXME: There should be a VariadicArgument type that takes any other type
184 //        of argument and generates the appropriate type.
185 class VariadicEnumArgument<string name, string type, list<string> values,
186                            list<string> enums> : Argument<name, 1>  {
187   string Type = type;
188   list<string> Values = values;
189   list<string> Enums = enums;
190 }
191
192 // This handles one spelling of an attribute.
193 class Spelling<string name, string variety> {
194   string Name = name;
195   string Variety = variety;
196   bit KnownToGCC;
197 }
198
199 class GNU<string name> : Spelling<name, "GNU">;
200 class Declspec<string name> : Spelling<name, "Declspec">;
201 class Microsoft<string name> : Spelling<name, "Microsoft">;
202 class CXX11<string namespace, string name, int version = 1>
203     : Spelling<name, "CXX11"> {
204   string Namespace = namespace;
205   int Version = version;
206 }
207 class Keyword<string name> : Spelling<name, "Keyword">;
208 class Pragma<string namespace, string name> : Spelling<name, "Pragma"> {
209   string Namespace = namespace;
210 }
211
212 // The GCC spelling implies GNU<name, "GNU"> and CXX11<"gnu", name> and also
213 // sets KnownToGCC to 1. This spelling should be used for any GCC-compatible
214 // attributes.
215 class GCC<string name> : Spelling<name, "GCC"> {
216   let KnownToGCC = 1;
217 }
218
219 class Accessor<string name, list<Spelling> spellings> {
220   string Name = name;
221   list<Spelling> Spellings = spellings;
222 }
223
224 class SubjectDiag<bit warn> {
225   bit Warn = warn;
226 }
227 def WarnDiag : SubjectDiag<1>;
228 def ErrorDiag : SubjectDiag<0>;
229
230 class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag,
231                   string customDiag = ""> {
232   list<AttrSubject> Subjects = subjects;
233   SubjectDiag Diag = diag;
234   string CustomDiag = customDiag;
235 }
236
237 class LangOpt<string name, bit negated = 0> {
238   string Name = name;
239   bit Negated = negated;
240 }
241 def MicrosoftExt : LangOpt<"MicrosoftExt">;
242 def Borland : LangOpt<"Borland">;
243 def CUDA : LangOpt<"CUDA">;
244 def COnly : LangOpt<"CPlusPlus", 1>;
245 def CPlusPlus : LangOpt<"CPlusPlus">;
246 def OpenCL : LangOpt<"OpenCL">;
247 def RenderScript : LangOpt<"RenderScript">;
248
249 // Defines targets for target-specific attributes. The list of strings should
250 // specify architectures for which the target applies, based off the ArchType
251 // enumeration in Triple.h.
252 class TargetArch<list<string> arches> {
253   list<string> Arches = arches;
254   list<string> OSes;
255   list<string> CXXABIs;
256 }
257 def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
258 def TargetMips : TargetArch<["mips", "mipsel"]>;
259 def TargetMSP430 : TargetArch<["msp430"]>;
260 def TargetX86 : TargetArch<["x86"]>;
261 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
262 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
263   let OSes = ["Win32"];
264 }
265 def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
266   let CXXABIs = ["Microsoft"];
267 }
268
269 class Attr {
270   // The various ways in which an attribute can be spelled in source
271   list<Spelling> Spellings;
272   // The things to which an attribute can appertain
273   SubjectList Subjects;
274   // The arguments allowed on an attribute
275   list<Argument> Args = [];
276   // Accessors which should be generated for the attribute.
277   list<Accessor> Accessors = [];
278   // Set to true for attributes with arguments which require delayed parsing.
279   bit LateParsed = 0;
280   // Set to false to prevent an attribute from being propagated from a template
281   // to the instantiation.
282   bit Clone = 1;
283   // Set to true for attributes which must be instantiated within templates
284   bit TemplateDependent = 0;
285   // Set to true for attributes that have a corresponding AST node.
286   bit ASTNode = 1;
287   // Set to true for attributes which have handler in Sema.
288   bit SemaHandler = 1;
289   // Set to true for attributes that are completely ignored.
290   bit Ignored = 0;
291   // Set to true if the attribute's parsing does not match its semantic
292   // content. Eg) It parses 3 args, but semantically takes 4 args.  Opts out of
293   // common attribute error checking.
294   bit HasCustomParsing = 0;
295   // Set to true if all of the attribute's arguments should be parsed in an
296   // unevaluated context.
297   bit ParseArgumentsAsUnevaluated = 0;
298   // Set to true if this attribute can be duplicated on a subject when merging
299   // attributes. By default, attributes are not merged.
300   bit DuplicatesAllowedWhileMerging = 0;
301   // Lists language options, one of which is required to be true for the
302   // attribute to be applicable. If empty, no language options are required.
303   list<LangOpt> LangOpts = [];
304   // Any additional text that should be included verbatim in the class.
305   // Note: Any additional data members will leak and should be constructed
306   // externally on the ASTContext.
307   code AdditionalMembers = [{}];
308   // Any documentation that should be associated with the attribute. Since an
309   // attribute may be documented under multiple categories, more than one
310   // Documentation entry may be listed.
311   list<Documentation> Documentation;
312 }
313
314 /// A type attribute is not processed on a declaration or a statement.
315 class TypeAttr : Attr {
316   // By default, type attributes do not get an AST node.
317   let ASTNode = 0;
318 }
319
320 /// A stmt attribute is not processed on a declaration or a type.
321 class StmtAttr : Attr;
322
323 /// An inheritable attribute is inherited by later redeclarations.
324 class InheritableAttr : Attr;
325
326 /// A target-specific attribute.  This class is meant to be used as a mixin
327 /// with InheritableAttr or Attr depending on the attribute's needs.
328 class TargetSpecificAttr<TargetArch target> {
329   TargetArch Target = target;
330   // Attributes are generally required to have unique spellings for their names
331   // so that the parser can determine what kind of attribute it has parsed.
332   // However, target-specific attributes are special in that the attribute only
333   // "exists" for a given target. So two target-specific attributes can share
334   // the same name when they exist in different targets. To support this, a
335   // Kind can be explicitly specified for a target-specific attribute. This
336   // corresponds to the AttributeList::AT_* enum that is generated and it
337   // should contain a shared value between the attributes.
338   //
339   // Target-specific attributes which use this feature should ensure that the
340   // spellings match exactly betweeen the attributes, and if the arguments or
341   // subjects differ, should specify HasCustomParsing = 1 and implement their
342   // own parsing and semantic handling requirements as-needed.
343   string ParseKind;
344 }
345
346 /// An inheritable parameter attribute is inherited by later
347 /// redeclarations, even when it's written on a parameter.
348 class InheritableParamAttr : InheritableAttr;
349
350 /// An attribute which changes the ABI rules for a specific parameter.
351 class ParameterABIAttr : InheritableParamAttr {
352   let Subjects = SubjectList<[ParmVar]>;
353 }
354
355 /// An ignored attribute, which we parse but discard with no checking.
356 class IgnoredAttr : Attr {
357   let Ignored = 1;
358   let ASTNode = 0;
359   let SemaHandler = 0;
360   let Documentation = [Undocumented];
361 }
362
363 //
364 // Attributes begin here
365 //
366
367 def AbiTag : Attr {
368   let Spellings = [GCC<"abi_tag">];
369   let Args = [VariadicStringArgument<"Tags">];
370   let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag,
371       "ExpectedStructClassVariableFunctionOrInlineNamespace">;
372   let Documentation = [AbiTagsDocs];
373 }
374
375 def AddressSpace : TypeAttr {
376   let Spellings = [GNU<"address_space">];
377   let Args = [IntArgument<"AddressSpace">];
378   let Documentation = [Undocumented];
379 }
380
381 def Alias : Attr {
382   let Spellings = [GCC<"alias">];
383   let Args = [StringArgument<"Aliasee">];
384   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
385                              "ExpectedFunctionOrGlobalVar">;
386   let Documentation = [Undocumented];
387 }
388
389 def Aligned : InheritableAttr {
390   let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">,
391                    Keyword<"_Alignas">];
392 //  let Subjects = SubjectList<[NonBitField, NormalVar, Tag]>;
393   let Args = [AlignedArgument<"Alignment", 1>];
394   let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
395                    Accessor<"isC11", [Keyword<"_Alignas">]>,
396                    Accessor<"isAlignas", [Keyword<"alignas">,
397                                           Keyword<"_Alignas">]>,
398                    Accessor<"isDeclspec",[Declspec<"align">]>];
399   let Documentation = [Undocumented];
400 }
401
402 def AlignValue : Attr {
403   let Spellings = [
404     // Unfortunately, this is semantically an assertion, not a directive
405     // (something else must ensure the alignment), so aligned_value is a
406     // probably a better name. We might want to add an aligned_value spelling in
407     // the future (and a corresponding C++ attribute), but this can be done
408     // later once we decide if we also want them to have slightly-different
409     // semantics than Intel's align_value.
410     GNU<"align_value">
411     // Intel's compiler on Windows also supports:
412     // , Declspec<"align_value">
413   ];
414   let Args = [ExprArgument<"Alignment">];
415   let Subjects = SubjectList<[Var, TypedefName], WarnDiag,
416                              "ExpectedVariableOrTypedef">;
417   let Documentation = [AlignValueDocs];
418 }
419
420 def AlignMac68k : InheritableAttr {
421   // This attribute has no spellings as it is only ever created implicitly.
422   let Spellings = [];
423   let SemaHandler = 0;
424   let Documentation = [Undocumented];
425 }
426
427 def AlwaysInline : InheritableAttr {
428   let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
429   let Subjects = SubjectList<[Function]>;
430   let Documentation = [Undocumented];
431 }
432
433 def XRayInstrument : InheritableAttr {
434   let Spellings = [GNU<"xray_always_instrument">,
435                    CXX11<"clang", "xray_always_instrument">,
436                    GNU<"xray_never_instrument">,
437                    CXX11<"clang", "xray_never_instrument">];
438   let Subjects = SubjectList<[CXXMethod, ObjCMethod, Function], WarnDiag,
439                               "ExpectedFunctionOrMethod">;
440   let Accessors = [Accessor<"alwaysXRayInstrument",
441                      [GNU<"xray_always_instrument">,
442                       CXX11<"clang", "xray_always_instrument">]>,
443                    Accessor<"neverXRayInstrument",
444                      [GNU<"xray_never_instrument">,
445                       CXX11<"clang", "xray_never_instrument">]>];
446   let Documentation = [XRayDocs];
447 }
448
449 def TLSModel : InheritableAttr {
450   let Spellings = [GCC<"tls_model">];
451   let Subjects = SubjectList<[TLSVar], ErrorDiag, "ExpectedTLSVar">;
452   let Args = [StringArgument<"Model">];
453   let Documentation = [TLSModelDocs];
454 }
455
456 def AnalyzerNoReturn : InheritableAttr {
457   let Spellings = [GNU<"analyzer_noreturn">];
458   let Documentation = [Undocumented];
459 }
460
461 def Annotate : InheritableParamAttr {
462   let Spellings = [GNU<"annotate">];
463   let Args = [StringArgument<"Annotation">];
464   let Documentation = [Undocumented];
465 }
466
467 def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> {
468   // NOTE: If you add any additional spellings, MSP430Interrupt's,
469   // MipsInterrupt's and AnyX86Interrupt's spellings must match.
470   let Spellings = [GNU<"interrupt">];
471   let Args = [EnumArgument<"Interrupt", "InterruptType",
472                            ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
473                            ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
474                            1>];
475   let ParseKind = "Interrupt";
476   let HasCustomParsing = 1;
477   let Documentation = [ARMInterruptDocs];
478 }
479
480 def AsmLabel : InheritableAttr {
481   let Spellings = [Keyword<"asm">, Keyword<"__asm__">];
482   let Args = [StringArgument<"Label">];
483   let SemaHandler = 0;
484   let Documentation = [Undocumented];
485 }
486
487 def Availability : InheritableAttr {
488   let Spellings = [GNU<"availability">];
489   let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
490               VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
491               BoolArgument<"unavailable">, StringArgument<"message">,
492               BoolArgument<"strict">, StringArgument<"replacement">];
493   let AdditionalMembers =
494 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
495     return llvm::StringSwitch<llvm::StringRef>(Platform)
496              .Case("android", "Android")
497              .Case("ios", "iOS")
498              .Case("macos", "macOS")
499              .Case("tvos", "tvOS")
500              .Case("watchos", "watchOS")
501              .Case("ios_app_extension", "iOS (App Extension)")
502              .Case("macos_app_extension", "macOS (App Extension)")
503              .Case("tvos_app_extension", "tvOS (App Extension)")
504              .Case("watchos_app_extension", "watchOS (App Extension)")
505              .Default(llvm::StringRef());
506 } }];
507   let HasCustomParsing = 1;
508   let DuplicatesAllowedWhileMerging = 1;
509 //  let Subjects = SubjectList<[Named]>;
510   let Documentation = [AvailabilityDocs];
511 }
512
513 def Blocks : InheritableAttr {
514   let Spellings = [GNU<"blocks">];
515   let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
516   let Documentation = [Undocumented];
517 }
518
519 def Bounded : IgnoredAttr {
520   let Spellings = [GNU<"bounded">];
521 }
522
523 def CarriesDependency : InheritableParamAttr {
524   let Spellings = [GNU<"carries_dependency">,
525                    CXX11<"","carries_dependency", 200809>];
526   let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>;
527   let Documentation = [CarriesDependencyDocs];
528 }
529
530 def CDecl : InheritableAttr {
531   let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">];
532 //  let Subjects = [Function, ObjCMethod];
533   let Documentation = [Undocumented];
534 }
535
536 // cf_audited_transfer indicates that the given function has been
537 // audited and has been marked with the appropriate cf_consumed and
538 // cf_returns_retained attributes.  It is generally applied by
539 // '#pragma clang arc_cf_code_audited' rather than explicitly.
540 def CFAuditedTransfer : InheritableAttr {
541   let Spellings = [GNU<"cf_audited_transfer">];
542   let Subjects = SubjectList<[Function], ErrorDiag>;
543   let Documentation = [Undocumented];
544 }
545
546 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
547 // It indicates that the function has unknown or unautomatable
548 // transfer semantics.
549 def CFUnknownTransfer : InheritableAttr {
550   let Spellings = [GNU<"cf_unknown_transfer">];
551   let Subjects = SubjectList<[Function], ErrorDiag>;
552   let Documentation = [Undocumented];
553 }
554
555 def CFReturnsRetained : InheritableAttr {
556   let Spellings = [GNU<"cf_returns_retained">];
557 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
558   let Documentation = [Undocumented];
559 }
560
561 def CFReturnsNotRetained : InheritableAttr {
562   let Spellings = [GNU<"cf_returns_not_retained">];
563 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
564   let Documentation = [Undocumented];
565 }
566
567 def CFConsumed : InheritableParamAttr {
568   let Spellings = [GNU<"cf_consumed">];
569   let Subjects = SubjectList<[ParmVar]>;
570   let Documentation = [Undocumented];
571 }
572
573 def Cleanup : InheritableAttr {
574   let Spellings = [GCC<"cleanup">];
575   let Args = [FunctionArgument<"FunctionDecl">];
576   let Subjects = SubjectList<[Var]>;
577   let Documentation = [Undocumented];
578 }
579
580 def Cold : InheritableAttr {
581   let Spellings = [GCC<"cold">];
582   let Subjects = SubjectList<[Function]>;
583   let Documentation = [Undocumented];
584 }
585
586 def Common : InheritableAttr {
587   let Spellings = [GCC<"common">];
588   let Subjects = SubjectList<[Var]>;
589   let Documentation = [Undocumented];
590 }
591
592 def Const : InheritableAttr {
593   let Spellings = [GCC<"const">, GCC<"__const">];
594   let Documentation = [Undocumented];
595 }
596
597 def Constructor : InheritableAttr {
598   let Spellings = [GCC<"constructor">];
599   let Args = [DefaultIntArgument<"Priority", 65535>];
600   let Subjects = SubjectList<[Function]>;
601   let Documentation = [Undocumented];
602 }
603
604 def CUDAConstant : InheritableAttr {
605   let Spellings = [GNU<"constant">];
606   let Subjects = SubjectList<[Var]>;
607   let LangOpts = [CUDA];
608   let Documentation = [Undocumented];
609 }
610
611 def CUDACudartBuiltin : IgnoredAttr {
612   let Spellings = [GNU<"cudart_builtin">];
613   let LangOpts = [CUDA];
614 }
615
616 def CUDADevice : InheritableAttr {
617   let Spellings = [GNU<"device">];
618   let Subjects = SubjectList<[Function, Var]>;
619   let LangOpts = [CUDA];
620   let Documentation = [Undocumented];
621 }
622
623 def CUDADeviceBuiltin : IgnoredAttr {
624   let Spellings = [GNU<"device_builtin">];
625   let LangOpts = [CUDA];
626 }
627
628 def CUDADeviceBuiltinSurfaceType : IgnoredAttr {
629   let Spellings = [GNU<"device_builtin_surface_type">];
630   let LangOpts = [CUDA];
631 }
632
633 def CUDADeviceBuiltinTextureType : IgnoredAttr {
634   let Spellings = [GNU<"device_builtin_texture_type">];
635   let LangOpts = [CUDA];
636 }
637
638 def CUDAGlobal : InheritableAttr {
639   let Spellings = [GNU<"global">];
640   let Subjects = SubjectList<[Function]>;
641   let LangOpts = [CUDA];
642   let Documentation = [Undocumented];
643 }
644
645 def CUDAHost : InheritableAttr {
646   let Spellings = [GNU<"host">];
647   let Subjects = SubjectList<[Function]>;
648   let LangOpts = [CUDA];
649   let Documentation = [Undocumented];
650 }
651
652 def CUDAInvalidTarget : InheritableAttr {
653   let Spellings = [];
654   let Subjects = SubjectList<[Function]>;
655   let LangOpts = [CUDA];
656   let Documentation = [Undocumented];
657 }
658
659 def CUDALaunchBounds : InheritableAttr {
660   let Spellings = [GNU<"launch_bounds">];
661   let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>];
662   let LangOpts = [CUDA];
663   let Subjects = SubjectList<[ObjCMethod, FunctionLike], WarnDiag,
664                              "ExpectedFunctionOrMethod">;
665   // An AST node is created for this attribute, but is not used by other parts
666   // of the compiler. However, this node needs to exist in the AST because
667   // non-LLVM backends may be relying on the attribute's presence.
668   let Documentation = [Undocumented];
669 }
670
671 def CUDAShared : InheritableAttr {
672   let Spellings = [GNU<"shared">];
673   let Subjects = SubjectList<[Var]>;
674   let LangOpts = [CUDA];
675   let Documentation = [Undocumented];
676 }
677
678 def C11NoReturn : InheritableAttr {
679   let Spellings = [Keyword<"_Noreturn">];
680   let Subjects = SubjectList<[Function], ErrorDiag>;
681   let SemaHandler = 0;
682   let Documentation = [C11NoReturnDocs];
683 }
684
685 def CXX11NoReturn : InheritableAttr {
686   let Spellings = [CXX11<"","noreturn", 200809>];
687   let Subjects = SubjectList<[Function], ErrorDiag>;
688   let Documentation = [CXX11NoReturnDocs];
689 }
690
691 def OpenCLKernel : InheritableAttr {
692   let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
693   let Subjects = SubjectList<[Function], ErrorDiag>;
694   let Documentation = [Undocumented];
695 }
696
697 def OpenCLUnrollHint : InheritableAttr {
698   let Spellings = [GNU<"opencl_unroll_hint">];
699   let Args = [UnsignedArgument<"UnrollHint">];
700   let Documentation = [OpenCLUnrollHintDocs];
701 }
702
703 // This attribute is both a type attribute, and a declaration attribute (for
704 // parameter variables).
705 def OpenCLAccess : Attr {
706   let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
707                    Keyword<"__write_only">, Keyword<"write_only">,
708                    Keyword<"__read_write">, Keyword<"read_write">];
709   let Subjects = SubjectList<[ParmVar, TypedefName], ErrorDiag,
710                              "ExpectedParameterOrTypedef">;
711   let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
712                                            Keyword<"read_only">]>,
713                    Accessor<"isReadWrite", [Keyword<"__read_write">,
714                                             Keyword<"read_write">]>,
715                    Accessor<"isWriteOnly", [Keyword<"__write_only">,
716                                             Keyword<"write_only">]>];
717   let Documentation = [OpenCLAccessDocs];
718 }
719
720 def OpenCLPrivateAddressSpace : TypeAttr {
721   let Spellings = [Keyword<"__private">, Keyword<"private">];
722   let Documentation = [OpenCLAddressSpacePrivateDocs];
723 }
724
725 def OpenCLGlobalAddressSpace : TypeAttr {
726   let Spellings = [Keyword<"__global">, Keyword<"global">];
727   let Documentation = [OpenCLAddressSpaceGlobalDocs];
728 }
729
730 def OpenCLLocalAddressSpace : TypeAttr {
731   let Spellings = [Keyword<"__local">, Keyword<"local">];
732   let Documentation = [OpenCLAddressSpaceLocalDocs];
733 }
734
735 def OpenCLConstantAddressSpace : TypeAttr {
736   let Spellings = [Keyword<"__constant">, Keyword<"constant">];
737   let Documentation = [OpenCLAddressSpaceConstantDocs];
738 }
739
740 def OpenCLGenericAddressSpace : TypeAttr {
741   let Spellings = [Keyword<"__generic">, Keyword<"generic">];
742   let Documentation = [OpenCLAddressSpaceGenericDocs];
743 }
744
745 def OpenCLNoSVM : Attr {
746   let Spellings = [GNU<"nosvm">];
747   let Subjects = SubjectList<[Var]>;
748   let Documentation = [OpenCLNoSVMDocs];
749   let LangOpts = [OpenCL];
750   let ASTNode = 0;
751 }
752
753 def RenderScriptKernel : Attr {
754   let Spellings = [GNU<"kernel">];
755   let Subjects = SubjectList<[Function]>;
756   let Documentation = [RenderScriptKernelAttributeDocs];
757   let LangOpts = [RenderScript];
758 }
759
760 def Deprecated : InheritableAttr {
761   let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
762                    CXX11<"","deprecated", 201309>];
763   let Args = [StringArgument<"Message", 1>,
764               // An optional string argument that enables us to provide a
765               // Fix-It.
766               StringArgument<"Replacement", 1>];
767   let Documentation = [DeprecatedDocs];
768 }
769
770 def Destructor : InheritableAttr {
771   let Spellings = [GCC<"destructor">];
772   let Args = [DefaultIntArgument<"Priority", 65535>];
773   let Subjects = SubjectList<[Function]>;
774   let Documentation = [Undocumented];
775 }
776
777 def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
778   let Spellings = [Declspec<"empty_bases">];
779   let Subjects = SubjectList<[CXXRecord]>;
780   let Documentation = [EmptyBasesDocs];
781 }
782
783 def AllocSize : InheritableAttr {
784   let Spellings = [GCC<"alloc_size">];
785   let Subjects = SubjectList<[Function]>;
786   let Args = [IntArgument<"ElemSizeParam">, IntArgument<"NumElemsParam", 1>];
787   let TemplateDependent = 1;
788   let Documentation = [AllocSizeDocs];
789 }
790
791 def EnableIf : InheritableAttr {
792   let Spellings = [GNU<"enable_if">];
793   let Subjects = SubjectList<[Function]>;
794   let Args = [ExprArgument<"Cond">, StringArgument<"Message">];
795   let TemplateDependent = 1;
796   let Documentation = [EnableIfDocs];
797 }
798
799 def ExtVectorType : Attr {
800   let Spellings = [GNU<"ext_vector_type">];
801   let Subjects = SubjectList<[TypedefName], ErrorDiag>;
802   let Args = [ExprArgument<"NumElements">];
803   let ASTNode = 0;
804   let Documentation = [Undocumented];
805 }
806
807 def FallThrough : StmtAttr {
808   let Spellings = [CXX11<"", "fallthrough", 201603>,
809                    CXX11<"clang", "fallthrough">];
810 //  let Subjects = [NullStmt];
811   let Documentation = [FallthroughDocs];
812 }
813
814 def FastCall : InheritableAttr {
815   let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
816                    Keyword<"_fastcall">];
817 //  let Subjects = [Function, ObjCMethod];
818   let Documentation = [FastCallDocs];
819 }
820
821 def RegCall : InheritableAttr {
822   let Spellings = [GCC<"regcall">, Keyword<"__regcall">];
823   let Documentation = [RegCallDocs];
824 }
825
826 def Final : InheritableAttr {
827   let Spellings = [Keyword<"final">, Keyword<"sealed">];
828   let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
829   let SemaHandler = 0;
830   let Documentation = [Undocumented];
831 }
832
833 def MinSize : InheritableAttr {
834   let Spellings = [GNU<"minsize">];
835   let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
836   let Documentation = [Undocumented];
837 }
838
839 def FlagEnum : InheritableAttr {
840   let Spellings = [GNU<"flag_enum">];
841   let Subjects = SubjectList<[Enum]>;
842   let Documentation = [FlagEnumDocs];
843   let LangOpts = [COnly];
844 }
845
846 def Flatten : InheritableAttr {
847   let Spellings = [GCC<"flatten">];
848   let Subjects = SubjectList<[Function], ErrorDiag>;
849   let Documentation = [FlattenDocs];
850 }
851
852 def Format : InheritableAttr {
853   let Spellings = [GCC<"format">];
854   let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
855               IntArgument<"FirstArg">];
856   let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto], WarnDiag,
857                              "ExpectedFunctionWithProtoType">;
858   let Documentation = [FormatDocs];
859 }
860
861 def FormatArg : InheritableAttr {
862   let Spellings = [GCC<"format_arg">];
863   let Args = [IntArgument<"FormatIdx">];
864   let Subjects = SubjectList<[ObjCMethod, HasFunctionProto], WarnDiag,
865                              "ExpectedFunctionWithProtoType">;
866   let Documentation = [Undocumented];
867 }
868
869 def GNUInline : InheritableAttr {
870   let Spellings = [GCC<"gnu_inline">];
871   let Subjects = SubjectList<[Function]>;
872   let Documentation = [Undocumented];
873 }
874
875 def Hot : InheritableAttr {
876   let Spellings = [GCC<"hot">];
877   let Subjects = SubjectList<[Function]>;
878   // An AST node is created for this attribute, but not actually used beyond
879   // semantic checking for mutual exclusion with the Cold attribute.
880   let Documentation = [Undocumented];
881 }
882
883 def IBAction : InheritableAttr {
884   let Spellings = [GNU<"ibaction">];
885   let Subjects = SubjectList<[ObjCInstanceMethod], WarnDiag,
886                              "ExpectedObjCInstanceMethod">;
887   // An AST node is created for this attribute, but is not used by other parts
888   // of the compiler. However, this node needs to exist in the AST because
889   // external tools rely on it.
890   let Documentation = [Undocumented];
891 }
892
893 def IBOutlet : InheritableAttr {
894   let Spellings = [GNU<"iboutlet">];
895 //  let Subjects = [ObjCIvar, ObjCProperty];
896   let Documentation = [Undocumented];
897 }
898
899 def IBOutletCollection : InheritableAttr {
900   let Spellings = [GNU<"iboutletcollection">];
901   let Args = [TypeArgument<"Interface", 1>];
902 //  let Subjects = [ObjCIvar, ObjCProperty];
903   let Documentation = [Undocumented];
904 }
905
906 def IFunc : Attr {
907   let Spellings = [GCC<"ifunc">];
908   let Args = [StringArgument<"Resolver">];
909   let Subjects = SubjectList<[Function]>;
910   let Documentation = [IFuncDocs];
911 }
912
913 def Restrict : InheritableAttr {
914   let Spellings = [Declspec<"restrict">, GCC<"malloc">];
915   let Subjects = SubjectList<[Function]>;
916   let Documentation = [Undocumented];
917 }
918
919 def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
920   let Spellings = [Declspec<"layout_version">];
921   let Args = [UnsignedArgument<"Version">];
922   let Subjects = SubjectList<[CXXRecord]>;
923   let Documentation = [LayoutVersionDocs];
924 }
925
926 def MaxFieldAlignment : InheritableAttr {
927   // This attribute has no spellings as it is only ever created implicitly.
928   let Spellings = [];
929   let Args = [UnsignedArgument<"Alignment">];
930   let SemaHandler = 0;
931   let Documentation = [Undocumented];
932 }
933
934 def MayAlias : InheritableAttr {
935   // FIXME: this is a type attribute in GCC, but a declaration attribute here.
936   let Spellings = [GCC<"may_alias">];
937   let Documentation = [Undocumented];
938 }
939
940 def MSABI : InheritableAttr {
941   let Spellings = [GCC<"ms_abi">];
942 //  let Subjects = [Function, ObjCMethod];
943   let Documentation = [MSABIDocs];
944 }
945
946 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
947   // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's
948   // and AnyX86Interrupt's spellings must match.
949   let Spellings = [GNU<"interrupt">];
950   let Args = [UnsignedArgument<"Number">];
951   let ParseKind = "Interrupt";
952   let HasCustomParsing = 1;
953   let Documentation = [Undocumented];
954 }
955
956 def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
957   let Spellings = [GCC<"mips16">];
958   let Subjects = SubjectList<[Function], ErrorDiag>;
959   let Documentation = [Undocumented];
960 }
961
962 def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips> {
963   // NOTE: If you add any additional spellings, ARMInterrupt's,
964   // MSP430Interrupt's and AnyX86Interrupt's spellings must match.
965   let Spellings = [GNU<"interrupt">];
966   let Subjects = SubjectList<[Function]>;
967   let Args = [EnumArgument<"Interrupt", "InterruptType",
968                            ["vector=sw0", "vector=sw1", "vector=hw0",
969                             "vector=hw1", "vector=hw2", "vector=hw3",
970                             "vector=hw4", "vector=hw5", "eic", ""],
971                            ["sw0", "sw1", "hw0", "hw1", "hw2", "hw3",
972                             "hw4", "hw5", "eic", "eic"]
973                            >];
974   let ParseKind = "Interrupt";
975   let Documentation = [MipsInterruptDocs];
976 }
977
978 def Mode : Attr {
979   let Spellings = [GCC<"mode">];
980   let Subjects = SubjectList<[Var, Enum, TypedefName, Field], ErrorDiag,
981                              "ExpectedVariableEnumFieldOrTypedef">;
982   let Args = [IdentifierArgument<"Mode">];
983   let Documentation = [Undocumented];
984 }
985
986 def Naked : InheritableAttr {
987   let Spellings = [GCC<"naked">, Declspec<"naked">];
988   let Subjects = SubjectList<[Function]>;
989   let Documentation = [Undocumented];
990 }
991
992 def NeonPolyVectorType : TypeAttr {
993   let Spellings = [GNU<"neon_polyvector_type">];
994   let Args = [IntArgument<"NumElements">];
995   let Documentation = [Undocumented];
996 }
997
998 def NeonVectorType : TypeAttr {
999   let Spellings = [GNU<"neon_vector_type">];
1000   let Args = [IntArgument<"NumElements">];
1001   let Documentation = [Undocumented];
1002 }
1003
1004 def ReturnsTwice : InheritableAttr {
1005   let Spellings = [GCC<"returns_twice">];
1006   let Subjects = SubjectList<[Function]>;
1007   let Documentation = [Undocumented];
1008 }
1009
1010 def DisableTailCalls : InheritableAttr {
1011   let Spellings = [GNU<"disable_tail_calls">,
1012                    CXX11<"clang", "disable_tail_calls">];
1013   let Subjects = SubjectList<[Function, ObjCMethod]>;
1014   let Documentation = [DisableTailCallsDocs];
1015 }
1016
1017 def NoAlias : InheritableAttr {
1018   let Spellings = [Declspec<"noalias">];
1019   let Subjects = SubjectList<[Function]>;
1020   let Documentation = [NoAliasDocs];
1021 }
1022
1023 def NoCommon : InheritableAttr {
1024   let Spellings = [GCC<"nocommon">];
1025   let Subjects = SubjectList<[Var]>;
1026   let Documentation = [Undocumented];
1027 }
1028
1029 def NoDebug : InheritableAttr {
1030   let Spellings = [GCC<"nodebug">];
1031   let Subjects = SubjectList<[FunctionLike, ObjCMethod, NonParmVar], WarnDiag,
1032                               "ExpectedVariableOrFunction">;
1033   let Documentation = [NoDebugDocs];
1034 }
1035
1036 def NoDuplicate : InheritableAttr {
1037   let Spellings = [GNU<"noduplicate">, CXX11<"clang", "noduplicate">];
1038   let Subjects = SubjectList<[Function]>;
1039   let Documentation = [NoDuplicateDocs];
1040 }
1041
1042 def Convergent : InheritableAttr {
1043   let Spellings = [GNU<"convergent">, CXX11<"clang", "convergent">];
1044   let Subjects = SubjectList<[Function]>;
1045   let Documentation = [ConvergentDocs];
1046 }
1047
1048 def NoInline : InheritableAttr {
1049   let Spellings = [GCC<"noinline">, Declspec<"noinline">];
1050   let Subjects = SubjectList<[Function]>;
1051   let Documentation = [Undocumented];
1052 }
1053
1054 def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
1055   let Spellings = [GCC<"nomips16">];
1056   let Subjects = SubjectList<[Function], ErrorDiag>;
1057   let Documentation = [Undocumented];
1058 }
1059
1060 // This is not a TargetSpecificAttr so that is silently accepted and
1061 // ignored on other targets as encouraged by the OpenCL spec.
1062 //
1063 // See OpenCL 1.2 6.11.5: "It is our intention that a particular
1064 // implementation of OpenCL be free to ignore all attributes and the
1065 // resulting executable binary will produce the same result."
1066 //
1067 // However, only AMD GPU targets will emit the corresponding IR
1068 // attribute.
1069 //
1070 // FIXME: This provides a sub-optimal error message if you attempt to
1071 // use this in CUDA, since CUDA does not use the same terminology.
1072 //
1073 // FIXME: SubjectList should be for OpenCLKernelFunction, but is not to
1074 // workaround needing to see kernel attribute before others to know if
1075 // this should be rejected on non-kernels.
1076
1077 def AMDGPUFlatWorkGroupSize : InheritableAttr {
1078   let Spellings = [GNU<"amdgpu_flat_work_group_size">];
1079   let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max">];
1080   let Documentation = [AMDGPUFlatWorkGroupSizeDocs];
1081   let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1082 }
1083
1084 def AMDGPUWavesPerEU : InheritableAttr {
1085   let Spellings = [GNU<"amdgpu_waves_per_eu">];
1086   let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max", 1>];
1087   let Documentation = [AMDGPUWavesPerEUDocs];
1088   let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1089 }
1090
1091 def AMDGPUNumSGPR : InheritableAttr {
1092   let Spellings = [GNU<"amdgpu_num_sgpr">];
1093   let Args = [UnsignedArgument<"NumSGPR">];
1094   let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1095   let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1096 }
1097
1098 def AMDGPUNumVGPR : InheritableAttr {
1099   let Spellings = [GNU<"amdgpu_num_vgpr">];
1100   let Args = [UnsignedArgument<"NumVGPR">];
1101   let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1102   let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1103 }
1104
1105 def NoSplitStack : InheritableAttr {
1106   let Spellings = [GCC<"no_split_stack">];
1107   let Subjects = SubjectList<[Function], ErrorDiag>;
1108   let Documentation = [NoSplitStackDocs];
1109 }
1110
1111 def NonNull : InheritableAttr {
1112   let Spellings = [GCC<"nonnull">];
1113   let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
1114                              "ExpectedFunctionMethodOrParameter">;
1115   let Args = [VariadicUnsignedArgument<"Args">];
1116   let AdditionalMembers =
1117 [{bool isNonNull(unsigned idx) const {
1118     if (!args_size())
1119       return true;
1120     for (const auto &V : args())
1121       if (V == idx)
1122         return true;
1123     return false;
1124   } }];
1125   // FIXME: We should merge duplicates into a single nonnull attribute.
1126   let DuplicatesAllowedWhileMerging = 1;
1127   let Documentation = [NonNullDocs];
1128 }
1129
1130 def ReturnsNonNull : InheritableAttr {
1131   let Spellings = [GCC<"returns_nonnull">];
1132   let Subjects = SubjectList<[ObjCMethod, Function], WarnDiag,
1133                              "ExpectedFunctionOrMethod">;
1134   let Documentation = [ReturnsNonNullDocs];
1135 }
1136
1137 // pass_object_size(N) indicates that the parameter should have
1138 // __builtin_object_size with Type=N evaluated on the parameter at the callsite.
1139 def PassObjectSize : InheritableParamAttr {
1140   let Spellings = [GNU<"pass_object_size">];
1141   let Args = [IntArgument<"Type">];
1142   let Subjects = SubjectList<[ParmVar]>;
1143   let Documentation = [PassObjectSizeDocs];
1144 }
1145
1146 // Nullability type attributes.
1147 def TypeNonNull : TypeAttr {
1148   let Spellings = [Keyword<"_Nonnull">];
1149   let Documentation = [TypeNonNullDocs];
1150 }
1151
1152 def TypeNullable : TypeAttr {
1153   let Spellings = [Keyword<"_Nullable">];
1154   let Documentation = [TypeNullableDocs];
1155 }
1156
1157 def TypeNullUnspecified : TypeAttr {
1158   let Spellings = [Keyword<"_Null_unspecified">];
1159   let Documentation = [TypeNullUnspecifiedDocs];
1160 }
1161
1162 def ObjCKindOf : TypeAttr {
1163   let Spellings = [Keyword<"__kindof">];
1164   let Documentation = [Undocumented];
1165 }
1166
1167 def AssumeAligned : InheritableAttr {
1168   let Spellings = [GCC<"assume_aligned">];
1169   let Subjects = SubjectList<[ObjCMethod, Function]>;
1170   let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>];
1171   let Documentation = [AssumeAlignedDocs];
1172 }
1173
1174 def NoReturn : InheritableAttr {
1175   let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
1176   // FIXME: Does GCC allow this on the function instead?
1177   let Documentation = [Undocumented];
1178 }
1179
1180 def NoInstrumentFunction : InheritableAttr {
1181   let Spellings = [GCC<"no_instrument_function">];
1182   let Subjects = SubjectList<[Function]>;
1183   let Documentation = [Undocumented];
1184 }
1185
1186 def NotTailCalled : InheritableAttr {
1187   let Spellings = [GNU<"not_tail_called">, CXX11<"clang", "not_tail_called">];
1188   let Subjects = SubjectList<[Function]>;
1189   let Documentation = [NotTailCalledDocs];
1190 }
1191
1192 def NoThrow : InheritableAttr {
1193   let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
1194   let Documentation = [Undocumented];
1195 }
1196
1197 def NvWeak : IgnoredAttr {
1198   let Spellings = [GNU<"nv_weak">];
1199   let LangOpts = [CUDA];
1200 }
1201
1202 def ObjCBridge : InheritableAttr {
1203   let Spellings = [GNU<"objc_bridge">];
1204   let Subjects = SubjectList<[Record, TypedefName], ErrorDiag,
1205                              "ExpectedStructOrUnionOrTypedef">;
1206   let Args = [IdentifierArgument<"BridgedType">];
1207   let Documentation = [Undocumented];
1208 }
1209
1210 def ObjCBridgeMutable : InheritableAttr {
1211   let Spellings = [GNU<"objc_bridge_mutable">];
1212   let Subjects = SubjectList<[Record], ErrorDiag>;
1213   let Args = [IdentifierArgument<"BridgedType">];
1214   let Documentation = [Undocumented];
1215 }
1216
1217 def ObjCBridgeRelated : InheritableAttr {
1218   let Spellings = [GNU<"objc_bridge_related">];
1219   let Subjects = SubjectList<[Record], ErrorDiag>;
1220   let Args = [IdentifierArgument<"RelatedClass">,
1221           IdentifierArgument<"ClassMethod", 1>,
1222           IdentifierArgument<"InstanceMethod", 1>];
1223   let HasCustomParsing = 1;
1224   let Documentation = [Undocumented];
1225 }
1226
1227 def NSReturnsRetained : InheritableAttr {
1228   let Spellings = [GNU<"ns_returns_retained">];
1229 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1230   let Documentation = [Undocumented];
1231 }
1232
1233 def NSReturnsNotRetained : InheritableAttr {
1234   let Spellings = [GNU<"ns_returns_not_retained">];
1235 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1236   let Documentation = [Undocumented];
1237 }
1238
1239 def NSReturnsAutoreleased : InheritableAttr {
1240   let Spellings = [GNU<"ns_returns_autoreleased">];
1241 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1242   let Documentation = [Undocumented];
1243 }
1244
1245 def NSConsumesSelf : InheritableAttr {
1246   let Spellings = [GNU<"ns_consumes_self">];
1247   let Subjects = SubjectList<[ObjCMethod]>;
1248   let Documentation = [Undocumented];
1249 }
1250
1251 def NSConsumed : InheritableParamAttr {
1252   let Spellings = [GNU<"ns_consumed">];
1253   let Subjects = SubjectList<[ParmVar]>;
1254   let Documentation = [Undocumented];
1255 }
1256
1257 def ObjCException : InheritableAttr {
1258   let Spellings = [GNU<"objc_exception">];
1259   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1260   let Documentation = [Undocumented];
1261 }
1262
1263 def ObjCMethodFamily : InheritableAttr {
1264   let Spellings = [GNU<"objc_method_family">];
1265   let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1266   let Args = [EnumArgument<"Family", "FamilyKind",
1267                ["none", "alloc", "copy", "init", "mutableCopy", "new"],
1268                ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
1269                 "OMF_mutableCopy", "OMF_new"]>];
1270   let Documentation = [ObjCMethodFamilyDocs];
1271 }
1272
1273 def ObjCNSObject : InheritableAttr {
1274   let Spellings = [GNU<"NSObject">];
1275   let Documentation = [Undocumented];
1276 }
1277
1278 def ObjCIndependentClass : InheritableAttr {
1279   let Spellings = [GNU<"objc_independent_class">];
1280   let Documentation = [Undocumented];
1281 }
1282
1283 def ObjCPreciseLifetime : InheritableAttr {
1284   let Spellings = [GNU<"objc_precise_lifetime">];
1285   let Subjects = SubjectList<[Var], ErrorDiag>;
1286   let Documentation = [Undocumented];
1287 }
1288
1289 def ObjCReturnsInnerPointer : InheritableAttr {
1290   let Spellings = [GNU<"objc_returns_inner_pointer">];
1291   let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
1292   let Documentation = [Undocumented];
1293 }
1294
1295 def ObjCRequiresSuper : InheritableAttr {
1296   let Spellings = [GNU<"objc_requires_super">];
1297   let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1298   let Documentation = [ObjCRequiresSuperDocs];
1299 }
1300
1301 def ObjCRootClass : InheritableAttr {
1302   let Spellings = [GNU<"objc_root_class">];
1303   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1304   let Documentation = [Undocumented];
1305 }
1306
1307 def ObjCSubclassingRestricted : InheritableAttr {
1308   let Spellings = [GNU<"objc_subclassing_restricted">];
1309   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1310   let Documentation = [ObjCSubclassingRestrictedDocs];
1311 }
1312
1313 def ObjCExplicitProtocolImpl : InheritableAttr {
1314   let Spellings = [GNU<"objc_protocol_requires_explicit_implementation">];
1315   let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
1316   let Documentation = [Undocumented];
1317 }
1318
1319 def ObjCDesignatedInitializer : Attr {
1320   let Spellings = [GNU<"objc_designated_initializer">];
1321   let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag,
1322                              "ExpectedObjCInterfaceDeclInitMethod">;
1323   let Documentation = [Undocumented];
1324 }
1325
1326 def ObjCRuntimeName : Attr {
1327   let Spellings = [GNU<"objc_runtime_name">];
1328   let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
1329   let Args = [StringArgument<"MetadataName">];
1330   let Documentation = [ObjCRuntimeNameDocs];
1331 }
1332
1333 def ObjCRuntimeVisible : Attr {
1334   let Spellings = [GNU<"objc_runtime_visible">];
1335   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1336   let Documentation = [ObjCRuntimeVisibleDocs];
1337 }
1338
1339 def ObjCBoxable : Attr {
1340   let Spellings = [GNU<"objc_boxable">];
1341   let Subjects = SubjectList<[Record], ErrorDiag, "ExpectedStructOrUnion">;
1342   let Documentation = [ObjCBoxableDocs];
1343 }
1344
1345 def OptimizeNone : InheritableAttr {
1346   let Spellings = [GNU<"optnone">, CXX11<"clang", "optnone">];
1347   let Subjects = SubjectList<[Function, ObjCMethod]>;
1348   let Documentation = [OptnoneDocs];
1349 }
1350
1351 def Overloadable : Attr {
1352   let Spellings = [GNU<"overloadable">];
1353   let Subjects = SubjectList<[Function], ErrorDiag>;
1354   let Documentation = [OverloadableDocs];
1355 }
1356
1357 def Override : InheritableAttr { 
1358   let Spellings = [Keyword<"override">];
1359   let SemaHandler = 0;
1360   let Documentation = [Undocumented];
1361 }
1362
1363 def Ownership : InheritableAttr {
1364   let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
1365                    GNU<"ownership_takes">];
1366   let Accessors = [Accessor<"isHolds", [GNU<"ownership_holds">]>,
1367                    Accessor<"isReturns", [GNU<"ownership_returns">]>,
1368                    Accessor<"isTakes", [GNU<"ownership_takes">]>];
1369   let AdditionalMembers = [{
1370     enum OwnershipKind { Holds, Returns, Takes };
1371     OwnershipKind getOwnKind() const {
1372       return isHolds() ? Holds :
1373              isTakes() ? Takes :
1374              Returns;
1375     }
1376   }];
1377   let Args = [IdentifierArgument<"Module">, VariadicUnsignedArgument<"Args">];
1378   let Subjects = SubjectList<[HasFunctionProto], WarnDiag,
1379                              "ExpectedFunctionWithProtoType">;
1380   let Documentation = [Undocumented];
1381 }
1382
1383 def Packed : InheritableAttr {
1384   let Spellings = [GCC<"packed">];
1385 //  let Subjects = [Tag, Field];
1386   let Documentation = [Undocumented];
1387 }
1388
1389 def IntelOclBicc : InheritableAttr {
1390   let Spellings = [GNU<"intel_ocl_bicc">];
1391 //  let Subjects = [Function, ObjCMethod];
1392   let Documentation = [Undocumented];
1393 }
1394
1395 def Pcs : InheritableAttr {
1396   let Spellings = [GCC<"pcs">];
1397   let Args = [EnumArgument<"PCS", "PCSType",
1398                            ["aapcs", "aapcs-vfp"],
1399                            ["AAPCS", "AAPCS_VFP"]>];
1400 //  let Subjects = [Function, ObjCMethod];
1401   let Documentation = [PcsDocs];
1402 }
1403
1404 def Pure : InheritableAttr {
1405   let Spellings = [GCC<"pure">];
1406   let Documentation = [Undocumented];
1407 }
1408
1409 def Regparm : TypeAttr {
1410   let Spellings = [GCC<"regparm">];
1411   let Args = [UnsignedArgument<"NumParams">];
1412   let Documentation = [RegparmDocs];
1413 }
1414
1415 def ReqdWorkGroupSize : InheritableAttr {
1416   let Spellings = [GNU<"reqd_work_group_size">];
1417   let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
1418               UnsignedArgument<"ZDim">];
1419   let Subjects = SubjectList<[Function], ErrorDiag>;
1420   let Documentation = [Undocumented];
1421 }
1422
1423 def RequireConstantInit : InheritableAttr {
1424   let Spellings = [GNU<"require_constant_initialization">,
1425                    CXX11<"clang", "require_constant_initialization">];
1426   let Subjects = SubjectList<[GlobalVar], ErrorDiag,
1427                               "ExpectedStaticOrTLSVar">;
1428   let Documentation = [RequireConstantInitDocs];
1429   let LangOpts = [CPlusPlus];
1430 }
1431
1432 def WorkGroupSizeHint :  InheritableAttr {
1433   let Spellings = [GNU<"work_group_size_hint">];
1434   let Args = [UnsignedArgument<"XDim">, 
1435               UnsignedArgument<"YDim">,
1436               UnsignedArgument<"ZDim">];
1437   let Subjects = SubjectList<[Function], ErrorDiag>;
1438   let Documentation = [Undocumented];
1439 }
1440
1441 def InitPriority : InheritableAttr {
1442   let Spellings = [GNU<"init_priority">];
1443   let Args = [UnsignedArgument<"Priority">];
1444   let Subjects = SubjectList<[Var], ErrorDiag>;
1445   let Documentation = [Undocumented];
1446 }
1447
1448 def Section : InheritableAttr {
1449   let Spellings = [GCC<"section">, Declspec<"allocate">];
1450   let Args = [StringArgument<"Name">];
1451   let Subjects = SubjectList<[Function, GlobalVar,
1452                               ObjCMethod, ObjCProperty], ErrorDiag,
1453                              "ExpectedFunctionGlobalVarMethodOrProperty">;
1454   let Documentation = [SectionDocs];
1455 }
1456
1457 def Sentinel : InheritableAttr {
1458   let Spellings = [GCC<"sentinel">];
1459   let Args = [DefaultIntArgument<"Sentinel", 0>,
1460               DefaultIntArgument<"NullPos", 0>];
1461 //  let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
1462   let Documentation = [Undocumented];
1463 }
1464
1465 def StdCall : InheritableAttr {
1466   let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
1467 //  let Subjects = [Function, ObjCMethod];
1468   let Documentation = [StdCallDocs];
1469 }
1470
1471 def SwiftCall : InheritableAttr {
1472   let Spellings = [GCC<"swiftcall">];
1473 //  let Subjects = SubjectList<[Function]>;
1474   let Documentation = [SwiftCallDocs];
1475 }
1476
1477 def SwiftContext : ParameterABIAttr {
1478   let Spellings = [GCC<"swift_context">];
1479   let Documentation = [SwiftContextDocs];
1480 }
1481
1482 def SwiftErrorResult : ParameterABIAttr {
1483   let Spellings = [GCC<"swift_error_result">];
1484   let Documentation = [SwiftErrorResultDocs];
1485 }
1486
1487 def SwiftIndirectResult : ParameterABIAttr {
1488   let Spellings = [GCC<"swift_indirect_result">];
1489   let Documentation = [SwiftIndirectResultDocs];
1490 }
1491
1492 def SysVABI : InheritableAttr {
1493   let Spellings = [GCC<"sysv_abi">];
1494 //  let Subjects = [Function, ObjCMethod];
1495   let Documentation = [Undocumented];
1496 }
1497
1498 def ThisCall : InheritableAttr {
1499   let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
1500                    Keyword<"_thiscall">];
1501 //  let Subjects = [Function, ObjCMethod];
1502   let Documentation = [ThisCallDocs];
1503 }
1504
1505 def VectorCall : InheritableAttr {
1506   let Spellings = [GNU<"vectorcall">, Keyword<"__vectorcall">,
1507                    Keyword<"_vectorcall">];
1508 //  let Subjects = [Function, ObjCMethod];
1509   let Documentation = [VectorCallDocs];
1510 }
1511
1512 def Pascal : InheritableAttr {
1513   let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
1514 //  let Subjects = [Function, ObjCMethod];
1515   let Documentation = [Undocumented];
1516 }
1517
1518 def PreserveMost : InheritableAttr {
1519   let Spellings = [GNU<"preserve_most">];
1520   let Documentation = [PreserveMostDocs];
1521 }
1522
1523 def PreserveAll : InheritableAttr {
1524   let Spellings = [GNU<"preserve_all">];
1525   let Documentation = [PreserveAllDocs];
1526 }
1527
1528 def Target : InheritableAttr {
1529   let Spellings = [GCC<"target">];
1530   let Args = [StringArgument<"featuresStr">];
1531   let Subjects = SubjectList<[Function], ErrorDiag>;
1532   let Documentation = [TargetDocs];
1533   let AdditionalMembers = [{
1534     typedef std::pair<std::vector<std::string>, StringRef> ParsedTargetAttr;
1535     ParsedTargetAttr parse() const {
1536       ParsedTargetAttr Ret;
1537       SmallVector<StringRef, 1> AttrFeatures;
1538       getFeaturesStr().split(AttrFeatures, ",");
1539
1540       // Grab the various features and prepend a "+" to turn on the feature to
1541       // the backend and add them to our existing set of features.
1542       for (auto &Feature : AttrFeatures) {
1543         // Go ahead and trim whitespace rather than either erroring or
1544         // accepting it weirdly.
1545         Feature = Feature.trim();
1546
1547         // We don't support cpu tuning this way currently.
1548         // TODO: Support the fpmath option. It will require checking
1549         // overall feature validity for the function with the rest of the
1550         // attributes on the function.
1551         if (Feature.startswith("fpmath=") || Feature.startswith("tune="))
1552           continue;
1553
1554         // While we're here iterating check for a different target cpu.
1555         if (Feature.startswith("arch="))
1556           Ret.second = Feature.split("=").second.trim();
1557         else if (Feature.startswith("no-"))
1558           Ret.first.push_back("-" + Feature.split("-").second.str());
1559         else
1560           Ret.first.push_back("+" + Feature.str());
1561       }
1562       return Ret;
1563     }
1564   }];
1565 }
1566
1567 def TransparentUnion : InheritableAttr {
1568   let Spellings = [GCC<"transparent_union">];
1569 //  let Subjects = SubjectList<[Record, TypedefName]>;
1570   let Documentation = [TransparentUnionDocs];
1571   let LangOpts = [COnly];
1572 }
1573
1574 def Unavailable : InheritableAttr {
1575   let Spellings = [GNU<"unavailable">];
1576   let Args = [StringArgument<"Message", 1>,
1577               EnumArgument<"ImplicitReason", "ImplicitReason",
1578                 ["", "", "", ""],
1579                 ["IR_None",
1580                  "IR_ARCForbiddenType",
1581                  "IR_ForbiddenWeak",
1582                  "IR_ARCForbiddenConversion",
1583                  "IR_ARCInitReturnsUnrelated",
1584                  "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>];
1585   let Documentation = [Undocumented];
1586 }
1587
1588 def ArcWeakrefUnavailable : InheritableAttr {
1589   let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
1590   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1591   let Documentation = [Undocumented];
1592 }
1593
1594 def ObjCGC : TypeAttr {
1595   let Spellings = [GNU<"objc_gc">];
1596   let Args = [IdentifierArgument<"Kind">];
1597   let Documentation = [Undocumented];
1598 }
1599
1600 def ObjCOwnership : InheritableAttr {
1601   let Spellings = [GNU<"objc_ownership">];
1602   let Args = [IdentifierArgument<"Kind">];
1603   let ASTNode = 0;
1604   let Documentation = [Undocumented];
1605 }
1606
1607 def ObjCRequiresPropertyDefs : InheritableAttr {
1608   let Spellings = [GNU<"objc_requires_property_definitions">];
1609   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1610   let Documentation = [Undocumented];
1611 }
1612
1613 def Unused : InheritableAttr {
1614   let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">];
1615   let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
1616                               Field, ObjCMethod, FunctionLike], WarnDiag,
1617                              "ExpectedForMaybeUnused">;
1618   let Documentation = [WarnMaybeUnusedDocs];
1619 }
1620
1621 def Used : InheritableAttr {
1622   let Spellings = [GCC<"used">];
1623   let Documentation = [Undocumented];
1624 }
1625
1626 def Uuid : InheritableAttr {
1627   let Spellings = [Declspec<"uuid">, Microsoft<"uuid">];
1628   let Args = [StringArgument<"Guid">];
1629   let Subjects = SubjectList<[Record, Enum], WarnDiag, "ExpectedEnumOrClass">;
1630   // FIXME: Allow expressing logical AND for LangOpts. Our condition should be:
1631   // CPlusPlus && (MicrosoftExt || Borland)
1632   let LangOpts = [MicrosoftExt, Borland];
1633   let Documentation = [Undocumented];
1634 }
1635
1636 def VectorSize : TypeAttr {
1637   let Spellings = [GCC<"vector_size">];
1638   let Args = [ExprArgument<"NumBytes">];
1639   let Documentation = [Undocumented];
1640 }
1641
1642 def VecTypeHint : InheritableAttr {
1643   let Spellings = [GNU<"vec_type_hint">];
1644   let Args = [TypeArgument<"TypeHint">];
1645   let Subjects = SubjectList<[Function], ErrorDiag>;
1646   let Documentation = [Undocumented];
1647 }
1648
1649 def Visibility : InheritableAttr {
1650   let Clone = 0;
1651   let Spellings = [GCC<"visibility">];
1652   let Args = [EnumArgument<"Visibility", "VisibilityType",
1653                            ["default", "hidden", "internal", "protected"],
1654                            ["Default", "Hidden", "Hidden", "Protected"]>];
1655   let Documentation = [Undocumented];
1656 }
1657
1658 def TypeVisibility : InheritableAttr {
1659   let Clone = 0;
1660   let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">];
1661   let Args = [EnumArgument<"Visibility", "VisibilityType",
1662                            ["default", "hidden", "internal", "protected"],
1663                            ["Default", "Hidden", "Hidden", "Protected"]>];
1664 //  let Subjects = [Tag, ObjCInterface, Namespace];
1665   let Documentation = [Undocumented];
1666 }
1667
1668 def VecReturn : InheritableAttr {
1669   let Spellings = [GNU<"vecreturn">];
1670   let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
1671   let Documentation = [Undocumented];
1672 }
1673
1674 def WarnUnused : InheritableAttr {
1675   let Spellings = [GNU<"warn_unused">];
1676   let Subjects = SubjectList<[Record]>;
1677   let Documentation = [Undocumented];
1678 }
1679
1680 def WarnUnusedResult : InheritableAttr {
1681   let Spellings = [CXX11<"", "nodiscard", 201603>,
1682                    CXX11<"clang", "warn_unused_result">,
1683                    GCC<"warn_unused_result">];
1684   let Subjects = SubjectList<[ObjCMethod, Enum, CXXRecord, FunctionLike],
1685                              WarnDiag, "ExpectedFunctionMethodEnumOrClass">;
1686   let Documentation = [WarnUnusedResultsDocs];
1687 }
1688
1689 def Weak : InheritableAttr {
1690   let Spellings = [GCC<"weak">];
1691   let Subjects = SubjectList<[Var, Function, CXXRecord]>;
1692   let Documentation = [Undocumented];
1693 }
1694
1695 def WeakImport : InheritableAttr {
1696   let Spellings = [GNU<"weak_import">];
1697   let Documentation = [Undocumented];
1698 }
1699
1700 def WeakRef : InheritableAttr {
1701   let Spellings = [GCC<"weakref">];
1702   // A WeakRef that has an argument is treated as being an AliasAttr
1703   let Args = [StringArgument<"Aliasee", 1>];
1704   let Subjects = SubjectList<[Var, Function], ErrorDiag>;
1705   let Documentation = [Undocumented];
1706 }
1707
1708 def LTOVisibilityPublic : InheritableAttr {
1709   let Spellings = [CXX11<"clang", "lto_visibility_public">];
1710   let Subjects = SubjectList<[Record]>;
1711   let Documentation = [LTOVisibilityDocs];
1712 }
1713
1714 def AnyX86Interrupt : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
1715   // NOTE: If you add any additional spellings, ARMInterrupt's,
1716   // MSP430Interrupt's and MipsInterrupt's spellings must match.
1717   let Spellings = [GNU<"interrupt">];
1718   let Subjects = SubjectList<[HasFunctionProto]>;
1719   let ParseKind = "Interrupt";
1720   let HasCustomParsing = 1;
1721   let Documentation = [AnyX86InterruptDocs];
1722 }
1723
1724 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetX86> {
1725   let Spellings = [GNU<"force_align_arg_pointer">];
1726   // Technically, this appertains to a FunctionDecl, but the target-specific
1727   // code silently allows anything function-like (such as typedefs or function
1728   // pointers), but does not apply the attribute to them.
1729   let Documentation = [Undocumented];
1730 }
1731
1732 def NoSanitize : InheritableAttr {
1733   let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">];
1734   let Args = [VariadicStringArgument<"Sanitizers">];
1735   let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag,
1736     "ExpectedFunctionMethodOrGlobalVar">;
1737   let Documentation = [NoSanitizeDocs];
1738   let AdditionalMembers = [{
1739     SanitizerMask getMask() const {
1740       SanitizerMask Mask = 0;
1741       for (auto SanitizerName : sanitizers()) {
1742         SanitizerMask ParsedMask =
1743             parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
1744         Mask |= expandSanitizerGroups(ParsedMask);
1745       }
1746       return Mask;
1747     }
1748   }];
1749 }
1750
1751 // Attributes to disable a specific sanitizer. No new sanitizers should be added
1752 // to this list; the no_sanitize attribute should be extended instead.
1753 def NoSanitizeSpecific : InheritableAttr {
1754   let Spellings = [GCC<"no_address_safety_analysis">,
1755                    GCC<"no_sanitize_address">,
1756                    GCC<"no_sanitize_thread">,
1757                    GNU<"no_sanitize_memory">];
1758   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
1759         "ExpectedFunctionOrGlobalVar">;
1760   let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
1761                        NoSanitizeMemoryDocs];
1762   let ASTNode = 0;
1763 }
1764
1765 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
1766
1767 def GuardedVar : InheritableAttr {
1768   let Spellings = [GNU<"guarded_var">];
1769   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1770                              "ExpectedFieldOrGlobalVar">;
1771   let Documentation = [Undocumented];
1772 }
1773
1774 def PtGuardedVar : InheritableAttr {
1775   let Spellings = [GNU<"pt_guarded_var">];
1776   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1777                              "ExpectedFieldOrGlobalVar">;
1778   let Documentation = [Undocumented];
1779 }
1780
1781 def Lockable : InheritableAttr {
1782   let Spellings = [GNU<"lockable">];
1783   let Subjects = SubjectList<[Record]>;
1784   let Documentation = [Undocumented];
1785   let ASTNode = 0;  // Replaced by Capability
1786 }
1787
1788 def ScopedLockable : InheritableAttr {
1789   let Spellings = [GNU<"scoped_lockable">];
1790   let Subjects = SubjectList<[Record]>;
1791   let Documentation = [Undocumented];
1792 }
1793
1794 def Capability : InheritableAttr {
1795   let Spellings = [GNU<"capability">, CXX11<"clang", "capability">,
1796                    GNU<"shared_capability">,
1797                    CXX11<"clang", "shared_capability">];
1798   let Subjects = SubjectList<[Record, TypedefName], ErrorDiag,
1799                              "ExpectedStructOrUnionOrTypedef">;
1800   let Args = [StringArgument<"Name">];
1801   let Accessors = [Accessor<"isShared",
1802                     [GNU<"shared_capability">,
1803                      CXX11<"clang","shared_capability">]>];
1804   let Documentation = [Undocumented];
1805   let AdditionalMembers = [{
1806     bool isMutex() const { return getName().equals_lower("mutex"); }
1807     bool isRole() const { return getName().equals_lower("role"); }
1808   }];
1809 }
1810
1811 def AssertCapability : InheritableAttr {
1812   let Spellings = [GNU<"assert_capability">,
1813                    CXX11<"clang", "assert_capability">,
1814                    GNU<"assert_shared_capability">,
1815                    CXX11<"clang", "assert_shared_capability">];
1816   let Subjects = SubjectList<[Function]>;
1817   let LateParsed = 1;
1818   let TemplateDependent = 1;
1819   let ParseArgumentsAsUnevaluated = 1;
1820   let DuplicatesAllowedWhileMerging = 1;
1821   let Args = [ExprArgument<"Expr">];
1822   let Accessors = [Accessor<"isShared",
1823                     [GNU<"assert_shared_capability">,
1824                      CXX11<"clang", "assert_shared_capability">]>];
1825   let Documentation = [AssertCapabilityDocs];
1826 }
1827
1828 def AcquireCapability : InheritableAttr {
1829   let Spellings = [GNU<"acquire_capability">,
1830                    CXX11<"clang", "acquire_capability">,
1831                    GNU<"acquire_shared_capability">,
1832                    CXX11<"clang", "acquire_shared_capability">,
1833                    GNU<"exclusive_lock_function">,
1834                    GNU<"shared_lock_function">];
1835   let Subjects = SubjectList<[Function]>;
1836   let LateParsed = 1;
1837   let TemplateDependent = 1;
1838   let ParseArgumentsAsUnevaluated = 1;
1839   let DuplicatesAllowedWhileMerging = 1;
1840   let Args = [VariadicExprArgument<"Args">];
1841   let Accessors = [Accessor<"isShared",
1842                     [GNU<"acquire_shared_capability">,
1843                      CXX11<"clang", "acquire_shared_capability">,
1844                      GNU<"shared_lock_function">]>];
1845   let Documentation = [AcquireCapabilityDocs];
1846 }
1847
1848 def TryAcquireCapability : InheritableAttr {
1849   let Spellings = [GNU<"try_acquire_capability">,
1850                    CXX11<"clang", "try_acquire_capability">,
1851                    GNU<"try_acquire_shared_capability">,
1852                    CXX11<"clang", "try_acquire_shared_capability">];
1853   let Subjects = SubjectList<[Function],
1854                              ErrorDiag>;
1855   let LateParsed = 1;
1856   let TemplateDependent = 1;
1857   let ParseArgumentsAsUnevaluated = 1;
1858   let DuplicatesAllowedWhileMerging = 1;
1859   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1860   let Accessors = [Accessor<"isShared",
1861                     [GNU<"try_acquire_shared_capability">,
1862                      CXX11<"clang", "try_acquire_shared_capability">]>];
1863   let Documentation = [TryAcquireCapabilityDocs];
1864 }
1865
1866 def ReleaseCapability : InheritableAttr {
1867   let Spellings = [GNU<"release_capability">,
1868                    CXX11<"clang", "release_capability">,
1869                    GNU<"release_shared_capability">,
1870                    CXX11<"clang", "release_shared_capability">,
1871                    GNU<"release_generic_capability">,
1872                    CXX11<"clang", "release_generic_capability">,
1873                    GNU<"unlock_function">];
1874   let Subjects = SubjectList<[Function]>;
1875   let LateParsed = 1;
1876   let TemplateDependent = 1;
1877   let ParseArgumentsAsUnevaluated = 1;
1878   let DuplicatesAllowedWhileMerging = 1;
1879   let Args = [VariadicExprArgument<"Args">];
1880   let Accessors = [Accessor<"isShared",
1881                     [GNU<"release_shared_capability">,
1882                      CXX11<"clang", "release_shared_capability">]>,
1883                    Accessor<"isGeneric",
1884                      [GNU<"release_generic_capability">,
1885                       CXX11<"clang", "release_generic_capability">,
1886                       GNU<"unlock_function">]>];
1887   let Documentation = [ReleaseCapabilityDocs];
1888 }
1889
1890 def RequiresCapability : InheritableAttr {
1891   let Spellings = [GNU<"requires_capability">,
1892                    CXX11<"clang", "requires_capability">,
1893                    GNU<"exclusive_locks_required">,
1894                    GNU<"requires_shared_capability">,
1895                    CXX11<"clang", "requires_shared_capability">,
1896                    GNU<"shared_locks_required">];
1897   let Args = [VariadicExprArgument<"Args">];
1898   let LateParsed = 1;
1899   let TemplateDependent = 1;
1900   let ParseArgumentsAsUnevaluated = 1;
1901   let DuplicatesAllowedWhileMerging = 1;
1902   let Subjects = SubjectList<[Function]>;
1903   let Accessors = [Accessor<"isShared", [GNU<"requires_shared_capability">,
1904                                          GNU<"shared_locks_required">,
1905                                 CXX11<"clang","requires_shared_capability">]>];
1906   let Documentation = [Undocumented];
1907 }
1908
1909 def NoThreadSafetyAnalysis : InheritableAttr {
1910   let Spellings = [GNU<"no_thread_safety_analysis">];
1911   let Subjects = SubjectList<[Function]>;
1912   let Documentation = [Undocumented];
1913 }
1914
1915 def GuardedBy : InheritableAttr {
1916   let Spellings = [GNU<"guarded_by">];
1917   let Args = [ExprArgument<"Arg">];
1918   let LateParsed = 1;
1919   let TemplateDependent = 1;
1920   let ParseArgumentsAsUnevaluated = 1;
1921   let DuplicatesAllowedWhileMerging = 1;
1922   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1923                              "ExpectedFieldOrGlobalVar">;
1924   let Documentation = [Undocumented];
1925 }
1926
1927 def PtGuardedBy : InheritableAttr {
1928   let Spellings = [GNU<"pt_guarded_by">];
1929   let Args = [ExprArgument<"Arg">];
1930   let LateParsed = 1;
1931   let TemplateDependent = 1;
1932   let ParseArgumentsAsUnevaluated = 1;
1933   let DuplicatesAllowedWhileMerging = 1;
1934   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1935                              "ExpectedFieldOrGlobalVar">;
1936   let Documentation = [Undocumented];
1937 }
1938
1939 def AcquiredAfter : InheritableAttr {
1940   let Spellings = [GNU<"acquired_after">];
1941   let Args = [VariadicExprArgument<"Args">];
1942   let LateParsed = 1;
1943   let TemplateDependent = 1;
1944   let ParseArgumentsAsUnevaluated = 1;
1945   let DuplicatesAllowedWhileMerging = 1;
1946   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1947                              "ExpectedFieldOrGlobalVar">;
1948   let Documentation = [Undocumented];
1949 }
1950
1951 def AcquiredBefore : InheritableAttr {
1952   let Spellings = [GNU<"acquired_before">];
1953   let Args = [VariadicExprArgument<"Args">];
1954   let LateParsed = 1;
1955   let TemplateDependent = 1;
1956   let ParseArgumentsAsUnevaluated = 1;
1957   let DuplicatesAllowedWhileMerging = 1;
1958   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1959                              "ExpectedFieldOrGlobalVar">;
1960   let Documentation = [Undocumented];
1961 }
1962
1963 def AssertExclusiveLock : InheritableAttr {
1964   let Spellings = [GNU<"assert_exclusive_lock">];
1965   let Args = [VariadicExprArgument<"Args">];
1966   let LateParsed = 1;
1967   let TemplateDependent = 1;
1968   let ParseArgumentsAsUnevaluated = 1;
1969   let DuplicatesAllowedWhileMerging = 1;
1970   let Subjects = SubjectList<[Function]>;
1971   let Documentation = [Undocumented];
1972 }
1973
1974 def AssertSharedLock : InheritableAttr {
1975   let Spellings = [GNU<"assert_shared_lock">];
1976   let Args = [VariadicExprArgument<"Args">];
1977   let LateParsed = 1;
1978   let TemplateDependent = 1;
1979   let ParseArgumentsAsUnevaluated = 1;
1980   let DuplicatesAllowedWhileMerging = 1;
1981   let Subjects = SubjectList<[Function]>;
1982   let Documentation = [Undocumented];
1983 }
1984
1985 // The first argument is an integer or boolean value specifying the return value
1986 // of a successful lock acquisition.
1987 def ExclusiveTrylockFunction : InheritableAttr {
1988   let Spellings = [GNU<"exclusive_trylock_function">];
1989   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1990   let LateParsed = 1;
1991   let TemplateDependent = 1;
1992   let ParseArgumentsAsUnevaluated = 1;
1993   let DuplicatesAllowedWhileMerging = 1;
1994   let Subjects = SubjectList<[Function]>;
1995   let Documentation = [Undocumented];
1996 }
1997
1998 // The first argument is an integer or boolean value specifying the return value
1999 // of a successful lock acquisition.
2000 def SharedTrylockFunction : InheritableAttr {
2001   let Spellings = [GNU<"shared_trylock_function">];
2002   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2003   let LateParsed = 1;
2004   let TemplateDependent = 1;
2005   let ParseArgumentsAsUnevaluated = 1;
2006   let DuplicatesAllowedWhileMerging = 1;
2007   let Subjects = SubjectList<[Function]>;
2008   let Documentation = [Undocumented];
2009 }
2010
2011 def LockReturned : InheritableAttr {
2012   let Spellings = [GNU<"lock_returned">];
2013   let Args = [ExprArgument<"Arg">];
2014   let LateParsed = 1;
2015   let TemplateDependent = 1;
2016   let ParseArgumentsAsUnevaluated = 1;
2017   let Subjects = SubjectList<[Function]>;
2018   let Documentation = [Undocumented];
2019 }
2020
2021 def LocksExcluded : InheritableAttr {
2022   let Spellings = [GNU<"locks_excluded">];
2023   let Args = [VariadicExprArgument<"Args">];
2024   let LateParsed = 1;
2025   let TemplateDependent = 1;
2026   let ParseArgumentsAsUnevaluated = 1;
2027   let DuplicatesAllowedWhileMerging = 1;
2028   let Subjects = SubjectList<[Function]>;
2029   let Documentation = [Undocumented];
2030 }
2031
2032 // C/C++ consumed attributes.
2033
2034 def Consumable : InheritableAttr {
2035   let Spellings = [GNU<"consumable">];
2036   let Subjects = SubjectList<[CXXRecord]>;
2037   let Args = [EnumArgument<"DefaultState", "ConsumedState",
2038                            ["unknown", "consumed", "unconsumed"],
2039                            ["Unknown", "Consumed", "Unconsumed"]>];
2040   let Documentation = [ConsumableDocs];
2041 }
2042
2043 def ConsumableAutoCast : InheritableAttr {
2044   let Spellings = [GNU<"consumable_auto_cast_state">];
2045   let Subjects = SubjectList<[CXXRecord]>;
2046   let Documentation = [Undocumented];
2047 }
2048
2049 def ConsumableSetOnRead : InheritableAttr {
2050   let Spellings = [GNU<"consumable_set_state_on_read">];
2051   let Subjects = SubjectList<[CXXRecord]>;
2052   let Documentation = [Undocumented];
2053 }
2054
2055 def CallableWhen : InheritableAttr {
2056   let Spellings = [GNU<"callable_when">];
2057   let Subjects = SubjectList<[CXXMethod]>;
2058   let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
2059                                    ["unknown", "consumed", "unconsumed"],
2060                                    ["Unknown", "Consumed", "Unconsumed"]>];
2061   let Documentation = [CallableWhenDocs];
2062 }
2063
2064 def ParamTypestate : InheritableAttr {
2065   let Spellings = [GNU<"param_typestate">];
2066   let Subjects = SubjectList<[ParmVar]>;
2067   let Args = [EnumArgument<"ParamState", "ConsumedState",
2068                            ["unknown", "consumed", "unconsumed"],
2069                            ["Unknown", "Consumed", "Unconsumed"]>];
2070   let Documentation = [ParamTypestateDocs];
2071 }
2072
2073 def ReturnTypestate : InheritableAttr {
2074   let Spellings = [GNU<"return_typestate">];
2075   let Subjects = SubjectList<[Function, ParmVar]>;
2076   let Args = [EnumArgument<"State", "ConsumedState",
2077                            ["unknown", "consumed", "unconsumed"],
2078                            ["Unknown", "Consumed", "Unconsumed"]>];
2079   let Documentation = [ReturnTypestateDocs];
2080 }
2081
2082 def SetTypestate : InheritableAttr {
2083   let Spellings = [GNU<"set_typestate">];
2084   let Subjects = SubjectList<[CXXMethod]>;
2085   let Args = [EnumArgument<"NewState", "ConsumedState",
2086                            ["unknown", "consumed", "unconsumed"],
2087                            ["Unknown", "Consumed", "Unconsumed"]>];
2088   let Documentation = [SetTypestateDocs];
2089 }
2090
2091 def TestTypestate : InheritableAttr {
2092   let Spellings = [GNU<"test_typestate">];
2093   let Subjects = SubjectList<[CXXMethod]>;
2094   let Args = [EnumArgument<"TestState", "ConsumedState",
2095                            ["consumed", "unconsumed"],
2096                            ["Consumed", "Unconsumed"]>];
2097   let Documentation = [TestTypestateDocs];
2098 }
2099
2100 // Type safety attributes for `void *' pointers and type tags.
2101
2102 def ArgumentWithTypeTag : InheritableAttr {
2103   let Spellings = [GNU<"argument_with_type_tag">,
2104                    GNU<"pointer_with_type_tag">];
2105   let Args = [IdentifierArgument<"ArgumentKind">,
2106               UnsignedArgument<"ArgumentIdx">,
2107               UnsignedArgument<"TypeTagIdx">,
2108               BoolArgument<"IsPointer">];
2109   let HasCustomParsing = 1;
2110   let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
2111 }
2112
2113 def TypeTagForDatatype : InheritableAttr {
2114   let Spellings = [GNU<"type_tag_for_datatype">];
2115   let Args = [IdentifierArgument<"ArgumentKind">,
2116               TypeArgument<"MatchingCType">,
2117               BoolArgument<"LayoutCompatible">,
2118               BoolArgument<"MustBeNull">];
2119 //  let Subjects = SubjectList<[Var], ErrorDiag>;
2120   let HasCustomParsing = 1;
2121   let Documentation = [TypeTagForDatatypeDocs];
2122 }
2123
2124 // Microsoft-related attributes
2125
2126 def MSNoVTable : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
2127   let Spellings = [Declspec<"novtable">];
2128   let Subjects = SubjectList<[CXXRecord]>;
2129   let Documentation = [MSNoVTableDocs];
2130 }
2131
2132 def : IgnoredAttr {
2133   let Spellings = [Declspec<"property">];
2134 }
2135
2136 def MSStruct : InheritableAttr {
2137   let Spellings = [GCC<"ms_struct">];
2138   let Subjects = SubjectList<[Record]>;
2139   let Documentation = [Undocumented];
2140 }
2141
2142 def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2143   let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
2144   let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2145   let Documentation = [DLLExportDocs];
2146 }
2147
2148 def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2149   let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
2150   let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2151   let Documentation = [DLLImportDocs];
2152 }
2153
2154 def SelectAny : InheritableAttr {
2155   let Spellings = [Declspec<"selectany">];
2156   let LangOpts = [MicrosoftExt];
2157   let Documentation = [Undocumented];
2158 }
2159
2160 def Thread : Attr {
2161   let Spellings = [Declspec<"thread">];
2162   let LangOpts = [MicrosoftExt];
2163   let Documentation = [ThreadDocs];
2164   let Subjects = SubjectList<[Var]>;
2165 }
2166
2167 def Win64 : IgnoredAttr {
2168   let Spellings = [Keyword<"__w64">];
2169   let LangOpts = [MicrosoftExt];
2170 }
2171
2172 def Ptr32 : TypeAttr {
2173   let Spellings = [Keyword<"__ptr32">];
2174   let Documentation = [Undocumented];
2175 }
2176
2177 def Ptr64 : TypeAttr {
2178   let Spellings = [Keyword<"__ptr64">];
2179   let Documentation = [Undocumented];
2180 }
2181
2182 def SPtr : TypeAttr {
2183   let Spellings = [Keyword<"__sptr">];
2184   let Documentation = [Undocumented];
2185 }
2186
2187 def UPtr : TypeAttr {
2188   let Spellings = [Keyword<"__uptr">];
2189   let Documentation = [Undocumented];
2190 }
2191
2192 def MSInheritance : InheritableAttr {
2193   let LangOpts = [MicrosoftExt];
2194   let Args = [DefaultBoolArgument<"BestCase", 1>];
2195   let Spellings = [Keyword<"__single_inheritance">,
2196                    Keyword<"__multiple_inheritance">,
2197                    Keyword<"__virtual_inheritance">,
2198                    Keyword<"__unspecified_inheritance">];
2199   let AdditionalMembers = [{
2200   static bool hasVBPtrOffsetField(Spelling Inheritance) {
2201     return Inheritance == Keyword_unspecified_inheritance;
2202   }
2203
2204   // Only member pointers to functions need a this adjustment, since it can be
2205   // combined with the field offset for data pointers.
2206   static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
2207     return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
2208   }
2209
2210   static bool hasVBTableOffsetField(Spelling Inheritance) {
2211     return Inheritance >= Keyword_virtual_inheritance;
2212   }
2213
2214   static bool hasOnlyOneField(bool IsMemberFunction,
2215                               Spelling Inheritance) {
2216     if (IsMemberFunction)
2217       return Inheritance <= Keyword_single_inheritance;
2218     return Inheritance <= Keyword_multiple_inheritance;
2219   }
2220   }];
2221   let Documentation = [MSInheritanceDocs];
2222 }
2223
2224 def MSVtorDisp : InheritableAttr {
2225   // This attribute has no spellings as it is only ever created implicitly.
2226   let Spellings = [];
2227   let Args = [UnsignedArgument<"vdm">];
2228   let SemaHandler = 0;
2229
2230   let AdditionalMembers = [{
2231   enum Mode {
2232     Never,
2233     ForVBaseOverride,
2234     ForVFTable
2235   };
2236
2237   Mode getVtorDispMode() const { return Mode(vdm); }
2238   }];
2239   let Documentation = [Undocumented];
2240 }
2241
2242 def InitSeg : Attr {
2243   let Spellings = [Pragma<"", "init_seg">];
2244   let Args = [StringArgument<"Section">];
2245   let SemaHandler = 0;
2246   let Documentation = [InitSegDocs];
2247   let AdditionalMembers = [{
2248   void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2249     OS << '(' << getSection() << ')';
2250   }
2251   }];
2252 }
2253
2254 def LoopHint : Attr {
2255   /// #pragma clang loop <option> directive
2256   /// vectorize: vectorizes loop operations if State == Enable.
2257   /// vectorize_width: vectorize loop operations with width 'Value'.
2258   /// interleave: interleave multiple loop iterations if State == Enable.
2259   /// interleave_count: interleaves 'Value' loop interations.
2260   /// unroll: fully unroll loop if State == Enable.
2261   /// unroll_count: unrolls loop 'Value' times.
2262   /// distribute: attempt to distribute loop if State == Enable
2263
2264   /// #pragma unroll <argument> directive
2265   /// <no arg>: fully unrolls loop.
2266   /// boolean: fully unrolls loop if State == Enable.
2267   /// expression: unrolls loop 'Value' times.
2268
2269   let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">,
2270                    Pragma<"", "nounroll">];
2271
2272   /// State of the loop optimization specified by the spelling.
2273   let Args = [EnumArgument<"Option", "OptionType",
2274                           ["vectorize", "vectorize_width", "interleave", "interleave_count",
2275                            "unroll", "unroll_count", "distribute"],
2276                           ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
2277                            "Unroll", "UnrollCount", "Distribute"]>,
2278               EnumArgument<"State", "LoopHintState",
2279                            ["enable", "disable", "numeric", "assume_safety", "full"],
2280                            ["Enable", "Disable", "Numeric", "AssumeSafety", "Full"]>,
2281               ExprArgument<"Value">];
2282
2283   let AdditionalMembers = [{
2284   static const char *getOptionName(int Option) {
2285     switch(Option) {
2286     case Vectorize: return "vectorize";
2287     case VectorizeWidth: return "vectorize_width";
2288     case Interleave: return "interleave";
2289     case InterleaveCount: return "interleave_count";
2290     case Unroll: return "unroll";
2291     case UnrollCount: return "unroll_count";
2292     case Distribute: return "distribute";
2293     }
2294     llvm_unreachable("Unhandled LoopHint option.");
2295   }
2296
2297   void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2298     unsigned SpellingIndex = getSpellingListIndex();
2299     // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
2300     // "nounroll" is already emitted as the pragma name.
2301     if (SpellingIndex == Pragma_nounroll)
2302       return;
2303     else if (SpellingIndex == Pragma_unroll) {
2304       OS << getValueString(Policy);
2305       return;
2306     }
2307
2308     assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2309     OS << getOptionName(option) << getValueString(Policy);
2310   }
2311
2312   // Return a string containing the loop hint argument including the
2313   // enclosing parentheses.
2314   std::string getValueString(const PrintingPolicy &Policy) const {
2315     std::string ValueName;
2316     llvm::raw_string_ostream OS(ValueName);
2317     OS << "(";
2318     if (state == Numeric)
2319       value->printPretty(OS, nullptr, Policy);
2320     else if (state == Enable)
2321       OS << "enable";
2322     else if (state == Full)
2323       OS << "full";
2324     else if (state == AssumeSafety)
2325       OS << "assume_safety";
2326     else
2327       OS << "disable";
2328     OS << ")";
2329     return OS.str();
2330   }
2331
2332   // Return a string suitable for identifying this attribute in diagnostics.
2333   std::string getDiagnosticName(const PrintingPolicy &Policy) const {
2334     unsigned SpellingIndex = getSpellingListIndex();
2335     if (SpellingIndex == Pragma_nounroll)
2336       return "#pragma nounroll";
2337     else if (SpellingIndex == Pragma_unroll)
2338       return "#pragma unroll" + (option == UnrollCount ? getValueString(Policy) : "");
2339
2340     assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2341     return getOptionName(option) + getValueString(Policy);
2342   }
2343   }];
2344
2345   let Documentation = [LoopHintDocs, UnrollHintDocs];
2346 }
2347
2348 def CapturedRecord : InheritableAttr {
2349   // This attribute has no spellings as it is only ever created implicitly.
2350   let Spellings = [];
2351   let SemaHandler = 0;
2352   let Documentation = [Undocumented];
2353 }
2354
2355 def OMPThreadPrivateDecl : InheritableAttr {
2356   // This attribute has no spellings as it is only ever created implicitly.
2357   let Spellings = [];
2358   let SemaHandler = 0;
2359   let Documentation = [Undocumented];
2360 }
2361
2362 def OMPCaptureNoInit : InheritableAttr {
2363   // This attribute has no spellings as it is only ever created implicitly.
2364   let Spellings = [];
2365   let SemaHandler = 0;
2366   let Documentation = [Undocumented];
2367 }
2368
2369 def OMPDeclareSimdDecl : Attr {
2370   let Spellings = [Pragma<"omp", "declare simd">];
2371   let Subjects = SubjectList<[Function]>;
2372   let SemaHandler = 0;
2373   let HasCustomParsing = 1;
2374   let Documentation = [OMPDeclareSimdDocs];
2375   let Args = [
2376     EnumArgument<"BranchState", "BranchStateTy",
2377                  [ "", "inbranch", "notinbranch" ],
2378                  [ "BS_Undefined", "BS_Inbranch", "BS_Notinbranch" ]>,
2379     ExprArgument<"Simdlen">, VariadicExprArgument<"Uniforms">,
2380     VariadicExprArgument<"Aligneds">, VariadicExprArgument<"Alignments">,
2381     VariadicExprArgument<"Linears">, VariadicUnsignedArgument<"Modifiers">,
2382     VariadicExprArgument<"Steps">
2383   ];
2384   let AdditionalMembers = [{
2385     void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
2386         const {
2387       if (getBranchState() != BS_Undefined)
2388         OS << ConvertBranchStateTyToStr(getBranchState()) << " ";
2389       if (auto *E = getSimdlen()) {
2390         OS << "simdlen(";
2391         E->printPretty(OS, nullptr, Policy);
2392         OS << ") ";
2393       }
2394       if (uniforms_size() > 0) {
2395         OS << "uniform";
2396         StringRef Sep = "(";
2397         for (auto *E : uniforms()) {
2398           OS << Sep;
2399           E->printPretty(OS, nullptr, Policy);
2400           Sep = ", ";
2401         }
2402         OS << ") ";
2403       }
2404       alignments_iterator NI = alignments_begin();
2405       for (auto *E : aligneds()) {
2406         OS << "aligned(";
2407         E->printPretty(OS, nullptr, Policy);
2408         if (*NI) {
2409           OS << ": ";
2410           (*NI)->printPretty(OS, nullptr, Policy);
2411         }
2412         OS << ") ";
2413         ++NI;
2414       }
2415       steps_iterator I = steps_begin();
2416       modifiers_iterator MI = modifiers_begin();
2417       for (auto *E : linears()) {
2418         OS << "linear(";
2419         if (*MI != OMPC_LINEAR_unknown)
2420           OS << getOpenMPSimpleClauseTypeName(OMPC_linear, *MI) << "(";
2421         E->printPretty(OS, nullptr, Policy);
2422         if (*MI != OMPC_LINEAR_unknown)
2423           OS << ")";
2424         if (*I) {
2425           OS << ": ";
2426           (*I)->printPretty(OS, nullptr, Policy);
2427         }
2428         OS << ") ";
2429         ++I;
2430         ++MI;
2431       }
2432     }
2433   }];
2434 }
2435
2436 def OMPDeclareTargetDecl : Attr {
2437   let Spellings = [Pragma<"omp", "declare target">];
2438   let SemaHandler = 0;
2439   let Documentation = [OMPDeclareTargetDocs];
2440   let Args = [
2441     EnumArgument<"MapType", "MapTypeTy",
2442                  [ "to", "link" ],
2443                  [ "MT_To", "MT_Link" ]>
2444   ];
2445   let AdditionalMembers = [{
2446     void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2447       // Use fake syntax because it is for testing and debugging purpose only.
2448       if (getMapType() != MT_To)
2449         OS << ConvertMapTypeTyToStr(getMapType()) << " ";
2450     }
2451   }];
2452 }
2453
2454 def InternalLinkage : InheritableAttr {
2455   let Spellings = [GNU<"internal_linkage">, CXX11<"clang", "internal_linkage">];
2456   let Subjects = SubjectList<[Var, Function, CXXRecord]>;
2457   let Documentation = [InternalLinkageDocs];
2458 }