]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/clang/Basic/Attr.td
Vendor import of stripped clang trunk r375505, the last commit before
[FreeBSD/FreeBSD.git] / include / clang / Basic / Attr.td
1 //==--- Attr.td - attribute definitions -----------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // The documentation is organized by category. Attributes can have category-
10 // specific documentation that is collated within the larger document.
11 class DocumentationCategory<string name> {
12   string Name = name;
13   code Content = [{}];
14 }
15 def DocCatFunction : DocumentationCategory<"Function Attributes">;
16 def DocCatVariable : DocumentationCategory<"Variable Attributes">;
17 def DocCatField : DocumentationCategory<"Field Attributes">;
18 def DocCatType : DocumentationCategory<"Type Attributes">;
19 def DocCatStmt : DocumentationCategory<"Statement Attributes">;
20 def DocCatDecl : DocumentationCategory<"Declaration Attributes">;
21
22 // Attributes listed under the Undocumented category do not generate any public
23 // documentation. Ideally, this category should be used for internal-only
24 // attributes which contain no spellings.
25 def DocCatUndocumented : DocumentationCategory<"Undocumented">;
26
27 class DocDeprecated<string replacement = ""> {
28   // If the Replacement field is empty, no replacement will be listed with the
29   // documentation. Otherwise, the documentation will specify the attribute has
30   // been superseded by this replacement.
31   string Replacement = replacement;
32 }
33
34 // Specifies the documentation to be associated with the given category.
35 class Documentation {
36   DocumentationCategory Category;
37   code Content;
38
39   // If the heading is empty, one may be picked automatically. If the attribute
40   // only has one spelling, no heading is required as the attribute's sole
41   // spelling is sufficient. If all spellings are semantically common, the
42   // heading will be the semantic spelling. If the spellings are not
43   // semantically common and no heading is provided, an error will be emitted.
44   string Heading = "";
45
46   // When set, specifies that the attribute is deprecated and can optionally
47   // specify a replacement attribute.
48   DocDeprecated Deprecated;
49 }
50
51 // Specifies that the attribute is explicitly undocumented. This can be a
52 // helpful placeholder for the attribute while working on the implementation,
53 // but should not be used once feature work has been completed.
54 def Undocumented : Documentation {
55   let Category = DocCatUndocumented;
56 }
57
58 include "clang/Basic/AttrDocs.td"
59
60 // An attribute's subject is whatever it appertains to. In this file, it is
61 // more accurately a list of things that an attribute can appertain to. All
62 // Decls and Stmts are possibly AttrSubjects (even though the syntax may not
63 // allow attributes on a given Decl or Stmt).
64 class AttrSubject;
65
66 include "clang/Basic/DeclNodes.td"
67 include "clang/Basic/StmtNodes.td"
68
69 // A subset-subject is an AttrSubject constrained to operate only on some subset
70 // of that subject.
71 //
72 // The code fragment is a boolean expression that will confirm that the subject
73 // meets the requirements; the subject will have the name S, and will have the
74 // type specified by the base. It should be a simple boolean expression. The
75 // diagnostic string should be a comma-separated list of subject names.
76 class SubsetSubject<AttrSubject base, code check, string diag> : AttrSubject {
77   AttrSubject Base = base;
78   code CheckCode = check;
79   string DiagSpelling = diag;
80 }
81
82 def LocalVar : SubsetSubject<Var,
83                               [{S->hasLocalStorage() && !isa<ParmVarDecl>(S)}],
84                               "local variables">;
85 def NonParmVar : SubsetSubject<Var,
86                                [{S->getKind() != Decl::ParmVar}],
87                                "variables">;
88 def NonLocalVar : SubsetSubject<Var,
89                                 [{!S->hasLocalStorage()}],
90                                 "variables with non-local storage">;
91 def NonBitField : SubsetSubject<Field,
92                                 [{!S->isBitField()}],
93                                 "non-bit-field non-static data members">;
94
95 def NonStaticCXXMethod : SubsetSubject<CXXMethod,
96                                        [{!S->isStatic()}],
97                                        "non-static member functions">;
98
99 def NonStaticNonConstCXXMethod
100     : SubsetSubject<CXXMethod,
101                     [{!S->isStatic() && !S->isConst()}],
102                     "non-static non-const member functions">;
103
104 def ObjCInstanceMethod : SubsetSubject<ObjCMethod,
105                                        [{S->isInstanceMethod()}],
106                                        "Objective-C instance methods">;
107
108 def Struct : SubsetSubject<Record,
109                            [{!S->isUnion()}], "structs">;
110
111 def TLSVar : SubsetSubject<Var,
112                            [{S->getTLSKind() != 0}], "thread-local variables">;
113
114 def SharedVar : SubsetSubject<Var,
115                               [{S->hasGlobalStorage() && !S->getTLSKind()}],
116                               "global variables">;
117
118 def GlobalVar : SubsetSubject<Var,
119                              [{S->hasGlobalStorage()}], "global variables">;
120
121 def InlineFunction : SubsetSubject<Function,
122                              [{S->isInlineSpecified()}], "inline functions">;
123
124 // FIXME: this hack is needed because DeclNodes.td defines the base Decl node
125 // type to be a class, not a definition. This makes it impossible to create an
126 // attribute subject which accepts a Decl. Normally, this is not a problem,
127 // because the attribute can have no Subjects clause to accomplish this. But in
128 // the case of a SubsetSubject, there's no way to express it without this hack.
129 def DeclBase : AttrSubject;
130 def FunctionLike : SubsetSubject<DeclBase,
131                                  [{S->getFunctionType(false) != nullptr}],
132                                  "functions, function pointers">;
133
134 def OpenCLKernelFunction
135     : SubsetSubject<Function, [{S->hasAttr<OpenCLKernelAttr>()}],
136                     "kernel functions">;
137
138 // HasFunctionProto is a more strict version of FunctionLike, so it should
139 // never be specified in a Subjects list along with FunctionLike (due to the
140 // inclusive nature of subject testing).
141 def HasFunctionProto : SubsetSubject<DeclBase,
142                                      [{(S->getFunctionType(true) != nullptr &&
143                               isa<FunctionProtoType>(S->getFunctionType())) ||
144                                        isa<ObjCMethodDecl>(S) ||
145                                        isa<BlockDecl>(S)}],
146                                      "non-K&R-style functions">;
147
148 // A subject that matches the implicit object parameter of a non-static member
149 // function. Accepted as a function type attribute on the type of such a
150 // member function.
151 // FIXME: This does not actually ever match currently.
152 def ImplicitObjectParameter
153     : SubsetSubject<Function, [{static_cast<void>(S), false}],
154                     "implicit object parameters">;
155
156 // A single argument to an attribute
157 class Argument<string name, bit optional, bit fake = 0> {
158   string Name = name;
159   bit Optional = optional;
160
161   /// A fake argument is used to store and serialize additional information
162   /// in an attribute without actually changing its parsing or pretty-printing.
163   bit Fake = fake;
164 }
165
166 class BoolArgument<string name, bit opt = 0, bit fake = 0> : Argument<name, opt,
167                                                                       fake>;
168 class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>;
169 class IntArgument<string name, bit opt = 0> : Argument<name, opt>;
170 class StringArgument<string name, bit opt = 0> : Argument<name, opt>;
171 class ExprArgument<string name, bit opt = 0> : Argument<name, opt>;
172 class FunctionArgument<string name, bit opt = 0, bit fake = 0> : Argument<name,
173                                                                           opt,
174                                                                           fake>;
175 class NamedArgument<string name, bit opt = 0, bit fake = 0> : Argument<name,
176                                                                           opt,
177                                                                           fake>;
178 class TypeArgument<string name, bit opt = 0> : Argument<name, opt>;
179 class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>;
180 class VariadicUnsignedArgument<string name> : Argument<name, 1>;
181 class VariadicExprArgument<string name> : Argument<name, 1>;
182 class VariadicStringArgument<string name> : Argument<name, 1>;
183 class VariadicIdentifierArgument<string name> : Argument<name, 1>;
184
185 // Like VariadicUnsignedArgument except values are ParamIdx.
186 class VariadicParamIdxArgument<string name> : Argument<name, 1>;
187
188 // A list of identifiers matching parameters or ParamIdx indices.
189 class VariadicParamOrParamIdxArgument<string name> : Argument<name, 1>;
190
191 // Like VariadicParamIdxArgument but for a single function parameter index.
192 class ParamIdxArgument<string name, bit opt = 0> : Argument<name, opt>;
193
194 // A version of the form major.minor[.subminor].
195 class VersionArgument<string name, bit opt = 0> : Argument<name, opt>;
196
197 // This one's a doozy, so it gets its own special type
198 // It can be an unsigned integer, or a type. Either can
199 // be dependent.
200 class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>;
201
202 // A bool argument with a default value
203 class DefaultBoolArgument<string name, bit default, bit fake = 0>
204     : BoolArgument<name, 1, fake> {
205   bit Default = default;
206 }
207
208 // An integer argument with a default value
209 class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
210   int Default = default;
211 }
212
213 // This argument is more complex, it includes the enumerator type name,
214 // a list of strings to accept, and a list of enumerators to map them to.
215 class EnumArgument<string name, string type, list<string> values,
216                    list<string> enums, bit opt = 0, bit fake = 0>
217     : Argument<name, opt, fake> {
218   string Type = type;
219   list<string> Values = values;
220   list<string> Enums = enums;
221 }
222
223 // FIXME: There should be a VariadicArgument type that takes any other type
224 //        of argument and generates the appropriate type.
225 class VariadicEnumArgument<string name, string type, list<string> values,
226                            list<string> enums> : Argument<name, 1>  {
227   string Type = type;
228   list<string> Values = values;
229   list<string> Enums = enums;
230 }
231
232 // This handles one spelling of an attribute.
233 class Spelling<string name, string variety> {
234   string Name = name;
235   string Variety = variety;
236   bit KnownToGCC;
237 }
238
239 class GNU<string name> : Spelling<name, "GNU">;
240 class Declspec<string name> : Spelling<name, "Declspec">;
241 class Microsoft<string name> : Spelling<name, "Microsoft">;
242 class CXX11<string namespace, string name, int version = 1>
243     : Spelling<name, "CXX11"> {
244   string Namespace = namespace;
245   int Version = version;
246 }
247 class C2x<string namespace, string name> : Spelling<name, "C2x"> {
248   string Namespace = namespace;
249 }
250
251 class Keyword<string name> : Spelling<name, "Keyword">;
252 class Pragma<string namespace, string name> : Spelling<name, "Pragma"> {
253   string Namespace = namespace;
254 }
255
256 // The GCC spelling implies GNU<name> and CXX11<"gnu", name> and also sets
257 // KnownToGCC to 1. This spelling should be used for any GCC-compatible
258 // attributes.
259 class GCC<string name> : Spelling<name, "GCC"> {
260   let KnownToGCC = 1;
261 }
262
263 // The Clang spelling implies GNU<name>, CXX11<"clang", name>, and optionally,
264 // C2x<"clang", name>. This spelling should be used for any Clang-specific
265 // attributes.
266 class Clang<string name, bit allowInC = 1> : Spelling<name, "Clang"> {
267   bit AllowInC = allowInC;
268 }
269
270 class Accessor<string name, list<Spelling> spellings> {
271   string Name = name;
272   list<Spelling> Spellings = spellings;
273 }
274
275 class SubjectDiag<bit warn> {
276   bit Warn = warn;
277 }
278 def WarnDiag : SubjectDiag<1>;
279 def ErrorDiag : SubjectDiag<0>;
280
281 class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag,
282                   string customDiag = ""> {
283   list<AttrSubject> Subjects = subjects;
284   SubjectDiag Diag = diag;
285   string CustomDiag = customDiag;
286 }
287
288 class LangOpt<string name, code customCode = [{}]> {
289   string Name = name;
290
291   // A custom predicate, written as an expression evaluated in a context with
292   // "LangOpts" bound.
293   code CustomCode = customCode;
294 }
295 def MicrosoftExt : LangOpt<"MicrosoftExt">;
296 def Borland : LangOpt<"Borland">;
297 def CUDA : LangOpt<"CUDA">;
298 def HIP : LangOpt<"HIP">;
299 def COnly : LangOpt<"COnly", "!LangOpts.CPlusPlus">;
300 def CPlusPlus : LangOpt<"CPlusPlus">;
301 def OpenCL : LangOpt<"OpenCL">;
302 def RenderScript : LangOpt<"RenderScript">;
303 def ObjC : LangOpt<"ObjC">;
304 def BlocksSupported : LangOpt<"Blocks">;
305 def ObjCAutoRefCount : LangOpt<"ObjCAutoRefCount">;
306 def ObjCNonFragileRuntime : LangOpt<"ObjCNonFragileRuntime",
307                                     "LangOpts.ObjCRuntime.allowsClassStubs()">;
308
309 // Language option for CMSE extensions
310 def Cmse : LangOpt<"Cmse">;
311
312 // Defines targets for target-specific attributes. Empty lists are unchecked.
313 class TargetSpec {
314   // Specifies Architectures for which the target applies, based off the
315   // ArchType enumeration in Triple.h.
316   list<string> Arches = [];
317   // Specifies Operating Systems for which the target applies, based off the
318   // OSType enumeration in Triple.h
319   list<string> OSes;
320   // Specifies Object Formats for which the target applies, based off the
321   // ObjectFormatType enumeration in Triple.h
322   list<string> ObjectFormats;
323   // A custom predicate, written as an expression evaluated in a context
324   // with the following declarations in scope:
325   //   const clang::TargetInfo &Target;
326   //   const llvm::Triple &T = Target.getTriple();
327   code CustomCode = [{}];
328 }
329
330 class TargetArch<list<string> arches> : TargetSpec {
331   let Arches = arches;
332 }
333 def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
334 def TargetAVR : TargetArch<["avr"]>;
335 def TargetMips32 : TargetArch<["mips", "mipsel"]>;
336 def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
337 def TargetMSP430 : TargetArch<["msp430"]>;
338 def TargetRISCV : TargetArch<["riscv32", "riscv64"]>;
339 def TargetX86 : TargetArch<["x86"]>;
340 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
341 def TargetWebAssembly : TargetArch<["wasm32", "wasm64"]>;
342 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
343   let OSes = ["Win32"];
344 }
345 def TargetItaniumCXXABI : TargetSpec {
346   let CustomCode = [{ Target.getCXXABI().isItaniumFamily() }];
347 }
348 def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
349   let CustomCode = [{ Target.getCXXABI().isMicrosoft() }];
350 }
351 def TargetELF : TargetSpec {
352   let ObjectFormats = ["ELF"];
353 }
354
355 // Attribute subject match rules that are used for #pragma clang attribute.
356 //
357 // A instance of AttrSubjectMatcherRule represents an individual match rule.
358 // An individual match rule can correspond to a number of different attribute
359 // subjects, e.g. "record" matching rule corresponds to the Record and
360 // CXXRecord attribute subjects.
361 //
362 // Match rules are used in the subject list of the #pragma clang attribute.
363 // Match rules can have sub-match rules that are instances of
364 // AttrSubjectMatcherSubRule. A sub-match rule can correspond to a number
365 // of different attribute subjects, and it can have a negated spelling as well.
366 // For example, "variable(unless(is_parameter))" matching rule corresponds to
367 // the NonParmVar attribute subject.
368 class AttrSubjectMatcherSubRule<string name, list<AttrSubject> subjects,
369                                 bit negated = 0> {
370   string Name = name;
371   list<AttrSubject> Subjects = subjects;
372   bit Negated = negated;
373   // Lists language options, one of which is required to be true for the
374   // attribute to be applicable. If empty, the language options are taken
375   // from the parent matcher rule.
376   list<LangOpt> LangOpts = [];
377 }
378 class AttrSubjectMatcherRule<string name, list<AttrSubject> subjects,
379                              list<AttrSubjectMatcherSubRule> subrules = []> {
380   string Name = name;
381   list<AttrSubject> Subjects = subjects;
382   list<AttrSubjectMatcherSubRule> Constraints = subrules;
383   // Lists language options, one of which is required to be true for the
384   // attribute to be applicable. If empty, no language options are required.
385   list<LangOpt> LangOpts = [];
386 }
387
388 // function(is_member)
389 def SubRuleForCXXMethod : AttrSubjectMatcherSubRule<"is_member", [CXXMethod]> {
390   let LangOpts = [CPlusPlus];
391 }
392 def SubjectMatcherForFunction : AttrSubjectMatcherRule<"function", [Function], [
393   SubRuleForCXXMethod
394 ]>;
395 // hasType is abstract, it should be used with one of the sub-rules.
396 def SubjectMatcherForType : AttrSubjectMatcherRule<"hasType", [], [
397   AttrSubjectMatcherSubRule<"functionType", [FunctionLike]>
398
399   // FIXME: There's a matcher ambiguity with objc methods and blocks since
400   // functionType excludes them but functionProtoType includes them.
401   // AttrSubjectMatcherSubRule<"functionProtoType", [HasFunctionProto]>
402 ]>;
403 def SubjectMatcherForTypedef : AttrSubjectMatcherRule<"type_alias",
404                                                       [TypedefName]>;
405 def SubjectMatcherForRecord : AttrSubjectMatcherRule<"record", [Record,
406                                                                 CXXRecord], [
407   // unless(is_union)
408   AttrSubjectMatcherSubRule<"is_union", [Struct], 1>
409 ]>;
410 def SubjectMatcherForEnum : AttrSubjectMatcherRule<"enum", [Enum]>;
411 def SubjectMatcherForEnumConstant : AttrSubjectMatcherRule<"enum_constant",
412                                                            [EnumConstant]>;
413 def SubjectMatcherForVar : AttrSubjectMatcherRule<"variable", [Var], [
414   AttrSubjectMatcherSubRule<"is_thread_local", [TLSVar]>,
415   AttrSubjectMatcherSubRule<"is_global", [GlobalVar]>,
416   AttrSubjectMatcherSubRule<"is_parameter", [ParmVar]>,
417   // unless(is_parameter)
418   AttrSubjectMatcherSubRule<"is_parameter", [NonParmVar], 1>
419 ]>;
420 def SubjectMatcherForField : AttrSubjectMatcherRule<"field", [Field]>;
421 def SubjectMatcherForNamespace : AttrSubjectMatcherRule<"namespace",
422                                                         [Namespace]> {
423   let LangOpts = [CPlusPlus];
424 }
425 def SubjectMatcherForObjCInterface : AttrSubjectMatcherRule<"objc_interface",
426                                                             [ObjCInterface]> {
427   let LangOpts = [ObjC];
428 }
429 def SubjectMatcherForObjCProtocol : AttrSubjectMatcherRule<"objc_protocol",
430                                                            [ObjCProtocol]> {
431   let LangOpts = [ObjC];
432 }
433 def SubjectMatcherForObjCCategory : AttrSubjectMatcherRule<"objc_category",
434                                                            [ObjCCategory]> {
435   let LangOpts = [ObjC];
436 }
437 def SubjectMatcherForObjCImplementation :
438     AttrSubjectMatcherRule<"objc_implementation", [ObjCImpl]> {
439   let LangOpts = [ObjC];
440 }
441 def SubjectMatcherForObjCMethod : AttrSubjectMatcherRule<"objc_method",
442                                                          [ObjCMethod], [
443   AttrSubjectMatcherSubRule<"is_instance", [ObjCInstanceMethod]>
444 ]> {
445   let LangOpts = [ObjC];
446 }
447 def SubjectMatcherForObjCProperty : AttrSubjectMatcherRule<"objc_property",
448                                                            [ObjCProperty]> {
449   let LangOpts = [ObjC];
450 }
451 def SubjectMatcherForBlock : AttrSubjectMatcherRule<"block", [Block]> {
452   let LangOpts = [BlocksSupported];
453 }
454
455 // Aggregate attribute subject match rules are abstract match rules that can't
456 // be used directly in #pragma clang attribute. Instead, users have to use
457 // subject match rules that correspond to attribute subjects that derive from
458 // the specified subject.
459 class AttrSubjectMatcherAggregateRule<AttrSubject subject> {
460   AttrSubject Subject = subject;
461 }
462
463 def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule<Named>;
464
465 class Attr {
466   // The various ways in which an attribute can be spelled in source
467   list<Spelling> Spellings;
468   // The things to which an attribute can appertain
469   SubjectList Subjects;
470   // The arguments allowed on an attribute
471   list<Argument> Args = [];
472   // Accessors which should be generated for the attribute.
473   list<Accessor> Accessors = [];
474   // Set to true for attributes with arguments which require delayed parsing.
475   bit LateParsed = 0;
476   // Set to false to prevent an attribute from being propagated from a template
477   // to the instantiation.
478   bit Clone = 1;
479   // Set to true for attributes which must be instantiated within templates
480   bit TemplateDependent = 0;
481   // Set to true for attributes that have a corresponding AST node.
482   bit ASTNode = 1;
483   // Set to true for attributes which have handler in Sema.
484   bit SemaHandler = 1;
485   // Set to true for attributes that are completely ignored.
486   bit Ignored = 0;
487   // Set to true if the attribute's parsing does not match its semantic
488   // content. Eg) It parses 3 args, but semantically takes 4 args.  Opts out of
489   // common attribute error checking.
490   bit HasCustomParsing = 0;
491   // Set to true if all of the attribute's arguments should be parsed in an
492   // unevaluated context.
493   bit ParseArgumentsAsUnevaluated = 0;
494   // Set to true if this attribute meaningful when applied to or inherited
495   // in a class template definition.
496   bit MeaningfulToClassTemplateDefinition = 0;
497   // Set to true if this attribute can be used with '#pragma clang attribute'.
498   // By default, an attribute is supported by the '#pragma clang attribute'
499   // only when:
500   // - It has a subject list whose subjects can be represented using subject
501   //   match rules.
502   // - It has GNU/CXX11 spelling and doesn't require delayed parsing.
503   bit PragmaAttributeSupport;
504   // Lists language options, one of which is required to be true for the
505   // attribute to be applicable. If empty, no language options are required.
506   list<LangOpt> LangOpts = [];
507   // Any additional text that should be included verbatim in the class.
508   // Note: Any additional data members will leak and should be constructed
509   // externally on the ASTContext.
510   code AdditionalMembers = [{}];
511   // Any documentation that should be associated with the attribute. Since an
512   // attribute may be documented under multiple categories, more than one
513   // Documentation entry may be listed.
514   list<Documentation> Documentation;
515 }
516
517 /// A type attribute is not processed on a declaration or a statement.
518 class TypeAttr : Attr;
519
520 /// A stmt attribute is not processed on a declaration or a type.
521 class StmtAttr : Attr;
522
523 /// An inheritable attribute is inherited by later redeclarations.
524 class InheritableAttr : Attr {
525   // Set to true if this attribute can be duplicated on a subject when inheriting
526   // attributes from prior declarations.
527   bit InheritEvenIfAlreadyPresent = 0;
528 }
529
530 /// Some attributes, like calling conventions, can appear in either the
531 /// declaration or the type position. These attributes are morally type
532 /// attributes, but have historically been written on declarations.
533 class DeclOrTypeAttr : InheritableAttr;
534
535 /// A target-specific attribute.  This class is meant to be used as a mixin
536 /// with InheritableAttr or Attr depending on the attribute's needs.
537 class TargetSpecificAttr<TargetSpec target> {
538   TargetSpec Target = target;
539   // Attributes are generally required to have unique spellings for their names
540   // so that the parser can determine what kind of attribute it has parsed.
541   // However, target-specific attributes are special in that the attribute only
542   // "exists" for a given target. So two target-specific attributes can share
543   // the same name when they exist in different targets. To support this, a
544   // Kind can be explicitly specified for a target-specific attribute. This
545   // corresponds to the ParsedAttr::AT_* enum that is generated and it
546   // should contain a shared value between the attributes.
547   //
548   // Target-specific attributes which use this feature should ensure that the
549   // spellings match exactly between the attributes, and if the arguments or
550   // subjects differ, should specify HasCustomParsing = 1 and implement their
551   // own parsing and semantic handling requirements as-needed.
552   string ParseKind;
553 }
554
555 /// An inheritable parameter attribute is inherited by later
556 /// redeclarations, even when it's written on a parameter.
557 class InheritableParamAttr : InheritableAttr;
558
559 /// An attribute which changes the ABI rules for a specific parameter.
560 class ParameterABIAttr : InheritableParamAttr {
561   let Subjects = SubjectList<[ParmVar]>;
562 }
563
564 /// An ignored attribute, which we parse but discard with no checking.
565 class IgnoredAttr : Attr {
566   let Ignored = 1;
567   let ASTNode = 0;
568   let SemaHandler = 0;
569   let Documentation = [Undocumented];
570 }
571
572 //
573 // Attributes begin here
574 //
575
576 def AbiTag : Attr {
577   let Spellings = [GCC<"abi_tag">];
578   let Args = [VariadicStringArgument<"Tags">];
579   let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag>;
580   let MeaningfulToClassTemplateDefinition = 1;
581   let Documentation = [AbiTagsDocs];
582 }
583
584 def AddressSpace : TypeAttr {
585   let Spellings = [Clang<"address_space">];
586   let Args = [IntArgument<"AddressSpace">];
587   let Documentation = [Undocumented];
588 }
589
590 def Alias : Attr {
591   let Spellings = [GCC<"alias">];
592   let Args = [StringArgument<"Aliasee">];
593   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
594   let Documentation = [Undocumented];
595 }
596
597 def Aligned : InheritableAttr {
598   let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">,
599                    Keyword<"_Alignas">];
600   let Args = [AlignedArgument<"Alignment", 1>];
601   let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
602                    Accessor<"isC11", [Keyword<"_Alignas">]>,
603                    Accessor<"isAlignas", [Keyword<"alignas">,
604                                           Keyword<"_Alignas">]>,
605                    Accessor<"isDeclspec",[Declspec<"align">]>];
606   let Documentation = [Undocumented];
607 }
608
609 def AlignValue : Attr {
610   let Spellings = [
611     // Unfortunately, this is semantically an assertion, not a directive
612     // (something else must ensure the alignment), so aligned_value is a
613     // probably a better name. We might want to add an aligned_value spelling in
614     // the future (and a corresponding C++ attribute), but this can be done
615     // later once we decide if we also want them to have slightly-different
616     // semantics than Intel's align_value.
617     //
618     // Does not get a [[]] spelling because the attribute is not exposed as such
619     // by Intel.
620     GNU<"align_value">
621     // Intel's compiler on Windows also supports:
622     // , Declspec<"align_value">
623   ];
624   let Args = [ExprArgument<"Alignment">];
625   let Subjects = SubjectList<[Var, TypedefName]>;
626   let Documentation = [AlignValueDocs];
627 }
628
629 def AlignMac68k : InheritableAttr {
630   // This attribute has no spellings as it is only ever created implicitly.
631   let Spellings = [];
632   let SemaHandler = 0;
633   let Documentation = [Undocumented];
634 }
635
636 def AlwaysInline : InheritableAttr {
637   let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
638   let Subjects = SubjectList<[Function]>;
639   let Documentation = [Undocumented];
640 }
641
642 def Artificial : InheritableAttr {
643   let Spellings = [GCC<"artificial">];
644   let Subjects = SubjectList<[InlineFunction], WarnDiag>;
645   let Documentation = [ArtificialDocs];
646 }
647
648 def XRayInstrument : InheritableAttr {
649   let Spellings = [Clang<"xray_always_instrument">,
650                    Clang<"xray_never_instrument">];
651   let Subjects = SubjectList<[Function, ObjCMethod]>;
652   let Accessors = [Accessor<"alwaysXRayInstrument",
653                      [Clang<"xray_always_instrument">]>,
654                    Accessor<"neverXRayInstrument",
655                      [Clang<"xray_never_instrument">]>];
656   let Documentation = [XRayDocs];
657 }
658
659 def XRayLogArgs : InheritableAttr {
660   let Spellings = [Clang<"xray_log_args">];
661   let Subjects = SubjectList<[Function, ObjCMethod]>;
662   // This argument is a count not an index, so it has the same encoding (base
663   // 1 including C++ implicit this parameter) at the source and LLVM levels of
664   // representation, so ParamIdxArgument is inappropriate.  It is never used
665   // at the AST level of representation, so it never needs to be adjusted not
666   // to include any C++ implicit this parameter.  Thus, we just store it and
667   // use it as an unsigned that never needs adjustment.
668   let Args = [UnsignedArgument<"ArgumentCount">];
669   let Documentation = [XRayDocs];
670 }
671
672 def TLSModel : InheritableAttr {
673   let Spellings = [GCC<"tls_model">];
674   let Subjects = SubjectList<[TLSVar], ErrorDiag>;
675   let Args = [StringArgument<"Model">];
676   let Documentation = [TLSModelDocs];
677 }
678
679 def AnalyzerNoReturn : InheritableAttr {
680   // TODO: should this attribute be exposed with a [[]] spelling under the clang
681   // vendor namespace, or should it use a vendor namespace specific to the
682   // analyzer?
683   let Spellings = [GNU<"analyzer_noreturn">];
684   // TODO: Add subject list.
685   let Documentation = [Undocumented];
686 }
687
688 def Annotate : InheritableParamAttr {
689   let Spellings = [Clang<"annotate">];
690   let Args = [StringArgument<"Annotation">];
691   // Ensure that the annotate attribute can be used with
692   // '#pragma clang attribute' even though it has no subject list.
693   let PragmaAttributeSupport = 1;
694   let Documentation = [Undocumented];
695 }
696
697 def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> {
698   // NOTE: If you add any additional spellings, MSP430Interrupt's,
699   // MipsInterrupt's and AnyX86Interrupt's spellings must match.
700   let Spellings = [GCC<"interrupt">];
701   let Args = [EnumArgument<"Interrupt", "InterruptType",
702                            ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
703                            ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
704                            1>];
705   let ParseKind = "Interrupt";
706   let HasCustomParsing = 1;
707   let Documentation = [ARMInterruptDocs];
708 }
709
710 def AVRInterrupt : InheritableAttr, TargetSpecificAttr<TargetAVR> {
711   let Spellings = [GCC<"interrupt">];
712   let Subjects = SubjectList<[Function]>;
713   let ParseKind = "Interrupt";
714   let Documentation = [AVRInterruptDocs];
715 }
716
717 def AVRSignal : InheritableAttr, TargetSpecificAttr<TargetAVR> {
718   let Spellings = [GCC<"signal">];
719   let Subjects = SubjectList<[Function]>;
720   let Documentation = [AVRSignalDocs];
721 }
722
723 def AsmLabel : InheritableAttr {
724   let Spellings = [Keyword<"asm">, Keyword<"__asm__">];
725   let Args = [
726     // Label specifies the mangled name for the decl.
727     StringArgument<"Label">,
728
729     // IsLiteralLabel specifies whether the label is literal (i.e. suppresses
730     // the global C symbol prefix) or not. If not, the mangle-suppression prefix
731     // ('\01') is omitted from the decl name at the LLVM IR level.
732     //
733     // Non-literal labels are used by some external AST sources like LLDB.
734     BoolArgument<"IsLiteralLabel", /*optional=*/0, /*fake=*/1>
735   ];
736   let SemaHandler = 0;
737   let Documentation = [AsmLabelDocs];
738   let AdditionalMembers =
739 [{
740 bool isEquivalent(AsmLabelAttr *Other) const {
741   return getLabel() == Other->getLabel() && getIsLiteralLabel() == Other->getIsLiteralLabel();
742 }
743 }];
744 }
745
746 def Availability : InheritableAttr {
747   let Spellings = [Clang<"availability">];
748   let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
749               VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
750               BoolArgument<"unavailable">, StringArgument<"message">,
751               BoolArgument<"strict">, StringArgument<"replacement">,
752               IntArgument<"priority">];
753   let AdditionalMembers =
754 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
755     return llvm::StringSwitch<llvm::StringRef>(Platform)
756              .Case("android", "Android")
757              .Case("ios", "iOS")
758              .Case("macos", "macOS")
759              .Case("tvos", "tvOS")
760              .Case("watchos", "watchOS")
761              .Case("ios_app_extension", "iOS (App Extension)")
762              .Case("macos_app_extension", "macOS (App Extension)")
763              .Case("tvos_app_extension", "tvOS (App Extension)")
764              .Case("watchos_app_extension", "watchOS (App Extension)")
765              .Case("swift", "Swift")
766              .Default(llvm::StringRef());
767 }
768 static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) {
769     return llvm::StringSwitch<llvm::StringRef>(Platform)
770              .Case("ios", "iOS")
771              .Case("macos", "macOS")
772              .Case("tvos", "tvOS")
773              .Case("watchos", "watchOS")
774              .Case("ios_app_extension", "iOSApplicationExtension")
775              .Case("macos_app_extension", "macOSApplicationExtension")
776              .Case("tvos_app_extension", "tvOSApplicationExtension")
777              .Case("watchos_app_extension", "watchOSApplicationExtension")
778              .Default(Platform);
779 }
780 static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) {
781     return llvm::StringSwitch<llvm::StringRef>(Platform)
782              .Case("iOS", "ios")
783              .Case("macOS", "macos")
784              .Case("tvOS", "tvos")
785              .Case("watchOS", "watchos")
786              .Case("iOSApplicationExtension", "ios_app_extension")
787              .Case("macOSApplicationExtension", "macos_app_extension")
788              .Case("tvOSApplicationExtension", "tvos_app_extension")
789              .Case("watchOSApplicationExtension", "watchos_app_extension")
790              .Default(Platform);
791 } }];
792   let HasCustomParsing = 1;
793   let InheritEvenIfAlreadyPresent = 1;
794   let Subjects = SubjectList<[Named]>;
795   let Documentation = [AvailabilityDocs];
796 }
797
798 def ExternalSourceSymbol : InheritableAttr {
799   let Spellings = [Clang<"external_source_symbol">];
800   let Args = [StringArgument<"language", 1>,
801               StringArgument<"definedIn", 1>,
802               BoolArgument<"generatedDeclaration", 1>];
803   let HasCustomParsing = 1;
804   let Subjects = SubjectList<[Named]>;
805   let Documentation = [ExternalSourceSymbolDocs];
806 }
807
808 def Blocks : InheritableAttr {
809   let Spellings = [Clang<"blocks">];
810   let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
811   let Documentation = [Undocumented];
812 }
813
814 def Bounded : IgnoredAttr {
815   // Does not have a [[]] spelling because the attribute is ignored.
816   let Spellings = [GNU<"bounded">];
817 }
818
819 def CarriesDependency : InheritableParamAttr {
820   let Spellings = [GNU<"carries_dependency">,
821                    CXX11<"","carries_dependency", 200809>];
822   let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>;
823   let Documentation = [CarriesDependencyDocs];
824 }
825
826 def CDecl : DeclOrTypeAttr {
827   let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">];
828 //  let Subjects = [Function, ObjCMethod];
829   let Documentation = [Undocumented];
830 }
831
832 // cf_audited_transfer indicates that the given function has been
833 // audited and has been marked with the appropriate cf_consumed and
834 // cf_returns_retained attributes.  It is generally applied by
835 // '#pragma clang arc_cf_code_audited' rather than explicitly.
836 def CFAuditedTransfer : InheritableAttr {
837   let Spellings = [Clang<"cf_audited_transfer">];
838   let Subjects = SubjectList<[Function], ErrorDiag>;
839   let Documentation = [Undocumented];
840 }
841
842 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
843 // It indicates that the function has unknown or unautomatable
844 // transfer semantics.
845 def CFUnknownTransfer : InheritableAttr {
846   let Spellings = [Clang<"cf_unknown_transfer">];
847   let Subjects = SubjectList<[Function], ErrorDiag>;
848   let Documentation = [Undocumented];
849 }
850
851 def CFReturnsRetained : InheritableAttr {
852   let Spellings = [Clang<"cf_returns_retained">];
853 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
854   let Documentation = [RetainBehaviorDocs];
855 }
856
857 def CFReturnsNotRetained : InheritableAttr {
858   let Spellings = [Clang<"cf_returns_not_retained">];
859 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
860   let Documentation = [RetainBehaviorDocs];
861 }
862
863 def CFConsumed : InheritableParamAttr {
864   let Spellings = [Clang<"cf_consumed">];
865   let Subjects = SubjectList<[ParmVar]>;
866   let Documentation = [RetainBehaviorDocs];
867 }
868
869 // OSObject-based attributes.
870 def OSConsumed : InheritableParamAttr {
871   let Spellings = [Clang<"os_consumed">];
872   let Subjects = SubjectList<[ParmVar]>;
873   let Documentation = [RetainBehaviorDocs];
874 }
875
876 def OSReturnsRetained : InheritableAttr {
877   let Spellings = [Clang<"os_returns_retained">];
878   let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty, ParmVar]>;
879   let Documentation = [RetainBehaviorDocs];
880 }
881
882 def OSReturnsNotRetained : InheritableAttr {
883   let Spellings = [Clang<"os_returns_not_retained">];
884   let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty, ParmVar]>;
885   let Documentation = [RetainBehaviorDocs];
886 }
887
888 def OSReturnsRetainedOnZero : InheritableAttr {
889   let Spellings = [Clang<"os_returns_retained_on_zero">];
890   let Subjects = SubjectList<[ParmVar]>;
891   let Documentation = [RetainBehaviorDocs];
892 }
893
894 def OSReturnsRetainedOnNonZero : InheritableAttr {
895   let Spellings = [Clang<"os_returns_retained_on_non_zero">];
896   let Subjects = SubjectList<[ParmVar]>;
897   let Documentation = [RetainBehaviorDocs];
898 }
899
900 def OSConsumesThis : InheritableAttr {
901   let Spellings = [Clang<"os_consumes_this">];
902   let Subjects = SubjectList<[NonStaticCXXMethod]>;
903   let Documentation = [RetainBehaviorDocs];
904 }
905
906 def Cleanup : InheritableAttr {
907   let Spellings = [GCC<"cleanup">];
908   let Args = [FunctionArgument<"FunctionDecl">];
909   let Subjects = SubjectList<[LocalVar]>;
910   let Documentation = [Undocumented];
911 }
912
913 def Cold : InheritableAttr {
914   let Spellings = [GCC<"cold">];
915   let Subjects = SubjectList<[Function]>;
916   let Documentation = [Undocumented];
917 }
918
919 def Common : InheritableAttr {
920   let Spellings = [GCC<"common">];
921   let Subjects = SubjectList<[Var]>;
922   let Documentation = [Undocumented];
923 }
924
925 def Const : InheritableAttr {
926   let Spellings = [GCC<"const">, GCC<"__const">];
927   let Documentation = [Undocumented];
928 }
929
930 def ConstInit : InheritableAttr {
931   // This attribute does not have a C [[]] spelling because it requires the
932   // CPlusPlus language option.
933   let Spellings = [Keyword<"constinit">,
934                    Clang<"require_constant_initialization", 0>];
935   let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
936   let Accessors = [Accessor<"isConstinit", [Keyword<"constinit">]>];
937   let Documentation = [ConstInitDocs];
938   let LangOpts = [CPlusPlus];
939 }
940
941 def Constructor : InheritableAttr {
942   let Spellings = [GCC<"constructor">];
943   let Args = [DefaultIntArgument<"Priority", 65535>];
944   let Subjects = SubjectList<[Function]>;
945   let Documentation = [Undocumented];
946 }
947
948 def CPUSpecific : InheritableAttr {
949   let Spellings = [Clang<"cpu_specific">, Declspec<"cpu_specific">];
950   let Args = [VariadicIdentifierArgument<"Cpus">];
951   let Subjects = SubjectList<[Function]>;
952   let Documentation = [CPUSpecificCPUDispatchDocs];
953   let AdditionalMembers = [{
954     IdentifierInfo *getCPUName(unsigned Index) const {
955       return *(cpus_begin() + Index);
956     }
957   }];
958 }
959
960 def CPUDispatch : InheritableAttr {
961   let Spellings = [Clang<"cpu_dispatch">, Declspec<"cpu_dispatch">];
962   let Args = [VariadicIdentifierArgument<"Cpus">];
963   let Subjects = SubjectList<[Function]>;
964   let Documentation = [CPUSpecificCPUDispatchDocs];
965 }
966
967 // CUDA attributes are spelled __attribute__((attr)) or __declspec(__attr__),
968 // and they do not receive a [[]] spelling.
969 def CUDAConstant : InheritableAttr {
970   let Spellings = [GNU<"constant">, Declspec<"__constant__">];
971   let Subjects = SubjectList<[Var]>;
972   let LangOpts = [CUDA];
973   let Documentation = [Undocumented];
974 }
975
976 def CUDACudartBuiltin : IgnoredAttr {
977   let Spellings = [GNU<"cudart_builtin">, Declspec<"__cudart_builtin__">];
978   let LangOpts = [CUDA];
979 }
980
981 def CUDADevice : InheritableAttr {
982   let Spellings = [GNU<"device">, Declspec<"__device__">];
983   let Subjects = SubjectList<[Function, Var]>;
984   let LangOpts = [CUDA];
985   let Documentation = [Undocumented];
986 }
987
988 def HIPPinnedShadow : InheritableAttr {
989   let Spellings = [GNU<"hip_pinned_shadow">, Declspec<"__hip_pinned_shadow__">];
990   let Subjects = SubjectList<[Var]>;
991   let LangOpts = [HIP];
992   let Documentation = [HIPPinnedShadowDocs];
993 }
994
995 def CUDADeviceBuiltin : IgnoredAttr {
996   let Spellings = [GNU<"device_builtin">, Declspec<"__device_builtin__">];
997   let LangOpts = [CUDA];
998 }
999
1000 def CUDADeviceBuiltinSurfaceType : IgnoredAttr {
1001   let Spellings = [GNU<"device_builtin_surface_type">,
1002                    Declspec<"__device_builtin_surface_type__">];
1003   let LangOpts = [CUDA];
1004 }
1005
1006 def CUDADeviceBuiltinTextureType : IgnoredAttr {
1007   let Spellings = [GNU<"device_builtin_texture_type">,
1008                    Declspec<"__device_builtin_texture_type__">];
1009   let LangOpts = [CUDA];
1010 }
1011
1012 def CUDAGlobal : InheritableAttr {
1013   let Spellings = [GNU<"global">, Declspec<"__global__">];
1014   let Subjects = SubjectList<[Function]>;
1015   let LangOpts = [CUDA];
1016   let Documentation = [Undocumented];
1017 }
1018
1019 def CUDAHost : InheritableAttr {
1020   let Spellings = [GNU<"host">, Declspec<"__host__">];
1021   let Subjects = SubjectList<[Function]>;
1022   let LangOpts = [CUDA];
1023   let Documentation = [Undocumented];
1024 }
1025
1026 def CUDAInvalidTarget : InheritableAttr {
1027   let Spellings = [];
1028   let Subjects = SubjectList<[Function]>;
1029   let LangOpts = [CUDA];
1030   let Documentation = [Undocumented];
1031 }
1032
1033 def CUDALaunchBounds : InheritableAttr {
1034   let Spellings = [GNU<"launch_bounds">, Declspec<"__launch_bounds__">];
1035   let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>];
1036   let LangOpts = [CUDA];
1037   let Subjects = SubjectList<[ObjCMethod, FunctionLike]>;
1038   // An AST node is created for this attribute, but is not used by other parts
1039   // of the compiler. However, this node needs to exist in the AST because
1040   // non-LLVM backends may be relying on the attribute's presence.
1041   let Documentation = [Undocumented];
1042 }
1043
1044 def CUDAShared : InheritableAttr {
1045   let Spellings = [GNU<"shared">, Declspec<"__shared__">];
1046   let Subjects = SubjectList<[Var]>;
1047   let LangOpts = [CUDA];
1048   let Documentation = [Undocumented];
1049 }
1050
1051 def C11NoReturn : InheritableAttr {
1052   let Spellings = [Keyword<"_Noreturn">];
1053   let Subjects = SubjectList<[Function], ErrorDiag>;
1054   let SemaHandler = 0;
1055   let Documentation = [C11NoReturnDocs];
1056 }
1057
1058 def CXX11NoReturn : InheritableAttr {
1059   let Spellings = [CXX11<"", "noreturn", 200809>];
1060   let Subjects = SubjectList<[Function], ErrorDiag>;
1061   let Documentation = [CXX11NoReturnDocs];
1062 }
1063
1064 // Similar to CUDA, OpenCL attributes do not receive a [[]] spelling because
1065 // the specification does not expose them with one currently.
1066 def OpenCLKernel : InheritableAttr {
1067   let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
1068   let Subjects = SubjectList<[Function], ErrorDiag>;
1069   let Documentation = [Undocumented];
1070 }
1071
1072 def OpenCLUnrollHint : InheritableAttr {
1073   let Spellings = [GNU<"opencl_unroll_hint">];
1074   let Args = [UnsignedArgument<"UnrollHint">];
1075   let Documentation = [OpenCLUnrollHintDocs];
1076 }
1077
1078 def OpenCLIntelReqdSubGroupSize: InheritableAttr {
1079   let Spellings = [GNU<"intel_reqd_sub_group_size">];
1080   let Args = [UnsignedArgument<"SubGroupSize">];
1081   let Subjects = SubjectList<[Function], ErrorDiag>;
1082   let Documentation = [OpenCLIntelReqdSubGroupSizeDocs];
1083 }
1084
1085 // This attribute is both a type attribute, and a declaration attribute (for
1086 // parameter variables).
1087 def OpenCLAccess : Attr {
1088   let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
1089                    Keyword<"__write_only">, Keyword<"write_only">,
1090                    Keyword<"__read_write">, Keyword<"read_write">];
1091   let Subjects = SubjectList<[ParmVar, TypedefName], ErrorDiag>;
1092   let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
1093                                            Keyword<"read_only">]>,
1094                    Accessor<"isReadWrite", [Keyword<"__read_write">,
1095                                             Keyword<"read_write">]>,
1096                    Accessor<"isWriteOnly", [Keyword<"__write_only">,
1097                                             Keyword<"write_only">]>];
1098   let Documentation = [OpenCLAccessDocs];
1099 }
1100
1101 def OpenCLPrivateAddressSpace : TypeAttr {
1102   let Spellings = [Keyword<"__private">, Keyword<"private">];
1103   let Documentation = [OpenCLAddressSpacePrivateDocs];
1104 }
1105
1106 def OpenCLGlobalAddressSpace : TypeAttr {
1107   let Spellings = [Keyword<"__global">, Keyword<"global">];
1108   let Documentation = [OpenCLAddressSpaceGlobalDocs];
1109 }
1110
1111 def OpenCLLocalAddressSpace : TypeAttr {
1112   let Spellings = [Keyword<"__local">, Keyword<"local">];
1113   let Documentation = [OpenCLAddressSpaceLocalDocs];
1114 }
1115
1116 def OpenCLConstantAddressSpace : TypeAttr {
1117   let Spellings = [Keyword<"__constant">, Keyword<"constant">];
1118   let Documentation = [OpenCLAddressSpaceConstantDocs];
1119 }
1120
1121 def OpenCLGenericAddressSpace : TypeAttr {
1122   let Spellings = [Keyword<"__generic">, Keyword<"generic">];
1123   let Documentation = [OpenCLAddressSpaceGenericDocs];
1124 }
1125
1126 def OpenCLNoSVM : Attr {
1127   let Spellings = [GNU<"nosvm">];
1128   let Subjects = SubjectList<[Var]>;
1129   let Documentation = [OpenCLNoSVMDocs];
1130   let LangOpts = [OpenCL];
1131   let ASTNode = 0;
1132 }
1133
1134 def RenderScriptKernel : Attr {
1135   let Spellings = [GNU<"kernel">];
1136   let Subjects = SubjectList<[Function]>;
1137   let Documentation = [RenderScriptKernelAttributeDocs];
1138   let LangOpts = [RenderScript];
1139 }
1140
1141 def Deprecated : InheritableAttr {
1142   let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
1143                    CXX11<"","deprecated", 201309>, C2x<"", "deprecated">];
1144   let Args = [StringArgument<"Message", 1>,
1145               // An optional string argument that enables us to provide a
1146               // Fix-It.
1147               StringArgument<"Replacement", 1>];
1148   let MeaningfulToClassTemplateDefinition = 1;
1149   let Documentation = [DeprecatedDocs];
1150 }
1151
1152 def Destructor : InheritableAttr {
1153   let Spellings = [GCC<"destructor">];
1154   let Args = [DefaultIntArgument<"Priority", 65535>];
1155   let Subjects = SubjectList<[Function]>;
1156   let Documentation = [Undocumented];
1157 }
1158
1159 def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
1160   let Spellings = [Declspec<"empty_bases">];
1161   let Subjects = SubjectList<[CXXRecord]>;
1162   let Documentation = [EmptyBasesDocs];
1163 }
1164
1165 def AllocSize : InheritableAttr {
1166   let Spellings = [GCC<"alloc_size">];
1167   let Subjects = SubjectList<[Function]>;
1168   let Args = [ParamIdxArgument<"ElemSizeParam">,
1169               ParamIdxArgument<"NumElemsParam", /*opt*/ 1>];
1170   let TemplateDependent = 1;
1171   let Documentation = [AllocSizeDocs];
1172 }
1173
1174 def EnableIf : InheritableAttr {
1175   // Does not have a [[]] spelling because this attribute requires the ability
1176   // to parse function arguments but the attribute is not written in the type
1177   // position.
1178   let Spellings = [GNU<"enable_if">];
1179   let Subjects = SubjectList<[Function]>;
1180   let Args = [ExprArgument<"Cond">, StringArgument<"Message">];
1181   let TemplateDependent = 1;
1182   let Documentation = [EnableIfDocs];
1183 }
1184
1185 def ExtVectorType : Attr {
1186   // This is an OpenCL-related attribute and does not receive a [[]] spelling.
1187   let Spellings = [GNU<"ext_vector_type">];
1188   // FIXME: This subject list is wrong; this is a type attribute.
1189   let Subjects = SubjectList<[TypedefName], ErrorDiag>;
1190   let Args = [ExprArgument<"NumElements">];
1191   let ASTNode = 0;
1192   let Documentation = [Undocumented];
1193   // This is a type attribute with an incorrect subject list, so should not be
1194   // permitted by #pragma clang attribute.
1195   let PragmaAttributeSupport = 0;
1196 }
1197
1198 def FallThrough : StmtAttr {
1199   let Spellings = [CXX11<"", "fallthrough", 201603>, C2x<"", "fallthrough">,
1200                    CXX11<"clang", "fallthrough">, GCC<"fallthrough">];
1201 //  let Subjects = [NullStmt];
1202   let Documentation = [FallthroughDocs];
1203 }
1204
1205 def FastCall : DeclOrTypeAttr {
1206   let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
1207                    Keyword<"_fastcall">];
1208 //  let Subjects = [Function, ObjCMethod];
1209   let Documentation = [FastCallDocs];
1210 }
1211
1212 def RegCall : DeclOrTypeAttr {
1213   let Spellings = [GCC<"regcall">, Keyword<"__regcall">];
1214   let Documentation = [RegCallDocs];
1215 }
1216
1217 def Final : InheritableAttr {
1218   let Spellings = [Keyword<"final">, Keyword<"sealed">];
1219   let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
1220   let SemaHandler = 0;
1221   let Documentation = [Undocumented];
1222 }
1223
1224 def MinSize : InheritableAttr {
1225   let Spellings = [Clang<"minsize">];
1226   let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
1227   let Documentation = [Undocumented];
1228 }
1229
1230 def FlagEnum : InheritableAttr {
1231   let Spellings = [Clang<"flag_enum">];
1232   let Subjects = SubjectList<[Enum]>;
1233   let Documentation = [FlagEnumDocs];
1234 }
1235
1236 def EnumExtensibility : InheritableAttr {
1237   let Spellings = [Clang<"enum_extensibility">];
1238   let Subjects = SubjectList<[Enum]>;
1239   let Args = [EnumArgument<"Extensibility", "Kind",
1240               ["closed", "open"], ["Closed", "Open"]>];
1241   let Documentation = [EnumExtensibilityDocs];
1242 }
1243
1244 def Flatten : InheritableAttr {
1245   let Spellings = [GCC<"flatten">];
1246   let Subjects = SubjectList<[Function], ErrorDiag>;
1247   let Documentation = [FlattenDocs];
1248 }
1249
1250 def Format : InheritableAttr {
1251   let Spellings = [GCC<"format">];
1252   let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
1253               IntArgument<"FirstArg">];
1254   let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto]>;
1255   let Documentation = [FormatDocs];
1256 }
1257
1258 def FormatArg : InheritableAttr {
1259   let Spellings = [GCC<"format_arg">];
1260   let Args = [ParamIdxArgument<"FormatIdx">];
1261   let Subjects = SubjectList<[ObjCMethod, HasFunctionProto]>;
1262   let Documentation = [Undocumented];
1263 }
1264
1265 def Callback : InheritableAttr {
1266   let Spellings = [Clang<"callback">];
1267   let Args = [VariadicParamOrParamIdxArgument<"Encoding">];
1268   let Subjects = SubjectList<[Function]>;
1269   let Documentation = [CallbackDocs];
1270 }
1271
1272 def GNUInline : InheritableAttr {
1273   let Spellings = [GCC<"gnu_inline">];
1274   let Subjects = SubjectList<[Function]>;
1275   let Documentation = [GnuInlineDocs];
1276 }
1277
1278 def Hot : InheritableAttr {
1279   let Spellings = [GCC<"hot">];
1280   let Subjects = SubjectList<[Function]>;
1281   // An AST node is created for this attribute, but not actually used beyond
1282   // semantic checking for mutual exclusion with the Cold attribute.
1283   let Documentation = [Undocumented];
1284 }
1285
1286 def IBAction : InheritableAttr {
1287   let Spellings = [Clang<"ibaction">];
1288   let Subjects = SubjectList<[ObjCInstanceMethod]>;
1289   // An AST node is created for this attribute, but is not used by other parts
1290   // of the compiler. However, this node needs to exist in the AST because
1291   // external tools rely on it.
1292   let Documentation = [Undocumented];
1293 }
1294
1295 def IBOutlet : InheritableAttr {
1296   let Spellings = [Clang<"iboutlet">];
1297 //  let Subjects = [ObjCIvar, ObjCProperty];
1298   let Documentation = [Undocumented];
1299 }
1300
1301 def IBOutletCollection : InheritableAttr {
1302   let Spellings = [Clang<"iboutletcollection">];
1303   let Args = [TypeArgument<"Interface", 1>];
1304 //  let Subjects = [ObjCIvar, ObjCProperty];
1305   let Documentation = [Undocumented];
1306 }
1307
1308 def IFunc : Attr, TargetSpecificAttr<TargetELF> {
1309   let Spellings = [GCC<"ifunc">];
1310   let Args = [StringArgument<"Resolver">];
1311   let Subjects = SubjectList<[Function]>;
1312   let Documentation = [IFuncDocs];
1313 }
1314
1315 def Restrict : InheritableAttr {
1316   let Spellings = [Declspec<"restrict">, GCC<"malloc">];
1317   let Subjects = SubjectList<[Function]>;
1318   let Documentation = [Undocumented];
1319 }
1320
1321 def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
1322   let Spellings = [Declspec<"layout_version">];
1323   let Args = [UnsignedArgument<"Version">];
1324   let Subjects = SubjectList<[CXXRecord]>;
1325   let Documentation = [LayoutVersionDocs];
1326 }
1327
1328 def LifetimeBound : DeclOrTypeAttr {
1329   let Spellings = [Clang<"lifetimebound", 0>];
1330   let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;
1331   let Documentation = [LifetimeBoundDocs];
1332   let LangOpts = [CPlusPlus];
1333 }
1334
1335 def TrivialABI : InheritableAttr {
1336   // This attribute does not have a C [[]] spelling because it requires the
1337   // CPlusPlus language option.
1338   let Spellings = [Clang<"trivial_abi", 0>];
1339   let Subjects = SubjectList<[CXXRecord]>;
1340   let Documentation = [TrivialABIDocs];
1341   let LangOpts = [CPlusPlus];
1342 }
1343
1344 def MaxFieldAlignment : InheritableAttr {
1345   // This attribute has no spellings as it is only ever created implicitly.
1346   let Spellings = [];
1347   let Args = [UnsignedArgument<"Alignment">];
1348   let SemaHandler = 0;
1349   let Documentation = [Undocumented];
1350 }
1351
1352 def MayAlias : InheritableAttr {
1353   // FIXME: this is a type attribute in GCC, but a declaration attribute here.
1354   let Spellings = [GCC<"may_alias">];
1355   let Documentation = [Undocumented];
1356 }
1357
1358 def MIGServerRoutine : InheritableAttr {
1359   let Spellings = [Clang<"mig_server_routine">];
1360   let Subjects = SubjectList<[Function, ObjCMethod, Block]>;
1361   let Documentation = [MIGConventionDocs];
1362 }
1363
1364 def MSABI : DeclOrTypeAttr {
1365   let Spellings = [GCC<"ms_abi">];
1366 //  let Subjects = [Function, ObjCMethod];
1367   let Documentation = [MSABIDocs];
1368 }
1369
1370 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
1371   // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's
1372   // and AnyX86Interrupt's spellings must match.
1373   let Spellings = [GCC<"interrupt">];
1374   let Args = [UnsignedArgument<"Number">];
1375   let ParseKind = "Interrupt";
1376   let HasCustomParsing = 1;
1377   let Documentation = [Undocumented];
1378 }
1379
1380 def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1381   let Spellings = [GCC<"mips16">];
1382   let Subjects = SubjectList<[Function], ErrorDiag>;
1383   let Documentation = [Undocumented];
1384 }
1385
1386 def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1387   // NOTE: If you add any additional spellings, ARMInterrupt's,
1388   // MSP430Interrupt's and AnyX86Interrupt's spellings must match.
1389   let Spellings = [GCC<"interrupt">];
1390   let Subjects = SubjectList<[Function]>;
1391   let Args = [EnumArgument<"Interrupt", "InterruptType",
1392                            ["vector=sw0", "vector=sw1", "vector=hw0",
1393                             "vector=hw1", "vector=hw2", "vector=hw3",
1394                             "vector=hw4", "vector=hw5", "eic", ""],
1395                            ["sw0", "sw1", "hw0", "hw1", "hw2", "hw3",
1396                             "hw4", "hw5", "eic", "eic"]
1397                            >];
1398   let ParseKind = "Interrupt";
1399   let Documentation = [MipsInterruptDocs];
1400 }
1401
1402 def MicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1403   let Spellings = [GCC<"micromips">];
1404   let Subjects = SubjectList<[Function], ErrorDiag>;
1405   let Documentation = [MicroMipsDocs];
1406 }
1407
1408 def MipsLongCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
1409   let Spellings = [GCC<"long_call">, GCC<"far">];
1410   let Subjects = SubjectList<[Function]>;
1411   let Documentation = [MipsLongCallStyleDocs];
1412 }
1413
1414 def MipsShortCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
1415   let Spellings = [GCC<"short_call">, GCC<"near">];
1416   let Subjects = SubjectList<[Function]>;
1417   let Documentation = [MipsShortCallStyleDocs];
1418 }
1419
1420 def Mode : Attr {
1421   let Spellings = [GCC<"mode">];
1422   let Subjects = SubjectList<[Var, Enum, TypedefName, Field], ErrorDiag>;
1423   let Args = [IdentifierArgument<"Mode">];
1424   let Documentation = [Undocumented];
1425   // This is notionally a type attribute, which #pragma clang attribute
1426   // generally does not support.
1427   let PragmaAttributeSupport = 0;
1428 }
1429
1430 def Naked : InheritableAttr {
1431   let Spellings = [GCC<"naked">, Declspec<"naked">];
1432   let Subjects = SubjectList<[Function]>;
1433   let Documentation = [Undocumented];
1434 }
1435
1436 def NeonPolyVectorType : TypeAttr {
1437   let Spellings = [Clang<"neon_polyvector_type">];
1438   let Args = [IntArgument<"NumElements">];
1439   let Documentation = [Undocumented];
1440   // Represented as VectorType instead.
1441   let ASTNode = 0;
1442 }
1443
1444 def NeonVectorType : TypeAttr {
1445   let Spellings = [Clang<"neon_vector_type">];
1446   let Args = [IntArgument<"NumElements">];
1447   let Documentation = [Undocumented];
1448   // Represented as VectorType instead.
1449   let ASTNode = 0;
1450 }
1451
1452 def NoUniqueAddress : InheritableAttr, TargetSpecificAttr<TargetItaniumCXXABI> {
1453   let Spellings = [CXX11<"", "no_unique_address", 201803>];
1454   let Subjects = SubjectList<[NonBitField], ErrorDiag>;
1455   let Documentation = [NoUniqueAddressDocs];
1456 }
1457
1458 def ReturnsTwice : InheritableAttr {
1459   let Spellings = [GCC<"returns_twice">];
1460   let Subjects = SubjectList<[Function]>;
1461   let Documentation = [Undocumented];
1462 }
1463
1464 def DisableTailCalls : InheritableAttr {
1465   let Spellings = [Clang<"disable_tail_calls">];
1466   let Subjects = SubjectList<[Function, ObjCMethod]>;
1467   let Documentation = [DisableTailCallsDocs];
1468 }
1469
1470 def NoAlias : InheritableAttr {
1471   let Spellings = [Declspec<"noalias">];
1472   let Subjects = SubjectList<[Function]>;
1473   let Documentation = [NoAliasDocs];
1474 }
1475
1476 def NoCommon : InheritableAttr {
1477   let Spellings = [GCC<"nocommon">];
1478   let Subjects = SubjectList<[Var]>;
1479   let Documentation = [Undocumented];
1480 }
1481
1482 def NoDebug : InheritableAttr {
1483   let Spellings = [GCC<"nodebug">];
1484   let Subjects = SubjectList<[TypedefName, FunctionLike, ObjCMethod, NonParmVar]>;
1485   let Documentation = [NoDebugDocs];
1486 }
1487
1488 def NoDuplicate : InheritableAttr {
1489   let Spellings = [Clang<"noduplicate">];
1490   let Subjects = SubjectList<[Function]>;
1491   let Documentation = [NoDuplicateDocs];
1492 }
1493
1494 def Convergent : InheritableAttr {
1495   let Spellings = [Clang<"convergent">];
1496   let Subjects = SubjectList<[Function]>;
1497   let Documentation = [ConvergentDocs];
1498 }
1499
1500 def NoInline : InheritableAttr {
1501   let Spellings = [GCC<"noinline">, Declspec<"noinline">];
1502   let Subjects = SubjectList<[Function]>;
1503   let Documentation = [Undocumented];
1504 }
1505
1506 def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1507   let Spellings = [GCC<"nomips16">];
1508   let Subjects = SubjectList<[Function], ErrorDiag>;
1509   let Documentation = [Undocumented];
1510 }
1511
1512 def NoMicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1513   let Spellings = [GCC<"nomicromips">];
1514   let Subjects = SubjectList<[Function], ErrorDiag>;
1515   let Documentation = [MicroMipsDocs];
1516 }
1517
1518 def RISCVInterrupt : InheritableAttr, TargetSpecificAttr<TargetRISCV> {
1519   let Spellings = [GCC<"interrupt">];
1520   let Subjects = SubjectList<[Function]>;
1521   let Args = [EnumArgument<"Interrupt", "InterruptType",
1522                            ["user", "supervisor", "machine"],
1523                            ["user", "supervisor", "machine"],
1524                            1>];
1525   let ParseKind = "Interrupt";
1526   let Documentation = [RISCVInterruptDocs];
1527 }
1528
1529 // This is not a TargetSpecificAttr so that is silently accepted and
1530 // ignored on other targets as encouraged by the OpenCL spec.
1531 //
1532 // See OpenCL 1.2 6.11.5: "It is our intention that a particular
1533 // implementation of OpenCL be free to ignore all attributes and the
1534 // resulting executable binary will produce the same result."
1535 //
1536 // However, only AMD GPU targets will emit the corresponding IR
1537 // attribute.
1538 //
1539 // FIXME: This provides a sub-optimal error message if you attempt to
1540 // use this in CUDA, since CUDA does not use the same terminology.
1541 //
1542 // FIXME: SubjectList should be for OpenCLKernelFunction, but is not to
1543 // workaround needing to see kernel attribute before others to know if
1544 // this should be rejected on non-kernels.
1545
1546 def AMDGPUFlatWorkGroupSize : InheritableAttr {
1547   let Spellings = [Clang<"amdgpu_flat_work_group_size", 0>];
1548   let Args = [ExprArgument<"Min">, ExprArgument<"Max">];
1549   let Documentation = [AMDGPUFlatWorkGroupSizeDocs];
1550   let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1551 }
1552
1553 def AMDGPUWavesPerEU : InheritableAttr {
1554   let Spellings = [Clang<"amdgpu_waves_per_eu", 0>];
1555   let Args = [ExprArgument<"Min">, ExprArgument<"Max", 1>];
1556   let Documentation = [AMDGPUWavesPerEUDocs];
1557   let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1558 }
1559
1560 def AMDGPUNumSGPR : InheritableAttr {
1561   let Spellings = [Clang<"amdgpu_num_sgpr", 0>];
1562   let Args = [UnsignedArgument<"NumSGPR">];
1563   let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1564   let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1565 }
1566
1567 def AMDGPUNumVGPR : InheritableAttr {
1568   let Spellings = [Clang<"amdgpu_num_vgpr", 0>];
1569   let Args = [UnsignedArgument<"NumVGPR">];
1570   let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1571   let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1572 }
1573
1574 def WebAssemblyImportModule : InheritableAttr,
1575                               TargetSpecificAttr<TargetWebAssembly> {
1576   let Spellings = [Clang<"import_module">];
1577   let Args = [StringArgument<"ImportModule">];
1578   let Documentation = [WebAssemblyImportModuleDocs];
1579   let Subjects = SubjectList<[Function], ErrorDiag>;
1580 }
1581
1582 def WebAssemblyImportName : InheritableAttr,
1583                             TargetSpecificAttr<TargetWebAssembly> {
1584   let Spellings = [Clang<"import_name">];
1585   let Args = [StringArgument<"ImportName">];
1586   let Documentation = [WebAssemblyImportNameDocs];
1587   let Subjects = SubjectList<[Function], ErrorDiag>;
1588 }
1589
1590 def NoSplitStack : InheritableAttr {
1591   let Spellings = [GCC<"no_split_stack">];
1592   let Subjects = SubjectList<[Function], ErrorDiag>;
1593   let Documentation = [NoSplitStackDocs];
1594 }
1595
1596 def NonNull : InheritableParamAttr {
1597   let Spellings = [GCC<"nonnull">];
1598   let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
1599                              "functions, methods, and parameters">;
1600   let Args = [VariadicParamIdxArgument<"Args">];
1601   let AdditionalMembers = [{
1602     bool isNonNull(unsigned IdxAST) const {
1603       if (!args_size())
1604         return true;
1605       return args_end() != std::find_if(
1606           args_begin(), args_end(),
1607           [=](const ParamIdx &Idx) { return Idx.getASTIndex() == IdxAST; });
1608     }
1609   }];
1610   // FIXME: We should merge duplicates into a single nonnull attribute.
1611   let InheritEvenIfAlreadyPresent = 1;
1612   let Documentation = [NonNullDocs];
1613 }
1614
1615 def ReturnsNonNull : InheritableAttr {
1616   let Spellings = [GCC<"returns_nonnull">];
1617   let Subjects = SubjectList<[ObjCMethod, Function]>;
1618   let Documentation = [ReturnsNonNullDocs];
1619 }
1620
1621 // pass_object_size(N) indicates that the parameter should have
1622 // __builtin_object_size with Type=N evaluated on the parameter at the callsite.
1623 def PassObjectSize : InheritableParamAttr {
1624   let Spellings = [Clang<"pass_object_size">,
1625                    Clang<"pass_dynamic_object_size">];
1626   let Accessors = [Accessor<"isDynamic", [Clang<"pass_dynamic_object_size">]>];
1627   let Args = [IntArgument<"Type">];
1628   let Subjects = SubjectList<[ParmVar]>;
1629   let Documentation = [PassObjectSizeDocs];
1630 }
1631
1632 // Nullability type attributes.
1633 def TypeNonNull : TypeAttr {
1634   let Spellings = [Keyword<"_Nonnull">];
1635   let Documentation = [TypeNonNullDocs];
1636 }
1637
1638 def TypeNullable : TypeAttr {
1639   let Spellings = [Keyword<"_Nullable">];
1640   let Documentation = [TypeNullableDocs];
1641 }
1642
1643 def TypeNullUnspecified : TypeAttr {
1644   let Spellings = [Keyword<"_Null_unspecified">];
1645   let Documentation = [TypeNullUnspecifiedDocs];
1646 }
1647
1648 // This is a marker used to indicate that an __unsafe_unretained qualifier was
1649 // ignored because ARC is not enabled. The usual representation for this
1650 // qualifier is as an ObjCOwnership attribute with Kind == "none".
1651 def ObjCInertUnsafeUnretained : TypeAttr {
1652   let Spellings = [Keyword<"__unsafe_unretained">];
1653   let Documentation = [Undocumented];
1654 }
1655
1656 def ObjCKindOf : TypeAttr {
1657   let Spellings = [Keyword<"__kindof">];
1658   let Documentation = [Undocumented];
1659 }
1660
1661 def NoEscape : Attr {
1662   let Spellings = [Clang<"noescape">];
1663   let Subjects = SubjectList<[ParmVar]>;
1664   let Documentation = [NoEscapeDocs];
1665 }
1666
1667 def AssumeAligned : InheritableAttr {
1668   let Spellings = [GCC<"assume_aligned">];
1669   let Subjects = SubjectList<[ObjCMethod, Function]>;
1670   let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>];
1671   let Documentation = [AssumeAlignedDocs];
1672 }
1673
1674 def AllocAlign : InheritableAttr {
1675   let Spellings = [GCC<"alloc_align">];
1676   let Subjects = SubjectList<[HasFunctionProto]>;
1677   let Args = [ParamIdxArgument<"ParamIndex">];
1678   let Documentation = [AllocAlignDocs];
1679 }
1680
1681 def NoReturn : InheritableAttr {
1682   let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
1683   // FIXME: Does GCC allow this on the function instead?
1684   let Documentation = [Undocumented];
1685 }
1686
1687 def NoInstrumentFunction : InheritableAttr {
1688   let Spellings = [GCC<"no_instrument_function">];
1689   let Subjects = SubjectList<[Function]>;
1690   let Documentation = [Undocumented];
1691 }
1692
1693 def NotTailCalled : InheritableAttr {
1694   let Spellings = [Clang<"not_tail_called">];
1695   let Subjects = SubjectList<[Function]>;
1696   let Documentation = [NotTailCalledDocs];
1697 }
1698
1699 def NoStackProtector : InheritableAttr {
1700   let Spellings = [Clang<"no_stack_protector">];
1701   let Subjects = SubjectList<[Function]>;
1702   let Documentation = [NoStackProtectorDocs];
1703 }
1704
1705 def NoThrow : InheritableAttr {
1706   let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
1707   let Subjects = SubjectList<[FunctionLike]>;
1708   let Documentation = [NoThrowDocs];
1709 }
1710
1711 def NvWeak : IgnoredAttr {
1712   // No Declspec spelling of this attribute; the CUDA headers use
1713   // __attribute__((nv_weak)) unconditionally. Does not receive an [[]]
1714   // spelling because it is a CUDA attribute.
1715   let Spellings = [GNU<"nv_weak">];
1716   let LangOpts = [CUDA];
1717 }
1718
1719 def ObjCBridge : InheritableAttr {
1720   let Spellings = [Clang<"objc_bridge">];
1721   let Subjects = SubjectList<[Record, TypedefName], ErrorDiag>;
1722   let Args = [IdentifierArgument<"BridgedType">];
1723   let Documentation = [Undocumented];
1724 }
1725
1726 def ObjCBridgeMutable : InheritableAttr {
1727   let Spellings = [Clang<"objc_bridge_mutable">];
1728   let Subjects = SubjectList<[Record], ErrorDiag>;
1729   let Args = [IdentifierArgument<"BridgedType">];
1730   let Documentation = [Undocumented];
1731 }
1732
1733 def ObjCBridgeRelated : InheritableAttr {
1734   let Spellings = [Clang<"objc_bridge_related">];
1735   let Subjects = SubjectList<[Record], ErrorDiag>;
1736   let Args = [IdentifierArgument<"RelatedClass">,
1737           IdentifierArgument<"ClassMethod">,
1738           IdentifierArgument<"InstanceMethod">];
1739   let HasCustomParsing = 1;
1740   let Documentation = [Undocumented];
1741 }
1742
1743 def NSReturnsRetained : DeclOrTypeAttr {
1744   let Spellings = [Clang<"ns_returns_retained">];
1745 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1746   let Documentation = [RetainBehaviorDocs];
1747 }
1748
1749 def NSReturnsNotRetained : InheritableAttr {
1750   let Spellings = [Clang<"ns_returns_not_retained">];
1751 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1752   let Documentation = [RetainBehaviorDocs];
1753 }
1754
1755 def NSReturnsAutoreleased : InheritableAttr {
1756   let Spellings = [Clang<"ns_returns_autoreleased">];
1757 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1758   let Documentation = [RetainBehaviorDocs];
1759 }
1760
1761 def NSConsumesSelf : InheritableAttr {
1762   let Spellings = [Clang<"ns_consumes_self">];
1763   let Subjects = SubjectList<[ObjCMethod]>;
1764   let Documentation = [RetainBehaviorDocs];
1765 }
1766
1767 def NSConsumed : InheritableParamAttr {
1768   let Spellings = [Clang<"ns_consumed">];
1769   let Subjects = SubjectList<[ParmVar]>;
1770   let Documentation = [RetainBehaviorDocs];
1771 }
1772
1773 def ObjCException : InheritableAttr {
1774   let Spellings = [Clang<"objc_exception">];
1775   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1776   let Documentation = [Undocumented];
1777 }
1778
1779 def ObjCMethodFamily : InheritableAttr {
1780   let Spellings = [Clang<"objc_method_family">];
1781   let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1782   let Args = [EnumArgument<"Family", "FamilyKind",
1783                ["none", "alloc", "copy", "init", "mutableCopy", "new"],
1784                ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
1785                 "OMF_mutableCopy", "OMF_new"]>];
1786   let Documentation = [ObjCMethodFamilyDocs];
1787 }
1788
1789 def ObjCNSObject : InheritableAttr {
1790   let Spellings = [Clang<"NSObject">];
1791   let Documentation = [Undocumented];
1792 }
1793
1794 def ObjCIndependentClass : InheritableAttr {
1795   let Spellings = [Clang<"objc_independent_class">];
1796   let Documentation = [Undocumented];
1797 }
1798
1799 def ObjCPreciseLifetime : InheritableAttr {
1800   let Spellings = [Clang<"objc_precise_lifetime">];
1801   let Subjects = SubjectList<[Var], ErrorDiag>;
1802   let Documentation = [Undocumented];
1803 }
1804
1805 def ObjCReturnsInnerPointer : InheritableAttr {
1806   let Spellings = [Clang<"objc_returns_inner_pointer">];
1807   let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
1808   let Documentation = [Undocumented];
1809 }
1810
1811 def ObjCRequiresSuper : InheritableAttr {
1812   let Spellings = [Clang<"objc_requires_super">];
1813   let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1814   let Documentation = [ObjCRequiresSuperDocs];
1815 }
1816
1817 def ObjCRootClass : InheritableAttr {
1818   let Spellings = [Clang<"objc_root_class">];
1819   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1820   let Documentation = [Undocumented];
1821 }
1822
1823 def ObjCNonLazyClass : Attr {
1824   let Spellings = [Clang<"objc_nonlazy_class">];
1825   let Subjects = SubjectList<[ObjCInterface, ObjCImpl], ErrorDiag>;
1826   let LangOpts = [ObjC];
1827   let Documentation = [ObjCNonLazyClassDocs];
1828 }
1829
1830 def ObjCSubclassingRestricted : InheritableAttr {
1831   let Spellings = [Clang<"objc_subclassing_restricted">];
1832   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1833   let Documentation = [ObjCSubclassingRestrictedDocs];
1834 }
1835
1836 def ObjCExplicitProtocolImpl : InheritableAttr {
1837   let Spellings = [Clang<"objc_protocol_requires_explicit_implementation">];
1838   let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
1839   let Documentation = [Undocumented];
1840 }
1841
1842 def ObjCDesignatedInitializer : Attr {
1843   let Spellings = [Clang<"objc_designated_initializer">];
1844   let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1845   let Documentation = [Undocumented];
1846 }
1847
1848 def ObjCRuntimeName : Attr {
1849   let Spellings = [Clang<"objc_runtime_name">];
1850   let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
1851   let Args = [StringArgument<"MetadataName">];
1852   let Documentation = [ObjCRuntimeNameDocs];
1853 }
1854
1855 def ObjCRuntimeVisible : Attr {
1856   let Spellings = [Clang<"objc_runtime_visible">];
1857   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1858   let Documentation = [ObjCRuntimeVisibleDocs];
1859 }
1860
1861 def ObjCClassStub : Attr {
1862   let Spellings = [Clang<"objc_class_stub">];
1863   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1864   let Documentation = [ObjCClassStubDocs];
1865   let LangOpts = [ObjCNonFragileRuntime];
1866 }
1867
1868 def ObjCBoxable : Attr {
1869   let Spellings = [Clang<"objc_boxable">];
1870   let Subjects = SubjectList<[Record], ErrorDiag>;
1871   let Documentation = [ObjCBoxableDocs];
1872 }
1873
1874 def OptimizeNone : InheritableAttr {
1875   let Spellings = [Clang<"optnone">];
1876   let Subjects = SubjectList<[Function, ObjCMethod]>;
1877   let Documentation = [OptnoneDocs];
1878 }
1879
1880 def Overloadable : Attr {
1881   let Spellings = [Clang<"overloadable">];
1882   let Subjects = SubjectList<[Function], ErrorDiag>;
1883   let Documentation = [OverloadableDocs];
1884 }
1885
1886 def Override : InheritableAttr {
1887   let Spellings = [Keyword<"override">];
1888   let SemaHandler = 0;
1889   let Documentation = [Undocumented];
1890 }
1891
1892 def Ownership : InheritableAttr {
1893   let Spellings = [Clang<"ownership_holds">, Clang<"ownership_returns">,
1894                    Clang<"ownership_takes">];
1895   let Accessors = [Accessor<"isHolds", [Clang<"ownership_holds">]>,
1896                    Accessor<"isReturns", [Clang<"ownership_returns">]>,
1897                    Accessor<"isTakes", [Clang<"ownership_takes">]>];
1898   let AdditionalMembers = [{
1899     enum OwnershipKind { Holds, Returns, Takes };
1900     OwnershipKind getOwnKind() const {
1901       return isHolds() ? Holds :
1902              isTakes() ? Takes :
1903              Returns;
1904     }
1905   }];
1906   let Args = [IdentifierArgument<"Module">,
1907               VariadicParamIdxArgument<"Args">];
1908   let Subjects = SubjectList<[HasFunctionProto]>;
1909   let Documentation = [Undocumented];
1910 }
1911
1912 def Packed : InheritableAttr {
1913   let Spellings = [GCC<"packed">];
1914 //  let Subjects = [Tag, Field];
1915   let Documentation = [Undocumented];
1916 }
1917
1918 def IntelOclBicc : DeclOrTypeAttr {
1919   let Spellings = [Clang<"intel_ocl_bicc", 0>];
1920 //  let Subjects = [Function, ObjCMethod];
1921   let Documentation = [Undocumented];
1922 }
1923
1924 def Pcs : DeclOrTypeAttr {
1925   let Spellings = [GCC<"pcs">];
1926   let Args = [EnumArgument<"PCS", "PCSType",
1927                            ["aapcs", "aapcs-vfp"],
1928                            ["AAPCS", "AAPCS_VFP"]>];
1929 //  let Subjects = [Function, ObjCMethod];
1930   let Documentation = [PcsDocs];
1931 }
1932
1933 def AArch64VectorPcs: DeclOrTypeAttr {
1934   let Spellings = [Clang<"aarch64_vector_pcs">];
1935   let Documentation = [AArch64VectorPcsDocs];
1936 }
1937
1938 def Pure : InheritableAttr {
1939   let Spellings = [GCC<"pure">];
1940   let Documentation = [Undocumented];
1941 }
1942
1943 def Regparm : TypeAttr {
1944   let Spellings = [GCC<"regparm">];
1945   let Args = [UnsignedArgument<"NumParams">];
1946   let Documentation = [RegparmDocs];
1947   // Represented as part of the enclosing function type.
1948   let ASTNode = 0;
1949 }
1950
1951 def NoDeref : TypeAttr {
1952   let Spellings = [Clang<"noderef">];
1953   let Documentation = [NoDerefDocs];
1954 }
1955
1956 def ReqdWorkGroupSize : InheritableAttr {
1957   // Does not have a [[]] spelling because it is an OpenCL-related attribute.
1958   let Spellings = [GNU<"reqd_work_group_size">];
1959   let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
1960               UnsignedArgument<"ZDim">];
1961   let Subjects = SubjectList<[Function], ErrorDiag>;
1962   let Documentation = [Undocumented];
1963 }
1964
1965 def WorkGroupSizeHint :  InheritableAttr {
1966   // Does not have a [[]] spelling because it is an OpenCL-related attribute.
1967   let Spellings = [GNU<"work_group_size_hint">];
1968   let Args = [UnsignedArgument<"XDim">,
1969               UnsignedArgument<"YDim">,
1970               UnsignedArgument<"ZDim">];
1971   let Subjects = SubjectList<[Function], ErrorDiag>;
1972   let Documentation = [Undocumented];
1973 }
1974
1975 def InitPriority : InheritableAttr {
1976   let Spellings = [GCC<"init_priority">];
1977   let Args = [UnsignedArgument<"Priority">];
1978   let Subjects = SubjectList<[Var], ErrorDiag>;
1979   let Documentation = [Undocumented];
1980 }
1981
1982 def Section : InheritableAttr {
1983   let Spellings = [GCC<"section">, Declspec<"allocate">];
1984   let Args = [StringArgument<"Name">];
1985   let Subjects =
1986       SubjectList<[ Function, GlobalVar, ObjCMethod, ObjCProperty ], ErrorDiag>;
1987   let Documentation = [SectionDocs];
1988 }
1989
1990 // This is used for `__declspec(code_seg("segname"))`, but not for
1991 // `#pragma code_seg("segname")`.
1992 def CodeSeg : InheritableAttr {
1993   let Spellings = [Declspec<"code_seg">];
1994   let Args = [StringArgument<"Name">];
1995   let Subjects = SubjectList<[Function, CXXRecord], ErrorDiag>;
1996   let Documentation = [CodeSegDocs];
1997 }
1998
1999 def PragmaClangBSSSection : InheritableAttr {
2000   // This attribute has no spellings as it is only ever created implicitly.
2001   let Spellings = [];
2002   let Args = [StringArgument<"Name">];
2003   let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
2004   let Documentation = [Undocumented];
2005 }
2006
2007 def PragmaClangDataSection : InheritableAttr {
2008   // This attribute has no spellings as it is only ever created implicitly.
2009   let Spellings = [];
2010   let Args = [StringArgument<"Name">];
2011   let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
2012   let Documentation = [Undocumented];
2013 }
2014
2015 def PragmaClangRodataSection : InheritableAttr {
2016   // This attribute has no spellings as it is only ever created implicitly.
2017   let Spellings = [];
2018   let Args = [StringArgument<"Name">];
2019   let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
2020   let Documentation = [Undocumented];
2021 }
2022
2023 def PragmaClangRelroSection : InheritableAttr {
2024   // This attribute has no spellings as it is only ever created implicitly.
2025   let Spellings = [];
2026   let Args = [StringArgument<"Name">];
2027   let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
2028   let Documentation = [Undocumented];
2029 }
2030
2031 def PragmaClangTextSection : InheritableAttr {
2032   // This attribute has no spellings as it is only ever created implicitly.
2033   let Spellings = [];
2034   let Args = [StringArgument<"Name">];
2035   let Subjects = SubjectList<[Function], ErrorDiag>;
2036   let Documentation = [Undocumented];
2037 }
2038
2039 def Sentinel : InheritableAttr {
2040   let Spellings = [GCC<"sentinel">];
2041   let Args = [DefaultIntArgument<"Sentinel", 0>,
2042               DefaultIntArgument<"NullPos", 0>];
2043 //  let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
2044   let Documentation = [Undocumented];
2045 }
2046
2047 def StdCall : DeclOrTypeAttr {
2048   let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
2049 //  let Subjects = [Function, ObjCMethod];
2050   let Documentation = [StdCallDocs];
2051 }
2052
2053 def SwiftCall : DeclOrTypeAttr {
2054   let Spellings = [Clang<"swiftcall">];
2055 //  let Subjects = SubjectList<[Function]>;
2056   let Documentation = [SwiftCallDocs];
2057 }
2058
2059 def SwiftContext : ParameterABIAttr {
2060   let Spellings = [Clang<"swift_context">];
2061   let Documentation = [SwiftContextDocs];
2062 }
2063
2064 def SwiftErrorResult : ParameterABIAttr {
2065   let Spellings = [Clang<"swift_error_result">];
2066   let Documentation = [SwiftErrorResultDocs];
2067 }
2068
2069 def SwiftIndirectResult : ParameterABIAttr {
2070   let Spellings = [Clang<"swift_indirect_result">];
2071   let Documentation = [SwiftIndirectResultDocs];
2072 }
2073
2074 def Suppress : StmtAttr {
2075   let Spellings = [CXX11<"gsl", "suppress">];
2076   let Args = [VariadicStringArgument<"DiagnosticIdentifiers">];
2077   let Documentation = [SuppressDocs];
2078 }
2079
2080 def SysVABI : DeclOrTypeAttr {
2081   let Spellings = [GCC<"sysv_abi">];
2082 //  let Subjects = [Function, ObjCMethod];
2083   let Documentation = [Undocumented];
2084 }
2085
2086 def ThisCall : DeclOrTypeAttr {
2087   let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
2088                    Keyword<"_thiscall">];
2089 //  let Subjects = [Function, ObjCMethod];
2090   let Documentation = [ThisCallDocs];
2091 }
2092
2093 def VectorCall : DeclOrTypeAttr {
2094   let Spellings = [Clang<"vectorcall">, Keyword<"__vectorcall">,
2095                    Keyword<"_vectorcall">];
2096 //  let Subjects = [Function, ObjCMethod];
2097   let Documentation = [VectorCallDocs];
2098 }
2099
2100 def Pascal : DeclOrTypeAttr {
2101   let Spellings = [Clang<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
2102 //  let Subjects = [Function, ObjCMethod];
2103   let Documentation = [Undocumented];
2104 }
2105
2106 def PreserveMost : DeclOrTypeAttr {
2107   let Spellings = [Clang<"preserve_most">];
2108   let Documentation = [PreserveMostDocs];
2109 }
2110
2111 def PreserveAll : DeclOrTypeAttr {
2112   let Spellings = [Clang<"preserve_all">];
2113   let Documentation = [PreserveAllDocs];
2114 }
2115
2116 def Target : InheritableAttr {
2117   let Spellings = [GCC<"target">];
2118   let Args = [StringArgument<"featuresStr">];
2119   let Subjects = SubjectList<[Function], ErrorDiag>;
2120   let Documentation = [TargetDocs];
2121   let AdditionalMembers = [{
2122     struct ParsedTargetAttr {
2123       std::vector<std::string> Features;
2124       StringRef Architecture;
2125       bool DuplicateArchitecture = false;
2126       bool operator ==(const ParsedTargetAttr &Other) const {
2127         return DuplicateArchitecture == Other.DuplicateArchitecture &&
2128                Architecture == Other.Architecture && Features == Other.Features;
2129       }
2130     };
2131     ParsedTargetAttr parse() const {
2132       return parse(getFeaturesStr());
2133     }
2134
2135     StringRef getArchitecture() const {
2136       StringRef Features = getFeaturesStr();
2137       if (Features == "default") return {};
2138
2139       SmallVector<StringRef, 1> AttrFeatures;
2140       Features.split(AttrFeatures, ",");
2141
2142       for (auto &Feature : AttrFeatures) {
2143         Feature = Feature.trim();
2144         if (Feature.startswith("arch="))
2145           return Feature.drop_front(sizeof("arch=") - 1);
2146       }
2147       return "";
2148     }
2149
2150     // Gets the list of features as simple string-refs with no +/- or 'no-'.
2151     // Only adds the items to 'Out' that are additions.
2152     void getAddedFeatures(llvm::SmallVectorImpl<StringRef> &Out) const {
2153       StringRef Features = getFeaturesStr();
2154       if (Features == "default") return;
2155
2156       SmallVector<StringRef, 1> AttrFeatures;
2157       Features.split(AttrFeatures, ",");
2158
2159       for (auto &Feature : AttrFeatures) {
2160         Feature = Feature.trim();
2161
2162         if (!Feature.startswith("no-") && !Feature.startswith("arch=") &&
2163             !Feature.startswith("fpmath=") && !Feature.startswith("tune="))
2164           Out.push_back(Feature);
2165       }
2166     }
2167
2168     template<class Compare>
2169     ParsedTargetAttr parse(Compare cmp) const {
2170       ParsedTargetAttr Attrs = parse();
2171       llvm::sort(std::begin(Attrs.Features), std::end(Attrs.Features), cmp);
2172       return Attrs;
2173     }
2174
2175     bool isDefaultVersion() const { return getFeaturesStr() == "default"; }
2176
2177     static ParsedTargetAttr parse(StringRef Features) {
2178       ParsedTargetAttr Ret;
2179       if (Features == "default") return Ret;
2180       SmallVector<StringRef, 1> AttrFeatures;
2181       Features.split(AttrFeatures, ",");
2182
2183       // Grab the various features and prepend a "+" to turn on the feature to
2184       // the backend and add them to our existing set of features.
2185       for (auto &Feature : AttrFeatures) {
2186         // Go ahead and trim whitespace rather than either erroring or
2187         // accepting it weirdly.
2188         Feature = Feature.trim();
2189
2190         // We don't support cpu tuning this way currently.
2191         // TODO: Support the fpmath option. It will require checking
2192         // overall feature validity for the function with the rest of the
2193         // attributes on the function.
2194         if (Feature.startswith("fpmath=") || Feature.startswith("tune="))
2195           continue;
2196
2197         // While we're here iterating check for a different target cpu.
2198         if (Feature.startswith("arch=")) {
2199           if (!Ret.Architecture.empty())
2200             Ret.DuplicateArchitecture = true;
2201           else
2202             Ret.Architecture = Feature.split("=").second.trim();
2203         } else if (Feature.startswith("no-"))
2204           Ret.Features.push_back("-" + Feature.split("-").second.str());
2205         else
2206           Ret.Features.push_back("+" + Feature.str());
2207       }
2208       return Ret;
2209     }
2210   }];
2211 }
2212
2213 def MinVectorWidth : InheritableAttr {
2214   let Spellings = [Clang<"min_vector_width">];
2215   let Args = [UnsignedArgument<"VectorWidth">];
2216   let Subjects = SubjectList<[Function], ErrorDiag>;
2217   let Documentation = [MinVectorWidthDocs];
2218 }
2219
2220 def TransparentUnion : InheritableAttr {
2221   let Spellings = [GCC<"transparent_union">];
2222 //  let Subjects = SubjectList<[Record, TypedefName]>;
2223   let Documentation = [TransparentUnionDocs];
2224   let LangOpts = [COnly];
2225 }
2226
2227 def Unavailable : InheritableAttr {
2228   let Spellings = [Clang<"unavailable">];
2229   let Args = [StringArgument<"Message", 1>,
2230               EnumArgument<"ImplicitReason", "ImplicitReason",
2231                 ["", "", "", ""],
2232                 ["IR_None",
2233                  "IR_ARCForbiddenType",
2234                  "IR_ForbiddenWeak",
2235                  "IR_ARCForbiddenConversion",
2236                  "IR_ARCInitReturnsUnrelated",
2237                  "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>];
2238   let Documentation = [Undocumented];
2239 }
2240
2241 def DiagnoseIf : InheritableAttr {
2242   // Does not have a [[]] spelling because this attribute requires the ability
2243   // to parse function arguments but the attribute is not written in the type
2244   // position.
2245   let Spellings = [GNU<"diagnose_if">];
2246   let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;
2247   let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
2248               EnumArgument<"DiagnosticType",
2249                            "DiagnosticType",
2250                            ["error", "warning"],
2251                            ["DT_Error", "DT_Warning"]>,
2252               BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
2253               NamedArgument<"Parent", 0, /*fake*/ 1>];
2254   let InheritEvenIfAlreadyPresent = 1;
2255   let LateParsed = 1;
2256   let AdditionalMembers = [{
2257     bool isError() const { return diagnosticType == DT_Error; }
2258     bool isWarning() const { return diagnosticType == DT_Warning; }
2259   }];
2260   let TemplateDependent = 1;
2261   let Documentation = [DiagnoseIfDocs];
2262 }
2263
2264 def ArcWeakrefUnavailable : InheritableAttr {
2265   let Spellings = [Clang<"objc_arc_weak_reference_unavailable">];
2266   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
2267   let Documentation = [Undocumented];
2268 }
2269
2270 def ObjCGC : TypeAttr {
2271   let Spellings = [Clang<"objc_gc">];
2272   let Args = [IdentifierArgument<"Kind">];
2273   let Documentation = [Undocumented];
2274 }
2275
2276 def ObjCOwnership : DeclOrTypeAttr {
2277   let Spellings = [Clang<"objc_ownership">];
2278   let Args = [IdentifierArgument<"Kind">];
2279   let Documentation = [Undocumented];
2280 }
2281
2282 def ObjCRequiresPropertyDefs : InheritableAttr {
2283   let Spellings = [Clang<"objc_requires_property_definitions">];
2284   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
2285   let Documentation = [Undocumented];
2286 }
2287
2288 def Unused : InheritableAttr {
2289   let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
2290                    C2x<"", "maybe_unused">];
2291   let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
2292                               Field, ObjCMethod, FunctionLike]>;
2293   let Documentation = [WarnMaybeUnusedDocs];
2294 }
2295
2296 def Used : InheritableAttr {
2297   let Spellings = [GCC<"used">];
2298   let Subjects = SubjectList<[NonLocalVar, Function, ObjCMethod]>;
2299   let Documentation = [Undocumented];
2300 }
2301
2302 def Uuid : InheritableAttr {
2303   let Spellings = [Declspec<"uuid">, Microsoft<"uuid">];
2304   let Args = [StringArgument<"Guid">];
2305   let Subjects = SubjectList<[Record, Enum]>;
2306   // FIXME: Allow expressing logical AND for LangOpts. Our condition should be:
2307   // CPlusPlus && (MicrosoftExt || Borland)
2308   let LangOpts = [MicrosoftExt, Borland];
2309   let Documentation = [Undocumented];
2310 }
2311
2312 def VectorSize : TypeAttr {
2313   let Spellings = [GCC<"vector_size">];
2314   let Args = [ExprArgument<"NumBytes">];
2315   let Documentation = [Undocumented];
2316   // Represented as VectorType instead.
2317   let ASTNode = 0;
2318 }
2319
2320 def VecTypeHint : InheritableAttr {
2321   // Does not have a [[]] spelling because it is an OpenCL-related attribute.
2322   let Spellings = [GNU<"vec_type_hint">];
2323   let Args = [TypeArgument<"TypeHint">];
2324   let Subjects = SubjectList<[Function], ErrorDiag>;
2325   let Documentation = [Undocumented];
2326 }
2327
2328 def Visibility : InheritableAttr {
2329   let Clone = 0;
2330   let Spellings = [GCC<"visibility">];
2331   let Args = [EnumArgument<"Visibility", "VisibilityType",
2332                            ["default", "hidden", "internal", "protected"],
2333                            ["Default", "Hidden", "Hidden", "Protected"]>];
2334   let MeaningfulToClassTemplateDefinition = 1;
2335   let Documentation = [Undocumented];
2336 }
2337
2338 def TypeVisibility : InheritableAttr {
2339   let Clone = 0;
2340   let Spellings = [Clang<"type_visibility">];
2341   let Args = [EnumArgument<"Visibility", "VisibilityType",
2342                            ["default", "hidden", "internal", "protected"],
2343                            ["Default", "Hidden", "Hidden", "Protected"]>];
2344 //  let Subjects = [Tag, ObjCInterface, Namespace];
2345   let Documentation = [Undocumented];
2346 }
2347
2348 def VecReturn : InheritableAttr {
2349   // This attribute does not have a C [[]] spelling because it only appertains
2350   // to C++ struct/class/union.
2351   // FIXME: should this attribute have a CPlusPlus language option?
2352   let Spellings = [Clang<"vecreturn", 0>];
2353   let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
2354   let Documentation = [Undocumented];
2355 }
2356
2357 def WarnUnused : InheritableAttr {
2358   let Spellings = [GCC<"warn_unused">];
2359   let Subjects = SubjectList<[Record]>;
2360   let Documentation = [Undocumented];
2361 }
2362
2363 def WarnUnusedResult : InheritableAttr {
2364   let Spellings = [CXX11<"", "nodiscard", 201907>, C2x<"", "nodiscard">,
2365                    CXX11<"clang", "warn_unused_result">,
2366                    GCC<"warn_unused_result">];
2367   let Subjects = SubjectList<[ObjCMethod, Enum, Record, FunctionLike]>;
2368   let Args = [StringArgument<"Message", 1>];
2369   let Documentation = [WarnUnusedResultsDocs];
2370   let AdditionalMembers = [{
2371     // Check whether this the C++11 nodiscard version, even in non C++11
2372     // spellings.
2373     bool IsCXX11NoDiscard() const {
2374       return this->getSemanticSpelling() == CXX11_nodiscard;
2375     }
2376   }];
2377 }
2378
2379 def Weak : InheritableAttr {
2380   let Spellings = [GCC<"weak">];
2381   let Subjects = SubjectList<[Var, Function, CXXRecord]>;
2382   let Documentation = [Undocumented];
2383 }
2384
2385 def WeakImport : InheritableAttr {
2386   let Spellings = [Clang<"weak_import">];
2387   let Documentation = [Undocumented];
2388 }
2389
2390 def WeakRef : InheritableAttr {
2391   let Spellings = [GCC<"weakref">];
2392   // A WeakRef that has an argument is treated as being an AliasAttr
2393   let Args = [StringArgument<"Aliasee", 1>];
2394   let Subjects = SubjectList<[Var, Function], ErrorDiag>;
2395   let Documentation = [Undocumented];
2396 }
2397
2398 def LTOVisibilityPublic : InheritableAttr {
2399   let Spellings = [Clang<"lto_visibility_public">];
2400   let Subjects = SubjectList<[Record]>;
2401   let Documentation = [LTOVisibilityDocs];
2402 }
2403
2404 def AnyX86Interrupt : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
2405   // NOTE: If you add any additional spellings, ARMInterrupt's,
2406   // MSP430Interrupt's and MipsInterrupt's spellings must match.
2407   let Spellings = [GCC<"interrupt">];
2408   let Subjects = SubjectList<[HasFunctionProto]>;
2409   let ParseKind = "Interrupt";
2410   let HasCustomParsing = 1;
2411   let Documentation = [Undocumented];
2412 }
2413
2414 def AnyX86NoCallerSavedRegisters : InheritableAttr,
2415                                    TargetSpecificAttr<TargetAnyX86> {
2416   let Spellings = [GCC<"no_caller_saved_registers">];
2417   let Documentation = [AnyX86NoCallerSavedRegistersDocs];
2418 }
2419
2420 def AnyX86NoCfCheck : DeclOrTypeAttr, TargetSpecificAttr<TargetAnyX86>{
2421   let Spellings = [GCC<"nocf_check">];
2422   let Subjects = SubjectList<[FunctionLike]>;
2423   let Documentation = [AnyX86NoCfCheckDocs];
2424 }
2425
2426 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
2427   let Spellings = [GCC<"force_align_arg_pointer">];
2428   // Technically, this appertains to a FunctionDecl, but the target-specific
2429   // code silently allows anything function-like (such as typedefs or function
2430   // pointers), but does not apply the attribute to them.
2431   let Documentation = [X86ForceAlignArgPointerDocs];
2432 }
2433
2434 def NoSanitize : InheritableAttr {
2435   let Spellings = [Clang<"no_sanitize">];
2436   let Args = [VariadicStringArgument<"Sanitizers">];
2437   let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag>;
2438   let Documentation = [NoSanitizeDocs];
2439   let AdditionalMembers = [{
2440     SanitizerMask getMask() const {
2441       SanitizerMask Mask;
2442       for (auto SanitizerName : sanitizers()) {
2443         SanitizerMask ParsedMask =
2444             parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
2445         Mask |= expandSanitizerGroups(ParsedMask);
2446       }
2447       return Mask;
2448     }
2449   }];
2450 }
2451
2452 // Attributes to disable a specific sanitizer. No new sanitizers should be added
2453 // to this list; the no_sanitize attribute should be extended instead.
2454 def NoSanitizeSpecific : InheritableAttr {
2455   let Spellings = [GCC<"no_address_safety_analysis">,
2456                    GCC<"no_sanitize_address">,
2457                    GCC<"no_sanitize_thread">,
2458                    Clang<"no_sanitize_memory">];
2459   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
2460   let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
2461                        NoSanitizeMemoryDocs];
2462   let ASTNode = 0;
2463 }
2464
2465 def CFICanonicalJumpTable : InheritableAttr {
2466   let Spellings = [Clang<"cfi_canonical_jump_table">];
2467   let Subjects = SubjectList<[Function], ErrorDiag>;
2468   let Documentation = [CFICanonicalJumpTableDocs];
2469 }
2470
2471 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
2472 // Not all of these attributes will be given a [[]] spelling. The attributes
2473 // which require access to function parameter names cannot use the [[]] spelling
2474 // because they are not written in the type position. Some attributes are given
2475 // an updated captability-based name and the older name will only be supported
2476 // under the GNU-style spelling.
2477 def GuardedVar : InheritableAttr {
2478   let Spellings = [Clang<"guarded_var", 0>];
2479   let Subjects = SubjectList<[Field, SharedVar]>;
2480   let Documentation = [Undocumented];
2481 }
2482
2483 def PtGuardedVar : InheritableAttr {
2484   let Spellings = [Clang<"pt_guarded_var", 0>];
2485   let Subjects = SubjectList<[Field, SharedVar]>;
2486   let Documentation = [Undocumented];
2487 }
2488
2489 def Lockable : InheritableAttr {
2490   let Spellings = [GNU<"lockable">];
2491   let Subjects = SubjectList<[Record]>;
2492   let Documentation = [Undocumented];
2493   let ASTNode = 0;  // Replaced by Capability
2494 }
2495
2496 def ScopedLockable : InheritableAttr {
2497   let Spellings = [Clang<"scoped_lockable", 0>];
2498   let Subjects = SubjectList<[Record]>;
2499   let Documentation = [Undocumented];
2500 }
2501
2502 def Capability : InheritableAttr {
2503   let Spellings = [Clang<"capability", 0>, Clang<"shared_capability", 0>];
2504   let Subjects = SubjectList<[Record, TypedefName], ErrorDiag>;
2505   let Args = [StringArgument<"Name">];
2506   let Accessors = [Accessor<"isShared",
2507                     [Clang<"shared_capability", 0>]>];
2508   let Documentation = [Undocumented];
2509   let AdditionalMembers = [{
2510     bool isMutex() const { return getName().equals_lower("mutex"); }
2511     bool isRole() const { return getName().equals_lower("role"); }
2512   }];
2513 }
2514
2515 def AssertCapability : InheritableAttr {
2516   let Spellings = [Clang<"assert_capability", 0>,
2517                    Clang<"assert_shared_capability", 0>];
2518   let Subjects = SubjectList<[Function]>;
2519   let LateParsed = 1;
2520   let TemplateDependent = 1;
2521   let ParseArgumentsAsUnevaluated = 1;
2522   let InheritEvenIfAlreadyPresent = 1;
2523   let Args = [VariadicExprArgument<"Args">];
2524   let Accessors = [Accessor<"isShared",
2525                     [Clang<"assert_shared_capability", 0>]>];
2526   let Documentation = [AssertCapabilityDocs];
2527 }
2528
2529 def AcquireCapability : InheritableAttr {
2530   let Spellings = [Clang<"acquire_capability", 0>,
2531                    Clang<"acquire_shared_capability", 0>,
2532                    GNU<"exclusive_lock_function">,
2533                    GNU<"shared_lock_function">];
2534   let Subjects = SubjectList<[Function]>;
2535   let LateParsed = 1;
2536   let TemplateDependent = 1;
2537   let ParseArgumentsAsUnevaluated = 1;
2538   let InheritEvenIfAlreadyPresent = 1;
2539   let Args = [VariadicExprArgument<"Args">];
2540   let Accessors = [Accessor<"isShared",
2541                     [Clang<"acquire_shared_capability", 0>,
2542                      GNU<"shared_lock_function">]>];
2543   let Documentation = [AcquireCapabilityDocs];
2544 }
2545
2546 def TryAcquireCapability : InheritableAttr {
2547   let Spellings = [Clang<"try_acquire_capability", 0>,
2548                    Clang<"try_acquire_shared_capability", 0>];
2549   let Subjects = SubjectList<[Function],
2550                              ErrorDiag>;
2551   let LateParsed = 1;
2552   let TemplateDependent = 1;
2553   let ParseArgumentsAsUnevaluated = 1;
2554   let InheritEvenIfAlreadyPresent = 1;
2555   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2556   let Accessors = [Accessor<"isShared",
2557                     [Clang<"try_acquire_shared_capability", 0>]>];
2558   let Documentation = [TryAcquireCapabilityDocs];
2559 }
2560
2561 def ReleaseCapability : InheritableAttr {
2562   let Spellings = [Clang<"release_capability", 0>,
2563                    Clang<"release_shared_capability", 0>,
2564                    Clang<"release_generic_capability", 0>,
2565                    Clang<"unlock_function", 0>];
2566   let Subjects = SubjectList<[Function]>;
2567   let LateParsed = 1;
2568   let TemplateDependent = 1;
2569   let ParseArgumentsAsUnevaluated = 1;
2570   let InheritEvenIfAlreadyPresent = 1;
2571   let Args = [VariadicExprArgument<"Args">];
2572   let Accessors = [Accessor<"isShared",
2573                     [Clang<"release_shared_capability", 0>]>,
2574                    Accessor<"isGeneric",
2575                      [Clang<"release_generic_capability", 0>,
2576                       Clang<"unlock_function", 0>]>];
2577   let Documentation = [ReleaseCapabilityDocs];
2578 }
2579
2580 def RequiresCapability : InheritableAttr {
2581   let Spellings = [Clang<"requires_capability", 0>,
2582                    Clang<"exclusive_locks_required", 0>,
2583                    Clang<"requires_shared_capability", 0>,
2584                    Clang<"shared_locks_required", 0>];
2585   let Args = [VariadicExprArgument<"Args">];
2586   let LateParsed = 1;
2587   let TemplateDependent = 1;
2588   let ParseArgumentsAsUnevaluated = 1;
2589   let InheritEvenIfAlreadyPresent = 1;
2590   let Subjects = SubjectList<[Function]>;
2591   let Accessors = [Accessor<"isShared", [Clang<"requires_shared_capability", 0>,
2592                                          Clang<"shared_locks_required", 0>]>];
2593   let Documentation = [Undocumented];
2594 }
2595
2596 def NoThreadSafetyAnalysis : InheritableAttr {
2597   let Spellings = [Clang<"no_thread_safety_analysis">];
2598   let Subjects = SubjectList<[Function]>;
2599   let Documentation = [Undocumented];
2600 }
2601
2602 def GuardedBy : InheritableAttr {
2603   let Spellings = [GNU<"guarded_by">];
2604   let Args = [ExprArgument<"Arg">];
2605   let LateParsed = 1;
2606   let TemplateDependent = 1;
2607   let ParseArgumentsAsUnevaluated = 1;
2608   let InheritEvenIfAlreadyPresent = 1;
2609   let Subjects = SubjectList<[Field, SharedVar]>;
2610   let Documentation = [Undocumented];
2611 }
2612
2613 def PtGuardedBy : InheritableAttr {
2614   let Spellings = [GNU<"pt_guarded_by">];
2615   let Args = [ExprArgument<"Arg">];
2616   let LateParsed = 1;
2617   let TemplateDependent = 1;
2618   let ParseArgumentsAsUnevaluated = 1;
2619   let InheritEvenIfAlreadyPresent = 1;
2620   let Subjects = SubjectList<[Field, SharedVar]>;
2621   let Documentation = [Undocumented];
2622 }
2623
2624 def AcquiredAfter : InheritableAttr {
2625   let Spellings = [GNU<"acquired_after">];
2626   let Args = [VariadicExprArgument<"Args">];
2627   let LateParsed = 1;
2628   let TemplateDependent = 1;
2629   let ParseArgumentsAsUnevaluated = 1;
2630   let InheritEvenIfAlreadyPresent = 1;
2631   let Subjects = SubjectList<[Field, SharedVar]>;
2632   let Documentation = [Undocumented];
2633 }
2634
2635 def AcquiredBefore : InheritableAttr {
2636   let Spellings = [GNU<"acquired_before">];
2637   let Args = [VariadicExprArgument<"Args">];
2638   let LateParsed = 1;
2639   let TemplateDependent = 1;
2640   let ParseArgumentsAsUnevaluated = 1;
2641   let InheritEvenIfAlreadyPresent = 1;
2642   let Subjects = SubjectList<[Field, SharedVar]>;
2643   let Documentation = [Undocumented];
2644 }
2645
2646 def AssertExclusiveLock : InheritableAttr {
2647   let Spellings = [GNU<"assert_exclusive_lock">];
2648   let Args = [VariadicExprArgument<"Args">];
2649   let LateParsed = 1;
2650   let TemplateDependent = 1;
2651   let ParseArgumentsAsUnevaluated = 1;
2652   let InheritEvenIfAlreadyPresent = 1;
2653   let Subjects = SubjectList<[Function]>;
2654   let Documentation = [Undocumented];
2655 }
2656
2657 def AssertSharedLock : InheritableAttr {
2658   let Spellings = [GNU<"assert_shared_lock">];
2659   let Args = [VariadicExprArgument<"Args">];
2660   let LateParsed = 1;
2661   let TemplateDependent = 1;
2662   let ParseArgumentsAsUnevaluated = 1;
2663   let InheritEvenIfAlreadyPresent = 1;
2664   let Subjects = SubjectList<[Function]>;
2665   let Documentation = [Undocumented];
2666 }
2667
2668 // The first argument is an integer or boolean value specifying the return value
2669 // of a successful lock acquisition.
2670 def ExclusiveTrylockFunction : InheritableAttr {
2671   let Spellings = [GNU<"exclusive_trylock_function">];
2672   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2673   let LateParsed = 1;
2674   let TemplateDependent = 1;
2675   let ParseArgumentsAsUnevaluated = 1;
2676   let InheritEvenIfAlreadyPresent = 1;
2677   let Subjects = SubjectList<[Function]>;
2678   let Documentation = [Undocumented];
2679 }
2680
2681 // The first argument is an integer or boolean value specifying the return value
2682 // of a successful lock acquisition.
2683 def SharedTrylockFunction : InheritableAttr {
2684   let Spellings = [GNU<"shared_trylock_function">];
2685   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2686   let LateParsed = 1;
2687   let TemplateDependent = 1;
2688   let ParseArgumentsAsUnevaluated = 1;
2689   let InheritEvenIfAlreadyPresent = 1;
2690   let Subjects = SubjectList<[Function]>;
2691   let Documentation = [Undocumented];
2692 }
2693
2694 def LockReturned : InheritableAttr {
2695   let Spellings = [GNU<"lock_returned">];
2696   let Args = [ExprArgument<"Arg">];
2697   let LateParsed = 1;
2698   let TemplateDependent = 1;
2699   let ParseArgumentsAsUnevaluated = 1;
2700   let Subjects = SubjectList<[Function]>;
2701   let Documentation = [Undocumented];
2702 }
2703
2704 def LocksExcluded : InheritableAttr {
2705   let Spellings = [GNU<"locks_excluded">];
2706   let Args = [VariadicExprArgument<"Args">];
2707   let LateParsed = 1;
2708   let TemplateDependent = 1;
2709   let ParseArgumentsAsUnevaluated = 1;
2710   let InheritEvenIfAlreadyPresent = 1;
2711   let Subjects = SubjectList<[Function]>;
2712   let Documentation = [Undocumented];
2713 }
2714
2715 // C/C++ consumed attributes.
2716
2717 def Consumable : InheritableAttr {
2718   // This attribute does not have a C [[]] spelling because it only appertains
2719   // to C++ struct/class/union.
2720   // FIXME: should this attribute have a CPlusPlus language option?
2721   let Spellings = [Clang<"consumable", 0>];
2722   let Subjects = SubjectList<[CXXRecord]>;
2723   let Args = [EnumArgument<"DefaultState", "ConsumedState",
2724                            ["unknown", "consumed", "unconsumed"],
2725                            ["Unknown", "Consumed", "Unconsumed"]>];
2726   let Documentation = [ConsumableDocs];
2727 }
2728
2729 def ConsumableAutoCast : InheritableAttr {
2730   // This attribute does not have a C [[]] spelling because it only appertains
2731   // to C++ struct/class/union.
2732   // FIXME: should this attribute have a CPlusPlus language option?
2733   let Spellings = [Clang<"consumable_auto_cast_state", 0>];
2734   let Subjects = SubjectList<[CXXRecord]>;
2735   let Documentation = [Undocumented];
2736 }
2737
2738 def ConsumableSetOnRead : InheritableAttr {
2739   // This attribute does not have a C [[]] spelling because it only appertains
2740   // to C++ struct/class/union.
2741   // FIXME: should this attribute have a CPlusPlus language option?
2742   let Spellings = [Clang<"consumable_set_state_on_read", 0>];
2743   let Subjects = SubjectList<[CXXRecord]>;
2744   let Documentation = [Undocumented];
2745 }
2746
2747 def CallableWhen : InheritableAttr {
2748   // This attribute does not have a C [[]] spelling because it only appertains
2749   // to C++ function (but doesn't require it to be a member function).
2750   // FIXME: should this attribute have a CPlusPlus language option?
2751   let Spellings = [Clang<"callable_when", 0>];
2752   let Subjects = SubjectList<[CXXMethod]>;
2753   let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
2754                                    ["unknown", "consumed", "unconsumed"],
2755                                    ["Unknown", "Consumed", "Unconsumed"]>];
2756   let Documentation = [CallableWhenDocs];
2757 }
2758
2759 def ParamTypestate : InheritableAttr {
2760   // This attribute does not have a C [[]] spelling because it only appertains
2761   // to a parameter whose type is a consumable C++ class.
2762   // FIXME: should this attribute have a CPlusPlus language option?
2763   let Spellings = [Clang<"param_typestate", 0>];
2764   let Subjects = SubjectList<[ParmVar]>;
2765   let Args = [EnumArgument<"ParamState", "ConsumedState",
2766                            ["unknown", "consumed", "unconsumed"],
2767                            ["Unknown", "Consumed", "Unconsumed"]>];
2768   let Documentation = [ParamTypestateDocs];
2769 }
2770
2771 def ReturnTypestate : InheritableAttr {
2772   // This attribute does not have a C [[]] spelling because it only appertains
2773   // to a parameter or function return type that is a consumable C++ class.
2774   // FIXME: should this attribute have a CPlusPlus language option?
2775   let Spellings = [Clang<"return_typestate", 0>];
2776   let Subjects = SubjectList<[Function, ParmVar]>;
2777   let Args = [EnumArgument<"State", "ConsumedState",
2778                            ["unknown", "consumed", "unconsumed"],
2779                            ["Unknown", "Consumed", "Unconsumed"]>];
2780   let Documentation = [ReturnTypestateDocs];
2781 }
2782
2783 def SetTypestate : InheritableAttr {
2784   // This attribute does not have a C [[]] spelling because it only appertains
2785   // to C++ function (but doesn't require it to be a member function).
2786   // FIXME: should this attribute have a CPlusPlus language option?
2787   let Spellings = [Clang<"set_typestate", 0>];
2788   let Subjects = SubjectList<[CXXMethod]>;
2789   let Args = [EnumArgument<"NewState", "ConsumedState",
2790                            ["unknown", "consumed", "unconsumed"],
2791                            ["Unknown", "Consumed", "Unconsumed"]>];
2792   let Documentation = [SetTypestateDocs];
2793 }
2794
2795 def TestTypestate : InheritableAttr {
2796   // This attribute does not have a C [[]] spelling because it only appertains
2797   // to C++ function (but doesn't require it to be a member function).
2798   // FIXME: should this attribute have a CPlusPlus language option?
2799   let Spellings = [Clang<"test_typestate", 0>];
2800   let Subjects = SubjectList<[CXXMethod]>;
2801   let Args = [EnumArgument<"TestState", "ConsumedState",
2802                            ["consumed", "unconsumed"],
2803                            ["Consumed", "Unconsumed"]>];
2804   let Documentation = [TestTypestateDocs];
2805 }
2806
2807 // Type safety attributes for `void *' pointers and type tags.
2808
2809 def ArgumentWithTypeTag : InheritableAttr {
2810   let Spellings = [Clang<"argument_with_type_tag">,
2811                    Clang<"pointer_with_type_tag">];
2812   let Subjects = SubjectList<[HasFunctionProto], ErrorDiag>;
2813   let Args = [IdentifierArgument<"ArgumentKind">,
2814               ParamIdxArgument<"ArgumentIdx">,
2815               ParamIdxArgument<"TypeTagIdx">,
2816               BoolArgument<"IsPointer", /*opt*/0, /*fake*/1>];
2817   let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
2818 }
2819
2820 def TypeTagForDatatype : InheritableAttr {
2821   let Spellings = [Clang<"type_tag_for_datatype">];
2822   let Args = [IdentifierArgument<"ArgumentKind">,
2823               TypeArgument<"MatchingCType">,
2824               BoolArgument<"LayoutCompatible">,
2825               BoolArgument<"MustBeNull">];
2826 //  let Subjects = SubjectList<[Var], ErrorDiag>;
2827   let HasCustomParsing = 1;
2828   let Documentation = [TypeTagForDatatypeDocs];
2829 }
2830
2831 def Owner : InheritableAttr {
2832   let Spellings = [CXX11<"gsl", "Owner">];
2833   let Subjects = SubjectList<[Struct]>;
2834   let Args = [TypeArgument<"DerefType", /*opt=*/1>];
2835   let Documentation = [LifetimeOwnerDocs];
2836 }
2837
2838 def Pointer : InheritableAttr {
2839   let Spellings = [CXX11<"gsl", "Pointer">];
2840   let Subjects = SubjectList<[Struct]>;
2841   let Args = [TypeArgument<"DerefType", /*opt=*/1>];
2842   let Documentation = [LifetimePointerDocs];
2843 }
2844
2845 // Microsoft-related attributes
2846
2847 def MSNoVTable : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
2848   let Spellings = [Declspec<"novtable">];
2849   let Subjects = SubjectList<[CXXRecord]>;
2850   let Documentation = [MSNoVTableDocs];
2851 }
2852
2853 def : IgnoredAttr {
2854   let Spellings = [Declspec<"property">];
2855 }
2856
2857 def MSAllocator : InheritableAttr {
2858   let Spellings = [Declspec<"allocator">];
2859   let Subjects = SubjectList<[Function]>;
2860   let Documentation = [MSAllocatorDocs];
2861 }
2862
2863 def MSStruct : InheritableAttr {
2864   let Spellings = [GCC<"ms_struct">];
2865   let Subjects = SubjectList<[Record]>;
2866   let Documentation = [Undocumented];
2867 }
2868
2869 def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2870   let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
2871   let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2872   let Documentation = [DLLExportDocs];
2873 }
2874
2875 def DLLExportStaticLocal : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2876   // This attribute is used internally only when -fno-dllexport-inlines is
2877   // passed. This attribute is added to inline function of class having
2878   // dllexport attribute. And if the function has static local variables, this
2879   // attribute is used to whether the variables are exported or not. Also if
2880   // function has local static variables, the function is dllexported too.
2881   let Spellings = [];
2882   let Subjects = SubjectList<[Function]>;
2883   let Documentation = [Undocumented];
2884 }
2885
2886 def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2887   let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
2888   let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2889   let Documentation = [DLLImportDocs];
2890
2891
2892   let AdditionalMembers = [{
2893 private:
2894   bool PropagatedToBaseTemplate = false;
2895
2896 public:
2897   void setPropagatedToBaseTemplate() { PropagatedToBaseTemplate = true; }
2898   bool wasPropagatedToBaseTemplate() { return PropagatedToBaseTemplate; }
2899   }];
2900 }
2901
2902 def DLLImportStaticLocal : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2903   // This attribute is used internally only when -fno-dllexport-inlines is
2904   // passed. This attribute is added to inline function of class having
2905   // dllimport attribute. And if the function has static local variables, this
2906   // attribute is used to whether the variables are imported or not.
2907   let Spellings = [];
2908   let Subjects = SubjectList<[Function]>;
2909   let Documentation = [Undocumented];
2910 }
2911
2912 def SelectAny : InheritableAttr {
2913   let Spellings = [Declspec<"selectany">, GCC<"selectany">];
2914   let Documentation = [SelectAnyDocs];
2915 }
2916
2917 def Thread : Attr {
2918   let Spellings = [Declspec<"thread">];
2919   let LangOpts = [MicrosoftExt];
2920   let Documentation = [ThreadDocs];
2921   let Subjects = SubjectList<[Var]>;
2922 }
2923
2924 def Win64 : IgnoredAttr {
2925   let Spellings = [Keyword<"__w64">];
2926   let LangOpts = [MicrosoftExt];
2927 }
2928
2929 def Ptr32 : TypeAttr {
2930   let Spellings = [Keyword<"__ptr32">];
2931   let Documentation = [Undocumented];
2932 }
2933
2934 def Ptr64 : TypeAttr {
2935   let Spellings = [Keyword<"__ptr64">];
2936   let Documentation = [Undocumented];
2937 }
2938
2939 def SPtr : TypeAttr {
2940   let Spellings = [Keyword<"__sptr">];
2941   let Documentation = [Undocumented];
2942 }
2943
2944 def UPtr : TypeAttr {
2945   let Spellings = [Keyword<"__uptr">];
2946   let Documentation = [Undocumented];
2947 }
2948
2949 def MSInheritance : InheritableAttr {
2950   let LangOpts = [MicrosoftExt];
2951   let Args = [DefaultBoolArgument<"BestCase", /*default*/1, /*fake*/1>];
2952   let Spellings = [Keyword<"__single_inheritance">,
2953                    Keyword<"__multiple_inheritance">,
2954                    Keyword<"__virtual_inheritance">,
2955                    Keyword<"__unspecified_inheritance">];
2956   let AdditionalMembers = [{
2957   static bool hasVBPtrOffsetField(Spelling Inheritance) {
2958     return Inheritance == Keyword_unspecified_inheritance;
2959   }
2960
2961   // Only member pointers to functions need a this adjustment, since it can be
2962   // combined with the field offset for data pointers.
2963   static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
2964     return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
2965   }
2966
2967   static bool hasVBTableOffsetField(Spelling Inheritance) {
2968     return Inheritance >= Keyword_virtual_inheritance;
2969   }
2970
2971   static bool hasOnlyOneField(bool IsMemberFunction,
2972                               Spelling Inheritance) {
2973     if (IsMemberFunction)
2974       return Inheritance <= Keyword_single_inheritance;
2975     return Inheritance <= Keyword_multiple_inheritance;
2976   }
2977   }];
2978   let Documentation = [MSInheritanceDocs];
2979 }
2980
2981 def MSVtorDisp : InheritableAttr {
2982   // This attribute has no spellings as it is only ever created implicitly.
2983   let Spellings = [];
2984   let Args = [UnsignedArgument<"vdm">];
2985   let SemaHandler = 0;
2986
2987   let AdditionalMembers = [{
2988   enum Mode {
2989     Never,
2990     ForVBaseOverride,
2991     ForVFTable
2992   };
2993
2994   Mode getVtorDispMode() const { return Mode(vdm); }
2995   }];
2996   let Documentation = [Undocumented];
2997 }
2998
2999 def InitSeg : Attr {
3000   let Spellings = [Pragma<"", "init_seg">];
3001   let Args = [StringArgument<"Section">];
3002   let SemaHandler = 0;
3003   let Documentation = [InitSegDocs];
3004   let AdditionalMembers = [{
3005   void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
3006     OS << " (" << getSection() << ')';
3007   }
3008   }];
3009 }
3010
3011 def LoopHint : Attr {
3012   /// #pragma clang loop <option> directive
3013   /// vectorize: vectorizes loop operations if State == Enable.
3014   /// vectorize_width: vectorize loop operations with width 'Value'.
3015   /// interleave: interleave multiple loop iterations if State == Enable.
3016   /// interleave_count: interleaves 'Value' loop iterations.
3017   /// unroll: fully unroll loop if State == Enable.
3018   /// unroll_count: unrolls loop 'Value' times.
3019   /// unroll_and_jam: attempt to unroll and jam loop if State == Enable.
3020   /// unroll_and_jam_count: unroll and jams loop 'Value' times.
3021   /// distribute: attempt to distribute loop if State == Enable.
3022   /// pipeline: disable pipelining loop if State == Disable.
3023   /// pipeline_initiation_interval: create loop schedule with initiation interval equal to 'Value'.
3024
3025   /// #pragma unroll <argument> directive
3026   /// <no arg>: fully unrolls loop.
3027   /// boolean: fully unrolls loop if State == Enable.
3028   /// expression: unrolls loop 'Value' times.
3029
3030   let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">,
3031                    Pragma<"", "nounroll">, Pragma<"", "unroll_and_jam">,
3032                    Pragma<"", "nounroll_and_jam">];
3033
3034   /// State of the loop optimization specified by the spelling.
3035   let Args = [EnumArgument<"Option", "OptionType",
3036                           ["vectorize", "vectorize_width", "interleave", "interleave_count",
3037                            "unroll", "unroll_count", "unroll_and_jam", "unroll_and_jam_count",
3038                            "pipeline", "pipeline_initiation_interval", "distribute",
3039                            "vectorize_predicate"],
3040                           ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
3041                            "Unroll", "UnrollCount", "UnrollAndJam", "UnrollAndJamCount",
3042                            "PipelineDisabled", "PipelineInitiationInterval", "Distribute",
3043                            "VectorizePredicate"]>,
3044               EnumArgument<"State", "LoopHintState",
3045                            ["enable", "disable", "numeric", "assume_safety", "full"],
3046                            ["Enable", "Disable", "Numeric", "AssumeSafety", "Full"]>,
3047               ExprArgument<"Value">];
3048
3049   let AdditionalMembers = [{
3050   static const char *getOptionName(int Option) {
3051     switch(Option) {
3052     case Vectorize: return "vectorize";
3053     case VectorizeWidth: return "vectorize_width";
3054     case Interleave: return "interleave";
3055     case InterleaveCount: return "interleave_count";
3056     case Unroll: return "unroll";
3057     case UnrollCount: return "unroll_count";
3058     case UnrollAndJam: return "unroll_and_jam";
3059     case UnrollAndJamCount: return "unroll_and_jam_count";
3060     case PipelineDisabled: return "pipeline";
3061     case PipelineInitiationInterval: return "pipeline_initiation_interval";
3062     case Distribute: return "distribute";
3063     case VectorizePredicate: return "vectorize_predicate";
3064     }
3065     llvm_unreachable("Unhandled LoopHint option.");
3066   }
3067
3068   void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
3069     unsigned SpellingIndex = getAttributeSpellingListIndex();
3070     // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
3071     // "nounroll" is already emitted as the pragma name.
3072     if (SpellingIndex == Pragma_nounroll || SpellingIndex == Pragma_nounroll_and_jam)
3073       return;
3074     else if (SpellingIndex == Pragma_unroll || SpellingIndex == Pragma_unroll_and_jam) {
3075       OS << ' ' << getValueString(Policy);
3076       return;
3077     }
3078
3079     assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
3080     OS << ' ' << getOptionName(option) << getValueString(Policy);
3081   }
3082
3083   // Return a string containing the loop hint argument including the
3084   // enclosing parentheses.
3085   std::string getValueString(const PrintingPolicy &Policy) const {
3086     std::string ValueName;
3087     llvm::raw_string_ostream OS(ValueName);
3088     OS << "(";
3089     if (state == Numeric)
3090       value->printPretty(OS, nullptr, Policy);
3091     else if (state == Enable)
3092       OS << "enable";
3093     else if (state == Full)
3094       OS << "full";
3095     else if (state == AssumeSafety)
3096       OS << "assume_safety";
3097     else
3098       OS << "disable";
3099     OS << ")";
3100     return OS.str();
3101   }
3102
3103   // Return a string suitable for identifying this attribute in diagnostics.
3104   std::string getDiagnosticName(const PrintingPolicy &Policy) const {
3105     unsigned SpellingIndex = getAttributeSpellingListIndex();
3106     if (SpellingIndex == Pragma_nounroll)
3107       return "#pragma nounroll";
3108     else if (SpellingIndex == Pragma_unroll)
3109       return "#pragma unroll" + (option == UnrollCount ? getValueString(Policy) : "");
3110     else if (SpellingIndex == Pragma_nounroll_and_jam)
3111       return "#pragma nounroll_and_jam";
3112     else if (SpellingIndex == Pragma_unroll_and_jam)
3113       return "#pragma unroll_and_jam" +
3114         (option == UnrollAndJamCount ? getValueString(Policy) : "");
3115
3116     assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
3117     return getOptionName(option) + getValueString(Policy);
3118   }
3119   }];
3120
3121   let Documentation = [LoopHintDocs, UnrollHintDocs];
3122 }
3123
3124 def CapturedRecord : InheritableAttr {
3125   // This attribute has no spellings as it is only ever created implicitly.
3126   let Spellings = [];
3127   let SemaHandler = 0;
3128   let Documentation = [Undocumented];
3129 }
3130
3131 def OMPThreadPrivateDecl : InheritableAttr {
3132   // This attribute has no spellings as it is only ever created implicitly.
3133   let Spellings = [];
3134   let SemaHandler = 0;
3135   let Documentation = [Undocumented];
3136 }
3137
3138 def OMPCaptureNoInit : InheritableAttr {
3139   // This attribute has no spellings as it is only ever created implicitly.
3140   let Spellings = [];
3141   let SemaHandler = 0;
3142   let Documentation = [Undocumented];
3143 }
3144
3145 def OMPCaptureKind : Attr {
3146   // This attribute has no spellings as it is only ever created implicitly.
3147   let Spellings = [];
3148   let SemaHandler = 0;
3149   let Args = [UnsignedArgument<"CaptureKind">];
3150   let Documentation = [Undocumented];
3151 }
3152
3153 def OMPReferencedVar : Attr {
3154   // This attribute has no spellings as it is only ever created implicitly.
3155   let Spellings = [];
3156   let SemaHandler = 0;
3157   let Args = [ExprArgument<"Ref">];
3158   let Documentation = [Undocumented];
3159 }
3160
3161 def OMPDeclareSimdDecl : Attr {
3162   let Spellings = [Pragma<"omp", "declare simd">];
3163   let Subjects = SubjectList<[Function]>;
3164   let SemaHandler = 0;
3165   let HasCustomParsing = 1;
3166   let Documentation = [OMPDeclareSimdDocs];
3167   let Args = [
3168     EnumArgument<"BranchState", "BranchStateTy",
3169                  [ "", "inbranch", "notinbranch" ],
3170                  [ "BS_Undefined", "BS_Inbranch", "BS_Notinbranch" ]>,
3171     ExprArgument<"Simdlen">, VariadicExprArgument<"Uniforms">,
3172     VariadicExprArgument<"Aligneds">, VariadicExprArgument<"Alignments">,
3173     VariadicExprArgument<"Linears">, VariadicUnsignedArgument<"Modifiers">,
3174     VariadicExprArgument<"Steps">
3175   ];
3176   let AdditionalMembers = [{
3177     void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
3178         const {
3179       if (getBranchState() != BS_Undefined)
3180         OS << ' ' << ConvertBranchStateTyToStr(getBranchState());
3181       if (auto *E = getSimdlen()) {
3182         OS << " simdlen(";
3183         E->printPretty(OS, nullptr, Policy);
3184         OS << ")";
3185       }
3186       if (uniforms_size() > 0) {
3187         OS << " uniform";
3188         StringRef Sep = "(";
3189         for (auto *E : uniforms()) {
3190           OS << Sep;
3191           E->printPretty(OS, nullptr, Policy);
3192           Sep = ", ";
3193         }
3194         OS << ")";
3195       }
3196       alignments_iterator NI = alignments_begin();
3197       for (auto *E : aligneds()) {
3198         OS << " aligned(";
3199         E->printPretty(OS, nullptr, Policy);
3200         if (*NI) {
3201           OS << ": ";
3202           (*NI)->printPretty(OS, nullptr, Policy);
3203         }
3204         OS << ")";
3205         ++NI;
3206       }
3207       steps_iterator I = steps_begin();
3208       modifiers_iterator MI = modifiers_begin();
3209       for (auto *E : linears()) {
3210         OS << " linear(";
3211         if (*MI != OMPC_LINEAR_unknown)
3212           OS << getOpenMPSimpleClauseTypeName(OMPC_linear, *MI) << "(";
3213         E->printPretty(OS, nullptr, Policy);
3214         if (*MI != OMPC_LINEAR_unknown)
3215           OS << ")";
3216         if (*I) {
3217           OS << ": ";
3218           (*I)->printPretty(OS, nullptr, Policy);
3219         }
3220         OS << ")";
3221         ++I;
3222         ++MI;
3223       }
3224     }
3225   }];
3226 }
3227
3228 def OMPDeclareTargetDecl : InheritableAttr {
3229   let Spellings = [Pragma<"omp", "declare target">];
3230   let SemaHandler = 0;
3231   let Subjects = SubjectList<[Function, SharedVar]>;
3232   let Documentation = [OMPDeclareTargetDocs];
3233   let Args = [
3234     EnumArgument<"MapType", "MapTypeTy",
3235                  [ "to", "link" ],
3236                  [ "MT_To", "MT_Link" ]>,
3237     EnumArgument<"DevType", "DevTypeTy",
3238                  [ "host", "nohost", "any" ],
3239                  [ "DT_Host", "DT_NoHost", "DT_Any" ]>
3240   ];
3241   let AdditionalMembers = [{
3242     void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
3243       // Use fake syntax because it is for testing and debugging purpose only.
3244       if (getDevType() != DT_Any)
3245         OS << " device_type(" << ConvertDevTypeTyToStr(getDevType()) << ")";
3246       if (getMapType() != MT_To)
3247         OS << ' ' << ConvertMapTypeTyToStr(getMapType());
3248     }
3249     static llvm::Optional<MapTypeTy>
3250     isDeclareTargetDeclaration(const ValueDecl *VD) {
3251       if (!VD->hasAttrs())
3252         return llvm::None;
3253       if (const auto *Attr = VD->getAttr<OMPDeclareTargetDeclAttr>())
3254         return Attr->getMapType();
3255
3256       return llvm::None;
3257     }
3258     static llvm::Optional<DevTypeTy> getDeviceType(const ValueDecl *VD) {
3259       if (!VD->hasAttrs())
3260         return llvm::None;
3261       if (const auto *Attr = VD->getAttr<OMPDeclareTargetDeclAttr>())
3262         return Attr->getDevType();
3263
3264       return llvm::None;
3265     }
3266   }];
3267 }
3268
3269 def OMPAllocateDecl : InheritableAttr {
3270   // This attribute has no spellings as it is only ever created implicitly.
3271   let Spellings = [];
3272   let SemaHandler = 0;
3273   let Args = [
3274     EnumArgument<"AllocatorType", "AllocatorTypeTy",
3275                  [
3276                    "omp_default_mem_alloc", "omp_large_cap_mem_alloc",
3277                    "omp_const_mem_alloc", "omp_high_bw_mem_alloc",
3278                    "omp_low_lat_mem_alloc", "omp_cgroup_mem_alloc",
3279                    "omp_pteam_mem_alloc", "omp_thread_mem_alloc", ""
3280                  ],
3281                  [
3282                    "OMPDefaultMemAlloc", "OMPLargeCapMemAlloc",
3283                    "OMPConstMemAlloc", "OMPHighBWMemAlloc", "OMPLowLatMemAlloc",
3284                    "OMPCGroupMemAlloc", "OMPPTeamMemAlloc", "OMPThreadMemAlloc",
3285                    "OMPUserDefinedMemAlloc"
3286                  ]>,
3287     ExprArgument<"Allocator">
3288   ];
3289   let Documentation = [Undocumented];
3290 }
3291
3292 def OMPDeclareVariant : InheritableAttr {
3293   let Spellings = [Pragma<"omp", "declare variant">];
3294   let Subjects = SubjectList<[Function]>;
3295   let SemaHandler = 0;
3296   let HasCustomParsing = 1;
3297   let InheritEvenIfAlreadyPresent = 1;
3298   let Documentation = [OMPDeclareVariantDocs];
3299   let Args = [
3300     ExprArgument<"VariantFuncRef">,
3301     ExprArgument<"Score">,
3302     EnumArgument<"CtxSelectorSet", "CtxSelectorSetType",
3303                  [ "", "implementation"
3304                  ],
3305                  [
3306                    "CtxSetUnknown", "CtxSetImplementation"
3307                  ]>,
3308     EnumArgument<"CtxScore", "ScoreType",
3309                  [ "", "score"
3310                  ],
3311                  [
3312                    "ScoreUnknown", "ScoreSpecified"
3313                  ]>,
3314     EnumArgument<"CtxSelector", "CtxSelectorType",
3315                  [ "", "vendor"
3316                  ],
3317                  [
3318                    "CtxUnknown", "CtxVendor"
3319                  ]>,
3320     VariadicStringArgument<"ImplVendors">
3321   ];
3322   let AdditionalMembers = [{
3323     void printScore(raw_ostream & OS, const PrintingPolicy &Policy) const {
3324       if (const Expr *E = getScore()) {
3325         OS << "score(";
3326         E->printPretty(OS, nullptr, Policy);
3327         OS << "):";
3328       }
3329     }
3330     void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
3331         const {
3332       assert(getCtxSelectorSet() != CtxSetUnknown &&
3333              getCtxSelector() != CtxUnknown && "Unknown context selector.");
3334       if (const Expr *E = getVariantFuncRef()) {
3335         OS << "(";
3336         E->printPretty(OS, nullptr, Policy);
3337         OS << ")";
3338       }
3339       // TODO: add printing of real context selectors.
3340       OS << " match(";
3341       switch (getCtxSelectorSet()) {
3342       case CtxSetImplementation:
3343         OS << "implementation={";
3344         switch (getCtxSelector()) {
3345         case CtxVendor:
3346           OS << "vendor(";
3347           printScore(OS, Policy);
3348           if (implVendors_size() > 0) {
3349             OS << *implVendors(). begin();
3350             for (StringRef VendorName : llvm::drop_begin(implVendors(), 1))
3351               OS << ", " << VendorName;
3352           }
3353           OS << ")";
3354           break;
3355         case CtxUnknown:
3356           llvm_unreachable("Unknown context selector.");
3357         }
3358         OS << "}";
3359         break;
3360       case CtxSetUnknown:
3361         llvm_unreachable("Unknown context selector set.");
3362       }
3363       OS << ")";
3364     }
3365   }];
3366 }
3367
3368 def InternalLinkage : InheritableAttr {
3369   let Spellings = [Clang<"internal_linkage">];
3370   let Subjects = SubjectList<[Var, Function, CXXRecord]>;
3371   let Documentation = [InternalLinkageDocs];
3372 }
3373
3374 def ExcludeFromExplicitInstantiation : InheritableAttr {
3375   let Spellings = [Clang<"exclude_from_explicit_instantiation">];
3376   let Subjects = SubjectList<[Var, Function, CXXRecord]>;
3377   let Documentation = [ExcludeFromExplicitInstantiationDocs];
3378   let MeaningfulToClassTemplateDefinition = 1;
3379 }
3380
3381 def Reinitializes : InheritableAttr {
3382   let Spellings = [Clang<"reinitializes", 0>];
3383   let Subjects = SubjectList<[NonStaticNonConstCXXMethod], ErrorDiag>;
3384   let Documentation = [ReinitializesDocs];
3385 }
3386
3387 def NoDestroy : InheritableAttr {
3388   let Spellings = [Clang<"no_destroy", 0>];
3389   let Subjects = SubjectList<[Var]>;
3390   let Documentation = [NoDestroyDocs];
3391 }
3392
3393 def AlwaysDestroy : InheritableAttr {
3394   let Spellings = [Clang<"always_destroy", 0>];
3395   let Subjects = SubjectList<[Var]>;
3396   let Documentation = [AlwaysDestroyDocs];
3397 }
3398
3399 def SpeculativeLoadHardening : InheritableAttr {
3400   let Spellings = [Clang<"speculative_load_hardening">];
3401   let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
3402   let Documentation = [SpeculativeLoadHardeningDocs];
3403 }
3404
3405 def NoSpeculativeLoadHardening : InheritableAttr {
3406   let Spellings = [Clang<"no_speculative_load_hardening">];
3407   let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
3408   let Documentation = [NoSpeculativeLoadHardeningDocs];
3409 }
3410
3411 def Uninitialized : InheritableAttr {
3412   let Spellings = [Clang<"uninitialized", 0>];
3413   let Subjects = SubjectList<[LocalVar]>;
3414   let Documentation = [UninitializedDocs];
3415 }
3416
3417 def ObjCExternallyRetained : InheritableAttr {
3418   let LangOpts = [ObjCAutoRefCount];
3419   let Spellings = [Clang<"objc_externally_retained">];
3420   let Subjects = SubjectList<[NonParmVar, Function, Block, ObjCMethod]>;
3421   let Documentation = [ObjCExternallyRetainedDocs];
3422 }