]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Basic/Attr.td
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r302418, and update
[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 def OpenCLIntelReqdSubGroupSize: InheritableAttr {
868   let Spellings = [GNU<"intel_reqd_sub_group_size">];
869   let Args = [UnsignedArgument<"SubGroupSize">];
870   let Subjects = SubjectList<[Function], ErrorDiag>;
871   let Documentation = [OpenCLIntelReqdSubGroupSizeDocs];
872 }
873
874 // This attribute is both a type attribute, and a declaration attribute (for
875 // parameter variables).
876 def OpenCLAccess : Attr {
877   let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
878                    Keyword<"__write_only">, Keyword<"write_only">,
879                    Keyword<"__read_write">, Keyword<"read_write">];
880   let Subjects = SubjectList<[ParmVar, TypedefName], ErrorDiag,
881                              "ExpectedParameterOrTypedef">;
882   let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
883                                            Keyword<"read_only">]>,
884                    Accessor<"isReadWrite", [Keyword<"__read_write">,
885                                             Keyword<"read_write">]>,
886                    Accessor<"isWriteOnly", [Keyword<"__write_only">,
887                                             Keyword<"write_only">]>];
888   let Documentation = [OpenCLAccessDocs];
889 }
890
891 def OpenCLPrivateAddressSpace : TypeAttr {
892   let Spellings = [Keyword<"__private">, Keyword<"private">];
893   let Documentation = [OpenCLAddressSpacePrivateDocs];
894 }
895
896 def OpenCLGlobalAddressSpace : TypeAttr {
897   let Spellings = [Keyword<"__global">, Keyword<"global">];
898   let Documentation = [OpenCLAddressSpaceGlobalDocs];
899 }
900
901 def OpenCLLocalAddressSpace : TypeAttr {
902   let Spellings = [Keyword<"__local">, Keyword<"local">];
903   let Documentation = [OpenCLAddressSpaceLocalDocs];
904 }
905
906 def OpenCLConstantAddressSpace : TypeAttr {
907   let Spellings = [Keyword<"__constant">, Keyword<"constant">];
908   let Documentation = [OpenCLAddressSpaceConstantDocs];
909 }
910
911 def OpenCLGenericAddressSpace : TypeAttr {
912   let Spellings = [Keyword<"__generic">, Keyword<"generic">];
913   let Documentation = [OpenCLAddressSpaceGenericDocs];
914 }
915
916 def OpenCLNoSVM : Attr {
917   let Spellings = [GNU<"nosvm">];
918   let Subjects = SubjectList<[Var]>;
919   let Documentation = [OpenCLNoSVMDocs];
920   let LangOpts = [OpenCL];
921   let ASTNode = 0;
922 }
923
924 def RenderScriptKernel : Attr {
925   let Spellings = [GNU<"kernel">];
926   let Subjects = SubjectList<[Function]>;
927   let Documentation = [RenderScriptKernelAttributeDocs];
928   let LangOpts = [RenderScript];
929 }
930
931 def Deprecated : InheritableAttr {
932   let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
933                    CXX11<"","deprecated", 201309>];
934   let Args = [StringArgument<"Message", 1>,
935               // An optional string argument that enables us to provide a
936               // Fix-It.
937               StringArgument<"Replacement", 1>];
938   let MeaningfulToClassTemplateDefinition = 1;
939   let Documentation = [DeprecatedDocs];
940 }
941
942 def Destructor : InheritableAttr {
943   let Spellings = [GCC<"destructor">];
944   let Args = [DefaultIntArgument<"Priority", 65535>];
945   let Subjects = SubjectList<[Function]>;
946   let Documentation = [Undocumented];
947 }
948
949 def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
950   let Spellings = [Declspec<"empty_bases">];
951   let Subjects = SubjectList<[CXXRecord]>;
952   let Documentation = [EmptyBasesDocs];
953 }
954
955 def AllocSize : InheritableAttr {
956   let Spellings = [GCC<"alloc_size">];
957   let Subjects = SubjectList<[Function]>;
958   let Args = [IntArgument<"ElemSizeParam">, IntArgument<"NumElemsParam", 1>];
959   let TemplateDependent = 1;
960   let Documentation = [AllocSizeDocs];
961 }
962
963 def EnableIf : InheritableAttr {
964   let Spellings = [GNU<"enable_if">];
965   let Subjects = SubjectList<[Function]>;
966   let Args = [ExprArgument<"Cond">, StringArgument<"Message">];
967   let TemplateDependent = 1;
968   let Documentation = [EnableIfDocs];
969 }
970
971 def ExtVectorType : Attr {
972   let Spellings = [GNU<"ext_vector_type">];
973   let Subjects = SubjectList<[TypedefName], ErrorDiag>;
974   let Args = [ExprArgument<"NumElements">];
975   let ASTNode = 0;
976   let Documentation = [Undocumented];
977 }
978
979 def FallThrough : StmtAttr {
980   let Spellings = [CXX11<"", "fallthrough", 201603>,
981                    CXX11<"clang", "fallthrough">];
982 //  let Subjects = [NullStmt];
983   let Documentation = [FallthroughDocs];
984 }
985
986 def FastCall : InheritableAttr {
987   let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
988                    Keyword<"_fastcall">];
989 //  let Subjects = [Function, ObjCMethod];
990   let Documentation = [FastCallDocs];
991 }
992
993 def RegCall : InheritableAttr {
994   let Spellings = [GCC<"regcall">, Keyword<"__regcall">];
995   let Documentation = [RegCallDocs];
996 }
997
998 def Final : InheritableAttr {
999   let Spellings = [Keyword<"final">, Keyword<"sealed">];
1000   let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
1001   let SemaHandler = 0;
1002   let Documentation = [Undocumented];
1003 }
1004
1005 def MinSize : InheritableAttr {
1006   let Spellings = [GNU<"minsize">];
1007   let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
1008   let Documentation = [Undocumented];
1009 }
1010
1011 def FlagEnum : InheritableAttr {
1012   let Spellings = [GNU<"flag_enum">];
1013   let Subjects = SubjectList<[Enum]>;
1014   let Documentation = [FlagEnumDocs];
1015 }
1016
1017 def EnumExtensibility : InheritableAttr {
1018   let Spellings = [GNU<"enum_extensibility">,
1019                    CXX11<"clang", "enum_extensibility">];
1020   let Subjects = SubjectList<[Enum]>;
1021   let Args = [EnumArgument<"Extensibility", "Kind",
1022               ["closed", "open"], ["Closed", "Open"]>];
1023   let Documentation = [EnumExtensibilityDocs];
1024 }
1025
1026 def Flatten : InheritableAttr {
1027   let Spellings = [GCC<"flatten">];
1028   let Subjects = SubjectList<[Function], ErrorDiag>;
1029   let Documentation = [FlattenDocs];
1030 }
1031
1032 def Format : InheritableAttr {
1033   let Spellings = [GCC<"format">];
1034   let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
1035               IntArgument<"FirstArg">];
1036   let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto], WarnDiag,
1037                              "ExpectedFunctionWithProtoType">;
1038   let Documentation = [FormatDocs];
1039 }
1040
1041 def FormatArg : InheritableAttr {
1042   let Spellings = [GCC<"format_arg">];
1043   let Args = [IntArgument<"FormatIdx">];
1044   let Subjects = SubjectList<[ObjCMethod, HasFunctionProto], WarnDiag,
1045                              "ExpectedFunctionWithProtoType">;
1046   let Documentation = [Undocumented];
1047 }
1048
1049 def GNUInline : InheritableAttr {
1050   let Spellings = [GCC<"gnu_inline">];
1051   let Subjects = SubjectList<[Function]>;
1052   let Documentation = [Undocumented];
1053 }
1054
1055 def Hot : InheritableAttr {
1056   let Spellings = [GCC<"hot">];
1057   let Subjects = SubjectList<[Function]>;
1058   // An AST node is created for this attribute, but not actually used beyond
1059   // semantic checking for mutual exclusion with the Cold attribute.
1060   let Documentation = [Undocumented];
1061 }
1062
1063 def IBAction : InheritableAttr {
1064   let Spellings = [GNU<"ibaction">];
1065   let Subjects = SubjectList<[ObjCInstanceMethod], WarnDiag,
1066                              "ExpectedObjCInstanceMethod">;
1067   // An AST node is created for this attribute, but is not used by other parts
1068   // of the compiler. However, this node needs to exist in the AST because
1069   // external tools rely on it.
1070   let Documentation = [Undocumented];
1071 }
1072
1073 def IBOutlet : InheritableAttr {
1074   let Spellings = [GNU<"iboutlet">];
1075 //  let Subjects = [ObjCIvar, ObjCProperty];
1076   let Documentation = [Undocumented];
1077 }
1078
1079 def IBOutletCollection : InheritableAttr {
1080   let Spellings = [GNU<"iboutletcollection">];
1081   let Args = [TypeArgument<"Interface", 1>];
1082 //  let Subjects = [ObjCIvar, ObjCProperty];
1083   let Documentation = [Undocumented];
1084 }
1085
1086 def IFunc : Attr {
1087   let Spellings = [GCC<"ifunc">];
1088   let Args = [StringArgument<"Resolver">];
1089   let Subjects = SubjectList<[Function]>;
1090   let Documentation = [IFuncDocs];
1091 }
1092
1093 def Restrict : InheritableAttr {
1094   let Spellings = [Declspec<"restrict">, GCC<"malloc">];
1095   let Subjects = SubjectList<[Function]>;
1096   let Documentation = [Undocumented];
1097 }
1098
1099 def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
1100   let Spellings = [Declspec<"layout_version">];
1101   let Args = [UnsignedArgument<"Version">];
1102   let Subjects = SubjectList<[CXXRecord]>;
1103   let Documentation = [LayoutVersionDocs];
1104 }
1105
1106 def MaxFieldAlignment : InheritableAttr {
1107   // This attribute has no spellings as it is only ever created implicitly.
1108   let Spellings = [];
1109   let Args = [UnsignedArgument<"Alignment">];
1110   let SemaHandler = 0;
1111   let Documentation = [Undocumented];
1112 }
1113
1114 def MayAlias : InheritableAttr {
1115   // FIXME: this is a type attribute in GCC, but a declaration attribute here.
1116   let Spellings = [GCC<"may_alias">];
1117   let Documentation = [Undocumented];
1118 }
1119
1120 def MSABI : InheritableAttr {
1121   let Spellings = [GCC<"ms_abi">];
1122 //  let Subjects = [Function, ObjCMethod];
1123   let Documentation = [MSABIDocs];
1124 }
1125
1126 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
1127   // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's
1128   // and AnyX86Interrupt's spellings must match.
1129   let Spellings = [GNU<"interrupt">];
1130   let Args = [UnsignedArgument<"Number">];
1131   let ParseKind = "Interrupt";
1132   let HasCustomParsing = 1;
1133   let Documentation = [Undocumented];
1134 }
1135
1136 def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
1137   let Spellings = [GCC<"mips16">];
1138   let Subjects = SubjectList<[Function], ErrorDiag>;
1139   let Documentation = [Undocumented];
1140 }
1141
1142 def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips> {
1143   // NOTE: If you add any additional spellings, ARMInterrupt's,
1144   // MSP430Interrupt's and AnyX86Interrupt's spellings must match.
1145   let Spellings = [GNU<"interrupt">];
1146   let Subjects = SubjectList<[Function]>;
1147   let Args = [EnumArgument<"Interrupt", "InterruptType",
1148                            ["vector=sw0", "vector=sw1", "vector=hw0",
1149                             "vector=hw1", "vector=hw2", "vector=hw3",
1150                             "vector=hw4", "vector=hw5", "eic", ""],
1151                            ["sw0", "sw1", "hw0", "hw1", "hw2", "hw3",
1152                             "hw4", "hw5", "eic", "eic"]
1153                            >];
1154   let ParseKind = "Interrupt";
1155   let Documentation = [MipsInterruptDocs];
1156 }
1157
1158 def Mode : Attr {
1159   let Spellings = [GCC<"mode">];
1160   let Subjects = SubjectList<[Var, Enum, TypedefName, Field], ErrorDiag,
1161                              "ExpectedVariableEnumFieldOrTypedef">;
1162   let Args = [IdentifierArgument<"Mode">];
1163   let Documentation = [Undocumented];
1164 }
1165
1166 def Naked : InheritableAttr {
1167   let Spellings = [GCC<"naked">, Declspec<"naked">];
1168   let Subjects = SubjectList<[Function]>;
1169   let Documentation = [Undocumented];
1170 }
1171
1172 def NeonPolyVectorType : TypeAttr {
1173   let Spellings = [GNU<"neon_polyvector_type">];
1174   let Args = [IntArgument<"NumElements">];
1175   let Documentation = [Undocumented];
1176 }
1177
1178 def NeonVectorType : TypeAttr {
1179   let Spellings = [GNU<"neon_vector_type">];
1180   let Args = [IntArgument<"NumElements">];
1181   let Documentation = [Undocumented];
1182 }
1183
1184 def ReturnsTwice : InheritableAttr {
1185   let Spellings = [GCC<"returns_twice">];
1186   let Subjects = SubjectList<[Function]>;
1187   let Documentation = [Undocumented];
1188 }
1189
1190 def DisableTailCalls : InheritableAttr {
1191   let Spellings = [GNU<"disable_tail_calls">,
1192                    CXX11<"clang", "disable_tail_calls">];
1193   let Subjects = SubjectList<[Function, ObjCMethod]>;
1194   let Documentation = [DisableTailCallsDocs];
1195 }
1196
1197 def NoAlias : InheritableAttr {
1198   let Spellings = [Declspec<"noalias">];
1199   let Subjects = SubjectList<[Function]>;
1200   let Documentation = [NoAliasDocs];
1201 }
1202
1203 def NoCommon : InheritableAttr {
1204   let Spellings = [GCC<"nocommon">];
1205   let Subjects = SubjectList<[Var]>;
1206   let Documentation = [Undocumented];
1207 }
1208
1209 def NoDebug : InheritableAttr {
1210   let Spellings = [GCC<"nodebug">];
1211   let Subjects = SubjectList<[FunctionLike, ObjCMethod, NonParmVar], WarnDiag,
1212                               "ExpectedVariableOrFunction">;
1213   let Documentation = [NoDebugDocs];
1214 }
1215
1216 def NoDuplicate : InheritableAttr {
1217   let Spellings = [GNU<"noduplicate">, CXX11<"clang", "noduplicate">];
1218   let Subjects = SubjectList<[Function]>;
1219   let Documentation = [NoDuplicateDocs];
1220 }
1221
1222 def Convergent : InheritableAttr {
1223   let Spellings = [GNU<"convergent">, CXX11<"clang", "convergent">];
1224   let Subjects = SubjectList<[Function]>;
1225   let Documentation = [ConvergentDocs];
1226 }
1227
1228 def NoInline : InheritableAttr {
1229   let Spellings = [GCC<"noinline">, Declspec<"noinline">];
1230   let Subjects = SubjectList<[Function]>;
1231   let Documentation = [Undocumented];
1232 }
1233
1234 def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
1235   let Spellings = [GCC<"nomips16">];
1236   let Subjects = SubjectList<[Function], ErrorDiag>;
1237   let Documentation = [Undocumented];
1238 }
1239
1240 // This is not a TargetSpecificAttr so that is silently accepted and
1241 // ignored on other targets as encouraged by the OpenCL spec.
1242 //
1243 // See OpenCL 1.2 6.11.5: "It is our intention that a particular
1244 // implementation of OpenCL be free to ignore all attributes and the
1245 // resulting executable binary will produce the same result."
1246 //
1247 // However, only AMD GPU targets will emit the corresponding IR
1248 // attribute.
1249 //
1250 // FIXME: This provides a sub-optimal error message if you attempt to
1251 // use this in CUDA, since CUDA does not use the same terminology.
1252 //
1253 // FIXME: SubjectList should be for OpenCLKernelFunction, but is not to
1254 // workaround needing to see kernel attribute before others to know if
1255 // this should be rejected on non-kernels.
1256
1257 def AMDGPUFlatWorkGroupSize : InheritableAttr {
1258   let Spellings = [GNU<"amdgpu_flat_work_group_size">];
1259   let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max">];
1260   let Documentation = [AMDGPUFlatWorkGroupSizeDocs];
1261   let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1262 }
1263
1264 def AMDGPUWavesPerEU : InheritableAttr {
1265   let Spellings = [GNU<"amdgpu_waves_per_eu">];
1266   let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max", 1>];
1267   let Documentation = [AMDGPUWavesPerEUDocs];
1268   let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1269 }
1270
1271 def AMDGPUNumSGPR : InheritableAttr {
1272   let Spellings = [GNU<"amdgpu_num_sgpr">];
1273   let Args = [UnsignedArgument<"NumSGPR">];
1274   let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1275   let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1276 }
1277
1278 def AMDGPUNumVGPR : InheritableAttr {
1279   let Spellings = [GNU<"amdgpu_num_vgpr">];
1280   let Args = [UnsignedArgument<"NumVGPR">];
1281   let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1282   let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1283 }
1284
1285 def NoSplitStack : InheritableAttr {
1286   let Spellings = [GCC<"no_split_stack">];
1287   let Subjects = SubjectList<[Function], ErrorDiag>;
1288   let Documentation = [NoSplitStackDocs];
1289 }
1290
1291 def NonNull : InheritableParamAttr {
1292   let Spellings = [GCC<"nonnull">];
1293   let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
1294                              "ExpectedFunctionMethodOrParameter">;
1295   let Args = [VariadicUnsignedArgument<"Args">];
1296   let AdditionalMembers =
1297 [{bool isNonNull(unsigned idx) const {
1298     if (!args_size())
1299       return true;
1300     for (const auto &V : args())
1301       if (V == idx)
1302         return true;
1303     return false;
1304   } }];
1305   // FIXME: We should merge duplicates into a single nonnull attribute.
1306   let DuplicatesAllowedWhileMerging = 1;
1307   let Documentation = [NonNullDocs];
1308 }
1309
1310 def ReturnsNonNull : InheritableAttr {
1311   let Spellings = [GCC<"returns_nonnull">];
1312   let Subjects = SubjectList<[ObjCMethod, Function], WarnDiag,
1313                              "ExpectedFunctionOrMethod">;
1314   let Documentation = [ReturnsNonNullDocs];
1315 }
1316
1317 // pass_object_size(N) indicates that the parameter should have
1318 // __builtin_object_size with Type=N evaluated on the parameter at the callsite.
1319 def PassObjectSize : InheritableParamAttr {
1320   let Spellings = [GNU<"pass_object_size">];
1321   let Args = [IntArgument<"Type">];
1322   let Subjects = SubjectList<[ParmVar]>;
1323   let Documentation = [PassObjectSizeDocs];
1324 }
1325
1326 // Nullability type attributes.
1327 def TypeNonNull : TypeAttr {
1328   let Spellings = [Keyword<"_Nonnull">];
1329   let Documentation = [TypeNonNullDocs];
1330 }
1331
1332 def TypeNullable : TypeAttr {
1333   let Spellings = [Keyword<"_Nullable">];
1334   let Documentation = [TypeNullableDocs];
1335 }
1336
1337 def TypeNullUnspecified : TypeAttr {
1338   let Spellings = [Keyword<"_Null_unspecified">];
1339   let Documentation = [TypeNullUnspecifiedDocs];
1340 }
1341
1342 def ObjCKindOf : TypeAttr {
1343   let Spellings = [Keyword<"__kindof">];
1344   let Documentation = [Undocumented];
1345 }
1346
1347 def AssumeAligned : InheritableAttr {
1348   let Spellings = [GCC<"assume_aligned">];
1349   let Subjects = SubjectList<[ObjCMethod, Function]>;
1350   let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>];
1351   let Documentation = [AssumeAlignedDocs];
1352 }
1353
1354 def AllocAlign : InheritableAttr {
1355   let Spellings = [GCC<"alloc_align">];
1356   let Subjects = SubjectList<[HasFunctionProto], WarnDiag,
1357                              "ExpectedFunctionWithProtoType">;
1358   let Args = [IntArgument<"ParamIndex">];
1359   let Documentation = [AllocAlignDocs];
1360 }
1361
1362 def NoReturn : InheritableAttr {
1363   let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
1364   // FIXME: Does GCC allow this on the function instead?
1365   let Documentation = [Undocumented];
1366 }
1367
1368 def NoInstrumentFunction : InheritableAttr {
1369   let Spellings = [GCC<"no_instrument_function">];
1370   let Subjects = SubjectList<[Function]>;
1371   let Documentation = [Undocumented];
1372 }
1373
1374 def NotTailCalled : InheritableAttr {
1375   let Spellings = [GNU<"not_tail_called">, CXX11<"clang", "not_tail_called">];
1376   let Subjects = SubjectList<[Function]>;
1377   let Documentation = [NotTailCalledDocs];
1378 }
1379
1380 def NoThrow : InheritableAttr {
1381   let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
1382   let Documentation = [Undocumented];
1383 }
1384
1385 def NvWeak : IgnoredAttr {
1386   // No Declspec spelling of this attribute; the CUDA headers use
1387   // __attribute__((nv_weak)) unconditionally.
1388   let Spellings = [GNU<"nv_weak">];
1389   let LangOpts = [CUDA];
1390 }
1391
1392 def ObjCBridge : InheritableAttr {
1393   let Spellings = [GNU<"objc_bridge">];
1394   let Subjects = SubjectList<[Record, TypedefName], ErrorDiag,
1395                              "ExpectedStructOrUnionOrTypedef">;
1396   let Args = [IdentifierArgument<"BridgedType">];
1397   let Documentation = [Undocumented];
1398 }
1399
1400 def ObjCBridgeMutable : InheritableAttr {
1401   let Spellings = [GNU<"objc_bridge_mutable">];
1402   let Subjects = SubjectList<[Record], ErrorDiag>;
1403   let Args = [IdentifierArgument<"BridgedType">];
1404   let Documentation = [Undocumented];
1405 }
1406
1407 def ObjCBridgeRelated : InheritableAttr {
1408   let Spellings = [GNU<"objc_bridge_related">];
1409   let Subjects = SubjectList<[Record], ErrorDiag>;
1410   let Args = [IdentifierArgument<"RelatedClass">,
1411           IdentifierArgument<"ClassMethod", 1>,
1412           IdentifierArgument<"InstanceMethod", 1>];
1413   let HasCustomParsing = 1;
1414   let Documentation = [Undocumented];
1415 }
1416
1417 def NSReturnsRetained : InheritableAttr {
1418   let Spellings = [GNU<"ns_returns_retained">];
1419 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1420   let Documentation = [Undocumented];
1421 }
1422
1423 def NSReturnsNotRetained : InheritableAttr {
1424   let Spellings = [GNU<"ns_returns_not_retained">];
1425 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1426   let Documentation = [Undocumented];
1427 }
1428
1429 def NSReturnsAutoreleased : InheritableAttr {
1430   let Spellings = [GNU<"ns_returns_autoreleased">];
1431 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1432   let Documentation = [Undocumented];
1433 }
1434
1435 def NSConsumesSelf : InheritableAttr {
1436   let Spellings = [GNU<"ns_consumes_self">];
1437   let Subjects = SubjectList<[ObjCMethod]>;
1438   let Documentation = [Undocumented];
1439 }
1440
1441 def NSConsumed : InheritableParamAttr {
1442   let Spellings = [GNU<"ns_consumed">];
1443   let Subjects = SubjectList<[ParmVar]>;
1444   let Documentation = [Undocumented];
1445 }
1446
1447 def ObjCException : InheritableAttr {
1448   let Spellings = [GNU<"objc_exception">];
1449   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1450   let Documentation = [Undocumented];
1451 }
1452
1453 def ObjCMethodFamily : InheritableAttr {
1454   let Spellings = [GNU<"objc_method_family">];
1455   let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1456   let Args = [EnumArgument<"Family", "FamilyKind",
1457                ["none", "alloc", "copy", "init", "mutableCopy", "new"],
1458                ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
1459                 "OMF_mutableCopy", "OMF_new"]>];
1460   let Documentation = [ObjCMethodFamilyDocs];
1461 }
1462
1463 def ObjCNSObject : InheritableAttr {
1464   let Spellings = [GNU<"NSObject">];
1465   let Documentation = [Undocumented];
1466 }
1467
1468 def ObjCIndependentClass : InheritableAttr {
1469   let Spellings = [GNU<"objc_independent_class">];
1470   let Documentation = [Undocumented];
1471 }
1472
1473 def ObjCPreciseLifetime : InheritableAttr {
1474   let Spellings = [GNU<"objc_precise_lifetime">];
1475   let Subjects = SubjectList<[Var], ErrorDiag>;
1476   let Documentation = [Undocumented];
1477 }
1478
1479 def ObjCReturnsInnerPointer : InheritableAttr {
1480   let Spellings = [GNU<"objc_returns_inner_pointer">];
1481   let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
1482   let Documentation = [Undocumented];
1483 }
1484
1485 def ObjCRequiresSuper : InheritableAttr {
1486   let Spellings = [GNU<"objc_requires_super">];
1487   let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1488   let Documentation = [ObjCRequiresSuperDocs];
1489 }
1490
1491 def ObjCRootClass : InheritableAttr {
1492   let Spellings = [GNU<"objc_root_class">];
1493   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1494   let Documentation = [Undocumented];
1495 }
1496
1497 def ObjCSubclassingRestricted : InheritableAttr {
1498   let Spellings = [GNU<"objc_subclassing_restricted">];
1499   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1500   let Documentation = [ObjCSubclassingRestrictedDocs];
1501 }
1502
1503 def ObjCExplicitProtocolImpl : InheritableAttr {
1504   let Spellings = [GNU<"objc_protocol_requires_explicit_implementation">];
1505   let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
1506   let Documentation = [Undocumented];
1507 }
1508
1509 def ObjCDesignatedInitializer : Attr {
1510   let Spellings = [GNU<"objc_designated_initializer">];
1511   let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag,
1512                              "ExpectedObjCInterfaceDeclInitMethod">;
1513   let Documentation = [Undocumented];
1514 }
1515
1516 def ObjCRuntimeName : Attr {
1517   let Spellings = [GNU<"objc_runtime_name">];
1518   let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
1519   let Args = [StringArgument<"MetadataName">];
1520   let Documentation = [ObjCRuntimeNameDocs];
1521 }
1522
1523 def ObjCRuntimeVisible : Attr {
1524   let Spellings = [GNU<"objc_runtime_visible">];
1525   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1526   let Documentation = [ObjCRuntimeVisibleDocs];
1527 }
1528
1529 def ObjCBoxable : Attr {
1530   let Spellings = [GNU<"objc_boxable">];
1531   let Subjects = SubjectList<[Record], ErrorDiag, "ExpectedStructOrUnion">;
1532   let Documentation = [ObjCBoxableDocs];
1533 }
1534
1535 def OptimizeNone : InheritableAttr {
1536   let Spellings = [GNU<"optnone">, CXX11<"clang", "optnone">];
1537   let Subjects = SubjectList<[Function, ObjCMethod]>;
1538   let Documentation = [OptnoneDocs];
1539 }
1540
1541 def Overloadable : Attr {
1542   let Spellings = [GNU<"overloadable">];
1543   let Subjects = SubjectList<[Function], ErrorDiag>;
1544   let Documentation = [OverloadableDocs];
1545 }
1546
1547 def Override : InheritableAttr { 
1548   let Spellings = [Keyword<"override">];
1549   let SemaHandler = 0;
1550   let Documentation = [Undocumented];
1551 }
1552
1553 def Ownership : InheritableAttr {
1554   let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
1555                    GNU<"ownership_takes">];
1556   let Accessors = [Accessor<"isHolds", [GNU<"ownership_holds">]>,
1557                    Accessor<"isReturns", [GNU<"ownership_returns">]>,
1558                    Accessor<"isTakes", [GNU<"ownership_takes">]>];
1559   let AdditionalMembers = [{
1560     enum OwnershipKind { Holds, Returns, Takes };
1561     OwnershipKind getOwnKind() const {
1562       return isHolds() ? Holds :
1563              isTakes() ? Takes :
1564              Returns;
1565     }
1566   }];
1567   let Args = [IdentifierArgument<"Module">, VariadicUnsignedArgument<"Args">];
1568   let Subjects = SubjectList<[HasFunctionProto], WarnDiag,
1569                              "ExpectedFunctionWithProtoType">;
1570   let Documentation = [Undocumented];
1571 }
1572
1573 def Packed : InheritableAttr {
1574   let Spellings = [GCC<"packed">];
1575 //  let Subjects = [Tag, Field];
1576   let Documentation = [Undocumented];
1577 }
1578
1579 def IntelOclBicc : InheritableAttr {
1580   let Spellings = [GNU<"intel_ocl_bicc">];
1581 //  let Subjects = [Function, ObjCMethod];
1582   let Documentation = [Undocumented];
1583 }
1584
1585 def Pcs : InheritableAttr {
1586   let Spellings = [GCC<"pcs">];
1587   let Args = [EnumArgument<"PCS", "PCSType",
1588                            ["aapcs", "aapcs-vfp"],
1589                            ["AAPCS", "AAPCS_VFP"]>];
1590 //  let Subjects = [Function, ObjCMethod];
1591   let Documentation = [PcsDocs];
1592 }
1593
1594 def Pure : InheritableAttr {
1595   let Spellings = [GCC<"pure">];
1596   let Documentation = [Undocumented];
1597 }
1598
1599 def Regparm : TypeAttr {
1600   let Spellings = [GCC<"regparm">];
1601   let Args = [UnsignedArgument<"NumParams">];
1602   let Documentation = [RegparmDocs];
1603 }
1604
1605 def ReqdWorkGroupSize : InheritableAttr {
1606   let Spellings = [GNU<"reqd_work_group_size">];
1607   let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
1608               UnsignedArgument<"ZDim">];
1609   let Subjects = SubjectList<[Function], ErrorDiag>;
1610   let Documentation = [Undocumented];
1611 }
1612
1613 def RequireConstantInit : InheritableAttr {
1614   let Spellings = [GNU<"require_constant_initialization">,
1615                    CXX11<"clang", "require_constant_initialization">];
1616   let Subjects = SubjectList<[GlobalVar], ErrorDiag,
1617                               "ExpectedStaticOrTLSVar">;
1618   let Documentation = [RequireConstantInitDocs];
1619   let LangOpts = [CPlusPlus];
1620 }
1621
1622 def WorkGroupSizeHint :  InheritableAttr {
1623   let Spellings = [GNU<"work_group_size_hint">];
1624   let Args = [UnsignedArgument<"XDim">, 
1625               UnsignedArgument<"YDim">,
1626               UnsignedArgument<"ZDim">];
1627   let Subjects = SubjectList<[Function], ErrorDiag>;
1628   let Documentation = [Undocumented];
1629 }
1630
1631 def InitPriority : InheritableAttr {
1632   let Spellings = [GNU<"init_priority">];
1633   let Args = [UnsignedArgument<"Priority">];
1634   let Subjects = SubjectList<[Var], ErrorDiag>;
1635   let Documentation = [Undocumented];
1636 }
1637
1638 def Section : InheritableAttr {
1639   let Spellings = [GCC<"section">, Declspec<"allocate">];
1640   let Args = [StringArgument<"Name">];
1641   let Subjects = SubjectList<[Function, GlobalVar,
1642                               ObjCMethod, ObjCProperty], ErrorDiag,
1643                              "ExpectedFunctionGlobalVarMethodOrProperty">;
1644   let Documentation = [SectionDocs];
1645 }
1646
1647 def Sentinel : InheritableAttr {
1648   let Spellings = [GCC<"sentinel">];
1649   let Args = [DefaultIntArgument<"Sentinel", 0>,
1650               DefaultIntArgument<"NullPos", 0>];
1651 //  let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
1652   let Documentation = [Undocumented];
1653 }
1654
1655 def StdCall : InheritableAttr {
1656   let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
1657 //  let Subjects = [Function, ObjCMethod];
1658   let Documentation = [StdCallDocs];
1659 }
1660
1661 def SwiftCall : InheritableAttr {
1662   let Spellings = [GCC<"swiftcall">];
1663 //  let Subjects = SubjectList<[Function]>;
1664   let Documentation = [SwiftCallDocs];
1665 }
1666
1667 def SwiftContext : ParameterABIAttr {
1668   let Spellings = [GCC<"swift_context">];
1669   let Documentation = [SwiftContextDocs];
1670 }
1671
1672 def SwiftErrorResult : ParameterABIAttr {
1673   let Spellings = [GCC<"swift_error_result">];
1674   let Documentation = [SwiftErrorResultDocs];
1675 }
1676
1677 def SwiftIndirectResult : ParameterABIAttr {
1678   let Spellings = [GCC<"swift_indirect_result">];
1679   let Documentation = [SwiftIndirectResultDocs];
1680 }
1681
1682 def Suppress : StmtAttr {
1683   let Spellings = [CXX11<"gsl", "suppress">];
1684   let Args = [VariadicStringArgument<"DiagnosticIdentifiers">];
1685   let Documentation = [SuppressDocs];
1686 }
1687
1688 def SysVABI : InheritableAttr {
1689   let Spellings = [GCC<"sysv_abi">];
1690 //  let Subjects = [Function, ObjCMethod];
1691   let Documentation = [Undocumented];
1692 }
1693
1694 def ThisCall : InheritableAttr {
1695   let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
1696                    Keyword<"_thiscall">];
1697 //  let Subjects = [Function, ObjCMethod];
1698   let Documentation = [ThisCallDocs];
1699 }
1700
1701 def VectorCall : InheritableAttr {
1702   let Spellings = [GNU<"vectorcall">, Keyword<"__vectorcall">,
1703                    Keyword<"_vectorcall">];
1704 //  let Subjects = [Function, ObjCMethod];
1705   let Documentation = [VectorCallDocs];
1706 }
1707
1708 def Pascal : InheritableAttr {
1709   let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
1710 //  let Subjects = [Function, ObjCMethod];
1711   let Documentation = [Undocumented];
1712 }
1713
1714 def PreserveMost : InheritableAttr {
1715   let Spellings = [GNU<"preserve_most">];
1716   let Documentation = [PreserveMostDocs];
1717 }
1718
1719 def PreserveAll : InheritableAttr {
1720   let Spellings = [GNU<"preserve_all">];
1721   let Documentation = [PreserveAllDocs];
1722 }
1723
1724 def Target : InheritableAttr {
1725   let Spellings = [GCC<"target">];
1726   let Args = [StringArgument<"featuresStr">];
1727   let Subjects = SubjectList<[Function], ErrorDiag>;
1728   let Documentation = [TargetDocs];
1729   let AdditionalMembers = [{
1730     typedef std::pair<std::vector<std::string>, StringRef> ParsedTargetAttr;
1731     ParsedTargetAttr parse() const {
1732       ParsedTargetAttr Ret;
1733       SmallVector<StringRef, 1> AttrFeatures;
1734       getFeaturesStr().split(AttrFeatures, ",");
1735
1736       // Grab the various features and prepend a "+" to turn on the feature to
1737       // the backend and add them to our existing set of features.
1738       for (auto &Feature : AttrFeatures) {
1739         // Go ahead and trim whitespace rather than either erroring or
1740         // accepting it weirdly.
1741         Feature = Feature.trim();
1742
1743         // We don't support cpu tuning this way currently.
1744         // TODO: Support the fpmath option. It will require checking
1745         // overall feature validity for the function with the rest of the
1746         // attributes on the function.
1747         if (Feature.startswith("fpmath=") || Feature.startswith("tune="))
1748           continue;
1749
1750         // While we're here iterating check for a different target cpu.
1751         if (Feature.startswith("arch="))
1752           Ret.second = Feature.split("=").second.trim();
1753         else if (Feature.startswith("no-"))
1754           Ret.first.push_back("-" + Feature.split("-").second.str());
1755         else
1756           Ret.first.push_back("+" + Feature.str());
1757       }
1758       return Ret;
1759     }
1760   }];
1761 }
1762
1763 def TransparentUnion : InheritableAttr {
1764   let Spellings = [GCC<"transparent_union">];
1765 //  let Subjects = SubjectList<[Record, TypedefName]>;
1766   let Documentation = [TransparentUnionDocs];
1767   let LangOpts = [COnly];
1768 }
1769
1770 def Unavailable : InheritableAttr {
1771   let Spellings = [GNU<"unavailable">];
1772   let Args = [StringArgument<"Message", 1>,
1773               EnumArgument<"ImplicitReason", "ImplicitReason",
1774                 ["", "", "", ""],
1775                 ["IR_None",
1776                  "IR_ARCForbiddenType",
1777                  "IR_ForbiddenWeak",
1778                  "IR_ARCForbiddenConversion",
1779                  "IR_ARCInitReturnsUnrelated",
1780                  "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>];
1781   let Documentation = [Undocumented];
1782 }
1783
1784 def DiagnoseIf : InheritableAttr {
1785   let Spellings = [GNU<"diagnose_if">];
1786   let Subjects = SubjectList<[Function]>;
1787   let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
1788               EnumArgument<"DiagnosticType",
1789                            "DiagnosticType",
1790                            ["error", "warning"],
1791                            ["DT_Error", "DT_Warning"]>,
1792               BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
1793               FunctionArgument<"Parent", 0, /*fake*/ 1>];
1794   let DuplicatesAllowedWhileMerging = 1;
1795   let LateParsed = 1;
1796   let AdditionalMembers = [{
1797     bool isError() const { return diagnosticType == DT_Error; }
1798     bool isWarning() const { return diagnosticType == DT_Warning; }
1799   }];
1800   let TemplateDependent = 1;
1801   let Documentation = [DiagnoseIfDocs];
1802 }
1803
1804 def ArcWeakrefUnavailable : InheritableAttr {
1805   let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
1806   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1807   let Documentation = [Undocumented];
1808 }
1809
1810 def ObjCGC : TypeAttr {
1811   let Spellings = [GNU<"objc_gc">];
1812   let Args = [IdentifierArgument<"Kind">];
1813   let Documentation = [Undocumented];
1814 }
1815
1816 def ObjCOwnership : InheritableAttr {
1817   let Spellings = [GNU<"objc_ownership">];
1818   let Args = [IdentifierArgument<"Kind">];
1819   let ASTNode = 0;
1820   let Documentation = [Undocumented];
1821 }
1822
1823 def ObjCRequiresPropertyDefs : InheritableAttr {
1824   let Spellings = [GNU<"objc_requires_property_definitions">];
1825   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1826   let Documentation = [Undocumented];
1827 }
1828
1829 def Unused : InheritableAttr {
1830   let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">];
1831   let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
1832                               Field, ObjCMethod, FunctionLike], WarnDiag,
1833                              "ExpectedForMaybeUnused">;
1834   let Documentation = [WarnMaybeUnusedDocs];
1835 }
1836
1837 def Used : InheritableAttr {
1838   let Spellings = [GCC<"used">];
1839   let Documentation = [Undocumented];
1840 }
1841
1842 def Uuid : InheritableAttr {
1843   let Spellings = [Declspec<"uuid">, Microsoft<"uuid">];
1844   let Args = [StringArgument<"Guid">];
1845   let Subjects = SubjectList<[Record, Enum], WarnDiag, "ExpectedEnumOrClass">;
1846   // FIXME: Allow expressing logical AND for LangOpts. Our condition should be:
1847   // CPlusPlus && (MicrosoftExt || Borland)
1848   let LangOpts = [MicrosoftExt, Borland];
1849   let Documentation = [Undocumented];
1850 }
1851
1852 def VectorSize : TypeAttr {
1853   let Spellings = [GCC<"vector_size">];
1854   let Args = [ExprArgument<"NumBytes">];
1855   let Documentation = [Undocumented];
1856 }
1857
1858 def VecTypeHint : InheritableAttr {
1859   let Spellings = [GNU<"vec_type_hint">];
1860   let Args = [TypeArgument<"TypeHint">];
1861   let Subjects = SubjectList<[Function], ErrorDiag>;
1862   let Documentation = [Undocumented];
1863 }
1864
1865 def Visibility : InheritableAttr {
1866   let Clone = 0;
1867   let Spellings = [GCC<"visibility">];
1868   let Args = [EnumArgument<"Visibility", "VisibilityType",
1869                            ["default", "hidden", "internal", "protected"],
1870                            ["Default", "Hidden", "Hidden", "Protected"]>];
1871   let MeaningfulToClassTemplateDefinition = 1;
1872   let Documentation = [Undocumented];
1873 }
1874
1875 def TypeVisibility : InheritableAttr {
1876   let Clone = 0;
1877   let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">];
1878   let Args = [EnumArgument<"Visibility", "VisibilityType",
1879                            ["default", "hidden", "internal", "protected"],
1880                            ["Default", "Hidden", "Hidden", "Protected"]>];
1881 //  let Subjects = [Tag, ObjCInterface, Namespace];
1882   let Documentation = [Undocumented];
1883 }
1884
1885 def VecReturn : InheritableAttr {
1886   let Spellings = [GNU<"vecreturn">];
1887   let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
1888   let Documentation = [Undocumented];
1889 }
1890
1891 def WarnUnused : InheritableAttr {
1892   let Spellings = [GNU<"warn_unused">];
1893   let Subjects = SubjectList<[Record]>;
1894   let Documentation = [Undocumented];
1895 }
1896
1897 def WarnUnusedResult : InheritableAttr {
1898   let Spellings = [CXX11<"", "nodiscard", 201603>,
1899                    CXX11<"clang", "warn_unused_result">,
1900                    GCC<"warn_unused_result">];
1901   let Subjects = SubjectList<[ObjCMethod, Enum, CXXRecord, FunctionLike],
1902                              WarnDiag, "ExpectedFunctionMethodEnumOrClass">;
1903   let Documentation = [WarnUnusedResultsDocs];
1904 }
1905
1906 def Weak : InheritableAttr {
1907   let Spellings = [GCC<"weak">];
1908   let Subjects = SubjectList<[Var, Function, CXXRecord]>;
1909   let Documentation = [Undocumented];
1910 }
1911
1912 def WeakImport : InheritableAttr {
1913   let Spellings = [GNU<"weak_import">];
1914   let Documentation = [Undocumented];
1915 }
1916
1917 def WeakRef : InheritableAttr {
1918   let Spellings = [GCC<"weakref">];
1919   // A WeakRef that has an argument is treated as being an AliasAttr
1920   let Args = [StringArgument<"Aliasee", 1>];
1921   let Subjects = SubjectList<[Var, Function], ErrorDiag>;
1922   let Documentation = [Undocumented];
1923 }
1924
1925 def LTOVisibilityPublic : InheritableAttr {
1926   let Spellings = [CXX11<"clang", "lto_visibility_public">];
1927   let Subjects = SubjectList<[Record]>;
1928   let Documentation = [LTOVisibilityDocs];
1929 }
1930
1931 def AnyX86Interrupt : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
1932   // NOTE: If you add any additional spellings, ARMInterrupt's,
1933   // MSP430Interrupt's and MipsInterrupt's spellings must match.
1934   let Spellings = [GNU<"interrupt">];
1935   let Subjects = SubjectList<[HasFunctionProto]>;
1936   let ParseKind = "Interrupt";
1937   let HasCustomParsing = 1;
1938   let Documentation = [AnyX86InterruptDocs];
1939 }
1940
1941 def AnyX86NoCallerSavedRegisters : InheritableAttr,
1942                                    TargetSpecificAttr<TargetAnyX86> {
1943   let Spellings = [GCC<"no_caller_saved_registers">];
1944   let Documentation = [AnyX86NoCallerSavedRegistersDocs];
1945 }
1946
1947 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetX86> {
1948   let Spellings = [GNU<"force_align_arg_pointer">];
1949   // Technically, this appertains to a FunctionDecl, but the target-specific
1950   // code silently allows anything function-like (such as typedefs or function
1951   // pointers), but does not apply the attribute to them.
1952   let Documentation = [Undocumented];
1953 }
1954
1955 def NoSanitize : InheritableAttr {
1956   let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">];
1957   let Args = [VariadicStringArgument<"Sanitizers">];
1958   let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag,
1959     "ExpectedFunctionMethodOrGlobalVar">;
1960   let Documentation = [NoSanitizeDocs];
1961   let AdditionalMembers = [{
1962     SanitizerMask getMask() const {
1963       SanitizerMask Mask = 0;
1964       for (auto SanitizerName : sanitizers()) {
1965         SanitizerMask ParsedMask =
1966             parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
1967         Mask |= expandSanitizerGroups(ParsedMask);
1968       }
1969       return Mask;
1970     }
1971   }];
1972 }
1973
1974 // Attributes to disable a specific sanitizer. No new sanitizers should be added
1975 // to this list; the no_sanitize attribute should be extended instead.
1976 def NoSanitizeSpecific : InheritableAttr {
1977   let Spellings = [GCC<"no_address_safety_analysis">,
1978                    GCC<"no_sanitize_address">,
1979                    GCC<"no_sanitize_thread">,
1980                    GNU<"no_sanitize_memory">];
1981   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
1982         "ExpectedFunctionOrGlobalVar">;
1983   let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
1984                        NoSanitizeMemoryDocs];
1985   let ASTNode = 0;
1986 }
1987
1988 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
1989
1990 def GuardedVar : InheritableAttr {
1991   let Spellings = [GNU<"guarded_var">];
1992   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1993                              "ExpectedFieldOrGlobalVar">;
1994   let Documentation = [Undocumented];
1995 }
1996
1997 def PtGuardedVar : InheritableAttr {
1998   let Spellings = [GNU<"pt_guarded_var">];
1999   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2000                              "ExpectedFieldOrGlobalVar">;
2001   let Documentation = [Undocumented];
2002 }
2003
2004 def Lockable : InheritableAttr {
2005   let Spellings = [GNU<"lockable">];
2006   let Subjects = SubjectList<[Record]>;
2007   let Documentation = [Undocumented];
2008   let ASTNode = 0;  // Replaced by Capability
2009 }
2010
2011 def ScopedLockable : InheritableAttr {
2012   let Spellings = [GNU<"scoped_lockable">];
2013   let Subjects = SubjectList<[Record]>;
2014   let Documentation = [Undocumented];
2015 }
2016
2017 def Capability : InheritableAttr {
2018   let Spellings = [GNU<"capability">, CXX11<"clang", "capability">,
2019                    GNU<"shared_capability">,
2020                    CXX11<"clang", "shared_capability">];
2021   let Subjects = SubjectList<[Record, TypedefName], ErrorDiag,
2022                              "ExpectedStructOrUnionOrTypedef">;
2023   let Args = [StringArgument<"Name">];
2024   let Accessors = [Accessor<"isShared",
2025                     [GNU<"shared_capability">,
2026                      CXX11<"clang","shared_capability">]>];
2027   let Documentation = [Undocumented];
2028   let AdditionalMembers = [{
2029     bool isMutex() const { return getName().equals_lower("mutex"); }
2030     bool isRole() const { return getName().equals_lower("role"); }
2031   }];
2032 }
2033
2034 def AssertCapability : InheritableAttr {
2035   let Spellings = [GNU<"assert_capability">,
2036                    CXX11<"clang", "assert_capability">,
2037                    GNU<"assert_shared_capability">,
2038                    CXX11<"clang", "assert_shared_capability">];
2039   let Subjects = SubjectList<[Function]>;
2040   let LateParsed = 1;
2041   let TemplateDependent = 1;
2042   let ParseArgumentsAsUnevaluated = 1;
2043   let DuplicatesAllowedWhileMerging = 1;
2044   let Args = [ExprArgument<"Expr">];
2045   let Accessors = [Accessor<"isShared",
2046                     [GNU<"assert_shared_capability">,
2047                      CXX11<"clang", "assert_shared_capability">]>];
2048   let Documentation = [AssertCapabilityDocs];
2049 }
2050
2051 def AcquireCapability : InheritableAttr {
2052   let Spellings = [GNU<"acquire_capability">,
2053                    CXX11<"clang", "acquire_capability">,
2054                    GNU<"acquire_shared_capability">,
2055                    CXX11<"clang", "acquire_shared_capability">,
2056                    GNU<"exclusive_lock_function">,
2057                    GNU<"shared_lock_function">];
2058   let Subjects = SubjectList<[Function]>;
2059   let LateParsed = 1;
2060   let TemplateDependent = 1;
2061   let ParseArgumentsAsUnevaluated = 1;
2062   let DuplicatesAllowedWhileMerging = 1;
2063   let Args = [VariadicExprArgument<"Args">];
2064   let Accessors = [Accessor<"isShared",
2065                     [GNU<"acquire_shared_capability">,
2066                      CXX11<"clang", "acquire_shared_capability">,
2067                      GNU<"shared_lock_function">]>];
2068   let Documentation = [AcquireCapabilityDocs];
2069 }
2070
2071 def TryAcquireCapability : InheritableAttr {
2072   let Spellings = [GNU<"try_acquire_capability">,
2073                    CXX11<"clang", "try_acquire_capability">,
2074                    GNU<"try_acquire_shared_capability">,
2075                    CXX11<"clang", "try_acquire_shared_capability">];
2076   let Subjects = SubjectList<[Function],
2077                              ErrorDiag>;
2078   let LateParsed = 1;
2079   let TemplateDependent = 1;
2080   let ParseArgumentsAsUnevaluated = 1;
2081   let DuplicatesAllowedWhileMerging = 1;
2082   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2083   let Accessors = [Accessor<"isShared",
2084                     [GNU<"try_acquire_shared_capability">,
2085                      CXX11<"clang", "try_acquire_shared_capability">]>];
2086   let Documentation = [TryAcquireCapabilityDocs];
2087 }
2088
2089 def ReleaseCapability : InheritableAttr {
2090   let Spellings = [GNU<"release_capability">,
2091                    CXX11<"clang", "release_capability">,
2092                    GNU<"release_shared_capability">,
2093                    CXX11<"clang", "release_shared_capability">,
2094                    GNU<"release_generic_capability">,
2095                    CXX11<"clang", "release_generic_capability">,
2096                    GNU<"unlock_function">];
2097   let Subjects = SubjectList<[Function]>;
2098   let LateParsed = 1;
2099   let TemplateDependent = 1;
2100   let ParseArgumentsAsUnevaluated = 1;
2101   let DuplicatesAllowedWhileMerging = 1;
2102   let Args = [VariadicExprArgument<"Args">];
2103   let Accessors = [Accessor<"isShared",
2104                     [GNU<"release_shared_capability">,
2105                      CXX11<"clang", "release_shared_capability">]>,
2106                    Accessor<"isGeneric",
2107                      [GNU<"release_generic_capability">,
2108                       CXX11<"clang", "release_generic_capability">,
2109                       GNU<"unlock_function">]>];
2110   let Documentation = [ReleaseCapabilityDocs];
2111 }
2112
2113 def RequiresCapability : InheritableAttr {
2114   let Spellings = [GNU<"requires_capability">,
2115                    CXX11<"clang", "requires_capability">,
2116                    GNU<"exclusive_locks_required">,
2117                    GNU<"requires_shared_capability">,
2118                    CXX11<"clang", "requires_shared_capability">,
2119                    GNU<"shared_locks_required">];
2120   let Args = [VariadicExprArgument<"Args">];
2121   let LateParsed = 1;
2122   let TemplateDependent = 1;
2123   let ParseArgumentsAsUnevaluated = 1;
2124   let DuplicatesAllowedWhileMerging = 1;
2125   let Subjects = SubjectList<[Function]>;
2126   let Accessors = [Accessor<"isShared", [GNU<"requires_shared_capability">,
2127                                          GNU<"shared_locks_required">,
2128                                 CXX11<"clang","requires_shared_capability">]>];
2129   let Documentation = [Undocumented];
2130 }
2131
2132 def NoThreadSafetyAnalysis : InheritableAttr {
2133   let Spellings = [GNU<"no_thread_safety_analysis">];
2134   let Subjects = SubjectList<[Function]>;
2135   let Documentation = [Undocumented];
2136 }
2137
2138 def GuardedBy : InheritableAttr {
2139   let Spellings = [GNU<"guarded_by">];
2140   let Args = [ExprArgument<"Arg">];
2141   let LateParsed = 1;
2142   let TemplateDependent = 1;
2143   let ParseArgumentsAsUnevaluated = 1;
2144   let DuplicatesAllowedWhileMerging = 1;
2145   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2146                              "ExpectedFieldOrGlobalVar">;
2147   let Documentation = [Undocumented];
2148 }
2149
2150 def PtGuardedBy : InheritableAttr {
2151   let Spellings = [GNU<"pt_guarded_by">];
2152   let Args = [ExprArgument<"Arg">];
2153   let LateParsed = 1;
2154   let TemplateDependent = 1;
2155   let ParseArgumentsAsUnevaluated = 1;
2156   let DuplicatesAllowedWhileMerging = 1;
2157   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2158                              "ExpectedFieldOrGlobalVar">;
2159   let Documentation = [Undocumented];
2160 }
2161
2162 def AcquiredAfter : InheritableAttr {
2163   let Spellings = [GNU<"acquired_after">];
2164   let Args = [VariadicExprArgument<"Args">];
2165   let LateParsed = 1;
2166   let TemplateDependent = 1;
2167   let ParseArgumentsAsUnevaluated = 1;
2168   let DuplicatesAllowedWhileMerging = 1;
2169   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2170                              "ExpectedFieldOrGlobalVar">;
2171   let Documentation = [Undocumented];
2172 }
2173
2174 def AcquiredBefore : InheritableAttr {
2175   let Spellings = [GNU<"acquired_before">];
2176   let Args = [VariadicExprArgument<"Args">];
2177   let LateParsed = 1;
2178   let TemplateDependent = 1;
2179   let ParseArgumentsAsUnevaluated = 1;
2180   let DuplicatesAllowedWhileMerging = 1;
2181   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2182                              "ExpectedFieldOrGlobalVar">;
2183   let Documentation = [Undocumented];
2184 }
2185
2186 def AssertExclusiveLock : InheritableAttr {
2187   let Spellings = [GNU<"assert_exclusive_lock">];
2188   let Args = [VariadicExprArgument<"Args">];
2189   let LateParsed = 1;
2190   let TemplateDependent = 1;
2191   let ParseArgumentsAsUnevaluated = 1;
2192   let DuplicatesAllowedWhileMerging = 1;
2193   let Subjects = SubjectList<[Function]>;
2194   let Documentation = [Undocumented];
2195 }
2196
2197 def AssertSharedLock : InheritableAttr {
2198   let Spellings = [GNU<"assert_shared_lock">];
2199   let Args = [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 ExclusiveTrylockFunction : InheritableAttr {
2211   let Spellings = [GNU<"exclusive_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 // The first argument is an integer or boolean value specifying the return value
2222 // of a successful lock acquisition.
2223 def SharedTrylockFunction : InheritableAttr {
2224   let Spellings = [GNU<"shared_trylock_function">];
2225   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2226   let LateParsed = 1;
2227   let TemplateDependent = 1;
2228   let ParseArgumentsAsUnevaluated = 1;
2229   let DuplicatesAllowedWhileMerging = 1;
2230   let Subjects = SubjectList<[Function]>;
2231   let Documentation = [Undocumented];
2232 }
2233
2234 def LockReturned : InheritableAttr {
2235   let Spellings = [GNU<"lock_returned">];
2236   let Args = [ExprArgument<"Arg">];
2237   let LateParsed = 1;
2238   let TemplateDependent = 1;
2239   let ParseArgumentsAsUnevaluated = 1;
2240   let Subjects = SubjectList<[Function]>;
2241   let Documentation = [Undocumented];
2242 }
2243
2244 def LocksExcluded : InheritableAttr {
2245   let Spellings = [GNU<"locks_excluded">];
2246   let Args = [VariadicExprArgument<"Args">];
2247   let LateParsed = 1;
2248   let TemplateDependent = 1;
2249   let ParseArgumentsAsUnevaluated = 1;
2250   let DuplicatesAllowedWhileMerging = 1;
2251   let Subjects = SubjectList<[Function]>;
2252   let Documentation = [Undocumented];
2253 }
2254
2255 // C/C++ consumed attributes.
2256
2257 def Consumable : InheritableAttr {
2258   let Spellings = [GNU<"consumable">];
2259   let Subjects = SubjectList<[CXXRecord]>;
2260   let Args = [EnumArgument<"DefaultState", "ConsumedState",
2261                            ["unknown", "consumed", "unconsumed"],
2262                            ["Unknown", "Consumed", "Unconsumed"]>];
2263   let Documentation = [ConsumableDocs];
2264 }
2265
2266 def ConsumableAutoCast : InheritableAttr {
2267   let Spellings = [GNU<"consumable_auto_cast_state">];
2268   let Subjects = SubjectList<[CXXRecord]>;
2269   let Documentation = [Undocumented];
2270 }
2271
2272 def ConsumableSetOnRead : InheritableAttr {
2273   let Spellings = [GNU<"consumable_set_state_on_read">];
2274   let Subjects = SubjectList<[CXXRecord]>;
2275   let Documentation = [Undocumented];
2276 }
2277
2278 def CallableWhen : InheritableAttr {
2279   let Spellings = [GNU<"callable_when">];
2280   let Subjects = SubjectList<[CXXMethod]>;
2281   let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
2282                                    ["unknown", "consumed", "unconsumed"],
2283                                    ["Unknown", "Consumed", "Unconsumed"]>];
2284   let Documentation = [CallableWhenDocs];
2285 }
2286
2287 def ParamTypestate : InheritableAttr {
2288   let Spellings = [GNU<"param_typestate">];
2289   let Subjects = SubjectList<[ParmVar]>;
2290   let Args = [EnumArgument<"ParamState", "ConsumedState",
2291                            ["unknown", "consumed", "unconsumed"],
2292                            ["Unknown", "Consumed", "Unconsumed"]>];
2293   let Documentation = [ParamTypestateDocs];
2294 }
2295
2296 def ReturnTypestate : InheritableAttr {
2297   let Spellings = [GNU<"return_typestate">];
2298   let Subjects = SubjectList<[Function, ParmVar]>;
2299   let Args = [EnumArgument<"State", "ConsumedState",
2300                            ["unknown", "consumed", "unconsumed"],
2301                            ["Unknown", "Consumed", "Unconsumed"]>];
2302   let Documentation = [ReturnTypestateDocs];
2303 }
2304
2305 def SetTypestate : InheritableAttr {
2306   let Spellings = [GNU<"set_typestate">];
2307   let Subjects = SubjectList<[CXXMethod]>;
2308   let Args = [EnumArgument<"NewState", "ConsumedState",
2309                            ["unknown", "consumed", "unconsumed"],
2310                            ["Unknown", "Consumed", "Unconsumed"]>];
2311   let Documentation = [SetTypestateDocs];
2312 }
2313
2314 def TestTypestate : InheritableAttr {
2315   let Spellings = [GNU<"test_typestate">];
2316   let Subjects = SubjectList<[CXXMethod]>;
2317   let Args = [EnumArgument<"TestState", "ConsumedState",
2318                            ["consumed", "unconsumed"],
2319                            ["Consumed", "Unconsumed"]>];
2320   let Documentation = [TestTypestateDocs];
2321 }
2322
2323 // Type safety attributes for `void *' pointers and type tags.
2324
2325 def ArgumentWithTypeTag : InheritableAttr {
2326   let Spellings = [GNU<"argument_with_type_tag">,
2327                    GNU<"pointer_with_type_tag">];
2328   let Args = [IdentifierArgument<"ArgumentKind">,
2329               UnsignedArgument<"ArgumentIdx">,
2330               UnsignedArgument<"TypeTagIdx">,
2331               BoolArgument<"IsPointer">];
2332   let HasCustomParsing = 1;
2333   let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
2334 }
2335
2336 def TypeTagForDatatype : InheritableAttr {
2337   let Spellings = [GNU<"type_tag_for_datatype">];
2338   let Args = [IdentifierArgument<"ArgumentKind">,
2339               TypeArgument<"MatchingCType">,
2340               BoolArgument<"LayoutCompatible">,
2341               BoolArgument<"MustBeNull">];
2342 //  let Subjects = SubjectList<[Var], ErrorDiag>;
2343   let HasCustomParsing = 1;
2344   let Documentation = [TypeTagForDatatypeDocs];
2345 }
2346
2347 // Microsoft-related attributes
2348
2349 def MSNoVTable : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
2350   let Spellings = [Declspec<"novtable">];
2351   let Subjects = SubjectList<[CXXRecord]>;
2352   let Documentation = [MSNoVTableDocs];
2353 }
2354
2355 def : IgnoredAttr {
2356   let Spellings = [Declspec<"property">];
2357 }
2358
2359 def MSStruct : InheritableAttr {
2360   let Spellings = [GCC<"ms_struct">];
2361   let Subjects = SubjectList<[Record]>;
2362   let Documentation = [Undocumented];
2363 }
2364
2365 def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2366   let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
2367   let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2368   let Documentation = [DLLExportDocs];
2369 }
2370
2371 def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2372   let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
2373   let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2374   let Documentation = [DLLImportDocs];
2375 }
2376
2377 def SelectAny : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2378   let Spellings = [Declspec<"selectany">, GCC<"selectany">];
2379   let Documentation = [Undocumented];
2380 }
2381
2382 def Thread : Attr {
2383   let Spellings = [Declspec<"thread">];
2384   let LangOpts = [MicrosoftExt];
2385   let Documentation = [ThreadDocs];
2386   let Subjects = SubjectList<[Var]>;
2387 }
2388
2389 def Win64 : IgnoredAttr {
2390   let Spellings = [Keyword<"__w64">];
2391   let LangOpts = [MicrosoftExt];
2392 }
2393
2394 def Ptr32 : TypeAttr {
2395   let Spellings = [Keyword<"__ptr32">];
2396   let Documentation = [Undocumented];
2397 }
2398
2399 def Ptr64 : TypeAttr {
2400   let Spellings = [Keyword<"__ptr64">];
2401   let Documentation = [Undocumented];
2402 }
2403
2404 def SPtr : TypeAttr {
2405   let Spellings = [Keyword<"__sptr">];
2406   let Documentation = [Undocumented];
2407 }
2408
2409 def UPtr : TypeAttr {
2410   let Spellings = [Keyword<"__uptr">];
2411   let Documentation = [Undocumented];
2412 }
2413
2414 def MSInheritance : InheritableAttr {
2415   let LangOpts = [MicrosoftExt];
2416   let Args = [DefaultBoolArgument<"BestCase", 1>];
2417   let Spellings = [Keyword<"__single_inheritance">,
2418                    Keyword<"__multiple_inheritance">,
2419                    Keyword<"__virtual_inheritance">,
2420                    Keyword<"__unspecified_inheritance">];
2421   let AdditionalMembers = [{
2422   static bool hasVBPtrOffsetField(Spelling Inheritance) {
2423     return Inheritance == Keyword_unspecified_inheritance;
2424   }
2425
2426   // Only member pointers to functions need a this adjustment, since it can be
2427   // combined with the field offset for data pointers.
2428   static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
2429     return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
2430   }
2431
2432   static bool hasVBTableOffsetField(Spelling Inheritance) {
2433     return Inheritance >= Keyword_virtual_inheritance;
2434   }
2435
2436   static bool hasOnlyOneField(bool IsMemberFunction,
2437                               Spelling Inheritance) {
2438     if (IsMemberFunction)
2439       return Inheritance <= Keyword_single_inheritance;
2440     return Inheritance <= Keyword_multiple_inheritance;
2441   }
2442   }];
2443   let Documentation = [MSInheritanceDocs];
2444 }
2445
2446 def MSVtorDisp : InheritableAttr {
2447   // This attribute has no spellings as it is only ever created implicitly.
2448   let Spellings = [];
2449   let Args = [UnsignedArgument<"vdm">];
2450   let SemaHandler = 0;
2451
2452   let AdditionalMembers = [{
2453   enum Mode {
2454     Never,
2455     ForVBaseOverride,
2456     ForVFTable
2457   };
2458
2459   Mode getVtorDispMode() const { return Mode(vdm); }
2460   }];
2461   let Documentation = [Undocumented];
2462 }
2463
2464 def InitSeg : Attr {
2465   let Spellings = [Pragma<"", "init_seg">];
2466   let Args = [StringArgument<"Section">];
2467   let SemaHandler = 0;
2468   let Documentation = [InitSegDocs];
2469   let AdditionalMembers = [{
2470   void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2471     OS << '(' << getSection() << ')';
2472   }
2473   }];
2474 }
2475
2476 def LoopHint : Attr {
2477   /// #pragma clang loop <option> directive
2478   /// vectorize: vectorizes loop operations if State == Enable.
2479   /// vectorize_width: vectorize loop operations with width 'Value'.
2480   /// interleave: interleave multiple loop iterations if State == Enable.
2481   /// interleave_count: interleaves 'Value' loop interations.
2482   /// unroll: fully unroll loop if State == Enable.
2483   /// unroll_count: unrolls loop 'Value' times.
2484   /// distribute: attempt to distribute loop if State == Enable
2485
2486   /// #pragma unroll <argument> directive
2487   /// <no arg>: fully unrolls loop.
2488   /// boolean: fully unrolls loop if State == Enable.
2489   /// expression: unrolls loop 'Value' times.
2490
2491   let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">,
2492                    Pragma<"", "nounroll">];
2493
2494   /// State of the loop optimization specified by the spelling.
2495   let Args = [EnumArgument<"Option", "OptionType",
2496                           ["vectorize", "vectorize_width", "interleave", "interleave_count",
2497                            "unroll", "unroll_count", "distribute"],
2498                           ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
2499                            "Unroll", "UnrollCount", "Distribute"]>,
2500               EnumArgument<"State", "LoopHintState",
2501                            ["enable", "disable", "numeric", "assume_safety", "full"],
2502                            ["Enable", "Disable", "Numeric", "AssumeSafety", "Full"]>,
2503               ExprArgument<"Value">];
2504
2505   let AdditionalMembers = [{
2506   static const char *getOptionName(int Option) {
2507     switch(Option) {
2508     case Vectorize: return "vectorize";
2509     case VectorizeWidth: return "vectorize_width";
2510     case Interleave: return "interleave";
2511     case InterleaveCount: return "interleave_count";
2512     case Unroll: return "unroll";
2513     case UnrollCount: return "unroll_count";
2514     case Distribute: return "distribute";
2515     }
2516     llvm_unreachable("Unhandled LoopHint option.");
2517   }
2518
2519   void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2520     unsigned SpellingIndex = getSpellingListIndex();
2521     // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
2522     // "nounroll" is already emitted as the pragma name.
2523     if (SpellingIndex == Pragma_nounroll)
2524       return;
2525     else if (SpellingIndex == Pragma_unroll) {
2526       OS << getValueString(Policy);
2527       return;
2528     }
2529
2530     assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2531     OS << getOptionName(option) << getValueString(Policy);
2532   }
2533
2534   // Return a string containing the loop hint argument including the
2535   // enclosing parentheses.
2536   std::string getValueString(const PrintingPolicy &Policy) const {
2537     std::string ValueName;
2538     llvm::raw_string_ostream OS(ValueName);
2539     OS << "(";
2540     if (state == Numeric)
2541       value->printPretty(OS, nullptr, Policy);
2542     else if (state == Enable)
2543       OS << "enable";
2544     else if (state == Full)
2545       OS << "full";
2546     else if (state == AssumeSafety)
2547       OS << "assume_safety";
2548     else
2549       OS << "disable";
2550     OS << ")";
2551     return OS.str();
2552   }
2553
2554   // Return a string suitable for identifying this attribute in diagnostics.
2555   std::string getDiagnosticName(const PrintingPolicy &Policy) const {
2556     unsigned SpellingIndex = getSpellingListIndex();
2557     if (SpellingIndex == Pragma_nounroll)
2558       return "#pragma nounroll";
2559     else if (SpellingIndex == Pragma_unroll)
2560       return "#pragma unroll" + (option == UnrollCount ? getValueString(Policy) : "");
2561
2562     assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2563     return getOptionName(option) + getValueString(Policy);
2564   }
2565   }];
2566
2567   let Documentation = [LoopHintDocs, UnrollHintDocs];
2568 }
2569
2570 def CapturedRecord : InheritableAttr {
2571   // This attribute has no spellings as it is only ever created implicitly.
2572   let Spellings = [];
2573   let SemaHandler = 0;
2574   let Documentation = [Undocumented];
2575 }
2576
2577 def OMPThreadPrivateDecl : InheritableAttr {
2578   // This attribute has no spellings as it is only ever created implicitly.
2579   let Spellings = [];
2580   let SemaHandler = 0;
2581   let Documentation = [Undocumented];
2582 }
2583
2584 def OMPCaptureNoInit : InheritableAttr {
2585   // This attribute has no spellings as it is only ever created implicitly.
2586   let Spellings = [];
2587   let SemaHandler = 0;
2588   let Documentation = [Undocumented];
2589 }
2590
2591 def OMPDeclareSimdDecl : Attr {
2592   let Spellings = [Pragma<"omp", "declare simd">];
2593   let Subjects = SubjectList<[Function]>;
2594   let SemaHandler = 0;
2595   let HasCustomParsing = 1;
2596   let Documentation = [OMPDeclareSimdDocs];
2597   let Args = [
2598     EnumArgument<"BranchState", "BranchStateTy",
2599                  [ "", "inbranch", "notinbranch" ],
2600                  [ "BS_Undefined", "BS_Inbranch", "BS_Notinbranch" ]>,
2601     ExprArgument<"Simdlen">, VariadicExprArgument<"Uniforms">,
2602     VariadicExprArgument<"Aligneds">, VariadicExprArgument<"Alignments">,
2603     VariadicExprArgument<"Linears">, VariadicUnsignedArgument<"Modifiers">,
2604     VariadicExprArgument<"Steps">
2605   ];
2606   let AdditionalMembers = [{
2607     void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
2608         const {
2609       if (getBranchState() != BS_Undefined)
2610         OS << ConvertBranchStateTyToStr(getBranchState()) << " ";
2611       if (auto *E = getSimdlen()) {
2612         OS << "simdlen(";
2613         E->printPretty(OS, nullptr, Policy);
2614         OS << ") ";
2615       }
2616       if (uniforms_size() > 0) {
2617         OS << "uniform";
2618         StringRef Sep = "(";
2619         for (auto *E : uniforms()) {
2620           OS << Sep;
2621           E->printPretty(OS, nullptr, Policy);
2622           Sep = ", ";
2623         }
2624         OS << ") ";
2625       }
2626       alignments_iterator NI = alignments_begin();
2627       for (auto *E : aligneds()) {
2628         OS << "aligned(";
2629         E->printPretty(OS, nullptr, Policy);
2630         if (*NI) {
2631           OS << ": ";
2632           (*NI)->printPretty(OS, nullptr, Policy);
2633         }
2634         OS << ") ";
2635         ++NI;
2636       }
2637       steps_iterator I = steps_begin();
2638       modifiers_iterator MI = modifiers_begin();
2639       for (auto *E : linears()) {
2640         OS << "linear(";
2641         if (*MI != OMPC_LINEAR_unknown)
2642           OS << getOpenMPSimpleClauseTypeName(OMPC_linear, *MI) << "(";
2643         E->printPretty(OS, nullptr, Policy);
2644         if (*MI != OMPC_LINEAR_unknown)
2645           OS << ")";
2646         if (*I) {
2647           OS << ": ";
2648           (*I)->printPretty(OS, nullptr, Policy);
2649         }
2650         OS << ") ";
2651         ++I;
2652         ++MI;
2653       }
2654     }
2655   }];
2656 }
2657
2658 def OMPDeclareTargetDecl : Attr {
2659   let Spellings = [Pragma<"omp", "declare target">];
2660   let SemaHandler = 0;
2661   let Documentation = [OMPDeclareTargetDocs];
2662   let Args = [
2663     EnumArgument<"MapType", "MapTypeTy",
2664                  [ "to", "link" ],
2665                  [ "MT_To", "MT_Link" ]>
2666   ];
2667   let AdditionalMembers = [{
2668     void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2669       // Use fake syntax because it is for testing and debugging purpose only.
2670       if (getMapType() != MT_To)
2671         OS << ConvertMapTypeTyToStr(getMapType()) << " ";
2672     }
2673   }];
2674 }
2675
2676 def InternalLinkage : InheritableAttr {
2677   let Spellings = [GNU<"internal_linkage">, CXX11<"clang", "internal_linkage">];
2678   let Subjects = SubjectList<[Var, Function, CXXRecord]>;
2679   let Documentation = [InternalLinkageDocs];
2680 }