1 //==--- Attr.td - attribute definitions -----------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // The documentation is organized by category. Attributes can have category-
11 // specific documentation that is collated within the larger document.
12 class DocumentationCategory<string name> {
16 def DocCatFunction : DocumentationCategory<"Function Attributes">;
17 def DocCatVariable : DocumentationCategory<"Variable Attributes">;
18 def DocCatType : DocumentationCategory<"Type Attributes">;
19 def DocCatStmt : DocumentationCategory<"Statement Attributes">;
20 // Attributes listed under the Undocumented category do not generate any public
21 // documentation. Ideally, this category should be used for internal-only
22 // attributes which contain no spellings.
23 def DocCatUndocumented : DocumentationCategory<"Undocumented">;
25 class DocDeprecated<string replacement = ""> {
26 // If the Replacement field is empty, no replacement will be listed with the
27 // documentation. Otherwise, the documentation will specify the attribute has
28 // been superseded by this replacement.
29 string Replacement = replacement;
32 // Specifies the documentation to be associated with the given category.
34 DocumentationCategory Category;
37 // If the heading is empty, one may be picked automatically. If the attribute
38 // only has one spelling, no heading is required as the attribute's sole
39 // spelling is sufficient. If all spellings are semantically common, the
40 // heading will be the semantic spelling. If the spellings are not
41 // semantically common and no heading is provided, an error will be emitted.
44 // When set, specifies that the attribute is deprecated and can optionally
45 // specify a replacement attribute.
46 DocDeprecated Deprecated;
49 // Specifies that the attribute is explicitly undocumented. This can be a
50 // helpful placeholder for the attribute while working on the implementation,
51 // but should not be used once feature work has been completed.
52 def Undocumented : Documentation {
53 let Category = DocCatUndocumented;
56 include "clang/Basic/AttrDocs.td"
58 // An attribute's subject is whatever it appertains to. In this file, it is
59 // more accurately a list of things that an attribute can appertain to. All
60 // Decls and Stmts are possibly AttrSubjects (even though the syntax may not
61 // allow attributes on a given Decl or Stmt).
64 include "clang/Basic/DeclNodes.td"
65 include "clang/Basic/StmtNodes.td"
67 // A subset-subject is an AttrSubject constrained to operate only on some subset
70 // The code fragment is a boolean expression that will confirm that the subject
71 // meets the requirements; the subject will have the name S, and will have the
72 // type specified by the base. It should be a simple boolean expression. The
73 // diagnostic string should be a comma-separated list of subject names.
74 class SubsetSubject<AttrSubject base, code check, string diag> : AttrSubject {
75 AttrSubject Base = base;
76 code CheckCode = check;
77 string DiagSpelling = diag;
80 def LocalVar : SubsetSubject<Var,
81 [{S->hasLocalStorage() && !isa<ParmVarDecl>(S)}],
83 def NonParmVar : SubsetSubject<Var,
84 [{S->getKind() != Decl::ParmVar}],
86 def NonLocalVar : SubsetSubject<Var,
87 [{!S->hasLocalStorage()}],
88 "variables with non-local storage">;
89 def NonBitField : SubsetSubject<Field,
91 "non-bit-field non-static data members">;
93 def ObjCInstanceMethod : SubsetSubject<ObjCMethod,
94 [{S->isInstanceMethod()}],
95 "Objective-C instance methods">;
97 def ObjCInterfaceDeclInitMethod : SubsetSubject<ObjCMethod,
98 [{S->getMethodFamily() == OMF_init &&
99 (isa<ObjCInterfaceDecl>(S->getDeclContext()) ||
100 (isa<ObjCCategoryDecl>(S->getDeclContext()) &&
101 cast<ObjCCategoryDecl>(S->getDeclContext())->IsClassExtension()))}],
102 "init methods of interface or class extension declarations">;
104 def Struct : SubsetSubject<Record,
105 [{!S->isUnion()}], "structs">;
107 def TLSVar : SubsetSubject<Var,
108 [{S->getTLSKind() != 0}], "thread-local variables">;
110 def SharedVar : SubsetSubject<Var,
111 [{S->hasGlobalStorage() && !S->getTLSKind()}],
114 def GlobalVar : SubsetSubject<Var,
115 [{S->hasGlobalStorage()}], "global variables">;
117 def InlineFunction : SubsetSubject<Function,
118 [{S->isInlineSpecified()}], "inline functions">;
120 // FIXME: this hack is needed because DeclNodes.td defines the base Decl node
121 // type to be a class, not a definition. This makes it impossible to create an
122 // attribute subject which accepts a Decl. Normally, this is not a problem,
123 // because the attribute can have no Subjects clause to accomplish this. But in
124 // the case of a SubsetSubject, there's no way to express it without this hack.
125 def DeclBase : AttrSubject;
126 def FunctionLike : SubsetSubject<DeclBase,
127 [{S->getFunctionType(false) != nullptr}],
128 "functions, function pointers">;
130 def OpenCLKernelFunction
131 : SubsetSubject<Function, [{S->hasAttr<OpenCLKernelAttr>()}],
134 // HasFunctionProto is a more strict version of FunctionLike, so it should
135 // never be specified in a Subjects list along with FunctionLike (due to the
136 // inclusive nature of subject testing).
137 def HasFunctionProto : SubsetSubject<DeclBase,
138 [{(S->getFunctionType(true) != nullptr &&
139 isa<FunctionProtoType>(S->getFunctionType())) ||
140 isa<ObjCMethodDecl>(S) ||
142 "non-K&R-style functions">;
144 // A subject that matches the implicit object parameter of a non-static member
145 // function. Accepted as a function type attribute on the type of such a
147 // FIXME: This does not actually ever match currently.
148 def ImplicitObjectParameter : SubsetSubject<Function, [{false}],
149 "implicit object parameters">;
151 // A single argument to an attribute
152 class Argument<string name, bit optional, bit fake = 0> {
154 bit Optional = optional;
156 /// A fake argument is used to store and serialize additional information
157 /// in an attribute without actually changing its parsing or pretty-printing.
161 class BoolArgument<string name, bit opt = 0, bit fake = 0> : Argument<name, opt,
163 class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>;
164 class IntArgument<string name, bit opt = 0> : Argument<name, opt>;
165 class StringArgument<string name, bit opt = 0> : Argument<name, opt>;
166 class ExprArgument<string name, bit opt = 0> : Argument<name, opt>;
167 class FunctionArgument<string name, bit opt = 0, bit fake = 0> : Argument<name,
170 class NamedArgument<string name, bit opt = 0, bit fake = 0> : Argument<name,
173 class TypeArgument<string name, bit opt = 0> : Argument<name, opt>;
174 class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>;
175 class VariadicUnsignedArgument<string name> : Argument<name, 1>;
176 class VariadicExprArgument<string name> : Argument<name, 1>;
177 class VariadicStringArgument<string name> : Argument<name, 1>;
178 class VariadicIdentifierArgument<string name> : Argument<name, 1>;
180 // Like VariadicUnsignedArgument except values are ParamIdx.
181 class VariadicParamIdxArgument<string name> : Argument<name, 1>;
183 // Like VariadicParamIdxArgument but for a single function parameter index.
184 class ParamIdxArgument<string name, bit opt = 0> : Argument<name, opt>;
186 // A version of the form major.minor[.subminor].
187 class VersionArgument<string name, bit opt = 0> : Argument<name, opt>;
189 // This one's a doozy, so it gets its own special type
190 // It can be an unsigned integer, or a type. Either can
192 class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>;
194 // A bool argument with a default value
195 class DefaultBoolArgument<string name, bit default, bit fake = 0>
196 : BoolArgument<name, 1, fake> {
197 bit Default = default;
200 // An integer argument with a default value
201 class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
202 int Default = default;
205 // This argument is more complex, it includes the enumerator type name,
206 // a list of strings to accept, and a list of enumerators to map them to.
207 class EnumArgument<string name, string type, list<string> values,
208 list<string> enums, bit opt = 0, bit fake = 0>
209 : Argument<name, opt, fake> {
211 list<string> Values = values;
212 list<string> Enums = enums;
215 // FIXME: There should be a VariadicArgument type that takes any other type
216 // of argument and generates the appropriate type.
217 class VariadicEnumArgument<string name, string type, list<string> values,
218 list<string> enums> : Argument<name, 1> {
220 list<string> Values = values;
221 list<string> Enums = enums;
224 // This handles one spelling of an attribute.
225 class Spelling<string name, string variety> {
227 string Variety = variety;
231 class GNU<string name> : Spelling<name, "GNU">;
232 class Declspec<string name> : Spelling<name, "Declspec">;
233 class Microsoft<string name> : Spelling<name, "Microsoft">;
234 class CXX11<string namespace, string name, int version = 1>
235 : Spelling<name, "CXX11"> {
236 string Namespace = namespace;
237 int Version = version;
239 class C2x<string namespace, string name> : Spelling<name, "C2x"> {
240 string Namespace = namespace;
243 class Keyword<string name> : Spelling<name, "Keyword">;
244 class Pragma<string namespace, string name> : Spelling<name, "Pragma"> {
245 string Namespace = namespace;
248 // The GCC spelling implies GNU<name> and CXX11<"gnu", name> and also sets
249 // KnownToGCC to 1. This spelling should be used for any GCC-compatible
251 class GCC<string name> : Spelling<name, "GCC"> {
255 // The Clang spelling implies GNU<name>, CXX11<"clang", name>, and optionally,
256 // C2x<"clang", name>. This spelling should be used for any Clang-specific
258 class Clang<string name, bit allowInC = 1> : Spelling<name, "Clang"> {
259 bit AllowInC = allowInC;
262 class Accessor<string name, list<Spelling> spellings> {
264 list<Spelling> Spellings = spellings;
267 class SubjectDiag<bit warn> {
270 def WarnDiag : SubjectDiag<1>;
271 def ErrorDiag : SubjectDiag<0>;
273 class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag,
274 string customDiag = ""> {
275 list<AttrSubject> Subjects = subjects;
276 SubjectDiag Diag = diag;
277 string CustomDiag = customDiag;
280 class LangOpt<string name, bit negated = 0> {
282 bit Negated = negated;
284 def MicrosoftExt : LangOpt<"MicrosoftExt">;
285 def Borland : LangOpt<"Borland">;
286 def CUDA : LangOpt<"CUDA">;
287 def COnly : LangOpt<"CPlusPlus", 1>;
288 def CPlusPlus : LangOpt<"CPlusPlus">;
289 def OpenCL : LangOpt<"OpenCL">;
290 def RenderScript : LangOpt<"RenderScript">;
291 def ObjC : LangOpt<"ObjC1">;
292 def BlocksSupported : LangOpt<"Blocks">;
294 // Defines targets for target-specific attributes. Empty lists are unchecked.
296 // Specifies Architectures for which the target applies, based off the
297 // ArchType enumeration in Triple.h.
298 list<string> Arches = [];
299 // Specifies Operating Systems for which the target applies, based off the
300 // OSType enumeration in Triple.h
302 // Specifies the C++ ABIs for which the target applies, based off the
303 // TargetCXXABI::Kind in TargetCXXABI.h.
304 list<string> CXXABIs;
305 // Specifies Object Formats for which the target applies, based off the
306 // ObjectFormatType enumeration in Triple.h
307 list<string> ObjectFormats;
310 class TargetArch<list<string> arches> : TargetSpec {
313 def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
314 def TargetAVR : TargetArch<["avr"]>;
315 def TargetMips32 : TargetArch<["mips", "mipsel"]>;
316 def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
317 def TargetMSP430 : TargetArch<["msp430"]>;
318 def TargetRISCV : TargetArch<["riscv32", "riscv64"]>;
319 def TargetX86 : TargetArch<["x86"]>;
320 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
321 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
322 let OSes = ["Win32"];
324 def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
325 let CXXABIs = ["Microsoft"];
327 def TargetELF : TargetSpec {
328 let ObjectFormats = ["ELF"];
331 // Attribute subject match rules that are used for #pragma clang attribute.
333 // A instance of AttrSubjectMatcherRule represents an individual match rule.
334 // An individual match rule can correspond to a number of different attribute
335 // subjects, e.g. "record" matching rule corresponds to the Record and
336 // CXXRecord attribute subjects.
338 // Match rules are used in the subject list of the #pragma clang attribute.
339 // Match rules can have sub-match rules that are instances of
340 // AttrSubjectMatcherSubRule. A sub-match rule can correspond to a number
341 // of different attribute subjects, and it can have a negated spelling as well.
342 // For example, "variable(unless(is_parameter))" matching rule corresponds to
343 // the NonParmVar attribute subject.
344 class AttrSubjectMatcherSubRule<string name, list<AttrSubject> subjects,
347 list<AttrSubject> Subjects = subjects;
348 bit Negated = negated;
349 // Lists language options, one of which is required to be true for the
350 // attribute to be applicable. If empty, the language options are taken
351 // from the parent matcher rule.
352 list<LangOpt> LangOpts = [];
354 class AttrSubjectMatcherRule<string name, list<AttrSubject> subjects,
355 list<AttrSubjectMatcherSubRule> subrules = []> {
357 list<AttrSubject> Subjects = subjects;
358 list<AttrSubjectMatcherSubRule> Constraints = subrules;
359 // Lists language options, one of which is required to be true for the
360 // attribute to be applicable. If empty, no language options are required.
361 list<LangOpt> LangOpts = [];
364 // function(is_member)
365 def SubRuleForCXXMethod : AttrSubjectMatcherSubRule<"is_member", [CXXMethod]> {
366 let LangOpts = [CPlusPlus];
368 def SubjectMatcherForFunction : AttrSubjectMatcherRule<"function", [Function], [
371 // hasType is abstract, it should be used with one of the sub-rules.
372 def SubjectMatcherForType : AttrSubjectMatcherRule<"hasType", [], [
373 AttrSubjectMatcherSubRule<"functionType", [FunctionLike]>
375 // FIXME: There's a matcher ambiguity with objc methods and blocks since
376 // functionType excludes them but functionProtoType includes them.
377 // AttrSubjectMatcherSubRule<"functionProtoType", [HasFunctionProto]>
379 def SubjectMatcherForTypedef : AttrSubjectMatcherRule<"type_alias",
381 def SubjectMatcherForRecord : AttrSubjectMatcherRule<"record", [Record,
384 AttrSubjectMatcherSubRule<"is_union", [Struct], 1>
386 def SubjectMatcherForEnum : AttrSubjectMatcherRule<"enum", [Enum]>;
387 def SubjectMatcherForEnumConstant : AttrSubjectMatcherRule<"enum_constant",
389 def SubjectMatcherForVar : AttrSubjectMatcherRule<"variable", [Var], [
390 AttrSubjectMatcherSubRule<"is_thread_local", [TLSVar]>,
391 AttrSubjectMatcherSubRule<"is_global", [GlobalVar]>,
392 AttrSubjectMatcherSubRule<"is_parameter", [ParmVar]>,
393 // unless(is_parameter)
394 AttrSubjectMatcherSubRule<"is_parameter", [NonParmVar], 1>
396 def SubjectMatcherForField : AttrSubjectMatcherRule<"field", [Field]>;
397 def SubjectMatcherForNamespace : AttrSubjectMatcherRule<"namespace",
399 let LangOpts = [CPlusPlus];
401 def SubjectMatcherForObjCInterface : AttrSubjectMatcherRule<"objc_interface",
403 let LangOpts = [ObjC];
405 def SubjectMatcherForObjCProtocol : AttrSubjectMatcherRule<"objc_protocol",
407 let LangOpts = [ObjC];
409 def SubjectMatcherForObjCCategory : AttrSubjectMatcherRule<"objc_category",
411 let LangOpts = [ObjC];
413 def SubjectMatcherForObjCMethod : AttrSubjectMatcherRule<"objc_method",
415 AttrSubjectMatcherSubRule<"is_instance", [ObjCInstanceMethod]>
417 let LangOpts = [ObjC];
419 def SubjectMatcherForObjCProperty : AttrSubjectMatcherRule<"objc_property",
421 let LangOpts = [ObjC];
423 def SubjectMatcherForBlock : AttrSubjectMatcherRule<"block", [Block]> {
424 let LangOpts = [BlocksSupported];
427 // Aggregate attribute subject match rules are abstract match rules that can't
428 // be used directly in #pragma clang attribute. Instead, users have to use
429 // subject match rules that correspond to attribute subjects that derive from
430 // the specified subject.
431 class AttrSubjectMatcherAggregateRule<AttrSubject subject> {
432 AttrSubject Subject = subject;
435 def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule<Named>;
438 // The various ways in which an attribute can be spelled in source
439 list<Spelling> Spellings;
440 // The things to which an attribute can appertain
441 SubjectList Subjects;
442 // The arguments allowed on an attribute
443 list<Argument> Args = [];
444 // Accessors which should be generated for the attribute.
445 list<Accessor> Accessors = [];
446 // Set to true for attributes with arguments which require delayed parsing.
448 // Set to false to prevent an attribute from being propagated from a template
449 // to the instantiation.
451 // Set to true for attributes which must be instantiated within templates
452 bit TemplateDependent = 0;
453 // Set to true for attributes that have a corresponding AST node.
455 // Set to true for attributes which have handler in Sema.
457 // Set to true for attributes that are completely ignored.
459 // Set to true if the attribute's parsing does not match its semantic
460 // content. Eg) It parses 3 args, but semantically takes 4 args. Opts out of
461 // common attribute error checking.
462 bit HasCustomParsing = 0;
463 // Set to true if all of the attribute's arguments should be parsed in an
464 // unevaluated context.
465 bit ParseArgumentsAsUnevaluated = 0;
466 // Set to true if this attribute meaningful when applied to or inherited
467 // in a class template definition.
468 bit MeaningfulToClassTemplateDefinition = 0;
469 // Set to true if this attribute can be used with '#pragma clang attribute'.
470 // By default, when this value is false, an attribute is supported by the
471 // '#pragma clang attribute' only when:
472 // - It has documentation.
473 // - It has a subject list whose subjects can be represented using subject
475 // - It has GNU/CXX11 spelling and doesn't require delayed parsing.
476 bit ForcePragmaAttributeSupport = 0;
477 // Lists language options, one of which is required to be true for the
478 // attribute to be applicable. If empty, no language options are required.
479 list<LangOpt> LangOpts = [];
480 // Any additional text that should be included verbatim in the class.
481 // Note: Any additional data members will leak and should be constructed
482 // externally on the ASTContext.
483 code AdditionalMembers = [{}];
484 // Any documentation that should be associated with the attribute. Since an
485 // attribute may be documented under multiple categories, more than one
486 // Documentation entry may be listed.
487 list<Documentation> Documentation;
490 /// A type attribute is not processed on a declaration or a statement.
491 class TypeAttr : Attr {
492 // By default, type attributes do not get an AST node.
496 /// A stmt attribute is not processed on a declaration or a type.
497 class StmtAttr : Attr;
499 /// An inheritable attribute is inherited by later redeclarations.
500 class InheritableAttr : Attr {
501 // Set to true if this attribute can be duplicated on a subject when inheriting
502 // attributes from prior declarations.
503 bit InheritEvenIfAlreadyPresent = 0;
506 /// Some attributes, like calling conventions, can appear in either the
507 /// declaration or the type position. These attributes are morally type
508 /// attributes, but have historically been written on declarations.
509 class DeclOrTypeAttr : InheritableAttr;
511 /// A target-specific attribute. This class is meant to be used as a mixin
512 /// with InheritableAttr or Attr depending on the attribute's needs.
513 class TargetSpecificAttr<TargetSpec target> {
514 TargetSpec Target = target;
515 // Attributes are generally required to have unique spellings for their names
516 // so that the parser can determine what kind of attribute it has parsed.
517 // However, target-specific attributes are special in that the attribute only
518 // "exists" for a given target. So two target-specific attributes can share
519 // the same name when they exist in different targets. To support this, a
520 // Kind can be explicitly specified for a target-specific attribute. This
521 // corresponds to the ParsedAttr::AT_* enum that is generated and it
522 // should contain a shared value between the attributes.
524 // Target-specific attributes which use this feature should ensure that the
525 // spellings match exactly between the attributes, and if the arguments or
526 // subjects differ, should specify HasCustomParsing = 1 and implement their
527 // own parsing and semantic handling requirements as-needed.
531 /// An inheritable parameter attribute is inherited by later
532 /// redeclarations, even when it's written on a parameter.
533 class InheritableParamAttr : InheritableAttr;
535 /// An attribute which changes the ABI rules for a specific parameter.
536 class ParameterABIAttr : InheritableParamAttr {
537 let Subjects = SubjectList<[ParmVar]>;
540 /// An ignored attribute, which we parse but discard with no checking.
541 class IgnoredAttr : Attr {
545 let Documentation = [Undocumented];
549 // Attributes begin here
553 let Spellings = [GCC<"abi_tag">];
554 let Args = [VariadicStringArgument<"Tags">];
555 let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag>;
556 let MeaningfulToClassTemplateDefinition = 1;
557 let Documentation = [AbiTagsDocs];
560 def AddressSpace : TypeAttr {
561 let Spellings = [Clang<"address_space">];
562 let Args = [IntArgument<"AddressSpace">];
563 let Documentation = [Undocumented];
567 let Spellings = [GCC<"alias">];
568 let Args = [StringArgument<"Aliasee">];
569 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
570 let Documentation = [Undocumented];
573 def Aligned : InheritableAttr {
574 let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">,
575 Keyword<"_Alignas">];
576 let Args = [AlignedArgument<"Alignment", 1>];
577 let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
578 Accessor<"isC11", [Keyword<"_Alignas">]>,
579 Accessor<"isAlignas", [Keyword<"alignas">,
580 Keyword<"_Alignas">]>,
581 Accessor<"isDeclspec",[Declspec<"align">]>];
582 let Documentation = [Undocumented];
585 def AlignValue : Attr {
587 // Unfortunately, this is semantically an assertion, not a directive
588 // (something else must ensure the alignment), so aligned_value is a
589 // probably a better name. We might want to add an aligned_value spelling in
590 // the future (and a corresponding C++ attribute), but this can be done
591 // later once we decide if we also want them to have slightly-different
592 // semantics than Intel's align_value.
594 // Does not get a [[]] spelling because the attribute is not exposed as such
597 // Intel's compiler on Windows also supports:
598 // , Declspec<"align_value">
600 let Args = [ExprArgument<"Alignment">];
601 let Subjects = SubjectList<[Var, TypedefName]>;
602 let Documentation = [AlignValueDocs];
605 def AlignMac68k : InheritableAttr {
606 // This attribute has no spellings as it is only ever created implicitly.
609 let Documentation = [Undocumented];
612 def AlwaysInline : InheritableAttr {
613 let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
614 let Subjects = SubjectList<[Function]>;
615 let Documentation = [Undocumented];
618 def Artificial : InheritableAttr {
619 let Spellings = [GCC<"artificial">];
620 let Subjects = SubjectList<[InlineFunction], WarnDiag>;
621 let Documentation = [ArtificialDocs];
624 def XRayInstrument : InheritableAttr {
625 let Spellings = [Clang<"xray_always_instrument">,
626 Clang<"xray_never_instrument">];
627 let Subjects = SubjectList<[Function, ObjCMethod]>;
628 let Accessors = [Accessor<"alwaysXRayInstrument",
629 [Clang<"xray_always_instrument">]>,
630 Accessor<"neverXRayInstrument",
631 [Clang<"xray_never_instrument">]>];
632 let Documentation = [XRayDocs];
635 def XRayLogArgs : InheritableAttr {
636 let Spellings = [Clang<"xray_log_args">];
637 let Subjects = SubjectList<[Function, ObjCMethod]>;
638 // This argument is a count not an index, so it has the same encoding (base
639 // 1 including C++ implicit this parameter) at the source and LLVM levels of
640 // representation, so ParamIdxArgument is inappropriate. It is never used
641 // at the AST level of representation, so it never needs to be adjusted not
642 // to include any C++ implicit this parameter. Thus, we just store it and
643 // use it as an unsigned that never needs adjustment.
644 let Args = [UnsignedArgument<"ArgumentCount">];
645 let Documentation = [XRayDocs];
648 def TLSModel : InheritableAttr {
649 let Spellings = [GCC<"tls_model">];
650 let Subjects = SubjectList<[TLSVar], ErrorDiag>;
651 let Args = [StringArgument<"Model">];
652 let Documentation = [TLSModelDocs];
655 def AnalyzerNoReturn : InheritableAttr {
656 // TODO: should this attribute be exposed with a [[]] spelling under the clang
657 // vendor namespace, or should it use a vendor namespace specific to the
659 let Spellings = [GNU<"analyzer_noreturn">];
660 let Documentation = [Undocumented];
663 def Annotate : InheritableParamAttr {
664 let Spellings = [Clang<"annotate">];
665 let Args = [StringArgument<"Annotation">];
666 // Ensure that the annotate attribute can be used with
667 // '#pragma clang attribute' even though it has no subject list.
668 let ForcePragmaAttributeSupport = 1;
669 let Documentation = [Undocumented];
672 def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> {
673 // NOTE: If you add any additional spellings, MSP430Interrupt's,
674 // MipsInterrupt's and AnyX86Interrupt's spellings must match.
675 let Spellings = [GCC<"interrupt">];
676 let Args = [EnumArgument<"Interrupt", "InterruptType",
677 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
678 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
680 let ParseKind = "Interrupt";
681 let HasCustomParsing = 1;
682 let Documentation = [ARMInterruptDocs];
685 def AVRInterrupt : InheritableAttr, TargetSpecificAttr<TargetAVR> {
686 let Spellings = [GCC<"interrupt">];
687 let Subjects = SubjectList<[Function]>;
688 let ParseKind = "Interrupt";
689 let Documentation = [AVRInterruptDocs];
692 def AVRSignal : InheritableAttr, TargetSpecificAttr<TargetAVR> {
693 let Spellings = [GCC<"signal">];
694 let Subjects = SubjectList<[Function]>;
695 let Documentation = [AVRSignalDocs];
698 def AsmLabel : InheritableAttr {
699 let Spellings = [Keyword<"asm">, Keyword<"__asm__">];
700 let Args = [StringArgument<"Label">];
702 let Documentation = [Undocumented];
705 def Availability : InheritableAttr {
706 let Spellings = [Clang<"availability">];
707 let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
708 VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
709 BoolArgument<"unavailable">, StringArgument<"message">,
710 BoolArgument<"strict">, StringArgument<"replacement">];
711 let AdditionalMembers =
712 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
713 return llvm::StringSwitch<llvm::StringRef>(Platform)
714 .Case("android", "Android")
716 .Case("macos", "macOS")
717 .Case("tvos", "tvOS")
718 .Case("watchos", "watchOS")
719 .Case("ios_app_extension", "iOS (App Extension)")
720 .Case("macos_app_extension", "macOS (App Extension)")
721 .Case("tvos_app_extension", "tvOS (App Extension)")
722 .Case("watchos_app_extension", "watchOS (App Extension)")
723 .Default(llvm::StringRef());
725 static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) {
726 return llvm::StringSwitch<llvm::StringRef>(Platform)
728 .Case("macos", "macOS")
729 .Case("tvos", "tvOS")
730 .Case("watchos", "watchOS")
731 .Case("ios_app_extension", "iOSApplicationExtension")
732 .Case("macos_app_extension", "macOSApplicationExtension")
733 .Case("tvos_app_extension", "tvOSApplicationExtension")
734 .Case("watchos_app_extension", "watchOSApplicationExtension")
737 static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) {
738 return llvm::StringSwitch<llvm::StringRef>(Platform)
740 .Case("macOS", "macos")
741 .Case("tvOS", "tvos")
742 .Case("watchOS", "watchos")
743 .Case("iOSApplicationExtension", "ios_app_extension")
744 .Case("macOSApplicationExtension", "macos_app_extension")
745 .Case("tvOSApplicationExtension", "tvos_app_extension")
746 .Case("watchOSApplicationExtension", "watchos_app_extension")
749 let HasCustomParsing = 1;
750 let InheritEvenIfAlreadyPresent = 1;
751 let Subjects = SubjectList<[Named]>;
752 let Documentation = [AvailabilityDocs];
755 def ExternalSourceSymbol : InheritableAttr {
756 let Spellings = [Clang<"external_source_symbol">];
757 let Args = [StringArgument<"language", 1>,
758 StringArgument<"definedIn", 1>,
759 BoolArgument<"generatedDeclaration", 1>];
760 let HasCustomParsing = 1;
761 let Subjects = SubjectList<[Named]>;
762 let Documentation = [ExternalSourceSymbolDocs];
765 def Blocks : InheritableAttr {
766 let Spellings = [Clang<"blocks">];
767 let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
768 let Documentation = [Undocumented];
771 def Bounded : IgnoredAttr {
772 // Does not have a [[]] spelling because the attribute is ignored.
773 let Spellings = [GNU<"bounded">];
776 def CarriesDependency : InheritableParamAttr {
777 let Spellings = [GNU<"carries_dependency">,
778 CXX11<"","carries_dependency", 200809>];
779 let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>;
780 let Documentation = [CarriesDependencyDocs];
783 def CDecl : DeclOrTypeAttr {
784 let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">];
785 // let Subjects = [Function, ObjCMethod];
786 let Documentation = [Undocumented];
789 // cf_audited_transfer indicates that the given function has been
790 // audited and has been marked with the appropriate cf_consumed and
791 // cf_returns_retained attributes. It is generally applied by
792 // '#pragma clang arc_cf_code_audited' rather than explicitly.
793 def CFAuditedTransfer : InheritableAttr {
794 let Spellings = [Clang<"cf_audited_transfer">];
795 let Subjects = SubjectList<[Function], ErrorDiag>;
796 let Documentation = [Undocumented];
799 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
800 // It indicates that the function has unknown or unautomatable
801 // transfer semantics.
802 def CFUnknownTransfer : InheritableAttr {
803 let Spellings = [Clang<"cf_unknown_transfer">];
804 let Subjects = SubjectList<[Function], ErrorDiag>;
805 let Documentation = [Undocumented];
808 def CFReturnsRetained : InheritableAttr {
809 let Spellings = [Clang<"cf_returns_retained">];
810 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
811 let Documentation = [Undocumented];
814 def CFReturnsNotRetained : InheritableAttr {
815 let Spellings = [Clang<"cf_returns_not_retained">];
816 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
817 let Documentation = [Undocumented];
820 def CFConsumed : InheritableParamAttr {
821 let Spellings = [Clang<"cf_consumed">];
822 let Subjects = SubjectList<[ParmVar]>;
823 let Documentation = [Undocumented];
826 def Cleanup : InheritableAttr {
827 let Spellings = [GCC<"cleanup">];
828 let Args = [FunctionArgument<"FunctionDecl">];
829 let Subjects = SubjectList<[LocalVar]>;
830 let Documentation = [Undocumented];
833 def Cold : InheritableAttr {
834 let Spellings = [GCC<"cold">];
835 let Subjects = SubjectList<[Function]>;
836 let Documentation = [Undocumented];
839 def Common : InheritableAttr {
840 let Spellings = [GCC<"common">];
841 let Subjects = SubjectList<[Var]>;
842 let Documentation = [Undocumented];
845 def Const : InheritableAttr {
846 let Spellings = [GCC<"const">, GCC<"__const">];
847 let Documentation = [Undocumented];
850 def Constructor : InheritableAttr {
851 let Spellings = [GCC<"constructor">];
852 let Args = [DefaultIntArgument<"Priority", 65535>];
853 let Subjects = SubjectList<[Function]>;
854 let Documentation = [Undocumented];
857 def CPUSpecific : InheritableAttr {
858 let Spellings = [Clang<"cpu_specific">];
859 let Args = [VariadicIdentifierArgument<"Cpus">];
860 let Subjects = SubjectList<[Function]>;
861 let Documentation = [CPUSpecificCPUDispatchDocs];
862 let AdditionalMembers = [{
863 unsigned ActiveArgIndex = 0;
865 IdentifierInfo *getCurCPUName() const {
866 return *(cpus_begin() + ActiveArgIndex);
871 def CPUDispatch : InheritableAttr {
872 let Spellings = [Clang<"cpu_dispatch">];
873 let Args = [VariadicIdentifierArgument<"Cpus">];
874 let Subjects = SubjectList<[Function]>;
875 let Documentation = [CPUSpecificCPUDispatchDocs];
878 // CUDA attributes are spelled __attribute__((attr)) or __declspec(__attr__),
879 // and they do not receive a [[]] spelling.
880 def CUDAConstant : InheritableAttr {
881 let Spellings = [GNU<"constant">, Declspec<"__constant__">];
882 let Subjects = SubjectList<[Var]>;
883 let LangOpts = [CUDA];
884 let Documentation = [Undocumented];
887 def CUDACudartBuiltin : IgnoredAttr {
888 let Spellings = [GNU<"cudart_builtin">, Declspec<"__cudart_builtin__">];
889 let LangOpts = [CUDA];
892 def CUDADevice : InheritableAttr {
893 let Spellings = [GNU<"device">, Declspec<"__device__">];
894 let Subjects = SubjectList<[Function, Var]>;
895 let LangOpts = [CUDA];
896 let Documentation = [Undocumented];
899 def CUDADeviceBuiltin : IgnoredAttr {
900 let Spellings = [GNU<"device_builtin">, Declspec<"__device_builtin__">];
901 let LangOpts = [CUDA];
904 def CUDADeviceBuiltinSurfaceType : IgnoredAttr {
905 let Spellings = [GNU<"device_builtin_surface_type">,
906 Declspec<"__device_builtin_surface_type__">];
907 let LangOpts = [CUDA];
910 def CUDADeviceBuiltinTextureType : IgnoredAttr {
911 let Spellings = [GNU<"device_builtin_texture_type">,
912 Declspec<"__device_builtin_texture_type__">];
913 let LangOpts = [CUDA];
916 def CUDAGlobal : InheritableAttr {
917 let Spellings = [GNU<"global">, Declspec<"__global__">];
918 let Subjects = SubjectList<[Function]>;
919 let LangOpts = [CUDA];
920 let Documentation = [Undocumented];
923 def CUDAHost : InheritableAttr {
924 let Spellings = [GNU<"host">, Declspec<"__host__">];
925 let Subjects = SubjectList<[Function]>;
926 let LangOpts = [CUDA];
927 let Documentation = [Undocumented];
930 def CUDAInvalidTarget : InheritableAttr {
932 let Subjects = SubjectList<[Function]>;
933 let LangOpts = [CUDA];
934 let Documentation = [Undocumented];
937 def CUDALaunchBounds : InheritableAttr {
938 let Spellings = [GNU<"launch_bounds">, Declspec<"__launch_bounds__">];
939 let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>];
940 let LangOpts = [CUDA];
941 let Subjects = SubjectList<[ObjCMethod, FunctionLike]>;
942 // An AST node is created for this attribute, but is not used by other parts
943 // of the compiler. However, this node needs to exist in the AST because
944 // non-LLVM backends may be relying on the attribute's presence.
945 let Documentation = [Undocumented];
948 def CUDAShared : InheritableAttr {
949 let Spellings = [GNU<"shared">, Declspec<"__shared__">];
950 let Subjects = SubjectList<[Var]>;
951 let LangOpts = [CUDA];
952 let Documentation = [Undocumented];
955 def C11NoReturn : InheritableAttr {
956 let Spellings = [Keyword<"_Noreturn">];
957 let Subjects = SubjectList<[Function], ErrorDiag>;
959 let Documentation = [C11NoReturnDocs];
962 def CXX11NoReturn : InheritableAttr {
963 let Spellings = [CXX11<"", "noreturn", 200809>];
964 let Subjects = SubjectList<[Function], ErrorDiag>;
965 let Documentation = [CXX11NoReturnDocs];
968 // Similar to CUDA, OpenCL attributes do not receive a [[]] spelling because
969 // the specification does not expose them with one currently.
970 def OpenCLKernel : InheritableAttr {
971 let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
972 let Subjects = SubjectList<[Function], ErrorDiag>;
973 let Documentation = [Undocumented];
976 def OpenCLUnrollHint : InheritableAttr {
977 let Spellings = [GNU<"opencl_unroll_hint">];
978 let Args = [UnsignedArgument<"UnrollHint">];
979 let Documentation = [OpenCLUnrollHintDocs];
982 def OpenCLIntelReqdSubGroupSize: InheritableAttr {
983 let Spellings = [GNU<"intel_reqd_sub_group_size">];
984 let Args = [UnsignedArgument<"SubGroupSize">];
985 let Subjects = SubjectList<[Function], ErrorDiag>;
986 let Documentation = [OpenCLIntelReqdSubGroupSizeDocs];
989 // This attribute is both a type attribute, and a declaration attribute (for
990 // parameter variables).
991 def OpenCLAccess : Attr {
992 let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
993 Keyword<"__write_only">, Keyword<"write_only">,
994 Keyword<"__read_write">, Keyword<"read_write">];
995 let Subjects = SubjectList<[ParmVar, TypedefName], ErrorDiag>;
996 let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
997 Keyword<"read_only">]>,
998 Accessor<"isReadWrite", [Keyword<"__read_write">,
999 Keyword<"read_write">]>,
1000 Accessor<"isWriteOnly", [Keyword<"__write_only">,
1001 Keyword<"write_only">]>];
1002 let Documentation = [OpenCLAccessDocs];
1005 def OpenCLPrivateAddressSpace : TypeAttr {
1006 let Spellings = [Keyword<"__private">, Keyword<"private">];
1007 let Documentation = [OpenCLAddressSpacePrivateDocs];
1010 def OpenCLGlobalAddressSpace : TypeAttr {
1011 let Spellings = [Keyword<"__global">, Keyword<"global">];
1012 let Documentation = [OpenCLAddressSpaceGlobalDocs];
1015 def OpenCLLocalAddressSpace : TypeAttr {
1016 let Spellings = [Keyword<"__local">, Keyword<"local">];
1017 let Documentation = [OpenCLAddressSpaceLocalDocs];
1020 def OpenCLConstantAddressSpace : TypeAttr {
1021 let Spellings = [Keyword<"__constant">, Keyword<"constant">];
1022 let Documentation = [OpenCLAddressSpaceConstantDocs];
1025 def OpenCLGenericAddressSpace : TypeAttr {
1026 let Spellings = [Keyword<"__generic">, Keyword<"generic">];
1027 let Documentation = [OpenCLAddressSpaceGenericDocs];
1030 def OpenCLNoSVM : Attr {
1031 let Spellings = [GNU<"nosvm">];
1032 let Subjects = SubjectList<[Var]>;
1033 let Documentation = [OpenCLNoSVMDocs];
1034 let LangOpts = [OpenCL];
1038 def RenderScriptKernel : Attr {
1039 let Spellings = [GNU<"kernel">];
1040 let Subjects = SubjectList<[Function]>;
1041 let Documentation = [RenderScriptKernelAttributeDocs];
1042 let LangOpts = [RenderScript];
1045 def Deprecated : InheritableAttr {
1046 let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
1047 CXX11<"","deprecated", 201309>, C2x<"", "deprecated">];
1048 let Args = [StringArgument<"Message", 1>,
1049 // An optional string argument that enables us to provide a
1051 StringArgument<"Replacement", 1>];
1052 let MeaningfulToClassTemplateDefinition = 1;
1053 let Documentation = [DeprecatedDocs];
1056 def Destructor : InheritableAttr {
1057 let Spellings = [GCC<"destructor">];
1058 let Args = [DefaultIntArgument<"Priority", 65535>];
1059 let Subjects = SubjectList<[Function]>;
1060 let Documentation = [Undocumented];
1063 def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
1064 let Spellings = [Declspec<"empty_bases">];
1065 let Subjects = SubjectList<[CXXRecord]>;
1066 let Documentation = [EmptyBasesDocs];
1069 def AllocSize : InheritableAttr {
1070 let Spellings = [GCC<"alloc_size">];
1071 let Subjects = SubjectList<[Function]>;
1072 let Args = [ParamIdxArgument<"ElemSizeParam">,
1073 ParamIdxArgument<"NumElemsParam", /*opt*/ 1>];
1074 let TemplateDependent = 1;
1075 let Documentation = [AllocSizeDocs];
1078 def EnableIf : InheritableAttr {
1079 // Does not have a [[]] spelling because this attribute requires the ability
1080 // to parse function arguments but the attribute is not written in the type
1082 let Spellings = [GNU<"enable_if">];
1083 let Subjects = SubjectList<[Function]>;
1084 let Args = [ExprArgument<"Cond">, StringArgument<"Message">];
1085 let TemplateDependent = 1;
1086 let Documentation = [EnableIfDocs];
1089 def ExtVectorType : Attr {
1090 // This is an OpenCL-related attribute and does not receive a [[]] spelling.
1091 let Spellings = [GNU<"ext_vector_type">];
1092 let Subjects = SubjectList<[TypedefName], ErrorDiag>;
1093 let Args = [ExprArgument<"NumElements">];
1095 let Documentation = [Undocumented];
1098 def FallThrough : StmtAttr {
1099 let Spellings = [CXX11<"", "fallthrough", 201603>, C2x<"", "fallthrough">,
1100 CXX11<"clang", "fallthrough">];
1101 // let Subjects = [NullStmt];
1102 let Documentation = [FallthroughDocs];
1105 def FastCall : DeclOrTypeAttr {
1106 let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
1107 Keyword<"_fastcall">];
1108 // let Subjects = [Function, ObjCMethod];
1109 let Documentation = [FastCallDocs];
1112 def RegCall : DeclOrTypeAttr {
1113 let Spellings = [GCC<"regcall">, Keyword<"__regcall">];
1114 let Documentation = [RegCallDocs];
1117 def Final : InheritableAttr {
1118 let Spellings = [Keyword<"final">, Keyword<"sealed">];
1119 let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
1120 let SemaHandler = 0;
1121 let Documentation = [Undocumented];
1124 def MinSize : InheritableAttr {
1125 let Spellings = [Clang<"minsize">];
1126 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
1127 let Documentation = [Undocumented];
1130 def FlagEnum : InheritableAttr {
1131 let Spellings = [Clang<"flag_enum">];
1132 let Subjects = SubjectList<[Enum]>;
1133 let Documentation = [FlagEnumDocs];
1136 def EnumExtensibility : InheritableAttr {
1137 let Spellings = [Clang<"enum_extensibility">];
1138 let Subjects = SubjectList<[Enum]>;
1139 let Args = [EnumArgument<"Extensibility", "Kind",
1140 ["closed", "open"], ["Closed", "Open"]>];
1141 let Documentation = [EnumExtensibilityDocs];
1144 def Flatten : InheritableAttr {
1145 let Spellings = [GCC<"flatten">];
1146 let Subjects = SubjectList<[Function], ErrorDiag>;
1147 let Documentation = [FlattenDocs];
1150 def Format : InheritableAttr {
1151 let Spellings = [GCC<"format">];
1152 let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
1153 IntArgument<"FirstArg">];
1154 let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto]>;
1155 let Documentation = [FormatDocs];
1158 def FormatArg : InheritableAttr {
1159 let Spellings = [GCC<"format_arg">];
1160 let Args = [ParamIdxArgument<"FormatIdx">];
1161 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto]>;
1162 let Documentation = [Undocumented];
1165 def GNUInline : InheritableAttr {
1166 let Spellings = [GCC<"gnu_inline">];
1167 let Subjects = SubjectList<[Function]>;
1168 let Documentation = [Undocumented];
1171 def Hot : InheritableAttr {
1172 let Spellings = [GCC<"hot">];
1173 let Subjects = SubjectList<[Function]>;
1174 // An AST node is created for this attribute, but not actually used beyond
1175 // semantic checking for mutual exclusion with the Cold attribute.
1176 let Documentation = [Undocumented];
1179 def IBAction : InheritableAttr {
1180 let Spellings = [Clang<"ibaction">];
1181 let Subjects = SubjectList<[ObjCInstanceMethod]>;
1182 // An AST node is created for this attribute, but is not used by other parts
1183 // of the compiler. However, this node needs to exist in the AST because
1184 // external tools rely on it.
1185 let Documentation = [Undocumented];
1188 def IBOutlet : InheritableAttr {
1189 let Spellings = [Clang<"iboutlet">];
1190 // let Subjects = [ObjCIvar, ObjCProperty];
1191 let Documentation = [Undocumented];
1194 def IBOutletCollection : InheritableAttr {
1195 let Spellings = [Clang<"iboutletcollection">];
1196 let Args = [TypeArgument<"Interface", 1>];
1197 // let Subjects = [ObjCIvar, ObjCProperty];
1198 let Documentation = [Undocumented];
1201 def IFunc : Attr, TargetSpecificAttr<TargetELF> {
1202 let Spellings = [GCC<"ifunc">];
1203 let Args = [StringArgument<"Resolver">];
1204 let Subjects = SubjectList<[Function]>;
1205 let Documentation = [IFuncDocs];
1208 def Restrict : InheritableAttr {
1209 let Spellings = [Declspec<"restrict">, GCC<"malloc">];
1210 let Subjects = SubjectList<[Function]>;
1211 let Documentation = [Undocumented];
1214 def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
1215 let Spellings = [Declspec<"layout_version">];
1216 let Args = [UnsignedArgument<"Version">];
1217 let Subjects = SubjectList<[CXXRecord]>;
1218 let Documentation = [LayoutVersionDocs];
1221 def LifetimeBound : InheritableAttr {
1222 let Spellings = [Clang<"lifetimebound", 0>];
1223 let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;
1224 let Documentation = [LifetimeBoundDocs];
1225 let LangOpts = [CPlusPlus];
1228 def TrivialABI : InheritableAttr {
1229 // This attribute does not have a C [[]] spelling because it requires the
1230 // CPlusPlus language option.
1231 let Spellings = [Clang<"trivial_abi", 0>];
1232 let Subjects = SubjectList<[CXXRecord]>;
1233 let Documentation = [TrivialABIDocs];
1234 let LangOpts = [CPlusPlus];
1237 def MaxFieldAlignment : InheritableAttr {
1238 // This attribute has no spellings as it is only ever created implicitly.
1240 let Args = [UnsignedArgument<"Alignment">];
1241 let SemaHandler = 0;
1242 let Documentation = [Undocumented];
1245 def MayAlias : InheritableAttr {
1246 // FIXME: this is a type attribute in GCC, but a declaration attribute here.
1247 let Spellings = [GCC<"may_alias">];
1248 let Documentation = [Undocumented];
1251 def MSABI : DeclOrTypeAttr {
1252 let Spellings = [GCC<"ms_abi">];
1253 // let Subjects = [Function, ObjCMethod];
1254 let Documentation = [MSABIDocs];
1257 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
1258 // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's
1259 // and AnyX86Interrupt's spellings must match.
1260 let Spellings = [GCC<"interrupt">];
1261 let Args = [UnsignedArgument<"Number">];
1262 let ParseKind = "Interrupt";
1263 let HasCustomParsing = 1;
1264 let Documentation = [Undocumented];
1267 def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1268 let Spellings = [GCC<"mips16">];
1269 let Subjects = SubjectList<[Function], ErrorDiag>;
1270 let Documentation = [Undocumented];
1273 def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1274 // NOTE: If you add any additional spellings, ARMInterrupt's,
1275 // MSP430Interrupt's and AnyX86Interrupt's spellings must match.
1276 let Spellings = [GCC<"interrupt">];
1277 let Subjects = SubjectList<[Function]>;
1278 let Args = [EnumArgument<"Interrupt", "InterruptType",
1279 ["vector=sw0", "vector=sw1", "vector=hw0",
1280 "vector=hw1", "vector=hw2", "vector=hw3",
1281 "vector=hw4", "vector=hw5", "eic", ""],
1282 ["sw0", "sw1", "hw0", "hw1", "hw2", "hw3",
1283 "hw4", "hw5", "eic", "eic"]
1285 let ParseKind = "Interrupt";
1286 let Documentation = [MipsInterruptDocs];
1289 def MicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1290 let Spellings = [GCC<"micromips">];
1291 let Subjects = SubjectList<[Function], ErrorDiag>;
1292 let Documentation = [MicroMipsDocs];
1295 def MipsLongCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
1296 let Spellings = [GCC<"long_call">, GCC<"far">];
1297 let Subjects = SubjectList<[Function]>;
1298 let Documentation = [MipsLongCallStyleDocs];
1301 def MipsShortCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
1302 let Spellings = [GCC<"short_call">, GCC<"near">];
1303 let Subjects = SubjectList<[Function]>;
1304 let Documentation = [MipsShortCallStyleDocs];
1308 let Spellings = [GCC<"mode">];
1309 let Subjects = SubjectList<[Var, Enum, TypedefName, Field], ErrorDiag>;
1310 let Args = [IdentifierArgument<"Mode">];
1311 let Documentation = [Undocumented];
1314 def Naked : InheritableAttr {
1315 let Spellings = [GCC<"naked">, Declspec<"naked">];
1316 let Subjects = SubjectList<[Function]>;
1317 let Documentation = [Undocumented];
1320 def NeonPolyVectorType : TypeAttr {
1321 let Spellings = [Clang<"neon_polyvector_type">];
1322 let Args = [IntArgument<"NumElements">];
1323 let Documentation = [Undocumented];
1326 def NeonVectorType : TypeAttr {
1327 let Spellings = [Clang<"neon_vector_type">];
1328 let Args = [IntArgument<"NumElements">];
1329 let Documentation = [Undocumented];
1332 def ReturnsTwice : InheritableAttr {
1333 let Spellings = [GCC<"returns_twice">];
1334 let Subjects = SubjectList<[Function]>;
1335 let Documentation = [Undocumented];
1338 def DisableTailCalls : InheritableAttr {
1339 let Spellings = [Clang<"disable_tail_calls">];
1340 let Subjects = SubjectList<[Function, ObjCMethod]>;
1341 let Documentation = [DisableTailCallsDocs];
1344 def NoAlias : InheritableAttr {
1345 let Spellings = [Declspec<"noalias">];
1346 let Subjects = SubjectList<[Function]>;
1347 let Documentation = [NoAliasDocs];
1350 def NoCommon : InheritableAttr {
1351 let Spellings = [GCC<"nocommon">];
1352 let Subjects = SubjectList<[Var]>;
1353 let Documentation = [Undocumented];
1356 def NoDebug : InheritableAttr {
1357 let Spellings = [GCC<"nodebug">];
1358 let Subjects = SubjectList<[FunctionLike, ObjCMethod, NonParmVar]>;
1359 let Documentation = [NoDebugDocs];
1362 def NoDuplicate : InheritableAttr {
1363 let Spellings = [Clang<"noduplicate">];
1364 let Subjects = SubjectList<[Function]>;
1365 let Documentation = [NoDuplicateDocs];
1368 def Convergent : InheritableAttr {
1369 let Spellings = [Clang<"convergent">];
1370 let Subjects = SubjectList<[Function]>;
1371 let Documentation = [ConvergentDocs];
1374 def NoInline : InheritableAttr {
1375 let Spellings = [GCC<"noinline">, Declspec<"noinline">];
1376 let Subjects = SubjectList<[Function]>;
1377 let Documentation = [Undocumented];
1380 def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1381 let Spellings = [GCC<"nomips16">];
1382 let Subjects = SubjectList<[Function], ErrorDiag>;
1383 let Documentation = [Undocumented];
1386 def NoMicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1387 let Spellings = [GCC<"nomicromips">];
1388 let Subjects = SubjectList<[Function], ErrorDiag>;
1389 let Documentation = [MicroMipsDocs];
1392 def RISCVInterrupt : InheritableAttr, TargetSpecificAttr<TargetRISCV> {
1393 let Spellings = [GCC<"interrupt">];
1394 let Subjects = SubjectList<[Function]>;
1395 let Args = [EnumArgument<"Interrupt", "InterruptType",
1396 ["user", "supervisor", "machine"],
1397 ["user", "supervisor", "machine"],
1399 let ParseKind = "Interrupt";
1400 let Documentation = [RISCVInterruptDocs];
1403 // This is not a TargetSpecificAttr so that is silently accepted and
1404 // ignored on other targets as encouraged by the OpenCL spec.
1406 // See OpenCL 1.2 6.11.5: "It is our intention that a particular
1407 // implementation of OpenCL be free to ignore all attributes and the
1408 // resulting executable binary will produce the same result."
1410 // However, only AMD GPU targets will emit the corresponding IR
1413 // FIXME: This provides a sub-optimal error message if you attempt to
1414 // use this in CUDA, since CUDA does not use the same terminology.
1416 // FIXME: SubjectList should be for OpenCLKernelFunction, but is not to
1417 // workaround needing to see kernel attribute before others to know if
1418 // this should be rejected on non-kernels.
1420 def AMDGPUFlatWorkGroupSize : InheritableAttr {
1421 let Spellings = [Clang<"amdgpu_flat_work_group_size", 0>];
1422 let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max">];
1423 let Documentation = [AMDGPUFlatWorkGroupSizeDocs];
1424 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1427 def AMDGPUWavesPerEU : InheritableAttr {
1428 let Spellings = [Clang<"amdgpu_waves_per_eu", 0>];
1429 let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max", 1>];
1430 let Documentation = [AMDGPUWavesPerEUDocs];
1431 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1434 def AMDGPUNumSGPR : InheritableAttr {
1435 let Spellings = [Clang<"amdgpu_num_sgpr", 0>];
1436 let Args = [UnsignedArgument<"NumSGPR">];
1437 let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1438 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1441 def AMDGPUNumVGPR : InheritableAttr {
1442 let Spellings = [Clang<"amdgpu_num_vgpr", 0>];
1443 let Args = [UnsignedArgument<"NumVGPR">];
1444 let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1445 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1448 def NoSplitStack : InheritableAttr {
1449 let Spellings = [GCC<"no_split_stack">];
1450 let Subjects = SubjectList<[Function], ErrorDiag>;
1451 let Documentation = [NoSplitStackDocs];
1454 def NonNull : InheritableParamAttr {
1455 let Spellings = [GCC<"nonnull">];
1456 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
1457 "functions, methods, and parameters">;
1458 let Args = [VariadicParamIdxArgument<"Args">];
1459 let AdditionalMembers = [{
1460 bool isNonNull(unsigned IdxAST) const {
1463 return args_end() != std::find_if(
1464 args_begin(), args_end(),
1465 [=](const ParamIdx &Idx) { return Idx.getASTIndex() == IdxAST; });
1468 // FIXME: We should merge duplicates into a single nonnull attribute.
1469 let InheritEvenIfAlreadyPresent = 1;
1470 let Documentation = [NonNullDocs];
1473 def ReturnsNonNull : InheritableAttr {
1474 let Spellings = [GCC<"returns_nonnull">];
1475 let Subjects = SubjectList<[ObjCMethod, Function]>;
1476 let Documentation = [ReturnsNonNullDocs];
1479 // pass_object_size(N) indicates that the parameter should have
1480 // __builtin_object_size with Type=N evaluated on the parameter at the callsite.
1481 def PassObjectSize : InheritableParamAttr {
1482 let Spellings = [Clang<"pass_object_size">];
1483 let Args = [IntArgument<"Type">];
1484 let Subjects = SubjectList<[ParmVar]>;
1485 let Documentation = [PassObjectSizeDocs];
1488 // Nullability type attributes.
1489 def TypeNonNull : TypeAttr {
1490 let Spellings = [Keyword<"_Nonnull">];
1491 let Documentation = [TypeNonNullDocs];
1494 def TypeNullable : TypeAttr {
1495 let Spellings = [Keyword<"_Nullable">];
1496 let Documentation = [TypeNullableDocs];
1499 def TypeNullUnspecified : TypeAttr {
1500 let Spellings = [Keyword<"_Null_unspecified">];
1501 let Documentation = [TypeNullUnspecifiedDocs];
1504 def ObjCKindOf : TypeAttr {
1505 let Spellings = [Keyword<"__kindof">];
1506 let Documentation = [Undocumented];
1509 def NoEscape : Attr {
1510 let Spellings = [Clang<"noescape">];
1511 let Subjects = SubjectList<[ParmVar]>;
1512 let Documentation = [NoEscapeDocs];
1515 def AssumeAligned : InheritableAttr {
1516 let Spellings = [GCC<"assume_aligned">];
1517 let Subjects = SubjectList<[ObjCMethod, Function]>;
1518 let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>];
1519 let Documentation = [AssumeAlignedDocs];
1522 def AllocAlign : InheritableAttr {
1523 let Spellings = [GCC<"alloc_align">];
1524 let Subjects = SubjectList<[HasFunctionProto]>;
1525 let Args = [ParamIdxArgument<"ParamIndex">];
1526 let Documentation = [AllocAlignDocs];
1529 def NoReturn : InheritableAttr {
1530 let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
1531 // FIXME: Does GCC allow this on the function instead?
1532 let Documentation = [Undocumented];
1535 def NoInstrumentFunction : InheritableAttr {
1536 let Spellings = [GCC<"no_instrument_function">];
1537 let Subjects = SubjectList<[Function]>;
1538 let Documentation = [Undocumented];
1541 def NotTailCalled : InheritableAttr {
1542 let Spellings = [Clang<"not_tail_called">];
1543 let Subjects = SubjectList<[Function]>;
1544 let Documentation = [NotTailCalledDocs];
1547 def NoStackProtector : InheritableAttr {
1548 let Spellings = [Clang<"no_stack_protector">];
1549 let Subjects = SubjectList<[Function]>;
1550 let Documentation = [NoStackProtectorDocs];
1553 def NoThrow : InheritableAttr {
1554 let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
1555 let Subjects = SubjectList<[Function]>;
1556 let Documentation = [NoThrowDocs];
1559 def NvWeak : IgnoredAttr {
1560 // No Declspec spelling of this attribute; the CUDA headers use
1561 // __attribute__((nv_weak)) unconditionally. Does not receive an [[]]
1562 // spelling because it is a CUDA attribute.
1563 let Spellings = [GNU<"nv_weak">];
1564 let LangOpts = [CUDA];
1567 def ObjCBridge : InheritableAttr {
1568 let Spellings = [Clang<"objc_bridge">];
1569 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag>;
1570 let Args = [IdentifierArgument<"BridgedType">];
1571 let Documentation = [Undocumented];
1574 def ObjCBridgeMutable : InheritableAttr {
1575 let Spellings = [Clang<"objc_bridge_mutable">];
1576 let Subjects = SubjectList<[Record], ErrorDiag>;
1577 let Args = [IdentifierArgument<"BridgedType">];
1578 let Documentation = [Undocumented];
1581 def ObjCBridgeRelated : InheritableAttr {
1582 let Spellings = [Clang<"objc_bridge_related">];
1583 let Subjects = SubjectList<[Record], ErrorDiag>;
1584 let Args = [IdentifierArgument<"RelatedClass">,
1585 IdentifierArgument<"ClassMethod">,
1586 IdentifierArgument<"InstanceMethod">];
1587 let HasCustomParsing = 1;
1588 let Documentation = [Undocumented];
1591 def NSReturnsRetained : InheritableAttr {
1592 let Spellings = [Clang<"ns_returns_retained">];
1593 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1594 let Documentation = [Undocumented];
1597 def NSReturnsNotRetained : InheritableAttr {
1598 let Spellings = [Clang<"ns_returns_not_retained">];
1599 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1600 let Documentation = [Undocumented];
1603 def NSReturnsAutoreleased : InheritableAttr {
1604 let Spellings = [Clang<"ns_returns_autoreleased">];
1605 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1606 let Documentation = [Undocumented];
1609 def NSConsumesSelf : InheritableAttr {
1610 let Spellings = [Clang<"ns_consumes_self">];
1611 let Subjects = SubjectList<[ObjCMethod]>;
1612 let Documentation = [Undocumented];
1615 def NSConsumed : InheritableParamAttr {
1616 let Spellings = [Clang<"ns_consumed">];
1617 let Subjects = SubjectList<[ParmVar]>;
1618 let Documentation = [Undocumented];
1621 def ObjCException : InheritableAttr {
1622 let Spellings = [Clang<"objc_exception">];
1623 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1624 let Documentation = [Undocumented];
1627 def ObjCMethodFamily : InheritableAttr {
1628 let Spellings = [Clang<"objc_method_family">];
1629 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1630 let Args = [EnumArgument<"Family", "FamilyKind",
1631 ["none", "alloc", "copy", "init", "mutableCopy", "new"],
1632 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
1633 "OMF_mutableCopy", "OMF_new"]>];
1634 let Documentation = [ObjCMethodFamilyDocs];
1637 def ObjCNSObject : InheritableAttr {
1638 let Spellings = [Clang<"NSObject">];
1639 let Documentation = [Undocumented];
1642 def ObjCIndependentClass : InheritableAttr {
1643 let Spellings = [Clang<"objc_independent_class">];
1644 let Documentation = [Undocumented];
1647 def ObjCPreciseLifetime : InheritableAttr {
1648 let Spellings = [Clang<"objc_precise_lifetime">];
1649 let Subjects = SubjectList<[Var], ErrorDiag>;
1650 let Documentation = [Undocumented];
1653 def ObjCReturnsInnerPointer : InheritableAttr {
1654 let Spellings = [Clang<"objc_returns_inner_pointer">];
1655 let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
1656 let Documentation = [Undocumented];
1659 def ObjCRequiresSuper : InheritableAttr {
1660 let Spellings = [Clang<"objc_requires_super">];
1661 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1662 let Documentation = [ObjCRequiresSuperDocs];
1665 def ObjCRootClass : InheritableAttr {
1666 let Spellings = [Clang<"objc_root_class">];
1667 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1668 let Documentation = [Undocumented];
1671 def ObjCSubclassingRestricted : InheritableAttr {
1672 let Spellings = [Clang<"objc_subclassing_restricted">];
1673 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1674 let Documentation = [ObjCSubclassingRestrictedDocs];
1677 def ObjCExplicitProtocolImpl : InheritableAttr {
1678 let Spellings = [Clang<"objc_protocol_requires_explicit_implementation">];
1679 let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
1680 let Documentation = [Undocumented];
1683 def ObjCDesignatedInitializer : Attr {
1684 let Spellings = [Clang<"objc_designated_initializer">];
1685 let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag>;
1686 let Documentation = [Undocumented];
1689 def ObjCRuntimeName : Attr {
1690 let Spellings = [Clang<"objc_runtime_name">];
1691 let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
1692 let Args = [StringArgument<"MetadataName">];
1693 let Documentation = [ObjCRuntimeNameDocs];
1696 def ObjCRuntimeVisible : Attr {
1697 let Spellings = [Clang<"objc_runtime_visible">];
1698 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1699 let Documentation = [ObjCRuntimeVisibleDocs];
1702 def ObjCBoxable : Attr {
1703 let Spellings = [Clang<"objc_boxable">];
1704 let Subjects = SubjectList<[Record], ErrorDiag>;
1705 let Documentation = [ObjCBoxableDocs];
1708 def OptimizeNone : InheritableAttr {
1709 let Spellings = [Clang<"optnone">];
1710 let Subjects = SubjectList<[Function, ObjCMethod]>;
1711 let Documentation = [OptnoneDocs];
1714 def Overloadable : Attr {
1715 let Spellings = [Clang<"overloadable">];
1716 let Subjects = SubjectList<[Function], ErrorDiag>;
1717 let Documentation = [OverloadableDocs];
1720 def Override : InheritableAttr {
1721 let Spellings = [Keyword<"override">];
1722 let SemaHandler = 0;
1723 let Documentation = [Undocumented];
1726 def Ownership : InheritableAttr {
1727 let Spellings = [Clang<"ownership_holds">, Clang<"ownership_returns">,
1728 Clang<"ownership_takes">];
1729 let Accessors = [Accessor<"isHolds", [Clang<"ownership_holds">]>,
1730 Accessor<"isReturns", [Clang<"ownership_returns">]>,
1731 Accessor<"isTakes", [Clang<"ownership_takes">]>];
1732 let AdditionalMembers = [{
1733 enum OwnershipKind { Holds, Returns, Takes };
1734 OwnershipKind getOwnKind() const {
1735 return isHolds() ? Holds :
1740 let Args = [IdentifierArgument<"Module">,
1741 VariadicParamIdxArgument<"Args">];
1742 let Subjects = SubjectList<[HasFunctionProto]>;
1743 let Documentation = [Undocumented];
1746 def Packed : InheritableAttr {
1747 let Spellings = [GCC<"packed">];
1748 // let Subjects = [Tag, Field];
1749 let Documentation = [Undocumented];
1752 def IntelOclBicc : DeclOrTypeAttr {
1753 let Spellings = [Clang<"intel_ocl_bicc", 0>];
1754 // let Subjects = [Function, ObjCMethod];
1755 let Documentation = [Undocumented];
1758 def Pcs : DeclOrTypeAttr {
1759 let Spellings = [GCC<"pcs">];
1760 let Args = [EnumArgument<"PCS", "PCSType",
1761 ["aapcs", "aapcs-vfp"],
1762 ["AAPCS", "AAPCS_VFP"]>];
1763 // let Subjects = [Function, ObjCMethod];
1764 let Documentation = [PcsDocs];
1767 def Pure : InheritableAttr {
1768 let Spellings = [GCC<"pure">];
1769 let Documentation = [Undocumented];
1772 def Regparm : TypeAttr {
1773 let Spellings = [GCC<"regparm">];
1774 let Args = [UnsignedArgument<"NumParams">];
1775 let Documentation = [RegparmDocs];
1778 def ReqdWorkGroupSize : InheritableAttr {
1779 // Does not have a [[]] spelling because it is an OpenCL-related attribute.
1780 let Spellings = [GNU<"reqd_work_group_size">];
1781 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
1782 UnsignedArgument<"ZDim">];
1783 let Subjects = SubjectList<[Function], ErrorDiag>;
1784 let Documentation = [Undocumented];
1787 def RequireConstantInit : InheritableAttr {
1788 // This attribute does not have a C [[]] spelling because it requires the
1789 // CPlusPlus language option.
1790 let Spellings = [Clang<"require_constant_initialization", 0>];
1791 let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
1792 let Documentation = [RequireConstantInitDocs];
1793 let LangOpts = [CPlusPlus];
1796 def WorkGroupSizeHint : InheritableAttr {
1797 // Does not have a [[]] spelling because it is an OpenCL-related attribute.
1798 let Spellings = [GNU<"work_group_size_hint">];
1799 let Args = [UnsignedArgument<"XDim">,
1800 UnsignedArgument<"YDim">,
1801 UnsignedArgument<"ZDim">];
1802 let Subjects = SubjectList<[Function], ErrorDiag>;
1803 let Documentation = [Undocumented];
1806 def InitPriority : InheritableAttr {
1807 let Spellings = [GCC<"init_priority">];
1808 let Args = [UnsignedArgument<"Priority">];
1809 let Subjects = SubjectList<[Var], ErrorDiag>;
1810 let Documentation = [Undocumented];
1813 def Section : InheritableAttr {
1814 let Spellings = [GCC<"section">, Declspec<"allocate">];
1815 let Args = [StringArgument<"Name">];
1817 SubjectList<[ Function, GlobalVar, ObjCMethod, ObjCProperty ], ErrorDiag>;
1818 let Documentation = [SectionDocs];
1821 def CodeSeg : InheritableAttr {
1822 let Spellings = [Declspec<"code_seg">];
1823 let Args = [StringArgument<"Name">];
1824 let Subjects = SubjectList<[Function, CXXRecord], ErrorDiag>;
1825 let Documentation = [CodeSegDocs];
1828 def PragmaClangBSSSection : InheritableAttr {
1829 // This attribute has no spellings as it is only ever created implicitly.
1831 let Args = [StringArgument<"Name">];
1832 let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
1833 let Documentation = [Undocumented];
1836 def PragmaClangDataSection : InheritableAttr {
1837 // This attribute has no spellings as it is only ever created implicitly.
1839 let Args = [StringArgument<"Name">];
1840 let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
1841 let Documentation = [Undocumented];
1844 def PragmaClangRodataSection : InheritableAttr {
1845 // This attribute has no spellings as it is only ever created implicitly.
1847 let Args = [StringArgument<"Name">];
1848 let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
1849 let Documentation = [Undocumented];
1852 def PragmaClangTextSection : InheritableAttr {
1853 // This attribute has no spellings as it is only ever created implicitly.
1855 let Args = [StringArgument<"Name">];
1856 let Subjects = SubjectList<[Function], ErrorDiag>;
1857 let Documentation = [Undocumented];
1860 def Sentinel : InheritableAttr {
1861 let Spellings = [GCC<"sentinel">];
1862 let Args = [DefaultIntArgument<"Sentinel", 0>,
1863 DefaultIntArgument<"NullPos", 0>];
1864 // let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
1865 let Documentation = [Undocumented];
1868 def StdCall : DeclOrTypeAttr {
1869 let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
1870 // let Subjects = [Function, ObjCMethod];
1871 let Documentation = [StdCallDocs];
1874 def SwiftCall : DeclOrTypeAttr {
1875 let Spellings = [Clang<"swiftcall">];
1876 // let Subjects = SubjectList<[Function]>;
1877 let Documentation = [SwiftCallDocs];
1880 def SwiftContext : ParameterABIAttr {
1881 let Spellings = [Clang<"swift_context">];
1882 let Documentation = [SwiftContextDocs];
1885 def SwiftErrorResult : ParameterABIAttr {
1886 let Spellings = [Clang<"swift_error_result">];
1887 let Documentation = [SwiftErrorResultDocs];
1890 def SwiftIndirectResult : ParameterABIAttr {
1891 let Spellings = [Clang<"swift_indirect_result">];
1892 let Documentation = [SwiftIndirectResultDocs];
1895 def Suppress : StmtAttr {
1896 let Spellings = [CXX11<"gsl", "suppress">];
1897 let Args = [VariadicStringArgument<"DiagnosticIdentifiers">];
1898 let Documentation = [SuppressDocs];
1901 def SysVABI : DeclOrTypeAttr {
1902 let Spellings = [GCC<"sysv_abi">];
1903 // let Subjects = [Function, ObjCMethod];
1904 let Documentation = [Undocumented];
1907 def ThisCall : DeclOrTypeAttr {
1908 let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
1909 Keyword<"_thiscall">];
1910 // let Subjects = [Function, ObjCMethod];
1911 let Documentation = [ThisCallDocs];
1914 def VectorCall : DeclOrTypeAttr {
1915 let Spellings = [Clang<"vectorcall">, Keyword<"__vectorcall">,
1916 Keyword<"_vectorcall">];
1917 // let Subjects = [Function, ObjCMethod];
1918 let Documentation = [VectorCallDocs];
1921 def Pascal : DeclOrTypeAttr {
1922 let Spellings = [Clang<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
1923 // let Subjects = [Function, ObjCMethod];
1924 let Documentation = [Undocumented];
1927 def PreserveMost : DeclOrTypeAttr {
1928 let Spellings = [Clang<"preserve_most">];
1929 let Documentation = [PreserveMostDocs];
1932 def PreserveAll : DeclOrTypeAttr {
1933 let Spellings = [Clang<"preserve_all">];
1934 let Documentation = [PreserveAllDocs];
1937 def Target : InheritableAttr {
1938 let Spellings = [GCC<"target">];
1939 let Args = [StringArgument<"featuresStr">];
1940 let Subjects = SubjectList<[Function], ErrorDiag>;
1941 let Documentation = [TargetDocs];
1942 let AdditionalMembers = [{
1943 struct ParsedTargetAttr {
1944 std::vector<std::string> Features;
1945 StringRef Architecture;
1946 bool DuplicateArchitecture = false;
1947 bool operator ==(const ParsedTargetAttr &Other) const {
1948 return DuplicateArchitecture == Other.DuplicateArchitecture &&
1949 Architecture == Other.Architecture && Features == Other.Features;
1952 ParsedTargetAttr parse() const {
1953 return parse(getFeaturesStr());
1956 template<class Compare>
1957 ParsedTargetAttr parse(Compare cmp) const {
1958 ParsedTargetAttr Attrs = parse();
1959 llvm::sort(std::begin(Attrs.Features), std::end(Attrs.Features), cmp);
1963 bool isDefaultVersion() const { return getFeaturesStr() == "default"; }
1965 static ParsedTargetAttr parse(StringRef Features) {
1966 ParsedTargetAttr Ret;
1967 if (Features == "default") return Ret;
1968 SmallVector<StringRef, 1> AttrFeatures;
1969 Features.split(AttrFeatures, ",");
1971 // Grab the various features and prepend a "+" to turn on the feature to
1972 // the backend and add them to our existing set of features.
1973 for (auto &Feature : AttrFeatures) {
1974 // Go ahead and trim whitespace rather than either erroring or
1975 // accepting it weirdly.
1976 Feature = Feature.trim();
1978 // We don't support cpu tuning this way currently.
1979 // TODO: Support the fpmath option. It will require checking
1980 // overall feature validity for the function with the rest of the
1981 // attributes on the function.
1982 if (Feature.startswith("fpmath=") || Feature.startswith("tune="))
1985 // While we're here iterating check for a different target cpu.
1986 if (Feature.startswith("arch=")) {
1987 if (!Ret.Architecture.empty())
1988 Ret.DuplicateArchitecture = true;
1990 Ret.Architecture = Feature.split("=").second.trim();
1991 } else if (Feature.startswith("no-"))
1992 Ret.Features.push_back("-" + Feature.split("-").second.str());
1994 Ret.Features.push_back("+" + Feature.str());
2001 def MinVectorWidth : InheritableAttr {
2002 let Spellings = [Clang<"min_vector_width">];
2003 let Args = [UnsignedArgument<"VectorWidth">];
2004 let Subjects = SubjectList<[Function], ErrorDiag>;
2005 let Documentation = [MinVectorWidthDocs];
2008 def TransparentUnion : InheritableAttr {
2009 let Spellings = [GCC<"transparent_union">];
2010 // let Subjects = SubjectList<[Record, TypedefName]>;
2011 let Documentation = [TransparentUnionDocs];
2012 let LangOpts = [COnly];
2015 def Unavailable : InheritableAttr {
2016 let Spellings = [Clang<"unavailable">];
2017 let Args = [StringArgument<"Message", 1>,
2018 EnumArgument<"ImplicitReason", "ImplicitReason",
2021 "IR_ARCForbiddenType",
2023 "IR_ARCForbiddenConversion",
2024 "IR_ARCInitReturnsUnrelated",
2025 "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>];
2026 let Documentation = [Undocumented];
2029 def DiagnoseIf : InheritableAttr {
2030 // Does not have a [[]] spelling because this attribute requires the ability
2031 // to parse function arguments but the attribute is not written in the type
2033 let Spellings = [GNU<"diagnose_if">];
2034 let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;
2035 let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
2036 EnumArgument<"DiagnosticType",
2038 ["error", "warning"],
2039 ["DT_Error", "DT_Warning"]>,
2040 BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
2041 NamedArgument<"Parent", 0, /*fake*/ 1>];
2042 let InheritEvenIfAlreadyPresent = 1;
2044 let AdditionalMembers = [{
2045 bool isError() const { return diagnosticType == DT_Error; }
2046 bool isWarning() const { return diagnosticType == DT_Warning; }
2048 let TemplateDependent = 1;
2049 let Documentation = [DiagnoseIfDocs];
2052 def ArcWeakrefUnavailable : InheritableAttr {
2053 let Spellings = [Clang<"objc_arc_weak_reference_unavailable">];
2054 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
2055 let Documentation = [Undocumented];
2058 def ObjCGC : TypeAttr {
2059 let Spellings = [Clang<"objc_gc">];
2060 let Args = [IdentifierArgument<"Kind">];
2061 let Documentation = [Undocumented];
2064 def ObjCOwnership : InheritableAttr {
2065 let Spellings = [Clang<"objc_ownership">];
2066 let Args = [IdentifierArgument<"Kind">];
2068 let Documentation = [Undocumented];
2071 def ObjCRequiresPropertyDefs : InheritableAttr {
2072 let Spellings = [Clang<"objc_requires_property_definitions">];
2073 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
2074 let Documentation = [Undocumented];
2077 def Unused : InheritableAttr {
2078 let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
2079 C2x<"", "maybe_unused">];
2080 let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
2081 Field, ObjCMethod, FunctionLike]>;
2082 let Documentation = [WarnMaybeUnusedDocs];
2085 def Used : InheritableAttr {
2086 let Spellings = [GCC<"used">];
2087 let Subjects = SubjectList<[NonLocalVar, Function, ObjCMethod]>;
2088 let Documentation = [Undocumented];
2091 def Uuid : InheritableAttr {
2092 let Spellings = [Declspec<"uuid">, Microsoft<"uuid">];
2093 let Args = [StringArgument<"Guid">];
2094 let Subjects = SubjectList<[Record, Enum]>;
2095 // FIXME: Allow expressing logical AND for LangOpts. Our condition should be:
2096 // CPlusPlus && (MicrosoftExt || Borland)
2097 let LangOpts = [MicrosoftExt, Borland];
2098 let Documentation = [Undocumented];
2101 def VectorSize : TypeAttr {
2102 let Spellings = [GCC<"vector_size">];
2103 let Args = [ExprArgument<"NumBytes">];
2104 let Documentation = [Undocumented];
2107 def VecTypeHint : InheritableAttr {
2108 // Does not have a [[]] spelling because it is an OpenCL-related attribute.
2109 let Spellings = [GNU<"vec_type_hint">];
2110 let Args = [TypeArgument<"TypeHint">];
2111 let Subjects = SubjectList<[Function], ErrorDiag>;
2112 let Documentation = [Undocumented];
2115 def Visibility : InheritableAttr {
2117 let Spellings = [GCC<"visibility">];
2118 let Args = [EnumArgument<"Visibility", "VisibilityType",
2119 ["default", "hidden", "internal", "protected"],
2120 ["Default", "Hidden", "Hidden", "Protected"]>];
2121 let MeaningfulToClassTemplateDefinition = 1;
2122 let Documentation = [Undocumented];
2125 def TypeVisibility : InheritableAttr {
2127 let Spellings = [Clang<"type_visibility">];
2128 let Args = [EnumArgument<"Visibility", "VisibilityType",
2129 ["default", "hidden", "internal", "protected"],
2130 ["Default", "Hidden", "Hidden", "Protected"]>];
2131 // let Subjects = [Tag, ObjCInterface, Namespace];
2132 let Documentation = [Undocumented];
2135 def VecReturn : InheritableAttr {
2136 // This attribute does not have a C [[]] spelling because it only appertains
2137 // to C++ struct/class/union.
2138 // FIXME: should this attribute have a CPlusPlus language option?
2139 let Spellings = [Clang<"vecreturn", 0>];
2140 let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
2141 let Documentation = [Undocumented];
2144 def WarnUnused : InheritableAttr {
2145 let Spellings = [GCC<"warn_unused">];
2146 let Subjects = SubjectList<[Record]>;
2147 let Documentation = [Undocumented];
2150 def WarnUnusedResult : InheritableAttr {
2151 let Spellings = [CXX11<"", "nodiscard", 201603>, C2x<"", "nodiscard">,
2152 CXX11<"clang", "warn_unused_result">,
2153 GCC<"warn_unused_result">];
2154 let Subjects = SubjectList<[ObjCMethod, Enum, Record, FunctionLike]>;
2155 let Documentation = [WarnUnusedResultsDocs];
2158 def Weak : InheritableAttr {
2159 let Spellings = [GCC<"weak">];
2160 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
2161 let Documentation = [Undocumented];
2164 def WeakImport : InheritableAttr {
2165 let Spellings = [Clang<"weak_import">];
2166 let Documentation = [Undocumented];
2169 def WeakRef : InheritableAttr {
2170 let Spellings = [GCC<"weakref">];
2171 // A WeakRef that has an argument is treated as being an AliasAttr
2172 let Args = [StringArgument<"Aliasee", 1>];
2173 let Subjects = SubjectList<[Var, Function], ErrorDiag>;
2174 let Documentation = [Undocumented];
2177 def LTOVisibilityPublic : InheritableAttr {
2178 let Spellings = [Clang<"lto_visibility_public">];
2179 let Subjects = SubjectList<[Record]>;
2180 let Documentation = [LTOVisibilityDocs];
2183 def AnyX86Interrupt : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
2184 // NOTE: If you add any additional spellings, ARMInterrupt's,
2185 // MSP430Interrupt's and MipsInterrupt's spellings must match.
2186 let Spellings = [GCC<"interrupt">];
2187 let Subjects = SubjectList<[HasFunctionProto]>;
2188 let ParseKind = "Interrupt";
2189 let HasCustomParsing = 1;
2190 let Documentation = [Undocumented];
2193 def AnyX86NoCallerSavedRegisters : InheritableAttr,
2194 TargetSpecificAttr<TargetAnyX86> {
2195 let Spellings = [GCC<"no_caller_saved_registers">];
2196 let Documentation = [AnyX86NoCallerSavedRegistersDocs];
2199 def AnyX86NoCfCheck : InheritableAttr, TargetSpecificAttr<TargetAnyX86>{
2200 let Spellings = [GCC<"nocf_check">];
2201 let Subjects = SubjectList<[FunctionLike]>;
2202 let Documentation = [AnyX86NoCfCheckDocs];
2205 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
2206 let Spellings = [GCC<"force_align_arg_pointer">];
2207 // Technically, this appertains to a FunctionDecl, but the target-specific
2208 // code silently allows anything function-like (such as typedefs or function
2209 // pointers), but does not apply the attribute to them.
2210 let Documentation = [X86ForceAlignArgPointerDocs];
2213 def NoSanitize : InheritableAttr {
2214 let Spellings = [Clang<"no_sanitize">];
2215 let Args = [VariadicStringArgument<"Sanitizers">];
2216 let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag>;
2217 let Documentation = [NoSanitizeDocs];
2218 let AdditionalMembers = [{
2219 SanitizerMask getMask() const {
2220 SanitizerMask Mask = 0;
2221 for (auto SanitizerName : sanitizers()) {
2222 SanitizerMask ParsedMask =
2223 parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
2224 Mask |= expandSanitizerGroups(ParsedMask);
2231 // Attributes to disable a specific sanitizer. No new sanitizers should be added
2232 // to this list; the no_sanitize attribute should be extended instead.
2233 def NoSanitizeSpecific : InheritableAttr {
2234 let Spellings = [GCC<"no_address_safety_analysis">,
2235 GCC<"no_sanitize_address">,
2236 GCC<"no_sanitize_thread">,
2237 Clang<"no_sanitize_memory">];
2238 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
2239 let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
2240 NoSanitizeMemoryDocs];
2244 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
2245 // Not all of these attributes will be given a [[]] spelling. The attributes
2246 // which require access to function parameter names cannot use the [[]] spelling
2247 // because they are not written in the type position. Some attributes are given
2248 // an updated captability-based name and the older name will only be supported
2249 // under the GNU-style spelling.
2250 def GuardedVar : InheritableAttr {
2251 let Spellings = [Clang<"guarded_var", 0>];
2252 let Subjects = SubjectList<[Field, SharedVar]>;
2253 let Documentation = [Undocumented];
2256 def PtGuardedVar : InheritableAttr {
2257 let Spellings = [Clang<"pt_guarded_var", 0>];
2258 let Subjects = SubjectList<[Field, SharedVar]>;
2259 let Documentation = [Undocumented];
2262 def Lockable : InheritableAttr {
2263 let Spellings = [GNU<"lockable">];
2264 let Subjects = SubjectList<[Record]>;
2265 let Documentation = [Undocumented];
2266 let ASTNode = 0; // Replaced by Capability
2269 def ScopedLockable : InheritableAttr {
2270 let Spellings = [Clang<"scoped_lockable", 0>];
2271 let Subjects = SubjectList<[Record]>;
2272 let Documentation = [Undocumented];
2275 def Capability : InheritableAttr {
2276 let Spellings = [Clang<"capability", 0>, Clang<"shared_capability", 0>];
2277 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag>;
2278 let Args = [StringArgument<"Name">];
2279 let Accessors = [Accessor<"isShared",
2280 [Clang<"shared_capability", 0>]>];
2281 let Documentation = [Undocumented];
2282 let AdditionalMembers = [{
2283 bool isMutex() const { return getName().equals_lower("mutex"); }
2284 bool isRole() const { return getName().equals_lower("role"); }
2288 def AssertCapability : InheritableAttr {
2289 let Spellings = [Clang<"assert_capability", 0>,
2290 Clang<"assert_shared_capability", 0>];
2291 let Subjects = SubjectList<[Function]>;
2293 let TemplateDependent = 1;
2294 let ParseArgumentsAsUnevaluated = 1;
2295 let InheritEvenIfAlreadyPresent = 1;
2296 let Args = [VariadicExprArgument<"Args">];
2297 let Accessors = [Accessor<"isShared",
2298 [Clang<"assert_shared_capability", 0>]>];
2299 let Documentation = [AssertCapabilityDocs];
2302 def AcquireCapability : InheritableAttr {
2303 let Spellings = [Clang<"acquire_capability", 0>,
2304 Clang<"acquire_shared_capability", 0>,
2305 GNU<"exclusive_lock_function">,
2306 GNU<"shared_lock_function">];
2307 let Subjects = SubjectList<[Function]>;
2309 let TemplateDependent = 1;
2310 let ParseArgumentsAsUnevaluated = 1;
2311 let InheritEvenIfAlreadyPresent = 1;
2312 let Args = [VariadicExprArgument<"Args">];
2313 let Accessors = [Accessor<"isShared",
2314 [Clang<"acquire_shared_capability", 0>,
2315 GNU<"shared_lock_function">]>];
2316 let Documentation = [AcquireCapabilityDocs];
2319 def TryAcquireCapability : InheritableAttr {
2320 let Spellings = [Clang<"try_acquire_capability", 0>,
2321 Clang<"try_acquire_shared_capability", 0>];
2322 let Subjects = SubjectList<[Function],
2325 let TemplateDependent = 1;
2326 let ParseArgumentsAsUnevaluated = 1;
2327 let InheritEvenIfAlreadyPresent = 1;
2328 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2329 let Accessors = [Accessor<"isShared",
2330 [Clang<"try_acquire_shared_capability", 0>]>];
2331 let Documentation = [TryAcquireCapabilityDocs];
2334 def ReleaseCapability : InheritableAttr {
2335 let Spellings = [Clang<"release_capability", 0>,
2336 Clang<"release_shared_capability", 0>,
2337 Clang<"release_generic_capability", 0>,
2338 Clang<"unlock_function", 0>];
2339 let Subjects = SubjectList<[Function]>;
2341 let TemplateDependent = 1;
2342 let ParseArgumentsAsUnevaluated = 1;
2343 let InheritEvenIfAlreadyPresent = 1;
2344 let Args = [VariadicExprArgument<"Args">];
2345 let Accessors = [Accessor<"isShared",
2346 [Clang<"release_shared_capability", 0>]>,
2347 Accessor<"isGeneric",
2348 [Clang<"release_generic_capability", 0>,
2349 Clang<"unlock_function", 0>]>];
2350 let Documentation = [ReleaseCapabilityDocs];
2353 def RequiresCapability : InheritableAttr {
2354 let Spellings = [Clang<"requires_capability", 0>,
2355 Clang<"exclusive_locks_required", 0>,
2356 Clang<"requires_shared_capability", 0>,
2357 Clang<"shared_locks_required", 0>];
2358 let Args = [VariadicExprArgument<"Args">];
2360 let TemplateDependent = 1;
2361 let ParseArgumentsAsUnevaluated = 1;
2362 let InheritEvenIfAlreadyPresent = 1;
2363 let Subjects = SubjectList<[Function]>;
2364 let Accessors = [Accessor<"isShared", [Clang<"requires_shared_capability", 0>,
2365 Clang<"shared_locks_required", 0>]>];
2366 let Documentation = [Undocumented];
2369 def NoThreadSafetyAnalysis : InheritableAttr {
2370 let Spellings = [Clang<"no_thread_safety_analysis">];
2371 let Subjects = SubjectList<[Function]>;
2372 let Documentation = [Undocumented];
2375 def GuardedBy : InheritableAttr {
2376 let Spellings = [GNU<"guarded_by">];
2377 let Args = [ExprArgument<"Arg">];
2379 let TemplateDependent = 1;
2380 let ParseArgumentsAsUnevaluated = 1;
2381 let InheritEvenIfAlreadyPresent = 1;
2382 let Subjects = SubjectList<[Field, SharedVar]>;
2383 let Documentation = [Undocumented];
2386 def PtGuardedBy : InheritableAttr {
2387 let Spellings = [GNU<"pt_guarded_by">];
2388 let Args = [ExprArgument<"Arg">];
2390 let TemplateDependent = 1;
2391 let ParseArgumentsAsUnevaluated = 1;
2392 let InheritEvenIfAlreadyPresent = 1;
2393 let Subjects = SubjectList<[Field, SharedVar]>;
2394 let Documentation = [Undocumented];
2397 def AcquiredAfter : InheritableAttr {
2398 let Spellings = [GNU<"acquired_after">];
2399 let Args = [VariadicExprArgument<"Args">];
2401 let TemplateDependent = 1;
2402 let ParseArgumentsAsUnevaluated = 1;
2403 let InheritEvenIfAlreadyPresent = 1;
2404 let Subjects = SubjectList<[Field, SharedVar]>;
2405 let Documentation = [Undocumented];
2408 def AcquiredBefore : InheritableAttr {
2409 let Spellings = [GNU<"acquired_before">];
2410 let Args = [VariadicExprArgument<"Args">];
2412 let TemplateDependent = 1;
2413 let ParseArgumentsAsUnevaluated = 1;
2414 let InheritEvenIfAlreadyPresent = 1;
2415 let Subjects = SubjectList<[Field, SharedVar]>;
2416 let Documentation = [Undocumented];
2419 def AssertExclusiveLock : InheritableAttr {
2420 let Spellings = [GNU<"assert_exclusive_lock">];
2421 let Args = [VariadicExprArgument<"Args">];
2423 let TemplateDependent = 1;
2424 let ParseArgumentsAsUnevaluated = 1;
2425 let InheritEvenIfAlreadyPresent = 1;
2426 let Subjects = SubjectList<[Function]>;
2427 let Documentation = [Undocumented];
2430 def AssertSharedLock : InheritableAttr {
2431 let Spellings = [GNU<"assert_shared_lock">];
2432 let Args = [VariadicExprArgument<"Args">];
2434 let TemplateDependent = 1;
2435 let ParseArgumentsAsUnevaluated = 1;
2436 let InheritEvenIfAlreadyPresent = 1;
2437 let Subjects = SubjectList<[Function]>;
2438 let Documentation = [Undocumented];
2441 // The first argument is an integer or boolean value specifying the return value
2442 // of a successful lock acquisition.
2443 def ExclusiveTrylockFunction : InheritableAttr {
2444 let Spellings = [GNU<"exclusive_trylock_function">];
2445 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2447 let TemplateDependent = 1;
2448 let ParseArgumentsAsUnevaluated = 1;
2449 let InheritEvenIfAlreadyPresent = 1;
2450 let Subjects = SubjectList<[Function]>;
2451 let Documentation = [Undocumented];
2454 // The first argument is an integer or boolean value specifying the return value
2455 // of a successful lock acquisition.
2456 def SharedTrylockFunction : InheritableAttr {
2457 let Spellings = [GNU<"shared_trylock_function">];
2458 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2460 let TemplateDependent = 1;
2461 let ParseArgumentsAsUnevaluated = 1;
2462 let InheritEvenIfAlreadyPresent = 1;
2463 let Subjects = SubjectList<[Function]>;
2464 let Documentation = [Undocumented];
2467 def LockReturned : InheritableAttr {
2468 let Spellings = [GNU<"lock_returned">];
2469 let Args = [ExprArgument<"Arg">];
2471 let TemplateDependent = 1;
2472 let ParseArgumentsAsUnevaluated = 1;
2473 let Subjects = SubjectList<[Function]>;
2474 let Documentation = [Undocumented];
2477 def LocksExcluded : InheritableAttr {
2478 let Spellings = [GNU<"locks_excluded">];
2479 let Args = [VariadicExprArgument<"Args">];
2481 let TemplateDependent = 1;
2482 let ParseArgumentsAsUnevaluated = 1;
2483 let InheritEvenIfAlreadyPresent = 1;
2484 let Subjects = SubjectList<[Function]>;
2485 let Documentation = [Undocumented];
2488 // C/C++ consumed attributes.
2490 def Consumable : InheritableAttr {
2491 // This attribute does not have a C [[]] spelling because it only appertains
2492 // to C++ struct/class/union.
2493 // FIXME: should this attribute have a CPlusPlus language option?
2494 let Spellings = [Clang<"consumable", 0>];
2495 let Subjects = SubjectList<[CXXRecord]>;
2496 let Args = [EnumArgument<"DefaultState", "ConsumedState",
2497 ["unknown", "consumed", "unconsumed"],
2498 ["Unknown", "Consumed", "Unconsumed"]>];
2499 let Documentation = [ConsumableDocs];
2502 def ConsumableAutoCast : InheritableAttr {
2503 // This attribute does not have a C [[]] spelling because it only appertains
2504 // to C++ struct/class/union.
2505 // FIXME: should this attribute have a CPlusPlus language option?
2506 let Spellings = [Clang<"consumable_auto_cast_state", 0>];
2507 let Subjects = SubjectList<[CXXRecord]>;
2508 let Documentation = [Undocumented];
2511 def ConsumableSetOnRead : InheritableAttr {
2512 // This attribute does not have a C [[]] spelling because it only appertains
2513 // to C++ struct/class/union.
2514 // FIXME: should this attribute have a CPlusPlus language option?
2515 let Spellings = [Clang<"consumable_set_state_on_read", 0>];
2516 let Subjects = SubjectList<[CXXRecord]>;
2517 let Documentation = [Undocumented];
2520 def CallableWhen : InheritableAttr {
2521 // This attribute does not have a C [[]] spelling because it only appertains
2522 // to C++ function (but doesn't require it to be a member function).
2523 // FIXME: should this attribute have a CPlusPlus language option?
2524 let Spellings = [Clang<"callable_when", 0>];
2525 let Subjects = SubjectList<[CXXMethod]>;
2526 let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
2527 ["unknown", "consumed", "unconsumed"],
2528 ["Unknown", "Consumed", "Unconsumed"]>];
2529 let Documentation = [CallableWhenDocs];
2532 def ParamTypestate : InheritableAttr {
2533 // This attribute does not have a C [[]] spelling because it only appertains
2534 // to a parameter whose type is a consumable C++ class.
2535 // FIXME: should this attribute have a CPlusPlus language option?
2536 let Spellings = [Clang<"param_typestate", 0>];
2537 let Subjects = SubjectList<[ParmVar]>;
2538 let Args = [EnumArgument<"ParamState", "ConsumedState",
2539 ["unknown", "consumed", "unconsumed"],
2540 ["Unknown", "Consumed", "Unconsumed"]>];
2541 let Documentation = [ParamTypestateDocs];
2544 def ReturnTypestate : InheritableAttr {
2545 // This attribute does not have a C [[]] spelling because it only appertains
2546 // to a parameter or function return type that is a consumable C++ class.
2547 // FIXME: should this attribute have a CPlusPlus language option?
2548 let Spellings = [Clang<"return_typestate", 0>];
2549 let Subjects = SubjectList<[Function, ParmVar]>;
2550 let Args = [EnumArgument<"State", "ConsumedState",
2551 ["unknown", "consumed", "unconsumed"],
2552 ["Unknown", "Consumed", "Unconsumed"]>];
2553 let Documentation = [ReturnTypestateDocs];
2556 def SetTypestate : InheritableAttr {
2557 // This attribute does not have a C [[]] spelling because it only appertains
2558 // to C++ function (but doesn't require it to be a member function).
2559 // FIXME: should this attribute have a CPlusPlus language option?
2560 let Spellings = [Clang<"set_typestate", 0>];
2561 let Subjects = SubjectList<[CXXMethod]>;
2562 let Args = [EnumArgument<"NewState", "ConsumedState",
2563 ["unknown", "consumed", "unconsumed"],
2564 ["Unknown", "Consumed", "Unconsumed"]>];
2565 let Documentation = [SetTypestateDocs];
2568 def TestTypestate : InheritableAttr {
2569 // This attribute does not have a C [[]] spelling because it only appertains
2570 // to C++ function (but doesn't require it to be a member function).
2571 // FIXME: should this attribute have a CPlusPlus language option?
2572 let Spellings = [Clang<"test_typestate", 0>];
2573 let Subjects = SubjectList<[CXXMethod]>;
2574 let Args = [EnumArgument<"TestState", "ConsumedState",
2575 ["consumed", "unconsumed"],
2576 ["Consumed", "Unconsumed"]>];
2577 let Documentation = [TestTypestateDocs];
2580 // Type safety attributes for `void *' pointers and type tags.
2582 def ArgumentWithTypeTag : InheritableAttr {
2583 let Spellings = [Clang<"argument_with_type_tag">,
2584 Clang<"pointer_with_type_tag">];
2585 let Subjects = SubjectList<[HasFunctionProto], ErrorDiag>;
2586 let Args = [IdentifierArgument<"ArgumentKind">,
2587 ParamIdxArgument<"ArgumentIdx">,
2588 ParamIdxArgument<"TypeTagIdx">,
2589 BoolArgument<"IsPointer", /*opt*/0, /*fake*/1>];
2590 let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
2593 def TypeTagForDatatype : InheritableAttr {
2594 let Spellings = [Clang<"type_tag_for_datatype">];
2595 let Args = [IdentifierArgument<"ArgumentKind">,
2596 TypeArgument<"MatchingCType">,
2597 BoolArgument<"LayoutCompatible">,
2598 BoolArgument<"MustBeNull">];
2599 // let Subjects = SubjectList<[Var], ErrorDiag>;
2600 let HasCustomParsing = 1;
2601 let Documentation = [TypeTagForDatatypeDocs];
2604 // Microsoft-related attributes
2606 def MSNoVTable : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
2607 let Spellings = [Declspec<"novtable">];
2608 let Subjects = SubjectList<[CXXRecord]>;
2609 let Documentation = [MSNoVTableDocs];
2613 let Spellings = [Declspec<"property">];
2616 def MSStruct : InheritableAttr {
2617 let Spellings = [GCC<"ms_struct">];
2618 let Subjects = SubjectList<[Record]>;
2619 let Documentation = [Undocumented];
2622 def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2623 let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
2624 let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2625 let Documentation = [DLLExportDocs];
2628 def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2629 let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
2630 let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2631 let Documentation = [DLLImportDocs];
2634 let AdditionalMembers = [{
2636 bool PropagatedToBaseTemplate = false;
2639 void setPropagatedToBaseTemplate() { PropagatedToBaseTemplate = true; }
2640 bool wasPropagatedToBaseTemplate() { return PropagatedToBaseTemplate; }
2644 def SelectAny : InheritableAttr {
2645 let Spellings = [Declspec<"selectany">, GCC<"selectany">];
2646 let Documentation = [SelectAnyDocs];
2650 let Spellings = [Declspec<"thread">];
2651 let LangOpts = [MicrosoftExt];
2652 let Documentation = [ThreadDocs];
2653 let Subjects = SubjectList<[Var]>;
2656 def Win64 : IgnoredAttr {
2657 let Spellings = [Keyword<"__w64">];
2658 let LangOpts = [MicrosoftExt];
2661 def Ptr32 : TypeAttr {
2662 let Spellings = [Keyword<"__ptr32">];
2663 let Documentation = [Undocumented];
2666 def Ptr64 : TypeAttr {
2667 let Spellings = [Keyword<"__ptr64">];
2668 let Documentation = [Undocumented];
2671 def SPtr : TypeAttr {
2672 let Spellings = [Keyword<"__sptr">];
2673 let Documentation = [Undocumented];
2676 def UPtr : TypeAttr {
2677 let Spellings = [Keyword<"__uptr">];
2678 let Documentation = [Undocumented];
2681 def MSInheritance : InheritableAttr {
2682 let LangOpts = [MicrosoftExt];
2683 let Args = [DefaultBoolArgument<"BestCase", /*default*/1, /*fake*/1>];
2684 let Spellings = [Keyword<"__single_inheritance">,
2685 Keyword<"__multiple_inheritance">,
2686 Keyword<"__virtual_inheritance">,
2687 Keyword<"__unspecified_inheritance">];
2688 let AdditionalMembers = [{
2689 static bool hasVBPtrOffsetField(Spelling Inheritance) {
2690 return Inheritance == Keyword_unspecified_inheritance;
2693 // Only member pointers to functions need a this adjustment, since it can be
2694 // combined with the field offset for data pointers.
2695 static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
2696 return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
2699 static bool hasVBTableOffsetField(Spelling Inheritance) {
2700 return Inheritance >= Keyword_virtual_inheritance;
2703 static bool hasOnlyOneField(bool IsMemberFunction,
2704 Spelling Inheritance) {
2705 if (IsMemberFunction)
2706 return Inheritance <= Keyword_single_inheritance;
2707 return Inheritance <= Keyword_multiple_inheritance;
2710 let Documentation = [MSInheritanceDocs];
2713 def MSVtorDisp : InheritableAttr {
2714 // This attribute has no spellings as it is only ever created implicitly.
2716 let Args = [UnsignedArgument<"vdm">];
2717 let SemaHandler = 0;
2719 let AdditionalMembers = [{
2726 Mode getVtorDispMode() const { return Mode(vdm); }
2728 let Documentation = [Undocumented];
2731 def InitSeg : Attr {
2732 let Spellings = [Pragma<"", "init_seg">];
2733 let Args = [StringArgument<"Section">];
2734 let SemaHandler = 0;
2735 let Documentation = [InitSegDocs];
2736 let AdditionalMembers = [{
2737 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2738 OS << " (" << getSection() << ')';
2743 def LoopHint : Attr {
2744 /// #pragma clang loop <option> directive
2745 /// vectorize: vectorizes loop operations if State == Enable.
2746 /// vectorize_width: vectorize loop operations with width 'Value'.
2747 /// interleave: interleave multiple loop iterations if State == Enable.
2748 /// interleave_count: interleaves 'Value' loop iterations.
2749 /// unroll: fully unroll loop if State == Enable.
2750 /// unroll_count: unrolls loop 'Value' times.
2751 /// distribute: attempt to distribute loop if State == Enable
2753 /// #pragma unroll <argument> directive
2754 /// <no arg>: fully unrolls loop.
2755 /// boolean: fully unrolls loop if State == Enable.
2756 /// expression: unrolls loop 'Value' times.
2758 let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">,
2759 Pragma<"", "nounroll">];
2761 /// State of the loop optimization specified by the spelling.
2762 let Args = [EnumArgument<"Option", "OptionType",
2763 ["vectorize", "vectorize_width", "interleave", "interleave_count",
2764 "unroll", "unroll_count", "distribute"],
2765 ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
2766 "Unroll", "UnrollCount", "Distribute"]>,
2767 EnumArgument<"State", "LoopHintState",
2768 ["enable", "disable", "numeric", "assume_safety", "full"],
2769 ["Enable", "Disable", "Numeric", "AssumeSafety", "Full"]>,
2770 ExprArgument<"Value">];
2772 let AdditionalMembers = [{
2773 static const char *getOptionName(int Option) {
2775 case Vectorize: return "vectorize";
2776 case VectorizeWidth: return "vectorize_width";
2777 case Interleave: return "interleave";
2778 case InterleaveCount: return "interleave_count";
2779 case Unroll: return "unroll";
2780 case UnrollCount: return "unroll_count";
2781 case Distribute: return "distribute";
2783 llvm_unreachable("Unhandled LoopHint option.");
2786 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2787 unsigned SpellingIndex = getSpellingListIndex();
2788 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
2789 // "nounroll" is already emitted as the pragma name.
2790 if (SpellingIndex == Pragma_nounroll)
2792 else if (SpellingIndex == Pragma_unroll) {
2793 OS << ' ' << getValueString(Policy);
2797 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2798 OS << ' ' << getOptionName(option) << getValueString(Policy);
2801 // Return a string containing the loop hint argument including the
2802 // enclosing parentheses.
2803 std::string getValueString(const PrintingPolicy &Policy) const {
2804 std::string ValueName;
2805 llvm::raw_string_ostream OS(ValueName);
2807 if (state == Numeric)
2808 value->printPretty(OS, nullptr, Policy);
2809 else if (state == Enable)
2811 else if (state == Full)
2813 else if (state == AssumeSafety)
2814 OS << "assume_safety";
2821 // Return a string suitable for identifying this attribute in diagnostics.
2822 std::string getDiagnosticName(const PrintingPolicy &Policy) const {
2823 unsigned SpellingIndex = getSpellingListIndex();
2824 if (SpellingIndex == Pragma_nounroll)
2825 return "#pragma nounroll";
2826 else if (SpellingIndex == Pragma_unroll)
2827 return "#pragma unroll" + (option == UnrollCount ? getValueString(Policy) : "");
2829 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2830 return getOptionName(option) + getValueString(Policy);
2834 let Documentation = [LoopHintDocs, UnrollHintDocs];
2837 def CapturedRecord : InheritableAttr {
2838 // This attribute has no spellings as it is only ever created implicitly.
2840 let SemaHandler = 0;
2841 let Documentation = [Undocumented];
2844 def OMPThreadPrivateDecl : InheritableAttr {
2845 // This attribute has no spellings as it is only ever created implicitly.
2847 let SemaHandler = 0;
2848 let Documentation = [Undocumented];
2851 def OMPCaptureNoInit : InheritableAttr {
2852 // This attribute has no spellings as it is only ever created implicitly.
2854 let SemaHandler = 0;
2855 let Documentation = [Undocumented];
2858 def OMPCaptureKind : Attr {
2859 // This attribute has no spellings as it is only ever created implicitly.
2861 let SemaHandler = 0;
2862 let Args = [UnsignedArgument<"CaptureKind">];
2863 let Documentation = [Undocumented];
2866 def OMPReferencedVar : Attr {
2867 // This attribute has no spellings as it is only ever created implicitly.
2869 let SemaHandler = 0;
2870 let Args = [ExprArgument<"Ref">];
2871 let Documentation = [Undocumented];
2874 def OMPDeclareSimdDecl : Attr {
2875 let Spellings = [Pragma<"omp", "declare simd">];
2876 let Subjects = SubjectList<[Function]>;
2877 let SemaHandler = 0;
2878 let HasCustomParsing = 1;
2879 let Documentation = [OMPDeclareSimdDocs];
2881 EnumArgument<"BranchState", "BranchStateTy",
2882 [ "", "inbranch", "notinbranch" ],
2883 [ "BS_Undefined", "BS_Inbranch", "BS_Notinbranch" ]>,
2884 ExprArgument<"Simdlen">, VariadicExprArgument<"Uniforms">,
2885 VariadicExprArgument<"Aligneds">, VariadicExprArgument<"Alignments">,
2886 VariadicExprArgument<"Linears">, VariadicUnsignedArgument<"Modifiers">,
2887 VariadicExprArgument<"Steps">
2889 let AdditionalMembers = [{
2890 void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
2892 if (getBranchState() != BS_Undefined)
2893 OS << ' ' << ConvertBranchStateTyToStr(getBranchState());
2894 if (auto *E = getSimdlen()) {
2896 E->printPretty(OS, nullptr, Policy);
2899 if (uniforms_size() > 0) {
2901 StringRef Sep = "(";
2902 for (auto *E : uniforms()) {
2904 E->printPretty(OS, nullptr, Policy);
2909 alignments_iterator NI = alignments_begin();
2910 for (auto *E : aligneds()) {
2912 E->printPretty(OS, nullptr, Policy);
2915 (*NI)->printPretty(OS, nullptr, Policy);
2920 steps_iterator I = steps_begin();
2921 modifiers_iterator MI = modifiers_begin();
2922 for (auto *E : linears()) {
2924 if (*MI != OMPC_LINEAR_unknown)
2925 OS << getOpenMPSimpleClauseTypeName(OMPC_linear, *MI) << "(";
2926 E->printPretty(OS, nullptr, Policy);
2927 if (*MI != OMPC_LINEAR_unknown)
2931 (*I)->printPretty(OS, nullptr, Policy);
2941 def OMPDeclareTargetDecl : InheritableAttr {
2942 let Spellings = [Pragma<"omp", "declare target">];
2943 let SemaHandler = 0;
2944 let Subjects = SubjectList<[Function, SharedVar]>;
2945 let Documentation = [OMPDeclareTargetDocs];
2947 EnumArgument<"MapType", "MapTypeTy",
2949 [ "MT_To", "MT_Link" ]>
2951 let AdditionalMembers = [{
2952 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2953 // Use fake syntax because it is for testing and debugging purpose only.
2954 if (getMapType() != MT_To)
2955 OS << ' ' << ConvertMapTypeTyToStr(getMapType());
2957 static llvm::Optional<MapTypeTy>
2958 isDeclareTargetDeclaration(const ValueDecl *VD) {
2959 if (!VD->hasAttrs())
2961 if (const auto *Attr = VD->getAttr<OMPDeclareTargetDeclAttr>())
2962 return Attr->getMapType();
2969 def InternalLinkage : InheritableAttr {
2970 let Spellings = [Clang<"internal_linkage">];
2971 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
2972 let Documentation = [InternalLinkageDocs];