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 NonStaticCXXMethod : SubsetSubject<CXXMethod,
95 "non-static member functions">;
97 def NonStaticNonConstCXXMethod
98 : SubsetSubject<CXXMethod,
99 [{!S->isStatic() && !S->isConst()}],
100 "non-static non-const member functions">;
102 def ObjCInstanceMethod : SubsetSubject<ObjCMethod,
103 [{S->isInstanceMethod()}],
104 "Objective-C instance methods">;
106 def Struct : SubsetSubject<Record,
107 [{!S->isUnion()}], "structs">;
109 def TLSVar : SubsetSubject<Var,
110 [{S->getTLSKind() != 0}], "thread-local variables">;
112 def SharedVar : SubsetSubject<Var,
113 [{S->hasGlobalStorage() && !S->getTLSKind()}],
116 def GlobalVar : SubsetSubject<Var,
117 [{S->hasGlobalStorage()}], "global variables">;
119 def InlineFunction : SubsetSubject<Function,
120 [{S->isInlineSpecified()}], "inline functions">;
122 // FIXME: this hack is needed because DeclNodes.td defines the base Decl node
123 // type to be a class, not a definition. This makes it impossible to create an
124 // attribute subject which accepts a Decl. Normally, this is not a problem,
125 // because the attribute can have no Subjects clause to accomplish this. But in
126 // the case of a SubsetSubject, there's no way to express it without this hack.
127 def DeclBase : AttrSubject;
128 def FunctionLike : SubsetSubject<DeclBase,
129 [{S->getFunctionType(false) != nullptr}],
130 "functions, function pointers">;
132 def OpenCLKernelFunction
133 : SubsetSubject<Function, [{S->hasAttr<OpenCLKernelAttr>()}],
136 // HasFunctionProto is a more strict version of FunctionLike, so it should
137 // never be specified in a Subjects list along with FunctionLike (due to the
138 // inclusive nature of subject testing).
139 def HasFunctionProto : SubsetSubject<DeclBase,
140 [{(S->getFunctionType(true) != nullptr &&
141 isa<FunctionProtoType>(S->getFunctionType())) ||
142 isa<ObjCMethodDecl>(S) ||
144 "non-K&R-style functions">;
146 // A subject that matches the implicit object parameter of a non-static member
147 // function. Accepted as a function type attribute on the type of such a
149 // FIXME: This does not actually ever match currently.
150 def ImplicitObjectParameter
151 : SubsetSubject<Function, [{static_cast<void>(S), false}],
152 "implicit object parameters">;
154 // A single argument to an attribute
155 class Argument<string name, bit optional, bit fake = 0> {
157 bit Optional = optional;
159 /// A fake argument is used to store and serialize additional information
160 /// in an attribute without actually changing its parsing or pretty-printing.
164 class BoolArgument<string name, bit opt = 0, bit fake = 0> : Argument<name, opt,
166 class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>;
167 class IntArgument<string name, bit opt = 0> : Argument<name, opt>;
168 class StringArgument<string name, bit opt = 0> : Argument<name, opt>;
169 class ExprArgument<string name, bit opt = 0> : Argument<name, opt>;
170 class FunctionArgument<string name, bit opt = 0, bit fake = 0> : Argument<name,
173 class NamedArgument<string name, bit opt = 0, bit fake = 0> : Argument<name,
176 class TypeArgument<string name, bit opt = 0> : Argument<name, opt>;
177 class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>;
178 class VariadicUnsignedArgument<string name> : Argument<name, 1>;
179 class VariadicExprArgument<string name> : Argument<name, 1>;
180 class VariadicStringArgument<string name> : Argument<name, 1>;
181 class VariadicIdentifierArgument<string name> : Argument<name, 1>;
183 // Like VariadicUnsignedArgument except values are ParamIdx.
184 class VariadicParamIdxArgument<string name> : Argument<name, 1>;
186 // Like VariadicParamIdxArgument but for a single function parameter index.
187 class ParamIdxArgument<string name, bit opt = 0> : Argument<name, opt>;
189 // A version of the form major.minor[.subminor].
190 class VersionArgument<string name, bit opt = 0> : Argument<name, opt>;
192 // This one's a doozy, so it gets its own special type
193 // It can be an unsigned integer, or a type. Either can
195 class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>;
197 // A bool argument with a default value
198 class DefaultBoolArgument<string name, bit default, bit fake = 0>
199 : BoolArgument<name, 1, fake> {
200 bit Default = default;
203 // An integer argument with a default value
204 class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
205 int Default = default;
208 // This argument is more complex, it includes the enumerator type name,
209 // a list of strings to accept, and a list of enumerators to map them to.
210 class EnumArgument<string name, string type, list<string> values,
211 list<string> enums, bit opt = 0, bit fake = 0>
212 : Argument<name, opt, fake> {
214 list<string> Values = values;
215 list<string> Enums = enums;
218 // FIXME: There should be a VariadicArgument type that takes any other type
219 // of argument and generates the appropriate type.
220 class VariadicEnumArgument<string name, string type, list<string> values,
221 list<string> enums> : Argument<name, 1> {
223 list<string> Values = values;
224 list<string> Enums = enums;
227 // This handles one spelling of an attribute.
228 class Spelling<string name, string variety> {
230 string Variety = variety;
234 class GNU<string name> : Spelling<name, "GNU">;
235 class Declspec<string name> : Spelling<name, "Declspec">;
236 class Microsoft<string name> : Spelling<name, "Microsoft">;
237 class CXX11<string namespace, string name, int version = 1>
238 : Spelling<name, "CXX11"> {
239 string Namespace = namespace;
240 int Version = version;
242 class C2x<string namespace, string name> : Spelling<name, "C2x"> {
243 string Namespace = namespace;
246 class Keyword<string name> : Spelling<name, "Keyword">;
247 class Pragma<string namespace, string name> : Spelling<name, "Pragma"> {
248 string Namespace = namespace;
251 // The GCC spelling implies GNU<name> and CXX11<"gnu", name> and also sets
252 // KnownToGCC to 1. This spelling should be used for any GCC-compatible
254 class GCC<string name> : Spelling<name, "GCC"> {
258 // The Clang spelling implies GNU<name>, CXX11<"clang", name>, and optionally,
259 // C2x<"clang", name>. This spelling should be used for any Clang-specific
261 class Clang<string name, bit allowInC = 1> : Spelling<name, "Clang"> {
262 bit AllowInC = allowInC;
265 class Accessor<string name, list<Spelling> spellings> {
267 list<Spelling> Spellings = spellings;
270 class SubjectDiag<bit warn> {
273 def WarnDiag : SubjectDiag<1>;
274 def ErrorDiag : SubjectDiag<0>;
276 class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag,
277 string customDiag = ""> {
278 list<AttrSubject> Subjects = subjects;
279 SubjectDiag Diag = diag;
280 string CustomDiag = customDiag;
283 class LangOpt<string name, bit negated = 0> {
285 bit Negated = negated;
287 def MicrosoftExt : LangOpt<"MicrosoftExt">;
288 def Borland : LangOpt<"Borland">;
289 def CUDA : LangOpt<"CUDA">;
290 def COnly : LangOpt<"CPlusPlus", 1>;
291 def CPlusPlus : LangOpt<"CPlusPlus">;
292 def OpenCL : LangOpt<"OpenCL">;
293 def RenderScript : LangOpt<"RenderScript">;
294 def ObjC : LangOpt<"ObjC">;
295 def BlocksSupported : LangOpt<"Blocks">;
296 def ObjCAutoRefCount : LangOpt<"ObjCAutoRefCount">;
298 // Defines targets for target-specific attributes. Empty lists are unchecked.
300 // Specifies Architectures for which the target applies, based off the
301 // ArchType enumeration in Triple.h.
302 list<string> Arches = [];
303 // Specifies Operating Systems for which the target applies, based off the
304 // OSType enumeration in Triple.h
306 // Specifies the C++ ABIs for which the target applies, based off the
307 // TargetCXXABI::Kind in TargetCXXABI.h.
308 list<string> CXXABIs;
309 // Specifies Object Formats for which the target applies, based off the
310 // ObjectFormatType enumeration in Triple.h
311 list<string> ObjectFormats;
314 class TargetArch<list<string> arches> : TargetSpec {
317 def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
318 def TargetAVR : TargetArch<["avr"]>;
319 def TargetMips32 : TargetArch<["mips", "mipsel"]>;
320 def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
321 def TargetMSP430 : TargetArch<["msp430"]>;
322 def TargetRISCV : TargetArch<["riscv32", "riscv64"]>;
323 def TargetX86 : TargetArch<["x86"]>;
324 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
325 def TargetWebAssembly : TargetArch<["wasm32", "wasm64"]>;
326 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
327 let OSes = ["Win32"];
329 def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
330 let CXXABIs = ["Microsoft"];
332 def TargetELF : TargetSpec {
333 let ObjectFormats = ["ELF"];
336 // Attribute subject match rules that are used for #pragma clang attribute.
338 // A instance of AttrSubjectMatcherRule represents an individual match rule.
339 // An individual match rule can correspond to a number of different attribute
340 // subjects, e.g. "record" matching rule corresponds to the Record and
341 // CXXRecord attribute subjects.
343 // Match rules are used in the subject list of the #pragma clang attribute.
344 // Match rules can have sub-match rules that are instances of
345 // AttrSubjectMatcherSubRule. A sub-match rule can correspond to a number
346 // of different attribute subjects, and it can have a negated spelling as well.
347 // For example, "variable(unless(is_parameter))" matching rule corresponds to
348 // the NonParmVar attribute subject.
349 class AttrSubjectMatcherSubRule<string name, list<AttrSubject> subjects,
352 list<AttrSubject> Subjects = subjects;
353 bit Negated = negated;
354 // Lists language options, one of which is required to be true for the
355 // attribute to be applicable. If empty, the language options are taken
356 // from the parent matcher rule.
357 list<LangOpt> LangOpts = [];
359 class AttrSubjectMatcherRule<string name, list<AttrSubject> subjects,
360 list<AttrSubjectMatcherSubRule> subrules = []> {
362 list<AttrSubject> Subjects = subjects;
363 list<AttrSubjectMatcherSubRule> Constraints = subrules;
364 // Lists language options, one of which is required to be true for the
365 // attribute to be applicable. If empty, no language options are required.
366 list<LangOpt> LangOpts = [];
369 // function(is_member)
370 def SubRuleForCXXMethod : AttrSubjectMatcherSubRule<"is_member", [CXXMethod]> {
371 let LangOpts = [CPlusPlus];
373 def SubjectMatcherForFunction : AttrSubjectMatcherRule<"function", [Function], [
376 // hasType is abstract, it should be used with one of the sub-rules.
377 def SubjectMatcherForType : AttrSubjectMatcherRule<"hasType", [], [
378 AttrSubjectMatcherSubRule<"functionType", [FunctionLike]>
380 // FIXME: There's a matcher ambiguity with objc methods and blocks since
381 // functionType excludes them but functionProtoType includes them.
382 // AttrSubjectMatcherSubRule<"functionProtoType", [HasFunctionProto]>
384 def SubjectMatcherForTypedef : AttrSubjectMatcherRule<"type_alias",
386 def SubjectMatcherForRecord : AttrSubjectMatcherRule<"record", [Record,
389 AttrSubjectMatcherSubRule<"is_union", [Struct], 1>
391 def SubjectMatcherForEnum : AttrSubjectMatcherRule<"enum", [Enum]>;
392 def SubjectMatcherForEnumConstant : AttrSubjectMatcherRule<"enum_constant",
394 def SubjectMatcherForVar : AttrSubjectMatcherRule<"variable", [Var], [
395 AttrSubjectMatcherSubRule<"is_thread_local", [TLSVar]>,
396 AttrSubjectMatcherSubRule<"is_global", [GlobalVar]>,
397 AttrSubjectMatcherSubRule<"is_parameter", [ParmVar]>,
398 // unless(is_parameter)
399 AttrSubjectMatcherSubRule<"is_parameter", [NonParmVar], 1>
401 def SubjectMatcherForField : AttrSubjectMatcherRule<"field", [Field]>;
402 def SubjectMatcherForNamespace : AttrSubjectMatcherRule<"namespace",
404 let LangOpts = [CPlusPlus];
406 def SubjectMatcherForObjCInterface : AttrSubjectMatcherRule<"objc_interface",
408 let LangOpts = [ObjC];
410 def SubjectMatcherForObjCProtocol : AttrSubjectMatcherRule<"objc_protocol",
412 let LangOpts = [ObjC];
414 def SubjectMatcherForObjCCategory : AttrSubjectMatcherRule<"objc_category",
416 let LangOpts = [ObjC];
418 def SubjectMatcherForObjCMethod : AttrSubjectMatcherRule<"objc_method",
420 AttrSubjectMatcherSubRule<"is_instance", [ObjCInstanceMethod]>
422 let LangOpts = [ObjC];
424 def SubjectMatcherForObjCProperty : AttrSubjectMatcherRule<"objc_property",
426 let LangOpts = [ObjC];
428 def SubjectMatcherForBlock : AttrSubjectMatcherRule<"block", [Block]> {
429 let LangOpts = [BlocksSupported];
432 // Aggregate attribute subject match rules are abstract match rules that can't
433 // be used directly in #pragma clang attribute. Instead, users have to use
434 // subject match rules that correspond to attribute subjects that derive from
435 // the specified subject.
436 class AttrSubjectMatcherAggregateRule<AttrSubject subject> {
437 AttrSubject Subject = subject;
440 def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule<Named>;
443 // The various ways in which an attribute can be spelled in source
444 list<Spelling> Spellings;
445 // The things to which an attribute can appertain
446 SubjectList Subjects;
447 // The arguments allowed on an attribute
448 list<Argument> Args = [];
449 // Accessors which should be generated for the attribute.
450 list<Accessor> Accessors = [];
451 // Set to true for attributes with arguments which require delayed parsing.
453 // Set to false to prevent an attribute from being propagated from a template
454 // to the instantiation.
456 // Set to true for attributes which must be instantiated within templates
457 bit TemplateDependent = 0;
458 // Set to true for attributes that have a corresponding AST node.
460 // Set to true for attributes which have handler in Sema.
462 // Set to true for attributes that are completely ignored.
464 // Set to true if the attribute's parsing does not match its semantic
465 // content. Eg) It parses 3 args, but semantically takes 4 args. Opts out of
466 // common attribute error checking.
467 bit HasCustomParsing = 0;
468 // Set to true if all of the attribute's arguments should be parsed in an
469 // unevaluated context.
470 bit ParseArgumentsAsUnevaluated = 0;
471 // Set to true if this attribute meaningful when applied to or inherited
472 // in a class template definition.
473 bit MeaningfulToClassTemplateDefinition = 0;
474 // Set to true if this attribute can be used with '#pragma clang attribute'.
475 // By default, an attribute is supported by the '#pragma clang attribute'
477 // - It has a subject list whose subjects can be represented using subject
479 // - It has GNU/CXX11 spelling and doesn't require delayed parsing.
480 bit PragmaAttributeSupport;
481 // Lists language options, one of which is required to be true for the
482 // attribute to be applicable. If empty, no language options are required.
483 list<LangOpt> LangOpts = [];
484 // Any additional text that should be included verbatim in the class.
485 // Note: Any additional data members will leak and should be constructed
486 // externally on the ASTContext.
487 code AdditionalMembers = [{}];
488 // Any documentation that should be associated with the attribute. Since an
489 // attribute may be documented under multiple categories, more than one
490 // Documentation entry may be listed.
491 list<Documentation> Documentation;
494 /// A type attribute is not processed on a declaration or a statement.
495 class TypeAttr : Attr;
497 /// A stmt attribute is not processed on a declaration or a type.
498 class StmtAttr : Attr;
500 /// An inheritable attribute is inherited by later redeclarations.
501 class InheritableAttr : Attr {
502 // Set to true if this attribute can be duplicated on a subject when inheriting
503 // attributes from prior declarations.
504 bit InheritEvenIfAlreadyPresent = 0;
507 /// Some attributes, like calling conventions, can appear in either the
508 /// declaration or the type position. These attributes are morally type
509 /// attributes, but have historically been written on declarations.
510 class DeclOrTypeAttr : InheritableAttr;
512 /// A target-specific attribute. This class is meant to be used as a mixin
513 /// with InheritableAttr or Attr depending on the attribute's needs.
514 class TargetSpecificAttr<TargetSpec target> {
515 TargetSpec Target = target;
516 // Attributes are generally required to have unique spellings for their names
517 // so that the parser can determine what kind of attribute it has parsed.
518 // However, target-specific attributes are special in that the attribute only
519 // "exists" for a given target. So two target-specific attributes can share
520 // the same name when they exist in different targets. To support this, a
521 // Kind can be explicitly specified for a target-specific attribute. This
522 // corresponds to the ParsedAttr::AT_* enum that is generated and it
523 // should contain a shared value between the attributes.
525 // Target-specific attributes which use this feature should ensure that the
526 // spellings match exactly between the attributes, and if the arguments or
527 // subjects differ, should specify HasCustomParsing = 1 and implement their
528 // own parsing and semantic handling requirements as-needed.
532 /// An inheritable parameter attribute is inherited by later
533 /// redeclarations, even when it's written on a parameter.
534 class InheritableParamAttr : InheritableAttr;
536 /// An attribute which changes the ABI rules for a specific parameter.
537 class ParameterABIAttr : InheritableParamAttr {
538 let Subjects = SubjectList<[ParmVar]>;
541 /// An ignored attribute, which we parse but discard with no checking.
542 class IgnoredAttr : Attr {
546 let Documentation = [Undocumented];
550 // Attributes begin here
554 let Spellings = [GCC<"abi_tag">];
555 let Args = [VariadicStringArgument<"Tags">];
556 let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag>;
557 let MeaningfulToClassTemplateDefinition = 1;
558 let Documentation = [AbiTagsDocs];
561 def AddressSpace : TypeAttr {
562 let Spellings = [Clang<"address_space">];
563 let Args = [IntArgument<"AddressSpace">];
564 let Documentation = [Undocumented];
568 let Spellings = [GCC<"alias">];
569 let Args = [StringArgument<"Aliasee">];
570 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
571 let Documentation = [Undocumented];
574 def Aligned : InheritableAttr {
575 let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">,
576 Keyword<"_Alignas">];
577 let Args = [AlignedArgument<"Alignment", 1>];
578 let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
579 Accessor<"isC11", [Keyword<"_Alignas">]>,
580 Accessor<"isAlignas", [Keyword<"alignas">,
581 Keyword<"_Alignas">]>,
582 Accessor<"isDeclspec",[Declspec<"align">]>];
583 let Documentation = [Undocumented];
586 def AlignValue : Attr {
588 // Unfortunately, this is semantically an assertion, not a directive
589 // (something else must ensure the alignment), so aligned_value is a
590 // probably a better name. We might want to add an aligned_value spelling in
591 // the future (and a corresponding C++ attribute), but this can be done
592 // later once we decide if we also want them to have slightly-different
593 // semantics than Intel's align_value.
595 // Does not get a [[]] spelling because the attribute is not exposed as such
598 // Intel's compiler on Windows also supports:
599 // , Declspec<"align_value">
601 let Args = [ExprArgument<"Alignment">];
602 let Subjects = SubjectList<[Var, TypedefName]>;
603 let Documentation = [AlignValueDocs];
606 def AlignMac68k : InheritableAttr {
607 // This attribute has no spellings as it is only ever created implicitly.
610 let Documentation = [Undocumented];
613 def AlwaysInline : InheritableAttr {
614 let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
615 let Subjects = SubjectList<[Function]>;
616 let Documentation = [Undocumented];
619 def Artificial : InheritableAttr {
620 let Spellings = [GCC<"artificial">];
621 let Subjects = SubjectList<[InlineFunction], WarnDiag>;
622 let Documentation = [ArtificialDocs];
625 def XRayInstrument : InheritableAttr {
626 let Spellings = [Clang<"xray_always_instrument">,
627 Clang<"xray_never_instrument">];
628 let Subjects = SubjectList<[Function, ObjCMethod]>;
629 let Accessors = [Accessor<"alwaysXRayInstrument",
630 [Clang<"xray_always_instrument">]>,
631 Accessor<"neverXRayInstrument",
632 [Clang<"xray_never_instrument">]>];
633 let Documentation = [XRayDocs];
636 def XRayLogArgs : InheritableAttr {
637 let Spellings = [Clang<"xray_log_args">];
638 let Subjects = SubjectList<[Function, ObjCMethod]>;
639 // This argument is a count not an index, so it has the same encoding (base
640 // 1 including C++ implicit this parameter) at the source and LLVM levels of
641 // representation, so ParamIdxArgument is inappropriate. It is never used
642 // at the AST level of representation, so it never needs to be adjusted not
643 // to include any C++ implicit this parameter. Thus, we just store it and
644 // use it as an unsigned that never needs adjustment.
645 let Args = [UnsignedArgument<"ArgumentCount">];
646 let Documentation = [XRayDocs];
649 def TLSModel : InheritableAttr {
650 let Spellings = [GCC<"tls_model">];
651 let Subjects = SubjectList<[TLSVar], ErrorDiag>;
652 let Args = [StringArgument<"Model">];
653 let Documentation = [TLSModelDocs];
656 def AnalyzerNoReturn : InheritableAttr {
657 // TODO: should this attribute be exposed with a [[]] spelling under the clang
658 // vendor namespace, or should it use a vendor namespace specific to the
660 let Spellings = [GNU<"analyzer_noreturn">];
661 // TODO: Add subject list.
662 let Documentation = [Undocumented];
665 def Annotate : InheritableParamAttr {
666 let Spellings = [Clang<"annotate">];
667 let Args = [StringArgument<"Annotation">];
668 // Ensure that the annotate attribute can be used with
669 // '#pragma clang attribute' even though it has no subject list.
670 let PragmaAttributeSupport = 1;
671 let Documentation = [Undocumented];
674 def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> {
675 // NOTE: If you add any additional spellings, MSP430Interrupt's,
676 // MipsInterrupt's and AnyX86Interrupt's spellings must match.
677 let Spellings = [GCC<"interrupt">];
678 let Args = [EnumArgument<"Interrupt", "InterruptType",
679 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
680 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
682 let ParseKind = "Interrupt";
683 let HasCustomParsing = 1;
684 let Documentation = [ARMInterruptDocs];
687 def AVRInterrupt : InheritableAttr, TargetSpecificAttr<TargetAVR> {
688 let Spellings = [GCC<"interrupt">];
689 let Subjects = SubjectList<[Function]>;
690 let ParseKind = "Interrupt";
691 let Documentation = [AVRInterruptDocs];
694 def AVRSignal : InheritableAttr, TargetSpecificAttr<TargetAVR> {
695 let Spellings = [GCC<"signal">];
696 let Subjects = SubjectList<[Function]>;
697 let Documentation = [AVRSignalDocs];
700 def AsmLabel : InheritableAttr {
701 let Spellings = [Keyword<"asm">, Keyword<"__asm__">];
702 let Args = [StringArgument<"Label">];
704 let Documentation = [Undocumented];
707 def Availability : InheritableAttr {
708 let Spellings = [Clang<"availability">];
709 let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
710 VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
711 BoolArgument<"unavailable">, StringArgument<"message">,
712 BoolArgument<"strict">, StringArgument<"replacement">];
713 let AdditionalMembers =
714 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
715 return llvm::StringSwitch<llvm::StringRef>(Platform)
716 .Case("android", "Android")
718 .Case("macos", "macOS")
719 .Case("tvos", "tvOS")
720 .Case("watchos", "watchOS")
721 .Case("ios_app_extension", "iOS (App Extension)")
722 .Case("macos_app_extension", "macOS (App Extension)")
723 .Case("tvos_app_extension", "tvOS (App Extension)")
724 .Case("watchos_app_extension", "watchOS (App Extension)")
725 .Case("swift", "Swift")
726 .Default(llvm::StringRef());
728 static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) {
729 return llvm::StringSwitch<llvm::StringRef>(Platform)
731 .Case("macos", "macOS")
732 .Case("tvos", "tvOS")
733 .Case("watchos", "watchOS")
734 .Case("ios_app_extension", "iOSApplicationExtension")
735 .Case("macos_app_extension", "macOSApplicationExtension")
736 .Case("tvos_app_extension", "tvOSApplicationExtension")
737 .Case("watchos_app_extension", "watchOSApplicationExtension")
740 static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) {
741 return llvm::StringSwitch<llvm::StringRef>(Platform)
743 .Case("macOS", "macos")
744 .Case("tvOS", "tvos")
745 .Case("watchOS", "watchos")
746 .Case("iOSApplicationExtension", "ios_app_extension")
747 .Case("macOSApplicationExtension", "macos_app_extension")
748 .Case("tvOSApplicationExtension", "tvos_app_extension")
749 .Case("watchOSApplicationExtension", "watchos_app_extension")
752 let HasCustomParsing = 1;
753 let InheritEvenIfAlreadyPresent = 1;
754 let Subjects = SubjectList<[Named]>;
755 let Documentation = [AvailabilityDocs];
758 def ExternalSourceSymbol : InheritableAttr {
759 let Spellings = [Clang<"external_source_symbol">];
760 let Args = [StringArgument<"language", 1>,
761 StringArgument<"definedIn", 1>,
762 BoolArgument<"generatedDeclaration", 1>];
763 let HasCustomParsing = 1;
764 let Subjects = SubjectList<[Named]>;
765 let Documentation = [ExternalSourceSymbolDocs];
768 def Blocks : InheritableAttr {
769 let Spellings = [Clang<"blocks">];
770 let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
771 let Documentation = [Undocumented];
774 def Bounded : IgnoredAttr {
775 // Does not have a [[]] spelling because the attribute is ignored.
776 let Spellings = [GNU<"bounded">];
779 def CarriesDependency : InheritableParamAttr {
780 let Spellings = [GNU<"carries_dependency">,
781 CXX11<"","carries_dependency", 200809>];
782 let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>;
783 let Documentation = [CarriesDependencyDocs];
786 def CDecl : DeclOrTypeAttr {
787 let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">];
788 // let Subjects = [Function, ObjCMethod];
789 let Documentation = [Undocumented];
792 // cf_audited_transfer indicates that the given function has been
793 // audited and has been marked with the appropriate cf_consumed and
794 // cf_returns_retained attributes. It is generally applied by
795 // '#pragma clang arc_cf_code_audited' rather than explicitly.
796 def CFAuditedTransfer : InheritableAttr {
797 let Spellings = [Clang<"cf_audited_transfer">];
798 let Subjects = SubjectList<[Function], ErrorDiag>;
799 let Documentation = [Undocumented];
802 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
803 // It indicates that the function has unknown or unautomatable
804 // transfer semantics.
805 def CFUnknownTransfer : InheritableAttr {
806 let Spellings = [Clang<"cf_unknown_transfer">];
807 let Subjects = SubjectList<[Function], ErrorDiag>;
808 let Documentation = [Undocumented];
811 def CFReturnsRetained : InheritableAttr {
812 let Spellings = [Clang<"cf_returns_retained">];
813 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
814 let Documentation = [RetainBehaviorDocs];
817 def CFReturnsNotRetained : InheritableAttr {
818 let Spellings = [Clang<"cf_returns_not_retained">];
819 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
820 let Documentation = [RetainBehaviorDocs];
823 def CFConsumed : InheritableParamAttr {
824 let Spellings = [Clang<"cf_consumed">];
825 let Subjects = SubjectList<[ParmVar]>;
826 let Documentation = [RetainBehaviorDocs];
829 // OSObject-based attributes.
830 def OSConsumed : InheritableParamAttr {
831 let Spellings = [Clang<"os_consumed">];
832 let Subjects = SubjectList<[ParmVar]>;
833 let Documentation = [RetainBehaviorDocs];
836 def OSReturnsRetained : InheritableAttr {
837 let Spellings = [Clang<"os_returns_retained">];
838 let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty, ParmVar]>;
839 let Documentation = [RetainBehaviorDocs];
842 def OSReturnsNotRetained : InheritableAttr {
843 let Spellings = [Clang<"os_returns_not_retained">];
844 let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty, ParmVar]>;
845 let Documentation = [RetainBehaviorDocs];
848 def OSReturnsRetainedOnZero : InheritableAttr {
849 let Spellings = [Clang<"os_returns_retained_on_zero">];
850 let Subjects = SubjectList<[ParmVar]>;
851 let Documentation = [RetainBehaviorDocs];
854 def OSReturnsRetainedOnNonZero : InheritableAttr {
855 let Spellings = [Clang<"os_returns_retained_on_non_zero">];
856 let Subjects = SubjectList<[ParmVar]>;
857 let Documentation = [RetainBehaviorDocs];
860 def OSConsumesThis : InheritableAttr {
861 let Spellings = [Clang<"os_consumes_this">];
862 let Subjects = SubjectList<[NonStaticCXXMethod]>;
863 let Documentation = [RetainBehaviorDocs];
866 def Cleanup : InheritableAttr {
867 let Spellings = [GCC<"cleanup">];
868 let Args = [FunctionArgument<"FunctionDecl">];
869 let Subjects = SubjectList<[LocalVar]>;
870 let Documentation = [Undocumented];
873 def Cold : InheritableAttr {
874 let Spellings = [GCC<"cold">];
875 let Subjects = SubjectList<[Function]>;
876 let Documentation = [Undocumented];
879 def Common : InheritableAttr {
880 let Spellings = [GCC<"common">];
881 let Subjects = SubjectList<[Var]>;
882 let Documentation = [Undocumented];
885 def Const : InheritableAttr {
886 let Spellings = [GCC<"const">, GCC<"__const">];
887 let Documentation = [Undocumented];
890 def Constructor : InheritableAttr {
891 let Spellings = [GCC<"constructor">];
892 let Args = [DefaultIntArgument<"Priority", 65535>];
893 let Subjects = SubjectList<[Function]>;
894 let Documentation = [Undocumented];
897 def CPUSpecific : InheritableAttr {
898 let Spellings = [Clang<"cpu_specific">, Declspec<"cpu_specific">];
899 let Args = [VariadicIdentifierArgument<"Cpus">];
900 let Subjects = SubjectList<[Function]>;
901 let Documentation = [CPUSpecificCPUDispatchDocs];
902 let AdditionalMembers = [{
903 IdentifierInfo *getCPUName(unsigned Index) const {
904 return *(cpus_begin() + Index);
909 def CPUDispatch : InheritableAttr {
910 let Spellings = [Clang<"cpu_dispatch">, Declspec<"cpu_dispatch">];
911 let Args = [VariadicIdentifierArgument<"Cpus">];
912 let Subjects = SubjectList<[Function]>;
913 let Documentation = [CPUSpecificCPUDispatchDocs];
916 // CUDA attributes are spelled __attribute__((attr)) or __declspec(__attr__),
917 // and they do not receive a [[]] spelling.
918 def CUDAConstant : InheritableAttr {
919 let Spellings = [GNU<"constant">, Declspec<"__constant__">];
920 let Subjects = SubjectList<[Var]>;
921 let LangOpts = [CUDA];
922 let Documentation = [Undocumented];
925 def CUDACudartBuiltin : IgnoredAttr {
926 let Spellings = [GNU<"cudart_builtin">, Declspec<"__cudart_builtin__">];
927 let LangOpts = [CUDA];
930 def CUDADevice : InheritableAttr {
931 let Spellings = [GNU<"device">, Declspec<"__device__">];
932 let Subjects = SubjectList<[Function, Var]>;
933 let LangOpts = [CUDA];
934 let Documentation = [Undocumented];
937 def CUDADeviceBuiltin : IgnoredAttr {
938 let Spellings = [GNU<"device_builtin">, Declspec<"__device_builtin__">];
939 let LangOpts = [CUDA];
942 def CUDADeviceBuiltinSurfaceType : IgnoredAttr {
943 let Spellings = [GNU<"device_builtin_surface_type">,
944 Declspec<"__device_builtin_surface_type__">];
945 let LangOpts = [CUDA];
948 def CUDADeviceBuiltinTextureType : IgnoredAttr {
949 let Spellings = [GNU<"device_builtin_texture_type">,
950 Declspec<"__device_builtin_texture_type__">];
951 let LangOpts = [CUDA];
954 def CUDAGlobal : InheritableAttr {
955 let Spellings = [GNU<"global">, Declspec<"__global__">];
956 let Subjects = SubjectList<[Function]>;
957 let LangOpts = [CUDA];
958 let Documentation = [Undocumented];
961 def CUDAHost : InheritableAttr {
962 let Spellings = [GNU<"host">, Declspec<"__host__">];
963 let Subjects = SubjectList<[Function]>;
964 let LangOpts = [CUDA];
965 let Documentation = [Undocumented];
968 def CUDAInvalidTarget : InheritableAttr {
970 let Subjects = SubjectList<[Function]>;
971 let LangOpts = [CUDA];
972 let Documentation = [Undocumented];
975 def CUDALaunchBounds : InheritableAttr {
976 let Spellings = [GNU<"launch_bounds">, Declspec<"__launch_bounds__">];
977 let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>];
978 let LangOpts = [CUDA];
979 let Subjects = SubjectList<[ObjCMethod, FunctionLike]>;
980 // An AST node is created for this attribute, but is not used by other parts
981 // of the compiler. However, this node needs to exist in the AST because
982 // non-LLVM backends may be relying on the attribute's presence.
983 let Documentation = [Undocumented];
986 def CUDAShared : InheritableAttr {
987 let Spellings = [GNU<"shared">, Declspec<"__shared__">];
988 let Subjects = SubjectList<[Var]>;
989 let LangOpts = [CUDA];
990 let Documentation = [Undocumented];
993 def C11NoReturn : InheritableAttr {
994 let Spellings = [Keyword<"_Noreturn">];
995 let Subjects = SubjectList<[Function], ErrorDiag>;
997 let Documentation = [C11NoReturnDocs];
1000 def CXX11NoReturn : InheritableAttr {
1001 let Spellings = [CXX11<"", "noreturn", 200809>];
1002 let Subjects = SubjectList<[Function], ErrorDiag>;
1003 let Documentation = [CXX11NoReturnDocs];
1006 // Similar to CUDA, OpenCL attributes do not receive a [[]] spelling because
1007 // the specification does not expose them with one currently.
1008 def OpenCLKernel : InheritableAttr {
1009 let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
1010 let Subjects = SubjectList<[Function], ErrorDiag>;
1011 let Documentation = [Undocumented];
1014 def OpenCLUnrollHint : InheritableAttr {
1015 let Spellings = [GNU<"opencl_unroll_hint">];
1016 let Args = [UnsignedArgument<"UnrollHint">];
1017 let Documentation = [OpenCLUnrollHintDocs];
1020 def OpenCLIntelReqdSubGroupSize: InheritableAttr {
1021 let Spellings = [GNU<"intel_reqd_sub_group_size">];
1022 let Args = [UnsignedArgument<"SubGroupSize">];
1023 let Subjects = SubjectList<[Function], ErrorDiag>;
1024 let Documentation = [OpenCLIntelReqdSubGroupSizeDocs];
1027 // This attribute is both a type attribute, and a declaration attribute (for
1028 // parameter variables).
1029 def OpenCLAccess : Attr {
1030 let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
1031 Keyword<"__write_only">, Keyword<"write_only">,
1032 Keyword<"__read_write">, Keyword<"read_write">];
1033 let Subjects = SubjectList<[ParmVar, TypedefName], ErrorDiag>;
1034 let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
1035 Keyword<"read_only">]>,
1036 Accessor<"isReadWrite", [Keyword<"__read_write">,
1037 Keyword<"read_write">]>,
1038 Accessor<"isWriteOnly", [Keyword<"__write_only">,
1039 Keyword<"write_only">]>];
1040 let Documentation = [OpenCLAccessDocs];
1043 def OpenCLPrivateAddressSpace : TypeAttr {
1044 let Spellings = [Keyword<"__private">, Keyword<"private">];
1045 let Documentation = [OpenCLAddressSpacePrivateDocs];
1048 def OpenCLGlobalAddressSpace : TypeAttr {
1049 let Spellings = [Keyword<"__global">, Keyword<"global">];
1050 let Documentation = [OpenCLAddressSpaceGlobalDocs];
1053 def OpenCLLocalAddressSpace : TypeAttr {
1054 let Spellings = [Keyword<"__local">, Keyword<"local">];
1055 let Documentation = [OpenCLAddressSpaceLocalDocs];
1058 def OpenCLConstantAddressSpace : TypeAttr {
1059 let Spellings = [Keyword<"__constant">, Keyword<"constant">];
1060 let Documentation = [OpenCLAddressSpaceConstantDocs];
1063 def OpenCLGenericAddressSpace : TypeAttr {
1064 let Spellings = [Keyword<"__generic">, Keyword<"generic">];
1065 let Documentation = [OpenCLAddressSpaceGenericDocs];
1068 def OpenCLNoSVM : Attr {
1069 let Spellings = [GNU<"nosvm">];
1070 let Subjects = SubjectList<[Var]>;
1071 let Documentation = [OpenCLNoSVMDocs];
1072 let LangOpts = [OpenCL];
1076 def RenderScriptKernel : Attr {
1077 let Spellings = [GNU<"kernel">];
1078 let Subjects = SubjectList<[Function]>;
1079 let Documentation = [RenderScriptKernelAttributeDocs];
1080 let LangOpts = [RenderScript];
1083 def Deprecated : InheritableAttr {
1084 let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
1085 CXX11<"","deprecated", 201309>, C2x<"", "deprecated">];
1086 let Args = [StringArgument<"Message", 1>,
1087 // An optional string argument that enables us to provide a
1089 StringArgument<"Replacement", 1>];
1090 let MeaningfulToClassTemplateDefinition = 1;
1091 let Documentation = [DeprecatedDocs];
1094 def Destructor : InheritableAttr {
1095 let Spellings = [GCC<"destructor">];
1096 let Args = [DefaultIntArgument<"Priority", 65535>];
1097 let Subjects = SubjectList<[Function]>;
1098 let Documentation = [Undocumented];
1101 def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
1102 let Spellings = [Declspec<"empty_bases">];
1103 let Subjects = SubjectList<[CXXRecord]>;
1104 let Documentation = [EmptyBasesDocs];
1107 def AllocSize : InheritableAttr {
1108 let Spellings = [GCC<"alloc_size">];
1109 let Subjects = SubjectList<[Function]>;
1110 let Args = [ParamIdxArgument<"ElemSizeParam">,
1111 ParamIdxArgument<"NumElemsParam", /*opt*/ 1>];
1112 let TemplateDependent = 1;
1113 let Documentation = [AllocSizeDocs];
1116 def EnableIf : InheritableAttr {
1117 // Does not have a [[]] spelling because this attribute requires the ability
1118 // to parse function arguments but the attribute is not written in the type
1120 let Spellings = [GNU<"enable_if">];
1121 let Subjects = SubjectList<[Function]>;
1122 let Args = [ExprArgument<"Cond">, StringArgument<"Message">];
1123 let TemplateDependent = 1;
1124 let Documentation = [EnableIfDocs];
1127 def ExtVectorType : Attr {
1128 // This is an OpenCL-related attribute and does not receive a [[]] spelling.
1129 let Spellings = [GNU<"ext_vector_type">];
1130 // FIXME: This subject list is wrong; this is a type attribute.
1131 let Subjects = SubjectList<[TypedefName], ErrorDiag>;
1132 let Args = [ExprArgument<"NumElements">];
1134 let Documentation = [Undocumented];
1135 // This is a type attribute with an incorrect subject list, so should not be
1136 // permitted by #pragma clang attribute.
1137 let PragmaAttributeSupport = 0;
1140 def FallThrough : StmtAttr {
1141 let Spellings = [CXX11<"", "fallthrough", 201603>, C2x<"", "fallthrough">,
1142 CXX11<"clang", "fallthrough">];
1143 // let Subjects = [NullStmt];
1144 let Documentation = [FallthroughDocs];
1147 def FastCall : DeclOrTypeAttr {
1148 let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
1149 Keyword<"_fastcall">];
1150 // let Subjects = [Function, ObjCMethod];
1151 let Documentation = [FastCallDocs];
1154 def RegCall : DeclOrTypeAttr {
1155 let Spellings = [GCC<"regcall">, Keyword<"__regcall">];
1156 let Documentation = [RegCallDocs];
1159 def Final : InheritableAttr {
1160 let Spellings = [Keyword<"final">, Keyword<"sealed">];
1161 let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
1162 let SemaHandler = 0;
1163 let Documentation = [Undocumented];
1166 def MinSize : InheritableAttr {
1167 let Spellings = [Clang<"minsize">];
1168 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
1169 let Documentation = [Undocumented];
1172 def FlagEnum : InheritableAttr {
1173 let Spellings = [Clang<"flag_enum">];
1174 let Subjects = SubjectList<[Enum]>;
1175 let Documentation = [FlagEnumDocs];
1178 def EnumExtensibility : InheritableAttr {
1179 let Spellings = [Clang<"enum_extensibility">];
1180 let Subjects = SubjectList<[Enum]>;
1181 let Args = [EnumArgument<"Extensibility", "Kind",
1182 ["closed", "open"], ["Closed", "Open"]>];
1183 let Documentation = [EnumExtensibilityDocs];
1186 def Flatten : InheritableAttr {
1187 let Spellings = [GCC<"flatten">];
1188 let Subjects = SubjectList<[Function], ErrorDiag>;
1189 let Documentation = [FlattenDocs];
1192 def Format : InheritableAttr {
1193 let Spellings = [GCC<"format">];
1194 let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
1195 IntArgument<"FirstArg">];
1196 let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto]>;
1197 let Documentation = [FormatDocs];
1200 def FormatArg : InheritableAttr {
1201 let Spellings = [GCC<"format_arg">];
1202 let Args = [ParamIdxArgument<"FormatIdx">];
1203 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto]>;
1204 let Documentation = [Undocumented];
1207 def GNUInline : InheritableAttr {
1208 let Spellings = [GCC<"gnu_inline">];
1209 let Subjects = SubjectList<[Function]>;
1210 let Documentation = [GnuInlineDocs];
1213 def Hot : InheritableAttr {
1214 let Spellings = [GCC<"hot">];
1215 let Subjects = SubjectList<[Function]>;
1216 // An AST node is created for this attribute, but not actually used beyond
1217 // semantic checking for mutual exclusion with the Cold attribute.
1218 let Documentation = [Undocumented];
1221 def IBAction : InheritableAttr {
1222 let Spellings = [Clang<"ibaction">];
1223 let Subjects = SubjectList<[ObjCInstanceMethod]>;
1224 // An AST node is created for this attribute, but is not used by other parts
1225 // of the compiler. However, this node needs to exist in the AST because
1226 // external tools rely on it.
1227 let Documentation = [Undocumented];
1230 def IBOutlet : InheritableAttr {
1231 let Spellings = [Clang<"iboutlet">];
1232 // let Subjects = [ObjCIvar, ObjCProperty];
1233 let Documentation = [Undocumented];
1236 def IBOutletCollection : InheritableAttr {
1237 let Spellings = [Clang<"iboutletcollection">];
1238 let Args = [TypeArgument<"Interface", 1>];
1239 // let Subjects = [ObjCIvar, ObjCProperty];
1240 let Documentation = [Undocumented];
1243 def IFunc : Attr, TargetSpecificAttr<TargetELF> {
1244 let Spellings = [GCC<"ifunc">];
1245 let Args = [StringArgument<"Resolver">];
1246 let Subjects = SubjectList<[Function]>;
1247 let Documentation = [IFuncDocs];
1250 def Restrict : InheritableAttr {
1251 let Spellings = [Declspec<"restrict">, GCC<"malloc">];
1252 let Subjects = SubjectList<[Function]>;
1253 let Documentation = [Undocumented];
1256 def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
1257 let Spellings = [Declspec<"layout_version">];
1258 let Args = [UnsignedArgument<"Version">];
1259 let Subjects = SubjectList<[CXXRecord]>;
1260 let Documentation = [LayoutVersionDocs];
1263 def LifetimeBound : DeclOrTypeAttr {
1264 let Spellings = [Clang<"lifetimebound", 0>];
1265 let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;
1266 let Documentation = [LifetimeBoundDocs];
1267 let LangOpts = [CPlusPlus];
1270 def TrivialABI : InheritableAttr {
1271 // This attribute does not have a C [[]] spelling because it requires the
1272 // CPlusPlus language option.
1273 let Spellings = [Clang<"trivial_abi", 0>];
1274 let Subjects = SubjectList<[CXXRecord]>;
1275 let Documentation = [TrivialABIDocs];
1276 let LangOpts = [CPlusPlus];
1279 def MaxFieldAlignment : InheritableAttr {
1280 // This attribute has no spellings as it is only ever created implicitly.
1282 let Args = [UnsignedArgument<"Alignment">];
1283 let SemaHandler = 0;
1284 let Documentation = [Undocumented];
1287 def MayAlias : InheritableAttr {
1288 // FIXME: this is a type attribute in GCC, but a declaration attribute here.
1289 let Spellings = [GCC<"may_alias">];
1290 let Documentation = [Undocumented];
1293 def MSABI : DeclOrTypeAttr {
1294 let Spellings = [GCC<"ms_abi">];
1295 // let Subjects = [Function, ObjCMethod];
1296 let Documentation = [MSABIDocs];
1299 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
1300 // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's
1301 // and AnyX86Interrupt's spellings must match.
1302 let Spellings = [GCC<"interrupt">];
1303 let Args = [UnsignedArgument<"Number">];
1304 let ParseKind = "Interrupt";
1305 let HasCustomParsing = 1;
1306 let Documentation = [Undocumented];
1309 def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1310 let Spellings = [GCC<"mips16">];
1311 let Subjects = SubjectList<[Function], ErrorDiag>;
1312 let Documentation = [Undocumented];
1315 def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1316 // NOTE: If you add any additional spellings, ARMInterrupt's,
1317 // MSP430Interrupt's and AnyX86Interrupt's spellings must match.
1318 let Spellings = [GCC<"interrupt">];
1319 let Subjects = SubjectList<[Function]>;
1320 let Args = [EnumArgument<"Interrupt", "InterruptType",
1321 ["vector=sw0", "vector=sw1", "vector=hw0",
1322 "vector=hw1", "vector=hw2", "vector=hw3",
1323 "vector=hw4", "vector=hw5", "eic", ""],
1324 ["sw0", "sw1", "hw0", "hw1", "hw2", "hw3",
1325 "hw4", "hw5", "eic", "eic"]
1327 let ParseKind = "Interrupt";
1328 let Documentation = [MipsInterruptDocs];
1331 def MicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1332 let Spellings = [GCC<"micromips">];
1333 let Subjects = SubjectList<[Function], ErrorDiag>;
1334 let Documentation = [MicroMipsDocs];
1337 def MipsLongCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
1338 let Spellings = [GCC<"long_call">, GCC<"far">];
1339 let Subjects = SubjectList<[Function]>;
1340 let Documentation = [MipsLongCallStyleDocs];
1343 def MipsShortCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
1344 let Spellings = [GCC<"short_call">, GCC<"near">];
1345 let Subjects = SubjectList<[Function]>;
1346 let Documentation = [MipsShortCallStyleDocs];
1350 let Spellings = [GCC<"mode">];
1351 let Subjects = SubjectList<[Var, Enum, TypedefName, Field], ErrorDiag>;
1352 let Args = [IdentifierArgument<"Mode">];
1353 let Documentation = [Undocumented];
1354 // This is notionally a type attribute, which #pragma clang attribute
1355 // generally does not support.
1356 let PragmaAttributeSupport = 0;
1359 def Naked : InheritableAttr {
1360 let Spellings = [GCC<"naked">, Declspec<"naked">];
1361 let Subjects = SubjectList<[Function]>;
1362 let Documentation = [Undocumented];
1365 def NeonPolyVectorType : TypeAttr {
1366 let Spellings = [Clang<"neon_polyvector_type">];
1367 let Args = [IntArgument<"NumElements">];
1368 let Documentation = [Undocumented];
1369 // Represented as VectorType instead.
1373 def NeonVectorType : TypeAttr {
1374 let Spellings = [Clang<"neon_vector_type">];
1375 let Args = [IntArgument<"NumElements">];
1376 let Documentation = [Undocumented];
1377 // Represented as VectorType instead.
1381 def ReturnsTwice : InheritableAttr {
1382 let Spellings = [GCC<"returns_twice">];
1383 let Subjects = SubjectList<[Function]>;
1384 let Documentation = [Undocumented];
1387 def DisableTailCalls : InheritableAttr {
1388 let Spellings = [Clang<"disable_tail_calls">];
1389 let Subjects = SubjectList<[Function, ObjCMethod]>;
1390 let Documentation = [DisableTailCallsDocs];
1393 def NoAlias : InheritableAttr {
1394 let Spellings = [Declspec<"noalias">];
1395 let Subjects = SubjectList<[Function]>;
1396 let Documentation = [NoAliasDocs];
1399 def NoCommon : InheritableAttr {
1400 let Spellings = [GCC<"nocommon">];
1401 let Subjects = SubjectList<[Var]>;
1402 let Documentation = [Undocumented];
1405 def NoDebug : InheritableAttr {
1406 let Spellings = [GCC<"nodebug">];
1407 let Subjects = SubjectList<[FunctionLike, ObjCMethod, NonParmVar]>;
1408 let Documentation = [NoDebugDocs];
1411 def NoDuplicate : InheritableAttr {
1412 let Spellings = [Clang<"noduplicate">];
1413 let Subjects = SubjectList<[Function]>;
1414 let Documentation = [NoDuplicateDocs];
1417 def Convergent : InheritableAttr {
1418 let Spellings = [Clang<"convergent">];
1419 let Subjects = SubjectList<[Function]>;
1420 let Documentation = [ConvergentDocs];
1423 def NoInline : InheritableAttr {
1424 let Spellings = [GCC<"noinline">, Declspec<"noinline">];
1425 let Subjects = SubjectList<[Function]>;
1426 let Documentation = [Undocumented];
1429 def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1430 let Spellings = [GCC<"nomips16">];
1431 let Subjects = SubjectList<[Function], ErrorDiag>;
1432 let Documentation = [Undocumented];
1435 def NoMicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1436 let Spellings = [GCC<"nomicromips">];
1437 let Subjects = SubjectList<[Function], ErrorDiag>;
1438 let Documentation = [MicroMipsDocs];
1441 def RISCVInterrupt : InheritableAttr, TargetSpecificAttr<TargetRISCV> {
1442 let Spellings = [GCC<"interrupt">];
1443 let Subjects = SubjectList<[Function]>;
1444 let Args = [EnumArgument<"Interrupt", "InterruptType",
1445 ["user", "supervisor", "machine"],
1446 ["user", "supervisor", "machine"],
1448 let ParseKind = "Interrupt";
1449 let Documentation = [RISCVInterruptDocs];
1452 // This is not a TargetSpecificAttr so that is silently accepted and
1453 // ignored on other targets as encouraged by the OpenCL spec.
1455 // See OpenCL 1.2 6.11.5: "It is our intention that a particular
1456 // implementation of OpenCL be free to ignore all attributes and the
1457 // resulting executable binary will produce the same result."
1459 // However, only AMD GPU targets will emit the corresponding IR
1462 // FIXME: This provides a sub-optimal error message if you attempt to
1463 // use this in CUDA, since CUDA does not use the same terminology.
1465 // FIXME: SubjectList should be for OpenCLKernelFunction, but is not to
1466 // workaround needing to see kernel attribute before others to know if
1467 // this should be rejected on non-kernels.
1469 def AMDGPUFlatWorkGroupSize : InheritableAttr {
1470 let Spellings = [Clang<"amdgpu_flat_work_group_size", 0>];
1471 let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max">];
1472 let Documentation = [AMDGPUFlatWorkGroupSizeDocs];
1473 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1476 def AMDGPUWavesPerEU : InheritableAttr {
1477 let Spellings = [Clang<"amdgpu_waves_per_eu", 0>];
1478 let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max", 1>];
1479 let Documentation = [AMDGPUWavesPerEUDocs];
1480 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1483 def AMDGPUNumSGPR : InheritableAttr {
1484 let Spellings = [Clang<"amdgpu_num_sgpr", 0>];
1485 let Args = [UnsignedArgument<"NumSGPR">];
1486 let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1487 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1490 def AMDGPUNumVGPR : InheritableAttr {
1491 let Spellings = [Clang<"amdgpu_num_vgpr", 0>];
1492 let Args = [UnsignedArgument<"NumVGPR">];
1493 let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1494 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1497 def WebAssemblyImportModule : InheritableAttr,
1498 TargetSpecificAttr<TargetWebAssembly> {
1499 let Spellings = [Clang<"import_module">];
1500 let Args = [StringArgument<"ImportModule">];
1501 let Documentation = [WebAssemblyImportModuleDocs];
1502 let Subjects = SubjectList<[Function], ErrorDiag>;
1505 def WebAssemblyImportName : InheritableAttr,
1506 TargetSpecificAttr<TargetWebAssembly> {
1507 let Spellings = [Clang<"import_name">];
1508 let Args = [StringArgument<"ImportName">];
1509 let Documentation = [WebAssemblyImportNameDocs];
1510 let Subjects = SubjectList<[Function], ErrorDiag>;
1513 def NoSplitStack : InheritableAttr {
1514 let Spellings = [GCC<"no_split_stack">];
1515 let Subjects = SubjectList<[Function], ErrorDiag>;
1516 let Documentation = [NoSplitStackDocs];
1519 def NonNull : InheritableParamAttr {
1520 let Spellings = [GCC<"nonnull">];
1521 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
1522 "functions, methods, and parameters">;
1523 let Args = [VariadicParamIdxArgument<"Args">];
1524 let AdditionalMembers = [{
1525 bool isNonNull(unsigned IdxAST) const {
1528 return args_end() != std::find_if(
1529 args_begin(), args_end(),
1530 [=](const ParamIdx &Idx) { return Idx.getASTIndex() == IdxAST; });
1533 // FIXME: We should merge duplicates into a single nonnull attribute.
1534 let InheritEvenIfAlreadyPresent = 1;
1535 let Documentation = [NonNullDocs];
1538 def ReturnsNonNull : InheritableAttr {
1539 let Spellings = [GCC<"returns_nonnull">];
1540 let Subjects = SubjectList<[ObjCMethod, Function]>;
1541 let Documentation = [ReturnsNonNullDocs];
1544 // pass_object_size(N) indicates that the parameter should have
1545 // __builtin_object_size with Type=N evaluated on the parameter at the callsite.
1546 def PassObjectSize : InheritableParamAttr {
1547 let Spellings = [Clang<"pass_object_size">];
1548 let Args = [IntArgument<"Type">];
1549 let Subjects = SubjectList<[ParmVar]>;
1550 let Documentation = [PassObjectSizeDocs];
1553 // Nullability type attributes.
1554 def TypeNonNull : TypeAttr {
1555 let Spellings = [Keyword<"_Nonnull">];
1556 let Documentation = [TypeNonNullDocs];
1559 def TypeNullable : TypeAttr {
1560 let Spellings = [Keyword<"_Nullable">];
1561 let Documentation = [TypeNullableDocs];
1564 def TypeNullUnspecified : TypeAttr {
1565 let Spellings = [Keyword<"_Null_unspecified">];
1566 let Documentation = [TypeNullUnspecifiedDocs];
1569 // This is a marker used to indicate that an __unsafe_unretained qualifier was
1570 // ignored because ARC is not enabled. The usual representation for this
1571 // qualifier is as an ObjCOwnership attribute with Kind == "none".
1572 def ObjCInertUnsafeUnretained : TypeAttr {
1573 let Spellings = [Keyword<"__unsafe_unretained">];
1574 let Documentation = [Undocumented];
1577 def ObjCKindOf : TypeAttr {
1578 let Spellings = [Keyword<"__kindof">];
1579 let Documentation = [Undocumented];
1582 def NoEscape : Attr {
1583 let Spellings = [Clang<"noescape">];
1584 let Subjects = SubjectList<[ParmVar]>;
1585 let Documentation = [NoEscapeDocs];
1588 def AssumeAligned : InheritableAttr {
1589 let Spellings = [GCC<"assume_aligned">];
1590 let Subjects = SubjectList<[ObjCMethod, Function]>;
1591 let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>];
1592 let Documentation = [AssumeAlignedDocs];
1595 def AllocAlign : InheritableAttr {
1596 let Spellings = [GCC<"alloc_align">];
1597 let Subjects = SubjectList<[HasFunctionProto]>;
1598 let Args = [ParamIdxArgument<"ParamIndex">];
1599 let Documentation = [AllocAlignDocs];
1602 def NoReturn : InheritableAttr {
1603 let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
1604 // FIXME: Does GCC allow this on the function instead?
1605 let Documentation = [Undocumented];
1608 def NoInstrumentFunction : InheritableAttr {
1609 let Spellings = [GCC<"no_instrument_function">];
1610 let Subjects = SubjectList<[Function]>;
1611 let Documentation = [Undocumented];
1614 def NotTailCalled : InheritableAttr {
1615 let Spellings = [Clang<"not_tail_called">];
1616 let Subjects = SubjectList<[Function]>;
1617 let Documentation = [NotTailCalledDocs];
1620 def NoStackProtector : InheritableAttr {
1621 let Spellings = [Clang<"no_stack_protector">];
1622 let Subjects = SubjectList<[Function]>;
1623 let Documentation = [NoStackProtectorDocs];
1626 def NoThrow : InheritableAttr {
1627 let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
1628 let Subjects = SubjectList<[Function]>;
1629 let Documentation = [NoThrowDocs];
1632 def NvWeak : IgnoredAttr {
1633 // No Declspec spelling of this attribute; the CUDA headers use
1634 // __attribute__((nv_weak)) unconditionally. Does not receive an [[]]
1635 // spelling because it is a CUDA attribute.
1636 let Spellings = [GNU<"nv_weak">];
1637 let LangOpts = [CUDA];
1640 def ObjCBridge : InheritableAttr {
1641 let Spellings = [Clang<"objc_bridge">];
1642 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag>;
1643 let Args = [IdentifierArgument<"BridgedType">];
1644 let Documentation = [Undocumented];
1647 def ObjCBridgeMutable : InheritableAttr {
1648 let Spellings = [Clang<"objc_bridge_mutable">];
1649 let Subjects = SubjectList<[Record], ErrorDiag>;
1650 let Args = [IdentifierArgument<"BridgedType">];
1651 let Documentation = [Undocumented];
1654 def ObjCBridgeRelated : InheritableAttr {
1655 let Spellings = [Clang<"objc_bridge_related">];
1656 let Subjects = SubjectList<[Record], ErrorDiag>;
1657 let Args = [IdentifierArgument<"RelatedClass">,
1658 IdentifierArgument<"ClassMethod">,
1659 IdentifierArgument<"InstanceMethod">];
1660 let HasCustomParsing = 1;
1661 let Documentation = [Undocumented];
1664 def NSReturnsRetained : DeclOrTypeAttr {
1665 let Spellings = [Clang<"ns_returns_retained">];
1666 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1667 let Documentation = [RetainBehaviorDocs];
1670 def NSReturnsNotRetained : InheritableAttr {
1671 let Spellings = [Clang<"ns_returns_not_retained">];
1672 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1673 let Documentation = [RetainBehaviorDocs];
1676 def NSReturnsAutoreleased : InheritableAttr {
1677 let Spellings = [Clang<"ns_returns_autoreleased">];
1678 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1679 let Documentation = [RetainBehaviorDocs];
1682 def NSConsumesSelf : InheritableAttr {
1683 let Spellings = [Clang<"ns_consumes_self">];
1684 let Subjects = SubjectList<[ObjCMethod]>;
1685 let Documentation = [RetainBehaviorDocs];
1688 def NSConsumed : InheritableParamAttr {
1689 let Spellings = [Clang<"ns_consumed">];
1690 let Subjects = SubjectList<[ParmVar]>;
1691 let Documentation = [RetainBehaviorDocs];
1694 def ObjCException : InheritableAttr {
1695 let Spellings = [Clang<"objc_exception">];
1696 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1697 let Documentation = [Undocumented];
1700 def ObjCMethodFamily : InheritableAttr {
1701 let Spellings = [Clang<"objc_method_family">];
1702 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1703 let Args = [EnumArgument<"Family", "FamilyKind",
1704 ["none", "alloc", "copy", "init", "mutableCopy", "new"],
1705 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
1706 "OMF_mutableCopy", "OMF_new"]>];
1707 let Documentation = [ObjCMethodFamilyDocs];
1710 def ObjCNSObject : InheritableAttr {
1711 let Spellings = [Clang<"NSObject">];
1712 let Documentation = [Undocumented];
1715 def ObjCIndependentClass : InheritableAttr {
1716 let Spellings = [Clang<"objc_independent_class">];
1717 let Documentation = [Undocumented];
1720 def ObjCPreciseLifetime : InheritableAttr {
1721 let Spellings = [Clang<"objc_precise_lifetime">];
1722 let Subjects = SubjectList<[Var], ErrorDiag>;
1723 let Documentation = [Undocumented];
1726 def ObjCReturnsInnerPointer : InheritableAttr {
1727 let Spellings = [Clang<"objc_returns_inner_pointer">];
1728 let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
1729 let Documentation = [Undocumented];
1732 def ObjCRequiresSuper : InheritableAttr {
1733 let Spellings = [Clang<"objc_requires_super">];
1734 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1735 let Documentation = [ObjCRequiresSuperDocs];
1738 def ObjCRootClass : InheritableAttr {
1739 let Spellings = [Clang<"objc_root_class">];
1740 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1741 let Documentation = [Undocumented];
1744 def ObjCSubclassingRestricted : InheritableAttr {
1745 let Spellings = [Clang<"objc_subclassing_restricted">];
1746 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1747 let Documentation = [ObjCSubclassingRestrictedDocs];
1750 def ObjCExplicitProtocolImpl : InheritableAttr {
1751 let Spellings = [Clang<"objc_protocol_requires_explicit_implementation">];
1752 let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
1753 let Documentation = [Undocumented];
1756 def ObjCDesignatedInitializer : Attr {
1757 let Spellings = [Clang<"objc_designated_initializer">];
1758 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1759 let Documentation = [Undocumented];
1762 def ObjCRuntimeName : Attr {
1763 let Spellings = [Clang<"objc_runtime_name">];
1764 let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
1765 let Args = [StringArgument<"MetadataName">];
1766 let Documentation = [ObjCRuntimeNameDocs];
1769 def ObjCRuntimeVisible : Attr {
1770 let Spellings = [Clang<"objc_runtime_visible">];
1771 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1772 let Documentation = [ObjCRuntimeVisibleDocs];
1775 def ObjCBoxable : Attr {
1776 let Spellings = [Clang<"objc_boxable">];
1777 let Subjects = SubjectList<[Record], ErrorDiag>;
1778 let Documentation = [ObjCBoxableDocs];
1781 def OptimizeNone : InheritableAttr {
1782 let Spellings = [Clang<"optnone">];
1783 let Subjects = SubjectList<[Function, ObjCMethod]>;
1784 let Documentation = [OptnoneDocs];
1787 def Overloadable : Attr {
1788 let Spellings = [Clang<"overloadable">];
1789 let Subjects = SubjectList<[Function], ErrorDiag>;
1790 let Documentation = [OverloadableDocs];
1793 def Override : InheritableAttr {
1794 let Spellings = [Keyword<"override">];
1795 let SemaHandler = 0;
1796 let Documentation = [Undocumented];
1799 def Ownership : InheritableAttr {
1800 let Spellings = [Clang<"ownership_holds">, Clang<"ownership_returns">,
1801 Clang<"ownership_takes">];
1802 let Accessors = [Accessor<"isHolds", [Clang<"ownership_holds">]>,
1803 Accessor<"isReturns", [Clang<"ownership_returns">]>,
1804 Accessor<"isTakes", [Clang<"ownership_takes">]>];
1805 let AdditionalMembers = [{
1806 enum OwnershipKind { Holds, Returns, Takes };
1807 OwnershipKind getOwnKind() const {
1808 return isHolds() ? Holds :
1813 let Args = [IdentifierArgument<"Module">,
1814 VariadicParamIdxArgument<"Args">];
1815 let Subjects = SubjectList<[HasFunctionProto]>;
1816 let Documentation = [Undocumented];
1819 def Packed : InheritableAttr {
1820 let Spellings = [GCC<"packed">];
1821 // let Subjects = [Tag, Field];
1822 let Documentation = [Undocumented];
1825 def IntelOclBicc : DeclOrTypeAttr {
1826 let Spellings = [Clang<"intel_ocl_bicc", 0>];
1827 // let Subjects = [Function, ObjCMethod];
1828 let Documentation = [Undocumented];
1831 def Pcs : DeclOrTypeAttr {
1832 let Spellings = [GCC<"pcs">];
1833 let Args = [EnumArgument<"PCS", "PCSType",
1834 ["aapcs", "aapcs-vfp"],
1835 ["AAPCS", "AAPCS_VFP"]>];
1836 // let Subjects = [Function, ObjCMethod];
1837 let Documentation = [PcsDocs];
1840 def AArch64VectorPcs: DeclOrTypeAttr {
1841 let Spellings = [Clang<"aarch64_vector_pcs">];
1842 let Documentation = [AArch64VectorPcsDocs];
1845 def Pure : InheritableAttr {
1846 let Spellings = [GCC<"pure">];
1847 let Documentation = [Undocumented];
1850 def Regparm : TypeAttr {
1851 let Spellings = [GCC<"regparm">];
1852 let Args = [UnsignedArgument<"NumParams">];
1853 let Documentation = [RegparmDocs];
1854 // Represented as part of the enclosing function type.
1858 def NoDeref : TypeAttr {
1859 let Spellings = [Clang<"noderef">];
1860 let Documentation = [NoDerefDocs];
1863 def ReqdWorkGroupSize : InheritableAttr {
1864 // Does not have a [[]] spelling because it is an OpenCL-related attribute.
1865 let Spellings = [GNU<"reqd_work_group_size">];
1866 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
1867 UnsignedArgument<"ZDim">];
1868 let Subjects = SubjectList<[Function], ErrorDiag>;
1869 let Documentation = [Undocumented];
1872 def RequireConstantInit : InheritableAttr {
1873 // This attribute does not have a C [[]] spelling because it requires the
1874 // CPlusPlus language option.
1875 let Spellings = [Clang<"require_constant_initialization", 0>];
1876 let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
1877 let Documentation = [RequireConstantInitDocs];
1878 let LangOpts = [CPlusPlus];
1881 def WorkGroupSizeHint : InheritableAttr {
1882 // Does not have a [[]] spelling because it is an OpenCL-related attribute.
1883 let Spellings = [GNU<"work_group_size_hint">];
1884 let Args = [UnsignedArgument<"XDim">,
1885 UnsignedArgument<"YDim">,
1886 UnsignedArgument<"ZDim">];
1887 let Subjects = SubjectList<[Function], ErrorDiag>;
1888 let Documentation = [Undocumented];
1891 def InitPriority : InheritableAttr {
1892 let Spellings = [GCC<"init_priority">];
1893 let Args = [UnsignedArgument<"Priority">];
1894 let Subjects = SubjectList<[Var], ErrorDiag>;
1895 let Documentation = [Undocumented];
1898 def Section : InheritableAttr {
1899 let Spellings = [GCC<"section">, Declspec<"allocate">];
1900 let Args = [StringArgument<"Name">];
1902 SubjectList<[ Function, GlobalVar, ObjCMethod, ObjCProperty ], ErrorDiag>;
1903 let Documentation = [SectionDocs];
1906 def CodeSeg : InheritableAttr {
1907 let Spellings = [Declspec<"code_seg">];
1908 let Args = [StringArgument<"Name">];
1909 let Subjects = SubjectList<[Function, CXXRecord], ErrorDiag>;
1910 let Documentation = [CodeSegDocs];
1913 def PragmaClangBSSSection : InheritableAttr {
1914 // This attribute has no spellings as it is only ever created implicitly.
1916 let Args = [StringArgument<"Name">];
1917 let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
1918 let Documentation = [Undocumented];
1921 def PragmaClangDataSection : InheritableAttr {
1922 // This attribute has no spellings as it is only ever created implicitly.
1924 let Args = [StringArgument<"Name">];
1925 let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
1926 let Documentation = [Undocumented];
1929 def PragmaClangRodataSection : InheritableAttr {
1930 // This attribute has no spellings as it is only ever created implicitly.
1932 let Args = [StringArgument<"Name">];
1933 let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
1934 let Documentation = [Undocumented];
1937 def PragmaClangTextSection : InheritableAttr {
1938 // This attribute has no spellings as it is only ever created implicitly.
1940 let Args = [StringArgument<"Name">];
1941 let Subjects = SubjectList<[Function], ErrorDiag>;
1942 let Documentation = [Undocumented];
1945 def Sentinel : InheritableAttr {
1946 let Spellings = [GCC<"sentinel">];
1947 let Args = [DefaultIntArgument<"Sentinel", 0>,
1948 DefaultIntArgument<"NullPos", 0>];
1949 // let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
1950 let Documentation = [Undocumented];
1953 def StdCall : DeclOrTypeAttr {
1954 let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
1955 // let Subjects = [Function, ObjCMethod];
1956 let Documentation = [StdCallDocs];
1959 def SwiftCall : DeclOrTypeAttr {
1960 let Spellings = [Clang<"swiftcall">];
1961 // let Subjects = SubjectList<[Function]>;
1962 let Documentation = [SwiftCallDocs];
1965 def SwiftContext : ParameterABIAttr {
1966 let Spellings = [Clang<"swift_context">];
1967 let Documentation = [SwiftContextDocs];
1970 def SwiftErrorResult : ParameterABIAttr {
1971 let Spellings = [Clang<"swift_error_result">];
1972 let Documentation = [SwiftErrorResultDocs];
1975 def SwiftIndirectResult : ParameterABIAttr {
1976 let Spellings = [Clang<"swift_indirect_result">];
1977 let Documentation = [SwiftIndirectResultDocs];
1980 def Suppress : StmtAttr {
1981 let Spellings = [CXX11<"gsl", "suppress">];
1982 let Args = [VariadicStringArgument<"DiagnosticIdentifiers">];
1983 let Documentation = [SuppressDocs];
1986 def SysVABI : DeclOrTypeAttr {
1987 let Spellings = [GCC<"sysv_abi">];
1988 // let Subjects = [Function, ObjCMethod];
1989 let Documentation = [Undocumented];
1992 def ThisCall : DeclOrTypeAttr {
1993 let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
1994 Keyword<"_thiscall">];
1995 // let Subjects = [Function, ObjCMethod];
1996 let Documentation = [ThisCallDocs];
1999 def VectorCall : DeclOrTypeAttr {
2000 let Spellings = [Clang<"vectorcall">, Keyword<"__vectorcall">,
2001 Keyword<"_vectorcall">];
2002 // let Subjects = [Function, ObjCMethod];
2003 let Documentation = [VectorCallDocs];
2006 def Pascal : DeclOrTypeAttr {
2007 let Spellings = [Clang<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
2008 // let Subjects = [Function, ObjCMethod];
2009 let Documentation = [Undocumented];
2012 def PreserveMost : DeclOrTypeAttr {
2013 let Spellings = [Clang<"preserve_most">];
2014 let Documentation = [PreserveMostDocs];
2017 def PreserveAll : DeclOrTypeAttr {
2018 let Spellings = [Clang<"preserve_all">];
2019 let Documentation = [PreserveAllDocs];
2022 def Target : InheritableAttr {
2023 let Spellings = [GCC<"target">];
2024 let Args = [StringArgument<"featuresStr">];
2025 let Subjects = SubjectList<[Function], ErrorDiag>;
2026 let Documentation = [TargetDocs];
2027 let AdditionalMembers = [{
2028 struct ParsedTargetAttr {
2029 std::vector<std::string> Features;
2030 StringRef Architecture;
2031 bool DuplicateArchitecture = false;
2032 bool operator ==(const ParsedTargetAttr &Other) const {
2033 return DuplicateArchitecture == Other.DuplicateArchitecture &&
2034 Architecture == Other.Architecture && Features == Other.Features;
2037 ParsedTargetAttr parse() const {
2038 return parse(getFeaturesStr());
2041 StringRef getArchitecture() const {
2042 StringRef Features = getFeaturesStr();
2043 if (Features == "default") return {};
2045 SmallVector<StringRef, 1> AttrFeatures;
2046 Features.split(AttrFeatures, ",");
2048 for (auto &Feature : AttrFeatures) {
2049 Feature = Feature.trim();
2050 if (Feature.startswith("arch="))
2051 return Feature.drop_front(sizeof("arch=") - 1);
2056 // Gets the list of features as simple string-refs with no +/- or 'no-'.
2057 // Only adds the items to 'Out' that are additions.
2058 void getAddedFeatures(llvm::SmallVectorImpl<StringRef> &Out) const {
2059 StringRef Features = getFeaturesStr();
2060 if (Features == "default") return;
2062 SmallVector<StringRef, 1> AttrFeatures;
2063 Features.split(AttrFeatures, ",");
2065 for (auto &Feature : AttrFeatures) {
2066 Feature = Feature.trim();
2068 if (!Feature.startswith("no-") && !Feature.startswith("arch=") &&
2069 !Feature.startswith("fpmath=") && !Feature.startswith("tune="))
2070 Out.push_back(Feature);
2074 template<class Compare>
2075 ParsedTargetAttr parse(Compare cmp) const {
2076 ParsedTargetAttr Attrs = parse();
2077 llvm::sort(std::begin(Attrs.Features), std::end(Attrs.Features), cmp);
2081 bool isDefaultVersion() const { return getFeaturesStr() == "default"; }
2083 static ParsedTargetAttr parse(StringRef Features) {
2084 ParsedTargetAttr Ret;
2085 if (Features == "default") return Ret;
2086 SmallVector<StringRef, 1> AttrFeatures;
2087 Features.split(AttrFeatures, ",");
2089 // Grab the various features and prepend a "+" to turn on the feature to
2090 // the backend and add them to our existing set of features.
2091 for (auto &Feature : AttrFeatures) {
2092 // Go ahead and trim whitespace rather than either erroring or
2093 // accepting it weirdly.
2094 Feature = Feature.trim();
2096 // We don't support cpu tuning this way currently.
2097 // TODO: Support the fpmath option. It will require checking
2098 // overall feature validity for the function with the rest of the
2099 // attributes on the function.
2100 if (Feature.startswith("fpmath=") || Feature.startswith("tune="))
2103 // While we're here iterating check for a different target cpu.
2104 if (Feature.startswith("arch=")) {
2105 if (!Ret.Architecture.empty())
2106 Ret.DuplicateArchitecture = true;
2108 Ret.Architecture = Feature.split("=").second.trim();
2109 } else if (Feature.startswith("no-"))
2110 Ret.Features.push_back("-" + Feature.split("-").second.str());
2112 Ret.Features.push_back("+" + Feature.str());
2119 def MinVectorWidth : InheritableAttr {
2120 let Spellings = [Clang<"min_vector_width">];
2121 let Args = [UnsignedArgument<"VectorWidth">];
2122 let Subjects = SubjectList<[Function], ErrorDiag>;
2123 let Documentation = [MinVectorWidthDocs];
2126 def TransparentUnion : InheritableAttr {
2127 let Spellings = [GCC<"transparent_union">];
2128 // let Subjects = SubjectList<[Record, TypedefName]>;
2129 let Documentation = [TransparentUnionDocs];
2130 let LangOpts = [COnly];
2133 def Unavailable : InheritableAttr {
2134 let Spellings = [Clang<"unavailable">];
2135 let Args = [StringArgument<"Message", 1>,
2136 EnumArgument<"ImplicitReason", "ImplicitReason",
2139 "IR_ARCForbiddenType",
2141 "IR_ARCForbiddenConversion",
2142 "IR_ARCInitReturnsUnrelated",
2143 "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>];
2144 let Documentation = [Undocumented];
2147 def DiagnoseIf : InheritableAttr {
2148 // Does not have a [[]] spelling because this attribute requires the ability
2149 // to parse function arguments but the attribute is not written in the type
2151 let Spellings = [GNU<"diagnose_if">];
2152 let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;
2153 let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
2154 EnumArgument<"DiagnosticType",
2156 ["error", "warning"],
2157 ["DT_Error", "DT_Warning"]>,
2158 BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
2159 NamedArgument<"Parent", 0, /*fake*/ 1>];
2160 let InheritEvenIfAlreadyPresent = 1;
2162 let AdditionalMembers = [{
2163 bool isError() const { return diagnosticType == DT_Error; }
2164 bool isWarning() const { return diagnosticType == DT_Warning; }
2166 let TemplateDependent = 1;
2167 let Documentation = [DiagnoseIfDocs];
2170 def ArcWeakrefUnavailable : InheritableAttr {
2171 let Spellings = [Clang<"objc_arc_weak_reference_unavailable">];
2172 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
2173 let Documentation = [Undocumented];
2176 def ObjCGC : TypeAttr {
2177 let Spellings = [Clang<"objc_gc">];
2178 let Args = [IdentifierArgument<"Kind">];
2179 let Documentation = [Undocumented];
2182 def ObjCOwnership : DeclOrTypeAttr {
2183 let Spellings = [Clang<"objc_ownership">];
2184 let Args = [IdentifierArgument<"Kind">];
2185 let Documentation = [Undocumented];
2188 def ObjCRequiresPropertyDefs : InheritableAttr {
2189 let Spellings = [Clang<"objc_requires_property_definitions">];
2190 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
2191 let Documentation = [Undocumented];
2194 def Unused : InheritableAttr {
2195 let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
2196 C2x<"", "maybe_unused">];
2197 let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
2198 Field, ObjCMethod, FunctionLike]>;
2199 let Documentation = [WarnMaybeUnusedDocs];
2202 def Used : InheritableAttr {
2203 let Spellings = [GCC<"used">];
2204 let Subjects = SubjectList<[NonLocalVar, Function, ObjCMethod]>;
2205 let Documentation = [Undocumented];
2208 def Uuid : InheritableAttr {
2209 let Spellings = [Declspec<"uuid">, Microsoft<"uuid">];
2210 let Args = [StringArgument<"Guid">];
2211 let Subjects = SubjectList<[Record, Enum]>;
2212 // FIXME: Allow expressing logical AND for LangOpts. Our condition should be:
2213 // CPlusPlus && (MicrosoftExt || Borland)
2214 let LangOpts = [MicrosoftExt, Borland];
2215 let Documentation = [Undocumented];
2218 def VectorSize : TypeAttr {
2219 let Spellings = [GCC<"vector_size">];
2220 let Args = [ExprArgument<"NumBytes">];
2221 let Documentation = [Undocumented];
2222 // Represented as VectorType instead.
2226 def VecTypeHint : InheritableAttr {
2227 // Does not have a [[]] spelling because it is an OpenCL-related attribute.
2228 let Spellings = [GNU<"vec_type_hint">];
2229 let Args = [TypeArgument<"TypeHint">];
2230 let Subjects = SubjectList<[Function], ErrorDiag>;
2231 let Documentation = [Undocumented];
2234 def Visibility : InheritableAttr {
2236 let Spellings = [GCC<"visibility">];
2237 let Args = [EnumArgument<"Visibility", "VisibilityType",
2238 ["default", "hidden", "internal", "protected"],
2239 ["Default", "Hidden", "Hidden", "Protected"]>];
2240 let MeaningfulToClassTemplateDefinition = 1;
2241 let Documentation = [Undocumented];
2244 def TypeVisibility : InheritableAttr {
2246 let Spellings = [Clang<"type_visibility">];
2247 let Args = [EnumArgument<"Visibility", "VisibilityType",
2248 ["default", "hidden", "internal", "protected"],
2249 ["Default", "Hidden", "Hidden", "Protected"]>];
2250 // let Subjects = [Tag, ObjCInterface, Namespace];
2251 let Documentation = [Undocumented];
2254 def VecReturn : InheritableAttr {
2255 // This attribute does not have a C [[]] spelling because it only appertains
2256 // to C++ struct/class/union.
2257 // FIXME: should this attribute have a CPlusPlus language option?
2258 let Spellings = [Clang<"vecreturn", 0>];
2259 let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
2260 let Documentation = [Undocumented];
2263 def WarnUnused : InheritableAttr {
2264 let Spellings = [GCC<"warn_unused">];
2265 let Subjects = SubjectList<[Record]>;
2266 let Documentation = [Undocumented];
2269 def WarnUnusedResult : InheritableAttr {
2270 let Spellings = [CXX11<"", "nodiscard", 201603>, C2x<"", "nodiscard">,
2271 CXX11<"clang", "warn_unused_result">,
2272 GCC<"warn_unused_result">];
2273 let Subjects = SubjectList<[ObjCMethod, Enum, Record, FunctionLike]>;
2274 let Documentation = [WarnUnusedResultsDocs];
2277 def Weak : InheritableAttr {
2278 let Spellings = [GCC<"weak">];
2279 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
2280 let Documentation = [Undocumented];
2283 def WeakImport : InheritableAttr {
2284 let Spellings = [Clang<"weak_import">];
2285 let Documentation = [Undocumented];
2288 def WeakRef : InheritableAttr {
2289 let Spellings = [GCC<"weakref">];
2290 // A WeakRef that has an argument is treated as being an AliasAttr
2291 let Args = [StringArgument<"Aliasee", 1>];
2292 let Subjects = SubjectList<[Var, Function], ErrorDiag>;
2293 let Documentation = [Undocumented];
2296 def LTOVisibilityPublic : InheritableAttr {
2297 let Spellings = [Clang<"lto_visibility_public">];
2298 let Subjects = SubjectList<[Record]>;
2299 let Documentation = [LTOVisibilityDocs];
2302 def AnyX86Interrupt : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
2303 // NOTE: If you add any additional spellings, ARMInterrupt's,
2304 // MSP430Interrupt's and MipsInterrupt's spellings must match.
2305 let Spellings = [GCC<"interrupt">];
2306 let Subjects = SubjectList<[HasFunctionProto]>;
2307 let ParseKind = "Interrupt";
2308 let HasCustomParsing = 1;
2309 let Documentation = [Undocumented];
2312 def AnyX86NoCallerSavedRegisters : InheritableAttr,
2313 TargetSpecificAttr<TargetAnyX86> {
2314 let Spellings = [GCC<"no_caller_saved_registers">];
2315 let Documentation = [AnyX86NoCallerSavedRegistersDocs];
2318 def AnyX86NoCfCheck : DeclOrTypeAttr, TargetSpecificAttr<TargetAnyX86>{
2319 let Spellings = [GCC<"nocf_check">];
2320 let Subjects = SubjectList<[FunctionLike]>;
2321 let Documentation = [AnyX86NoCfCheckDocs];
2324 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
2325 let Spellings = [GCC<"force_align_arg_pointer">];
2326 // Technically, this appertains to a FunctionDecl, but the target-specific
2327 // code silently allows anything function-like (such as typedefs or function
2328 // pointers), but does not apply the attribute to them.
2329 let Documentation = [X86ForceAlignArgPointerDocs];
2332 def NoSanitize : InheritableAttr {
2333 let Spellings = [Clang<"no_sanitize">];
2334 let Args = [VariadicStringArgument<"Sanitizers">];
2335 let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag>;
2336 let Documentation = [NoSanitizeDocs];
2337 let AdditionalMembers = [{
2338 SanitizerMask getMask() const {
2339 SanitizerMask Mask = 0;
2340 for (auto SanitizerName : sanitizers()) {
2341 SanitizerMask ParsedMask =
2342 parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
2343 Mask |= expandSanitizerGroups(ParsedMask);
2350 // Attributes to disable a specific sanitizer. No new sanitizers should be added
2351 // to this list; the no_sanitize attribute should be extended instead.
2352 def NoSanitizeSpecific : InheritableAttr {
2353 let Spellings = [GCC<"no_address_safety_analysis">,
2354 GCC<"no_sanitize_address">,
2355 GCC<"no_sanitize_thread">,
2356 Clang<"no_sanitize_memory">];
2357 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
2358 let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
2359 NoSanitizeMemoryDocs];
2363 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
2364 // Not all of these attributes will be given a [[]] spelling. The attributes
2365 // which require access to function parameter names cannot use the [[]] spelling
2366 // because they are not written in the type position. Some attributes are given
2367 // an updated captability-based name and the older name will only be supported
2368 // under the GNU-style spelling.
2369 def GuardedVar : InheritableAttr {
2370 let Spellings = [Clang<"guarded_var", 0>];
2371 let Subjects = SubjectList<[Field, SharedVar]>;
2372 let Documentation = [Undocumented];
2375 def PtGuardedVar : InheritableAttr {
2376 let Spellings = [Clang<"pt_guarded_var", 0>];
2377 let Subjects = SubjectList<[Field, SharedVar]>;
2378 let Documentation = [Undocumented];
2381 def Lockable : InheritableAttr {
2382 let Spellings = [GNU<"lockable">];
2383 let Subjects = SubjectList<[Record]>;
2384 let Documentation = [Undocumented];
2385 let ASTNode = 0; // Replaced by Capability
2388 def ScopedLockable : InheritableAttr {
2389 let Spellings = [Clang<"scoped_lockable", 0>];
2390 let Subjects = SubjectList<[Record]>;
2391 let Documentation = [Undocumented];
2394 def Capability : InheritableAttr {
2395 let Spellings = [Clang<"capability", 0>, Clang<"shared_capability", 0>];
2396 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag>;
2397 let Args = [StringArgument<"Name">];
2398 let Accessors = [Accessor<"isShared",
2399 [Clang<"shared_capability", 0>]>];
2400 let Documentation = [Undocumented];
2401 let AdditionalMembers = [{
2402 bool isMutex() const { return getName().equals_lower("mutex"); }
2403 bool isRole() const { return getName().equals_lower("role"); }
2407 def AssertCapability : InheritableAttr {
2408 let Spellings = [Clang<"assert_capability", 0>,
2409 Clang<"assert_shared_capability", 0>];
2410 let Subjects = SubjectList<[Function]>;
2412 let TemplateDependent = 1;
2413 let ParseArgumentsAsUnevaluated = 1;
2414 let InheritEvenIfAlreadyPresent = 1;
2415 let Args = [VariadicExprArgument<"Args">];
2416 let Accessors = [Accessor<"isShared",
2417 [Clang<"assert_shared_capability", 0>]>];
2418 let Documentation = [AssertCapabilityDocs];
2421 def AcquireCapability : InheritableAttr {
2422 let Spellings = [Clang<"acquire_capability", 0>,
2423 Clang<"acquire_shared_capability", 0>,
2424 GNU<"exclusive_lock_function">,
2425 GNU<"shared_lock_function">];
2426 let Subjects = SubjectList<[Function]>;
2428 let TemplateDependent = 1;
2429 let ParseArgumentsAsUnevaluated = 1;
2430 let InheritEvenIfAlreadyPresent = 1;
2431 let Args = [VariadicExprArgument<"Args">];
2432 let Accessors = [Accessor<"isShared",
2433 [Clang<"acquire_shared_capability", 0>,
2434 GNU<"shared_lock_function">]>];
2435 let Documentation = [AcquireCapabilityDocs];
2438 def TryAcquireCapability : InheritableAttr {
2439 let Spellings = [Clang<"try_acquire_capability", 0>,
2440 Clang<"try_acquire_shared_capability", 0>];
2441 let Subjects = SubjectList<[Function],
2444 let TemplateDependent = 1;
2445 let ParseArgumentsAsUnevaluated = 1;
2446 let InheritEvenIfAlreadyPresent = 1;
2447 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2448 let Accessors = [Accessor<"isShared",
2449 [Clang<"try_acquire_shared_capability", 0>]>];
2450 let Documentation = [TryAcquireCapabilityDocs];
2453 def ReleaseCapability : InheritableAttr {
2454 let Spellings = [Clang<"release_capability", 0>,
2455 Clang<"release_shared_capability", 0>,
2456 Clang<"release_generic_capability", 0>,
2457 Clang<"unlock_function", 0>];
2458 let Subjects = SubjectList<[Function]>;
2460 let TemplateDependent = 1;
2461 let ParseArgumentsAsUnevaluated = 1;
2462 let InheritEvenIfAlreadyPresent = 1;
2463 let Args = [VariadicExprArgument<"Args">];
2464 let Accessors = [Accessor<"isShared",
2465 [Clang<"release_shared_capability", 0>]>,
2466 Accessor<"isGeneric",
2467 [Clang<"release_generic_capability", 0>,
2468 Clang<"unlock_function", 0>]>];
2469 let Documentation = [ReleaseCapabilityDocs];
2472 def RequiresCapability : InheritableAttr {
2473 let Spellings = [Clang<"requires_capability", 0>,
2474 Clang<"exclusive_locks_required", 0>,
2475 Clang<"requires_shared_capability", 0>,
2476 Clang<"shared_locks_required", 0>];
2477 let Args = [VariadicExprArgument<"Args">];
2479 let TemplateDependent = 1;
2480 let ParseArgumentsAsUnevaluated = 1;
2481 let InheritEvenIfAlreadyPresent = 1;
2482 let Subjects = SubjectList<[Function]>;
2483 let Accessors = [Accessor<"isShared", [Clang<"requires_shared_capability", 0>,
2484 Clang<"shared_locks_required", 0>]>];
2485 let Documentation = [Undocumented];
2488 def NoThreadSafetyAnalysis : InheritableAttr {
2489 let Spellings = [Clang<"no_thread_safety_analysis">];
2490 let Subjects = SubjectList<[Function]>;
2491 let Documentation = [Undocumented];
2494 def GuardedBy : InheritableAttr {
2495 let Spellings = [GNU<"guarded_by">];
2496 let Args = [ExprArgument<"Arg">];
2498 let TemplateDependent = 1;
2499 let ParseArgumentsAsUnevaluated = 1;
2500 let InheritEvenIfAlreadyPresent = 1;
2501 let Subjects = SubjectList<[Field, SharedVar]>;
2502 let Documentation = [Undocumented];
2505 def PtGuardedBy : InheritableAttr {
2506 let Spellings = [GNU<"pt_guarded_by">];
2507 let Args = [ExprArgument<"Arg">];
2509 let TemplateDependent = 1;
2510 let ParseArgumentsAsUnevaluated = 1;
2511 let InheritEvenIfAlreadyPresent = 1;
2512 let Subjects = SubjectList<[Field, SharedVar]>;
2513 let Documentation = [Undocumented];
2516 def AcquiredAfter : InheritableAttr {
2517 let Spellings = [GNU<"acquired_after">];
2518 let Args = [VariadicExprArgument<"Args">];
2520 let TemplateDependent = 1;
2521 let ParseArgumentsAsUnevaluated = 1;
2522 let InheritEvenIfAlreadyPresent = 1;
2523 let Subjects = SubjectList<[Field, SharedVar]>;
2524 let Documentation = [Undocumented];
2527 def AcquiredBefore : InheritableAttr {
2528 let Spellings = [GNU<"acquired_before">];
2529 let Args = [VariadicExprArgument<"Args">];
2531 let TemplateDependent = 1;
2532 let ParseArgumentsAsUnevaluated = 1;
2533 let InheritEvenIfAlreadyPresent = 1;
2534 let Subjects = SubjectList<[Field, SharedVar]>;
2535 let Documentation = [Undocumented];
2538 def AssertExclusiveLock : InheritableAttr {
2539 let Spellings = [GNU<"assert_exclusive_lock">];
2540 let Args = [VariadicExprArgument<"Args">];
2542 let TemplateDependent = 1;
2543 let ParseArgumentsAsUnevaluated = 1;
2544 let InheritEvenIfAlreadyPresent = 1;
2545 let Subjects = SubjectList<[Function]>;
2546 let Documentation = [Undocumented];
2549 def AssertSharedLock : InheritableAttr {
2550 let Spellings = [GNU<"assert_shared_lock">];
2551 let Args = [VariadicExprArgument<"Args">];
2553 let TemplateDependent = 1;
2554 let ParseArgumentsAsUnevaluated = 1;
2555 let InheritEvenIfAlreadyPresent = 1;
2556 let Subjects = SubjectList<[Function]>;
2557 let Documentation = [Undocumented];
2560 // The first argument is an integer or boolean value specifying the return value
2561 // of a successful lock acquisition.
2562 def ExclusiveTrylockFunction : InheritableAttr {
2563 let Spellings = [GNU<"exclusive_trylock_function">];
2564 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2566 let TemplateDependent = 1;
2567 let ParseArgumentsAsUnevaluated = 1;
2568 let InheritEvenIfAlreadyPresent = 1;
2569 let Subjects = SubjectList<[Function]>;
2570 let Documentation = [Undocumented];
2573 // The first argument is an integer or boolean value specifying the return value
2574 // of a successful lock acquisition.
2575 def SharedTrylockFunction : InheritableAttr {
2576 let Spellings = [GNU<"shared_trylock_function">];
2577 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2579 let TemplateDependent = 1;
2580 let ParseArgumentsAsUnevaluated = 1;
2581 let InheritEvenIfAlreadyPresent = 1;
2582 let Subjects = SubjectList<[Function]>;
2583 let Documentation = [Undocumented];
2586 def LockReturned : InheritableAttr {
2587 let Spellings = [GNU<"lock_returned">];
2588 let Args = [ExprArgument<"Arg">];
2590 let TemplateDependent = 1;
2591 let ParseArgumentsAsUnevaluated = 1;
2592 let Subjects = SubjectList<[Function]>;
2593 let Documentation = [Undocumented];
2596 def LocksExcluded : InheritableAttr {
2597 let Spellings = [GNU<"locks_excluded">];
2598 let Args = [VariadicExprArgument<"Args">];
2600 let TemplateDependent = 1;
2601 let ParseArgumentsAsUnevaluated = 1;
2602 let InheritEvenIfAlreadyPresent = 1;
2603 let Subjects = SubjectList<[Function]>;
2604 let Documentation = [Undocumented];
2607 // C/C++ consumed attributes.
2609 def Consumable : InheritableAttr {
2610 // This attribute does not have a C [[]] spelling because it only appertains
2611 // to C++ struct/class/union.
2612 // FIXME: should this attribute have a CPlusPlus language option?
2613 let Spellings = [Clang<"consumable", 0>];
2614 let Subjects = SubjectList<[CXXRecord]>;
2615 let Args = [EnumArgument<"DefaultState", "ConsumedState",
2616 ["unknown", "consumed", "unconsumed"],
2617 ["Unknown", "Consumed", "Unconsumed"]>];
2618 let Documentation = [ConsumableDocs];
2621 def ConsumableAutoCast : InheritableAttr {
2622 // This attribute does not have a C [[]] spelling because it only appertains
2623 // to C++ struct/class/union.
2624 // FIXME: should this attribute have a CPlusPlus language option?
2625 let Spellings = [Clang<"consumable_auto_cast_state", 0>];
2626 let Subjects = SubjectList<[CXXRecord]>;
2627 let Documentation = [Undocumented];
2630 def ConsumableSetOnRead : InheritableAttr {
2631 // This attribute does not have a C [[]] spelling because it only appertains
2632 // to C++ struct/class/union.
2633 // FIXME: should this attribute have a CPlusPlus language option?
2634 let Spellings = [Clang<"consumable_set_state_on_read", 0>];
2635 let Subjects = SubjectList<[CXXRecord]>;
2636 let Documentation = [Undocumented];
2639 def CallableWhen : InheritableAttr {
2640 // This attribute does not have a C [[]] spelling because it only appertains
2641 // to C++ function (but doesn't require it to be a member function).
2642 // FIXME: should this attribute have a CPlusPlus language option?
2643 let Spellings = [Clang<"callable_when", 0>];
2644 let Subjects = SubjectList<[CXXMethod]>;
2645 let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
2646 ["unknown", "consumed", "unconsumed"],
2647 ["Unknown", "Consumed", "Unconsumed"]>];
2648 let Documentation = [CallableWhenDocs];
2651 def ParamTypestate : InheritableAttr {
2652 // This attribute does not have a C [[]] spelling because it only appertains
2653 // to a parameter whose type is a consumable C++ class.
2654 // FIXME: should this attribute have a CPlusPlus language option?
2655 let Spellings = [Clang<"param_typestate", 0>];
2656 let Subjects = SubjectList<[ParmVar]>;
2657 let Args = [EnumArgument<"ParamState", "ConsumedState",
2658 ["unknown", "consumed", "unconsumed"],
2659 ["Unknown", "Consumed", "Unconsumed"]>];
2660 let Documentation = [ParamTypestateDocs];
2663 def ReturnTypestate : InheritableAttr {
2664 // This attribute does not have a C [[]] spelling because it only appertains
2665 // to a parameter or function return type that is a consumable C++ class.
2666 // FIXME: should this attribute have a CPlusPlus language option?
2667 let Spellings = [Clang<"return_typestate", 0>];
2668 let Subjects = SubjectList<[Function, ParmVar]>;
2669 let Args = [EnumArgument<"State", "ConsumedState",
2670 ["unknown", "consumed", "unconsumed"],
2671 ["Unknown", "Consumed", "Unconsumed"]>];
2672 let Documentation = [ReturnTypestateDocs];
2675 def SetTypestate : InheritableAttr {
2676 // This attribute does not have a C [[]] spelling because it only appertains
2677 // to C++ function (but doesn't require it to be a member function).
2678 // FIXME: should this attribute have a CPlusPlus language option?
2679 let Spellings = [Clang<"set_typestate", 0>];
2680 let Subjects = SubjectList<[CXXMethod]>;
2681 let Args = [EnumArgument<"NewState", "ConsumedState",
2682 ["unknown", "consumed", "unconsumed"],
2683 ["Unknown", "Consumed", "Unconsumed"]>];
2684 let Documentation = [SetTypestateDocs];
2687 def TestTypestate : InheritableAttr {
2688 // This attribute does not have a C [[]] spelling because it only appertains
2689 // to C++ function (but doesn't require it to be a member function).
2690 // FIXME: should this attribute have a CPlusPlus language option?
2691 let Spellings = [Clang<"test_typestate", 0>];
2692 let Subjects = SubjectList<[CXXMethod]>;
2693 let Args = [EnumArgument<"TestState", "ConsumedState",
2694 ["consumed", "unconsumed"],
2695 ["Consumed", "Unconsumed"]>];
2696 let Documentation = [TestTypestateDocs];
2699 // Type safety attributes for `void *' pointers and type tags.
2701 def ArgumentWithTypeTag : InheritableAttr {
2702 let Spellings = [Clang<"argument_with_type_tag">,
2703 Clang<"pointer_with_type_tag">];
2704 let Subjects = SubjectList<[HasFunctionProto], ErrorDiag>;
2705 let Args = [IdentifierArgument<"ArgumentKind">,
2706 ParamIdxArgument<"ArgumentIdx">,
2707 ParamIdxArgument<"TypeTagIdx">,
2708 BoolArgument<"IsPointer", /*opt*/0, /*fake*/1>];
2709 let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
2712 def TypeTagForDatatype : InheritableAttr {
2713 let Spellings = [Clang<"type_tag_for_datatype">];
2714 let Args = [IdentifierArgument<"ArgumentKind">,
2715 TypeArgument<"MatchingCType">,
2716 BoolArgument<"LayoutCompatible">,
2717 BoolArgument<"MustBeNull">];
2718 // let Subjects = SubjectList<[Var], ErrorDiag>;
2719 let HasCustomParsing = 1;
2720 let Documentation = [TypeTagForDatatypeDocs];
2723 // Microsoft-related attributes
2725 def MSNoVTable : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
2726 let Spellings = [Declspec<"novtable">];
2727 let Subjects = SubjectList<[CXXRecord]>;
2728 let Documentation = [MSNoVTableDocs];
2732 let Spellings = [Declspec<"property">];
2735 def MSStruct : InheritableAttr {
2736 let Spellings = [GCC<"ms_struct">];
2737 let Subjects = SubjectList<[Record]>;
2738 let Documentation = [Undocumented];
2741 def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2742 let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
2743 let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2744 let Documentation = [DLLExportDocs];
2747 def DLLExportStaticLocal : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2748 // This attribute is used internally only when -fno-dllexport-inlines is
2749 // passed. This attribute is added to inline function of class having
2750 // dllexport attribute. And if the function has static local variables, this
2751 // attribute is used to whether the variables are exported or not. Also if
2752 // function has local static variables, the function is dllexported too.
2754 let Subjects = SubjectList<[Function]>;
2755 let Documentation = [Undocumented];
2758 def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2759 let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
2760 let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2761 let Documentation = [DLLImportDocs];
2764 let AdditionalMembers = [{
2766 bool PropagatedToBaseTemplate = false;
2769 void setPropagatedToBaseTemplate() { PropagatedToBaseTemplate = true; }
2770 bool wasPropagatedToBaseTemplate() { return PropagatedToBaseTemplate; }
2774 def DLLImportStaticLocal : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2775 // This attribute is used internally only when -fno-dllexport-inlines is
2776 // passed. This attribute is added to inline function of class having
2777 // dllimport attribute. And if the function has static local variables, this
2778 // attribute is used to whether the variables are imported or not.
2780 let Subjects = SubjectList<[Function]>;
2781 let Documentation = [Undocumented];
2784 def SelectAny : InheritableAttr {
2785 let Spellings = [Declspec<"selectany">, GCC<"selectany">];
2786 let Documentation = [SelectAnyDocs];
2790 let Spellings = [Declspec<"thread">];
2791 let LangOpts = [MicrosoftExt];
2792 let Documentation = [ThreadDocs];
2793 let Subjects = SubjectList<[Var]>;
2796 def Win64 : IgnoredAttr {
2797 let Spellings = [Keyword<"__w64">];
2798 let LangOpts = [MicrosoftExt];
2801 def Ptr32 : TypeAttr {
2802 let Spellings = [Keyword<"__ptr32">];
2803 let Documentation = [Undocumented];
2806 def Ptr64 : TypeAttr {
2807 let Spellings = [Keyword<"__ptr64">];
2808 let Documentation = [Undocumented];
2811 def SPtr : TypeAttr {
2812 let Spellings = [Keyword<"__sptr">];
2813 let Documentation = [Undocumented];
2816 def UPtr : TypeAttr {
2817 let Spellings = [Keyword<"__uptr">];
2818 let Documentation = [Undocumented];
2821 def MSInheritance : InheritableAttr {
2822 let LangOpts = [MicrosoftExt];
2823 let Args = [DefaultBoolArgument<"BestCase", /*default*/1, /*fake*/1>];
2824 let Spellings = [Keyword<"__single_inheritance">,
2825 Keyword<"__multiple_inheritance">,
2826 Keyword<"__virtual_inheritance">,
2827 Keyword<"__unspecified_inheritance">];
2828 let AdditionalMembers = [{
2829 static bool hasVBPtrOffsetField(Spelling Inheritance) {
2830 return Inheritance == Keyword_unspecified_inheritance;
2833 // Only member pointers to functions need a this adjustment, since it can be
2834 // combined with the field offset for data pointers.
2835 static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
2836 return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
2839 static bool hasVBTableOffsetField(Spelling Inheritance) {
2840 return Inheritance >= Keyword_virtual_inheritance;
2843 static bool hasOnlyOneField(bool IsMemberFunction,
2844 Spelling Inheritance) {
2845 if (IsMemberFunction)
2846 return Inheritance <= Keyword_single_inheritance;
2847 return Inheritance <= Keyword_multiple_inheritance;
2850 let Documentation = [MSInheritanceDocs];
2853 def MSVtorDisp : InheritableAttr {
2854 // This attribute has no spellings as it is only ever created implicitly.
2856 let Args = [UnsignedArgument<"vdm">];
2857 let SemaHandler = 0;
2859 let AdditionalMembers = [{
2866 Mode getVtorDispMode() const { return Mode(vdm); }
2868 let Documentation = [Undocumented];
2871 def InitSeg : Attr {
2872 let Spellings = [Pragma<"", "init_seg">];
2873 let Args = [StringArgument<"Section">];
2874 let SemaHandler = 0;
2875 let Documentation = [InitSegDocs];
2876 let AdditionalMembers = [{
2877 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2878 OS << " (" << getSection() << ')';
2883 def LoopHint : Attr {
2884 /// #pragma clang loop <option> directive
2885 /// vectorize: vectorizes loop operations if State == Enable.
2886 /// vectorize_width: vectorize loop operations with width 'Value'.
2887 /// interleave: interleave multiple loop iterations if State == Enable.
2888 /// interleave_count: interleaves 'Value' loop iterations.
2889 /// unroll: fully unroll loop if State == Enable.
2890 /// unroll_count: unrolls loop 'Value' times.
2891 /// unroll_and_jam: attempt to unroll and jam loop if State == Enable.
2892 /// unroll_and_jam_count: unroll and jams loop 'Value' times.
2893 /// distribute: attempt to distribute loop if State == Enable.
2894 /// pipeline: disable pipelining loop if State == Disable.
2895 /// pipeline_initiation_interval: create loop schedule with initiation interval equal to 'Value'.
2897 /// #pragma unroll <argument> directive
2898 /// <no arg>: fully unrolls loop.
2899 /// boolean: fully unrolls loop if State == Enable.
2900 /// expression: unrolls loop 'Value' times.
2902 let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">,
2903 Pragma<"", "nounroll">, Pragma<"", "unroll_and_jam">,
2904 Pragma<"", "nounroll_and_jam">];
2906 /// State of the loop optimization specified by the spelling.
2907 let Args = [EnumArgument<"Option", "OptionType",
2908 ["vectorize", "vectorize_width", "interleave", "interleave_count",
2909 "unroll", "unroll_count", "unroll_and_jam", "unroll_and_jam_count",
2910 "pipeline", "pipeline_initiation_interval", "distribute"],
2911 ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
2912 "Unroll", "UnrollCount", "UnrollAndJam", "UnrollAndJamCount",
2913 "PipelineDisabled", "PipelineInitiationInterval", "Distribute"]>,
2914 EnumArgument<"State", "LoopHintState",
2915 ["enable", "disable", "numeric", "assume_safety", "full"],
2916 ["Enable", "Disable", "Numeric", "AssumeSafety", "Full"]>,
2917 ExprArgument<"Value">];
2919 let AdditionalMembers = [{
2920 static const char *getOptionName(int Option) {
2922 case Vectorize: return "vectorize";
2923 case VectorizeWidth: return "vectorize_width";
2924 case Interleave: return "interleave";
2925 case InterleaveCount: return "interleave_count";
2926 case Unroll: return "unroll";
2927 case UnrollCount: return "unroll_count";
2928 case UnrollAndJam: return "unroll_and_jam";
2929 case UnrollAndJamCount: return "unroll_and_jam_count";
2930 case PipelineDisabled: return "pipeline";
2931 case PipelineInitiationInterval: return "pipeline_initiation_interval";
2932 case Distribute: return "distribute";
2934 llvm_unreachable("Unhandled LoopHint option.");
2937 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2938 unsigned SpellingIndex = getSpellingListIndex();
2939 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
2940 // "nounroll" is already emitted as the pragma name.
2941 if (SpellingIndex == Pragma_nounroll || SpellingIndex == Pragma_nounroll_and_jam)
2943 else if (SpellingIndex == Pragma_unroll || SpellingIndex == Pragma_unroll_and_jam) {
2944 OS << ' ' << getValueString(Policy);
2948 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2949 OS << ' ' << getOptionName(option) << getValueString(Policy);
2952 // Return a string containing the loop hint argument including the
2953 // enclosing parentheses.
2954 std::string getValueString(const PrintingPolicy &Policy) const {
2955 std::string ValueName;
2956 llvm::raw_string_ostream OS(ValueName);
2958 if (state == Numeric)
2959 value->printPretty(OS, nullptr, Policy);
2960 else if (state == Enable)
2962 else if (state == Full)
2964 else if (state == AssumeSafety)
2965 OS << "assume_safety";
2972 // Return a string suitable for identifying this attribute in diagnostics.
2973 std::string getDiagnosticName(const PrintingPolicy &Policy) const {
2974 unsigned SpellingIndex = getSpellingListIndex();
2975 if (SpellingIndex == Pragma_nounroll)
2976 return "#pragma nounroll";
2977 else if (SpellingIndex == Pragma_unroll)
2978 return "#pragma unroll" + (option == UnrollCount ? getValueString(Policy) : "");
2979 else if (SpellingIndex == Pragma_nounroll_and_jam)
2980 return "#pragma nounroll_and_jam";
2981 else if (SpellingIndex == Pragma_unroll_and_jam)
2982 return "#pragma unroll_and_jam" +
2983 (option == UnrollAndJamCount ? getValueString(Policy) : "");
2985 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2986 return getOptionName(option) + getValueString(Policy);
2990 let Documentation = [LoopHintDocs, UnrollHintDocs];
2993 def CapturedRecord : InheritableAttr {
2994 // This attribute has no spellings as it is only ever created implicitly.
2996 let SemaHandler = 0;
2997 let Documentation = [Undocumented];
3000 def OMPThreadPrivateDecl : InheritableAttr {
3001 // This attribute has no spellings as it is only ever created implicitly.
3003 let SemaHandler = 0;
3004 let Documentation = [Undocumented];
3007 def OMPCaptureNoInit : InheritableAttr {
3008 // This attribute has no spellings as it is only ever created implicitly.
3010 let SemaHandler = 0;
3011 let Documentation = [Undocumented];
3014 def OMPCaptureKind : Attr {
3015 // This attribute has no spellings as it is only ever created implicitly.
3017 let SemaHandler = 0;
3018 let Args = [UnsignedArgument<"CaptureKind">];
3019 let Documentation = [Undocumented];
3022 def OMPReferencedVar : Attr {
3023 // This attribute has no spellings as it is only ever created implicitly.
3025 let SemaHandler = 0;
3026 let Args = [ExprArgument<"Ref">];
3027 let Documentation = [Undocumented];
3030 def OMPDeclareSimdDecl : Attr {
3031 let Spellings = [Pragma<"omp", "declare simd">];
3032 let Subjects = SubjectList<[Function]>;
3033 let SemaHandler = 0;
3034 let HasCustomParsing = 1;
3035 let Documentation = [OMPDeclareSimdDocs];
3037 EnumArgument<"BranchState", "BranchStateTy",
3038 [ "", "inbranch", "notinbranch" ],
3039 [ "BS_Undefined", "BS_Inbranch", "BS_Notinbranch" ]>,
3040 ExprArgument<"Simdlen">, VariadicExprArgument<"Uniforms">,
3041 VariadicExprArgument<"Aligneds">, VariadicExprArgument<"Alignments">,
3042 VariadicExprArgument<"Linears">, VariadicUnsignedArgument<"Modifiers">,
3043 VariadicExprArgument<"Steps">
3045 let AdditionalMembers = [{
3046 void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
3048 if (getBranchState() != BS_Undefined)
3049 OS << ' ' << ConvertBranchStateTyToStr(getBranchState());
3050 if (auto *E = getSimdlen()) {
3052 E->printPretty(OS, nullptr, Policy);
3055 if (uniforms_size() > 0) {
3057 StringRef Sep = "(";
3058 for (auto *E : uniforms()) {
3060 E->printPretty(OS, nullptr, Policy);
3065 alignments_iterator NI = alignments_begin();
3066 for (auto *E : aligneds()) {
3068 E->printPretty(OS, nullptr, Policy);
3071 (*NI)->printPretty(OS, nullptr, Policy);
3076 steps_iterator I = steps_begin();
3077 modifiers_iterator MI = modifiers_begin();
3078 for (auto *E : linears()) {
3080 if (*MI != OMPC_LINEAR_unknown)
3081 OS << getOpenMPSimpleClauseTypeName(OMPC_linear, *MI) << "(";
3082 E->printPretty(OS, nullptr, Policy);
3083 if (*MI != OMPC_LINEAR_unknown)
3087 (*I)->printPretty(OS, nullptr, Policy);
3097 def OMPDeclareTargetDecl : InheritableAttr {
3098 let Spellings = [Pragma<"omp", "declare target">];
3099 let SemaHandler = 0;
3100 let Subjects = SubjectList<[Function, SharedVar]>;
3101 let Documentation = [OMPDeclareTargetDocs];
3103 EnumArgument<"MapType", "MapTypeTy",
3105 [ "MT_To", "MT_Link" ]>
3107 let AdditionalMembers = [{
3108 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
3109 // Use fake syntax because it is for testing and debugging purpose only.
3110 if (getMapType() != MT_To)
3111 OS << ' ' << ConvertMapTypeTyToStr(getMapType());
3113 static llvm::Optional<MapTypeTy>
3114 isDeclareTargetDeclaration(const ValueDecl *VD) {
3115 if (!VD->hasAttrs())
3117 if (const auto *Attr = VD->getAttr<OMPDeclareTargetDeclAttr>())
3118 return Attr->getMapType();
3125 def InternalLinkage : InheritableAttr {
3126 let Spellings = [Clang<"internal_linkage">];
3127 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
3128 let Documentation = [InternalLinkageDocs];
3131 def ExcludeFromExplicitInstantiation : InheritableAttr {
3132 let Spellings = [Clang<"exclude_from_explicit_instantiation">];
3133 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
3134 let Documentation = [ExcludeFromExplicitInstantiationDocs];
3135 let MeaningfulToClassTemplateDefinition = 1;
3138 def Reinitializes : InheritableAttr {
3139 let Spellings = [Clang<"reinitializes", 0>];
3140 let Subjects = SubjectList<[NonStaticNonConstCXXMethod], ErrorDiag>;
3141 let Documentation = [ReinitializesDocs];
3144 def NoDestroy : InheritableAttr {
3145 let Spellings = [Clang<"no_destroy", 0>];
3146 let Subjects = SubjectList<[Var]>;
3147 let Documentation = [NoDestroyDocs];
3150 def AlwaysDestroy : InheritableAttr {
3151 let Spellings = [Clang<"always_destroy", 0>];
3152 let Subjects = SubjectList<[Var]>;
3153 let Documentation = [AlwaysDestroyDocs];
3156 def SpeculativeLoadHardening : InheritableAttr {
3157 let Spellings = [Clang<"speculative_load_hardening">];
3158 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
3159 let Documentation = [SpeculativeLoadHardeningDocs];
3162 def Uninitialized : InheritableAttr {
3163 let Spellings = [Clang<"uninitialized", 0>];
3164 let Subjects = SubjectList<[LocalVar]>;
3165 let Documentation = [UninitializedDocs];
3168 def ObjCExternallyRetained : InheritableAttr {
3169 let LangOpts = [ObjCAutoRefCount];
3170 let Spellings = [Clang<"objc_externally_retained">];
3171 let Subjects = SubjectList<[NonParmVar, Function, Block, ObjCMethod]>;
3172 let Documentation = [ObjCExternallyRetainedDocs];