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