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.
11class DocumentationCategory<string name> {
12  string Name = name;
13  code Content = [{}];
14}
15def DocCatFunction : DocumentationCategory<"Function Attributes">;
16def DocCatVariable : DocumentationCategory<"Variable Attributes">;
17def DocCatField : DocumentationCategory<"Field Attributes">;
18def DocCatType : DocumentationCategory<"Type Attributes">;
19def DocCatStmt : DocumentationCategory<"Statement Attributes">;
20def DocCatDecl : DocumentationCategory<"Declaration Attributes">;
21
22// This category is for attributes which have not yet been properly documented,
23// but should be.
24def DocCatUndocumented : DocumentationCategory<"Undocumented"> {
25  let Content = [{
26This section lists attributes which are recognized by Clang, but which are
27currently missing documentation.
28}];
29}
30
31// Attributes listed under the InternalOnly category do not generate any entry
32// in the documentation.  This category should be used only when we _want_
33// to not document the attribute, e.g. if the attribute has no spellings.
34def DocCatInternalOnly : DocumentationCategory<"InternalOnly">;
35
36class DocDeprecated<string replacement = ""> {
37  // If the Replacement field is empty, no replacement will be listed with the
38  // documentation. Otherwise, the documentation will specify the attribute has
39  // been superseded by this replacement.
40  string Replacement = replacement;
41}
42
43// Specifies the documentation to be associated with the given category.
44class Documentation {
45  DocumentationCategory Category;
46  code Content;
47
48  // If the heading is empty, one may be picked automatically. If the attribute
49  // only has one spelling, no heading is required as the attribute's sole
50  // spelling is sufficient. If all spellings are semantically common, the
51  // heading will be the semantic spelling. If the spellings are not
52  // semantically common and no heading is provided, an error will be emitted.
53  string Heading = "";
54
55  // When set, specifies that the attribute is deprecated and can optionally
56  // specify a replacement attribute.
57  DocDeprecated Deprecated;
58}
59
60// Specifies that the attribute is explicitly omitted from the documentation,
61// because it is not intended to be user-facing.
62def InternalOnly : Documentation {
63  let Category = DocCatInternalOnly;
64}
65
66// Specifies that the attribute is undocumented, but that it _should_ have
67// documentation.
68def Undocumented : Documentation {
69  let Category = DocCatUndocumented;
70  let Content = "No documentation.";
71}
72
73include "clang/Basic/AttrDocs.td"
74
75// An attribute's subject is whatever it appertains to. In this file, it is
76// more accurately a list of things that an attribute can appertain to. All
77// Decls and Stmts are possibly AttrSubjects (even though the syntax may not
78// allow attributes on a given Decl or Stmt).
79class AttrSubject;
80
81include "clang/Basic/DeclNodes.td"
82include "clang/Basic/StmtNodes.td"
83
84// A subset-subject is an AttrSubject constrained to operate only on some subset
85// of that subject.
86//
87// The code fragment is a boolean expression that will confirm that the subject
88// meets the requirements; the subject will have the name S, and will have the
89// type specified by the base. It should be a simple boolean expression. The
90// diagnostic string should be a comma-separated list of subject names.
91class SubsetSubject<AttrSubject base, code check, string diag> : AttrSubject {
92  AttrSubject Base = base;
93  code CheckCode = check;
94  string DiagSpelling = diag;
95}
96
97def LocalVar : SubsetSubject<Var,
98                              [{S->hasLocalStorage() && !isa<ParmVarDecl>(S)}],
99                              "local variables">;
100def NonParmVar : SubsetSubject<Var,
101                               [{S->getKind() != Decl::ParmVar}],
102                               "variables">;
103def NonLocalVar : SubsetSubject<Var,
104                                [{!S->hasLocalStorage()}],
105                                "variables with non-local storage">;
106def NonBitField : SubsetSubject<Field,
107                                [{!S->isBitField()}],
108                                "non-bit-field non-static data members">;
109
110def BitField : SubsetSubject<Field,
111                             [{S->isBitField()}],
112                             "bit-field data members">;
113
114def NonStaticCXXMethod : SubsetSubject<CXXMethod,
115                                       [{!S->isStatic()}],
116                                       "non-static member functions">;
117
118def NonStaticNonConstCXXMethod
119    : SubsetSubject<CXXMethod,
120                    [{!S->isStatic() && !S->isConst()}],
121                    "non-static non-const member functions">;
122
123def ObjCInstanceMethod : SubsetSubject<ObjCMethod,
124                                       [{S->isInstanceMethod()}],
125                                       "Objective-C instance methods">;
126
127def Struct : SubsetSubject<Record,
128                           [{!S->isUnion()}], "structs">;
129
130def TLSVar : SubsetSubject<Var,
131                           [{S->getTLSKind() != 0}], "thread-local variables">;
132
133def SharedVar : SubsetSubject<Var,
134                              [{S->hasGlobalStorage() && !S->getTLSKind()}],
135                              "global variables">;
136
137def GlobalVar : SubsetSubject<Var,
138                             [{S->hasGlobalStorage()}], "global variables">;
139
140def ExternalGlobalVar : SubsetSubject<Var,
141                             [{S->hasGlobalStorage() &&
142                               S->getStorageClass()!=StorageClass::SC_Static &&
143                               !S->isLocalExternDecl()}],
144                             "external global variables">;
145
146def NonTLSGlobalVar : SubsetSubject<Var,
147                             [{S->hasGlobalStorage() &&
148                               S->getTLSKind() == 0}],
149                             "non-TLS global variables">;
150
151def InlineFunction : SubsetSubject<Function,
152                             [{S->isInlineSpecified()}], "inline functions">;
153
154def FunctionTmpl
155    : SubsetSubject<Function, [{S->getTemplatedKind() ==
156                                 FunctionDecl::TK_FunctionTemplate}],
157                    "function templates">;
158
159def HLSLEntry
160    : SubsetSubject<Function,
161                    [{S->isExternallyVisible() && !isa<CXXMethodDecl>(S)}],
162                    "global functions">;
163def HLSLBufferObj : SubsetSubject<HLSLBuffer,
164                    [{isa<HLSLBufferDecl>(S)}],
165                    "cbuffer/tbuffer">;
166
167def ClassTmpl : SubsetSubject<CXXRecord, [{S->getDescribedClassTemplate()}],
168                              "class templates">;
169
170// FIXME: this hack is needed because DeclNodes.td defines the base Decl node
171// type to be a class, not a definition. This makes it impossible to create an
172// attribute subject which accepts a Decl. Normally, this is not a problem,
173// because the attribute can have no Subjects clause to accomplish this. But in
174// the case of a SubsetSubject, there's no way to express it without this hack.
175def DeclBase : AttrSubject;
176def FunctionLike : SubsetSubject<DeclBase,
177                                 [{S->getFunctionType(false) != nullptr}],
178                                 "functions, function pointers">;
179
180// Function Pointer is a stricter version of FunctionLike that only allows function
181// pointers.
182def FunctionPointer : SubsetSubject<DeclBase,
183                                    [{S->isFunctionPointerType()}],
184                                    "functions pointers">;
185
186def OpenCLKernelFunction
187    : SubsetSubject<Function, [{S->hasAttr<OpenCLKernelAttr>()}],
188                    "kernel functions">;
189
190// HasFunctionProto is a more strict version of FunctionLike, so it should
191// never be specified in a Subjects list along with FunctionLike (due to the
192// inclusive nature of subject testing).
193def HasFunctionProto : SubsetSubject<DeclBase,
194                                     [{(S->getFunctionType(true) != nullptr &&
195                              isa<FunctionProtoType>(S->getFunctionType())) ||
196                                       isa<ObjCMethodDecl>(S) ||
197                                       isa<BlockDecl>(S)}],
198                                     "non-K&R-style functions">;
199
200// A subject that matches the implicit object parameter of a non-static member
201// function. Accepted as a function type attribute on the type of such a
202// member function.
203// FIXME: This does not actually ever match currently.
204def ImplicitObjectParameter
205    : SubsetSubject<Function, [{static_cast<void>(S), false}],
206                    "implicit object parameters">;
207
208// A single argument to an attribute
209class Argument<string name, bit optional, bit fake = 0> {
210  string Name = name;
211  bit Optional = optional;
212
213  /// A fake argument is used to store and serialize additional information
214  /// in an attribute without actually changing its parsing or pretty-printing.
215  bit Fake = fake;
216}
217
218class BoolArgument<string name, bit opt = 0, bit fake = 0> : Argument<name, opt,
219                                                                      fake>;
220class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>;
221class IntArgument<string name, bit opt = 0> : Argument<name, opt>;
222class StringArgument<string name, bit opt = 0> : Argument<name, opt>;
223class ExprArgument<string name, bit opt = 0> : Argument<name, opt>;
224class DeclArgument<DeclNode kind, string name, bit opt = 0, bit fake = 0>
225    : Argument<name, opt, fake> {
226  DeclNode Kind = kind;
227}
228
229// An argument of a OMPDeclareVariantAttr that represents the `match`
230// clause of the declare variant by keeping the information (incl. nesting) in
231// an OMPTraitInfo object.
232//
233// With some exceptions, the `match(<context-selector>)` clause looks roughly
234// as follows:
235//   context-selector := list<selector-set>
236//       selector-set := <kind>={list<selector>}
237//           selector := <kind>([score(<const-expr>):] list<trait>)
238//              trait := <kind>
239//
240// The structure of an OMPTraitInfo object is a tree as defined below:
241//
242//   OMPTraitInfo     := {list<OMPTraitSet>}
243//   OMPTraitSet      := {Kind, list<OMPTraitSelector>}
244//   OMPTraitSelector := {Kind, Expr, list<OMPTraitProperty>}
245//   OMPTraitProperty := {Kind}
246//
247class OMPTraitInfoArgument<string name> : Argument<name, 0>;
248class VariadicOMPInteropInfoArgument<string name> : Argument<name, 0>;
249
250class TypeArgument<string name, bit opt = 0> : Argument<name, opt>;
251class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>;
252class VariadicUnsignedArgument<string name> : Argument<name, 1>;
253class VariadicExprArgument<string name> : Argument<name, 1>;
254class VariadicStringArgument<string name> : Argument<name, 1>;
255class VariadicIdentifierArgument<string name> : Argument<name, 1>;
256
257// Like VariadicUnsignedArgument except values are ParamIdx.
258class VariadicParamIdxArgument<string name> : Argument<name, 1>;
259
260// A list of identifiers matching parameters or ParamIdx indices.
261class VariadicParamOrParamIdxArgument<string name> : Argument<name, 1>;
262
263// Like VariadicParamIdxArgument but for a single function parameter index.
264class ParamIdxArgument<string name, bit opt = 0> : Argument<name, opt>;
265
266// A version of the form major.minor[.subminor].
267class VersionArgument<string name, bit opt = 0> : Argument<name, opt>;
268
269// This one's a doozy, so it gets its own special type
270// It can be an unsigned integer, or a type. Either can
271// be dependent.
272class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>;
273
274// A bool argument with a default value
275class DefaultBoolArgument<string name, bit default, bit fake = 0>
276    : BoolArgument<name, 1, fake> {
277  bit Default = default;
278}
279
280// An integer argument with a default value
281class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
282  int Default = default;
283}
284
285// This argument is more complex, it includes the enumerator type
286// name, whether the enum type is externally defined, a list of
287// strings to accept, and a list of enumerators to map them to.
288class EnumArgument<string name, string type, list<string> values,
289                   list<string> enums, bit opt = 0, bit fake = 0,
290                   bit isExternalType = 0>
291    : Argument<name, opt, fake> {
292  string Type = type;
293  list<string> Values = values;
294  list<string> Enums = enums;
295  bit IsExternalType = isExternalType;
296}
297
298// FIXME: There should be a VariadicArgument type that takes any other type
299//        of argument and generates the appropriate type.
300class VariadicEnumArgument<string name, string type, list<string> values,
301                           list<string> enums, bit isExternalType = 0>
302    : Argument<name, 1>  {
303  string Type = type;
304  list<string> Values = values;
305  list<string> Enums = enums;
306  bit IsExternalType = isExternalType;
307}
308
309// Represents an attribute wrapped by another attribute.
310class WrappedAttr<string name, bit opt = 0> : Argument<name, opt>;
311
312// This handles one spelling of an attribute.
313class Spelling<string name, string variety, int version = 1> {
314  string Name = name;
315  string Variety = variety;
316  int Version = version;
317}
318
319class GNU<string name> : Spelling<name, "GNU">;
320class Declspec<string name> : Spelling<name, "Declspec"> {
321  bit PrintOnLeft = 1;
322}
323class Microsoft<string name> : Spelling<name, "Microsoft">;
324class CXX11<string namespace, string name, int version = 1>
325    : Spelling<name, "CXX11", version> {
326  bit CanPrintOnLeft = 0;
327  string Namespace = namespace;
328}
329class C23<string namespace, string name, int version = 1>
330    : Spelling<name, "C23", version> {
331  string Namespace = namespace;
332}
333
334class Keyword<string name, bit hasOwnParseRules>
335    : Spelling<name, "Keyword"> {
336  bit HasOwnParseRules = hasOwnParseRules;
337}
338
339// A keyword that can appear wherever a standard attribute can appear,
340// and that appertains to whatever a standard attribute would appertain to.
341// This is useful for things that affect semantics but that should otherwise
342// be treated like standard attributes.
343class RegularKeyword<string name> : Keyword<name, 0> {}
344
345// A keyword that has its own individual parsing rules.
346class CustomKeyword<string name> : Keyword<name, 1> {}
347
348class Pragma<string namespace, string name> : Spelling<name, "Pragma"> {
349  string Namespace = namespace;
350}
351
352// The GCC spelling implies GNU<name>, CXX11<"gnu", name>, and optionally,
353// C23<"gnu", name>. This spelling should be used for any GCC-compatible
354// attributes.
355class GCC<string name, bit allowInC = 1> : Spelling<name, "GCC"> {
356  bit AllowInC = allowInC;
357}
358
359// The Clang spelling implies GNU<name>, CXX11<"clang", name>, and optionally,
360// C23<"clang", name>. This spelling should be used for any Clang-specific
361// attributes.
362class Clang<string name, bit allowInC = 1, int version = 1>
363    : Spelling<name, "Clang", version> {
364  bit AllowInC = allowInC;
365}
366
367// HLSL Semantic spellings
368class HLSLSemantic<string name> : Spelling<name, "HLSLSemantic">;
369
370class Accessor<string name, list<Spelling> spellings> {
371  string Name = name;
372  list<Spelling> Spellings = spellings;
373}
374
375class SubjectDiag<bit warn> {
376  bit Warn = warn;
377}
378def WarnDiag : SubjectDiag<1>;
379def ErrorDiag : SubjectDiag<0>;
380
381class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag,
382                  string customDiag = ""> {
383  list<AttrSubject> Subjects = subjects;
384  SubjectDiag Diag = diag;
385  string CustomDiag = customDiag;
386}
387
388class LangOpt<string name, code customCode = [{}]> {
389  // The language option to test; ignored when custom code is supplied.
390  string Name = name;
391
392  // A custom predicate, written as an expression evaluated in a context with
393  // "LangOpts" bound.
394  code CustomCode = customCode;
395}
396def MicrosoftExt : LangOpt<"MicrosoftExt">;
397def Borland : LangOpt<"Borland">;
398def CUDA : LangOpt<"CUDA">;
399def HIP : LangOpt<"HIP">;
400def SYCL : LangOpt<"SYCLIsDevice">;
401def COnly : LangOpt<"", "!LangOpts.CPlusPlus">;
402def CPlusPlus : LangOpt<"CPlusPlus">;
403def OpenCL : LangOpt<"OpenCL">;
404def RenderScript : LangOpt<"RenderScript">;
405def ObjC : LangOpt<"ObjC">;
406def BlocksSupported : LangOpt<"Blocks">;
407def ObjCAutoRefCount : LangOpt<"ObjCAutoRefCount">;
408def ObjCNonFragileRuntime
409    : LangOpt<"", "LangOpts.ObjCRuntime.allowsClassStubs()">;
410
411def HLSL : LangOpt<"HLSL">;
412
413// Language option for CMSE extensions
414def Cmse : LangOpt<"Cmse">;
415
416// Defines targets for target-specific attributes. Empty lists are unchecked.
417class TargetSpec {
418  // Specifies Architectures for which the target applies, based off the
419  // ArchType enumeration in Triple.h.
420  list<string> Arches = [];
421  // Specifies Operating Systems for which the target applies, based off the
422  // OSType enumeration in Triple.h
423  list<string> OSes;
424  // Specifies Object Formats for which the target applies, based off the
425  // ObjectFormatType enumeration in Triple.h
426  list<string> ObjectFormats;
427  // A custom predicate, written as an expression evaluated in a context
428  // with the following declarations in scope:
429  //   const clang::TargetInfo &Target;
430  //   const llvm::Triple &T = Target.getTriple();
431  code CustomCode = [{}];
432}
433
434class TargetArch<list<string> arches> : TargetSpec {
435  let Arches = arches;
436}
437def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
438def TargetAArch64 : TargetArch<["aarch64", "aarch64_be", "aarch64_32"]>;
439def TargetAnyArm : TargetArch<!listconcat(TargetARM.Arches, TargetAArch64.Arches)>;
440def TargetAVR : TargetArch<["avr"]>;
441def TargetBPF : TargetArch<["bpfel", "bpfeb"]>;
442def TargetLoongArch : TargetArch<["loongarch32", "loongarch64"]>;
443def TargetMips32 : TargetArch<["mips", "mipsel"]>;
444def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
445def TargetMSP430 : TargetArch<["msp430"]>;
446def TargetM68k : TargetArch<["m68k"]>;
447def TargetRISCV : TargetArch<["riscv32", "riscv64"]>;
448def TargetX86 : TargetArch<["x86"]>;
449def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
450def TargetWebAssembly : TargetArch<["wasm32", "wasm64"]>;
451def TargetNVPTX : TargetArch<["nvptx", "nvptx64"]>;
452def TargetWindows : TargetSpec {
453  let OSes = ["Win32"];
454}
455def TargetHasDLLImportExport : TargetSpec {
456  let CustomCode = [{ Target.getTriple().hasDLLImportExport() }];
457}
458def TargetItaniumCXXABI : TargetSpec {
459  let CustomCode = [{ Target.getCXXABI().isItaniumFamily() }];
460}
461def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
462  let CustomCode = [{ Target.getCXXABI().isMicrosoft() }];
463}
464def TargetELF : TargetSpec {
465  let ObjectFormats = ["ELF"];
466}
467def TargetELFOrMachO : TargetSpec {
468  let ObjectFormats = ["ELF", "MachO"];
469}
470
471def TargetSupportsInitPriority : TargetSpec {
472  let CustomCode = [{ !Target.getTriple().isOSzOS() }];
473}
474
475class TargetSpecificSpelling<TargetSpec target, list<Spelling> spellings> {
476  TargetSpec Target = target;
477  list<Spelling> Spellings = spellings;
478}
479
480// Attribute subject match rules that are used for #pragma clang attribute.
481//
482// A instance of AttrSubjectMatcherRule represents an individual match rule.
483// An individual match rule can correspond to a number of different attribute
484// subjects, e.g. "record" matching rule corresponds to the Record and
485// CXXRecord attribute subjects.
486//
487// Match rules are used in the subject list of the #pragma clang attribute.
488// Match rules can have sub-match rules that are instances of
489// AttrSubjectMatcherSubRule. A sub-match rule can correspond to a number
490// of different attribute subjects, and it can have a negated spelling as well.
491// For example, "variable(unless(is_parameter))" matching rule corresponds to
492// the NonParmVar attribute subject.
493class AttrSubjectMatcherSubRule<string name, list<AttrSubject> subjects,
494                                bit negated = 0> {
495  string Name = name;
496  list<AttrSubject> Subjects = subjects;
497  bit Negated = negated;
498  // Lists language options, one of which is required to be true for the
499  // attribute to be applicable. If empty, the language options are taken
500  // from the parent matcher rule.
501  list<LangOpt> LangOpts = [];
502}
503class AttrSubjectMatcherRule<string name, list<AttrSubject> subjects,
504                             list<AttrSubjectMatcherSubRule> subrules = []> {
505  string Name = name;
506  list<AttrSubject> Subjects = subjects;
507  list<AttrSubjectMatcherSubRule> Constraints = subrules;
508  // Lists language options, one of which is required to be true for the
509  // attribute to be applicable. If empty, no language options are required.
510  list<LangOpt> LangOpts = [];
511}
512
513// function(is_member)
514def SubRuleForCXXMethod : AttrSubjectMatcherSubRule<"is_member", [CXXMethod]> {
515  let LangOpts = [CPlusPlus];
516}
517def SubjectMatcherForFunction : AttrSubjectMatcherRule<"function", [Function], [
518  SubRuleForCXXMethod
519]>;
520// hasType is abstract, it should be used with one of the sub-rules.
521def SubjectMatcherForType : AttrSubjectMatcherRule<"hasType", [], [
522  AttrSubjectMatcherSubRule<"functionType", [FunctionLike]>
523
524  // FIXME: There's a matcher ambiguity with objc methods and blocks since
525  // functionType excludes them but functionProtoType includes them.
526  // AttrSubjectMatcherSubRule<"functionProtoType", [HasFunctionProto]>
527]>;
528def SubjectMatcherForTypedef : AttrSubjectMatcherRule<"type_alias",
529                                                      [TypedefName]>;
530def SubjectMatcherForRecord : AttrSubjectMatcherRule<"record", [Record,
531                                                                CXXRecord], [
532  // unless(is_union)
533  AttrSubjectMatcherSubRule<"is_union", [Struct], 1>
534]>;
535def SubjectMatcherForEnum : AttrSubjectMatcherRule<"enum", [Enum]>;
536def SubjectMatcherForEnumConstant : AttrSubjectMatcherRule<"enum_constant",
537                                                           [EnumConstant]>;
538def SubjectMatcherForVar : AttrSubjectMatcherRule<"variable", [Var], [
539  AttrSubjectMatcherSubRule<"is_thread_local", [TLSVar]>,
540  AttrSubjectMatcherSubRule<"is_global", [GlobalVar]>,
541  AttrSubjectMatcherSubRule<"is_local", [LocalVar]>,
542  AttrSubjectMatcherSubRule<"is_parameter", [ParmVar]>,
543  // unless(is_parameter)
544  AttrSubjectMatcherSubRule<"is_parameter", [NonParmVar], 1>
545]>;
546def SubjectMatcherForField : AttrSubjectMatcherRule<"field", [Field]>;
547def SubjectMatcherForNamespace : AttrSubjectMatcherRule<"namespace",
548                                                        [Namespace]> {
549  let LangOpts = [CPlusPlus];
550}
551def SubjectMatcherForObjCInterface : AttrSubjectMatcherRule<"objc_interface",
552                                                            [ObjCInterface]> {
553  let LangOpts = [ObjC];
554}
555def SubjectMatcherForObjCProtocol : AttrSubjectMatcherRule<"objc_protocol",
556                                                           [ObjCProtocol]> {
557  let LangOpts = [ObjC];
558}
559def SubjectMatcherForObjCCategory : AttrSubjectMatcherRule<"objc_category",
560                                                           [ObjCCategory]> {
561  let LangOpts = [ObjC];
562}
563def SubjectMatcherForObjCImplementation :
564    AttrSubjectMatcherRule<"objc_implementation", [ObjCImpl]> {
565  let LangOpts = [ObjC];
566}
567def SubjectMatcherForObjCMethod : AttrSubjectMatcherRule<"objc_method",
568                                                         [ObjCMethod], [
569  AttrSubjectMatcherSubRule<"is_instance", [ObjCInstanceMethod]>
570]> {
571  let LangOpts = [ObjC];
572}
573def SubjectMatcherForObjCProperty : AttrSubjectMatcherRule<"objc_property",
574                                                           [ObjCProperty]> {
575  let LangOpts = [ObjC];
576}
577def SubjectMatcherForBlock : AttrSubjectMatcherRule<"block", [Block]> {
578  let LangOpts = [BlocksSupported];
579}
580
581// Aggregate attribute subject match rules are abstract match rules that can't
582// be used directly in #pragma clang attribute. Instead, users have to use
583// subject match rules that correspond to attribute subjects that derive from
584// the specified subject.
585class AttrSubjectMatcherAggregateRule<AttrSubject subject> {
586  AttrSubject Subject = subject;
587}
588
589def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule<Named>;
590
591class Attr {
592  // Specifies that when printed, this attribute is meaningful on the
593  // 'left side' of the declaration.
594  bit CanPrintOnLeft = 1;
595  // Specifies that when printed, this attribute is required to be printed on
596  // the 'left side' of the declaration.
597  bit PrintOnLeft = 0;
598  // The various ways in which an attribute can be spelled in source
599  list<Spelling> Spellings;
600  // The things to which an attribute can appertain
601  SubjectList Subjects;
602  // The arguments allowed on an attribute
603  list<Argument> Args = [];
604  // Accessors which should be generated for the attribute.
605  list<Accessor> Accessors = [];
606  // Specify targets for spellings.
607  list<TargetSpecificSpelling> TargetSpecificSpellings = [];
608  // Set to true for attributes with arguments which require delayed parsing.
609  bit LateParsed = 0;
610  // Set to false to prevent an attribute from being propagated from a template
611  // to the instantiation.
612  bit Clone = 1;
613  // Set to true for attributes which must be instantiated within templates
614  bit TemplateDependent = 0;
615  // Set to true for attributes that have a corresponding AST node.
616  bit ASTNode = 1;
617  // Set to true for attributes which have handler in Sema.
618  bit SemaHandler = 1;
619  // Set to true if this attribute doesn't need custom handling in Sema.
620  bit SimpleHandler = 0;
621  // Set to true for attributes that are completely ignored.
622  bit Ignored = 0;
623  // Set to true if the attribute's parsing does not match its semantic
624  // content. Eg) It parses 3 args, but semantically takes 4 args.  Opts out of
625  // common attribute error checking.
626  bit HasCustomParsing = 0;
627  // Set to true if all of the attribute's arguments should be parsed in an
628  // unevaluated context.
629  bit ParseArgumentsAsUnevaluated = 0;
630  // Set to true if this attribute meaningful when applied to or inherited
631  // in a class template definition.
632  bit MeaningfulToClassTemplateDefinition = 0;
633  // Set to true if this attribute can be used with '#pragma clang attribute'.
634  // By default, an attribute is supported by the '#pragma clang attribute'
635  // only when:
636  // - It has a subject list whose subjects can be represented using subject
637  //   match rules.
638  // - It has GNU/CXX11 spelling and doesn't require delayed parsing.
639  bit PragmaAttributeSupport;
640  // Set to true if this attribute accepts parameter pack expansion expressions.
641  bit AcceptsExprPack = 0;
642  // Lists language options, one of which is required to be true for the
643  // attribute to be applicable. If empty, no language options are required.
644  list<LangOpt> LangOpts = [];
645  // Any additional text that should be included verbatim in the class.
646  // Note: Any additional data members will leak and should be constructed
647  // externally on the ASTContext.
648  code AdditionalMembers = [{}];
649  // Any documentation that should be associated with the attribute. Since an
650  // attribute may be documented under multiple categories, more than one
651  // Documentation entry may be listed.
652  list<Documentation> Documentation;
653}
654
655/// Used to define a set of mutually exclusive attributes.
656class MutualExclusions<list<Attr> Ex> {
657  list<Attr> Exclusions = Ex;
658}
659
660/// A type attribute is not processed on a declaration or a statement.
661class TypeAttr : Attr;
662
663/// A stmt attribute is not processed on a declaration or a type.
664class StmtAttr : Attr;
665
666/// An inheritable attribute is inherited by later redeclarations.
667class InheritableAttr : Attr {
668  // Set to true if this attribute can be duplicated on a subject when inheriting
669  // attributes from prior declarations.
670  bit InheritEvenIfAlreadyPresent = 0;
671}
672
673/// Some attributes, like calling conventions, can appear in either the
674/// declaration or the type position. These attributes are morally type
675/// attributes, but have historically been written on declarations.
676class DeclOrTypeAttr : InheritableAttr;
677
678/// A attribute is either a declaration attribute or a statement attribute.
679class DeclOrStmtAttr : InheritableAttr;
680
681/// An attribute class for HLSL Annotations.
682class HLSLAnnotationAttr : InheritableAttr;
683
684/// A target-specific attribute.  This class is meant to be used as a mixin
685/// with InheritableAttr or Attr depending on the attribute's needs.
686class TargetSpecificAttr<TargetSpec target> {
687  TargetSpec Target = target;
688  // Attributes are generally required to have unique spellings for their names
689  // so that the parser can determine what kind of attribute it has parsed.
690  // However, target-specific attributes are special in that the attribute only
691  // "exists" for a given target. So two target-specific attributes can share
692  // the same name when they exist in different targets. To support this, a
693  // Kind can be explicitly specified for a target-specific attribute. This
694  // corresponds to the ParsedAttr::AT_* enum that is generated and it
695  // should contain a shared value between the attributes.
696  //
697  // Target-specific attributes which use this feature should ensure that the
698  // spellings match exactly between the attributes, and if the arguments or
699  // subjects differ, should specify HasCustomParsing = 1 and implement their
700  // own parsing and semantic handling requirements as-needed.
701  string ParseKind;
702}
703
704/// An inheritable parameter attribute is inherited by later
705/// redeclarations, even when it's written on a parameter.
706class InheritableParamAttr : InheritableAttr;
707
708/// An attribute which changes the ABI rules for a specific parameter.
709class ParameterABIAttr : InheritableParamAttr {
710  let Subjects = SubjectList<[ParmVar]>;
711}
712
713/// An ignored attribute, which we parse but discard with no checking.
714class IgnoredAttr : Attr {
715  let Ignored = 1;
716  let ASTNode = 0;
717  let SemaHandler = 0;
718  let Documentation = [InternalOnly];
719}
720
721//
722// Attributes begin here
723//
724
725def AbiTag : Attr {
726  let Spellings = [GCC<"abi_tag", /*AllowInC*/0>];
727  let Args = [VariadicStringArgument<"Tags">];
728  let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag>;
729  let MeaningfulToClassTemplateDefinition = 1;
730  let Documentation = [AbiTagsDocs];
731}
732
733def AddressSpace : TypeAttr {
734  let Spellings = [Clang<"address_space">];
735  let Args = [IntArgument<"AddressSpace">];
736  let Documentation = [Undocumented];
737}
738
739def Alias : Attr {
740  let Spellings = [GCC<"alias">];
741  let Args = [StringArgument<"Aliasee">];
742  let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
743  let Documentation = [Undocumented];
744}
745
746def BuiltinAlias : Attr {
747  let Spellings = [CXX11<"clang", "builtin_alias">,
748                   C23<"clang", "builtin_alias">,
749                   GNU<"clang_builtin_alias">];
750  let Args = [IdentifierArgument<"BuiltinName">];
751  let Subjects = SubjectList<[Function], ErrorDiag>;
752  let Documentation = [BuiltinAliasDocs];
753}
754
755def ArmBuiltinAlias : InheritableAttr, TargetSpecificAttr<TargetAnyArm> {
756  let Spellings = [Clang<"__clang_arm_builtin_alias">];
757  let Args = [IdentifierArgument<"BuiltinName">];
758  let Subjects = SubjectList<[Function], ErrorDiag>;
759  let Documentation = [ArmBuiltinAliasDocs];
760}
761
762def Aligned : InheritableAttr {
763  let Spellings = [GCC<"aligned">, Declspec<"align">, CustomKeyword<"alignas">,
764                   CustomKeyword<"_Alignas">];
765  let Args = [AlignedArgument<"Alignment", 1>];
766  let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
767                   Accessor<"isC11", [CustomKeyword<"_Alignas">]>,
768                   Accessor<"isAlignas", [CustomKeyword<"alignas">,
769                                          CustomKeyword<"_Alignas">]>,
770                   Accessor<"isDeclspec",[Declspec<"align">]>];
771  let Documentation = [Undocumented];
772}
773
774def AlignValue : Attr {
775  let Spellings = [
776    // Unfortunately, this is semantically an assertion, not a directive
777    // (something else must ensure the alignment), so aligned_value is a
778    // probably a better name. We might want to add an aligned_value spelling in
779    // the future (and a corresponding C++ attribute), but this can be done
780    // later once we decide if we also want them to have slightly-different
781    // semantics than Intel's align_value.
782    //
783    // Does not get a [[]] spelling because the attribute is not exposed as such
784    // by Intel.
785    GNU<"align_value">
786    // Intel's compiler on Windows also supports:
787    // , Declspec<"align_value">
788  ];
789  let Args = [ExprArgument<"Alignment">];
790  let Subjects = SubjectList<[Var, TypedefName]>;
791  let Documentation = [AlignValueDocs];
792}
793
794def AlignMac68k : InheritableAttr {
795  // This attribute has no spellings as it is only ever created implicitly.
796  let Spellings = [];
797  let SemaHandler = 0;
798  let Documentation = [InternalOnly];
799}
800
801def AlignNatural : InheritableAttr {
802  // This attribute has no spellings as it is only ever created implicitly.
803  let Spellings = [];
804  let SemaHandler = 0;
805  let Documentation = [InternalOnly];
806}
807
808def AlwaysInline : DeclOrStmtAttr {
809  let Spellings = [GCC<"always_inline">, CXX11<"clang", "always_inline">,
810                   C23<"clang", "always_inline">, CustomKeyword<"__forceinline">];
811  let Accessors = [Accessor<"isClangAlwaysInline", [CXX11<"clang", "always_inline">,
812                                                    C23<"clang", "always_inline">]>];
813  let Subjects = SubjectList<[Function, Stmt], WarnDiag,
814                             "functions and statements">;
815  let Documentation = [AlwaysInlineDocs];
816}
817
818def Artificial : InheritableAttr {
819  let Spellings = [GCC<"artificial">];
820  let Subjects = SubjectList<[InlineFunction]>;
821  let Documentation = [ArtificialDocs];
822  let SimpleHandler = 1;
823}
824
825def XRayInstrument : InheritableAttr {
826  let Spellings = [Clang<"xray_always_instrument">,
827                   Clang<"xray_never_instrument">];
828  let Subjects = SubjectList<[Function, ObjCMethod]>;
829  let Accessors = [Accessor<"alwaysXRayInstrument",
830                     [Clang<"xray_always_instrument">]>,
831                   Accessor<"neverXRayInstrument",
832                     [Clang<"xray_never_instrument">]>];
833  let Documentation = [XRayDocs];
834  let SimpleHandler = 1;
835}
836
837def XRayLogArgs : InheritableAttr {
838  let Spellings = [Clang<"xray_log_args">];
839  let Subjects = SubjectList<[Function, ObjCMethod]>;
840  // This argument is a count not an index, so it has the same encoding (base
841  // 1 including C++ implicit this parameter) at the source and LLVM levels of
842  // representation, so ParamIdxArgument is inappropriate.  It is never used
843  // at the AST level of representation, so it never needs to be adjusted not
844  // to include any C++ implicit this parameter.  Thus, we just store it and
845  // use it as an unsigned that never needs adjustment.
846  let Args = [UnsignedArgument<"ArgumentCount">];
847  let Documentation = [XRayDocs];
848}
849
850def PatchableFunctionEntry
851    : InheritableAttr,
852      TargetSpecificAttr<TargetArch<
853          ["aarch64", "aarch64_be", "loongarch32", "loongarch64", "riscv32",
854           "riscv64", "x86", "x86_64"]>> {
855  let Spellings = [GCC<"patchable_function_entry">];
856  let Subjects = SubjectList<[Function, ObjCMethod]>;
857  let Args = [UnsignedArgument<"Count">, DefaultIntArgument<"Offset", 0>];
858  let Documentation = [PatchableFunctionEntryDocs];
859}
860
861def TLSModel : InheritableAttr {
862  let Spellings = [GCC<"tls_model">];
863  let Subjects = SubjectList<[TLSVar], ErrorDiag>;
864  let Args = [StringArgument<"Model">];
865  let Documentation = [TLSModelDocs];
866}
867
868def AnalyzerNoReturn : InheritableAttr {
869  // TODO: should this attribute be exposed with a [[]] spelling under the clang
870  // vendor namespace, or should it use a vendor namespace specific to the
871  // analyzer?
872  let Spellings = [GNU<"analyzer_noreturn">];
873  // TODO: Add subject list.
874  let Documentation = [Undocumented];
875}
876
877def Annotate : InheritableParamAttr {
878  let Spellings = [Clang<"annotate">];
879  let Args = [StringArgument<"Annotation">, VariadicExprArgument<"Args">];
880  // Ensure that the annotate attribute can be used with
881  // '#pragma clang attribute' even though it has no subject list.
882  let AdditionalMembers = [{
883  static AnnotateAttr *Create(ASTContext &Ctx, llvm::StringRef Annotation, \
884              const AttributeCommonInfo &CommonInfo) {
885    return AnnotateAttr::Create(Ctx, Annotation, nullptr, 0, CommonInfo);
886  }
887  static AnnotateAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Annotation, \
888              const AttributeCommonInfo &CommonInfo) {
889    return AnnotateAttr::CreateImplicit(Ctx, Annotation, nullptr, 0, CommonInfo);
890  }
891  }];
892  let PragmaAttributeSupport = 1;
893  let AcceptsExprPack = 1;
894  let Documentation = [Undocumented];
895}
896
897def AnnotateType : TypeAttr {
898  let Spellings = [CXX11<"clang", "annotate_type">, C23<"clang", "annotate_type">];
899  let Args = [StringArgument<"Annotation">, VariadicExprArgument<"Args">];
900  let HasCustomParsing = 1;
901  let AcceptsExprPack = 1;
902  let Documentation = [AnnotateTypeDocs];
903}
904
905def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> {
906  // NOTE: If you add any additional spellings, M68kInterrupt's,
907  // MSP430Interrupt's, MipsInterrupt's and AnyX86Interrupt's spellings
908  // must match.
909  let Spellings = [GCC<"interrupt">];
910  let Args = [EnumArgument<"Interrupt", "InterruptType",
911                           ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
912                           ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
913                           1>];
914  let ParseKind = "Interrupt";
915  let HasCustomParsing = 1;
916  let Documentation = [ARMInterruptDocs];
917}
918
919def AVRInterrupt : InheritableAttr, TargetSpecificAttr<TargetAVR> {
920  let Spellings = [GCC<"interrupt">];
921  let Subjects = SubjectList<[Function]>;
922  let ParseKind = "Interrupt";
923  let Documentation = [AVRInterruptDocs];
924}
925
926def AVRSignal : InheritableAttr, TargetSpecificAttr<TargetAVR> {
927  let Spellings = [GCC<"signal">];
928  let Subjects = SubjectList<[Function]>;
929  let Documentation = [AVRSignalDocs];
930}
931
932def AsmLabel : InheritableAttr {
933  let CanPrintOnLeft = 0;
934  let Spellings = [CustomKeyword<"asm">, CustomKeyword<"__asm__">];
935  let Args = [
936    // Label specifies the mangled name for the decl.
937    StringArgument<"Label">,
938
939    // IsLiteralLabel specifies whether the label is literal (i.e. suppresses
940    // the global C symbol prefix) or not. If not, the mangle-suppression prefix
941    // ('\01') is omitted from the decl name at the LLVM IR level.
942    //
943    // Non-literal labels are used by some external AST sources like LLDB.
944    BoolArgument<"IsLiteralLabel", /*optional=*/0, /*fake=*/1>
945  ];
946  let SemaHandler = 0;
947  let Documentation = [AsmLabelDocs];
948  let AdditionalMembers =
949[{
950bool isEquivalent(AsmLabelAttr *Other) const {
951  return getLabel() == Other->getLabel() && getIsLiteralLabel() == Other->getIsLiteralLabel();
952}
953}];
954}
955
956def Availability : InheritableAttr {
957  let Spellings = [Clang<"availability">];
958  let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
959              VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
960              BoolArgument<"unavailable">, StringArgument<"message">,
961              BoolArgument<"strict">, StringArgument<"replacement">,
962              IntArgument<"priority">];
963  let AdditionalMembers =
964[{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
965    return llvm::StringSwitch<llvm::StringRef>(Platform)
966             .Case("android", "Android")
967             .Case("fuchsia", "Fuchsia")
968             .Case("ios", "iOS")
969             .Case("macos", "macOS")
970             .Case("tvos", "tvOS")
971             .Case("watchos", "watchOS")
972             .Case("driverkit", "DriverKit")
973             .Case("ios_app_extension", "iOS (App Extension)")
974             .Case("macos_app_extension", "macOS (App Extension)")
975             .Case("tvos_app_extension", "tvOS (App Extension)")
976             .Case("watchos_app_extension", "watchOS (App Extension)")
977             .Case("maccatalyst", "macCatalyst")
978             .Case("maccatalyst_app_extension", "macCatalyst (App Extension)")
979             .Case("swift", "Swift")
980             .Case("shadermodel", "HLSL ShaderModel")
981             .Case("ohos", "OpenHarmony OS")
982             .Default(llvm::StringRef());
983}
984static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) {
985    return llvm::StringSwitch<llvm::StringRef>(Platform)
986             .Case("ios", "iOS")
987             .Case("macos", "macOS")
988             .Case("tvos", "tvOS")
989             .Case("watchos", "watchOS")
990             .Case("ios_app_extension", "iOSApplicationExtension")
991             .Case("macos_app_extension", "macOSApplicationExtension")
992             .Case("tvos_app_extension", "tvOSApplicationExtension")
993             .Case("watchos_app_extension", "watchOSApplicationExtension")
994             .Case("maccatalyst", "macCatalyst")
995             .Case("maccatalyst_app_extension", "macCatalystApplicationExtension")
996             .Case("zos", "z/OS")
997             .Case("shadermodel", "ShaderModel")
998             .Default(Platform);
999}
1000static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) {
1001    return llvm::StringSwitch<llvm::StringRef>(Platform)
1002             .Case("iOS", "ios")
1003             .Case("macOS", "macos")
1004             .Case("tvOS", "tvos")
1005             .Case("watchOS", "watchos")
1006             .Case("iOSApplicationExtension", "ios_app_extension")
1007             .Case("macOSApplicationExtension", "macos_app_extension")
1008             .Case("tvOSApplicationExtension", "tvos_app_extension")
1009             .Case("watchOSApplicationExtension", "watchos_app_extension")
1010             .Case("macCatalyst", "maccatalyst")
1011             .Case("macCatalystApplicationExtension", "maccatalyst_app_extension")
1012             .Case("ShaderModel", "shadermodel")
1013             .Default(Platform);
1014} }];
1015  let HasCustomParsing = 1;
1016  let InheritEvenIfAlreadyPresent = 1;
1017  let Subjects = SubjectList<[Named]>;
1018  let Documentation = [AvailabilityDocs];
1019}
1020
1021def ExternalSourceSymbol : InheritableAttr {
1022  let Spellings = [Clang<"external_source_symbol", /*allowInC=*/1,
1023                   /*version=*/20230206>];
1024  let Args = [StringArgument<"language", 1>,
1025              StringArgument<"definedIn", 1>,
1026              BoolArgument<"generatedDeclaration", 1>,
1027              StringArgument<"USR", 1>];
1028  let HasCustomParsing = 1;
1029  let Subjects = SubjectList<[Named]>;
1030  let Documentation = [ExternalSourceSymbolDocs];
1031}
1032
1033def Blocks : InheritableAttr {
1034  let Spellings = [Clang<"blocks">];
1035  let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
1036  let Documentation = [Undocumented];
1037}
1038
1039def Bounded : IgnoredAttr {
1040  // Does not have a [[]] spelling because the attribute is ignored.
1041  let Spellings = [GNU<"bounded">];
1042}
1043
1044def CarriesDependency : InheritableParamAttr {
1045  let Spellings = [GNU<"carries_dependency">,
1046                   CXX11<"","carries_dependency", 200809>];
1047  let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>;
1048  let Documentation = [CarriesDependencyDocs];
1049}
1050
1051def CDecl : DeclOrTypeAttr {
1052  let Spellings = [GCC<"cdecl">, CustomKeyword<"__cdecl">, CustomKeyword<"_cdecl">];
1053//  let Subjects = [Function, ObjCMethod];
1054  let Documentation = [Undocumented];
1055}
1056
1057// cf_audited_transfer indicates that the given function has been
1058// audited and has been marked with the appropriate cf_consumed and
1059// cf_returns_retained attributes.  It is generally applied by
1060// '#pragma clang arc_cf_code_audited' rather than explicitly.
1061def CFAuditedTransfer : InheritableAttr {
1062  let Spellings = [Clang<"cf_audited_transfer">];
1063  let Subjects = SubjectList<[Function], ErrorDiag>;
1064  let Documentation = [Undocumented];
1065  let SimpleHandler = 1;
1066}
1067
1068// cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
1069// It indicates that the function has unknown or unautomatable
1070// transfer semantics.
1071def CFUnknownTransfer : InheritableAttr {
1072  let Spellings = [Clang<"cf_unknown_transfer">];
1073  let Subjects = SubjectList<[Function], ErrorDiag>;
1074  let Documentation = [Undocumented];
1075  let SimpleHandler = 1;
1076}
1077def : MutualExclusions<[CFAuditedTransfer, CFUnknownTransfer]>;
1078
1079def CFReturnsRetained : InheritableAttr {
1080  let Spellings = [Clang<"cf_returns_retained">];
1081//  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1082  let Documentation = [RetainBehaviorDocs];
1083}
1084
1085def CFReturnsNotRetained : InheritableAttr {
1086  let Spellings = [Clang<"cf_returns_not_retained">];
1087//  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1088  let Documentation = [RetainBehaviorDocs];
1089}
1090
1091def CFConsumed : InheritableParamAttr {
1092  let Spellings = [Clang<"cf_consumed">];
1093  let Subjects = SubjectList<[ParmVar]>;
1094  let Documentation = [RetainBehaviorDocs];
1095}
1096
1097
1098// coro_only_destroy_when_complete indicates the coroutines whose return type
1099// is marked by coro_only_destroy_when_complete can only be destroyed when the
1100// coroutine completes. Then the space for the destroy functions can be saved.
1101def CoroOnlyDestroyWhenComplete : InheritableAttr {
1102  let Spellings = [Clang<"coro_only_destroy_when_complete">];
1103  let Subjects = SubjectList<[CXXRecord]>;
1104  let LangOpts = [CPlusPlus];
1105  let Documentation = [CoroOnlyDestroyWhenCompleteDocs];
1106  let SimpleHandler = 1;
1107}
1108
1109def CoroReturnType : InheritableAttr {
1110  let Spellings = [Clang<"coro_return_type">];
1111  let Subjects = SubjectList<[CXXRecord]>;
1112  let LangOpts = [CPlusPlus];
1113  let Documentation = [CoroReturnTypeAndWrapperDoc];
1114  let SimpleHandler = 1;
1115}
1116
1117def CoroWrapper : InheritableAttr {
1118  let Spellings = [Clang<"coro_wrapper">];
1119  let Subjects = SubjectList<[Function]>;
1120  let LangOpts = [CPlusPlus];
1121  let Documentation = [CoroReturnTypeAndWrapperDoc];
1122  let SimpleHandler = 1;
1123}
1124
1125def CoroLifetimeBound : InheritableAttr {
1126  let Spellings = [Clang<"coro_lifetimebound">];
1127  let Subjects = SubjectList<[CXXRecord]>;
1128  let LangOpts = [CPlusPlus];
1129  let Documentation = [CoroLifetimeBoundDoc];
1130  let SimpleHandler = 1;
1131}
1132
1133def CoroDisableLifetimeBound : InheritableAttr {
1134  let Spellings = [Clang<"coro_disable_lifetimebound">];
1135  let Subjects = SubjectList<[Function]>;
1136  let LangOpts = [CPlusPlus];
1137  let Documentation = [CoroLifetimeBoundDoc];
1138  let SimpleHandler = 1;
1139}
1140
1141// OSObject-based attributes.
1142def OSConsumed : InheritableParamAttr {
1143  let Spellings = [Clang<"os_consumed">];
1144  let Subjects = SubjectList<[ParmVar]>;
1145  let Documentation = [RetainBehaviorDocs];
1146}
1147
1148def OSReturnsRetained : InheritableAttr {
1149  let Spellings = [Clang<"os_returns_retained">];
1150  let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty, ParmVar]>;
1151  let Documentation = [RetainBehaviorDocs];
1152}
1153
1154def OSReturnsNotRetained : InheritableAttr {
1155  let Spellings = [Clang<"os_returns_not_retained">];
1156  let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty, ParmVar]>;
1157  let Documentation = [RetainBehaviorDocs];
1158}
1159
1160def OSReturnsRetainedOnZero : InheritableAttr {
1161  let Spellings = [Clang<"os_returns_retained_on_zero">];
1162  let Subjects = SubjectList<[ParmVar]>;
1163  let Documentation = [RetainBehaviorDocs];
1164}
1165
1166def OSReturnsRetainedOnNonZero : InheritableAttr {
1167  let Spellings = [Clang<"os_returns_retained_on_non_zero">];
1168  let Subjects = SubjectList<[ParmVar]>;
1169  let Documentation = [RetainBehaviorDocs];
1170}
1171
1172def OSConsumesThis : InheritableAttr {
1173  let Spellings = [Clang<"os_consumes_this">];
1174  let Subjects = SubjectList<[NonStaticCXXMethod]>;
1175  let Documentation = [RetainBehaviorDocs];
1176  let SimpleHandler = 1;
1177}
1178
1179def Cleanup : InheritableAttr {
1180  let Spellings = [GCC<"cleanup">];
1181  let Args = [DeclArgument<Function, "FunctionDecl">];
1182  let Subjects = SubjectList<[LocalVar]>;
1183  let Documentation = [CleanupDocs];
1184}
1185
1186def CmseNSEntry : InheritableAttr, TargetSpecificAttr<TargetARM> {
1187  let Spellings = [GNU<"cmse_nonsecure_entry">];
1188  let Subjects = SubjectList<[Function]>;
1189  let LangOpts = [Cmse];
1190  let Documentation = [ArmCmseNSEntryDocs];
1191}
1192
1193def CmseNSCall : TypeAttr, TargetSpecificAttr<TargetARM> {
1194  let Spellings = [GNU<"cmse_nonsecure_call">];
1195  let LangOpts = [Cmse];
1196  let Documentation = [ArmCmseNSCallDocs];
1197}
1198
1199def Cold : InheritableAttr {
1200  let Spellings = [GCC<"cold">];
1201  let Subjects = SubjectList<[Function]>;
1202  let Documentation = [ColdFunctionEntryDocs];
1203  let SimpleHandler = 1;
1204}
1205
1206def Common : InheritableAttr {
1207  let Spellings = [GCC<"common">];
1208  let Subjects = SubjectList<[Var]>;
1209  let Documentation = [Undocumented];
1210}
1211
1212def Const : InheritableAttr {
1213  let Spellings = [GCC<"const">, GCC<"__const">];
1214  let Documentation = [Undocumented];
1215  let SimpleHandler = 1;
1216}
1217
1218def ConstInit : InheritableAttr {
1219  // This attribute does not have a C [[]] spelling because it requires the
1220  // CPlusPlus language option.
1221  let Spellings = [CustomKeyword<"constinit">,
1222                   Clang<"require_constant_initialization", 0>];
1223  let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
1224  let Accessors = [Accessor<"isConstinit", [CustomKeyword<"constinit">]>];
1225  let Documentation = [ConstInitDocs];
1226  let LangOpts = [CPlusPlus];
1227  let SimpleHandler = 1;
1228}
1229
1230def Constructor : InheritableAttr {
1231  let Spellings = [GCC<"constructor">];
1232  let Args = [DefaultIntArgument<"Priority", 65535>];
1233  let Subjects = SubjectList<[Function]>;
1234  let Documentation = [CtorDtorDocs];
1235}
1236
1237def CPUSpecific : InheritableAttr {
1238  let Spellings = [Clang<"cpu_specific">, Declspec<"cpu_specific">];
1239  let Args = [VariadicIdentifierArgument<"Cpus">];
1240  let Subjects = SubjectList<[Function]>;
1241  let Documentation = [CPUSpecificCPUDispatchDocs];
1242  let AdditionalMembers = [{
1243    IdentifierInfo *getCPUName(unsigned Index) const {
1244      return *(cpus_begin() + Index);
1245    }
1246  }];
1247}
1248
1249def CPUDispatch : InheritableAttr {
1250  let Spellings = [Clang<"cpu_dispatch">, Declspec<"cpu_dispatch">];
1251  let Args = [VariadicIdentifierArgument<"Cpus">];
1252  let Subjects = SubjectList<[Function]>;
1253  let Documentation = [CPUSpecificCPUDispatchDocs];
1254}
1255
1256// CUDA attributes are spelled __attribute__((attr)) or __declspec(__attr__),
1257// and they do not receive a [[]] spelling.
1258def CUDAConstant : InheritableAttr {
1259  let Spellings = [GNU<"constant">, Declspec<"__constant__">];
1260  let Subjects = SubjectList<[Var]>;
1261  let LangOpts = [CUDA];
1262  let Documentation = [Undocumented];
1263}
1264
1265def CUDACudartBuiltin : IgnoredAttr {
1266  let Spellings = [GNU<"cudart_builtin">, Declspec<"__cudart_builtin__">];
1267  let LangOpts = [CUDA];
1268}
1269
1270def CUDADevice : InheritableAttr {
1271  let Spellings = [GNU<"device">, Declspec<"__device__">];
1272  let Subjects = SubjectList<[Function, Var]>;
1273  let LangOpts = [CUDA];
1274  let Documentation = [Undocumented];
1275}
1276
1277def CUDADeviceBuiltin : IgnoredAttr {
1278  let Spellings = [GNU<"device_builtin">, Declspec<"__device_builtin__">];
1279  let LangOpts = [CUDA];
1280}
1281
1282def CUDADeviceBuiltinSurfaceType : InheritableAttr {
1283  let Spellings = [GNU<"device_builtin_surface_type">,
1284                   Declspec<"__device_builtin_surface_type__">];
1285  let LangOpts = [CUDA];
1286  let Subjects = SubjectList<[CXXRecord]>;
1287  let Documentation = [CUDADeviceBuiltinSurfaceTypeDocs];
1288  let MeaningfulToClassTemplateDefinition = 1;
1289  let SimpleHandler = 1;
1290}
1291
1292def CUDADeviceBuiltinTextureType : InheritableAttr {
1293  let Spellings = [GNU<"device_builtin_texture_type">,
1294                   Declspec<"__device_builtin_texture_type__">];
1295  let LangOpts = [CUDA];
1296  let Subjects = SubjectList<[CXXRecord]>;
1297  let Documentation = [CUDADeviceBuiltinTextureTypeDocs];
1298  let MeaningfulToClassTemplateDefinition = 1;
1299  let SimpleHandler = 1;
1300}
1301def : MutualExclusions<[CUDADeviceBuiltinSurfaceType,
1302                        CUDADeviceBuiltinTextureType]>;
1303
1304def CUDAGlobal : InheritableAttr {
1305  let Spellings = [GNU<"global">, Declspec<"__global__">];
1306  let Subjects = SubjectList<[Function]>;
1307  let LangOpts = [CUDA];
1308  let Documentation = [Undocumented];
1309}
1310def : MutualExclusions<[CUDADevice, CUDAGlobal]>;
1311
1312def CUDAHost : InheritableAttr {
1313  let Spellings = [GNU<"host">, Declspec<"__host__">];
1314  let Subjects = SubjectList<[Function]>;
1315  let LangOpts = [CUDA];
1316  let Documentation = [Undocumented];
1317  let SimpleHandler = 1;
1318}
1319def : MutualExclusions<[CUDAGlobal, CUDAHost]>;
1320
1321def NVPTXKernel : InheritableAttr, TargetSpecificAttr<TargetNVPTX> {
1322  let Spellings = [Clang<"nvptx_kernel">];
1323  let Subjects = SubjectList<[Function]>;
1324  let Documentation = [Undocumented];
1325}
1326
1327def HIPManaged : InheritableAttr {
1328  let Spellings = [GNU<"managed">, Declspec<"__managed__">];
1329  let Subjects = SubjectList<[Var]>;
1330  let LangOpts = [HIP];
1331  let Documentation = [HIPManagedAttrDocs];
1332}
1333
1334def CUDAInvalidTarget : InheritableAttr {
1335  let Spellings = [];
1336  let Subjects = SubjectList<[Function]>;
1337  let LangOpts = [CUDA];
1338  let Documentation = [InternalOnly];
1339}
1340
1341def CUDALaunchBounds : InheritableAttr {
1342  let Spellings = [GNU<"launch_bounds">, Declspec<"__launch_bounds__">];
1343  let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>,
1344              ExprArgument<"MaxBlocks", 1>];
1345  let LangOpts = [CUDA];
1346  let Subjects = SubjectList<[ObjCMethod, FunctionLike]>;
1347  // An AST node is created for this attribute, but is not used by other parts
1348  // of the compiler. However, this node needs to exist in the AST because
1349  // non-LLVM backends may be relying on the attribute's presence.
1350  let Documentation = [Undocumented];
1351}
1352
1353def CUDAShared : InheritableAttr {
1354  let Spellings = [GNU<"shared">, Declspec<"__shared__">];
1355  let Subjects = SubjectList<[Var]>;
1356  let LangOpts = [CUDA];
1357  let Documentation = [Undocumented];
1358}
1359def : MutualExclusions<[CUDAConstant, CUDAShared, HIPManaged]>;
1360
1361def SYCLKernel : InheritableAttr {
1362  let Spellings = [Clang<"sycl_kernel">];
1363  let Subjects = SubjectList<[FunctionTmpl]>;
1364  let LangOpts = [SYCL];
1365  let Documentation = [SYCLKernelDocs];
1366}
1367
1368def SYCLSpecialClass: InheritableAttr {
1369  let Spellings = [Clang<"sycl_special_class">];
1370  let Subjects = SubjectList<[CXXRecord]>;
1371  let LangOpts = [SYCL];
1372  let Documentation = [SYCLSpecialClassDocs];
1373}
1374
1375def C11NoReturn : InheritableAttr {
1376  let Spellings = [CustomKeyword<"_Noreturn">];
1377  let Subjects = SubjectList<[Function], ErrorDiag>;
1378  let SemaHandler = 0;
1379  let Documentation = [C11NoReturnDocs];
1380}
1381
1382def CXX11NoReturn : InheritableAttr {
1383  let Spellings = [CXX11<"", "noreturn", 200809>,
1384                   C23<"", "noreturn", 202202>, C23<"", "_Noreturn", 202202>];
1385  let Subjects = SubjectList<[Function], ErrorDiag>;
1386  let Documentation = [CXX11NoReturnDocs];
1387}
1388
1389// Similar to CUDA, OpenCL attributes do not receive a [[]] spelling because
1390// the specification does not expose them with one currently.
1391def OpenCLKernel : InheritableAttr {
1392  let Spellings = [CustomKeyword<"__kernel">, CustomKeyword<"kernel">];
1393  let Subjects = SubjectList<[Function], ErrorDiag>;
1394  let Documentation = [Undocumented];
1395  let SimpleHandler = 1;
1396}
1397
1398def OpenCLUnrollHint : StmtAttr {
1399  let Spellings = [GNU<"opencl_unroll_hint">];
1400  let Subjects = SubjectList<[ForStmt, CXXForRangeStmt, WhileStmt, DoStmt],
1401                             ErrorDiag, "'for', 'while', and 'do' statements">;
1402  let Args = [UnsignedArgument<"UnrollHint", /*opt*/1>];
1403  let Documentation = [OpenCLUnrollHintDocs];
1404}
1405
1406def OpenCLIntelReqdSubGroupSize: InheritableAttr {
1407  let Spellings = [GNU<"intel_reqd_sub_group_size">];
1408  let Args = [UnsignedArgument<"SubGroupSize">];
1409  let Subjects = SubjectList<[Function], ErrorDiag>;
1410  let Documentation = [OpenCLIntelReqdSubGroupSizeDocs];
1411}
1412
1413// This attribute is both a type attribute, and a declaration attribute (for
1414// parameter variables).
1415def OpenCLAccess : Attr {
1416  let Spellings = [CustomKeyword<"__read_only">, CustomKeyword<"read_only">,
1417                   CustomKeyword<"__write_only">, CustomKeyword<"write_only">,
1418                   CustomKeyword<"__read_write">, CustomKeyword<"read_write">];
1419  let Subjects = SubjectList<[ParmVar, TypedefName], ErrorDiag>;
1420  let Accessors = [Accessor<"isReadOnly", [CustomKeyword<"__read_only">,
1421                                           CustomKeyword<"read_only">]>,
1422                   Accessor<"isReadWrite", [CustomKeyword<"__read_write">,
1423                                            CustomKeyword<"read_write">]>,
1424                   Accessor<"isWriteOnly", [CustomKeyword<"__write_only">,
1425                                            CustomKeyword<"write_only">]>];
1426  let Documentation = [OpenCLAccessDocs];
1427}
1428
1429def OpenCLPrivateAddressSpace : TypeAttr {
1430  let Spellings = [CustomKeyword<"__private">, CustomKeyword<"private">,
1431                   Clang<"opencl_private">];
1432  let Documentation = [OpenCLAddressSpacePrivateDocs];
1433}
1434
1435def OpenCLGlobalAddressSpace : TypeAttr {
1436  let Spellings = [CustomKeyword<"__global">, CustomKeyword<"global">,
1437                   Clang<"opencl_global">];
1438  let Documentation = [OpenCLAddressSpaceGlobalDocs];
1439}
1440
1441def OpenCLGlobalDeviceAddressSpace : TypeAttr {
1442  let Spellings = [Clang<"opencl_global_device">];
1443  let Documentation = [OpenCLAddressSpaceGlobalExtDocs];
1444}
1445
1446def OpenCLGlobalHostAddressSpace : TypeAttr {
1447  let Spellings = [Clang<"opencl_global_host">];
1448  let Documentation = [OpenCLAddressSpaceGlobalExtDocs];
1449}
1450
1451def OpenCLLocalAddressSpace : TypeAttr {
1452  let Spellings = [CustomKeyword<"__local">, CustomKeyword<"local">,
1453                   Clang<"opencl_local">];
1454  let Documentation = [OpenCLAddressSpaceLocalDocs];
1455}
1456
1457def OpenCLConstantAddressSpace : TypeAttr {
1458  let Spellings = [CustomKeyword<"__constant">, CustomKeyword<"constant">,
1459                   Clang<"opencl_constant">];
1460  let Documentation = [OpenCLAddressSpaceConstantDocs];
1461}
1462
1463def OpenCLGenericAddressSpace : TypeAttr {
1464  let Spellings = [CustomKeyword<"__generic">, CustomKeyword<"generic">,
1465                   Clang<"opencl_generic">];
1466  let Documentation = [OpenCLAddressSpaceGenericDocs];
1467}
1468
1469def OpenCLNoSVM : Attr {
1470  let Spellings = [GNU<"nosvm">];
1471  let Subjects = SubjectList<[Var]>;
1472  let Documentation = [OpenCLNoSVMDocs];
1473  let LangOpts = [OpenCL];
1474  let ASTNode = 0;
1475}
1476
1477def RenderScriptKernel : Attr {
1478  let Spellings = [GNU<"kernel">];
1479  let Subjects = SubjectList<[Function]>;
1480  let Documentation = [RenderScriptKernelAttributeDocs];
1481  let LangOpts = [RenderScript];
1482  let SimpleHandler = 1;
1483}
1484
1485def Deprecated : InheritableAttr {
1486  let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
1487                   CXX11<"","deprecated", 201309>,
1488                   C23<"", "deprecated", 201904>];
1489  let Args = [StringArgument<"Message", 1>,
1490              // An optional string argument that enables us to provide a
1491              // Fix-It.
1492              StringArgument<"Replacement", 1>];
1493  let MeaningfulToClassTemplateDefinition = 1;
1494  let Documentation = [DeprecatedDocs];
1495}
1496
1497def Destructor : InheritableAttr {
1498  let Spellings = [GCC<"destructor">];
1499  let Args = [DefaultIntArgument<"Priority", 65535>];
1500  let Subjects = SubjectList<[Function]>;
1501  let Documentation = [CtorDtorDocs];
1502}
1503
1504def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
1505  let Spellings = [Declspec<"empty_bases">];
1506  let Subjects = SubjectList<[CXXRecord]>;
1507  let Documentation = [EmptyBasesDocs];
1508  let SimpleHandler = 1;
1509}
1510
1511def AllocSize : InheritableAttr {
1512  let Spellings = [GCC<"alloc_size">];
1513  let Subjects = SubjectList<[HasFunctionProto]>;
1514  let Args = [ParamIdxArgument<"ElemSizeParam">,
1515              ParamIdxArgument<"NumElemsParam", /*opt*/ 1>];
1516  let TemplateDependent = 1;
1517  let Documentation = [AllocSizeDocs];
1518}
1519
1520def EnableIf : InheritableAttr {
1521  let CanPrintOnLeft = 0;
1522  // Does not have a [[]] spelling because this attribute requires the ability
1523  // to parse function arguments but the attribute is not written in the type
1524  // position.
1525  let Spellings = [GNU<"enable_if">];
1526  let Subjects = SubjectList<[Function]>;
1527  let Args = [ExprArgument<"Cond">, StringArgument<"Message">];
1528  let TemplateDependent = 1;
1529  let Documentation = [EnableIfDocs];
1530}
1531
1532def ExtVectorType : Attr {
1533  // This is an OpenCL-related attribute and does not receive a [[]] spelling.
1534  let Spellings = [GNU<"ext_vector_type">];
1535  // FIXME: This subject list is wrong; this is a type attribute.
1536  let Subjects = SubjectList<[TypedefName], ErrorDiag>;
1537  let Args = [ExprArgument<"NumElements">];
1538  let ASTNode = 0;
1539  let Documentation = [Undocumented];
1540  // This is a type attribute with an incorrect subject list, so should not be
1541  // permitted by #pragma clang attribute.
1542  let PragmaAttributeSupport = 0;
1543}
1544
1545def FallThrough : StmtAttr {
1546  let Spellings = [CXX11<"", "fallthrough", 201603>,
1547                   C23<"", "fallthrough", 201910>,
1548                   CXX11<"clang", "fallthrough">, GCC<"fallthrough">];
1549  // The attribute only applies to a NullStmt, but we have special fix-it
1550  // behavior if applied to a case label.
1551  let Subjects = SubjectList<[NullStmt, SwitchCase], ErrorDiag,
1552                             "empty statements">;
1553  let Documentation = [FallthroughDocs];
1554}
1555
1556def Likely : StmtAttr {
1557  let Spellings = [CXX11<"", "likely", 201803>, C23<"clang", "likely">];
1558  let Documentation = [LikelihoodDocs];
1559}
1560
1561def Unlikely : StmtAttr {
1562  let Spellings = [CXX11<"", "unlikely", 201803>, C23<"clang", "unlikely">];
1563  let Documentation = [LikelihoodDocs];
1564}
1565def : MutualExclusions<[Likely, Unlikely]>;
1566
1567def NoMerge : DeclOrStmtAttr {
1568  let Spellings = [Clang<"nomerge">];
1569  let Documentation = [NoMergeDocs];
1570  let Subjects = SubjectList<[Function, Stmt, Var], ErrorDiag,
1571                             "functions, statements and variables">;
1572}
1573
1574def MustTail : StmtAttr {
1575  let Spellings = [Clang<"musttail">];
1576  let Documentation = [MustTailDocs];
1577  let Subjects = SubjectList<[ReturnStmt], ErrorDiag, "return statements">;
1578}
1579
1580def FastCall : DeclOrTypeAttr {
1581  let Spellings = [GCC<"fastcall">, CustomKeyword<"__fastcall">,
1582                   CustomKeyword<"_fastcall">];
1583//  let Subjects = [Function, ObjCMethod];
1584  let Documentation = [FastCallDocs];
1585}
1586
1587def RegCall : DeclOrTypeAttr {
1588  let Spellings = [GCC<"regcall">, CustomKeyword<"__regcall">];
1589  let Documentation = [RegCallDocs];
1590}
1591
1592def Final : InheritableAttr {
1593  let CanPrintOnLeft = 0;
1594  let Spellings = [CustomKeyword<"final">, CustomKeyword<"sealed">];
1595  let Accessors = [Accessor<"isSpelledAsSealed", [CustomKeyword<"sealed">]>];
1596  let SemaHandler = 0;
1597  // Omitted from docs, since this is language syntax, not an attribute, as far
1598  // as users are concerned.
1599  let Documentation = [InternalOnly];
1600}
1601
1602def MinSize : InheritableAttr {
1603  let Spellings = [Clang<"minsize">];
1604  let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
1605  let Documentation = [MinSizeDocs];
1606}
1607
1608def FlagEnum : InheritableAttr {
1609  let Spellings = [Clang<"flag_enum">];
1610  let Subjects = SubjectList<[Enum]>;
1611  let Documentation = [FlagEnumDocs];
1612  let SimpleHandler = 1;
1613}
1614
1615def EnumExtensibility : InheritableAttr {
1616  let Spellings = [Clang<"enum_extensibility">];
1617  let Subjects = SubjectList<[Enum]>;
1618  let Args = [EnumArgument<"Extensibility", "Kind",
1619              ["closed", "open"], ["Closed", "Open"]>];
1620  let Documentation = [EnumExtensibilityDocs];
1621}
1622
1623def Flatten : InheritableAttr {
1624  let Spellings = [GCC<"flatten">];
1625  let Subjects = SubjectList<[Function], ErrorDiag>;
1626  let Documentation = [FlattenDocs];
1627  let SimpleHandler = 1;
1628}
1629
1630def Format : InheritableAttr {
1631  let Spellings = [GCC<"format">];
1632  let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
1633              IntArgument<"FirstArg">];
1634  let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto]>;
1635  let Documentation = [FormatDocs];
1636}
1637
1638def FormatArg : InheritableAttr {
1639  let Spellings = [GCC<"format_arg">];
1640  let Args = [ParamIdxArgument<"FormatIdx">];
1641  let Subjects = SubjectList<[ObjCMethod, HasFunctionProto]>;
1642  let Documentation = [Undocumented];
1643}
1644
1645def Callback : InheritableAttr {
1646  let Spellings = [Clang<"callback">];
1647  let Args = [VariadicParamOrParamIdxArgument<"Encoding">];
1648  let Subjects = SubjectList<[Function]>;
1649  let Documentation = [CallbackDocs];
1650}
1651
1652def GNUInline : InheritableAttr {
1653  let Spellings = [GCC<"gnu_inline">];
1654  let Subjects = SubjectList<[Function]>;
1655  let Documentation = [GnuInlineDocs];
1656}
1657
1658def Hot : InheritableAttr {
1659  let Spellings = [GCC<"hot">];
1660  let Subjects = SubjectList<[Function]>;
1661  let Documentation = [HotFunctionEntryDocs];
1662  let SimpleHandler = 1;
1663}
1664def : MutualExclusions<[Hot, Cold]>;
1665
1666def IBAction : InheritableAttr {
1667  let Spellings = [Clang<"ibaction">];
1668  let Subjects = SubjectList<[ObjCInstanceMethod]>;
1669  // An AST node is created for this attribute, but is not used by other parts
1670  // of the compiler. However, this node needs to exist in the AST because
1671  // external tools rely on it.
1672  let Documentation = [Undocumented];
1673  let SimpleHandler = 1;
1674}
1675
1676def IBOutlet : InheritableAttr {
1677  let Spellings = [Clang<"iboutlet">];
1678//  let Subjects = [ObjCIvar, ObjCProperty];
1679  let Documentation = [Undocumented];
1680}
1681
1682def IBOutletCollection : InheritableAttr {
1683  let Spellings = [Clang<"iboutletcollection">];
1684  let Args = [TypeArgument<"Interface", 1>];
1685//  let Subjects = [ObjCIvar, ObjCProperty];
1686  let Documentation = [Undocumented];
1687}
1688
1689def IFunc : Attr, TargetSpecificAttr<TargetELFOrMachO> {
1690  let Spellings = [GCC<"ifunc">];
1691  let Args = [StringArgument<"Resolver">];
1692  let Subjects = SubjectList<[Function]>;
1693  let Documentation = [IFuncDocs];
1694}
1695
1696def Restrict : InheritableAttr {
1697  let Spellings = [Declspec<"restrict">, GCC<"malloc">];
1698  let Subjects = SubjectList<[Function]>;
1699  let Documentation = [RestrictDocs];
1700}
1701
1702def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
1703  let Spellings = [Declspec<"layout_version">];
1704  let Args = [UnsignedArgument<"Version">];
1705  let Subjects = SubjectList<[CXXRecord]>;
1706  let Documentation = [LayoutVersionDocs];
1707}
1708
1709def Leaf : InheritableAttr {
1710  let Spellings = [GCC<"leaf">];
1711  let Subjects = SubjectList<[Function]>;
1712  let Documentation = [LeafDocs];
1713  let SimpleHandler = 1;
1714}
1715
1716def LifetimeBound : DeclOrTypeAttr {
1717  let Spellings = [Clang<"lifetimebound", 0>];
1718  let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;
1719  let Documentation = [LifetimeBoundDocs];
1720  let LangOpts = [CPlusPlus];
1721  let SimpleHandler = 1;
1722}
1723
1724def TrivialABI : InheritableAttr {
1725  // This attribute does not have a C [[]] spelling because it requires the
1726  // CPlusPlus language option.
1727  let Spellings = [Clang<"trivial_abi", 0>];
1728  let Subjects = SubjectList<[CXXRecord]>;
1729  let Documentation = [TrivialABIDocs];
1730  let LangOpts = [CPlusPlus];
1731  let SimpleHandler = 1;
1732}
1733
1734def MaxFieldAlignment : InheritableAttr {
1735  // This attribute has no spellings as it is only ever created implicitly.
1736  let Spellings = [];
1737  let Args = [UnsignedArgument<"Alignment">];
1738  let SemaHandler = 0;
1739  let Documentation = [InternalOnly];
1740}
1741
1742def MayAlias : InheritableAttr {
1743  // FIXME: this is a type attribute in GCC, but a declaration attribute here.
1744  let Spellings = [GCC<"may_alias">];
1745  let Documentation = [Undocumented];
1746  let SimpleHandler = 1;
1747}
1748
1749def MIGServerRoutine : InheritableAttr {
1750  let Spellings = [Clang<"mig_server_routine">];
1751  let Subjects = SubjectList<[Function, ObjCMethod, Block]>;
1752  let Documentation = [MIGConventionDocs];
1753}
1754
1755def MSABI : DeclOrTypeAttr {
1756  let Spellings = [GCC<"ms_abi">];
1757//  let Subjects = [Function, ObjCMethod];
1758  let Documentation = [MSABIDocs];
1759}
1760
1761def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
1762  // NOTE: If you add any additional spellings, ARMInterrupt's, M68kInterrupt's,
1763  // MipsInterrupt's and AnyX86Interrupt's spellings must match.
1764  let Spellings = [GCC<"interrupt">];
1765  let Args = [UnsignedArgument<"Number">];
1766  let ParseKind = "Interrupt";
1767  let HasCustomParsing = 1;
1768  let Documentation = [Undocumented];
1769}
1770
1771def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1772  let Spellings = [GCC<"mips16">];
1773  let Subjects = SubjectList<[Function], ErrorDiag>;
1774  let Documentation = [Undocumented];
1775  let SimpleHandler = 1;
1776}
1777
1778def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1779  // NOTE: If you add any additional spellings, ARMInterrupt's,
1780  // M68kInterrupt's, MSP430Interrupt's and AnyX86Interrupt's spellings
1781  // must match.
1782  let Spellings = [GCC<"interrupt">];
1783  let Subjects = SubjectList<[Function]>;
1784  let Args = [EnumArgument<"Interrupt", "InterruptType",
1785                           ["vector=sw0", "vector=sw1", "vector=hw0",
1786                            "vector=hw1", "vector=hw2", "vector=hw3",
1787                            "vector=hw4", "vector=hw5", "eic", ""],
1788                           ["sw0", "sw1", "hw0", "hw1", "hw2", "hw3",
1789                            "hw4", "hw5", "eic", "eic"]
1790                           >];
1791  let ParseKind = "Interrupt";
1792  let Documentation = [MipsInterruptDocs];
1793}
1794def : MutualExclusions<[Mips16, MipsInterrupt]>;
1795
1796def MicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1797  let Spellings = [GCC<"micromips">];
1798  let Subjects = SubjectList<[Function], ErrorDiag>;
1799  let Documentation = [MicroMipsDocs];
1800  let SimpleHandler = 1;
1801}
1802def : MutualExclusions<[Mips16, MicroMips]>;
1803
1804def MipsLongCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
1805  let Spellings = [GCC<"long_call">, GCC<"far">];
1806  let Subjects = SubjectList<[Function]>;
1807  let Documentation = [MipsLongCallStyleDocs];
1808  let SimpleHandler = 1;
1809}
1810
1811def MipsShortCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
1812  let Spellings = [GCC<"short_call">, GCC<"near">];
1813  let Subjects = SubjectList<[Function]>;
1814  let Documentation = [MipsShortCallStyleDocs];
1815  let SimpleHandler = 1;
1816}
1817def : MutualExclusions<[MipsLongCall, MipsShortCall]>;
1818
1819def M68kInterrupt : InheritableAttr, TargetSpecificAttr<TargetM68k> {
1820  // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's
1821  // MSP430Interrupt's and AnyX86Interrupt's spellings must match.
1822  let Spellings = [GNU<"interrupt">];
1823  let Args = [UnsignedArgument<"Number">];
1824  let ParseKind = "Interrupt";
1825  let HasCustomParsing = 1;
1826  let Documentation = [Undocumented];
1827}
1828
1829def Mode : Attr {
1830  let Spellings = [GCC<"mode">];
1831  let Subjects = SubjectList<[Var, Enum, TypedefName, Field], ErrorDiag>;
1832  let Args = [IdentifierArgument<"Mode">];
1833  let Documentation = [Undocumented];
1834  // This is notionally a type attribute, which #pragma clang attribute
1835  // generally does not support.
1836  let PragmaAttributeSupport = 0;
1837}
1838
1839def Naked : InheritableAttr {
1840  let Spellings = [GCC<"naked">, Declspec<"naked">];
1841  let Subjects = SubjectList<[Function]>;
1842  let Documentation = [Undocumented];
1843}
1844
1845def NeonPolyVectorType : TypeAttr {
1846  let Spellings = [Clang<"neon_polyvector_type">];
1847  let Args = [IntArgument<"NumElements">];
1848  let Documentation = [Undocumented];
1849  // Represented as VectorType instead.
1850  let ASTNode = 0;
1851}
1852
1853def NeonVectorType : TypeAttr {
1854  let Spellings = [Clang<"neon_vector_type">];
1855  let Args = [IntArgument<"NumElements">];
1856  let Documentation = [Undocumented];
1857  // Represented as VectorType instead.
1858  let ASTNode = 0;
1859}
1860
1861def ArmSveVectorBits : TypeAttr {
1862  let Spellings = [GNU<"arm_sve_vector_bits">];
1863  let Subjects = SubjectList<[TypedefName], ErrorDiag>;
1864  let Args = [UnsignedArgument<"NumBits">];
1865  let Documentation = [ArmSveVectorBitsDocs];
1866  let PragmaAttributeSupport = 0;
1867  // Represented as VectorType instead.
1868  let ASTNode = 0;
1869}
1870
1871def ArmMveStrictPolymorphism : TypeAttr, TargetSpecificAttr<TargetARM> {
1872  let Spellings = [Clang<"__clang_arm_mve_strict_polymorphism">];
1873  let Documentation = [ArmMveStrictPolymorphismDocs];
1874}
1875
1876def NoUniqueAddress : InheritableAttr {
1877  let Subjects = SubjectList<[NonBitField], ErrorDiag>;
1878  let Spellings = [CXX11<"", "no_unique_address", 201803>, CXX11<"msvc", "no_unique_address", 201803>];
1879  let TargetSpecificSpellings = [
1880    TargetSpecificSpelling<TargetItaniumCXXABI, [CXX11<"", "no_unique_address", 201803>]>,
1881    TargetSpecificSpelling<TargetMicrosoftCXXABI, [CXX11<"msvc", "no_unique_address", 201803>]>,
1882  ];
1883  let Documentation = [NoUniqueAddressDocs];
1884}
1885
1886def ReturnsTwice : InheritableAttr {
1887  let Spellings = [GCC<"returns_twice">];
1888  let Subjects = SubjectList<[Function]>;
1889  let Documentation = [Undocumented];
1890  let SimpleHandler = 1;
1891}
1892
1893def DisableTailCalls : InheritableAttr {
1894  let Spellings = [Clang<"disable_tail_calls">];
1895  let Subjects = SubjectList<[Function, ObjCMethod]>;
1896  let Documentation = [DisableTailCallsDocs];
1897  let SimpleHandler = 1;
1898}
1899def : MutualExclusions<[Naked, DisableTailCalls]>;
1900
1901def NoAlias : InheritableAttr {
1902  let Spellings = [Declspec<"noalias">];
1903  let Subjects = SubjectList<[Function]>;
1904  let Documentation = [NoAliasDocs];
1905  let SimpleHandler = 1;
1906}
1907
1908def NoCommon : InheritableAttr {
1909  let Spellings = [GCC<"nocommon">];
1910  let Subjects = SubjectList<[Var]>;
1911  let Documentation = [Undocumented];
1912  let SimpleHandler = 1;
1913}
1914
1915def NoDebug : InheritableAttr {
1916  let Spellings = [GCC<"nodebug">];
1917  let Subjects = SubjectList<[TypedefName, FunctionLike, ObjCMethod, NonParmVar]>;
1918  let Documentation = [NoDebugDocs];
1919}
1920
1921def StandaloneDebug : InheritableAttr {
1922  let Spellings = [Clang<"standalone_debug", /*allowInC =*/0>];
1923  let Subjects = SubjectList<[CXXRecord]>;
1924  let Documentation = [StandaloneDebugDocs];
1925  let SimpleHandler = 1;
1926  let LangOpts = [CPlusPlus];
1927}
1928
1929def NoDuplicate : InheritableAttr {
1930  let Spellings = [Clang<"noduplicate">];
1931  let Subjects = SubjectList<[Function]>;
1932  let Documentation = [NoDuplicateDocs];
1933  let SimpleHandler = 1;
1934}
1935
1936def Convergent : InheritableAttr {
1937  let Spellings = [Clang<"convergent">];
1938  let Subjects = SubjectList<[Function]>;
1939  let Documentation = [ConvergentDocs];
1940  let SimpleHandler = 1;
1941}
1942
1943def NoInline : DeclOrStmtAttr {
1944  let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">,
1945                   CXX11<"clang", "noinline">, C23<"clang", "noinline">,
1946                   Declspec<"noinline">];
1947  let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">,
1948                                                C23<"clang", "noinline">]>];
1949  let Documentation = [NoInlineDocs];
1950  let Subjects = SubjectList<[Function, Stmt], WarnDiag,
1951                             "functions and statements">;
1952  let SimpleHandler = 1;
1953}
1954
1955def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1956  let Spellings = [GCC<"nomips16">];
1957  let Subjects = SubjectList<[Function], ErrorDiag>;
1958  let Documentation = [Undocumented];
1959  let SimpleHandler = 1;
1960}
1961
1962def NoMicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1963  let Spellings = [GCC<"nomicromips">];
1964  let Subjects = SubjectList<[Function], ErrorDiag>;
1965  let Documentation = [MicroMipsDocs];
1966  let SimpleHandler = 1;
1967}
1968
1969def RISCVInterrupt : InheritableAttr, TargetSpecificAttr<TargetRISCV> {
1970  let Spellings = [GCC<"interrupt">];
1971  let Subjects = SubjectList<[Function]>;
1972  let Args = [EnumArgument<"Interrupt", "InterruptType",
1973                           ["supervisor", "machine"],
1974                           ["supervisor", "machine"],
1975                           1>];
1976  let ParseKind = "Interrupt";
1977  let Documentation = [RISCVInterruptDocs];
1978}
1979
1980def RISCVRVVVectorBits : TypeAttr {
1981  let Spellings = [GNU<"riscv_rvv_vector_bits">];
1982  let Subjects = SubjectList<[TypedefName], ErrorDiag>;
1983  let Args = [UnsignedArgument<"NumBits">];
1984  let Documentation = [RISCVRVVVectorBitsDocs];
1985  let PragmaAttributeSupport = 0;
1986  // Represented as VectorType instead.
1987  let ASTNode = 0;
1988}
1989
1990// This is not a TargetSpecificAttr so that is silently accepted and
1991// ignored on other targets as encouraged by the OpenCL spec.
1992//
1993// See OpenCL 1.2 6.11.5: "It is our intention that a particular
1994// implementation of OpenCL be free to ignore all attributes and the
1995// resulting executable binary will produce the same result."
1996//
1997// However, only AMD GPU targets will emit the corresponding IR
1998// attribute.
1999//
2000// FIXME: This provides a sub-optimal error message if you attempt to
2001// use this in CUDA, since CUDA does not use the same terminology.
2002//
2003// FIXME: SubjectList should be for OpenCLKernelFunction, but is not to
2004// workaround needing to see kernel attribute before others to know if
2005// this should be rejected on non-kernels.
2006
2007def AMDGPUFlatWorkGroupSize : InheritableAttr {
2008  let Spellings = [Clang<"amdgpu_flat_work_group_size", 0>];
2009  let Args = [ExprArgument<"Min">, ExprArgument<"Max">];
2010  let Documentation = [AMDGPUFlatWorkGroupSizeDocs];
2011  let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
2012}
2013
2014def AMDGPUWavesPerEU : InheritableAttr {
2015  let Spellings = [Clang<"amdgpu_waves_per_eu", 0>];
2016  let Args = [ExprArgument<"Min">, ExprArgument<"Max", 1>];
2017  let Documentation = [AMDGPUWavesPerEUDocs];
2018  let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
2019}
2020
2021def AMDGPUNumSGPR : InheritableAttr {
2022  let Spellings = [Clang<"amdgpu_num_sgpr", 0>];
2023  let Args = [UnsignedArgument<"NumSGPR">];
2024  let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
2025  let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
2026}
2027
2028def AMDGPUNumVGPR : InheritableAttr {
2029  let Spellings = [Clang<"amdgpu_num_vgpr", 0>];
2030  let Args = [UnsignedArgument<"NumVGPR">];
2031  let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
2032  let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
2033}
2034
2035def AMDGPUKernelCall : DeclOrTypeAttr {
2036  let Spellings = [Clang<"amdgpu_kernel">];
2037  let Documentation = [Undocumented];
2038}
2039
2040def BPFPreserveAccessIndex : InheritableAttr,
2041                             TargetSpecificAttr<TargetBPF>  {
2042  let Spellings = [Clang<"preserve_access_index">];
2043  let Subjects = SubjectList<[Record], ErrorDiag>;
2044  let Documentation = [BPFPreserveAccessIndexDocs];
2045  let LangOpts = [COnly];
2046}
2047
2048def BPFPreserveStaticOffset : InheritableAttr,
2049                              TargetSpecificAttr<TargetBPF>  {
2050  let Spellings = [Clang<"preserve_static_offset">];
2051  let Subjects = SubjectList<[Record], ErrorDiag>;
2052  let Documentation = [BPFPreserveStaticOffsetDocs];
2053  let LangOpts = [COnly];
2054}
2055
2056def BTFDeclTag : InheritableAttr {
2057  let Spellings = [Clang<"btf_decl_tag">];
2058  let Args = [StringArgument<"BTFDeclTag">];
2059  let Subjects = SubjectList<[Var, Function, Record, Field, TypedefName],
2060                             ErrorDiag>;
2061  let Documentation = [BTFDeclTagDocs];
2062  let LangOpts = [COnly];
2063}
2064
2065def BTFTypeTag : TypeAttr {
2066  let Spellings = [Clang<"btf_type_tag">];
2067  let Args = [StringArgument<"BTFTypeTag">];
2068  let Documentation = [BTFTypeTagDocs];
2069  let LangOpts = [COnly];
2070}
2071
2072def WebAssemblyExportName : InheritableAttr,
2073                            TargetSpecificAttr<TargetWebAssembly> {
2074  let Spellings = [Clang<"export_name">];
2075  let Args = [StringArgument<"ExportName">];
2076  let Documentation = [WebAssemblyExportNameDocs];
2077  let Subjects = SubjectList<[Function], ErrorDiag>;
2078}
2079
2080def WebAssemblyImportModule : InheritableAttr,
2081                              TargetSpecificAttr<TargetWebAssembly> {
2082  let Spellings = [Clang<"import_module">];
2083  let Args = [StringArgument<"ImportModule">];
2084  let Documentation = [WebAssemblyImportModuleDocs];
2085  let Subjects = SubjectList<[Function], ErrorDiag>;
2086}
2087
2088def WebAssemblyImportName : InheritableAttr,
2089                            TargetSpecificAttr<TargetWebAssembly> {
2090  let Spellings = [Clang<"import_name">];
2091  let Args = [StringArgument<"ImportName">];
2092  let Documentation = [WebAssemblyImportNameDocs];
2093  let Subjects = SubjectList<[Function], ErrorDiag>;
2094}
2095
2096def NoSplitStack : InheritableAttr {
2097  let Spellings = [GCC<"no_split_stack">];
2098  let Subjects = SubjectList<[Function], ErrorDiag>;
2099  let Documentation = [NoSplitStackDocs];
2100  let SimpleHandler = 1;
2101}
2102
2103def NonNull : InheritableParamAttr {
2104  let Spellings = [GCC<"nonnull">];
2105  let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
2106                             "functions, methods, and parameters">;
2107  let Args = [VariadicParamIdxArgument<"Args">];
2108  let AdditionalMembers = [{
2109    bool isNonNull(unsigned IdxAST) const {
2110      if (!args_size())
2111        return true;
2112      return llvm::any_of(args(), [=](const ParamIdx &Idx) {
2113        return Idx.getASTIndex() == IdxAST;
2114      });
2115    }
2116  }];
2117  // FIXME: We should merge duplicates into a single nonnull attribute.
2118  let InheritEvenIfAlreadyPresent = 1;
2119  let Documentation = [NonNullDocs];
2120}
2121
2122def ReturnsNonNull : InheritableAttr {
2123  let Spellings = [GCC<"returns_nonnull">];
2124  let Subjects = SubjectList<[ObjCMethod, Function]>;
2125  let Documentation = [ReturnsNonNullDocs];
2126}
2127
2128def CalledOnce : Attr {
2129  let Spellings = [Clang<"called_once">];
2130  let Subjects = SubjectList<[ParmVar]>;
2131  let LangOpts = [ObjC];
2132  let Documentation = [CalledOnceDocs];
2133}
2134
2135// pass_object_size(N) indicates that the parameter should have
2136// __builtin_object_size with Type=N evaluated on the parameter at the callsite.
2137def PassObjectSize : InheritableParamAttr {
2138  let Spellings = [Clang<"pass_object_size">,
2139                   Clang<"pass_dynamic_object_size">];
2140  let Accessors = [Accessor<"isDynamic", [Clang<"pass_dynamic_object_size">]>];
2141  let Args = [IntArgument<"Type">];
2142  let Subjects = SubjectList<[ParmVar]>;
2143  let Documentation = [PassObjectSizeDocs];
2144}
2145
2146// Nullability type attributes.
2147def TypeNonNull : TypeAttr {
2148  let Spellings = [CustomKeyword<"_Nonnull">];
2149  let Documentation = [TypeNonNullDocs];
2150}
2151
2152def TypeNullable : TypeAttr {
2153  let Spellings = [CustomKeyword<"_Nullable">];
2154  let Documentation = [TypeNullableDocs];
2155}
2156
2157def TypeNullableResult : TypeAttr {
2158  let Spellings = [CustomKeyword<"_Nullable_result">];
2159  let Documentation = [TypeNullableResultDocs];
2160}
2161
2162def TypeNullUnspecified : TypeAttr {
2163  let Spellings = [CustomKeyword<"_Null_unspecified">];
2164  let Documentation = [TypeNullUnspecifiedDocs];
2165}
2166
2167// This is a marker used to indicate that an __unsafe_unretained qualifier was
2168// ignored because ARC is not enabled. The usual representation for this
2169// qualifier is as an ObjCOwnership attribute with Kind == "none".
2170def ObjCInertUnsafeUnretained : TypeAttr {
2171  let Spellings = [CustomKeyword<"__unsafe_unretained">];
2172  let Documentation = [InternalOnly];
2173}
2174
2175def ObjCKindOf : TypeAttr {
2176  let Spellings = [CustomKeyword<"__kindof">];
2177  let Documentation = [Undocumented];
2178}
2179
2180def NoEscape : Attr {
2181  let Spellings = [Clang<"noescape">];
2182  let Subjects = SubjectList<[ParmVar]>;
2183  let Documentation = [NoEscapeDocs];
2184}
2185
2186def MaybeUndef : InheritableAttr {
2187  let Spellings = [Clang<"maybe_undef">];
2188  let Subjects = SubjectList<[ParmVar]>;
2189  let Documentation = [MaybeUndefDocs];
2190  let SimpleHandler = 1;
2191}
2192
2193def AssumeAligned : InheritableAttr {
2194  let Spellings = [GCC<"assume_aligned">];
2195  let Subjects = SubjectList<[ObjCMethod, Function]>;
2196  let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>];
2197  let Documentation = [AssumeAlignedDocs];
2198}
2199
2200def AllocAlign : InheritableAttr {
2201  let Spellings = [GCC<"alloc_align">];
2202  let Subjects = SubjectList<[HasFunctionProto]>;
2203  let Args = [ParamIdxArgument<"ParamIndex">];
2204  let Documentation = [AllocAlignDocs];
2205}
2206
2207def NoReturn : InheritableAttr {
2208  let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
2209  // FIXME: Does GCC allow this on the function instead?
2210  let Documentation = [Undocumented];
2211}
2212
2213def NoInstrumentFunction : InheritableAttr {
2214  let Spellings = [GCC<"no_instrument_function">];
2215  let Subjects = SubjectList<[Function, ObjCMethod]>;
2216  let Documentation = [Undocumented];
2217  let SimpleHandler = 1;
2218}
2219
2220def NoProfileFunction : InheritableAttr {
2221  let Spellings = [GCC<"no_profile_instrument_function">];
2222  let Subjects = SubjectList<[Function]>;
2223  let Documentation = [NoProfileInstrumentFunctionDocs];
2224  let SimpleHandler = 1;
2225}
2226
2227def NotTailCalled : InheritableAttr {
2228  let Spellings = [Clang<"not_tail_called">];
2229  let Subjects = SubjectList<[Function]>;
2230  let Documentation = [NotTailCalledDocs];
2231  let SimpleHandler = 1;
2232}
2233def : MutualExclusions<[AlwaysInline, NotTailCalled]>;
2234
2235def NoStackProtector : InheritableAttr {
2236  let Spellings = [Clang<"no_stack_protector">, CXX11<"gnu", "no_stack_protector">,
2237                   C23<"gnu", "no_stack_protector">, Declspec<"safebuffers">];
2238  let Subjects = SubjectList<[Function]>;
2239  let Documentation = [NoStackProtectorDocs];
2240  let SimpleHandler = 1;
2241}
2242
2243def StrictGuardStackCheck : InheritableAttr {
2244  let Spellings = [Declspec<"strict_gs_check">];
2245  let Subjects = SubjectList<[Function]>;
2246  let Documentation = [StrictGuardStackCheckDocs];
2247  let SimpleHandler = 1;
2248}
2249
2250def NoThrow : InheritableAttr {
2251  let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
2252  let Subjects = SubjectList<[FunctionLike]>;
2253  let Documentation = [NoThrowDocs];
2254}
2255
2256def NoUwtable : InheritableAttr {
2257  let Spellings = [Clang<"nouwtable">];
2258  let Subjects = SubjectList<[FunctionLike]>;
2259  let Documentation = [NoUwtableDocs];
2260  let SimpleHandler = 1;
2261}
2262
2263def NvWeak : IgnoredAttr {
2264  // No Declspec spelling of this attribute; the CUDA headers use
2265  // __attribute__((nv_weak)) unconditionally. Does not receive an [[]]
2266  // spelling because it is a CUDA attribute.
2267  let Spellings = [GNU<"nv_weak">];
2268  let LangOpts = [CUDA];
2269}
2270
2271def ObjCBridge : InheritableAttr {
2272  let Spellings = [Clang<"objc_bridge">];
2273  let Subjects = SubjectList<[Record, TypedefName], ErrorDiag>;
2274  let Args = [IdentifierArgument<"BridgedType">];
2275  let Documentation = [Undocumented];
2276}
2277
2278def ObjCBridgeMutable : InheritableAttr {
2279  let Spellings = [Clang<"objc_bridge_mutable">];
2280  let Subjects = SubjectList<[Record], ErrorDiag>;
2281  let Args = [IdentifierArgument<"BridgedType">];
2282  let Documentation = [Undocumented];
2283}
2284
2285def ObjCBridgeRelated : InheritableAttr {
2286  let Spellings = [Clang<"objc_bridge_related">];
2287  let Subjects = SubjectList<[Record], ErrorDiag>;
2288  let Args = [IdentifierArgument<"RelatedClass">,
2289          IdentifierArgument<"ClassMethod">,
2290          IdentifierArgument<"InstanceMethod">];
2291  let HasCustomParsing = 1;
2292  let Documentation = [Undocumented];
2293}
2294
2295def NSErrorDomain : InheritableAttr {
2296  let Spellings = [GNU<"ns_error_domain">];
2297  let Subjects = SubjectList<[Enum], ErrorDiag>;
2298  let Args = [IdentifierArgument<"ErrorDomain">];
2299  let Documentation = [NSErrorDomainDocs];
2300}
2301
2302def NSReturnsRetained : DeclOrTypeAttr {
2303  let Spellings = [Clang<"ns_returns_retained">];
2304//  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
2305  let Documentation = [RetainBehaviorDocs];
2306}
2307
2308def NSReturnsNotRetained : InheritableAttr {
2309  let Spellings = [Clang<"ns_returns_not_retained">];
2310//  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
2311  let Documentation = [RetainBehaviorDocs];
2312}
2313
2314def NSReturnsAutoreleased : InheritableAttr {
2315  let Spellings = [Clang<"ns_returns_autoreleased">];
2316//  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
2317  let Documentation = [RetainBehaviorDocs];
2318}
2319
2320def NSConsumesSelf : InheritableAttr {
2321  let Spellings = [Clang<"ns_consumes_self">];
2322  let Subjects = SubjectList<[ObjCMethod]>;
2323  let Documentation = [RetainBehaviorDocs];
2324  let SimpleHandler = 1;
2325}
2326
2327def NSConsumed : InheritableParamAttr {
2328  let Spellings = [Clang<"ns_consumed">];
2329  let Subjects = SubjectList<[ParmVar]>;
2330  let Documentation = [RetainBehaviorDocs];
2331}
2332
2333def ObjCException : InheritableAttr {
2334  let Spellings = [Clang<"objc_exception">];
2335  let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
2336  let Documentation = [Undocumented];
2337  let SimpleHandler = 1;
2338}
2339
2340def ObjCMethodFamily : InheritableAttr {
2341  let Spellings = [Clang<"objc_method_family">];
2342  let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
2343  let Args = [EnumArgument<"Family", "FamilyKind",
2344               ["none", "alloc", "copy", "init", "mutableCopy", "new"],
2345               ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
2346                "OMF_mutableCopy", "OMF_new"]>];
2347  let Documentation = [ObjCMethodFamilyDocs];
2348}
2349
2350def ObjCNSObject : InheritableAttr {
2351  let Spellings = [Clang<"NSObject">];
2352  let Documentation = [Undocumented];
2353}
2354
2355def ObjCIndependentClass : InheritableAttr {
2356  let Spellings = [Clang<"objc_independent_class">];
2357  let Documentation = [Undocumented];
2358}
2359
2360def ObjCPreciseLifetime : InheritableAttr {
2361  let Spellings = [Clang<"objc_precise_lifetime">];
2362  let Subjects = SubjectList<[Var], ErrorDiag>;
2363  let Documentation = [Undocumented];
2364}
2365
2366def ObjCReturnsInnerPointer : InheritableAttr {
2367  let Spellings = [Clang<"objc_returns_inner_pointer">];
2368  let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
2369  let Documentation = [Undocumented];
2370}
2371
2372def ObjCRequiresSuper : InheritableAttr {
2373  let Spellings = [Clang<"objc_requires_super">];
2374  let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
2375  let Documentation = [ObjCRequiresSuperDocs];
2376}
2377
2378def ObjCRootClass : InheritableAttr {
2379  let Spellings = [Clang<"objc_root_class">];
2380  let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
2381  let Documentation = [Undocumented];
2382  let SimpleHandler = 1;
2383}
2384
2385def ObjCNonLazyClass : Attr {
2386  let Spellings = [Clang<"objc_nonlazy_class">];
2387  let Subjects = SubjectList<[ObjCInterface, ObjCImpl], ErrorDiag>;
2388  let LangOpts = [ObjC];
2389  let Documentation = [ObjCNonLazyClassDocs];
2390  let SimpleHandler = 1;
2391}
2392
2393def ObjCSubclassingRestricted : InheritableAttr {
2394  let Spellings = [Clang<"objc_subclassing_restricted">];
2395  let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
2396  let Documentation = [ObjCSubclassingRestrictedDocs];
2397  let SimpleHandler = 1;
2398}
2399
2400def ObjCExplicitProtocolImpl : InheritableAttr {
2401  let Spellings = [Clang<"objc_protocol_requires_explicit_implementation">];
2402  let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
2403  let Documentation = [Undocumented];
2404}
2405
2406def ObjCDesignatedInitializer : Attr {
2407  let Spellings = [Clang<"objc_designated_initializer">];
2408  let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
2409  let Documentation = [Undocumented];
2410}
2411
2412def ObjCDirect : Attr {
2413  let Spellings = [Clang<"objc_direct">];
2414  let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
2415  let LangOpts = [ObjC];
2416  let Documentation = [ObjCDirectDocs];
2417}
2418
2419def ObjCDirectMembers : Attr {
2420  let Spellings = [Clang<"objc_direct_members">];
2421  let Subjects = SubjectList<[ObjCImpl, ObjCInterface, ObjCCategory], ErrorDiag>;
2422  let LangOpts = [ObjC];
2423  let Documentation = [ObjCDirectMembersDocs];
2424}
2425
2426def ObjCNonRuntimeProtocol : Attr {
2427  let Spellings = [Clang<"objc_non_runtime_protocol">];
2428  let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
2429  let LangOpts = [ObjC];
2430  let Documentation = [ObjCNonRuntimeProtocolDocs];
2431  let SimpleHandler = 1;
2432}
2433
2434def ObjCRuntimeName : Attr {
2435  let Spellings = [Clang<"objc_runtime_name">];
2436  let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
2437  let Args = [StringArgument<"MetadataName">];
2438  let Documentation = [ObjCRuntimeNameDocs];
2439}
2440
2441def ObjCRuntimeVisible : Attr {
2442  let Spellings = [Clang<"objc_runtime_visible">];
2443  let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
2444  let Documentation = [ObjCRuntimeVisibleDocs];
2445  let SimpleHandler = 1;
2446}
2447
2448def ObjCClassStub : Attr {
2449  let Spellings = [Clang<"objc_class_stub">];
2450  let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
2451  let Documentation = [ObjCClassStubDocs];
2452  let LangOpts = [ObjCNonFragileRuntime];
2453  let SimpleHandler = 1;
2454}
2455
2456def ObjCBoxable : Attr {
2457  let Spellings = [Clang<"objc_boxable">];
2458  let Subjects = SubjectList<[Record], ErrorDiag>;
2459  let Documentation = [ObjCBoxableDocs];
2460}
2461
2462def OptimizeNone : InheritableAttr {
2463  let Spellings = [Clang<"optnone">];
2464  let Subjects = SubjectList<[Function, ObjCMethod]>;
2465  let Documentation = [OptnoneDocs];
2466}
2467
2468def Overloadable : Attr {
2469  let Spellings = [Clang<"overloadable">];
2470  let Subjects = SubjectList<[Function], ErrorDiag>;
2471  let Documentation = [OverloadableDocs];
2472  let SimpleHandler = 1;
2473}
2474
2475def Override : InheritableAttr {
2476  let CanPrintOnLeft = 0;
2477  let Spellings = [CustomKeyword<"override">];
2478  let SemaHandler = 0;
2479  // Omitted from docs, since this is language syntax, not an attribute, as far
2480  // as users are concerned.
2481  let Documentation = [InternalOnly];
2482}
2483
2484def Ownership : InheritableAttr {
2485  let Spellings = [Clang<"ownership_holds">, Clang<"ownership_returns">,
2486                   Clang<"ownership_takes">];
2487  let Accessors = [Accessor<"isHolds", [Clang<"ownership_holds">]>,
2488                   Accessor<"isReturns", [Clang<"ownership_returns">]>,
2489                   Accessor<"isTakes", [Clang<"ownership_takes">]>];
2490  let AdditionalMembers = [{
2491    enum OwnershipKind { Holds, Returns, Takes };
2492    OwnershipKind getOwnKind() const {
2493      return isHolds() ? Holds :
2494             isTakes() ? Takes :
2495             Returns;
2496    }
2497  }];
2498  let Args = [IdentifierArgument<"Module">,
2499              VariadicParamIdxArgument<"Args">];
2500  let Subjects = SubjectList<[HasFunctionProto]>;
2501  let Documentation = [Undocumented];
2502}
2503
2504def Packed : InheritableAttr {
2505  let Spellings = [GCC<"packed">];
2506//  let Subjects = [Tag, Field];
2507  let Documentation = [Undocumented];
2508}
2509
2510def IntelOclBicc : DeclOrTypeAttr {
2511  let Spellings = [Clang<"intel_ocl_bicc", 0>];
2512//  let Subjects = [Function, ObjCMethod];
2513  let Documentation = [Undocumented];
2514}
2515
2516def Pcs : DeclOrTypeAttr {
2517  let Spellings = [GCC<"pcs">];
2518  let Args = [EnumArgument<"PCS", "PCSType",
2519                           ["aapcs", "aapcs-vfp"],
2520                           ["AAPCS", "AAPCS_VFP"]>];
2521//  let Subjects = [Function, ObjCMethod];
2522  let Documentation = [PcsDocs];
2523}
2524
2525def AArch64VectorPcs: DeclOrTypeAttr {
2526  let Spellings = [Clang<"aarch64_vector_pcs">];
2527  let Documentation = [AArch64VectorPcsDocs];
2528}
2529
2530def AArch64SVEPcs: DeclOrTypeAttr {
2531  let Spellings = [Clang<"aarch64_sve_pcs">];
2532  let Documentation = [AArch64SVEPcsDocs];
2533}
2534
2535def ArmStreaming : TypeAttr, TargetSpecificAttr<TargetAArch64> {
2536  let Spellings = [RegularKeyword<"__arm_streaming">];
2537  let Subjects = SubjectList<[HasFunctionProto], ErrorDiag>;
2538  let Documentation = [ArmSmeStreamingDocs];
2539}
2540
2541def ArmStreamingCompatible : TypeAttr, TargetSpecificAttr<TargetAArch64> {
2542  let Spellings = [RegularKeyword<"__arm_streaming_compatible">];
2543  let Subjects = SubjectList<[HasFunctionProto], ErrorDiag>;
2544  let Documentation = [ArmSmeStreamingCompatibleDocs];
2545}
2546
2547def ArmNew : InheritableAttr, TargetSpecificAttr<TargetAArch64> {
2548  let Spellings = [RegularKeyword<"__arm_new">];
2549  let Args = [VariadicStringArgument<"NewArgs">];
2550  let Subjects = SubjectList<[Function], ErrorDiag>;
2551  let Documentation = [ArmNewDocs];
2552
2553  let AdditionalMembers = [{
2554    bool isNewZA() const {
2555      return llvm::is_contained(newArgs(), "za");
2556    }
2557    bool isNewZT0() const {
2558      return llvm::is_contained(newArgs(), "zt0");
2559    }
2560  }];
2561}
2562
2563def ArmIn : TypeAttr, TargetSpecificAttr<TargetAArch64> {
2564  let Spellings = [RegularKeyword<"__arm_in">];
2565  let Args = [VariadicStringArgument<"InArgs">];
2566  let Subjects = SubjectList<[HasFunctionProto], ErrorDiag>;
2567  let Documentation = [ArmInDocs];
2568}
2569
2570def ArmOut : TypeAttr, TargetSpecificAttr<TargetAArch64> {
2571  let Spellings = [RegularKeyword<"__arm_out">];
2572  let Args = [VariadicStringArgument<"OutArgs">];
2573  let Subjects = SubjectList<[HasFunctionProto], ErrorDiag>;
2574  let Documentation = [ArmOutDocs];
2575}
2576
2577def ArmInOut : TypeAttr, TargetSpecificAttr<TargetAArch64> {
2578  let Spellings = [RegularKeyword<"__arm_inout">];
2579  let Args = [VariadicStringArgument<"InOutArgs">];
2580  let Subjects = SubjectList<[HasFunctionProto], ErrorDiag>;
2581  let Documentation = [ArmInOutDocs];
2582}
2583
2584def ArmPreserves : TypeAttr, TargetSpecificAttr<TargetAArch64> {
2585  let Spellings = [RegularKeyword<"__arm_preserves">];
2586  let Args = [VariadicStringArgument<"PreserveArgs">];
2587  let Subjects = SubjectList<[HasFunctionProto], ErrorDiag>;
2588  let Documentation = [ArmPreservesDocs];
2589}
2590
2591def ArmLocallyStreaming : InheritableAttr, TargetSpecificAttr<TargetAArch64> {
2592  let Spellings = [RegularKeyword<"__arm_locally_streaming">];
2593  let Subjects = SubjectList<[Function], ErrorDiag>;
2594  let Documentation = [ArmSmeLocallyStreamingDocs];
2595}
2596
2597
2598def Pure : InheritableAttr {
2599  let Spellings = [GCC<"pure">];
2600  let Documentation = [Undocumented];
2601  let SimpleHandler = 1;
2602}
2603
2604def Regparm : TypeAttr {
2605  let Spellings = [GCC<"regparm">];
2606  let Args = [UnsignedArgument<"NumParams">];
2607  let Documentation = [RegparmDocs];
2608  // Represented as part of the enclosing function type.
2609  let ASTNode = 0;
2610}
2611
2612def SwiftAsyncName : InheritableAttr {
2613  let Spellings = [GNU<"swift_async_name">];
2614  let Args = [StringArgument<"Name">];
2615  let Subjects = SubjectList<[ObjCMethod, Function], ErrorDiag>;
2616  let Documentation = [SwiftAsyncNameDocs];
2617}
2618
2619def SwiftAttr : InheritableAttr {
2620  let Spellings = [GNU<"swift_attr">];
2621  let Args = [StringArgument<"Attribute">];
2622  let Documentation = [SwiftAttrDocs];
2623  let PragmaAttributeSupport = 1;
2624}
2625
2626def SwiftBridge : InheritableAttr {
2627  let Spellings = [GNU<"swift_bridge">];
2628  let Args = [StringArgument<"SwiftType">];
2629  let Subjects = SubjectList<[Tag, TypedefName, ObjCInterface, ObjCProtocol],
2630                             ErrorDiag>;
2631  let Documentation = [SwiftBridgeDocs];
2632}
2633
2634def SwiftBridgedTypedef : InheritableAttr {
2635  let Spellings = [GNU<"swift_bridged_typedef">];
2636  let Subjects = SubjectList<[TypedefName], ErrorDiag>;
2637  let Documentation = [SwiftBridgedTypedefDocs];
2638  let SimpleHandler = 1;
2639}
2640
2641def SwiftObjCMembers : Attr {
2642  let Spellings = [GNU<"swift_objc_members">];
2643  let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
2644  let Documentation = [SwiftObjCMembersDocs];
2645  let SimpleHandler = 1;
2646}
2647
2648def SwiftError : InheritableAttr {
2649  let Spellings = [GNU<"swift_error">];
2650  let Args = [
2651      EnumArgument<"Convention", "ConventionKind",
2652                   ["none", "nonnull_error", "null_result", "zero_result", "nonzero_result"],
2653                   ["None", "NonNullError", "NullResult", "ZeroResult", "NonZeroResult"]>
2654  ];
2655  let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
2656  let Documentation = [SwiftErrorDocs];
2657}
2658
2659def SwiftImportAsNonGeneric : InheritableAttr {
2660  // This attribute has no spellings as it is only ever created implicitly
2661  // from API notes.
2662  let Spellings = [];
2663  let SemaHandler = 0;
2664  let Documentation = [InternalOnly];
2665}
2666
2667def SwiftImportPropertyAsAccessors : InheritableAttr {
2668  // This attribute has no spellings as it is only ever created implicitly
2669  // from API notes.
2670  let Spellings = [];
2671  let SemaHandler = 0;
2672  let Documentation = [InternalOnly];
2673}
2674
2675def SwiftName : InheritableAttr {
2676  let Spellings = [GNU<"swift_name">];
2677  let Args = [StringArgument<"Name">];
2678  let Documentation = [SwiftNameDocs];
2679}
2680
2681def SwiftNewType : InheritableAttr {
2682  let Spellings = [GNU<"swift_newtype">, GNU<"swift_wrapper">];
2683  let Args = [EnumArgument<"NewtypeKind", "NewtypeKind",
2684                           ["struct", "enum"], ["NK_Struct", "NK_Enum"]>];
2685  let Subjects = SubjectList<[TypedefName], ErrorDiag>;
2686  let Documentation = [SwiftNewTypeDocs];
2687  let HasCustomParsing = 1;
2688}
2689
2690def SwiftPrivate : InheritableAttr {
2691  let Spellings = [GNU<"swift_private">];
2692  let Documentation = [SwiftPrivateDocs];
2693  let SimpleHandler = 1;
2694}
2695
2696def SwiftVersionedAddition : Attr {
2697  // This attribute has no spellings as it is only ever created implicitly
2698  // from API notes.
2699  let Spellings = [];
2700  let Args = [VersionArgument<"Version">, WrappedAttr<"AdditionalAttr">,
2701              BoolArgument<"IsReplacedByActive">];
2702  let SemaHandler = 0;
2703  let Documentation = [InternalOnly];
2704}
2705
2706def SwiftVersionedRemoval : Attr {
2707  // This attribute has no spellings as it is only ever created implicitly
2708  // from API notes.
2709  let Spellings = [];
2710  let Args = [VersionArgument<"Version">, UnsignedArgument<"RawKind">,
2711              BoolArgument<"IsReplacedByActive">];
2712  let SemaHandler = 0;
2713  let Documentation = [InternalOnly];
2714  let AdditionalMembers = [{
2715    attr::Kind getAttrKindToRemove() const {
2716      return static_cast<attr::Kind>(getRawKind());
2717    }
2718  }];
2719}
2720
2721def NoDeref : TypeAttr {
2722  let Spellings = [Clang<"noderef">];
2723  let Documentation = [NoDerefDocs];
2724}
2725
2726def ReqdWorkGroupSize : InheritableAttr {
2727  // Does not have a [[]] spelling because it is an OpenCL-related attribute.
2728  let Spellings = [GNU<"reqd_work_group_size">];
2729  let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
2730              UnsignedArgument<"ZDim">];
2731  let Subjects = SubjectList<[Function], ErrorDiag>;
2732  let Documentation = [Undocumented];
2733}
2734
2735def WorkGroupSizeHint :  InheritableAttr {
2736  // Does not have a [[]] spelling because it is an OpenCL-related attribute.
2737  let Spellings = [GNU<"work_group_size_hint">];
2738  let Args = [UnsignedArgument<"XDim">,
2739              UnsignedArgument<"YDim">,
2740              UnsignedArgument<"ZDim">];
2741  let Subjects = SubjectList<[Function], ErrorDiag>;
2742  let Documentation = [Undocumented];
2743}
2744
2745def InitPriority : InheritableAttr, TargetSpecificAttr<TargetSupportsInitPriority> {
2746  let Spellings = [GCC<"init_priority", /*AllowInC*/0>];
2747  let Args = [UnsignedArgument<"Priority">];
2748  let Subjects = SubjectList<[Var], ErrorDiag>;
2749  let Documentation = [InitPriorityDocs];
2750}
2751
2752def Section : InheritableAttr {
2753  let Spellings = [GCC<"section">, Declspec<"allocate">];
2754  let Args = [StringArgument<"Name">];
2755  let Subjects =
2756      SubjectList<[ Function, GlobalVar, ObjCMethod, ObjCProperty ], ErrorDiag>;
2757  let Documentation = [SectionDocs];
2758}
2759
2760// This is used for `__declspec(code_seg("segname"))`, but not for
2761// `#pragma code_seg("segname")`.
2762def CodeSeg : InheritableAttr {
2763  let Spellings = [Declspec<"code_seg">];
2764  let Args = [StringArgument<"Name">];
2765  let Subjects = SubjectList<[Function, CXXRecord], ErrorDiag>;
2766  let Documentation = [CodeSegDocs];
2767}
2768
2769def PragmaClangBSSSection : InheritableAttr {
2770  // This attribute has no spellings as it is only ever created implicitly.
2771  let Spellings = [];
2772  let Args = [StringArgument<"Name">];
2773  let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
2774  let Documentation = [InternalOnly];
2775}
2776
2777def PragmaClangDataSection : InheritableAttr {
2778  // This attribute has no spellings as it is only ever created implicitly.
2779  let Spellings = [];
2780  let Args = [StringArgument<"Name">];
2781  let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
2782  let Documentation = [InternalOnly];
2783}
2784
2785def PragmaClangRodataSection : InheritableAttr {
2786  // This attribute has no spellings as it is only ever created implicitly.
2787  let Spellings = [];
2788  let Args = [StringArgument<"Name">];
2789  let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
2790  let Documentation = [InternalOnly];
2791}
2792
2793def PragmaClangRelroSection : InheritableAttr {
2794  // This attribute has no spellings as it is only ever created implicitly.
2795  let Spellings = [];
2796  let Args = [StringArgument<"Name">];
2797  let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
2798  let Documentation = [InternalOnly];
2799}
2800
2801def StrictFP : InheritableAttr {
2802  // This attribute has no spellings as it is only ever created implicitly.
2803  // Function uses strict floating point operations.
2804  let Spellings = [];
2805  let Subjects = SubjectList<[Function]>;
2806  let Documentation = [InternalOnly];
2807}
2808
2809def PragmaClangTextSection : InheritableAttr {
2810  // This attribute has no spellings as it is only ever created implicitly.
2811  let Spellings = [];
2812  let Args = [StringArgument<"Name">];
2813  let Subjects = SubjectList<[Function], ErrorDiag>;
2814  let Documentation = [InternalOnly];
2815}
2816
2817def CodeModel : InheritableAttr, TargetSpecificAttr<TargetLoongArch> {
2818  let Spellings = [GCC<"model">];
2819  let Args = [EnumArgument<"Model", "llvm::CodeModel::Model",
2820              ["normal", "medium", "extreme"], ["Small", "Medium", "Large"],
2821              /*opt=*/0, /*fake=*/0, /*isExternalType=*/1>];
2822  let Subjects = SubjectList<[NonTLSGlobalVar], ErrorDiag>;
2823  let Documentation = [CodeModelDocs];
2824}
2825
2826def Sentinel : InheritableAttr {
2827  let Spellings = [GCC<"sentinel">];
2828  let Args = [DefaultIntArgument<"Sentinel", 0>,
2829              DefaultIntArgument<"NullPos", 0>];
2830//  let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
2831  let Documentation = [Undocumented];
2832}
2833
2834def StdCall : DeclOrTypeAttr {
2835  let Spellings = [GCC<"stdcall">, CustomKeyword<"__stdcall">,
2836                   CustomKeyword<"_stdcall">];
2837//  let Subjects = [Function, ObjCMethod];
2838  let Documentation = [StdCallDocs];
2839}
2840
2841def SwiftCall : DeclOrTypeAttr {
2842  let Spellings = [Clang<"swiftcall">];
2843//  let Subjects = SubjectList<[Function]>;
2844  let Documentation = [SwiftCallDocs];
2845}
2846
2847def SwiftAsyncCall : DeclOrTypeAttr {
2848  let Spellings = [Clang<"swiftasynccall">];
2849  let Documentation = [SwiftAsyncCallDocs];
2850}
2851
2852def SwiftContext : ParameterABIAttr {
2853  let Spellings = [Clang<"swift_context">];
2854  let Documentation = [SwiftContextDocs];
2855}
2856
2857def SwiftAsyncContext : ParameterABIAttr {
2858  let Spellings = [Clang<"swift_async_context">];
2859  let Documentation = [SwiftAsyncContextDocs];
2860}
2861
2862def SwiftErrorResult : ParameterABIAttr {
2863  let Spellings = [Clang<"swift_error_result">];
2864  let Documentation = [SwiftErrorResultDocs];
2865}
2866
2867def SwiftIndirectResult : ParameterABIAttr {
2868  let Spellings = [Clang<"swift_indirect_result">];
2869  let Documentation = [SwiftIndirectResultDocs];
2870}
2871
2872def SwiftAsync : InheritableAttr {
2873  let Spellings = [Clang<"swift_async">];
2874  let Subjects = SubjectList<[Function, ObjCMethod]>;
2875  let Args = [EnumArgument<"Kind", "Kind",
2876                ["none", "swift_private", "not_swift_private"],
2877                ["None", "SwiftPrivate", "NotSwiftPrivate"]>,
2878              ParamIdxArgument<"CompletionHandlerIndex", /*opt=*/1>];
2879  let Documentation = [SwiftAsyncDocs];
2880}
2881
2882def SwiftAsyncError : InheritableAttr {
2883  let Spellings = [Clang<"swift_async_error">];
2884  let Subjects = SubjectList<[Function, ObjCMethod]>;
2885  let Args = [EnumArgument<"Convention", "ConventionKind",
2886              ["none", "nonnull_error", "zero_argument", "nonzero_argument"],
2887              ["None", "NonNullError", "ZeroArgument", "NonZeroArgument"]>,
2888              UnsignedArgument<"HandlerParamIdx", /*opt=*/1>];
2889  let Documentation = [SwiftAsyncErrorDocs];
2890}
2891
2892def Suppress : DeclOrStmtAttr {
2893  let Spellings = [CXX11<"gsl", "suppress">, Clang<"suppress">];
2894  let Args = [VariadicStringArgument<"DiagnosticIdentifiers">];
2895  let Accessors = [Accessor<"isGSL", [CXX11<"gsl", "suppress">]>];
2896  let Documentation = [SuppressDocs];
2897}
2898
2899def SysVABI : DeclOrTypeAttr {
2900  let Spellings = [GCC<"sysv_abi">];
2901//  let Subjects = [Function, ObjCMethod];
2902  let Documentation = [Undocumented];
2903}
2904
2905def ThisCall : DeclOrTypeAttr {
2906  let Spellings = [GCC<"thiscall">, CustomKeyword<"__thiscall">,
2907                   CustomKeyword<"_thiscall">];
2908//  let Subjects = [Function, ObjCMethod];
2909  let Documentation = [ThisCallDocs];
2910}
2911
2912def VectorCall : DeclOrTypeAttr {
2913  let Spellings = [Clang<"vectorcall">, CustomKeyword<"__vectorcall">,
2914                   CustomKeyword<"_vectorcall">];
2915//  let Subjects = [Function, ObjCMethod];
2916  let Documentation = [VectorCallDocs];
2917}
2918
2919def ZeroCallUsedRegs : InheritableAttr {
2920  let Spellings = [GCC<"zero_call_used_regs">];
2921  let Subjects = SubjectList<[Function], ErrorDiag>;
2922  let Args = [
2923    EnumArgument<"ZeroCallUsedRegs", "ZeroCallUsedRegsKind",
2924                 ["skip", "used-gpr-arg", "used-gpr", "used-arg", "used",
2925                  "all-gpr-arg", "all-gpr", "all-arg", "all"],
2926                 ["Skip", "UsedGPRArg", "UsedGPR", "UsedArg", "Used",
2927                  "AllGPRArg", "AllGPR", "AllArg", "All"]>
2928  ];
2929  let Documentation = [ZeroCallUsedRegsDocs];
2930}
2931
2932def Pascal : DeclOrTypeAttr {
2933  let Spellings = [Clang<"pascal">, CustomKeyword<"__pascal">,
2934                   CustomKeyword<"_pascal">];
2935//  let Subjects = [Function, ObjCMethod];
2936  let Documentation = [Undocumented];
2937}
2938
2939def PreferredName : InheritableAttr {
2940  let Spellings = [Clang<"preferred_name", /*AllowInC*/0>];
2941  let Subjects = SubjectList<[ClassTmpl]>;
2942  let Args = [TypeArgument<"TypedefType">];
2943  let Documentation = [PreferredNameDocs];
2944  let InheritEvenIfAlreadyPresent = 1;
2945  let MeaningfulToClassTemplateDefinition = 1;
2946  let TemplateDependent = 1;
2947}
2948
2949def PreserveMost : DeclOrTypeAttr {
2950  let Spellings = [Clang<"preserve_most">];
2951  let Documentation = [PreserveMostDocs];
2952}
2953
2954def PreserveAll : DeclOrTypeAttr {
2955  let Spellings = [Clang<"preserve_all">];
2956  let Documentation = [PreserveAllDocs];
2957}
2958
2959def M68kRTD: DeclOrTypeAttr {
2960  let Spellings = [Clang<"m68k_rtd">];
2961  let Documentation = [M68kRTDDocs];
2962}
2963
2964def Target : InheritableAttr {
2965  let Spellings = [GCC<"target">];
2966  let Args = [StringArgument<"featuresStr">];
2967  let Subjects = SubjectList<[Function], ErrorDiag>;
2968  let Documentation = [TargetDocs];
2969  let AdditionalMembers = [{
2970    StringRef getArchitecture() const {
2971      StringRef Features = getFeaturesStr();
2972      if (Features == "default") return {};
2973
2974      SmallVector<StringRef, 1> AttrFeatures;
2975      Features.split(AttrFeatures, ",");
2976
2977      for (auto &Feature : AttrFeatures) {
2978        Feature = Feature.trim();
2979        if (Feature.starts_with("arch="))
2980          return Feature.drop_front(sizeof("arch=") - 1);
2981      }
2982      return "";
2983    }
2984
2985    // Gets the list of features as simple string-refs with no +/- or 'no-'.
2986    // Only adds the items to 'Out' that are additions.
2987    void getAddedFeatures(llvm::SmallVectorImpl<StringRef> &Out) const {
2988      StringRef Features = getFeaturesStr();
2989      if (Features == "default") return;
2990
2991      SmallVector<StringRef, 1> AttrFeatures;
2992      Features.split(AttrFeatures, ",");
2993
2994      for (auto &Feature : AttrFeatures) {
2995        Feature = Feature.trim();
2996
2997        if (!Feature.starts_with("no-") && !Feature.starts_with("arch=") &&
2998            !Feature.starts_with("fpmath=") && !Feature.starts_with("tune="))
2999          Out.push_back(Feature);
3000      }
3001    }
3002
3003    bool isDefaultVersion() const { return getFeaturesStr() == "default"; }
3004  }];
3005}
3006
3007def TargetVersion : InheritableAttr {
3008  let Spellings = [GCC<"target_version">];
3009  let Args = [StringArgument<"NamesStr">];
3010  let Subjects = SubjectList<[Function], ErrorDiag>;
3011  let Documentation = [TargetVersionDocs];
3012  let AdditionalMembers = [{
3013    StringRef getName() const { return getNamesStr().trim(); }
3014    bool isDefaultVersion() const {
3015      return getName() == "default";
3016    }
3017    void getFeatures(llvm::SmallVectorImpl<StringRef> &Out) const {
3018      if (isDefaultVersion()) return;
3019      StringRef Features = getName();
3020
3021      SmallVector<StringRef, 8> AttrFeatures;
3022      Features.split(AttrFeatures, "+");
3023
3024      for (auto &Feature : AttrFeatures) {
3025        Feature = Feature.trim();
3026        Out.push_back(Feature);
3027      }
3028    }
3029  }];
3030}
3031
3032def TargetClones : InheritableAttr {
3033  let Spellings = [GCC<"target_clones">];
3034  let Args = [VariadicStringArgument<"featuresStrs">];
3035  let Documentation = [TargetClonesDocs];
3036  let Subjects = SubjectList<[Function], ErrorDiag>;
3037  let AdditionalMembers = [{
3038    StringRef getFeatureStr(unsigned Index) const {
3039      return *(featuresStrs_begin() + Index);
3040    }
3041    // Given an index into the 'featuresStrs' sequence, compute a unique
3042    // ID to be used with function name mangling for the associated variant.
3043    // This mapping is necessary due to a requirement that the mangling ID
3044    // used for the "default" variant be the largest mangling ID in the
3045    // variant set. Duplicate variants present in 'featuresStrs' are also
3046    // assigned their own unique ID (the mapping is bijective).
3047    unsigned getMangledIndex(unsigned Index) const {
3048      if (getFeatureStr(Index) == "default")
3049        return std::count_if(featuresStrs_begin(), featuresStrs_end(),
3050                              [](StringRef S) { return S != "default"; });
3051
3052      return std::count_if(featuresStrs_begin(), featuresStrs_begin() + Index,
3053                           [](StringRef S) { return S != "default"; });
3054    }
3055
3056    // Given an index into the 'featuresStrs' sequence, determine if the
3057    // index corresponds to the first instance of the named variant. This
3058    // is used to skip over duplicate variant instances when iterating over
3059    // 'featuresStrs'.
3060    bool isFirstOfVersion(unsigned Index) const {
3061      StringRef FeatureStr(getFeatureStr(Index));
3062      return 0 == std::count_if(
3063                      featuresStrs_begin(), featuresStrs_begin() + Index,
3064                      [FeatureStr](StringRef S) { return S == FeatureStr; });
3065
3066    }
3067  }];
3068}
3069
3070def : MutualExclusions<[TargetClones, TargetVersion, Target, CPUDispatch, CPUSpecific]>;
3071
3072def MinVectorWidth : InheritableAttr {
3073  let Spellings = [Clang<"min_vector_width">];
3074  let Args = [UnsignedArgument<"VectorWidth">];
3075  let Subjects = SubjectList<[Function], ErrorDiag>;
3076  let Documentation = [MinVectorWidthDocs];
3077}
3078
3079def TransparentUnion : InheritableAttr {
3080  let Spellings = [GCC<"transparent_union">];
3081//  let Subjects = SubjectList<[Record, TypedefName]>;
3082  let Documentation = [TransparentUnionDocs];
3083  let LangOpts = [COnly];
3084}
3085
3086def Unavailable : InheritableAttr {
3087  let Spellings = [Clang<"unavailable">];
3088  let Args = [StringArgument<"Message", 1>,
3089              EnumArgument<"ImplicitReason", "ImplicitReason",
3090                ["", "", "", ""],
3091                ["IR_None",
3092                 "IR_ARCForbiddenType",
3093                 "IR_ForbiddenWeak",
3094                 "IR_ARCForbiddenConversion",
3095                 "IR_ARCInitReturnsUnrelated",
3096                 "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>];
3097  let Documentation = [Undocumented];
3098  let MeaningfulToClassTemplateDefinition = 1;
3099}
3100
3101def DiagnoseIf : InheritableAttr {
3102  let CanPrintOnLeft = 0;
3103  // Does not have a [[]] spelling because this attribute requires the ability
3104  // to parse function arguments but the attribute is not written in the type
3105  // position.
3106  let Spellings = [GNU<"diagnose_if">];
3107  let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;
3108  let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
3109              EnumArgument<"DiagnosticType",
3110                           "DiagnosticType",
3111                           ["error", "warning"],
3112                           ["DT_Error", "DT_Warning"]>,
3113              BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
3114              DeclArgument<Named, "Parent", 0, /*fake*/ 1>];
3115  let InheritEvenIfAlreadyPresent = 1;
3116  let LateParsed = 1;
3117  let AdditionalMembers = [{
3118    bool isError() const { return diagnosticType == DT_Error; }
3119    bool isWarning() const { return diagnosticType == DT_Warning; }
3120  }];
3121  let TemplateDependent = 1;
3122  let Documentation = [DiagnoseIfDocs];
3123}
3124
3125def ArcWeakrefUnavailable : InheritableAttr {
3126  let Spellings = [Clang<"objc_arc_weak_reference_unavailable">];
3127  let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
3128  let Documentation = [Undocumented];
3129  let SimpleHandler = 1;
3130}
3131
3132def ObjCGC : TypeAttr {
3133  let Spellings = [Clang<"objc_gc">];
3134  let Args = [IdentifierArgument<"Kind">];
3135  let Documentation = [Undocumented];
3136}
3137
3138def ObjCOwnership : DeclOrTypeAttr {
3139  let Spellings = [Clang<"objc_ownership">];
3140  let Args = [IdentifierArgument<"Kind">];
3141  let Documentation = [Undocumented];
3142}
3143
3144def ObjCRequiresPropertyDefs : InheritableAttr {
3145  let Spellings = [Clang<"objc_requires_property_definitions">];
3146  let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
3147  let Documentation = [Undocumented];
3148  let SimpleHandler = 1;
3149}
3150
3151def Unused : InheritableAttr {
3152  let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
3153                   C23<"", "maybe_unused", 202106>];
3154  let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
3155                              Field, ObjCMethod, FunctionLike]>;
3156  let Documentation = [WarnMaybeUnusedDocs];
3157}
3158
3159def Used : InheritableAttr {
3160  let Spellings = [GCC<"used">];
3161  let Subjects = SubjectList<[NonLocalVar, Function, ObjCMethod]>;
3162  let Documentation = [UsedDocs];
3163  let SimpleHandler = 1;
3164}
3165
3166def Retain : InheritableAttr {
3167  let Spellings = [GCC<"retain">];
3168  let Subjects = SubjectList<[NonLocalVar, Function, ObjCMethod]>;
3169  let Documentation = [RetainDocs];
3170  let SimpleHandler = 1;
3171}
3172
3173def Uuid : InheritableAttr {
3174  let Spellings = [Declspec<"uuid">, Microsoft<"uuid">];
3175  let Args = [StringArgument<"Guid">,
3176              DeclArgument<MSGuid, "GuidDecl", 0, /*fake=*/1>];
3177  let Subjects = SubjectList<[Record, Enum]>;
3178  // FIXME: Allow expressing logical AND for LangOpts. Our condition should be:
3179  // CPlusPlus && (MicrosoftExt || Borland)
3180  let LangOpts = [MicrosoftExt, Borland];
3181  let Documentation = [Undocumented];
3182}
3183
3184def VectorSize : TypeAttr {
3185  let Spellings = [GCC<"vector_size">];
3186  let Args = [ExprArgument<"NumBytes">];
3187  let Documentation = [Undocumented];
3188  // Represented as VectorType instead.
3189  let ASTNode = 0;
3190}
3191
3192def VecTypeHint : InheritableAttr {
3193  // Does not have a [[]] spelling because it is an OpenCL-related attribute.
3194  let Spellings = [GNU<"vec_type_hint">];
3195  let Args = [TypeArgument<"TypeHint">];
3196  let Subjects = SubjectList<[Function], ErrorDiag>;
3197  let Documentation = [Undocumented];
3198}
3199
3200def MatrixType : TypeAttr {
3201  let Spellings = [Clang<"matrix_type">];
3202  let Subjects = SubjectList<[TypedefName], ErrorDiag>;
3203  let Args = [ExprArgument<"NumRows">, ExprArgument<"NumColumns">];
3204  let Documentation = [Undocumented];
3205  let ASTNode = 0;
3206  let PragmaAttributeSupport = 0;
3207}
3208
3209def Visibility : InheritableAttr {
3210  let Clone = 0;
3211  let Spellings = [GCC<"visibility">];
3212  let Args = [EnumArgument<"Visibility", "VisibilityType",
3213                           ["default", "hidden", "internal", "protected"],
3214                           ["Default", "Hidden", "Hidden", "Protected"]>];
3215  let MeaningfulToClassTemplateDefinition = 1;
3216  let Documentation = [Undocumented];
3217}
3218
3219def TypeVisibility : InheritableAttr {
3220  let Clone = 0;
3221  let Spellings = [Clang<"type_visibility">];
3222  let Args = [EnumArgument<"Visibility", "VisibilityType",
3223                           ["default", "hidden", "internal", "protected"],
3224                           ["Default", "Hidden", "Hidden", "Protected"]>];
3225//  let Subjects = [Tag, ObjCInterface, Namespace];
3226  let Documentation = [Undocumented];
3227}
3228
3229def VecReturn : InheritableAttr {
3230  // This attribute does not have a C [[]] spelling because it only appertains
3231  // to C++ struct/class/union.
3232  // FIXME: should this attribute have a CPlusPlus language option?
3233  let Spellings = [Clang<"vecreturn", 0>];
3234  let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
3235  let Documentation = [Undocumented];
3236}
3237
3238def WarnUnused : InheritableAttr {
3239  let Spellings = [GCC<"warn_unused">];
3240  let Subjects = SubjectList<[Record]>;
3241  let Documentation = [Undocumented];
3242  let SimpleHandler = 1;
3243}
3244
3245def WarnUnusedResult : InheritableAttr {
3246  let Spellings = [CXX11<"", "nodiscard", 201907>,
3247                   C23<"", "nodiscard", 202003>,
3248                   CXX11<"clang", "warn_unused_result">,
3249                   GCC<"warn_unused_result">];
3250  let Subjects = SubjectList<[ObjCMethod, Enum, Record, FunctionLike, TypedefName]>;
3251  let Args = [StringArgument<"Message", 1>];
3252  let Documentation = [WarnUnusedResultsDocs];
3253  let AdditionalMembers = [{
3254    // Check whether this the C++11 nodiscard version, even in non C++11
3255    // spellings.
3256    bool IsCXX11NoDiscard() const {
3257      return this->getSemanticSpelling() == CXX11_nodiscard;
3258    }
3259  }];
3260}
3261
3262def Weak : InheritableAttr {
3263  let Spellings = [GCC<"weak">];
3264  let Subjects = SubjectList<[Var, Function, CXXRecord]>;
3265  let Documentation = [WeakDocs];
3266  let SimpleHandler = 1;
3267}
3268
3269def WeakImport : InheritableAttr {
3270  let Spellings = [Clang<"weak_import">];
3271  let Documentation = [Undocumented];
3272}
3273
3274def WeakRef : InheritableAttr {
3275  let Spellings = [GCC<"weakref">];
3276  // A WeakRef that has an argument is treated as being an AliasAttr
3277  let Args = [StringArgument<"Aliasee", 1>];
3278  let Subjects = SubjectList<[Var, Function], ErrorDiag>;
3279  let Documentation = [Undocumented];
3280}
3281
3282def LTOVisibilityPublic : InheritableAttr {
3283  let Spellings = [Clang<"lto_visibility_public">];
3284  let Subjects = SubjectList<[Record]>;
3285  let Documentation = [LTOVisibilityDocs];
3286  let SimpleHandler = 1;
3287}
3288
3289def AnyX86Interrupt : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
3290  // NOTE: If you add any additional spellings, ARMInterrupt's,
3291  // M68kInterrupt's, MSP430Interrupt's and MipsInterrupt's spellings must match.
3292  let Spellings = [GCC<"interrupt">];
3293  let Subjects = SubjectList<[HasFunctionProto]>;
3294  let ParseKind = "Interrupt";
3295  let HasCustomParsing = 1;
3296  let Documentation = [AnyX86InterruptDocs];
3297}
3298
3299def AnyX86NoCallerSavedRegisters : InheritableAttr,
3300                                   TargetSpecificAttr<TargetAnyX86> {
3301  let Spellings = [GCC<"no_caller_saved_registers">];
3302  let Documentation = [AnyX86NoCallerSavedRegistersDocs];
3303  let SimpleHandler = 1;
3304}
3305
3306def AnyX86NoCfCheck : DeclOrTypeAttr, TargetSpecificAttr<TargetAnyX86>{
3307  let Spellings = [GCC<"nocf_check">];
3308  let Subjects = SubjectList<[FunctionLike]>;
3309  let Documentation = [AnyX86NoCfCheckDocs];
3310}
3311
3312def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
3313  let Spellings = [GCC<"force_align_arg_pointer">];
3314  // Technically, this appertains to a FunctionDecl, but the target-specific
3315  // code silently allows anything function-like (such as typedefs or function
3316  // pointers), but does not apply the attribute to them.
3317  let Documentation = [X86ForceAlignArgPointerDocs];
3318}
3319
3320def NoSanitize : InheritableAttr {
3321  let Spellings = [Clang<"no_sanitize">];
3322  let Args = [VariadicStringArgument<"Sanitizers">];
3323  let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag>;
3324  let Documentation = [NoSanitizeDocs];
3325  let AdditionalMembers = [{
3326    SanitizerMask getMask() const {
3327      SanitizerMask Mask;
3328      for (auto SanitizerName : sanitizers()) {
3329        SanitizerMask ParsedMask =
3330            parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
3331        Mask |= expandSanitizerGroups(ParsedMask);
3332      }
3333      return Mask;
3334    }
3335
3336    bool hasCoverage() const {
3337      return llvm::is_contained(sanitizers(), "coverage");
3338    }
3339  }];
3340}
3341
3342// Attributes to disable a specific sanitizer. No new sanitizers should be added
3343// to this list; the no_sanitize attribute should be extended instead.
3344def NoSanitizeSpecific : InheritableAttr {
3345  let Spellings = [GCC<"no_address_safety_analysis">,
3346                   GCC<"no_sanitize_address">,
3347                   GCC<"no_sanitize_thread">,
3348                   Clang<"no_sanitize_memory">];
3349  let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
3350  let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
3351                       NoSanitizeMemoryDocs];
3352  let ASTNode = 0;
3353}
3354
3355def DisableSanitizerInstrumentation : InheritableAttr {
3356  let Spellings = [Clang<"disable_sanitizer_instrumentation">];
3357  let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar]>;
3358  let Documentation = [DisableSanitizerInstrumentationDocs];
3359  let SimpleHandler = 1;
3360}
3361
3362def CFICanonicalJumpTable : InheritableAttr {
3363  let Spellings = [Clang<"cfi_canonical_jump_table">];
3364  let Subjects = SubjectList<[Function], ErrorDiag>;
3365  let Documentation = [CFICanonicalJumpTableDocs];
3366  let SimpleHandler = 1;
3367}
3368
3369// C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
3370// Not all of these attributes will be given a [[]] spelling. The attributes
3371// which require access to function parameter names cannot use the [[]] spelling
3372// because they are not written in the type position. Some attributes are given
3373// an updated captability-based name and the older name will only be supported
3374// under the GNU-style spelling.
3375def GuardedVar : InheritableAttr {
3376  let Spellings = [Clang<"guarded_var", 0>];
3377  let Subjects = SubjectList<[Field, SharedVar]>;
3378  let Documentation = [Undocumented];
3379  let SimpleHandler = 1;
3380}
3381
3382def PtGuardedVar : InheritableAttr {
3383  let Spellings = [Clang<"pt_guarded_var", 0>];
3384  let Subjects = SubjectList<[Field, SharedVar]>;
3385  let Documentation = [Undocumented];
3386}
3387
3388def Lockable : InheritableAttr {
3389  let Spellings = [GNU<"lockable">];
3390  let Subjects = SubjectList<[Record]>;
3391  let Documentation = [Undocumented];
3392  let ASTNode = 0;  // Replaced by Capability
3393}
3394
3395def ScopedLockable : InheritableAttr {
3396  let Spellings = [Clang<"scoped_lockable", 0>];
3397  let Subjects = SubjectList<[Record]>;
3398  let Documentation = [Undocumented];
3399  let SimpleHandler = 1;
3400}
3401
3402def Capability : InheritableAttr {
3403  let Spellings = [Clang<"capability", 0>, Clang<"shared_capability", 0>];
3404  let Subjects = SubjectList<[Record, TypedefName], ErrorDiag>;
3405  let Args = [StringArgument<"Name">];
3406  let Accessors = [Accessor<"isShared",
3407                    [Clang<"shared_capability", 0>]>];
3408  let Documentation = [Undocumented];
3409}
3410
3411def AssertCapability : InheritableAttr {
3412  let Spellings = [Clang<"assert_capability", 0>,
3413                   Clang<"assert_shared_capability", 0>];
3414  let Subjects = SubjectList<[Function]>;
3415  let LateParsed = 1;
3416  let TemplateDependent = 1;
3417  let ParseArgumentsAsUnevaluated = 1;
3418  let InheritEvenIfAlreadyPresent = 1;
3419  let Args = [VariadicExprArgument<"Args">];
3420  let Accessors = [Accessor<"isShared",
3421                    [Clang<"assert_shared_capability", 0>]>];
3422  let Documentation = [AssertCapabilityDocs];
3423}
3424
3425def AcquireCapability : InheritableAttr {
3426  let Spellings = [Clang<"acquire_capability", 0>,
3427                   Clang<"acquire_shared_capability", 0>,
3428                   GNU<"exclusive_lock_function">,
3429                   GNU<"shared_lock_function">];
3430  let Subjects = SubjectList<[Function]>;
3431  let LateParsed = 1;
3432  let TemplateDependent = 1;
3433  let ParseArgumentsAsUnevaluated = 1;
3434  let InheritEvenIfAlreadyPresent = 1;
3435  let Args = [VariadicExprArgument<"Args">];
3436  let Accessors = [Accessor<"isShared",
3437                    [Clang<"acquire_shared_capability", 0>,
3438                     GNU<"shared_lock_function">]>];
3439  let Documentation = [AcquireCapabilityDocs];
3440}
3441
3442def TryAcquireCapability : InheritableAttr {
3443  let Spellings = [Clang<"try_acquire_capability", 0>,
3444                   Clang<"try_acquire_shared_capability", 0>];
3445  let Subjects = SubjectList<[Function],
3446                             ErrorDiag>;
3447  let LateParsed = 1;
3448  let TemplateDependent = 1;
3449  let ParseArgumentsAsUnevaluated = 1;
3450  let InheritEvenIfAlreadyPresent = 1;
3451  let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
3452  let Accessors = [Accessor<"isShared",
3453                    [Clang<"try_acquire_shared_capability", 0>]>];
3454  let Documentation = [TryAcquireCapabilityDocs];
3455}
3456
3457def ReleaseCapability : InheritableAttr {
3458  let Spellings = [Clang<"release_capability", 0>,
3459                   Clang<"release_shared_capability", 0>,
3460                   Clang<"release_generic_capability", 0>,
3461                   Clang<"unlock_function", 0>];
3462  let Subjects = SubjectList<[Function]>;
3463  let LateParsed = 1;
3464  let TemplateDependent = 1;
3465  let ParseArgumentsAsUnevaluated = 1;
3466  let InheritEvenIfAlreadyPresent = 1;
3467  let Args = [VariadicExprArgument<"Args">];
3468  let Accessors = [Accessor<"isShared",
3469                    [Clang<"release_shared_capability", 0>]>,
3470                   Accessor<"isGeneric",
3471                     [Clang<"release_generic_capability", 0>,
3472                      Clang<"unlock_function", 0>]>];
3473  let Documentation = [ReleaseCapabilityDocs];
3474}
3475
3476def RequiresCapability : InheritableAttr {
3477  let Spellings = [Clang<"requires_capability", 0>,
3478                   Clang<"exclusive_locks_required", 0>,
3479                   Clang<"requires_shared_capability", 0>,
3480                   Clang<"shared_locks_required", 0>];
3481  let Args = [VariadicExprArgument<"Args">];
3482  let LateParsed = 1;
3483  let TemplateDependent = 1;
3484  let ParseArgumentsAsUnevaluated = 1;
3485  let InheritEvenIfAlreadyPresent = 1;
3486  let Subjects = SubjectList<[Function]>;
3487  let Accessors = [Accessor<"isShared", [Clang<"requires_shared_capability", 0>,
3488                                         Clang<"shared_locks_required", 0>]>];
3489  let Documentation = [Undocumented];
3490}
3491
3492def NoThreadSafetyAnalysis : InheritableAttr {
3493  let Spellings = [Clang<"no_thread_safety_analysis">];
3494  let Subjects = SubjectList<[Function]>;
3495  let Documentation = [Undocumented];
3496  let SimpleHandler = 1;
3497}
3498
3499def GuardedBy : InheritableAttr {
3500  let Spellings = [GNU<"guarded_by">];
3501  let Args = [ExprArgument<"Arg">];
3502  let LateParsed = 1;
3503  let TemplateDependent = 1;
3504  let ParseArgumentsAsUnevaluated = 1;
3505  let InheritEvenIfAlreadyPresent = 1;
3506  let Subjects = SubjectList<[Field, SharedVar]>;
3507  let Documentation = [Undocumented];
3508}
3509
3510def PtGuardedBy : InheritableAttr {
3511  let Spellings = [GNU<"pt_guarded_by">];
3512  let Args = [ExprArgument<"Arg">];
3513  let LateParsed = 1;
3514  let TemplateDependent = 1;
3515  let ParseArgumentsAsUnevaluated = 1;
3516  let InheritEvenIfAlreadyPresent = 1;
3517  let Subjects = SubjectList<[Field, SharedVar]>;
3518  let Documentation = [Undocumented];
3519}
3520
3521def AcquiredAfter : InheritableAttr {
3522  let Spellings = [GNU<"acquired_after">];
3523  let Args = [VariadicExprArgument<"Args">];
3524  let LateParsed = 1;
3525  let TemplateDependent = 1;
3526  let ParseArgumentsAsUnevaluated = 1;
3527  let InheritEvenIfAlreadyPresent = 1;
3528  let Subjects = SubjectList<[Field, SharedVar]>;
3529  let Documentation = [Undocumented];
3530}
3531
3532def AcquiredBefore : InheritableAttr {
3533  let Spellings = [GNU<"acquired_before">];
3534  let Args = [VariadicExprArgument<"Args">];
3535  let LateParsed = 1;
3536  let TemplateDependent = 1;
3537  let ParseArgumentsAsUnevaluated = 1;
3538  let InheritEvenIfAlreadyPresent = 1;
3539  let Subjects = SubjectList<[Field, SharedVar]>;
3540  let Documentation = [Undocumented];
3541}
3542
3543def AssertExclusiveLock : InheritableAttr {
3544  let Spellings = [GNU<"assert_exclusive_lock">];
3545  let Args = [VariadicExprArgument<"Args">];
3546  let LateParsed = 1;
3547  let TemplateDependent = 1;
3548  let ParseArgumentsAsUnevaluated = 1;
3549  let InheritEvenIfAlreadyPresent = 1;
3550  let Subjects = SubjectList<[Function]>;
3551  let Documentation = [Undocumented];
3552}
3553
3554def AssertSharedLock : InheritableAttr {
3555  let Spellings = [GNU<"assert_shared_lock">];
3556  let Args = [VariadicExprArgument<"Args">];
3557  let LateParsed = 1;
3558  let TemplateDependent = 1;
3559  let ParseArgumentsAsUnevaluated = 1;
3560  let InheritEvenIfAlreadyPresent = 1;
3561  let Subjects = SubjectList<[Function]>;
3562  let Documentation = [Undocumented];
3563}
3564
3565// The first argument is an integer or boolean value specifying the return value
3566// of a successful lock acquisition.
3567def ExclusiveTrylockFunction : InheritableAttr {
3568  let Spellings = [GNU<"exclusive_trylock_function">];
3569  let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
3570  let LateParsed = 1;
3571  let TemplateDependent = 1;
3572  let ParseArgumentsAsUnevaluated = 1;
3573  let InheritEvenIfAlreadyPresent = 1;
3574  let Subjects = SubjectList<[Function]>;
3575  let Documentation = [Undocumented];
3576}
3577
3578// The first argument is an integer or boolean value specifying the return value
3579// of a successful lock acquisition.
3580def SharedTrylockFunction : InheritableAttr {
3581  let Spellings = [GNU<"shared_trylock_function">];
3582  let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
3583  let LateParsed = 1;
3584  let TemplateDependent = 1;
3585  let ParseArgumentsAsUnevaluated = 1;
3586  let InheritEvenIfAlreadyPresent = 1;
3587  let Subjects = SubjectList<[Function]>;
3588  let Documentation = [Undocumented];
3589}
3590
3591def LockReturned : InheritableAttr {
3592  let Spellings = [GNU<"lock_returned">];
3593  let Args = [ExprArgument<"Arg">];
3594  let LateParsed = 1;
3595  let TemplateDependent = 1;
3596  let ParseArgumentsAsUnevaluated = 1;
3597  let Subjects = SubjectList<[Function]>;
3598  let Documentation = [Undocumented];
3599}
3600
3601def LocksExcluded : InheritableAttr {
3602  let Spellings = [GNU<"locks_excluded">];
3603  let Args = [VariadicExprArgument<"Args">];
3604  let LateParsed = 1;
3605  let TemplateDependent = 1;
3606  let ParseArgumentsAsUnevaluated = 1;
3607  let InheritEvenIfAlreadyPresent = 1;
3608  let Subjects = SubjectList<[Function]>;
3609  let Documentation = [Undocumented];
3610}
3611
3612// C/C++ consumed attributes.
3613
3614def Consumable : InheritableAttr {
3615  // This attribute does not have a C [[]] spelling because it only appertains
3616  // to C++ struct/class/union.
3617  // FIXME: should this attribute have a CPlusPlus language option?
3618  let Spellings = [Clang<"consumable", 0>];
3619  let Subjects = SubjectList<[CXXRecord]>;
3620  let Args = [EnumArgument<"DefaultState", "ConsumedState",
3621                           ["unknown", "consumed", "unconsumed"],
3622                           ["Unknown", "Consumed", "Unconsumed"]>];
3623  let Documentation = [ConsumableDocs];
3624}
3625
3626def ConsumableAutoCast : InheritableAttr {
3627  // This attribute does not have a C [[]] spelling because it only appertains
3628  // to C++ struct/class/union.
3629  // FIXME: should this attribute have a CPlusPlus language option?
3630  let Spellings = [Clang<"consumable_auto_cast_state", 0>];
3631  let Subjects = SubjectList<[CXXRecord]>;
3632  let Documentation = [Undocumented];
3633  let SimpleHandler = 1;
3634}
3635
3636def ConsumableSetOnRead : InheritableAttr {
3637  // This attribute does not have a C [[]] spelling because it only appertains
3638  // to C++ struct/class/union.
3639  // FIXME: should this attribute have a CPlusPlus language option?
3640  let Spellings = [Clang<"consumable_set_state_on_read", 0>];
3641  let Subjects = SubjectList<[CXXRecord]>;
3642  let Documentation = [Undocumented];
3643  let SimpleHandler = 1;
3644}
3645
3646def CallableWhen : InheritableAttr {
3647  // This attribute does not have a C [[]] spelling because it only appertains
3648  // to C++ function (but doesn't require it to be a member function).
3649  // FIXME: should this attribute have a CPlusPlus language option?
3650  let Spellings = [Clang<"callable_when", 0>];
3651  let Subjects = SubjectList<[CXXMethod]>;
3652  let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
3653                                   ["unknown", "consumed", "unconsumed"],
3654                                   ["Unknown", "Consumed", "Unconsumed"]>];
3655  let Documentation = [CallableWhenDocs];
3656}
3657
3658def ParamTypestate : InheritableAttr {
3659  // This attribute does not have a C [[]] spelling because it only appertains
3660  // to a parameter whose type is a consumable C++ class.
3661  // FIXME: should this attribute have a CPlusPlus language option?
3662  let Spellings = [Clang<"param_typestate", 0>];
3663  let Subjects = SubjectList<[ParmVar]>;
3664  let Args = [EnumArgument<"ParamState", "ConsumedState",
3665                           ["unknown", "consumed", "unconsumed"],
3666                           ["Unknown", "Consumed", "Unconsumed"]>];
3667  let Documentation = [ParamTypestateDocs];
3668}
3669
3670def ReturnTypestate : InheritableAttr {
3671  // This attribute does not have a C [[]] spelling because it only appertains
3672  // to a parameter or function return type that is a consumable C++ class.
3673  // FIXME: should this attribute have a CPlusPlus language option?
3674  let Spellings = [Clang<"return_typestate", 0>];
3675  let Subjects = SubjectList<[Function, ParmVar]>;
3676  let Args = [EnumArgument<"State", "ConsumedState",
3677                           ["unknown", "consumed", "unconsumed"],
3678                           ["Unknown", "Consumed", "Unconsumed"]>];
3679  let Documentation = [ReturnTypestateDocs];
3680}
3681
3682def SetTypestate : InheritableAttr {
3683  // This attribute does not have a C [[]] spelling because it only appertains
3684  // to C++ function (but doesn't require it to be a member function).
3685  // FIXME: should this attribute have a CPlusPlus language option?
3686  let Spellings = [Clang<"set_typestate", 0>];
3687  let Subjects = SubjectList<[CXXMethod]>;
3688  let Args = [EnumArgument<"NewState", "ConsumedState",
3689                           ["unknown", "consumed", "unconsumed"],
3690                           ["Unknown", "Consumed", "Unconsumed"]>];
3691  let Documentation = [SetTypestateDocs];
3692}
3693
3694def TestTypestate : InheritableAttr {
3695  // This attribute does not have a C [[]] spelling because it only appertains
3696  // to C++ function (but doesn't require it to be a member function).
3697  // FIXME: should this attribute have a CPlusPlus language option?
3698  let Spellings = [Clang<"test_typestate", 0>];
3699  let Subjects = SubjectList<[CXXMethod]>;
3700  let Args = [EnumArgument<"TestState", "ConsumedState",
3701                           ["consumed", "unconsumed"],
3702                           ["Consumed", "Unconsumed"]>];
3703  let Documentation = [TestTypestateDocs];
3704}
3705
3706// Type safety attributes for `void *' pointers and type tags.
3707
3708def ArgumentWithTypeTag : InheritableAttr {
3709  let Spellings = [Clang<"argument_with_type_tag">,
3710                   Clang<"pointer_with_type_tag">];
3711  let Subjects = SubjectList<[HasFunctionProto], ErrorDiag>;
3712  let Args = [IdentifierArgument<"ArgumentKind">,
3713              ParamIdxArgument<"ArgumentIdx">,
3714              ParamIdxArgument<"TypeTagIdx">,
3715              BoolArgument<"IsPointer", /*opt*/0, /*fake*/1>];
3716  let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
3717}
3718
3719def TypeTagForDatatype : InheritableAttr {
3720  let Spellings = [Clang<"type_tag_for_datatype">];
3721  let Args = [IdentifierArgument<"ArgumentKind">,
3722              TypeArgument<"MatchingCType">,
3723              BoolArgument<"LayoutCompatible">,
3724              BoolArgument<"MustBeNull">];
3725//  let Subjects = SubjectList<[Var], ErrorDiag>;
3726  let HasCustomParsing = 1;
3727  let Documentation = [TypeTagForDatatypeDocs];
3728}
3729
3730def Owner : InheritableAttr {
3731  let Spellings = [CXX11<"gsl", "Owner">];
3732  let Subjects = SubjectList<[Struct]>;
3733  let Args = [TypeArgument<"DerefType", /*opt=*/1>];
3734  let Documentation = [LifetimeOwnerDocs];
3735}
3736
3737def Pointer : InheritableAttr {
3738  let Spellings = [CXX11<"gsl", "Pointer">];
3739  let Subjects = SubjectList<[Struct]>;
3740  let Args = [TypeArgument<"DerefType", /*opt=*/1>];
3741  let Documentation = [LifetimePointerDocs];
3742}
3743def : MutualExclusions<[Owner, Pointer]>;
3744
3745// Microsoft-related attributes
3746
3747def MSConstexpr : InheritableAttr {
3748  let LangOpts = [MicrosoftExt];
3749  let Spellings = [CXX11<"msvc", "constexpr">];
3750  let Subjects = SubjectList<[Function, ReturnStmt], ErrorDiag,
3751                             "functions and return statements">;
3752  let Documentation = [MSConstexprDocs];
3753}
3754
3755def MSNoVTable : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
3756  let Spellings = [Declspec<"novtable">];
3757  let Subjects = SubjectList<[CXXRecord]>;
3758  let Documentation = [MSNoVTableDocs];
3759  let SimpleHandler = 1;
3760}
3761
3762def : IgnoredAttr {
3763  let Spellings = [Declspec<"property">];
3764}
3765
3766def MSAllocator : InheritableAttr {
3767  let Spellings = [Declspec<"allocator">];
3768  let Subjects = SubjectList<[Function]>;
3769  let Documentation = [MSAllocatorDocs];
3770}
3771
3772def CFGuard : InheritableAttr, TargetSpecificAttr<TargetWindows> {
3773  // Currently only the __declspec(guard(nocf)) modifier is supported. In future
3774  // we might also want to support __declspec(guard(suppress)).
3775  let Spellings = [Declspec<"guard">, Clang<"guard">];
3776  let Subjects = SubjectList<[Function]>;
3777  let Args = [EnumArgument<"Guard", "GuardArg", ["nocf"], ["nocf"]>];
3778  let Documentation = [CFGuardDocs];
3779}
3780
3781def MSStruct : InheritableAttr {
3782  let Spellings = [GCC<"ms_struct">];
3783  let Subjects = SubjectList<[Record]>;
3784  let Documentation = [Undocumented];
3785  let SimpleHandler = 1;
3786}
3787
3788def DLLExport : InheritableAttr, TargetSpecificAttr<TargetHasDLLImportExport> {
3789  let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
3790  let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
3791  let Documentation = [DLLExportDocs];
3792}
3793
3794def DLLExportStaticLocal : InheritableAttr, TargetSpecificAttr<TargetHasDLLImportExport> {
3795  // This attribute is used internally only when -fno-dllexport-inlines is
3796  // passed. This attribute is added to inline functions of a class having the
3797  // dllexport attribute. If the function has static local variables, this
3798  // attribute is used to determine whether the variables are exported or not. If
3799  // the function has local static variables, the function is dllexported too.
3800  let Spellings = [];
3801  let Subjects = SubjectList<[Function]>;
3802  let Documentation = [InternalOnly];
3803}
3804
3805def DLLImport : InheritableAttr, TargetSpecificAttr<TargetHasDLLImportExport> {
3806  let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
3807  let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
3808  let Documentation = [DLLImportDocs];
3809
3810
3811  let AdditionalMembers = [{
3812private:
3813  bool PropagatedToBaseTemplate = false;
3814
3815public:
3816  void setPropagatedToBaseTemplate() { PropagatedToBaseTemplate = true; }
3817  bool wasPropagatedToBaseTemplate() { return PropagatedToBaseTemplate; }
3818  }];
3819}
3820
3821def DLLImportStaticLocal : InheritableAttr, TargetSpecificAttr<TargetHasDLLImportExport> {
3822  // This attribute is used internally only when -fno-dllexport-inlines is
3823  // passed. This attribute is added to inline functions of a class having the
3824  // dllimport attribute. If the function has static local variables, this
3825  // attribute is used to determine whether the variables are imported or not.
3826  let Spellings = [];
3827  let Subjects = SubjectList<[Function]>;
3828  let Documentation = [InternalOnly];
3829}
3830
3831def SelectAny : InheritableAttr {
3832  let Spellings = [Declspec<"selectany">, GCC<"selectany">];
3833  let Documentation = [SelectAnyDocs];
3834  let SimpleHandler = 1;
3835}
3836
3837def Thread : Attr {
3838  let Spellings = [Declspec<"thread">];
3839  let LangOpts = [MicrosoftExt];
3840  let Documentation = [ThreadDocs];
3841  let Subjects = SubjectList<[Var]>;
3842}
3843
3844def Win64 : IgnoredAttr {
3845  let Spellings = [CustomKeyword<"__w64">];
3846  let LangOpts = [MicrosoftExt];
3847}
3848
3849def Ptr32 : TypeAttr {
3850  let Spellings = [CustomKeyword<"__ptr32">];
3851  let Documentation = [Ptr32Docs];
3852}
3853
3854def Ptr64 : TypeAttr {
3855  let Spellings = [CustomKeyword<"__ptr64">];
3856  let Documentation = [Ptr64Docs];
3857}
3858
3859def SPtr : TypeAttr {
3860  let Spellings = [CustomKeyword<"__sptr">];
3861  let Documentation = [SPtrDocs];
3862}
3863
3864def UPtr : TypeAttr {
3865  let Spellings = [CustomKeyword<"__uptr">];
3866  let Documentation = [UPtrDocs];
3867}
3868
3869def MSInheritance : InheritableAttr {
3870  let LangOpts = [MicrosoftExt];
3871  let Args = [DefaultBoolArgument<"BestCase", /*default*/1, /*fake*/1>];
3872  let Spellings = [CustomKeyword<"__single_inheritance">,
3873                   CustomKeyword<"__multiple_inheritance">,
3874                   CustomKeyword<"__virtual_inheritance">,
3875                   CustomKeyword<"__unspecified_inheritance">];
3876  let AdditionalMembers = [{
3877  MSInheritanceModel getInheritanceModel() const {
3878    // The spelling enum should agree with MSInheritanceModel.
3879    return MSInheritanceModel(getSemanticSpelling());
3880  }
3881  }];
3882  let Documentation = [MSInheritanceDocs];
3883}
3884
3885def MSVtorDisp : InheritableAttr {
3886  // This attribute has no spellings as it is only ever created implicitly.
3887  let Spellings = [];
3888  let Args = [UnsignedArgument<"vdm">];
3889  let SemaHandler = 0;
3890
3891  let AdditionalMembers = [{
3892  MSVtorDispMode getVtorDispMode() const { return MSVtorDispMode(vdm); }
3893  }];
3894  let Documentation = [InternalOnly];
3895}
3896
3897def InitSeg : Attr {
3898  let Spellings = [Pragma<"", "init_seg">];
3899  let Args = [StringArgument<"Section">];
3900  let SemaHandler = 0;
3901  let Documentation = [InitSegDocs];
3902  let AdditionalMembers = [{
3903  void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
3904    OS << " (" << getSection() << ')';
3905  }
3906  }];
3907}
3908
3909def LoopHint : Attr {
3910  /// #pragma clang loop <option> directive
3911  /// vectorize: vectorizes loop operations if State == Enable.
3912  /// vectorize_width: vectorize loop operations with width 'Value'.
3913  /// interleave: interleave multiple loop iterations if State == Enable.
3914  /// interleave_count: interleaves 'Value' loop iterations.
3915  /// unroll: fully unroll loop if State == Enable.
3916  /// unroll_count: unrolls loop 'Value' times.
3917  /// unroll_and_jam: attempt to unroll and jam loop if State == Enable.
3918  /// unroll_and_jam_count: unroll and jams loop 'Value' times.
3919  /// distribute: attempt to distribute loop if State == Enable.
3920  /// pipeline: disable pipelining loop if State == Disable.
3921  /// pipeline_initiation_interval: create loop schedule with initiation interval equal to 'Value'.
3922
3923  /// #pragma unroll <argument> directive
3924  /// <no arg>: fully unrolls loop.
3925  /// boolean: fully unrolls loop if State == Enable.
3926  /// expression: unrolls loop 'Value' times.
3927
3928  let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">,
3929                   Pragma<"", "nounroll">, Pragma<"", "unroll_and_jam">,
3930                   Pragma<"", "nounroll_and_jam">];
3931
3932  /// State of the loop optimization specified by the spelling.
3933  let Args = [EnumArgument<"Option", "OptionType",
3934                          ["vectorize", "vectorize_width", "interleave", "interleave_count",
3935                           "unroll", "unroll_count", "unroll_and_jam", "unroll_and_jam_count",
3936                           "pipeline", "pipeline_initiation_interval", "distribute",
3937                           "vectorize_predicate"],
3938                          ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
3939                           "Unroll", "UnrollCount", "UnrollAndJam", "UnrollAndJamCount",
3940                           "PipelineDisabled", "PipelineInitiationInterval", "Distribute",
3941                           "VectorizePredicate"]>,
3942              EnumArgument<"State", "LoopHintState",
3943                           ["enable", "disable", "numeric", "fixed_width",
3944                            "scalable_width", "assume_safety", "full"],
3945                           ["Enable", "Disable", "Numeric", "FixedWidth",
3946                            "ScalableWidth", "AssumeSafety", "Full"]>,
3947              ExprArgument<"Value">];
3948
3949  let AdditionalMembers = [{
3950  static const char *getOptionName(int Option) {
3951    switch(Option) {
3952    case Vectorize: return "vectorize";
3953    case VectorizeWidth: return "vectorize_width";
3954    case Interleave: return "interleave";
3955    case InterleaveCount: return "interleave_count";
3956    case Unroll: return "unroll";
3957    case UnrollCount: return "unroll_count";
3958    case UnrollAndJam: return "unroll_and_jam";
3959    case UnrollAndJamCount: return "unroll_and_jam_count";
3960    case PipelineDisabled: return "pipeline";
3961    case PipelineInitiationInterval: return "pipeline_initiation_interval";
3962    case Distribute: return "distribute";
3963    case VectorizePredicate: return "vectorize_predicate";
3964    }
3965    llvm_unreachable("Unhandled LoopHint option.");
3966  }
3967
3968  void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const;
3969
3970  // Return a string containing the loop hint argument including the
3971  // enclosing parentheses.
3972  std::string getValueString(const PrintingPolicy &Policy) const;
3973
3974  // Return a string suitable for identifying this attribute in diagnostics.
3975  std::string getDiagnosticName(const PrintingPolicy &Policy) const;
3976  }];
3977
3978  let Documentation = [LoopHintDocs, UnrollHintDocs];
3979  let HasCustomParsing = 1;
3980}
3981
3982def CapturedRecord : InheritableAttr {
3983  // This attribute has no spellings as it is only ever created implicitly.
3984  let Spellings = [];
3985  let SemaHandler = 0;
3986  let Documentation = [InternalOnly];
3987}
3988
3989def OMPThreadPrivateDecl : InheritableAttr {
3990  // This attribute has no spellings as it is only ever created implicitly.
3991  let Spellings = [];
3992  let SemaHandler = 0;
3993  let Documentation = [InternalOnly];
3994}
3995
3996def OMPCaptureNoInit : InheritableAttr {
3997  // This attribute has no spellings as it is only ever created implicitly.
3998  let Spellings = [];
3999  let SemaHandler = 0;
4000  let Documentation = [InternalOnly];
4001}
4002
4003def OMPCaptureKind : Attr {
4004  // This attribute has no spellings as it is only ever created implicitly.
4005  let Spellings = [];
4006  let SemaHandler = 0;
4007  let Args = [UnsignedArgument<"CaptureKindVal">];
4008  let Documentation = [InternalOnly];
4009  let AdditionalMembers = [{
4010    llvm::omp::Clause getCaptureKind() const {
4011      return static_cast<llvm::omp::Clause>(getCaptureKindVal());
4012    }
4013  }];
4014}
4015
4016def OMPReferencedVar : Attr {
4017  // This attribute has no spellings as it is only ever created implicitly.
4018  let Spellings = [];
4019  let SemaHandler = 0;
4020  let Args = [ExprArgument<"Ref">];
4021  let Documentation = [InternalOnly];
4022}
4023
4024def OMPDeclareSimdDecl : Attr {
4025  let Spellings = [Pragma<"omp", "declare simd">];
4026  let Subjects = SubjectList<[Function]>;
4027  let SemaHandler = 0;
4028  let HasCustomParsing = 1;
4029  let Documentation = [OMPDeclareSimdDocs];
4030  let Args = [
4031    EnumArgument<"BranchState", "BranchStateTy",
4032                 [ "", "inbranch", "notinbranch" ],
4033                 [ "BS_Undefined", "BS_Inbranch", "BS_Notinbranch" ]>,
4034    ExprArgument<"Simdlen">, VariadicExprArgument<"Uniforms">,
4035    VariadicExprArgument<"Aligneds">, VariadicExprArgument<"Alignments">,
4036    VariadicExprArgument<"Linears">, VariadicUnsignedArgument<"Modifiers">,
4037    VariadicExprArgument<"Steps">
4038  ];
4039  let AdditionalMembers = [{
4040    void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
4041        const;
4042  }];
4043}
4044
4045def OMPDeclareTargetDecl : InheritableAttr {
4046  let Spellings = [Pragma<"omp", "declare target">];
4047  let SemaHandler = 0;
4048  let Subjects = SubjectList<[Function, SharedVar]>;
4049  let Documentation = [OMPDeclareTargetDocs];
4050  let Args = [
4051    EnumArgument<"MapType", "MapTypeTy",
4052                 [ "to", "enter", "link" ],
4053                 [ "MT_To", "MT_Enter", "MT_Link" ]>,
4054    EnumArgument<"DevType", "DevTypeTy",
4055                 [ "host", "nohost", "any" ],
4056                 [ "DT_Host", "DT_NoHost", "DT_Any" ]>,
4057    ExprArgument<"IndirectExpr">,
4058    BoolArgument<"Indirect">,
4059    UnsignedArgument<"Level">
4060  ];
4061  let AdditionalMembers = [{
4062    void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const;
4063    static std::optional<MapTypeTy>
4064    isDeclareTargetDeclaration(const ValueDecl *VD);
4065    static std::optional<OMPDeclareTargetDeclAttr*> getActiveAttr(const ValueDecl *VD);
4066    static std::optional<DevTypeTy> getDeviceType(const ValueDecl *VD);
4067    static std::optional<SourceLocation> getLocation(const ValueDecl *VD);
4068  }];
4069}
4070
4071def OMPAllocateDecl : InheritableAttr {
4072  // This attribute has no spellings as it is only ever created implicitly.
4073  let Spellings = [];
4074  let SemaHandler = 0;
4075  let Args = [
4076    EnumArgument<"AllocatorType", "AllocatorTypeTy",
4077                 [
4078                   "omp_null_allocator", "omp_default_mem_alloc",
4079                   "omp_large_cap_mem_alloc", "omp_const_mem_alloc",
4080                   "omp_high_bw_mem_alloc", "omp_low_lat_mem_alloc",
4081                   "omp_cgroup_mem_alloc", "omp_pteam_mem_alloc",
4082                   "omp_thread_mem_alloc", ""
4083                 ],
4084                 [
4085                   "OMPNullMemAlloc", "OMPDefaultMemAlloc",
4086                   "OMPLargeCapMemAlloc", "OMPConstMemAlloc",
4087                   "OMPHighBWMemAlloc", "OMPLowLatMemAlloc",
4088                   "OMPCGroupMemAlloc", "OMPPTeamMemAlloc", "OMPThreadMemAlloc",
4089                   "OMPUserDefinedMemAlloc"
4090                 ]>,
4091    ExprArgument<"Allocator">,
4092    ExprArgument<"Alignment">
4093  ];
4094  let Documentation = [InternalOnly];
4095}
4096
4097def OMPDeclareVariant : InheritableAttr {
4098  let Spellings = [Pragma<"omp", "declare variant">];
4099  let Subjects = SubjectList<[Function]>;
4100  let SemaHandler = 0;
4101  let HasCustomParsing = 1;
4102  let InheritEvenIfAlreadyPresent = 1;
4103  let Documentation = [OMPDeclareVariantDocs];
4104  let Args = [
4105    ExprArgument<"VariantFuncRef">,
4106    OMPTraitInfoArgument<"TraitInfos">,
4107    VariadicExprArgument<"AdjustArgsNothing">,
4108    VariadicExprArgument<"AdjustArgsNeedDevicePtr">,
4109    VariadicOMPInteropInfoArgument<"AppendArgs">,
4110  ];
4111  let AdditionalMembers = [{
4112    OMPTraitInfo &getTraitInfo() { return *traitInfos; }
4113    void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
4114        const;
4115    static StringRef getInteropTypeString(const OMPInteropInfo *I) {
4116      if (I->IsTarget && I->IsTargetSync)
4117        return "target,targetsync";
4118      if (I->IsTarget)
4119        return "target";
4120      return "targetsync";
4121    }
4122  }];
4123}
4124
4125def Assumption : InheritableAttr {
4126  let Spellings = [Clang<"assume">];
4127  let Subjects = SubjectList<[Function, ObjCMethod]>;
4128  let InheritEvenIfAlreadyPresent = 1;
4129  let Documentation = [AssumptionDocs];
4130  let Args = [StringArgument<"Assumption">];
4131}
4132
4133def InternalLinkage : InheritableAttr {
4134  let Spellings = [Clang<"internal_linkage">];
4135  let Subjects = SubjectList<[Var, Function, CXXRecord]>;
4136  let Documentation = [InternalLinkageDocs];
4137}
4138def : MutualExclusions<[Common, InternalLinkage]>;
4139
4140def ExcludeFromExplicitInstantiation : InheritableAttr {
4141  let Spellings = [Clang<"exclude_from_explicit_instantiation">];
4142  let Subjects = SubjectList<[Var, Function, CXXRecord]>;
4143  let Documentation = [ExcludeFromExplicitInstantiationDocs];
4144  let MeaningfulToClassTemplateDefinition = 1;
4145  let SimpleHandler = 1;
4146}
4147
4148def Reinitializes : InheritableAttr {
4149  let Spellings = [Clang<"reinitializes", 0>];
4150  let Subjects = SubjectList<[NonStaticNonConstCXXMethod], ErrorDiag>;
4151  let Documentation = [ReinitializesDocs];
4152  let SimpleHandler = 1;
4153}
4154
4155def NoDestroy : InheritableAttr {
4156  let Spellings = [Clang<"no_destroy", 0>];
4157  let Subjects = SubjectList<[Var]>;
4158  let Documentation = [NoDestroyDocs];
4159}
4160
4161def AlwaysDestroy : InheritableAttr {
4162  let Spellings = [Clang<"always_destroy", 0>];
4163  let Subjects = SubjectList<[Var]>;
4164  let Documentation = [AlwaysDestroyDocs];
4165}
4166def : MutualExclusions<[NoDestroy, AlwaysDestroy]>;
4167
4168def SpeculativeLoadHardening : InheritableAttr {
4169  let Spellings = [Clang<"speculative_load_hardening">];
4170  let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
4171  let Documentation = [SpeculativeLoadHardeningDocs];
4172  let SimpleHandler = 1;
4173}
4174
4175def NoSpeculativeLoadHardening : InheritableAttr {
4176  let Spellings = [Clang<"no_speculative_load_hardening">];
4177  let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
4178  let Documentation = [NoSpeculativeLoadHardeningDocs];
4179  let SimpleHandler = 1;
4180}
4181def : MutualExclusions<[SpeculativeLoadHardening, NoSpeculativeLoadHardening]>;
4182
4183def Uninitialized : InheritableAttr {
4184  let Spellings = [Clang<"uninitialized", 0>];
4185  let Subjects = SubjectList<[LocalVar]>;
4186  let PragmaAttributeSupport = 1;
4187  let Documentation = [UninitializedDocs];
4188}
4189
4190def LoaderUninitialized : Attr {
4191  let Spellings = [Clang<"loader_uninitialized">];
4192  let Subjects = SubjectList<[GlobalVar]>;
4193  let Documentation = [LoaderUninitializedDocs];
4194  let SimpleHandler = 1;
4195}
4196
4197def ObjCExternallyRetained : InheritableAttr {
4198  let LangOpts = [ObjCAutoRefCount];
4199  let Spellings = [Clang<"objc_externally_retained">];
4200  let Subjects = SubjectList<[NonParmVar, Function, Block, ObjCMethod]>;
4201  let Documentation = [ObjCExternallyRetainedDocs];
4202}
4203
4204def NoBuiltin : Attr {
4205  let Spellings = [Clang<"no_builtin">];
4206  let Args = [VariadicStringArgument<"BuiltinNames">];
4207  let Subjects = SubjectList<[Function]>;
4208  let Documentation = [NoBuiltinDocs];
4209}
4210
4211def UsingIfExists : InheritableAttr {
4212  let Spellings = [Clang<"using_if_exists", 0>];
4213  let Subjects = SubjectList<[Using,
4214                              UnresolvedUsingTypename,
4215                              UnresolvedUsingValue], ErrorDiag>;
4216  let Documentation = [UsingIfExistsDocs];
4217}
4218
4219// FIXME: This attribute is not inheritable, it will not be propagated to
4220// redecls. [[clang::lifetimebound]] has the same problems. This should be
4221// fixed in TableGen (by probably adding a new inheritable flag).
4222def AcquireHandle : DeclOrTypeAttr {
4223  let Spellings = [Clang<"acquire_handle">];
4224  let Args = [StringArgument<"HandleType">];
4225  let Subjects = SubjectList<[Function, TypedefName, ParmVar]>;
4226  let Documentation = [AcquireHandleDocs];
4227}
4228
4229def UseHandle : InheritableParamAttr {
4230  let Spellings = [Clang<"use_handle">];
4231  let Args = [StringArgument<"HandleType">];
4232  let Subjects = SubjectList<[ParmVar]>;
4233  let Documentation = [UseHandleDocs];
4234}
4235
4236def ReleaseHandle : InheritableParamAttr {
4237  let Spellings = [Clang<"release_handle">];
4238  let Args = [StringArgument<"HandleType">];
4239  let Subjects = SubjectList<[ParmVar]>;
4240  let Documentation = [ReleaseHandleDocs];
4241}
4242
4243def UnsafeBufferUsage : InheritableAttr {
4244  let Spellings = [Clang<"unsafe_buffer_usage">];
4245  let Subjects = SubjectList<[Function]>;
4246  let Documentation = [UnsafeBufferUsageDocs];
4247}
4248
4249def DiagnoseAsBuiltin : InheritableAttr {
4250  let Spellings = [Clang<"diagnose_as_builtin">];
4251  let Args = [DeclArgument<Function, "Function">,
4252              VariadicUnsignedArgument<"ArgIndices">];
4253  let Subjects = SubjectList<[Function]>;
4254  let Documentation = [DiagnoseAsBuiltinDocs];
4255}
4256
4257def Builtin : InheritableAttr {
4258  let Spellings = [];
4259  let Args = [UnsignedArgument<"ID">];
4260  let Subjects = SubjectList<[Function]>;
4261  let SemaHandler = 0;
4262  let Documentation = [InternalOnly];
4263}
4264
4265def EnforceTCB : InheritableAttr {
4266  let Spellings = [Clang<"enforce_tcb">];
4267  let Subjects = SubjectList<[Function, ObjCMethod]>;
4268  let Args = [StringArgument<"TCBName">];
4269  let Documentation = [EnforceTCBDocs];
4270  bit InheritEvenIfAlreadyPresent = 1;
4271}
4272
4273def EnforceTCBLeaf : InheritableAttr {
4274  let Spellings = [Clang<"enforce_tcb_leaf">];
4275  let Subjects = SubjectList<[Function, ObjCMethod]>;
4276  let Args = [StringArgument<"TCBName">];
4277  let Documentation = [EnforceTCBLeafDocs];
4278  bit InheritEvenIfAlreadyPresent = 1;
4279}
4280
4281def Error : InheritableAttr {
4282  let Spellings = [GCC<"error">, GCC<"warning">];
4283  let Accessors = [Accessor<"isError", [GCC<"error">]>,
4284                   Accessor<"isWarning", [GCC<"warning">]>];
4285  let Args = [StringArgument<"UserDiagnostic">];
4286  let Subjects = SubjectList<[Function], ErrorDiag>;
4287  let Documentation = [ErrorAttrDocs];
4288}
4289
4290def HLSLNumThreads: InheritableAttr {
4291  let Spellings = [Microsoft<"numthreads">];
4292  let Args = [IntArgument<"X">, IntArgument<"Y">, IntArgument<"Z">];
4293  let Subjects = SubjectList<[HLSLEntry]>;
4294  let LangOpts = [HLSL];
4295  let Documentation = [NumThreadsDocs];
4296}
4297
4298def HLSLSV_GroupIndex: HLSLAnnotationAttr {
4299  let Spellings = [HLSLSemantic<"SV_GroupIndex">];
4300  let Subjects = SubjectList<[ParmVar, GlobalVar]>;
4301  let LangOpts = [HLSL];
4302  let Documentation = [HLSLSV_GroupIndexDocs];
4303}
4304
4305def HLSLResourceBinding: InheritableAttr {
4306  let Spellings = [HLSLSemantic<"register">];
4307  let Subjects = SubjectList<[HLSLBufferObj, ExternalGlobalVar]>;
4308  let LangOpts = [HLSL];
4309  let Args = [StringArgument<"Slot">, StringArgument<"Space", 1>];
4310  let Documentation = [HLSLResourceBindingDocs];
4311}
4312
4313def HLSLSV_DispatchThreadID: HLSLAnnotationAttr {
4314  let Spellings = [HLSLSemantic<"SV_DispatchThreadID">];
4315  let Subjects = SubjectList<[ParmVar, Field]>;
4316  let LangOpts = [HLSL];
4317  let Documentation = [HLSLSV_DispatchThreadIDDocs];
4318}
4319
4320def HLSLShader : InheritableAttr {
4321  let Spellings = [Microsoft<"shader">];
4322  let Subjects = SubjectList<[HLSLEntry]>;
4323  let LangOpts = [HLSL];
4324  let Args = [
4325    EnumArgument<"Type", "ShaderType",
4326                 ["pixel", "vertex", "geometry", "hull", "domain", "compute",
4327                  "raygeneration", "intersection", "anyhit", "closesthit",
4328                  "miss", "callable", "mesh", "amplification"],
4329                 ["Pixel", "Vertex", "Geometry", "Hull", "Domain", "Compute",
4330                  "RayGeneration", "Intersection", "AnyHit", "ClosestHit",
4331                  "Miss", "Callable", "Mesh", "Amplification"]>
4332  ];
4333  let Documentation = [HLSLSV_ShaderTypeAttrDocs];
4334}
4335
4336def HLSLResource : InheritableAttr {
4337  let Spellings = [];
4338  let Subjects = SubjectList<[Struct]>;
4339  let LangOpts = [HLSL];
4340  let Args = [EnumArgument<"ResourceClass", "llvm::hlsl::ResourceClass",
4341                           ["SRV", "UAV", "CBuffer", "Sampler"],
4342                           ["SRV", "UAV", "CBuffer", "Sampler"],
4343                           /*opt=*/0, /*fake=*/0, /*isExternalType=*/1>,
4344              EnumArgument<"ResourceKind", "llvm::hlsl::ResourceKind",
4345                           ["Texture1D", "Texture2D", "Texture2DMS",
4346                            "Texture3D", "TextureCube", "Texture1DArray",
4347                            "Texture2DArray", "Texture2DMSArray",
4348                            "TextureCubeArray", "TypedBuffer", "RawBuffer",
4349                            "StructuredBuffer", "CBuffer", "Sampler",
4350                            "TBuffer", "RTAccelerationStructure",
4351                            "FeedbackTexture2D", "FeedbackTexture2DArray"],
4352                           ["Texture1D", "Texture2D", "Texture2DMS",
4353                            "Texture3D", "TextureCube", "Texture1DArray",
4354                            "Texture2DArray", "Texture2DMSArray",
4355                            "TextureCubeArray", "TypedBuffer", "RawBuffer",
4356                            "StructuredBuffer", "CBuffer", "Sampler",
4357                            "TBuffer", "RTAccelerationStructure",
4358                            "FeedbackTexture2D", "FeedbackTexture2DArray"],
4359                           /*opt=*/0, /*fake=*/0, /*isExternalType=*/1>,
4360              DefaultBoolArgument<"isROV", /*default=*/0>
4361              ];
4362  let Documentation = [InternalOnly];
4363}
4364
4365def HLSLGroupSharedAddressSpace : TypeAttr {
4366  let Spellings = [CustomKeyword<"groupshared">];
4367  let Subjects = SubjectList<[Var]>;
4368  let Documentation = [HLSLGroupSharedAddressSpaceDocs];
4369}
4370
4371def HLSLParamModifier : TypeAttr {
4372  let Spellings = [CustomKeyword<"in">, CustomKeyword<"inout">, CustomKeyword<"out">];
4373  let Accessors = [Accessor<"isIn", [CustomKeyword<"in">]>,
4374                   Accessor<"isInOut", [CustomKeyword<"inout">]>,
4375                   Accessor<"isOut", [CustomKeyword<"out">]>,
4376                   Accessor<"isAnyOut", [CustomKeyword<"out">, CustomKeyword<"inout">]>,
4377                   Accessor<"isAnyIn", [CustomKeyword<"in">, CustomKeyword<"inout">]>];
4378  let Subjects = SubjectList<[ParmVar]>;
4379  let Documentation = [HLSLParamQualifierDocs];
4380  let Args = [DefaultBoolArgument<"MergedSpelling", /*default*/0, /*fake*/1>];
4381}
4382
4383def RandomizeLayout : InheritableAttr {
4384  let Spellings = [GCC<"randomize_layout">];
4385  let Subjects = SubjectList<[Record]>;
4386  let Documentation = [ClangRandomizeLayoutDocs];
4387  let LangOpts = [COnly];
4388}
4389
4390def NoRandomizeLayout : InheritableAttr {
4391  let Spellings = [GCC<"no_randomize_layout">];
4392  let Subjects = SubjectList<[Record]>;
4393  let Documentation = [ClangRandomizeLayoutDocs];
4394  let LangOpts = [COnly];
4395}
4396def : MutualExclusions<[RandomizeLayout, NoRandomizeLayout]>;
4397
4398def FunctionReturnThunks : InheritableAttr,
4399    TargetSpecificAttr<TargetAnyX86> {
4400  let Spellings = [GCC<"function_return">];
4401  let Args = [EnumArgument<"ThunkType", "Kind",
4402    ["keep", "thunk-extern"],
4403    ["Keep", "Extern"]
4404  >];
4405  let Subjects = SubjectList<[Function]>;
4406  let Documentation = [FunctionReturnThunksDocs];
4407}
4408
4409def WebAssemblyFuncref : TypeAttr, TargetSpecificAttr<TargetWebAssembly> {
4410  let Spellings = [CustomKeyword<"__funcref">];
4411  let Documentation = [WebAssemblyExportNameDocs];
4412  let Subjects = SubjectList<[FunctionPointer], ErrorDiag>;
4413}
4414
4415def ReadOnlyPlacement : InheritableAttr {
4416  let Spellings = [Clang<"enforce_read_only_placement">];
4417  let Subjects = SubjectList<[Record]>;
4418  let Documentation = [ReadOnlyPlacementDocs];
4419}
4420
4421def AvailableOnlyInDefaultEvalMethod : InheritableAttr {
4422  let Spellings = [Clang<"available_only_in_default_eval_method">];
4423  let Subjects = SubjectList<[TypedefName], ErrorDiag>;
4424  let Documentation = [Undocumented];
4425}
4426
4427def PreferredType: InheritableAttr {
4428  let Spellings = [Clang<"preferred_type">];
4429  let Subjects = SubjectList<[BitField], ErrorDiag>;
4430  let Args = [TypeArgument<"Type", 1>];
4431  let Documentation = [PreferredTypeDocumentation];
4432}
4433
4434def CodeAlign: StmtAttr {
4435  let Spellings = [Clang<"code_align">];
4436  let Subjects = SubjectList<[ForStmt, CXXForRangeStmt, WhileStmt, DoStmt],
4437                              ErrorDiag, "'for', 'while', and 'do' statements">;
4438  let Args = [ExprArgument<"Alignment">];
4439  let Documentation = [CodeAlignAttrDocs];
4440  let AdditionalMembers = [{
4441    static constexpr int MinimumAlignment = 1;
4442    static constexpr int MaximumAlignment = 4096;
4443  }];
4444}
4445
4446def CountedBy : InheritableAttr {
4447  let Spellings = [Clang<"counted_by">];
4448  let Subjects = SubjectList<[Field]>;
4449  let Args = [IdentifierArgument<"CountedByField">];
4450  let Documentation = [CountedByDocs];
4451  let LangOpts = [COnly];
4452  // FIXME: This is ugly. Let using a DeclArgument would be nice, but a Decl
4453  // isn't yet available due to the fact that we're still parsing the
4454  // structure. Maybe that code could be changed sometime in the future.
4455  code AdditionalMembers = [{
4456    private:
4457      SourceRange CountedByFieldLoc;
4458    public:
4459      SourceRange getCountedByFieldLoc() const { return CountedByFieldLoc; }
4460      void setCountedByFieldLoc(SourceRange Loc) { CountedByFieldLoc = Loc; }
4461  }];
4462}
4463