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