1 //==--- Attr.td - attribute definitions -----------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // The documentation is organized by category. Attributes can have category-
10 // specific documentation that is collated within the larger document.
11 class DocumentationCategory<string name> {
15 def DocCatFunction : DocumentationCategory<"Function Attributes">;
16 def DocCatVariable : DocumentationCategory<"Variable Attributes">;
17 def DocCatField : DocumentationCategory<"Field Attributes">;
18 def DocCatType : DocumentationCategory<"Type Attributes">;
19 def DocCatStmt : DocumentationCategory<"Statement Attributes">;
20 def DocCatDecl : DocumentationCategory<"Declaration Attributes">;
22 // Attributes listed under the Undocumented category do not generate any public
23 // documentation. Ideally, this category should be used for internal-only
24 // attributes which contain no spellings.
25 def DocCatUndocumented : DocumentationCategory<"Undocumented">;
27 class DocDeprecated<string replacement = ""> {
28 // If the Replacement field is empty, no replacement will be listed with the
29 // documentation. Otherwise, the documentation will specify the attribute has
30 // been superseded by this replacement.
31 string Replacement = replacement;
34 // Specifies the documentation to be associated with the given category.
36 DocumentationCategory Category;
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.
46 // When set, specifies that the attribute is deprecated and can optionally
47 // specify a replacement attribute.
48 DocDeprecated Deprecated;
51 // Specifies that the attribute is explicitly undocumented. This can be a
52 // helpful placeholder for the attribute while working on the implementation,
53 // but should not be used once feature work has been completed.
54 def Undocumented : Documentation {
55 let Category = DocCatUndocumented;
58 include "clang/Basic/AttrDocs.td"
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).
66 include "clang/Basic/DeclNodes.td"
67 include "clang/Basic/StmtNodes.td"
69 // A subset-subject is an AttrSubject constrained to operate only on some subset
72 // The code fragment is a boolean expression that will confirm that the subject
73 // meets the requirements; the subject will have the name S, and will have the
74 // type specified by the base. It should be a simple boolean expression. The
75 // diagnostic string should be a comma-separated list of subject names.
76 class SubsetSubject<AttrSubject base, code check, string diag> : AttrSubject {
77 AttrSubject Base = base;
78 code CheckCode = check;
79 string DiagSpelling = diag;
82 def LocalVar : SubsetSubject<Var,
83 [{S->hasLocalStorage() && !isa<ParmVarDecl>(S)}],
85 def NonParmVar : SubsetSubject<Var,
86 [{S->getKind() != Decl::ParmVar}],
88 def NonLocalVar : SubsetSubject<Var,
89 [{!S->hasLocalStorage()}],
90 "variables with non-local storage">;
91 def NonBitField : SubsetSubject<Field,
93 "non-bit-field non-static data members">;
95 def NonStaticCXXMethod : SubsetSubject<CXXMethod,
97 "non-static member functions">;
99 def NonStaticNonConstCXXMethod
100 : SubsetSubject<CXXMethod,
101 [{!S->isStatic() && !S->isConst()}],
102 "non-static non-const member functions">;
104 def ObjCInstanceMethod : SubsetSubject<ObjCMethod,
105 [{S->isInstanceMethod()}],
106 "Objective-C instance methods">;
108 def Struct : SubsetSubject<Record,
109 [{!S->isUnion()}], "structs">;
111 def TLSVar : SubsetSubject<Var,
112 [{S->getTLSKind() != 0}], "thread-local variables">;
114 def SharedVar : SubsetSubject<Var,
115 [{S->hasGlobalStorage() && !S->getTLSKind()}],
118 def GlobalVar : SubsetSubject<Var,
119 [{S->hasGlobalStorage()}], "global variables">;
121 def InlineFunction : SubsetSubject<Function,
122 [{S->isInlineSpecified()}], "inline functions">;
124 // FIXME: this hack is needed because DeclNodes.td defines the base Decl node
125 // type to be a class, not a definition. This makes it impossible to create an
126 // attribute subject which accepts a Decl. Normally, this is not a problem,
127 // because the attribute can have no Subjects clause to accomplish this. But in
128 // the case of a SubsetSubject, there's no way to express it without this hack.
129 def DeclBase : AttrSubject;
130 def FunctionLike : SubsetSubject<DeclBase,
131 [{S->getFunctionType(false) != nullptr}],
132 "functions, function pointers">;
134 def OpenCLKernelFunction
135 : SubsetSubject<Function, [{S->hasAttr<OpenCLKernelAttr>()}],
138 // HasFunctionProto is a more strict version of FunctionLike, so it should
139 // never be specified in a Subjects list along with FunctionLike (due to the
140 // inclusive nature of subject testing).
141 def HasFunctionProto : SubsetSubject<DeclBase,
142 [{(S->getFunctionType(true) != nullptr &&
143 isa<FunctionProtoType>(S->getFunctionType())) ||
144 isa<ObjCMethodDecl>(S) ||
146 "non-K&R-style functions">;
148 // A subject that matches the implicit object parameter of a non-static member
149 // function. Accepted as a function type attribute on the type of such a
151 // FIXME: This does not actually ever match currently.
152 def ImplicitObjectParameter
153 : SubsetSubject<Function, [{static_cast<void>(S), false}],
154 "implicit object parameters">;
156 // A single argument to an attribute
157 class Argument<string name, bit optional, bit fake = 0> {
159 bit Optional = optional;
161 /// A fake argument is used to store and serialize additional information
162 /// in an attribute without actually changing its parsing or pretty-printing.
166 class BoolArgument<string name, bit opt = 0, bit fake = 0> : Argument<name, opt,
168 class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>;
169 class IntArgument<string name, bit opt = 0> : Argument<name, opt>;
170 class StringArgument<string name, bit opt = 0> : Argument<name, opt>;
171 class ExprArgument<string name, bit opt = 0> : Argument<name, opt>;
172 class FunctionArgument<string name, bit opt = 0, bit fake = 0> : Argument<name,
175 class NamedArgument<string name, bit opt = 0, bit fake = 0> : Argument<name,
178 class TypeArgument<string name, bit opt = 0> : Argument<name, opt>;
179 class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>;
180 class VariadicUnsignedArgument<string name> : Argument<name, 1>;
181 class VariadicExprArgument<string name> : Argument<name, 1>;
182 class VariadicStringArgument<string name> : Argument<name, 1>;
183 class VariadicIdentifierArgument<string name> : Argument<name, 1>;
185 // Like VariadicUnsignedArgument except values are ParamIdx.
186 class VariadicParamIdxArgument<string name> : Argument<name, 1>;
188 // A list of identifiers matching parameters or ParamIdx indices.
189 class VariadicParamOrParamIdxArgument<string name> : Argument<name, 1>;
191 // Like VariadicParamIdxArgument but for a single function parameter index.
192 class ParamIdxArgument<string name, bit opt = 0> : Argument<name, opt>;
194 // A version of the form major.minor[.subminor].
195 class VersionArgument<string name, bit opt = 0> : Argument<name, opt>;
197 // This one's a doozy, so it gets its own special type
198 // It can be an unsigned integer, or a type. Either can
200 class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>;
202 // A bool argument with a default value
203 class DefaultBoolArgument<string name, bit default, bit fake = 0>
204 : BoolArgument<name, 1, fake> {
205 bit Default = default;
208 // An integer argument with a default value
209 class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
210 int Default = default;
213 // This argument is more complex, it includes the enumerator type name,
214 // a list of strings to accept, and a list of enumerators to map them to.
215 class EnumArgument<string name, string type, list<string> values,
216 list<string> enums, bit opt = 0, bit fake = 0>
217 : Argument<name, opt, fake> {
219 list<string> Values = values;
220 list<string> Enums = enums;
223 // FIXME: There should be a VariadicArgument type that takes any other type
224 // of argument and generates the appropriate type.
225 class VariadicEnumArgument<string name, string type, list<string> values,
226 list<string> enums> : Argument<name, 1> {
228 list<string> Values = values;
229 list<string> Enums = enums;
232 // This handles one spelling of an attribute.
233 class Spelling<string name, string variety> {
235 string Variety = variety;
239 class GNU<string name> : Spelling<name, "GNU">;
240 class Declspec<string name> : Spelling<name, "Declspec">;
241 class Microsoft<string name> : Spelling<name, "Microsoft">;
242 class CXX11<string namespace, string name, int version = 1>
243 : Spelling<name, "CXX11"> {
244 string Namespace = namespace;
245 int Version = version;
247 class C2x<string namespace, string name> : Spelling<name, "C2x"> {
248 string Namespace = namespace;
251 class Keyword<string name> : Spelling<name, "Keyword">;
252 class Pragma<string namespace, string name> : Spelling<name, "Pragma"> {
253 string Namespace = namespace;
256 // The GCC spelling implies GNU<name> and CXX11<"gnu", name> and also sets
257 // KnownToGCC to 1. This spelling should be used for any GCC-compatible
259 class GCC<string name> : Spelling<name, "GCC"> {
263 // The Clang spelling implies GNU<name>, CXX11<"clang", name>, and optionally,
264 // C2x<"clang", name>. This spelling should be used for any Clang-specific
266 class Clang<string name, bit allowInC = 1> : Spelling<name, "Clang"> {
267 bit AllowInC = allowInC;
270 class Accessor<string name, list<Spelling> spellings> {
272 list<Spelling> Spellings = spellings;
275 class SubjectDiag<bit warn> {
278 def WarnDiag : SubjectDiag<1>;
279 def ErrorDiag : SubjectDiag<0>;
281 class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag,
282 string customDiag = ""> {
283 list<AttrSubject> Subjects = subjects;
284 SubjectDiag Diag = diag;
285 string CustomDiag = customDiag;
288 class LangOpt<string name, code customCode = [{}]> {
291 // A custom predicate, written as an expression evaluated in a context with
293 code CustomCode = customCode;
295 def MicrosoftExt : LangOpt<"MicrosoftExt">;
296 def Borland : LangOpt<"Borland">;
297 def CUDA : LangOpt<"CUDA">;
298 def HIP : LangOpt<"HIP">;
299 def COnly : LangOpt<"COnly", "!LangOpts.CPlusPlus">;
300 def CPlusPlus : LangOpt<"CPlusPlus">;
301 def OpenCL : LangOpt<"OpenCL">;
302 def RenderScript : LangOpt<"RenderScript">;
303 def ObjC : LangOpt<"ObjC">;
304 def BlocksSupported : LangOpt<"Blocks">;
305 def ObjCAutoRefCount : LangOpt<"ObjCAutoRefCount">;
306 def ObjCNonFragileRuntime : LangOpt<"ObjCNonFragileRuntime",
307 "LangOpts.ObjCRuntime.allowsClassStubs()">;
309 // Language option for CMSE extensions
310 def Cmse : LangOpt<"Cmse">;
312 // Defines targets for target-specific attributes. Empty lists are unchecked.
314 // Specifies Architectures for which the target applies, based off the
315 // ArchType enumeration in Triple.h.
316 list<string> Arches = [];
317 // Specifies Operating Systems for which the target applies, based off the
318 // OSType enumeration in Triple.h
320 // Specifies Object Formats for which the target applies, based off the
321 // ObjectFormatType enumeration in Triple.h
322 list<string> ObjectFormats;
323 // A custom predicate, written as an expression evaluated in a context
324 // with the following declarations in scope:
325 // const clang::TargetInfo &Target;
326 // const llvm::Triple &T = Target.getTriple();
327 code CustomCode = [{}];
330 class TargetArch<list<string> arches> : TargetSpec {
333 def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
334 def TargetAVR : TargetArch<["avr"]>;
335 def TargetMips32 : TargetArch<["mips", "mipsel"]>;
336 def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
337 def TargetMSP430 : TargetArch<["msp430"]>;
338 def TargetRISCV : TargetArch<["riscv32", "riscv64"]>;
339 def TargetX86 : TargetArch<["x86"]>;
340 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
341 def TargetWebAssembly : TargetArch<["wasm32", "wasm64"]>;
342 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
343 let OSes = ["Win32"];
345 def TargetItaniumCXXABI : TargetSpec {
346 let CustomCode = [{ Target.getCXXABI().isItaniumFamily() }];
348 def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
349 let CustomCode = [{ Target.getCXXABI().isMicrosoft() }];
351 def TargetELF : TargetSpec {
352 let ObjectFormats = ["ELF"];
355 // Attribute subject match rules that are used for #pragma clang attribute.
357 // A instance of AttrSubjectMatcherRule represents an individual match rule.
358 // An individual match rule can correspond to a number of different attribute
359 // subjects, e.g. "record" matching rule corresponds to the Record and
360 // CXXRecord attribute subjects.
362 // Match rules are used in the subject list of the #pragma clang attribute.
363 // Match rules can have sub-match rules that are instances of
364 // AttrSubjectMatcherSubRule. A sub-match rule can correspond to a number
365 // of different attribute subjects, and it can have a negated spelling as well.
366 // For example, "variable(unless(is_parameter))" matching rule corresponds to
367 // the NonParmVar attribute subject.
368 class AttrSubjectMatcherSubRule<string name, list<AttrSubject> subjects,
371 list<AttrSubject> Subjects = subjects;
372 bit Negated = negated;
373 // Lists language options, one of which is required to be true for the
374 // attribute to be applicable. If empty, the language options are taken
375 // from the parent matcher rule.
376 list<LangOpt> LangOpts = [];
378 class AttrSubjectMatcherRule<string name, list<AttrSubject> subjects,
379 list<AttrSubjectMatcherSubRule> subrules = []> {
381 list<AttrSubject> Subjects = subjects;
382 list<AttrSubjectMatcherSubRule> Constraints = subrules;
383 // Lists language options, one of which is required to be true for the
384 // attribute to be applicable. If empty, no language options are required.
385 list<LangOpt> LangOpts = [];
388 // function(is_member)
389 def SubRuleForCXXMethod : AttrSubjectMatcherSubRule<"is_member", [CXXMethod]> {
390 let LangOpts = [CPlusPlus];
392 def SubjectMatcherForFunction : AttrSubjectMatcherRule<"function", [Function], [
395 // hasType is abstract, it should be used with one of the sub-rules.
396 def SubjectMatcherForType : AttrSubjectMatcherRule<"hasType", [], [
397 AttrSubjectMatcherSubRule<"functionType", [FunctionLike]>
399 // FIXME: There's a matcher ambiguity with objc methods and blocks since
400 // functionType excludes them but functionProtoType includes them.
401 // AttrSubjectMatcherSubRule<"functionProtoType", [HasFunctionProto]>
403 def SubjectMatcherForTypedef : AttrSubjectMatcherRule<"type_alias",
405 def SubjectMatcherForRecord : AttrSubjectMatcherRule<"record", [Record,
408 AttrSubjectMatcherSubRule<"is_union", [Struct], 1>
410 def SubjectMatcherForEnum : AttrSubjectMatcherRule<"enum", [Enum]>;
411 def SubjectMatcherForEnumConstant : AttrSubjectMatcherRule<"enum_constant",
413 def SubjectMatcherForVar : AttrSubjectMatcherRule<"variable", [Var], [
414 AttrSubjectMatcherSubRule<"is_thread_local", [TLSVar]>,
415 AttrSubjectMatcherSubRule<"is_global", [GlobalVar]>,
416 AttrSubjectMatcherSubRule<"is_parameter", [ParmVar]>,
417 // unless(is_parameter)
418 AttrSubjectMatcherSubRule<"is_parameter", [NonParmVar], 1>
420 def SubjectMatcherForField : AttrSubjectMatcherRule<"field", [Field]>;
421 def SubjectMatcherForNamespace : AttrSubjectMatcherRule<"namespace",
423 let LangOpts = [CPlusPlus];
425 def SubjectMatcherForObjCInterface : AttrSubjectMatcherRule<"objc_interface",
427 let LangOpts = [ObjC];
429 def SubjectMatcherForObjCProtocol : AttrSubjectMatcherRule<"objc_protocol",
431 let LangOpts = [ObjC];
433 def SubjectMatcherForObjCCategory : AttrSubjectMatcherRule<"objc_category",
435 let LangOpts = [ObjC];
437 def SubjectMatcherForObjCImplementation :
438 AttrSubjectMatcherRule<"objc_implementation", [ObjCImpl]> {
439 let LangOpts = [ObjC];
441 def SubjectMatcherForObjCMethod : AttrSubjectMatcherRule<"objc_method",
443 AttrSubjectMatcherSubRule<"is_instance", [ObjCInstanceMethod]>
445 let LangOpts = [ObjC];
447 def SubjectMatcherForObjCProperty : AttrSubjectMatcherRule<"objc_property",
449 let LangOpts = [ObjC];
451 def SubjectMatcherForBlock : AttrSubjectMatcherRule<"block", [Block]> {
452 let LangOpts = [BlocksSupported];
455 // Aggregate attribute subject match rules are abstract match rules that can't
456 // be used directly in #pragma clang attribute. Instead, users have to use
457 // subject match rules that correspond to attribute subjects that derive from
458 // the specified subject.
459 class AttrSubjectMatcherAggregateRule<AttrSubject subject> {
460 AttrSubject Subject = subject;
463 def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule<Named>;
466 // The various ways in which an attribute can be spelled in source
467 list<Spelling> Spellings;
468 // The things to which an attribute can appertain
469 SubjectList Subjects;
470 // The arguments allowed on an attribute
471 list<Argument> Args = [];
472 // Accessors which should be generated for the attribute.
473 list<Accessor> Accessors = [];
474 // Set to true for attributes with arguments which require delayed parsing.
476 // Set to false to prevent an attribute from being propagated from a template
477 // to the instantiation.
479 // Set to true for attributes which must be instantiated within templates
480 bit TemplateDependent = 0;
481 // Set to true for attributes that have a corresponding AST node.
483 // Set to true for attributes which have handler in Sema.
485 // Set to true for attributes that are completely ignored.
487 // Set to true if the attribute's parsing does not match its semantic
488 // content. Eg) It parses 3 args, but semantically takes 4 args. Opts out of
489 // common attribute error checking.
490 bit HasCustomParsing = 0;
491 // Set to true if all of the attribute's arguments should be parsed in an
492 // unevaluated context.
493 bit ParseArgumentsAsUnevaluated = 0;
494 // Set to true if this attribute meaningful when applied to or inherited
495 // in a class template definition.
496 bit MeaningfulToClassTemplateDefinition = 0;
497 // Set to true if this attribute can be used with '#pragma clang attribute'.
498 // By default, an attribute is supported by the '#pragma clang attribute'
500 // - It has a subject list whose subjects can be represented using subject
502 // - It has GNU/CXX11 spelling and doesn't require delayed parsing.
503 bit PragmaAttributeSupport;
504 // Lists language options, one of which is required to be true for the
505 // attribute to be applicable. If empty, no language options are required.
506 list<LangOpt> LangOpts = [];
507 // Any additional text that should be included verbatim in the class.
508 // Note: Any additional data members will leak and should be constructed
509 // externally on the ASTContext.
510 code AdditionalMembers = [{}];
511 // Any documentation that should be associated with the attribute. Since an
512 // attribute may be documented under multiple categories, more than one
513 // Documentation entry may be listed.
514 list<Documentation> Documentation;
517 /// A type attribute is not processed on a declaration or a statement.
518 class TypeAttr : Attr;
520 /// A stmt attribute is not processed on a declaration or a type.
521 class StmtAttr : Attr;
523 /// An inheritable attribute is inherited by later redeclarations.
524 class InheritableAttr : Attr {
525 // Set to true if this attribute can be duplicated on a subject when inheriting
526 // attributes from prior declarations.
527 bit InheritEvenIfAlreadyPresent = 0;
530 /// Some attributes, like calling conventions, can appear in either the
531 /// declaration or the type position. These attributes are morally type
532 /// attributes, but have historically been written on declarations.
533 class DeclOrTypeAttr : InheritableAttr;
535 /// A target-specific attribute. This class is meant to be used as a mixin
536 /// with InheritableAttr or Attr depending on the attribute's needs.
537 class TargetSpecificAttr<TargetSpec target> {
538 TargetSpec Target = target;
539 // Attributes are generally required to have unique spellings for their names
540 // so that the parser can determine what kind of attribute it has parsed.
541 // However, target-specific attributes are special in that the attribute only
542 // "exists" for a given target. So two target-specific attributes can share
543 // the same name when they exist in different targets. To support this, a
544 // Kind can be explicitly specified for a target-specific attribute. This
545 // corresponds to the ParsedAttr::AT_* enum that is generated and it
546 // should contain a shared value between the attributes.
548 // Target-specific attributes which use this feature should ensure that the
549 // spellings match exactly between the attributes, and if the arguments or
550 // subjects differ, should specify HasCustomParsing = 1 and implement their
551 // own parsing and semantic handling requirements as-needed.
555 /// An inheritable parameter attribute is inherited by later
556 /// redeclarations, even when it's written on a parameter.
557 class InheritableParamAttr : InheritableAttr;
559 /// An attribute which changes the ABI rules for a specific parameter.
560 class ParameterABIAttr : InheritableParamAttr {
561 let Subjects = SubjectList<[ParmVar]>;
564 /// An ignored attribute, which we parse but discard with no checking.
565 class IgnoredAttr : Attr {
569 let Documentation = [Undocumented];
573 // Attributes begin here
577 let Spellings = [GCC<"abi_tag">];
578 let Args = [VariadicStringArgument<"Tags">];
579 let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag>;
580 let MeaningfulToClassTemplateDefinition = 1;
581 let Documentation = [AbiTagsDocs];
584 def AddressSpace : TypeAttr {
585 let Spellings = [Clang<"address_space">];
586 let Args = [IntArgument<"AddressSpace">];
587 let Documentation = [Undocumented];
591 let Spellings = [GCC<"alias">];
592 let Args = [StringArgument<"Aliasee">];
593 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
594 let Documentation = [Undocumented];
597 def Aligned : InheritableAttr {
598 let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">,
599 Keyword<"_Alignas">];
600 let Args = [AlignedArgument<"Alignment", 1>];
601 let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
602 Accessor<"isC11", [Keyword<"_Alignas">]>,
603 Accessor<"isAlignas", [Keyword<"alignas">,
604 Keyword<"_Alignas">]>,
605 Accessor<"isDeclspec",[Declspec<"align">]>];
606 let Documentation = [Undocumented];
609 def AlignValue : Attr {
611 // Unfortunately, this is semantically an assertion, not a directive
612 // (something else must ensure the alignment), so aligned_value is a
613 // probably a better name. We might want to add an aligned_value spelling in
614 // the future (and a corresponding C++ attribute), but this can be done
615 // later once we decide if we also want them to have slightly-different
616 // semantics than Intel's align_value.
618 // Does not get a [[]] spelling because the attribute is not exposed as such
621 // Intel's compiler on Windows also supports:
622 // , Declspec<"align_value">
624 let Args = [ExprArgument<"Alignment">];
625 let Subjects = SubjectList<[Var, TypedefName]>;
626 let Documentation = [AlignValueDocs];
629 def AlignMac68k : InheritableAttr {
630 // This attribute has no spellings as it is only ever created implicitly.
633 let Documentation = [Undocumented];
636 def AlwaysInline : InheritableAttr {
637 let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
638 let Subjects = SubjectList<[Function]>;
639 let Documentation = [Undocumented];
642 def Artificial : InheritableAttr {
643 let Spellings = [GCC<"artificial">];
644 let Subjects = SubjectList<[InlineFunction], WarnDiag>;
645 let Documentation = [ArtificialDocs];
648 def XRayInstrument : InheritableAttr {
649 let Spellings = [Clang<"xray_always_instrument">,
650 Clang<"xray_never_instrument">];
651 let Subjects = SubjectList<[Function, ObjCMethod]>;
652 let Accessors = [Accessor<"alwaysXRayInstrument",
653 [Clang<"xray_always_instrument">]>,
654 Accessor<"neverXRayInstrument",
655 [Clang<"xray_never_instrument">]>];
656 let Documentation = [XRayDocs];
659 def XRayLogArgs : InheritableAttr {
660 let Spellings = [Clang<"xray_log_args">];
661 let Subjects = SubjectList<[Function, ObjCMethod]>;
662 // This argument is a count not an index, so it has the same encoding (base
663 // 1 including C++ implicit this parameter) at the source and LLVM levels of
664 // representation, so ParamIdxArgument is inappropriate. It is never used
665 // at the AST level of representation, so it never needs to be adjusted not
666 // to include any C++ implicit this parameter. Thus, we just store it and
667 // use it as an unsigned that never needs adjustment.
668 let Args = [UnsignedArgument<"ArgumentCount">];
669 let Documentation = [XRayDocs];
672 def TLSModel : InheritableAttr {
673 let Spellings = [GCC<"tls_model">];
674 let Subjects = SubjectList<[TLSVar], ErrorDiag>;
675 let Args = [StringArgument<"Model">];
676 let Documentation = [TLSModelDocs];
679 def AnalyzerNoReturn : InheritableAttr {
680 // TODO: should this attribute be exposed with a [[]] spelling under the clang
681 // vendor namespace, or should it use a vendor namespace specific to the
683 let Spellings = [GNU<"analyzer_noreturn">];
684 // TODO: Add subject list.
685 let Documentation = [Undocumented];
688 def Annotate : InheritableParamAttr {
689 let Spellings = [Clang<"annotate">];
690 let Args = [StringArgument<"Annotation">];
691 // Ensure that the annotate attribute can be used with
692 // '#pragma clang attribute' even though it has no subject list.
693 let PragmaAttributeSupport = 1;
694 let Documentation = [Undocumented];
697 def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> {
698 // NOTE: If you add any additional spellings, MSP430Interrupt's,
699 // MipsInterrupt's and AnyX86Interrupt's spellings must match.
700 let Spellings = [GCC<"interrupt">];
701 let Args = [EnumArgument<"Interrupt", "InterruptType",
702 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
703 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
705 let ParseKind = "Interrupt";
706 let HasCustomParsing = 1;
707 let Documentation = [ARMInterruptDocs];
710 def AVRInterrupt : InheritableAttr, TargetSpecificAttr<TargetAVR> {
711 let Spellings = [GCC<"interrupt">];
712 let Subjects = SubjectList<[Function]>;
713 let ParseKind = "Interrupt";
714 let Documentation = [AVRInterruptDocs];
717 def AVRSignal : InheritableAttr, TargetSpecificAttr<TargetAVR> {
718 let Spellings = [GCC<"signal">];
719 let Subjects = SubjectList<[Function]>;
720 let Documentation = [AVRSignalDocs];
723 def AsmLabel : InheritableAttr {
724 let Spellings = [Keyword<"asm">, Keyword<"__asm__">];
725 let Args = [StringArgument<"Label">];
727 let Documentation = [Undocumented];
730 def Availability : InheritableAttr {
731 let Spellings = [Clang<"availability">];
732 let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
733 VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
734 BoolArgument<"unavailable">, StringArgument<"message">,
735 BoolArgument<"strict">, StringArgument<"replacement">,
736 IntArgument<"priority">];
737 let AdditionalMembers =
738 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
739 return llvm::StringSwitch<llvm::StringRef>(Platform)
740 .Case("android", "Android")
742 .Case("macos", "macOS")
743 .Case("tvos", "tvOS")
744 .Case("watchos", "watchOS")
745 .Case("ios_app_extension", "iOS (App Extension)")
746 .Case("macos_app_extension", "macOS (App Extension)")
747 .Case("tvos_app_extension", "tvOS (App Extension)")
748 .Case("watchos_app_extension", "watchOS (App Extension)")
749 .Case("swift", "Swift")
750 .Default(llvm::StringRef());
752 static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) {
753 return llvm::StringSwitch<llvm::StringRef>(Platform)
755 .Case("macos", "macOS")
756 .Case("tvos", "tvOS")
757 .Case("watchos", "watchOS")
758 .Case("ios_app_extension", "iOSApplicationExtension")
759 .Case("macos_app_extension", "macOSApplicationExtension")
760 .Case("tvos_app_extension", "tvOSApplicationExtension")
761 .Case("watchos_app_extension", "watchOSApplicationExtension")
764 static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) {
765 return llvm::StringSwitch<llvm::StringRef>(Platform)
767 .Case("macOS", "macos")
768 .Case("tvOS", "tvos")
769 .Case("watchOS", "watchos")
770 .Case("iOSApplicationExtension", "ios_app_extension")
771 .Case("macOSApplicationExtension", "macos_app_extension")
772 .Case("tvOSApplicationExtension", "tvos_app_extension")
773 .Case("watchOSApplicationExtension", "watchos_app_extension")
776 let HasCustomParsing = 1;
777 let InheritEvenIfAlreadyPresent = 1;
778 let Subjects = SubjectList<[Named]>;
779 let Documentation = [AvailabilityDocs];
782 def ExternalSourceSymbol : InheritableAttr {
783 let Spellings = [Clang<"external_source_symbol">];
784 let Args = [StringArgument<"language", 1>,
785 StringArgument<"definedIn", 1>,
786 BoolArgument<"generatedDeclaration", 1>];
787 let HasCustomParsing = 1;
788 let Subjects = SubjectList<[Named]>;
789 let Documentation = [ExternalSourceSymbolDocs];
792 def Blocks : InheritableAttr {
793 let Spellings = [Clang<"blocks">];
794 let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
795 let Documentation = [Undocumented];
798 def Bounded : IgnoredAttr {
799 // Does not have a [[]] spelling because the attribute is ignored.
800 let Spellings = [GNU<"bounded">];
803 def CarriesDependency : InheritableParamAttr {
804 let Spellings = [GNU<"carries_dependency">,
805 CXX11<"","carries_dependency", 200809>];
806 let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>;
807 let Documentation = [CarriesDependencyDocs];
810 def CDecl : DeclOrTypeAttr {
811 let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">];
812 // let Subjects = [Function, ObjCMethod];
813 let Documentation = [Undocumented];
816 // cf_audited_transfer indicates that the given function has been
817 // audited and has been marked with the appropriate cf_consumed and
818 // cf_returns_retained attributes. It is generally applied by
819 // '#pragma clang arc_cf_code_audited' rather than explicitly.
820 def CFAuditedTransfer : InheritableAttr {
821 let Spellings = [Clang<"cf_audited_transfer">];
822 let Subjects = SubjectList<[Function], ErrorDiag>;
823 let Documentation = [Undocumented];
826 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
827 // It indicates that the function has unknown or unautomatable
828 // transfer semantics.
829 def CFUnknownTransfer : InheritableAttr {
830 let Spellings = [Clang<"cf_unknown_transfer">];
831 let Subjects = SubjectList<[Function], ErrorDiag>;
832 let Documentation = [Undocumented];
835 def CFReturnsRetained : InheritableAttr {
836 let Spellings = [Clang<"cf_returns_retained">];
837 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
838 let Documentation = [RetainBehaviorDocs];
841 def CFReturnsNotRetained : InheritableAttr {
842 let Spellings = [Clang<"cf_returns_not_retained">];
843 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
844 let Documentation = [RetainBehaviorDocs];
847 def CFConsumed : InheritableParamAttr {
848 let Spellings = [Clang<"cf_consumed">];
849 let Subjects = SubjectList<[ParmVar]>;
850 let Documentation = [RetainBehaviorDocs];
853 // OSObject-based attributes.
854 def OSConsumed : InheritableParamAttr {
855 let Spellings = [Clang<"os_consumed">];
856 let Subjects = SubjectList<[ParmVar]>;
857 let Documentation = [RetainBehaviorDocs];
860 def OSReturnsRetained : InheritableAttr {
861 let Spellings = [Clang<"os_returns_retained">];
862 let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty, ParmVar]>;
863 let Documentation = [RetainBehaviorDocs];
866 def OSReturnsNotRetained : InheritableAttr {
867 let Spellings = [Clang<"os_returns_not_retained">];
868 let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty, ParmVar]>;
869 let Documentation = [RetainBehaviorDocs];
872 def OSReturnsRetainedOnZero : InheritableAttr {
873 let Spellings = [Clang<"os_returns_retained_on_zero">];
874 let Subjects = SubjectList<[ParmVar]>;
875 let Documentation = [RetainBehaviorDocs];
878 def OSReturnsRetainedOnNonZero : InheritableAttr {
879 let Spellings = [Clang<"os_returns_retained_on_non_zero">];
880 let Subjects = SubjectList<[ParmVar]>;
881 let Documentation = [RetainBehaviorDocs];
884 def OSConsumesThis : InheritableAttr {
885 let Spellings = [Clang<"os_consumes_this">];
886 let Subjects = SubjectList<[NonStaticCXXMethod]>;
887 let Documentation = [RetainBehaviorDocs];
890 def Cleanup : InheritableAttr {
891 let Spellings = [GCC<"cleanup">];
892 let Args = [FunctionArgument<"FunctionDecl">];
893 let Subjects = SubjectList<[LocalVar]>;
894 let Documentation = [Undocumented];
897 def Cold : InheritableAttr {
898 let Spellings = [GCC<"cold">];
899 let Subjects = SubjectList<[Function]>;
900 let Documentation = [Undocumented];
903 def Common : InheritableAttr {
904 let Spellings = [GCC<"common">];
905 let Subjects = SubjectList<[Var]>;
906 let Documentation = [Undocumented];
909 def Const : InheritableAttr {
910 let Spellings = [GCC<"const">, GCC<"__const">];
911 let Documentation = [Undocumented];
914 def Constructor : InheritableAttr {
915 let Spellings = [GCC<"constructor">];
916 let Args = [DefaultIntArgument<"Priority", 65535>];
917 let Subjects = SubjectList<[Function]>;
918 let Documentation = [Undocumented];
921 def CPUSpecific : InheritableAttr {
922 let Spellings = [Clang<"cpu_specific">, Declspec<"cpu_specific">];
923 let Args = [VariadicIdentifierArgument<"Cpus">];
924 let Subjects = SubjectList<[Function]>;
925 let Documentation = [CPUSpecificCPUDispatchDocs];
926 let AdditionalMembers = [{
927 IdentifierInfo *getCPUName(unsigned Index) const {
928 return *(cpus_begin() + Index);
933 def CPUDispatch : InheritableAttr {
934 let Spellings = [Clang<"cpu_dispatch">, Declspec<"cpu_dispatch">];
935 let Args = [VariadicIdentifierArgument<"Cpus">];
936 let Subjects = SubjectList<[Function]>;
937 let Documentation = [CPUSpecificCPUDispatchDocs];
940 // CUDA attributes are spelled __attribute__((attr)) or __declspec(__attr__),
941 // and they do not receive a [[]] spelling.
942 def CUDAConstant : InheritableAttr {
943 let Spellings = [GNU<"constant">, Declspec<"__constant__">];
944 let Subjects = SubjectList<[Var]>;
945 let LangOpts = [CUDA];
946 let Documentation = [Undocumented];
949 def CUDACudartBuiltin : IgnoredAttr {
950 let Spellings = [GNU<"cudart_builtin">, Declspec<"__cudart_builtin__">];
951 let LangOpts = [CUDA];
954 def CUDADevice : InheritableAttr {
955 let Spellings = [GNU<"device">, Declspec<"__device__">];
956 let Subjects = SubjectList<[Function, Var]>;
957 let LangOpts = [CUDA];
958 let Documentation = [Undocumented];
961 def HIPPinnedShadow : InheritableAttr {
962 let Spellings = [GNU<"hip_pinned_shadow">, Declspec<"__hip_pinned_shadow__">];
963 let Subjects = SubjectList<[Var]>;
964 let LangOpts = [HIP];
965 let Documentation = [HIPPinnedShadowDocs];
968 def CUDADeviceBuiltin : IgnoredAttr {
969 let Spellings = [GNU<"device_builtin">, Declspec<"__device_builtin__">];
970 let LangOpts = [CUDA];
973 def CUDADeviceBuiltinSurfaceType : IgnoredAttr {
974 let Spellings = [GNU<"device_builtin_surface_type">,
975 Declspec<"__device_builtin_surface_type__">];
976 let LangOpts = [CUDA];
979 def CUDADeviceBuiltinTextureType : IgnoredAttr {
980 let Spellings = [GNU<"device_builtin_texture_type">,
981 Declspec<"__device_builtin_texture_type__">];
982 let LangOpts = [CUDA];
985 def CUDAGlobal : InheritableAttr {
986 let Spellings = [GNU<"global">, Declspec<"__global__">];
987 let Subjects = SubjectList<[Function]>;
988 let LangOpts = [CUDA];
989 let Documentation = [Undocumented];
992 def CUDAHost : InheritableAttr {
993 let Spellings = [GNU<"host">, Declspec<"__host__">];
994 let Subjects = SubjectList<[Function]>;
995 let LangOpts = [CUDA];
996 let Documentation = [Undocumented];
999 def CUDAInvalidTarget : InheritableAttr {
1001 let Subjects = SubjectList<[Function]>;
1002 let LangOpts = [CUDA];
1003 let Documentation = [Undocumented];
1006 def CUDALaunchBounds : InheritableAttr {
1007 let Spellings = [GNU<"launch_bounds">, Declspec<"__launch_bounds__">];
1008 let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>];
1009 let LangOpts = [CUDA];
1010 let Subjects = SubjectList<[ObjCMethod, FunctionLike]>;
1011 // An AST node is created for this attribute, but is not used by other parts
1012 // of the compiler. However, this node needs to exist in the AST because
1013 // non-LLVM backends may be relying on the attribute's presence.
1014 let Documentation = [Undocumented];
1017 def CUDAShared : InheritableAttr {
1018 let Spellings = [GNU<"shared">, Declspec<"__shared__">];
1019 let Subjects = SubjectList<[Var]>;
1020 let LangOpts = [CUDA];
1021 let Documentation = [Undocumented];
1024 def C11NoReturn : InheritableAttr {
1025 let Spellings = [Keyword<"_Noreturn">];
1026 let Subjects = SubjectList<[Function], ErrorDiag>;
1027 let SemaHandler = 0;
1028 let Documentation = [C11NoReturnDocs];
1031 def CXX11NoReturn : InheritableAttr {
1032 let Spellings = [CXX11<"", "noreturn", 200809>];
1033 let Subjects = SubjectList<[Function], ErrorDiag>;
1034 let Documentation = [CXX11NoReturnDocs];
1037 // Similar to CUDA, OpenCL attributes do not receive a [[]] spelling because
1038 // the specification does not expose them with one currently.
1039 def OpenCLKernel : InheritableAttr {
1040 let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
1041 let Subjects = SubjectList<[Function], ErrorDiag>;
1042 let Documentation = [Undocumented];
1045 def OpenCLUnrollHint : InheritableAttr {
1046 let Spellings = [GNU<"opencl_unroll_hint">];
1047 let Args = [UnsignedArgument<"UnrollHint">];
1048 let Documentation = [OpenCLUnrollHintDocs];
1051 def OpenCLIntelReqdSubGroupSize: InheritableAttr {
1052 let Spellings = [GNU<"intel_reqd_sub_group_size">];
1053 let Args = [UnsignedArgument<"SubGroupSize">];
1054 let Subjects = SubjectList<[Function], ErrorDiag>;
1055 let Documentation = [OpenCLIntelReqdSubGroupSizeDocs];
1058 // This attribute is both a type attribute, and a declaration attribute (for
1059 // parameter variables).
1060 def OpenCLAccess : Attr {
1061 let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
1062 Keyword<"__write_only">, Keyword<"write_only">,
1063 Keyword<"__read_write">, Keyword<"read_write">];
1064 let Subjects = SubjectList<[ParmVar, TypedefName], ErrorDiag>;
1065 let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
1066 Keyword<"read_only">]>,
1067 Accessor<"isReadWrite", [Keyword<"__read_write">,
1068 Keyword<"read_write">]>,
1069 Accessor<"isWriteOnly", [Keyword<"__write_only">,
1070 Keyword<"write_only">]>];
1071 let Documentation = [OpenCLAccessDocs];
1074 def OpenCLPrivateAddressSpace : TypeAttr {
1075 let Spellings = [Keyword<"__private">, Keyword<"private">];
1076 let Documentation = [OpenCLAddressSpacePrivateDocs];
1079 def OpenCLGlobalAddressSpace : TypeAttr {
1080 let Spellings = [Keyword<"__global">, Keyword<"global">];
1081 let Documentation = [OpenCLAddressSpaceGlobalDocs];
1084 def OpenCLLocalAddressSpace : TypeAttr {
1085 let Spellings = [Keyword<"__local">, Keyword<"local">];
1086 let Documentation = [OpenCLAddressSpaceLocalDocs];
1089 def OpenCLConstantAddressSpace : TypeAttr {
1090 let Spellings = [Keyword<"__constant">, Keyword<"constant">];
1091 let Documentation = [OpenCLAddressSpaceConstantDocs];
1094 def OpenCLGenericAddressSpace : TypeAttr {
1095 let Spellings = [Keyword<"__generic">, Keyword<"generic">];
1096 let Documentation = [OpenCLAddressSpaceGenericDocs];
1099 def OpenCLNoSVM : Attr {
1100 let Spellings = [GNU<"nosvm">];
1101 let Subjects = SubjectList<[Var]>;
1102 let Documentation = [OpenCLNoSVMDocs];
1103 let LangOpts = [OpenCL];
1107 def RenderScriptKernel : Attr {
1108 let Spellings = [GNU<"kernel">];
1109 let Subjects = SubjectList<[Function]>;
1110 let Documentation = [RenderScriptKernelAttributeDocs];
1111 let LangOpts = [RenderScript];
1114 def Deprecated : InheritableAttr {
1115 let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
1116 CXX11<"","deprecated", 201309>, C2x<"", "deprecated">];
1117 let Args = [StringArgument<"Message", 1>,
1118 // An optional string argument that enables us to provide a
1120 StringArgument<"Replacement", 1>];
1121 let MeaningfulToClassTemplateDefinition = 1;
1122 let Documentation = [DeprecatedDocs];
1125 def Destructor : InheritableAttr {
1126 let Spellings = [GCC<"destructor">];
1127 let Args = [DefaultIntArgument<"Priority", 65535>];
1128 let Subjects = SubjectList<[Function]>;
1129 let Documentation = [Undocumented];
1132 def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
1133 let Spellings = [Declspec<"empty_bases">];
1134 let Subjects = SubjectList<[CXXRecord]>;
1135 let Documentation = [EmptyBasesDocs];
1138 def AllocSize : InheritableAttr {
1139 let Spellings = [GCC<"alloc_size">];
1140 let Subjects = SubjectList<[Function]>;
1141 let Args = [ParamIdxArgument<"ElemSizeParam">,
1142 ParamIdxArgument<"NumElemsParam", /*opt*/ 1>];
1143 let TemplateDependent = 1;
1144 let Documentation = [AllocSizeDocs];
1147 def EnableIf : InheritableAttr {
1148 // Does not have a [[]] spelling because this attribute requires the ability
1149 // to parse function arguments but the attribute is not written in the type
1151 let Spellings = [GNU<"enable_if">];
1152 let Subjects = SubjectList<[Function]>;
1153 let Args = [ExprArgument<"Cond">, StringArgument<"Message">];
1154 let TemplateDependent = 1;
1155 let Documentation = [EnableIfDocs];
1158 def ExtVectorType : Attr {
1159 // This is an OpenCL-related attribute and does not receive a [[]] spelling.
1160 let Spellings = [GNU<"ext_vector_type">];
1161 // FIXME: This subject list is wrong; this is a type attribute.
1162 let Subjects = SubjectList<[TypedefName], ErrorDiag>;
1163 let Args = [ExprArgument<"NumElements">];
1165 let Documentation = [Undocumented];
1166 // This is a type attribute with an incorrect subject list, so should not be
1167 // permitted by #pragma clang attribute.
1168 let PragmaAttributeSupport = 0;
1171 def FallThrough : StmtAttr {
1172 let Spellings = [CXX11<"", "fallthrough", 201603>, C2x<"", "fallthrough">,
1173 CXX11<"clang", "fallthrough">];
1174 // let Subjects = [NullStmt];
1175 let Documentation = [FallthroughDocs];
1178 def FastCall : DeclOrTypeAttr {
1179 let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
1180 Keyword<"_fastcall">];
1181 // let Subjects = [Function, ObjCMethod];
1182 let Documentation = [FastCallDocs];
1185 def RegCall : DeclOrTypeAttr {
1186 let Spellings = [GCC<"regcall">, Keyword<"__regcall">];
1187 let Documentation = [RegCallDocs];
1190 def Final : InheritableAttr {
1191 let Spellings = [Keyword<"final">, Keyword<"sealed">];
1192 let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
1193 let SemaHandler = 0;
1194 let Documentation = [Undocumented];
1197 def MinSize : InheritableAttr {
1198 let Spellings = [Clang<"minsize">];
1199 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
1200 let Documentation = [Undocumented];
1203 def FlagEnum : InheritableAttr {
1204 let Spellings = [Clang<"flag_enum">];
1205 let Subjects = SubjectList<[Enum]>;
1206 let Documentation = [FlagEnumDocs];
1209 def EnumExtensibility : InheritableAttr {
1210 let Spellings = [Clang<"enum_extensibility">];
1211 let Subjects = SubjectList<[Enum]>;
1212 let Args = [EnumArgument<"Extensibility", "Kind",
1213 ["closed", "open"], ["Closed", "Open"]>];
1214 let Documentation = [EnumExtensibilityDocs];
1217 def Flatten : InheritableAttr {
1218 let Spellings = [GCC<"flatten">];
1219 let Subjects = SubjectList<[Function], ErrorDiag>;
1220 let Documentation = [FlattenDocs];
1223 def Format : InheritableAttr {
1224 let Spellings = [GCC<"format">];
1225 let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
1226 IntArgument<"FirstArg">];
1227 let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto]>;
1228 let Documentation = [FormatDocs];
1231 def FormatArg : InheritableAttr {
1232 let Spellings = [GCC<"format_arg">];
1233 let Args = [ParamIdxArgument<"FormatIdx">];
1234 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto]>;
1235 let Documentation = [Undocumented];
1238 def Callback : InheritableAttr {
1239 let Spellings = [Clang<"callback">];
1240 let Args = [VariadicParamOrParamIdxArgument<"Encoding">];
1241 let Subjects = SubjectList<[Function]>;
1242 let Documentation = [CallbackDocs];
1245 def GNUInline : InheritableAttr {
1246 let Spellings = [GCC<"gnu_inline">];
1247 let Subjects = SubjectList<[Function]>;
1248 let Documentation = [GnuInlineDocs];
1251 def Hot : InheritableAttr {
1252 let Spellings = [GCC<"hot">];
1253 let Subjects = SubjectList<[Function]>;
1254 // An AST node is created for this attribute, but not actually used beyond
1255 // semantic checking for mutual exclusion with the Cold attribute.
1256 let Documentation = [Undocumented];
1259 def IBAction : InheritableAttr {
1260 let Spellings = [Clang<"ibaction">];
1261 let Subjects = SubjectList<[ObjCInstanceMethod]>;
1262 // An AST node is created for this attribute, but is not used by other parts
1263 // of the compiler. However, this node needs to exist in the AST because
1264 // external tools rely on it.
1265 let Documentation = [Undocumented];
1268 def IBOutlet : InheritableAttr {
1269 let Spellings = [Clang<"iboutlet">];
1270 // let Subjects = [ObjCIvar, ObjCProperty];
1271 let Documentation = [Undocumented];
1274 def IBOutletCollection : InheritableAttr {
1275 let Spellings = [Clang<"iboutletcollection">];
1276 let Args = [TypeArgument<"Interface", 1>];
1277 // let Subjects = [ObjCIvar, ObjCProperty];
1278 let Documentation = [Undocumented];
1281 def IFunc : Attr, TargetSpecificAttr<TargetELF> {
1282 let Spellings = [GCC<"ifunc">];
1283 let Args = [StringArgument<"Resolver">];
1284 let Subjects = SubjectList<[Function]>;
1285 let Documentation = [IFuncDocs];
1288 def Restrict : InheritableAttr {
1289 let Spellings = [Declspec<"restrict">, GCC<"malloc">];
1290 let Subjects = SubjectList<[Function]>;
1291 let Documentation = [Undocumented];
1294 def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
1295 let Spellings = [Declspec<"layout_version">];
1296 let Args = [UnsignedArgument<"Version">];
1297 let Subjects = SubjectList<[CXXRecord]>;
1298 let Documentation = [LayoutVersionDocs];
1301 def LifetimeBound : DeclOrTypeAttr {
1302 let Spellings = [Clang<"lifetimebound", 0>];
1303 let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;
1304 let Documentation = [LifetimeBoundDocs];
1305 let LangOpts = [CPlusPlus];
1308 def TrivialABI : InheritableAttr {
1309 // This attribute does not have a C [[]] spelling because it requires the
1310 // CPlusPlus language option.
1311 let Spellings = [Clang<"trivial_abi", 0>];
1312 let Subjects = SubjectList<[CXXRecord]>;
1313 let Documentation = [TrivialABIDocs];
1314 let LangOpts = [CPlusPlus];
1317 def MaxFieldAlignment : InheritableAttr {
1318 // This attribute has no spellings as it is only ever created implicitly.
1320 let Args = [UnsignedArgument<"Alignment">];
1321 let SemaHandler = 0;
1322 let Documentation = [Undocumented];
1325 def MayAlias : InheritableAttr {
1326 // FIXME: this is a type attribute in GCC, but a declaration attribute here.
1327 let Spellings = [GCC<"may_alias">];
1328 let Documentation = [Undocumented];
1331 def MIGServerRoutine : InheritableAttr {
1332 let Spellings = [Clang<"mig_server_routine">];
1333 let Subjects = SubjectList<[Function, ObjCMethod, Block]>;
1334 let Documentation = [MIGConventionDocs];
1337 def MSABI : DeclOrTypeAttr {
1338 let Spellings = [GCC<"ms_abi">];
1339 // let Subjects = [Function, ObjCMethod];
1340 let Documentation = [MSABIDocs];
1343 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
1344 // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's
1345 // and AnyX86Interrupt's spellings must match.
1346 let Spellings = [GCC<"interrupt">];
1347 let Args = [UnsignedArgument<"Number">];
1348 let ParseKind = "Interrupt";
1349 let HasCustomParsing = 1;
1350 let Documentation = [Undocumented];
1353 def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1354 let Spellings = [GCC<"mips16">];
1355 let Subjects = SubjectList<[Function], ErrorDiag>;
1356 let Documentation = [Undocumented];
1359 def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1360 // NOTE: If you add any additional spellings, ARMInterrupt's,
1361 // MSP430Interrupt's and AnyX86Interrupt's spellings must match.
1362 let Spellings = [GCC<"interrupt">];
1363 let Subjects = SubjectList<[Function]>;
1364 let Args = [EnumArgument<"Interrupt", "InterruptType",
1365 ["vector=sw0", "vector=sw1", "vector=hw0",
1366 "vector=hw1", "vector=hw2", "vector=hw3",
1367 "vector=hw4", "vector=hw5", "eic", ""],
1368 ["sw0", "sw1", "hw0", "hw1", "hw2", "hw3",
1369 "hw4", "hw5", "eic", "eic"]
1371 let ParseKind = "Interrupt";
1372 let Documentation = [MipsInterruptDocs];
1375 def MicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1376 let Spellings = [GCC<"micromips">];
1377 let Subjects = SubjectList<[Function], ErrorDiag>;
1378 let Documentation = [MicroMipsDocs];
1381 def MipsLongCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
1382 let Spellings = [GCC<"long_call">, GCC<"far">];
1383 let Subjects = SubjectList<[Function]>;
1384 let Documentation = [MipsLongCallStyleDocs];
1387 def MipsShortCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
1388 let Spellings = [GCC<"short_call">, GCC<"near">];
1389 let Subjects = SubjectList<[Function]>;
1390 let Documentation = [MipsShortCallStyleDocs];
1394 let Spellings = [GCC<"mode">];
1395 let Subjects = SubjectList<[Var, Enum, TypedefName, Field], ErrorDiag>;
1396 let Args = [IdentifierArgument<"Mode">];
1397 let Documentation = [Undocumented];
1398 // This is notionally a type attribute, which #pragma clang attribute
1399 // generally does not support.
1400 let PragmaAttributeSupport = 0;
1403 def Naked : InheritableAttr {
1404 let Spellings = [GCC<"naked">, Declspec<"naked">];
1405 let Subjects = SubjectList<[Function]>;
1406 let Documentation = [Undocumented];
1409 def NeonPolyVectorType : TypeAttr {
1410 let Spellings = [Clang<"neon_polyvector_type">];
1411 let Args = [IntArgument<"NumElements">];
1412 let Documentation = [Undocumented];
1413 // Represented as VectorType instead.
1417 def NeonVectorType : TypeAttr {
1418 let Spellings = [Clang<"neon_vector_type">];
1419 let Args = [IntArgument<"NumElements">];
1420 let Documentation = [Undocumented];
1421 // Represented as VectorType instead.
1425 def NoUniqueAddress : InheritableAttr, TargetSpecificAttr<TargetItaniumCXXABI> {
1426 let Spellings = [CXX11<"", "no_unique_address", 201803>];
1427 let Subjects = SubjectList<[NonBitField], ErrorDiag>;
1428 let Documentation = [NoUniqueAddressDocs];
1431 def ReturnsTwice : InheritableAttr {
1432 let Spellings = [GCC<"returns_twice">];
1433 let Subjects = SubjectList<[Function]>;
1434 let Documentation = [Undocumented];
1437 def DisableTailCalls : InheritableAttr {
1438 let Spellings = [Clang<"disable_tail_calls">];
1439 let Subjects = SubjectList<[Function, ObjCMethod]>;
1440 let Documentation = [DisableTailCallsDocs];
1443 def NoAlias : InheritableAttr {
1444 let Spellings = [Declspec<"noalias">];
1445 let Subjects = SubjectList<[Function]>;
1446 let Documentation = [NoAliasDocs];
1449 def NoCommon : InheritableAttr {
1450 let Spellings = [GCC<"nocommon">];
1451 let Subjects = SubjectList<[Var]>;
1452 let Documentation = [Undocumented];
1455 def NoDebug : InheritableAttr {
1456 let Spellings = [GCC<"nodebug">];
1457 let Subjects = SubjectList<[TypedefName, FunctionLike, ObjCMethod, NonParmVar]>;
1458 let Documentation = [NoDebugDocs];
1461 def NoDuplicate : InheritableAttr {
1462 let Spellings = [Clang<"noduplicate">];
1463 let Subjects = SubjectList<[Function]>;
1464 let Documentation = [NoDuplicateDocs];
1467 def Convergent : InheritableAttr {
1468 let Spellings = [Clang<"convergent">];
1469 let Subjects = SubjectList<[Function]>;
1470 let Documentation = [ConvergentDocs];
1473 def NoInline : InheritableAttr {
1474 let Spellings = [GCC<"noinline">, Declspec<"noinline">];
1475 let Subjects = SubjectList<[Function]>;
1476 let Documentation = [Undocumented];
1479 def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1480 let Spellings = [GCC<"nomips16">];
1481 let Subjects = SubjectList<[Function], ErrorDiag>;
1482 let Documentation = [Undocumented];
1485 def NoMicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1486 let Spellings = [GCC<"nomicromips">];
1487 let Subjects = SubjectList<[Function], ErrorDiag>;
1488 let Documentation = [MicroMipsDocs];
1491 def RISCVInterrupt : InheritableAttr, TargetSpecificAttr<TargetRISCV> {
1492 let Spellings = [GCC<"interrupt">];
1493 let Subjects = SubjectList<[Function]>;
1494 let Args = [EnumArgument<"Interrupt", "InterruptType",
1495 ["user", "supervisor", "machine"],
1496 ["user", "supervisor", "machine"],
1498 let ParseKind = "Interrupt";
1499 let Documentation = [RISCVInterruptDocs];
1502 // This is not a TargetSpecificAttr so that is silently accepted and
1503 // ignored on other targets as encouraged by the OpenCL spec.
1505 // See OpenCL 1.2 6.11.5: "It is our intention that a particular
1506 // implementation of OpenCL be free to ignore all attributes and the
1507 // resulting executable binary will produce the same result."
1509 // However, only AMD GPU targets will emit the corresponding IR
1512 // FIXME: This provides a sub-optimal error message if you attempt to
1513 // use this in CUDA, since CUDA does not use the same terminology.
1515 // FIXME: SubjectList should be for OpenCLKernelFunction, but is not to
1516 // workaround needing to see kernel attribute before others to know if
1517 // this should be rejected on non-kernels.
1519 def AMDGPUFlatWorkGroupSize : InheritableAttr {
1520 let Spellings = [Clang<"amdgpu_flat_work_group_size", 0>];
1521 let Args = [ExprArgument<"Min">, ExprArgument<"Max">];
1522 let Documentation = [AMDGPUFlatWorkGroupSizeDocs];
1523 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1526 def AMDGPUWavesPerEU : InheritableAttr {
1527 let Spellings = [Clang<"amdgpu_waves_per_eu", 0>];
1528 let Args = [ExprArgument<"Min">, ExprArgument<"Max", 1>];
1529 let Documentation = [AMDGPUWavesPerEUDocs];
1530 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1533 def AMDGPUNumSGPR : InheritableAttr {
1534 let Spellings = [Clang<"amdgpu_num_sgpr", 0>];
1535 let Args = [UnsignedArgument<"NumSGPR">];
1536 let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1537 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1540 def AMDGPUNumVGPR : InheritableAttr {
1541 let Spellings = [Clang<"amdgpu_num_vgpr", 0>];
1542 let Args = [UnsignedArgument<"NumVGPR">];
1543 let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1544 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1547 def WebAssemblyImportModule : InheritableAttr,
1548 TargetSpecificAttr<TargetWebAssembly> {
1549 let Spellings = [Clang<"import_module">];
1550 let Args = [StringArgument<"ImportModule">];
1551 let Documentation = [WebAssemblyImportModuleDocs];
1552 let Subjects = SubjectList<[Function], ErrorDiag>;
1555 def WebAssemblyImportName : InheritableAttr,
1556 TargetSpecificAttr<TargetWebAssembly> {
1557 let Spellings = [Clang<"import_name">];
1558 let Args = [StringArgument<"ImportName">];
1559 let Documentation = [WebAssemblyImportNameDocs];
1560 let Subjects = SubjectList<[Function], ErrorDiag>;
1563 def NoSplitStack : InheritableAttr {
1564 let Spellings = [GCC<"no_split_stack">];
1565 let Subjects = SubjectList<[Function], ErrorDiag>;
1566 let Documentation = [NoSplitStackDocs];
1569 def NonNull : InheritableParamAttr {
1570 let Spellings = [GCC<"nonnull">];
1571 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
1572 "functions, methods, and parameters">;
1573 let Args = [VariadicParamIdxArgument<"Args">];
1574 let AdditionalMembers = [{
1575 bool isNonNull(unsigned IdxAST) const {
1578 return args_end() != std::find_if(
1579 args_begin(), args_end(),
1580 [=](const ParamIdx &Idx) { return Idx.getASTIndex() == IdxAST; });
1583 // FIXME: We should merge duplicates into a single nonnull attribute.
1584 let InheritEvenIfAlreadyPresent = 1;
1585 let Documentation = [NonNullDocs];
1588 def ReturnsNonNull : InheritableAttr {
1589 let Spellings = [GCC<"returns_nonnull">];
1590 let Subjects = SubjectList<[ObjCMethod, Function]>;
1591 let Documentation = [ReturnsNonNullDocs];
1594 // pass_object_size(N) indicates that the parameter should have
1595 // __builtin_object_size with Type=N evaluated on the parameter at the callsite.
1596 def PassObjectSize : InheritableParamAttr {
1597 let Spellings = [Clang<"pass_object_size">,
1598 Clang<"pass_dynamic_object_size">];
1599 let Accessors = [Accessor<"isDynamic", [Clang<"pass_dynamic_object_size">]>];
1600 let Args = [IntArgument<"Type">];
1601 let Subjects = SubjectList<[ParmVar]>;
1602 let Documentation = [PassObjectSizeDocs];
1605 // Nullability type attributes.
1606 def TypeNonNull : TypeAttr {
1607 let Spellings = [Keyword<"_Nonnull">];
1608 let Documentation = [TypeNonNullDocs];
1611 def TypeNullable : TypeAttr {
1612 let Spellings = [Keyword<"_Nullable">];
1613 let Documentation = [TypeNullableDocs];
1616 def TypeNullUnspecified : TypeAttr {
1617 let Spellings = [Keyword<"_Null_unspecified">];
1618 let Documentation = [TypeNullUnspecifiedDocs];
1621 // This is a marker used to indicate that an __unsafe_unretained qualifier was
1622 // ignored because ARC is not enabled. The usual representation for this
1623 // qualifier is as an ObjCOwnership attribute with Kind == "none".
1624 def ObjCInertUnsafeUnretained : TypeAttr {
1625 let Spellings = [Keyword<"__unsafe_unretained">];
1626 let Documentation = [Undocumented];
1629 def ObjCKindOf : TypeAttr {
1630 let Spellings = [Keyword<"__kindof">];
1631 let Documentation = [Undocumented];
1634 def NoEscape : Attr {
1635 let Spellings = [Clang<"noescape">];
1636 let Subjects = SubjectList<[ParmVar]>;
1637 let Documentation = [NoEscapeDocs];
1640 def AssumeAligned : InheritableAttr {
1641 let Spellings = [GCC<"assume_aligned">];
1642 let Subjects = SubjectList<[ObjCMethod, Function]>;
1643 let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>];
1644 let Documentation = [AssumeAlignedDocs];
1647 def AllocAlign : InheritableAttr {
1648 let Spellings = [GCC<"alloc_align">];
1649 let Subjects = SubjectList<[HasFunctionProto]>;
1650 let Args = [ParamIdxArgument<"ParamIndex">];
1651 let Documentation = [AllocAlignDocs];
1654 def NoReturn : InheritableAttr {
1655 let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
1656 // FIXME: Does GCC allow this on the function instead?
1657 let Documentation = [Undocumented];
1660 def NoInstrumentFunction : InheritableAttr {
1661 let Spellings = [GCC<"no_instrument_function">];
1662 let Subjects = SubjectList<[Function]>;
1663 let Documentation = [Undocumented];
1666 def NotTailCalled : InheritableAttr {
1667 let Spellings = [Clang<"not_tail_called">];
1668 let Subjects = SubjectList<[Function]>;
1669 let Documentation = [NotTailCalledDocs];
1672 def NoStackProtector : InheritableAttr {
1673 let Spellings = [Clang<"no_stack_protector">];
1674 let Subjects = SubjectList<[Function]>;
1675 let Documentation = [NoStackProtectorDocs];
1678 def NoThrow : InheritableAttr {
1679 let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
1680 let Subjects = SubjectList<[FunctionLike]>;
1681 let Documentation = [NoThrowDocs];
1684 def NvWeak : IgnoredAttr {
1685 // No Declspec spelling of this attribute; the CUDA headers use
1686 // __attribute__((nv_weak)) unconditionally. Does not receive an [[]]
1687 // spelling because it is a CUDA attribute.
1688 let Spellings = [GNU<"nv_weak">];
1689 let LangOpts = [CUDA];
1692 def ObjCBridge : InheritableAttr {
1693 let Spellings = [Clang<"objc_bridge">];
1694 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag>;
1695 let Args = [IdentifierArgument<"BridgedType">];
1696 let Documentation = [Undocumented];
1699 def ObjCBridgeMutable : InheritableAttr {
1700 let Spellings = [Clang<"objc_bridge_mutable">];
1701 let Subjects = SubjectList<[Record], ErrorDiag>;
1702 let Args = [IdentifierArgument<"BridgedType">];
1703 let Documentation = [Undocumented];
1706 def ObjCBridgeRelated : InheritableAttr {
1707 let Spellings = [Clang<"objc_bridge_related">];
1708 let Subjects = SubjectList<[Record], ErrorDiag>;
1709 let Args = [IdentifierArgument<"RelatedClass">,
1710 IdentifierArgument<"ClassMethod">,
1711 IdentifierArgument<"InstanceMethod">];
1712 let HasCustomParsing = 1;
1713 let Documentation = [Undocumented];
1716 def NSReturnsRetained : DeclOrTypeAttr {
1717 let Spellings = [Clang<"ns_returns_retained">];
1718 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1719 let Documentation = [RetainBehaviorDocs];
1722 def NSReturnsNotRetained : InheritableAttr {
1723 let Spellings = [Clang<"ns_returns_not_retained">];
1724 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1725 let Documentation = [RetainBehaviorDocs];
1728 def NSReturnsAutoreleased : InheritableAttr {
1729 let Spellings = [Clang<"ns_returns_autoreleased">];
1730 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1731 let Documentation = [RetainBehaviorDocs];
1734 def NSConsumesSelf : InheritableAttr {
1735 let Spellings = [Clang<"ns_consumes_self">];
1736 let Subjects = SubjectList<[ObjCMethod]>;
1737 let Documentation = [RetainBehaviorDocs];
1740 def NSConsumed : InheritableParamAttr {
1741 let Spellings = [Clang<"ns_consumed">];
1742 let Subjects = SubjectList<[ParmVar]>;
1743 let Documentation = [RetainBehaviorDocs];
1746 def ObjCException : InheritableAttr {
1747 let Spellings = [Clang<"objc_exception">];
1748 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1749 let Documentation = [Undocumented];
1752 def ObjCMethodFamily : InheritableAttr {
1753 let Spellings = [Clang<"objc_method_family">];
1754 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1755 let Args = [EnumArgument<"Family", "FamilyKind",
1756 ["none", "alloc", "copy", "init", "mutableCopy", "new"],
1757 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
1758 "OMF_mutableCopy", "OMF_new"]>];
1759 let Documentation = [ObjCMethodFamilyDocs];
1762 def ObjCNSObject : InheritableAttr {
1763 let Spellings = [Clang<"NSObject">];
1764 let Documentation = [Undocumented];
1767 def ObjCIndependentClass : InheritableAttr {
1768 let Spellings = [Clang<"objc_independent_class">];
1769 let Documentation = [Undocumented];
1772 def ObjCPreciseLifetime : InheritableAttr {
1773 let Spellings = [Clang<"objc_precise_lifetime">];
1774 let Subjects = SubjectList<[Var], ErrorDiag>;
1775 let Documentation = [Undocumented];
1778 def ObjCReturnsInnerPointer : InheritableAttr {
1779 let Spellings = [Clang<"objc_returns_inner_pointer">];
1780 let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
1781 let Documentation = [Undocumented];
1784 def ObjCRequiresSuper : InheritableAttr {
1785 let Spellings = [Clang<"objc_requires_super">];
1786 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1787 let Documentation = [ObjCRequiresSuperDocs];
1790 def ObjCRootClass : InheritableAttr {
1791 let Spellings = [Clang<"objc_root_class">];
1792 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1793 let Documentation = [Undocumented];
1796 def ObjCNonLazyClass : Attr {
1797 let Spellings = [Clang<"objc_nonlazy_class">];
1798 let Subjects = SubjectList<[ObjCInterface, ObjCImpl], ErrorDiag>;
1799 let LangOpts = [ObjC];
1800 let Documentation = [ObjCNonLazyClassDocs];
1803 def ObjCSubclassingRestricted : InheritableAttr {
1804 let Spellings = [Clang<"objc_subclassing_restricted">];
1805 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1806 let Documentation = [ObjCSubclassingRestrictedDocs];
1809 def ObjCExplicitProtocolImpl : InheritableAttr {
1810 let Spellings = [Clang<"objc_protocol_requires_explicit_implementation">];
1811 let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
1812 let Documentation = [Undocumented];
1815 def ObjCDesignatedInitializer : Attr {
1816 let Spellings = [Clang<"objc_designated_initializer">];
1817 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1818 let Documentation = [Undocumented];
1821 def ObjCRuntimeName : Attr {
1822 let Spellings = [Clang<"objc_runtime_name">];
1823 let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
1824 let Args = [StringArgument<"MetadataName">];
1825 let Documentation = [ObjCRuntimeNameDocs];
1828 def ObjCRuntimeVisible : Attr {
1829 let Spellings = [Clang<"objc_runtime_visible">];
1830 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1831 let Documentation = [ObjCRuntimeVisibleDocs];
1834 def ObjCClassStub : Attr {
1835 let Spellings = [Clang<"objc_class_stub">];
1836 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1837 let Documentation = [ObjCClassStubDocs];
1838 let LangOpts = [ObjCNonFragileRuntime];
1841 def ObjCBoxable : Attr {
1842 let Spellings = [Clang<"objc_boxable">];
1843 let Subjects = SubjectList<[Record], ErrorDiag>;
1844 let Documentation = [ObjCBoxableDocs];
1847 def OptimizeNone : InheritableAttr {
1848 let Spellings = [Clang<"optnone">];
1849 let Subjects = SubjectList<[Function, ObjCMethod]>;
1850 let Documentation = [OptnoneDocs];
1853 def Overloadable : Attr {
1854 let Spellings = [Clang<"overloadable">];
1855 let Subjects = SubjectList<[Function], ErrorDiag>;
1856 let Documentation = [OverloadableDocs];
1859 def Override : InheritableAttr {
1860 let Spellings = [Keyword<"override">];
1861 let SemaHandler = 0;
1862 let Documentation = [Undocumented];
1865 def Ownership : InheritableAttr {
1866 let Spellings = [Clang<"ownership_holds">, Clang<"ownership_returns">,
1867 Clang<"ownership_takes">];
1868 let Accessors = [Accessor<"isHolds", [Clang<"ownership_holds">]>,
1869 Accessor<"isReturns", [Clang<"ownership_returns">]>,
1870 Accessor<"isTakes", [Clang<"ownership_takes">]>];
1871 let AdditionalMembers = [{
1872 enum OwnershipKind { Holds, Returns, Takes };
1873 OwnershipKind getOwnKind() const {
1874 return isHolds() ? Holds :
1879 let Args = [IdentifierArgument<"Module">,
1880 VariadicParamIdxArgument<"Args">];
1881 let Subjects = SubjectList<[HasFunctionProto]>;
1882 let Documentation = [Undocumented];
1885 def Packed : InheritableAttr {
1886 let Spellings = [GCC<"packed">];
1887 // let Subjects = [Tag, Field];
1888 let Documentation = [Undocumented];
1891 def IntelOclBicc : DeclOrTypeAttr {
1892 let Spellings = [Clang<"intel_ocl_bicc", 0>];
1893 // let Subjects = [Function, ObjCMethod];
1894 let Documentation = [Undocumented];
1897 def Pcs : DeclOrTypeAttr {
1898 let Spellings = [GCC<"pcs">];
1899 let Args = [EnumArgument<"PCS", "PCSType",
1900 ["aapcs", "aapcs-vfp"],
1901 ["AAPCS", "AAPCS_VFP"]>];
1902 // let Subjects = [Function, ObjCMethod];
1903 let Documentation = [PcsDocs];
1906 def AArch64VectorPcs: DeclOrTypeAttr {
1907 let Spellings = [Clang<"aarch64_vector_pcs">];
1908 let Documentation = [AArch64VectorPcsDocs];
1911 def Pure : InheritableAttr {
1912 let Spellings = [GCC<"pure">];
1913 let Documentation = [Undocumented];
1916 def Regparm : TypeAttr {
1917 let Spellings = [GCC<"regparm">];
1918 let Args = [UnsignedArgument<"NumParams">];
1919 let Documentation = [RegparmDocs];
1920 // Represented as part of the enclosing function type.
1924 def NoDeref : TypeAttr {
1925 let Spellings = [Clang<"noderef">];
1926 let Documentation = [NoDerefDocs];
1929 def ReqdWorkGroupSize : InheritableAttr {
1930 // Does not have a [[]] spelling because it is an OpenCL-related attribute.
1931 let Spellings = [GNU<"reqd_work_group_size">];
1932 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
1933 UnsignedArgument<"ZDim">];
1934 let Subjects = SubjectList<[Function], ErrorDiag>;
1935 let Documentation = [Undocumented];
1938 def RequireConstantInit : InheritableAttr {
1939 // This attribute does not have a C [[]] spelling because it requires the
1940 // CPlusPlus language option.
1941 let Spellings = [Clang<"require_constant_initialization", 0>];
1942 let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
1943 let Documentation = [RequireConstantInitDocs];
1944 let LangOpts = [CPlusPlus];
1947 def WorkGroupSizeHint : InheritableAttr {
1948 // Does not have a [[]] spelling because it is an OpenCL-related attribute.
1949 let Spellings = [GNU<"work_group_size_hint">];
1950 let Args = [UnsignedArgument<"XDim">,
1951 UnsignedArgument<"YDim">,
1952 UnsignedArgument<"ZDim">];
1953 let Subjects = SubjectList<[Function], ErrorDiag>;
1954 let Documentation = [Undocumented];
1957 def InitPriority : InheritableAttr {
1958 let Spellings = [GCC<"init_priority">];
1959 let Args = [UnsignedArgument<"Priority">];
1960 let Subjects = SubjectList<[Var], ErrorDiag>;
1961 let Documentation = [Undocumented];
1964 def Section : InheritableAttr {
1965 let Spellings = [GCC<"section">, Declspec<"allocate">];
1966 let Args = [StringArgument<"Name">];
1968 SubjectList<[ Function, GlobalVar, ObjCMethod, ObjCProperty ], ErrorDiag>;
1969 let Documentation = [SectionDocs];
1972 // This is used for `__declspec(code_seg("segname"))`, but not for
1973 // `#pragma code_seg("segname")`.
1974 def CodeSeg : InheritableAttr {
1975 let Spellings = [Declspec<"code_seg">];
1976 let Args = [StringArgument<"Name">];
1977 let Subjects = SubjectList<[Function, CXXRecord], ErrorDiag>;
1978 let Documentation = [CodeSegDocs];
1981 def PragmaClangBSSSection : InheritableAttr {
1982 // This attribute has no spellings as it is only ever created implicitly.
1984 let Args = [StringArgument<"Name">];
1985 let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
1986 let Documentation = [Undocumented];
1989 def PragmaClangDataSection : InheritableAttr {
1990 // This attribute has no spellings as it is only ever created implicitly.
1992 let Args = [StringArgument<"Name">];
1993 let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
1994 let Documentation = [Undocumented];
1997 def PragmaClangRodataSection : InheritableAttr {
1998 // This attribute has no spellings as it is only ever created implicitly.
2000 let Args = [StringArgument<"Name">];
2001 let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
2002 let Documentation = [Undocumented];
2005 def PragmaClangTextSection : InheritableAttr {
2006 // This attribute has no spellings as it is only ever created implicitly.
2008 let Args = [StringArgument<"Name">];
2009 let Subjects = SubjectList<[Function], ErrorDiag>;
2010 let Documentation = [Undocumented];
2013 def Sentinel : InheritableAttr {
2014 let Spellings = [GCC<"sentinel">];
2015 let Args = [DefaultIntArgument<"Sentinel", 0>,
2016 DefaultIntArgument<"NullPos", 0>];
2017 // let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
2018 let Documentation = [Undocumented];
2021 def StdCall : DeclOrTypeAttr {
2022 let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
2023 // let Subjects = [Function, ObjCMethod];
2024 let Documentation = [StdCallDocs];
2027 def SwiftCall : DeclOrTypeAttr {
2028 let Spellings = [Clang<"swiftcall">];
2029 // let Subjects = SubjectList<[Function]>;
2030 let Documentation = [SwiftCallDocs];
2033 def SwiftContext : ParameterABIAttr {
2034 let Spellings = [Clang<"swift_context">];
2035 let Documentation = [SwiftContextDocs];
2038 def SwiftErrorResult : ParameterABIAttr {
2039 let Spellings = [Clang<"swift_error_result">];
2040 let Documentation = [SwiftErrorResultDocs];
2043 def SwiftIndirectResult : ParameterABIAttr {
2044 let Spellings = [Clang<"swift_indirect_result">];
2045 let Documentation = [SwiftIndirectResultDocs];
2048 def Suppress : StmtAttr {
2049 let Spellings = [CXX11<"gsl", "suppress">];
2050 let Args = [VariadicStringArgument<"DiagnosticIdentifiers">];
2051 let Documentation = [SuppressDocs];
2054 def SysVABI : DeclOrTypeAttr {
2055 let Spellings = [GCC<"sysv_abi">];
2056 // let Subjects = [Function, ObjCMethod];
2057 let Documentation = [Undocumented];
2060 def ThisCall : DeclOrTypeAttr {
2061 let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
2062 Keyword<"_thiscall">];
2063 // let Subjects = [Function, ObjCMethod];
2064 let Documentation = [ThisCallDocs];
2067 def VectorCall : DeclOrTypeAttr {
2068 let Spellings = [Clang<"vectorcall">, Keyword<"__vectorcall">,
2069 Keyword<"_vectorcall">];
2070 // let Subjects = [Function, ObjCMethod];
2071 let Documentation = [VectorCallDocs];
2074 def Pascal : DeclOrTypeAttr {
2075 let Spellings = [Clang<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
2076 // let Subjects = [Function, ObjCMethod];
2077 let Documentation = [Undocumented];
2080 def PreserveMost : DeclOrTypeAttr {
2081 let Spellings = [Clang<"preserve_most">];
2082 let Documentation = [PreserveMostDocs];
2085 def PreserveAll : DeclOrTypeAttr {
2086 let Spellings = [Clang<"preserve_all">];
2087 let Documentation = [PreserveAllDocs];
2090 def Target : InheritableAttr {
2091 let Spellings = [GCC<"target">];
2092 let Args = [StringArgument<"featuresStr">];
2093 let Subjects = SubjectList<[Function], ErrorDiag>;
2094 let Documentation = [TargetDocs];
2095 let AdditionalMembers = [{
2096 struct ParsedTargetAttr {
2097 std::vector<std::string> Features;
2098 StringRef Architecture;
2099 bool DuplicateArchitecture = false;
2100 bool operator ==(const ParsedTargetAttr &Other) const {
2101 return DuplicateArchitecture == Other.DuplicateArchitecture &&
2102 Architecture == Other.Architecture && Features == Other.Features;
2105 ParsedTargetAttr parse() const {
2106 return parse(getFeaturesStr());
2109 StringRef getArchitecture() const {
2110 StringRef Features = getFeaturesStr();
2111 if (Features == "default") return {};
2113 SmallVector<StringRef, 1> AttrFeatures;
2114 Features.split(AttrFeatures, ",");
2116 for (auto &Feature : AttrFeatures) {
2117 Feature = Feature.trim();
2118 if (Feature.startswith("arch="))
2119 return Feature.drop_front(sizeof("arch=") - 1);
2124 // Gets the list of features as simple string-refs with no +/- or 'no-'.
2125 // Only adds the items to 'Out' that are additions.
2126 void getAddedFeatures(llvm::SmallVectorImpl<StringRef> &Out) const {
2127 StringRef Features = getFeaturesStr();
2128 if (Features == "default") return;
2130 SmallVector<StringRef, 1> AttrFeatures;
2131 Features.split(AttrFeatures, ",");
2133 for (auto &Feature : AttrFeatures) {
2134 Feature = Feature.trim();
2136 if (!Feature.startswith("no-") && !Feature.startswith("arch=") &&
2137 !Feature.startswith("fpmath=") && !Feature.startswith("tune="))
2138 Out.push_back(Feature);
2142 template<class Compare>
2143 ParsedTargetAttr parse(Compare cmp) const {
2144 ParsedTargetAttr Attrs = parse();
2145 llvm::sort(std::begin(Attrs.Features), std::end(Attrs.Features), cmp);
2149 bool isDefaultVersion() const { return getFeaturesStr() == "default"; }
2151 static ParsedTargetAttr parse(StringRef Features) {
2152 ParsedTargetAttr Ret;
2153 if (Features == "default") return Ret;
2154 SmallVector<StringRef, 1> AttrFeatures;
2155 Features.split(AttrFeatures, ",");
2157 // Grab the various features and prepend a "+" to turn on the feature to
2158 // the backend and add them to our existing set of features.
2159 for (auto &Feature : AttrFeatures) {
2160 // Go ahead and trim whitespace rather than either erroring or
2161 // accepting it weirdly.
2162 Feature = Feature.trim();
2164 // We don't support cpu tuning this way currently.
2165 // TODO: Support the fpmath option. It will require checking
2166 // overall feature validity for the function with the rest of the
2167 // attributes on the function.
2168 if (Feature.startswith("fpmath=") || Feature.startswith("tune="))
2171 // While we're here iterating check for a different target cpu.
2172 if (Feature.startswith("arch=")) {
2173 if (!Ret.Architecture.empty())
2174 Ret.DuplicateArchitecture = true;
2176 Ret.Architecture = Feature.split("=").second.trim();
2177 } else if (Feature.startswith("no-"))
2178 Ret.Features.push_back("-" + Feature.split("-").second.str());
2180 Ret.Features.push_back("+" + Feature.str());
2187 def MinVectorWidth : InheritableAttr {
2188 let Spellings = [Clang<"min_vector_width">];
2189 let Args = [UnsignedArgument<"VectorWidth">];
2190 let Subjects = SubjectList<[Function], ErrorDiag>;
2191 let Documentation = [MinVectorWidthDocs];
2194 def TransparentUnion : InheritableAttr {
2195 let Spellings = [GCC<"transparent_union">];
2196 // let Subjects = SubjectList<[Record, TypedefName]>;
2197 let Documentation = [TransparentUnionDocs];
2198 let LangOpts = [COnly];
2201 def Unavailable : InheritableAttr {
2202 let Spellings = [Clang<"unavailable">];
2203 let Args = [StringArgument<"Message", 1>,
2204 EnumArgument<"ImplicitReason", "ImplicitReason",
2207 "IR_ARCForbiddenType",
2209 "IR_ARCForbiddenConversion",
2210 "IR_ARCInitReturnsUnrelated",
2211 "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>];
2212 let Documentation = [Undocumented];
2215 def DiagnoseIf : InheritableAttr {
2216 // Does not have a [[]] spelling because this attribute requires the ability
2217 // to parse function arguments but the attribute is not written in the type
2219 let Spellings = [GNU<"diagnose_if">];
2220 let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;
2221 let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
2222 EnumArgument<"DiagnosticType",
2224 ["error", "warning"],
2225 ["DT_Error", "DT_Warning"]>,
2226 BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
2227 NamedArgument<"Parent", 0, /*fake*/ 1>];
2228 let InheritEvenIfAlreadyPresent = 1;
2230 let AdditionalMembers = [{
2231 bool isError() const { return diagnosticType == DT_Error; }
2232 bool isWarning() const { return diagnosticType == DT_Warning; }
2234 let TemplateDependent = 1;
2235 let Documentation = [DiagnoseIfDocs];
2238 def ArcWeakrefUnavailable : InheritableAttr {
2239 let Spellings = [Clang<"objc_arc_weak_reference_unavailable">];
2240 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
2241 let Documentation = [Undocumented];
2244 def ObjCGC : TypeAttr {
2245 let Spellings = [Clang<"objc_gc">];
2246 let Args = [IdentifierArgument<"Kind">];
2247 let Documentation = [Undocumented];
2250 def ObjCOwnership : DeclOrTypeAttr {
2251 let Spellings = [Clang<"objc_ownership">];
2252 let Args = [IdentifierArgument<"Kind">];
2253 let Documentation = [Undocumented];
2256 def ObjCRequiresPropertyDefs : InheritableAttr {
2257 let Spellings = [Clang<"objc_requires_property_definitions">];
2258 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
2259 let Documentation = [Undocumented];
2262 def Unused : InheritableAttr {
2263 let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
2264 C2x<"", "maybe_unused">];
2265 let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
2266 Field, ObjCMethod, FunctionLike]>;
2267 let Documentation = [WarnMaybeUnusedDocs];
2270 def Used : InheritableAttr {
2271 let Spellings = [GCC<"used">];
2272 let Subjects = SubjectList<[NonLocalVar, Function, ObjCMethod]>;
2273 let Documentation = [Undocumented];
2276 def Uuid : InheritableAttr {
2277 let Spellings = [Declspec<"uuid">, Microsoft<"uuid">];
2278 let Args = [StringArgument<"Guid">];
2279 let Subjects = SubjectList<[Record, Enum]>;
2280 // FIXME: Allow expressing logical AND for LangOpts. Our condition should be:
2281 // CPlusPlus && (MicrosoftExt || Borland)
2282 let LangOpts = [MicrosoftExt, Borland];
2283 let Documentation = [Undocumented];
2286 def VectorSize : TypeAttr {
2287 let Spellings = [GCC<"vector_size">];
2288 let Args = [ExprArgument<"NumBytes">];
2289 let Documentation = [Undocumented];
2290 // Represented as VectorType instead.
2294 def VecTypeHint : InheritableAttr {
2295 // Does not have a [[]] spelling because it is an OpenCL-related attribute.
2296 let Spellings = [GNU<"vec_type_hint">];
2297 let Args = [TypeArgument<"TypeHint">];
2298 let Subjects = SubjectList<[Function], ErrorDiag>;
2299 let Documentation = [Undocumented];
2302 def Visibility : InheritableAttr {
2304 let Spellings = [GCC<"visibility">];
2305 let Args = [EnumArgument<"Visibility", "VisibilityType",
2306 ["default", "hidden", "internal", "protected"],
2307 ["Default", "Hidden", "Hidden", "Protected"]>];
2308 let MeaningfulToClassTemplateDefinition = 1;
2309 let Documentation = [Undocumented];
2312 def TypeVisibility : InheritableAttr {
2314 let Spellings = [Clang<"type_visibility">];
2315 let Args = [EnumArgument<"Visibility", "VisibilityType",
2316 ["default", "hidden", "internal", "protected"],
2317 ["Default", "Hidden", "Hidden", "Protected"]>];
2318 // let Subjects = [Tag, ObjCInterface, Namespace];
2319 let Documentation = [Undocumented];
2322 def VecReturn : InheritableAttr {
2323 // This attribute does not have a C [[]] spelling because it only appertains
2324 // to C++ struct/class/union.
2325 // FIXME: should this attribute have a CPlusPlus language option?
2326 let Spellings = [Clang<"vecreturn", 0>];
2327 let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
2328 let Documentation = [Undocumented];
2331 def WarnUnused : InheritableAttr {
2332 let Spellings = [GCC<"warn_unused">];
2333 let Subjects = SubjectList<[Record]>;
2334 let Documentation = [Undocumented];
2337 def WarnUnusedResult : InheritableAttr {
2338 let Spellings = [CXX11<"", "nodiscard", 201603>, C2x<"", "nodiscard">,
2339 CXX11<"clang", "warn_unused_result">,
2340 GCC<"warn_unused_result">];
2341 let Subjects = SubjectList<[ObjCMethod, Enum, Record, FunctionLike]>;
2342 let Documentation = [WarnUnusedResultsDocs];
2345 def Weak : InheritableAttr {
2346 let Spellings = [GCC<"weak">];
2347 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
2348 let Documentation = [Undocumented];
2351 def WeakImport : InheritableAttr {
2352 let Spellings = [Clang<"weak_import">];
2353 let Documentation = [Undocumented];
2356 def WeakRef : InheritableAttr {
2357 let Spellings = [GCC<"weakref">];
2358 // A WeakRef that has an argument is treated as being an AliasAttr
2359 let Args = [StringArgument<"Aliasee", 1>];
2360 let Subjects = SubjectList<[Var, Function], ErrorDiag>;
2361 let Documentation = [Undocumented];
2364 def LTOVisibilityPublic : InheritableAttr {
2365 let Spellings = [Clang<"lto_visibility_public">];
2366 let Subjects = SubjectList<[Record]>;
2367 let Documentation = [LTOVisibilityDocs];
2370 def AnyX86Interrupt : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
2371 // NOTE: If you add any additional spellings, ARMInterrupt's,
2372 // MSP430Interrupt's and MipsInterrupt's spellings must match.
2373 let Spellings = [GCC<"interrupt">];
2374 let Subjects = SubjectList<[HasFunctionProto]>;
2375 let ParseKind = "Interrupt";
2376 let HasCustomParsing = 1;
2377 let Documentation = [Undocumented];
2380 def AnyX86NoCallerSavedRegisters : InheritableAttr,
2381 TargetSpecificAttr<TargetAnyX86> {
2382 let Spellings = [GCC<"no_caller_saved_registers">];
2383 let Documentation = [AnyX86NoCallerSavedRegistersDocs];
2386 def AnyX86NoCfCheck : DeclOrTypeAttr, TargetSpecificAttr<TargetAnyX86>{
2387 let Spellings = [GCC<"nocf_check">];
2388 let Subjects = SubjectList<[FunctionLike]>;
2389 let Documentation = [AnyX86NoCfCheckDocs];
2392 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
2393 let Spellings = [GCC<"force_align_arg_pointer">];
2394 // Technically, this appertains to a FunctionDecl, but the target-specific
2395 // code silently allows anything function-like (such as typedefs or function
2396 // pointers), but does not apply the attribute to them.
2397 let Documentation = [X86ForceAlignArgPointerDocs];
2400 def NoSanitize : InheritableAttr {
2401 let Spellings = [Clang<"no_sanitize">];
2402 let Args = [VariadicStringArgument<"Sanitizers">];
2403 let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag>;
2404 let Documentation = [NoSanitizeDocs];
2405 let AdditionalMembers = [{
2406 SanitizerMask getMask() const {
2408 for (auto SanitizerName : sanitizers()) {
2409 SanitizerMask ParsedMask =
2410 parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
2411 Mask |= expandSanitizerGroups(ParsedMask);
2418 // Attributes to disable a specific sanitizer. No new sanitizers should be added
2419 // to this list; the no_sanitize attribute should be extended instead.
2420 def NoSanitizeSpecific : InheritableAttr {
2421 let Spellings = [GCC<"no_address_safety_analysis">,
2422 GCC<"no_sanitize_address">,
2423 GCC<"no_sanitize_thread">,
2424 Clang<"no_sanitize_memory">];
2425 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
2426 let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
2427 NoSanitizeMemoryDocs];
2431 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
2432 // Not all of these attributes will be given a [[]] spelling. The attributes
2433 // which require access to function parameter names cannot use the [[]] spelling
2434 // because they are not written in the type position. Some attributes are given
2435 // an updated captability-based name and the older name will only be supported
2436 // under the GNU-style spelling.
2437 def GuardedVar : InheritableAttr {
2438 let Spellings = [Clang<"guarded_var", 0>];
2439 let Subjects = SubjectList<[Field, SharedVar]>;
2440 let Documentation = [Undocumented];
2443 def PtGuardedVar : InheritableAttr {
2444 let Spellings = [Clang<"pt_guarded_var", 0>];
2445 let Subjects = SubjectList<[Field, SharedVar]>;
2446 let Documentation = [Undocumented];
2449 def Lockable : InheritableAttr {
2450 let Spellings = [GNU<"lockable">];
2451 let Subjects = SubjectList<[Record]>;
2452 let Documentation = [Undocumented];
2453 let ASTNode = 0; // Replaced by Capability
2456 def ScopedLockable : InheritableAttr {
2457 let Spellings = [Clang<"scoped_lockable", 0>];
2458 let Subjects = SubjectList<[Record]>;
2459 let Documentation = [Undocumented];
2462 def Capability : InheritableAttr {
2463 let Spellings = [Clang<"capability", 0>, Clang<"shared_capability", 0>];
2464 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag>;
2465 let Args = [StringArgument<"Name">];
2466 let Accessors = [Accessor<"isShared",
2467 [Clang<"shared_capability", 0>]>];
2468 let Documentation = [Undocumented];
2469 let AdditionalMembers = [{
2470 bool isMutex() const { return getName().equals_lower("mutex"); }
2471 bool isRole() const { return getName().equals_lower("role"); }
2475 def AssertCapability : InheritableAttr {
2476 let Spellings = [Clang<"assert_capability", 0>,
2477 Clang<"assert_shared_capability", 0>];
2478 let Subjects = SubjectList<[Function]>;
2480 let TemplateDependent = 1;
2481 let ParseArgumentsAsUnevaluated = 1;
2482 let InheritEvenIfAlreadyPresent = 1;
2483 let Args = [VariadicExprArgument<"Args">];
2484 let Accessors = [Accessor<"isShared",
2485 [Clang<"assert_shared_capability", 0>]>];
2486 let Documentation = [AssertCapabilityDocs];
2489 def AcquireCapability : InheritableAttr {
2490 let Spellings = [Clang<"acquire_capability", 0>,
2491 Clang<"acquire_shared_capability", 0>,
2492 GNU<"exclusive_lock_function">,
2493 GNU<"shared_lock_function">];
2494 let Subjects = SubjectList<[Function]>;
2496 let TemplateDependent = 1;
2497 let ParseArgumentsAsUnevaluated = 1;
2498 let InheritEvenIfAlreadyPresent = 1;
2499 let Args = [VariadicExprArgument<"Args">];
2500 let Accessors = [Accessor<"isShared",
2501 [Clang<"acquire_shared_capability", 0>,
2502 GNU<"shared_lock_function">]>];
2503 let Documentation = [AcquireCapabilityDocs];
2506 def TryAcquireCapability : InheritableAttr {
2507 let Spellings = [Clang<"try_acquire_capability", 0>,
2508 Clang<"try_acquire_shared_capability", 0>];
2509 let Subjects = SubjectList<[Function],
2512 let TemplateDependent = 1;
2513 let ParseArgumentsAsUnevaluated = 1;
2514 let InheritEvenIfAlreadyPresent = 1;
2515 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2516 let Accessors = [Accessor<"isShared",
2517 [Clang<"try_acquire_shared_capability", 0>]>];
2518 let Documentation = [TryAcquireCapabilityDocs];
2521 def ReleaseCapability : InheritableAttr {
2522 let Spellings = [Clang<"release_capability", 0>,
2523 Clang<"release_shared_capability", 0>,
2524 Clang<"release_generic_capability", 0>,
2525 Clang<"unlock_function", 0>];
2526 let Subjects = SubjectList<[Function]>;
2528 let TemplateDependent = 1;
2529 let ParseArgumentsAsUnevaluated = 1;
2530 let InheritEvenIfAlreadyPresent = 1;
2531 let Args = [VariadicExprArgument<"Args">];
2532 let Accessors = [Accessor<"isShared",
2533 [Clang<"release_shared_capability", 0>]>,
2534 Accessor<"isGeneric",
2535 [Clang<"release_generic_capability", 0>,
2536 Clang<"unlock_function", 0>]>];
2537 let Documentation = [ReleaseCapabilityDocs];
2540 def RequiresCapability : InheritableAttr {
2541 let Spellings = [Clang<"requires_capability", 0>,
2542 Clang<"exclusive_locks_required", 0>,
2543 Clang<"requires_shared_capability", 0>,
2544 Clang<"shared_locks_required", 0>];
2545 let Args = [VariadicExprArgument<"Args">];
2547 let TemplateDependent = 1;
2548 let ParseArgumentsAsUnevaluated = 1;
2549 let InheritEvenIfAlreadyPresent = 1;
2550 let Subjects = SubjectList<[Function]>;
2551 let Accessors = [Accessor<"isShared", [Clang<"requires_shared_capability", 0>,
2552 Clang<"shared_locks_required", 0>]>];
2553 let Documentation = [Undocumented];
2556 def NoThreadSafetyAnalysis : InheritableAttr {
2557 let Spellings = [Clang<"no_thread_safety_analysis">];
2558 let Subjects = SubjectList<[Function]>;
2559 let Documentation = [Undocumented];
2562 def GuardedBy : InheritableAttr {
2563 let Spellings = [GNU<"guarded_by">];
2564 let Args = [ExprArgument<"Arg">];
2566 let TemplateDependent = 1;
2567 let ParseArgumentsAsUnevaluated = 1;
2568 let InheritEvenIfAlreadyPresent = 1;
2569 let Subjects = SubjectList<[Field, SharedVar]>;
2570 let Documentation = [Undocumented];
2573 def PtGuardedBy : InheritableAttr {
2574 let Spellings = [GNU<"pt_guarded_by">];
2575 let Args = [ExprArgument<"Arg">];
2577 let TemplateDependent = 1;
2578 let ParseArgumentsAsUnevaluated = 1;
2579 let InheritEvenIfAlreadyPresent = 1;
2580 let Subjects = SubjectList<[Field, SharedVar]>;
2581 let Documentation = [Undocumented];
2584 def AcquiredAfter : InheritableAttr {
2585 let Spellings = [GNU<"acquired_after">];
2586 let Args = [VariadicExprArgument<"Args">];
2588 let TemplateDependent = 1;
2589 let ParseArgumentsAsUnevaluated = 1;
2590 let InheritEvenIfAlreadyPresent = 1;
2591 let Subjects = SubjectList<[Field, SharedVar]>;
2592 let Documentation = [Undocumented];
2595 def AcquiredBefore : InheritableAttr {
2596 let Spellings = [GNU<"acquired_before">];
2597 let Args = [VariadicExprArgument<"Args">];
2599 let TemplateDependent = 1;
2600 let ParseArgumentsAsUnevaluated = 1;
2601 let InheritEvenIfAlreadyPresent = 1;
2602 let Subjects = SubjectList<[Field, SharedVar]>;
2603 let Documentation = [Undocumented];
2606 def AssertExclusiveLock : InheritableAttr {
2607 let Spellings = [GNU<"assert_exclusive_lock">];
2608 let Args = [VariadicExprArgument<"Args">];
2610 let TemplateDependent = 1;
2611 let ParseArgumentsAsUnevaluated = 1;
2612 let InheritEvenIfAlreadyPresent = 1;
2613 let Subjects = SubjectList<[Function]>;
2614 let Documentation = [Undocumented];
2617 def AssertSharedLock : InheritableAttr {
2618 let Spellings = [GNU<"assert_shared_lock">];
2619 let Args = [VariadicExprArgument<"Args">];
2621 let TemplateDependent = 1;
2622 let ParseArgumentsAsUnevaluated = 1;
2623 let InheritEvenIfAlreadyPresent = 1;
2624 let Subjects = SubjectList<[Function]>;
2625 let Documentation = [Undocumented];
2628 // The first argument is an integer or boolean value specifying the return value
2629 // of a successful lock acquisition.
2630 def ExclusiveTrylockFunction : InheritableAttr {
2631 let Spellings = [GNU<"exclusive_trylock_function">];
2632 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2634 let TemplateDependent = 1;
2635 let ParseArgumentsAsUnevaluated = 1;
2636 let InheritEvenIfAlreadyPresent = 1;
2637 let Subjects = SubjectList<[Function]>;
2638 let Documentation = [Undocumented];
2641 // The first argument is an integer or boolean value specifying the return value
2642 // of a successful lock acquisition.
2643 def SharedTrylockFunction : InheritableAttr {
2644 let Spellings = [GNU<"shared_trylock_function">];
2645 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2647 let TemplateDependent = 1;
2648 let ParseArgumentsAsUnevaluated = 1;
2649 let InheritEvenIfAlreadyPresent = 1;
2650 let Subjects = SubjectList<[Function]>;
2651 let Documentation = [Undocumented];
2654 def LockReturned : InheritableAttr {
2655 let Spellings = [GNU<"lock_returned">];
2656 let Args = [ExprArgument<"Arg">];
2658 let TemplateDependent = 1;
2659 let ParseArgumentsAsUnevaluated = 1;
2660 let Subjects = SubjectList<[Function]>;
2661 let Documentation = [Undocumented];
2664 def LocksExcluded : InheritableAttr {
2665 let Spellings = [GNU<"locks_excluded">];
2666 let Args = [VariadicExprArgument<"Args">];
2668 let TemplateDependent = 1;
2669 let ParseArgumentsAsUnevaluated = 1;
2670 let InheritEvenIfAlreadyPresent = 1;
2671 let Subjects = SubjectList<[Function]>;
2672 let Documentation = [Undocumented];
2675 // C/C++ consumed attributes.
2677 def Consumable : InheritableAttr {
2678 // This attribute does not have a C [[]] spelling because it only appertains
2679 // to C++ struct/class/union.
2680 // FIXME: should this attribute have a CPlusPlus language option?
2681 let Spellings = [Clang<"consumable", 0>];
2682 let Subjects = SubjectList<[CXXRecord]>;
2683 let Args = [EnumArgument<"DefaultState", "ConsumedState",
2684 ["unknown", "consumed", "unconsumed"],
2685 ["Unknown", "Consumed", "Unconsumed"]>];
2686 let Documentation = [ConsumableDocs];
2689 def ConsumableAutoCast : InheritableAttr {
2690 // This attribute does not have a C [[]] spelling because it only appertains
2691 // to C++ struct/class/union.
2692 // FIXME: should this attribute have a CPlusPlus language option?
2693 let Spellings = [Clang<"consumable_auto_cast_state", 0>];
2694 let Subjects = SubjectList<[CXXRecord]>;
2695 let Documentation = [Undocumented];
2698 def ConsumableSetOnRead : InheritableAttr {
2699 // This attribute does not have a C [[]] spelling because it only appertains
2700 // to C++ struct/class/union.
2701 // FIXME: should this attribute have a CPlusPlus language option?
2702 let Spellings = [Clang<"consumable_set_state_on_read", 0>];
2703 let Subjects = SubjectList<[CXXRecord]>;
2704 let Documentation = [Undocumented];
2707 def CallableWhen : InheritableAttr {
2708 // This attribute does not have a C [[]] spelling because it only appertains
2709 // to C++ function (but doesn't require it to be a member function).
2710 // FIXME: should this attribute have a CPlusPlus language option?
2711 let Spellings = [Clang<"callable_when", 0>];
2712 let Subjects = SubjectList<[CXXMethod]>;
2713 let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
2714 ["unknown", "consumed", "unconsumed"],
2715 ["Unknown", "Consumed", "Unconsumed"]>];
2716 let Documentation = [CallableWhenDocs];
2719 def ParamTypestate : InheritableAttr {
2720 // This attribute does not have a C [[]] spelling because it only appertains
2721 // to a parameter whose type is a consumable C++ class.
2722 // FIXME: should this attribute have a CPlusPlus language option?
2723 let Spellings = [Clang<"param_typestate", 0>];
2724 let Subjects = SubjectList<[ParmVar]>;
2725 let Args = [EnumArgument<"ParamState", "ConsumedState",
2726 ["unknown", "consumed", "unconsumed"],
2727 ["Unknown", "Consumed", "Unconsumed"]>];
2728 let Documentation = [ParamTypestateDocs];
2731 def ReturnTypestate : InheritableAttr {
2732 // This attribute does not have a C [[]] spelling because it only appertains
2733 // to a parameter or function return type that is a consumable C++ class.
2734 // FIXME: should this attribute have a CPlusPlus language option?
2735 let Spellings = [Clang<"return_typestate", 0>];
2736 let Subjects = SubjectList<[Function, ParmVar]>;
2737 let Args = [EnumArgument<"State", "ConsumedState",
2738 ["unknown", "consumed", "unconsumed"],
2739 ["Unknown", "Consumed", "Unconsumed"]>];
2740 let Documentation = [ReturnTypestateDocs];
2743 def SetTypestate : InheritableAttr {
2744 // This attribute does not have a C [[]] spelling because it only appertains
2745 // to C++ function (but doesn't require it to be a member function).
2746 // FIXME: should this attribute have a CPlusPlus language option?
2747 let Spellings = [Clang<"set_typestate", 0>];
2748 let Subjects = SubjectList<[CXXMethod]>;
2749 let Args = [EnumArgument<"NewState", "ConsumedState",
2750 ["unknown", "consumed", "unconsumed"],
2751 ["Unknown", "Consumed", "Unconsumed"]>];
2752 let Documentation = [SetTypestateDocs];
2755 def TestTypestate : InheritableAttr {
2756 // This attribute does not have a C [[]] spelling because it only appertains
2757 // to C++ function (but doesn't require it to be a member function).
2758 // FIXME: should this attribute have a CPlusPlus language option?
2759 let Spellings = [Clang<"test_typestate", 0>];
2760 let Subjects = SubjectList<[CXXMethod]>;
2761 let Args = [EnumArgument<"TestState", "ConsumedState",
2762 ["consumed", "unconsumed"],
2763 ["Consumed", "Unconsumed"]>];
2764 let Documentation = [TestTypestateDocs];
2767 // Type safety attributes for `void *' pointers and type tags.
2769 def ArgumentWithTypeTag : InheritableAttr {
2770 let Spellings = [Clang<"argument_with_type_tag">,
2771 Clang<"pointer_with_type_tag">];
2772 let Subjects = SubjectList<[HasFunctionProto], ErrorDiag>;
2773 let Args = [IdentifierArgument<"ArgumentKind">,
2774 ParamIdxArgument<"ArgumentIdx">,
2775 ParamIdxArgument<"TypeTagIdx">,
2776 BoolArgument<"IsPointer", /*opt*/0, /*fake*/1>];
2777 let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
2780 def TypeTagForDatatype : InheritableAttr {
2781 let Spellings = [Clang<"type_tag_for_datatype">];
2782 let Args = [IdentifierArgument<"ArgumentKind">,
2783 TypeArgument<"MatchingCType">,
2784 BoolArgument<"LayoutCompatible">,
2785 BoolArgument<"MustBeNull">];
2786 // let Subjects = SubjectList<[Var], ErrorDiag>;
2787 let HasCustomParsing = 1;
2788 let Documentation = [TypeTagForDatatypeDocs];
2791 // Microsoft-related attributes
2793 def MSNoVTable : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
2794 let Spellings = [Declspec<"novtable">];
2795 let Subjects = SubjectList<[CXXRecord]>;
2796 let Documentation = [MSNoVTableDocs];
2800 let Spellings = [Declspec<"property">];
2803 def MSAllocator : InheritableAttr {
2804 let Spellings = [Declspec<"allocator">];
2805 let Subjects = SubjectList<[Function]>;
2806 let Documentation = [MSAllocatorDocs];
2809 def MSStruct : InheritableAttr {
2810 let Spellings = [GCC<"ms_struct">];
2811 let Subjects = SubjectList<[Record]>;
2812 let Documentation = [Undocumented];
2815 def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2816 let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
2817 let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2818 let Documentation = [DLLExportDocs];
2821 def DLLExportStaticLocal : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2822 // This attribute is used internally only when -fno-dllexport-inlines is
2823 // passed. This attribute is added to inline function of class having
2824 // dllexport attribute. And if the function has static local variables, this
2825 // attribute is used to whether the variables are exported or not. Also if
2826 // function has local static variables, the function is dllexported too.
2828 let Subjects = SubjectList<[Function]>;
2829 let Documentation = [Undocumented];
2832 def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2833 let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
2834 let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2835 let Documentation = [DLLImportDocs];
2838 let AdditionalMembers = [{
2840 bool PropagatedToBaseTemplate = false;
2843 void setPropagatedToBaseTemplate() { PropagatedToBaseTemplate = true; }
2844 bool wasPropagatedToBaseTemplate() { return PropagatedToBaseTemplate; }
2848 def DLLImportStaticLocal : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2849 // This attribute is used internally only when -fno-dllexport-inlines is
2850 // passed. This attribute is added to inline function of class having
2851 // dllimport attribute. And if the function has static local variables, this
2852 // attribute is used to whether the variables are imported or not.
2854 let Subjects = SubjectList<[Function]>;
2855 let Documentation = [Undocumented];
2858 def SelectAny : InheritableAttr {
2859 let Spellings = [Declspec<"selectany">, GCC<"selectany">];
2860 let Documentation = [SelectAnyDocs];
2864 let Spellings = [Declspec<"thread">];
2865 let LangOpts = [MicrosoftExt];
2866 let Documentation = [ThreadDocs];
2867 let Subjects = SubjectList<[Var]>;
2870 def Win64 : IgnoredAttr {
2871 let Spellings = [Keyword<"__w64">];
2872 let LangOpts = [MicrosoftExt];
2875 def Ptr32 : TypeAttr {
2876 let Spellings = [Keyword<"__ptr32">];
2877 let Documentation = [Undocumented];
2880 def Ptr64 : TypeAttr {
2881 let Spellings = [Keyword<"__ptr64">];
2882 let Documentation = [Undocumented];
2885 def SPtr : TypeAttr {
2886 let Spellings = [Keyword<"__sptr">];
2887 let Documentation = [Undocumented];
2890 def UPtr : TypeAttr {
2891 let Spellings = [Keyword<"__uptr">];
2892 let Documentation = [Undocumented];
2895 def MSInheritance : InheritableAttr {
2896 let LangOpts = [MicrosoftExt];
2897 let Args = [DefaultBoolArgument<"BestCase", /*default*/1, /*fake*/1>];
2898 let Spellings = [Keyword<"__single_inheritance">,
2899 Keyword<"__multiple_inheritance">,
2900 Keyword<"__virtual_inheritance">,
2901 Keyword<"__unspecified_inheritance">];
2902 let AdditionalMembers = [{
2903 static bool hasVBPtrOffsetField(Spelling Inheritance) {
2904 return Inheritance == Keyword_unspecified_inheritance;
2907 // Only member pointers to functions need a this adjustment, since it can be
2908 // combined with the field offset for data pointers.
2909 static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
2910 return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
2913 static bool hasVBTableOffsetField(Spelling Inheritance) {
2914 return Inheritance >= Keyword_virtual_inheritance;
2917 static bool hasOnlyOneField(bool IsMemberFunction,
2918 Spelling Inheritance) {
2919 if (IsMemberFunction)
2920 return Inheritance <= Keyword_single_inheritance;
2921 return Inheritance <= Keyword_multiple_inheritance;
2924 let Documentation = [MSInheritanceDocs];
2927 def MSVtorDisp : InheritableAttr {
2928 // This attribute has no spellings as it is only ever created implicitly.
2930 let Args = [UnsignedArgument<"vdm">];
2931 let SemaHandler = 0;
2933 let AdditionalMembers = [{
2940 Mode getVtorDispMode() const { return Mode(vdm); }
2942 let Documentation = [Undocumented];
2945 def InitSeg : Attr {
2946 let Spellings = [Pragma<"", "init_seg">];
2947 let Args = [StringArgument<"Section">];
2948 let SemaHandler = 0;
2949 let Documentation = [InitSegDocs];
2950 let AdditionalMembers = [{
2951 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2952 OS << " (" << getSection() << ')';
2957 def LoopHint : Attr {
2958 /// #pragma clang loop <option> directive
2959 /// vectorize: vectorizes loop operations if State == Enable.
2960 /// vectorize_width: vectorize loop operations with width 'Value'.
2961 /// interleave: interleave multiple loop iterations if State == Enable.
2962 /// interleave_count: interleaves 'Value' loop iterations.
2963 /// unroll: fully unroll loop if State == Enable.
2964 /// unroll_count: unrolls loop 'Value' times.
2965 /// unroll_and_jam: attempt to unroll and jam loop if State == Enable.
2966 /// unroll_and_jam_count: unroll and jams loop 'Value' times.
2967 /// distribute: attempt to distribute loop if State == Enable.
2968 /// pipeline: disable pipelining loop if State == Disable.
2969 /// pipeline_initiation_interval: create loop schedule with initiation interval equal to 'Value'.
2971 /// #pragma unroll <argument> directive
2972 /// <no arg>: fully unrolls loop.
2973 /// boolean: fully unrolls loop if State == Enable.
2974 /// expression: unrolls loop 'Value' times.
2976 let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">,
2977 Pragma<"", "nounroll">, Pragma<"", "unroll_and_jam">,
2978 Pragma<"", "nounroll_and_jam">];
2980 /// State of the loop optimization specified by the spelling.
2981 let Args = [EnumArgument<"Option", "OptionType",
2982 ["vectorize", "vectorize_width", "interleave", "interleave_count",
2983 "unroll", "unroll_count", "unroll_and_jam", "unroll_and_jam_count",
2984 "pipeline", "pipeline_initiation_interval", "distribute"],
2985 ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
2986 "Unroll", "UnrollCount", "UnrollAndJam", "UnrollAndJamCount",
2987 "PipelineDisabled", "PipelineInitiationInterval", "Distribute"]>,
2988 EnumArgument<"State", "LoopHintState",
2989 ["enable", "disable", "numeric", "assume_safety", "full"],
2990 ["Enable", "Disable", "Numeric", "AssumeSafety", "Full"]>,
2991 ExprArgument<"Value">];
2993 let AdditionalMembers = [{
2994 static const char *getOptionName(int Option) {
2996 case Vectorize: return "vectorize";
2997 case VectorizeWidth: return "vectorize_width";
2998 case Interleave: return "interleave";
2999 case InterleaveCount: return "interleave_count";
3000 case Unroll: return "unroll";
3001 case UnrollCount: return "unroll_count";
3002 case UnrollAndJam: return "unroll_and_jam";
3003 case UnrollAndJamCount: return "unroll_and_jam_count";
3004 case PipelineDisabled: return "pipeline";
3005 case PipelineInitiationInterval: return "pipeline_initiation_interval";
3006 case Distribute: return "distribute";
3008 llvm_unreachable("Unhandled LoopHint option.");
3011 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
3012 unsigned SpellingIndex = getSpellingListIndex();
3013 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
3014 // "nounroll" is already emitted as the pragma name.
3015 if (SpellingIndex == Pragma_nounroll || SpellingIndex == Pragma_nounroll_and_jam)
3017 else if (SpellingIndex == Pragma_unroll || SpellingIndex == Pragma_unroll_and_jam) {
3018 OS << ' ' << getValueString(Policy);
3022 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
3023 OS << ' ' << getOptionName(option) << getValueString(Policy);
3026 // Return a string containing the loop hint argument including the
3027 // enclosing parentheses.
3028 std::string getValueString(const PrintingPolicy &Policy) const {
3029 std::string ValueName;
3030 llvm::raw_string_ostream OS(ValueName);
3032 if (state == Numeric)
3033 value->printPretty(OS, nullptr, Policy);
3034 else if (state == Enable)
3036 else if (state == Full)
3038 else if (state == AssumeSafety)
3039 OS << "assume_safety";
3046 // Return a string suitable for identifying this attribute in diagnostics.
3047 std::string getDiagnosticName(const PrintingPolicy &Policy) const {
3048 unsigned SpellingIndex = getSpellingListIndex();
3049 if (SpellingIndex == Pragma_nounroll)
3050 return "#pragma nounroll";
3051 else if (SpellingIndex == Pragma_unroll)
3052 return "#pragma unroll" + (option == UnrollCount ? getValueString(Policy) : "");
3053 else if (SpellingIndex == Pragma_nounroll_and_jam)
3054 return "#pragma nounroll_and_jam";
3055 else if (SpellingIndex == Pragma_unroll_and_jam)
3056 return "#pragma unroll_and_jam" +
3057 (option == UnrollAndJamCount ? getValueString(Policy) : "");
3059 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
3060 return getOptionName(option) + getValueString(Policy);
3064 let Documentation = [LoopHintDocs, UnrollHintDocs];
3067 def CapturedRecord : InheritableAttr {
3068 // This attribute has no spellings as it is only ever created implicitly.
3070 let SemaHandler = 0;
3071 let Documentation = [Undocumented];
3074 def OMPThreadPrivateDecl : InheritableAttr {
3075 // This attribute has no spellings as it is only ever created implicitly.
3077 let SemaHandler = 0;
3078 let Documentation = [Undocumented];
3081 def OMPCaptureNoInit : InheritableAttr {
3082 // This attribute has no spellings as it is only ever created implicitly.
3084 let SemaHandler = 0;
3085 let Documentation = [Undocumented];
3088 def OMPCaptureKind : Attr {
3089 // This attribute has no spellings as it is only ever created implicitly.
3091 let SemaHandler = 0;
3092 let Args = [UnsignedArgument<"CaptureKind">];
3093 let Documentation = [Undocumented];
3096 def OMPReferencedVar : Attr {
3097 // This attribute has no spellings as it is only ever created implicitly.
3099 let SemaHandler = 0;
3100 let Args = [ExprArgument<"Ref">];
3101 let Documentation = [Undocumented];
3104 def OMPDeclareSimdDecl : Attr {
3105 let Spellings = [Pragma<"omp", "declare simd">];
3106 let Subjects = SubjectList<[Function]>;
3107 let SemaHandler = 0;
3108 let HasCustomParsing = 1;
3109 let Documentation = [OMPDeclareSimdDocs];
3111 EnumArgument<"BranchState", "BranchStateTy",
3112 [ "", "inbranch", "notinbranch" ],
3113 [ "BS_Undefined", "BS_Inbranch", "BS_Notinbranch" ]>,
3114 ExprArgument<"Simdlen">, VariadicExprArgument<"Uniforms">,
3115 VariadicExprArgument<"Aligneds">, VariadicExprArgument<"Alignments">,
3116 VariadicExprArgument<"Linears">, VariadicUnsignedArgument<"Modifiers">,
3117 VariadicExprArgument<"Steps">
3119 let AdditionalMembers = [{
3120 void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
3122 if (getBranchState() != BS_Undefined)
3123 OS << ' ' << ConvertBranchStateTyToStr(getBranchState());
3124 if (auto *E = getSimdlen()) {
3126 E->printPretty(OS, nullptr, Policy);
3129 if (uniforms_size() > 0) {
3131 StringRef Sep = "(";
3132 for (auto *E : uniforms()) {
3134 E->printPretty(OS, nullptr, Policy);
3139 alignments_iterator NI = alignments_begin();
3140 for (auto *E : aligneds()) {
3142 E->printPretty(OS, nullptr, Policy);
3145 (*NI)->printPretty(OS, nullptr, Policy);
3150 steps_iterator I = steps_begin();
3151 modifiers_iterator MI = modifiers_begin();
3152 for (auto *E : linears()) {
3154 if (*MI != OMPC_LINEAR_unknown)
3155 OS << getOpenMPSimpleClauseTypeName(OMPC_linear, *MI) << "(";
3156 E->printPretty(OS, nullptr, Policy);
3157 if (*MI != OMPC_LINEAR_unknown)
3161 (*I)->printPretty(OS, nullptr, Policy);
3171 def OMPDeclareTargetDecl : InheritableAttr {
3172 let Spellings = [Pragma<"omp", "declare target">];
3173 let SemaHandler = 0;
3174 let Subjects = SubjectList<[Function, SharedVar]>;
3175 let Documentation = [OMPDeclareTargetDocs];
3177 EnumArgument<"MapType", "MapTypeTy",
3179 [ "MT_To", "MT_Link" ]>
3181 let AdditionalMembers = [{
3182 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
3183 // Use fake syntax because it is for testing and debugging purpose only.
3184 if (getMapType() != MT_To)
3185 OS << ' ' << ConvertMapTypeTyToStr(getMapType());
3187 static llvm::Optional<MapTypeTy>
3188 isDeclareTargetDeclaration(const ValueDecl *VD) {
3189 if (!VD->hasAttrs())
3191 if (const auto *Attr = VD->getAttr<OMPDeclareTargetDeclAttr>())
3192 return Attr->getMapType();
3199 def OMPAllocateDecl : InheritableAttr {
3200 // This attribute has no spellings as it is only ever created implicitly.
3202 let SemaHandler = 0;
3204 EnumArgument<"AllocatorType", "AllocatorTypeTy",
3206 "omp_default_mem_alloc", "omp_large_cap_mem_alloc",
3207 "omp_const_mem_alloc", "omp_high_bw_mem_alloc",
3208 "omp_low_lat_mem_alloc", "omp_cgroup_mem_alloc",
3209 "omp_pteam_mem_alloc", "omp_thread_mem_alloc", ""
3212 "OMPDefaultMemAlloc", "OMPLargeCapMemAlloc",
3213 "OMPConstMemAlloc", "OMPHighBWMemAlloc", "OMPLowLatMemAlloc",
3214 "OMPCGroupMemAlloc", "OMPPTeamMemAlloc", "OMPThreadMemAlloc",
3215 "OMPUserDefinedMemAlloc"
3217 ExprArgument<"Allocator">
3219 let Documentation = [Undocumented];
3222 def InternalLinkage : InheritableAttr {
3223 let Spellings = [Clang<"internal_linkage">];
3224 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
3225 let Documentation = [InternalLinkageDocs];
3228 def ExcludeFromExplicitInstantiation : InheritableAttr {
3229 let Spellings = [Clang<"exclude_from_explicit_instantiation">];
3230 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
3231 let Documentation = [ExcludeFromExplicitInstantiationDocs];
3232 let MeaningfulToClassTemplateDefinition = 1;
3235 def Reinitializes : InheritableAttr {
3236 let Spellings = [Clang<"reinitializes", 0>];
3237 let Subjects = SubjectList<[NonStaticNonConstCXXMethod], ErrorDiag>;
3238 let Documentation = [ReinitializesDocs];
3241 def NoDestroy : InheritableAttr {
3242 let Spellings = [Clang<"no_destroy", 0>];
3243 let Subjects = SubjectList<[Var]>;
3244 let Documentation = [NoDestroyDocs];
3247 def AlwaysDestroy : InheritableAttr {
3248 let Spellings = [Clang<"always_destroy", 0>];
3249 let Subjects = SubjectList<[Var]>;
3250 let Documentation = [AlwaysDestroyDocs];
3253 def SpeculativeLoadHardening : InheritableAttr {
3254 let Spellings = [Clang<"speculative_load_hardening">];
3255 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
3256 let Documentation = [SpeculativeLoadHardeningDocs];
3259 def NoSpeculativeLoadHardening : InheritableAttr {
3260 let Spellings = [Clang<"no_speculative_load_hardening">];
3261 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
3262 let Documentation = [NoSpeculativeLoadHardeningDocs];
3265 def Uninitialized : InheritableAttr {
3266 let Spellings = [Clang<"uninitialized", 0>];
3267 let Subjects = SubjectList<[LocalVar]>;
3268 let Documentation = [UninitializedDocs];
3271 def ObjCExternallyRetained : InheritableAttr {
3272 let LangOpts = [ObjCAutoRefCount];
3273 let Spellings = [Clang<"objc_externally_retained">];
3274 let Subjects = SubjectList<[NonParmVar, Function, Block, ObjCMethod]>;
3275 let Documentation = [ObjCExternallyRetainedDocs];