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 NonBitField : SubsetSubject<Field,
88 "non-bit-field non-static data members">;
90 def ObjCInstanceMethod : SubsetSubject<ObjCMethod,
91 [{S->isInstanceMethod()}],
92 "Objective-C instance methods">;
94 def ObjCInterfaceDeclInitMethod : SubsetSubject<ObjCMethod,
95 [{S->getMethodFamily() == OMF_init &&
96 (isa<ObjCInterfaceDecl>(S->getDeclContext()) ||
97 (isa<ObjCCategoryDecl>(S->getDeclContext()) &&
98 cast<ObjCCategoryDecl>(S->getDeclContext())->IsClassExtension()))}],
99 "init methods of interface or class extension declarations">;
101 def Struct : SubsetSubject<Record,
102 [{!S->isUnion()}], "structs">;
104 def TLSVar : SubsetSubject<Var,
105 [{S->getTLSKind() != 0}], "thread-local variables">;
107 def SharedVar : SubsetSubject<Var,
108 [{S->hasGlobalStorage() && !S->getTLSKind()}],
111 def GlobalVar : SubsetSubject<Var,
112 [{S->hasGlobalStorage()}], "global variables">;
114 // FIXME: this hack is needed because DeclNodes.td defines the base Decl node
115 // type to be a class, not a definition. This makes it impossible to create an
116 // attribute subject which accepts a Decl. Normally, this is not a problem,
117 // because the attribute can have no Subjects clause to accomplish this. But in
118 // the case of a SubsetSubject, there's no way to express it without this hack.
119 def DeclBase : AttrSubject;
120 def FunctionLike : SubsetSubject<DeclBase,
121 [{S->getFunctionType(false) != nullptr}],
122 "functions, function pointers">;
124 def OpenCLKernelFunction
125 : SubsetSubject<Function, [{S->hasAttr<OpenCLKernelAttr>()}],
128 // HasFunctionProto is a more strict version of FunctionLike, so it should
129 // never be specified in a Subjects list along with FunctionLike (due to the
130 // inclusive nature of subject testing).
131 def HasFunctionProto : SubsetSubject<DeclBase,
132 [{(S->getFunctionType(true) != nullptr &&
133 isa<FunctionProtoType>(S->getFunctionType())) ||
134 isa<ObjCMethodDecl>(S) ||
136 "non-K&R-style functions">;
138 // A single argument to an attribute
139 class Argument<string name, bit optional, bit fake = 0> {
141 bit Optional = optional;
143 /// A fake argument is used to store and serialize additional information
144 /// in an attribute without actually changing its parsing or pretty-printing.
148 class BoolArgument<string name, bit opt = 0, bit fake = 0> : Argument<name, opt,
150 class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>;
151 class IntArgument<string name, bit opt = 0> : Argument<name, opt>;
152 class StringArgument<string name, bit opt = 0> : Argument<name, opt>;
153 class ExprArgument<string name, bit opt = 0> : Argument<name, opt>;
154 class FunctionArgument<string name, bit opt = 0, bit fake = 0> : Argument<name,
157 class NamedArgument<string name, bit opt = 0, bit fake = 0> : Argument<name,
160 class TypeArgument<string name, bit opt = 0> : Argument<name, opt>;
161 class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>;
162 class VariadicUnsignedArgument<string name> : Argument<name, 1>;
163 class VariadicExprArgument<string name> : Argument<name, 1>;
164 class VariadicStringArgument<string name> : Argument<name, 1>;
166 // A version of the form major.minor[.subminor].
167 class VersionArgument<string name, bit opt = 0> : Argument<name, opt>;
169 // This one's a doozy, so it gets its own special type
170 // It can be an unsigned integer, or a type. Either can
172 class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>;
174 // A bool argument with a default value
175 class DefaultBoolArgument<string name, bit default> : BoolArgument<name, 1> {
176 bit Default = default;
179 // An integer argument with a default value
180 class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
181 int Default = default;
184 // This argument is more complex, it includes the enumerator type name,
185 // a list of strings to accept, and a list of enumerators to map them to.
186 class EnumArgument<string name, string type, list<string> values,
187 list<string> enums, bit opt = 0, bit fake = 0>
188 : Argument<name, opt, fake> {
190 list<string> Values = values;
191 list<string> Enums = enums;
194 // FIXME: There should be a VariadicArgument type that takes any other type
195 // of argument and generates the appropriate type.
196 class VariadicEnumArgument<string name, string type, list<string> values,
197 list<string> enums> : Argument<name, 1> {
199 list<string> Values = values;
200 list<string> Enums = enums;
203 // This handles one spelling of an attribute.
204 class Spelling<string name, string variety> {
206 string Variety = variety;
210 class GNU<string name> : Spelling<name, "GNU">;
211 class Declspec<string name> : Spelling<name, "Declspec">;
212 class Microsoft<string name> : Spelling<name, "Microsoft">;
213 class CXX11<string namespace, string name, int version = 1>
214 : Spelling<name, "CXX11"> {
215 string Namespace = namespace;
216 int Version = version;
218 class C2x<string namespace, string name> : Spelling<name, "C2x"> {
219 string Namespace = namespace;
222 class Keyword<string name> : Spelling<name, "Keyword">;
223 class Pragma<string namespace, string name> : Spelling<name, "Pragma"> {
224 string Namespace = namespace;
227 // The GCC spelling implies GNU<name> and CXX11<"gnu", name> and also sets
228 // KnownToGCC to 1. This spelling should be used for any GCC-compatible
230 class GCC<string name> : Spelling<name, "GCC"> {
234 // The Clang spelling implies GNU<name> and CXX11<"clang", name>. This spelling
235 // should be used for any Clang-specific attributes.
236 class Clang<string name> : Spelling<name, "Clang">;
238 class Accessor<string name, list<Spelling> spellings> {
240 list<Spelling> Spellings = spellings;
243 class SubjectDiag<bit warn> {
246 def WarnDiag : SubjectDiag<1>;
247 def ErrorDiag : SubjectDiag<0>;
249 class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag,
250 string customDiag = ""> {
251 list<AttrSubject> Subjects = subjects;
252 SubjectDiag Diag = diag;
253 string CustomDiag = customDiag;
256 class LangOpt<string name, bit negated = 0> {
258 bit Negated = negated;
260 def MicrosoftExt : LangOpt<"MicrosoftExt">;
261 def Borland : LangOpt<"Borland">;
262 def CUDA : LangOpt<"CUDA">;
263 def COnly : LangOpt<"CPlusPlus", 1>;
264 def CPlusPlus : LangOpt<"CPlusPlus">;
265 def OpenCL : LangOpt<"OpenCL">;
266 def RenderScript : LangOpt<"RenderScript">;
267 def ObjC : LangOpt<"ObjC1">;
268 def BlocksSupported : LangOpt<"Blocks">;
270 // Defines targets for target-specific attributes. Empty lists are unchecked.
272 // Specifies Architectures for which the target applies, based off the
273 // ArchType enumeration in Triple.h.
274 list<string> Arches = [];
275 // Specifies Operating Systems for which the target applies, based off the
276 // OSType enumeration in Triple.h
278 // Specifies the C++ ABIs for which the target applies, based off the
279 // TargetCXXABI::Kind in TargetCXXABI.h.
280 list<string> CXXABIs;
281 // Specifies Object Formats for which the target applies, based off the
282 // ObjectFormatType enumeration in Triple.h
283 list<string> ObjectFormats;
286 class TargetArch<list<string> arches> : TargetSpec {
289 def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
290 def TargetAVR : TargetArch<["avr"]>;
291 def TargetMips32 : TargetArch<["mips", "mipsel"]>;
292 def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
293 def TargetMSP430 : TargetArch<["msp430"]>;
294 def TargetX86 : TargetArch<["x86"]>;
295 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
296 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
297 let OSes = ["Win32"];
299 def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
300 let CXXABIs = ["Microsoft"];
302 def TargetELF : TargetSpec {
303 let ObjectFormats = ["ELF"];
306 // Attribute subject match rules that are used for #pragma clang attribute.
308 // A instance of AttrSubjectMatcherRule represents an individual match rule.
309 // An individual match rule can correspond to a number of different attribute
310 // subjects, e.g. "record" matching rule corresponds to the Record and
311 // CXXRecord attribute subjects.
313 // Match rules are used in the subject list of the #pragma clang attribute.
314 // Match rules can have sub-match rules that are instances of
315 // AttrSubjectMatcherSubRule. A sub-match rule can correspond to a number
316 // of different attribute subjects, and it can have a negated spelling as well.
317 // For example, "variable(unless(is_parameter))" matching rule corresponds to
318 // the NonParmVar attribute subject.
319 class AttrSubjectMatcherSubRule<string name, list<AttrSubject> subjects,
322 list<AttrSubject> Subjects = subjects;
323 bit Negated = negated;
324 // Lists language options, one of which is required to be true for the
325 // attribute to be applicable. If empty, the language options are taken
326 // from the parent matcher rule.
327 list<LangOpt> LangOpts = [];
329 class AttrSubjectMatcherRule<string name, list<AttrSubject> subjects,
330 list<AttrSubjectMatcherSubRule> subrules = []> {
332 list<AttrSubject> Subjects = subjects;
333 list<AttrSubjectMatcherSubRule> Constraints = subrules;
334 // Lists language options, one of which is required to be true for the
335 // attribute to be applicable. If empty, no language options are required.
336 list<LangOpt> LangOpts = [];
339 // function(is_member)
340 def SubRuleForCXXMethod : AttrSubjectMatcherSubRule<"is_member", [CXXMethod]> {
341 let LangOpts = [CPlusPlus];
343 def SubjectMatcherForFunction : AttrSubjectMatcherRule<"function", [Function], [
346 // hasType is abstract, it should be used with one of the sub-rules.
347 def SubjectMatcherForType : AttrSubjectMatcherRule<"hasType", [], [
348 AttrSubjectMatcherSubRule<"functionType", [FunctionLike]>
350 // FIXME: There's a matcher ambiguity with objc methods and blocks since
351 // functionType excludes them but functionProtoType includes them.
352 // AttrSubjectMatcherSubRule<"functionProtoType", [HasFunctionProto]>
354 def SubjectMatcherForTypedef : AttrSubjectMatcherRule<"type_alias",
356 def SubjectMatcherForRecord : AttrSubjectMatcherRule<"record", [Record,
359 AttrSubjectMatcherSubRule<"is_union", [Struct], 1>
361 def SubjectMatcherForEnum : AttrSubjectMatcherRule<"enum", [Enum]>;
362 def SubjectMatcherForEnumConstant : AttrSubjectMatcherRule<"enum_constant",
364 def SubjectMatcherForVar : AttrSubjectMatcherRule<"variable", [Var], [
365 AttrSubjectMatcherSubRule<"is_thread_local", [TLSVar]>,
366 AttrSubjectMatcherSubRule<"is_global", [GlobalVar]>,
367 AttrSubjectMatcherSubRule<"is_parameter", [ParmVar]>,
368 // unless(is_parameter)
369 AttrSubjectMatcherSubRule<"is_parameter", [NonParmVar], 1>
371 def SubjectMatcherForField : AttrSubjectMatcherRule<"field", [Field]>;
372 def SubjectMatcherForNamespace : AttrSubjectMatcherRule<"namespace",
374 let LangOpts = [CPlusPlus];
376 def SubjectMatcherForObjCInterface : AttrSubjectMatcherRule<"objc_interface",
378 let LangOpts = [ObjC];
380 def SubjectMatcherForObjCProtocol : AttrSubjectMatcherRule<"objc_protocol",
382 let LangOpts = [ObjC];
384 def SubjectMatcherForObjCCategory : AttrSubjectMatcherRule<"objc_category",
386 let LangOpts = [ObjC];
388 def SubjectMatcherForObjCMethod : AttrSubjectMatcherRule<"objc_method",
390 AttrSubjectMatcherSubRule<"is_instance", [ObjCInstanceMethod]>
392 let LangOpts = [ObjC];
394 def SubjectMatcherForObjCProperty : AttrSubjectMatcherRule<"objc_property",
396 let LangOpts = [ObjC];
398 def SubjectMatcherForBlock : AttrSubjectMatcherRule<"block", [Block]> {
399 let LangOpts = [BlocksSupported];
402 // Aggregate attribute subject match rules are abstract match rules that can't
403 // be used directly in #pragma clang attribute. Instead, users have to use
404 // subject match rules that correspond to attribute subjects that derive from
405 // the specified subject.
406 class AttrSubjectMatcherAggregateRule<AttrSubject subject> {
407 AttrSubject Subject = subject;
410 def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule<Named>;
413 // The various ways in which an attribute can be spelled in source
414 list<Spelling> Spellings;
415 // The things to which an attribute can appertain
416 SubjectList Subjects;
417 // The arguments allowed on an attribute
418 list<Argument> Args = [];
419 // Accessors which should be generated for the attribute.
420 list<Accessor> Accessors = [];
421 // Set to true for attributes with arguments which require delayed parsing.
423 // Set to false to prevent an attribute from being propagated from a template
424 // to the instantiation.
426 // Set to true for attributes which must be instantiated within templates
427 bit TemplateDependent = 0;
428 // Set to true for attributes that have a corresponding AST node.
430 // Set to true for attributes which have handler in Sema.
432 // Set to true for attributes that are completely ignored.
434 // Set to true if the attribute's parsing does not match its semantic
435 // content. Eg) It parses 3 args, but semantically takes 4 args. Opts out of
436 // common attribute error checking.
437 bit HasCustomParsing = 0;
438 // Set to true if all of the attribute's arguments should be parsed in an
439 // unevaluated context.
440 bit ParseArgumentsAsUnevaluated = 0;
441 // Set to true if this attribute can be duplicated on a subject when merging
442 // attributes. By default, attributes are not merged.
443 bit DuplicatesAllowedWhileMerging = 0;
444 // Set to true if this attribute meaningful when applied to or inherited
445 // in a class template definition.
446 bit MeaningfulToClassTemplateDefinition = 0;
447 // Set to true if this attribute can be used with '#pragma clang attribute'.
448 // By default, when this value is false, an attribute is supported by the
449 // '#pragma clang attribute' only when:
450 // - It has documentation.
451 // - It has a subject list whose subjects can be represented using subject
453 // - It has GNU/CXX11 spelling and doesn't require delayed parsing.
454 bit ForcePragmaAttributeSupport = 0;
455 // Lists language options, one of which is required to be true for the
456 // attribute to be applicable. If empty, no language options are required.
457 list<LangOpt> LangOpts = [];
458 // Any additional text that should be included verbatim in the class.
459 // Note: Any additional data members will leak and should be constructed
460 // externally on the ASTContext.
461 code AdditionalMembers = [{}];
462 // Any documentation that should be associated with the attribute. Since an
463 // attribute may be documented under multiple categories, more than one
464 // Documentation entry may be listed.
465 list<Documentation> Documentation;
468 /// A type attribute is not processed on a declaration or a statement.
469 class TypeAttr : Attr {
470 // By default, type attributes do not get an AST node.
474 /// A stmt attribute is not processed on a declaration or a type.
475 class StmtAttr : Attr;
477 /// An inheritable attribute is inherited by later redeclarations.
478 class InheritableAttr : Attr;
480 /// A target-specific attribute. This class is meant to be used as a mixin
481 /// with InheritableAttr or Attr depending on the attribute's needs.
482 class TargetSpecificAttr<TargetSpec target> {
483 TargetSpec Target = target;
484 // Attributes are generally required to have unique spellings for their names
485 // so that the parser can determine what kind of attribute it has parsed.
486 // However, target-specific attributes are special in that the attribute only
487 // "exists" for a given target. So two target-specific attributes can share
488 // the same name when they exist in different targets. To support this, a
489 // Kind can be explicitly specified for a target-specific attribute. This
490 // corresponds to the AttributeList::AT_* enum that is generated and it
491 // should contain a shared value between the attributes.
493 // Target-specific attributes which use this feature should ensure that the
494 // spellings match exactly between the attributes, and if the arguments or
495 // subjects differ, should specify HasCustomParsing = 1 and implement their
496 // own parsing and semantic handling requirements as-needed.
500 /// An inheritable parameter attribute is inherited by later
501 /// redeclarations, even when it's written on a parameter.
502 class InheritableParamAttr : InheritableAttr;
504 /// An attribute which changes the ABI rules for a specific parameter.
505 class ParameterABIAttr : InheritableParamAttr {
506 let Subjects = SubjectList<[ParmVar]>;
509 /// An ignored attribute, which we parse but discard with no checking.
510 class IgnoredAttr : Attr {
514 let Documentation = [Undocumented];
518 // Attributes begin here
522 let Spellings = [GCC<"abi_tag">];
523 let Args = [VariadicStringArgument<"Tags">];
524 let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag>;
525 let MeaningfulToClassTemplateDefinition = 1;
526 let Documentation = [AbiTagsDocs];
529 def AddressSpace : TypeAttr {
530 let Spellings = [Clang<"address_space">];
531 let Args = [IntArgument<"AddressSpace">];
532 let Documentation = [Undocumented];
536 let Spellings = [GCC<"alias">];
537 let Args = [StringArgument<"Aliasee">];
538 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
539 let Documentation = [Undocumented];
542 def Aligned : InheritableAttr {
543 let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">,
544 Keyword<"_Alignas">];
545 let Args = [AlignedArgument<"Alignment", 1>];
546 let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
547 Accessor<"isC11", [Keyword<"_Alignas">]>,
548 Accessor<"isAlignas", [Keyword<"alignas">,
549 Keyword<"_Alignas">]>,
550 Accessor<"isDeclspec",[Declspec<"align">]>];
551 let Documentation = [Undocumented];
552 let DuplicatesAllowedWhileMerging = 1;
555 def AlignValue : Attr {
557 // Unfortunately, this is semantically an assertion, not a directive
558 // (something else must ensure the alignment), so aligned_value is a
559 // probably a better name. We might want to add an aligned_value spelling in
560 // the future (and a corresponding C++ attribute), but this can be done
561 // later once we decide if we also want them to have slightly-different
562 // semantics than Intel's align_value.
564 // Does not get a [[]] spelling because the attribute is not exposed as such
567 // Intel's compiler on Windows also supports:
568 // , Declspec<"align_value">
570 let Args = [ExprArgument<"Alignment">];
571 let Subjects = SubjectList<[Var, TypedefName]>;
572 let Documentation = [AlignValueDocs];
575 def AlignMac68k : InheritableAttr {
576 // This attribute has no spellings as it is only ever created implicitly.
579 let Documentation = [Undocumented];
582 def AlwaysInline : InheritableAttr {
583 let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
584 let Subjects = SubjectList<[Function]>;
585 let Documentation = [Undocumented];
588 def XRayInstrument : InheritableAttr {
589 let Spellings = [Clang<"xray_always_instrument">,
590 Clang<"xray_never_instrument">];
591 let Subjects = SubjectList<[Function, ObjCMethod]>;
592 let Accessors = [Accessor<"alwaysXRayInstrument",
593 [Clang<"xray_always_instrument">]>,
594 Accessor<"neverXRayInstrument",
595 [Clang<"xray_never_instrument">]>];
596 let Documentation = [XRayDocs];
599 def XRayLogArgs : InheritableAttr {
600 let Spellings = [Clang<"xray_log_args">];
601 let Subjects = SubjectList<[Function, ObjCMethod]>;
602 let Args = [UnsignedArgument<"ArgumentCount">];
603 let Documentation = [XRayDocs];
606 def TLSModel : InheritableAttr {
607 let Spellings = [GCC<"tls_model">];
608 let Subjects = SubjectList<[TLSVar], ErrorDiag>;
609 let Args = [StringArgument<"Model">];
610 let Documentation = [TLSModelDocs];
613 def AnalyzerNoReturn : InheritableAttr {
614 // TODO: should this attribute be exposed with a [[]] spelling under the clang
615 // vendor namespace, or should it use a vendor namespace specific to the
617 let Spellings = [GNU<"analyzer_noreturn">];
618 let Documentation = [Undocumented];
621 def Annotate : InheritableParamAttr {
622 let Spellings = [Clang<"annotate">];
623 let Args = [StringArgument<"Annotation">];
624 // Ensure that the annotate attribute can be used with
625 // '#pragma clang attribute' even though it has no subject list.
626 let ForcePragmaAttributeSupport = 1;
627 let Documentation = [Undocumented];
630 def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> {
631 // NOTE: If you add any additional spellings, MSP430Interrupt's,
632 // MipsInterrupt's and AnyX86Interrupt's spellings must match.
633 let Spellings = [GCC<"interrupt">];
634 let Args = [EnumArgument<"Interrupt", "InterruptType",
635 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
636 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
638 let ParseKind = "Interrupt";
639 let HasCustomParsing = 1;
640 let Documentation = [ARMInterruptDocs];
643 def AVRInterrupt : InheritableAttr, TargetSpecificAttr<TargetAVR> {
644 let Spellings = [GCC<"interrupt">];
645 let Subjects = SubjectList<[Function]>;
646 let ParseKind = "Interrupt";
647 let Documentation = [AVRInterruptDocs];
650 def AVRSignal : InheritableAttr, TargetSpecificAttr<TargetAVR> {
651 let Spellings = [GCC<"signal">];
652 let Subjects = SubjectList<[Function]>;
653 let Documentation = [AVRSignalDocs];
656 def AsmLabel : InheritableAttr {
657 let Spellings = [Keyword<"asm">, Keyword<"__asm__">];
658 let Args = [StringArgument<"Label">];
660 let Documentation = [Undocumented];
663 def Availability : InheritableAttr {
664 // TODO: does not have a [[]] spelling because it requires custom parsing
666 let Spellings = [GNU<"availability">];
667 let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
668 VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
669 BoolArgument<"unavailable">, StringArgument<"message">,
670 BoolArgument<"strict">, StringArgument<"replacement">];
671 let AdditionalMembers =
672 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
673 return llvm::StringSwitch<llvm::StringRef>(Platform)
674 .Case("android", "Android")
676 .Case("macos", "macOS")
677 .Case("tvos", "tvOS")
678 .Case("watchos", "watchOS")
679 .Case("ios_app_extension", "iOS (App Extension)")
680 .Case("macos_app_extension", "macOS (App Extension)")
681 .Case("tvos_app_extension", "tvOS (App Extension)")
682 .Case("watchos_app_extension", "watchOS (App Extension)")
683 .Default(llvm::StringRef());
685 static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) {
686 return llvm::StringSwitch<llvm::StringRef>(Platform)
688 .Case("macos", "macOS")
689 .Case("tvos", "tvOS")
690 .Case("watchos", "watchOS")
691 .Case("ios_app_extension", "iOSApplicationExtension")
692 .Case("macos_app_extension", "macOSApplicationExtension")
693 .Case("tvos_app_extension", "tvOSApplicationExtension")
694 .Case("watchos_app_extension", "watchOSApplicationExtension")
697 static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) {
698 return llvm::StringSwitch<llvm::StringRef>(Platform)
700 .Case("macOS", "macos")
701 .Case("tvOS", "tvos")
702 .Case("watchOS", "watchos")
703 .Case("iOSApplicationExtension", "ios_app_extension")
704 .Case("macOSApplicationExtension", "macos_app_extension")
705 .Case("tvOSApplicationExtension", "tvos_app_extension")
706 .Case("watchOSApplicationExtension", "watchos_app_extension")
709 let HasCustomParsing = 1;
710 let DuplicatesAllowedWhileMerging = 1;
711 let Subjects = SubjectList<[Named]>;
712 let Documentation = [AvailabilityDocs];
715 def ExternalSourceSymbol : InheritableAttr {
716 let Spellings = [Clang<"external_source_symbol">];
717 let Args = [StringArgument<"language", 1>,
718 StringArgument<"definedIn", 1>,
719 BoolArgument<"generatedDeclaration", 1>];
720 let HasCustomParsing = 1;
721 let Subjects = SubjectList<[Named]>;
722 let Documentation = [ExternalSourceSymbolDocs];
725 def Blocks : InheritableAttr {
726 let Spellings = [Clang<"blocks">];
727 let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
728 let Documentation = [Undocumented];
731 def Bounded : IgnoredAttr {
732 // Does not have a [[]] spelling because the attribute is ignored.
733 let Spellings = [GNU<"bounded">];
736 def CarriesDependency : InheritableParamAttr {
737 let Spellings = [GNU<"carries_dependency">,
738 CXX11<"","carries_dependency", 200809>];
739 let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>;
740 let Documentation = [CarriesDependencyDocs];
743 def CDecl : InheritableAttr {
744 let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">];
745 // let Subjects = [Function, ObjCMethod];
746 let Documentation = [Undocumented];
749 // cf_audited_transfer indicates that the given function has been
750 // audited and has been marked with the appropriate cf_consumed and
751 // cf_returns_retained attributes. It is generally applied by
752 // '#pragma clang arc_cf_code_audited' rather than explicitly.
753 def CFAuditedTransfer : InheritableAttr {
754 let Spellings = [Clang<"cf_audited_transfer">];
755 let Subjects = SubjectList<[Function], ErrorDiag>;
756 let Documentation = [Undocumented];
759 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
760 // It indicates that the function has unknown or unautomatable
761 // transfer semantics.
762 def CFUnknownTransfer : InheritableAttr {
763 let Spellings = [Clang<"cf_unknown_transfer">];
764 let Subjects = SubjectList<[Function], ErrorDiag>;
765 let Documentation = [Undocumented];
768 def CFReturnsRetained : InheritableAttr {
769 let Spellings = [Clang<"cf_returns_retained">];
770 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
771 let Documentation = [Undocumented];
774 def CFReturnsNotRetained : InheritableAttr {
775 let Spellings = [Clang<"cf_returns_not_retained">];
776 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
777 let Documentation = [Undocumented];
780 def CFConsumed : InheritableParamAttr {
781 let Spellings = [Clang<"cf_consumed">];
782 let Subjects = SubjectList<[ParmVar]>;
783 let Documentation = [Undocumented];
786 def Cleanup : InheritableAttr {
787 let Spellings = [GCC<"cleanup">];
788 let Args = [FunctionArgument<"FunctionDecl">];
789 let Subjects = SubjectList<[LocalVar]>;
790 let Documentation = [Undocumented];
793 def Cold : InheritableAttr {
794 let Spellings = [GCC<"cold">];
795 let Subjects = SubjectList<[Function]>;
796 let Documentation = [Undocumented];
799 def Common : InheritableAttr {
800 let Spellings = [GCC<"common">];
801 let Subjects = SubjectList<[Var]>;
802 let Documentation = [Undocumented];
805 def Const : InheritableAttr {
806 let Spellings = [GCC<"const">, GCC<"__const">];
807 let Documentation = [Undocumented];
810 def Constructor : InheritableAttr {
811 let Spellings = [GCC<"constructor">];
812 let Args = [DefaultIntArgument<"Priority", 65535>];
813 let Subjects = SubjectList<[Function]>;
814 let Documentation = [Undocumented];
817 // CUDA attributes are spelled __attribute__((attr)) or __declspec(__attr__),
818 // and they do not receive a [[]] spelling.
819 def CUDAConstant : InheritableAttr {
820 let Spellings = [GNU<"constant">, Declspec<"__constant__">];
821 let Subjects = SubjectList<[Var]>;
822 let LangOpts = [CUDA];
823 let Documentation = [Undocumented];
826 def CUDACudartBuiltin : IgnoredAttr {
827 let Spellings = [GNU<"cudart_builtin">, Declspec<"__cudart_builtin__">];
828 let LangOpts = [CUDA];
831 def CUDADevice : InheritableAttr {
832 let Spellings = [GNU<"device">, Declspec<"__device__">];
833 let Subjects = SubjectList<[Function, Var]>;
834 let LangOpts = [CUDA];
835 let Documentation = [Undocumented];
838 def CUDADeviceBuiltin : IgnoredAttr {
839 let Spellings = [GNU<"device_builtin">, Declspec<"__device_builtin__">];
840 let LangOpts = [CUDA];
843 def CUDADeviceBuiltinSurfaceType : IgnoredAttr {
844 let Spellings = [GNU<"device_builtin_surface_type">,
845 Declspec<"__device_builtin_surface_type__">];
846 let LangOpts = [CUDA];
849 def CUDADeviceBuiltinTextureType : IgnoredAttr {
850 let Spellings = [GNU<"device_builtin_texture_type">,
851 Declspec<"__device_builtin_texture_type__">];
852 let LangOpts = [CUDA];
855 def CUDAGlobal : InheritableAttr {
856 let Spellings = [GNU<"global">, Declspec<"__global__">];
857 let Subjects = SubjectList<[Function]>;
858 let LangOpts = [CUDA];
859 let Documentation = [Undocumented];
862 def CUDAHost : InheritableAttr {
863 let Spellings = [GNU<"host">, Declspec<"__host__">];
864 let Subjects = SubjectList<[Function]>;
865 let LangOpts = [CUDA];
866 let Documentation = [Undocumented];
869 def CUDAInvalidTarget : InheritableAttr {
871 let Subjects = SubjectList<[Function]>;
872 let LangOpts = [CUDA];
873 let Documentation = [Undocumented];
876 def CUDALaunchBounds : InheritableAttr {
877 let Spellings = [GNU<"launch_bounds">, Declspec<"__launch_bounds__">];
878 let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>];
879 let LangOpts = [CUDA];
880 let Subjects = SubjectList<[ObjCMethod, FunctionLike]>;
881 // An AST node is created for this attribute, but is not used by other parts
882 // of the compiler. However, this node needs to exist in the AST because
883 // non-LLVM backends may be relying on the attribute's presence.
884 let Documentation = [Undocumented];
887 def CUDAShared : InheritableAttr {
888 let Spellings = [GNU<"shared">, Declspec<"__shared__">];
889 let Subjects = SubjectList<[Var]>;
890 let LangOpts = [CUDA];
891 let Documentation = [Undocumented];
894 def C11NoReturn : InheritableAttr {
895 let Spellings = [Keyword<"_Noreturn">];
896 let Subjects = SubjectList<[Function], ErrorDiag>;
898 let Documentation = [C11NoReturnDocs];
901 def CXX11NoReturn : InheritableAttr {
902 let Spellings = [CXX11<"", "noreturn", 200809>];
903 let Subjects = SubjectList<[Function], ErrorDiag>;
904 let Documentation = [CXX11NoReturnDocs];
907 // Similar to CUDA, OpenCL attributes do not receive a [[]] spelling because
908 // the specification does not expose them with one currently.
909 def OpenCLKernel : InheritableAttr {
910 let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
911 let Subjects = SubjectList<[Function], ErrorDiag>;
912 let Documentation = [Undocumented];
915 def OpenCLUnrollHint : InheritableAttr {
916 let Spellings = [GNU<"opencl_unroll_hint">];
917 let Args = [UnsignedArgument<"UnrollHint">];
918 let Documentation = [OpenCLUnrollHintDocs];
921 def OpenCLIntelReqdSubGroupSize: InheritableAttr {
922 let Spellings = [GNU<"intel_reqd_sub_group_size">];
923 let Args = [UnsignedArgument<"SubGroupSize">];
924 let Subjects = SubjectList<[Function], ErrorDiag>;
925 let Documentation = [OpenCLIntelReqdSubGroupSizeDocs];
928 // This attribute is both a type attribute, and a declaration attribute (for
929 // parameter variables).
930 def OpenCLAccess : Attr {
931 let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
932 Keyword<"__write_only">, Keyword<"write_only">,
933 Keyword<"__read_write">, Keyword<"read_write">];
934 let Subjects = SubjectList<[ParmVar, TypedefName], ErrorDiag>;
935 let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
936 Keyword<"read_only">]>,
937 Accessor<"isReadWrite", [Keyword<"__read_write">,
938 Keyword<"read_write">]>,
939 Accessor<"isWriteOnly", [Keyword<"__write_only">,
940 Keyword<"write_only">]>];
941 let Documentation = [OpenCLAccessDocs];
944 def OpenCLPrivateAddressSpace : TypeAttr {
945 let Spellings = [Keyword<"__private">, Keyword<"private">];
946 let Documentation = [OpenCLAddressSpacePrivateDocs];
949 def OpenCLGlobalAddressSpace : TypeAttr {
950 let Spellings = [Keyword<"__global">, Keyword<"global">];
951 let Documentation = [OpenCLAddressSpaceGlobalDocs];
954 def OpenCLLocalAddressSpace : TypeAttr {
955 let Spellings = [Keyword<"__local">, Keyword<"local">];
956 let Documentation = [OpenCLAddressSpaceLocalDocs];
959 def OpenCLConstantAddressSpace : TypeAttr {
960 let Spellings = [Keyword<"__constant">, Keyword<"constant">];
961 let Documentation = [OpenCLAddressSpaceConstantDocs];
964 def OpenCLGenericAddressSpace : TypeAttr {
965 let Spellings = [Keyword<"__generic">, Keyword<"generic">];
966 let Documentation = [OpenCLAddressSpaceGenericDocs];
969 def OpenCLNoSVM : Attr {
970 let Spellings = [GNU<"nosvm">];
971 let Subjects = SubjectList<[Var]>;
972 let Documentation = [OpenCLNoSVMDocs];
973 let LangOpts = [OpenCL];
977 def RenderScriptKernel : Attr {
978 let Spellings = [GNU<"kernel">];
979 let Subjects = SubjectList<[Function]>;
980 let Documentation = [RenderScriptKernelAttributeDocs];
981 let LangOpts = [RenderScript];
984 def Deprecated : InheritableAttr {
985 let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
986 CXX11<"","deprecated", 201309>, C2x<"", "deprecated">];
987 let Args = [StringArgument<"Message", 1>,
988 // An optional string argument that enables us to provide a
990 StringArgument<"Replacement", 1>];
991 let MeaningfulToClassTemplateDefinition = 1;
992 let Documentation = [DeprecatedDocs];
995 def Destructor : InheritableAttr {
996 let Spellings = [GCC<"destructor">];
997 let Args = [DefaultIntArgument<"Priority", 65535>];
998 let Subjects = SubjectList<[Function]>;
999 let Documentation = [Undocumented];
1002 def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
1003 let Spellings = [Declspec<"empty_bases">];
1004 let Subjects = SubjectList<[CXXRecord]>;
1005 let Documentation = [EmptyBasesDocs];
1008 def AllocSize : InheritableAttr {
1009 let Spellings = [GCC<"alloc_size">];
1010 let Subjects = SubjectList<[Function]>;
1011 let Args = [IntArgument<"ElemSizeParam">, IntArgument<"NumElemsParam", 1>];
1012 let TemplateDependent = 1;
1013 let Documentation = [AllocSizeDocs];
1016 def EnableIf : InheritableAttr {
1017 // Does not have a [[]] spelling because this attribute requires the ability
1018 // to parse function arguments but the attribute is not written in the type
1020 let Spellings = [GNU<"enable_if">];
1021 let Subjects = SubjectList<[Function]>;
1022 let Args = [ExprArgument<"Cond">, StringArgument<"Message">];
1023 let TemplateDependent = 1;
1024 let Documentation = [EnableIfDocs];
1027 def ExtVectorType : Attr {
1028 // This is an OpenCL-related attribute and does not receive a [[]] spelling.
1029 let Spellings = [GNU<"ext_vector_type">];
1030 let Subjects = SubjectList<[TypedefName], ErrorDiag>;
1031 let Args = [ExprArgument<"NumElements">];
1033 let Documentation = [Undocumented];
1036 def FallThrough : StmtAttr {
1037 let Spellings = [CXX11<"", "fallthrough", 201603>, C2x<"", "fallthrough">,
1038 CXX11<"clang", "fallthrough">];
1039 // let Subjects = [NullStmt];
1040 let Documentation = [FallthroughDocs];
1043 def FastCall : InheritableAttr {
1044 let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
1045 Keyword<"_fastcall">];
1046 // let Subjects = [Function, ObjCMethod];
1047 let Documentation = [FastCallDocs];
1050 def RegCall : InheritableAttr {
1051 let Spellings = [GCC<"regcall">, Keyword<"__regcall">];
1052 let Documentation = [RegCallDocs];
1055 def Final : InheritableAttr {
1056 let Spellings = [Keyword<"final">, Keyword<"sealed">];
1057 let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
1058 let SemaHandler = 0;
1059 let Documentation = [Undocumented];
1062 def MinSize : InheritableAttr {
1063 let Spellings = [Clang<"minsize">];
1064 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
1065 let Documentation = [Undocumented];
1068 def FlagEnum : InheritableAttr {
1069 let Spellings = [Clang<"flag_enum">];
1070 let Subjects = SubjectList<[Enum]>;
1071 let Documentation = [FlagEnumDocs];
1074 def EnumExtensibility : InheritableAttr {
1075 let Spellings = [Clang<"enum_extensibility">];
1076 let Subjects = SubjectList<[Enum]>;
1077 let Args = [EnumArgument<"Extensibility", "Kind",
1078 ["closed", "open"], ["Closed", "Open"]>];
1079 let Documentation = [EnumExtensibilityDocs];
1082 def Flatten : InheritableAttr {
1083 let Spellings = [GCC<"flatten">];
1084 let Subjects = SubjectList<[Function], ErrorDiag>;
1085 let Documentation = [FlattenDocs];
1088 def Format : InheritableAttr {
1089 let Spellings = [GCC<"format">];
1090 let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
1091 IntArgument<"FirstArg">];
1092 let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto]>;
1093 let Documentation = [FormatDocs];
1096 def FormatArg : InheritableAttr {
1097 let Spellings = [GCC<"format_arg">];
1098 let Args = [IntArgument<"FormatIdx">];
1099 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto]>;
1100 let Documentation = [Undocumented];
1103 def GNUInline : InheritableAttr {
1104 let Spellings = [GCC<"gnu_inline">];
1105 let Subjects = SubjectList<[Function]>;
1106 let Documentation = [Undocumented];
1109 def Hot : InheritableAttr {
1110 let Spellings = [GCC<"hot">];
1111 let Subjects = SubjectList<[Function]>;
1112 // An AST node is created for this attribute, but not actually used beyond
1113 // semantic checking for mutual exclusion with the Cold attribute.
1114 let Documentation = [Undocumented];
1117 def IBAction : InheritableAttr {
1118 let Spellings = [Clang<"ibaction">];
1119 let Subjects = SubjectList<[ObjCInstanceMethod]>;
1120 // An AST node is created for this attribute, but is not used by other parts
1121 // of the compiler. However, this node needs to exist in the AST because
1122 // external tools rely on it.
1123 let Documentation = [Undocumented];
1126 def IBOutlet : InheritableAttr {
1127 let Spellings = [Clang<"iboutlet">];
1128 // let Subjects = [ObjCIvar, ObjCProperty];
1129 let Documentation = [Undocumented];
1132 def IBOutletCollection : InheritableAttr {
1133 let Spellings = [Clang<"iboutletcollection">];
1134 let Args = [TypeArgument<"Interface", 1>];
1135 // let Subjects = [ObjCIvar, ObjCProperty];
1136 let Documentation = [Undocumented];
1139 def IFunc : Attr, TargetSpecificAttr<TargetELF> {
1140 let Spellings = [GCC<"ifunc">];
1141 let Args = [StringArgument<"Resolver">];
1142 let Subjects = SubjectList<[Function]>;
1143 let Documentation = [IFuncDocs];
1146 def Restrict : InheritableAttr {
1147 let Spellings = [Declspec<"restrict">, GCC<"malloc">];
1148 let Subjects = SubjectList<[Function]>;
1149 let Documentation = [Undocumented];
1152 def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
1153 let Spellings = [Declspec<"layout_version">];
1154 let Args = [UnsignedArgument<"Version">];
1155 let Subjects = SubjectList<[CXXRecord]>;
1156 let Documentation = [LayoutVersionDocs];
1159 def MaxFieldAlignment : InheritableAttr {
1160 // This attribute has no spellings as it is only ever created implicitly.
1162 let Args = [UnsignedArgument<"Alignment">];
1163 let SemaHandler = 0;
1164 let Documentation = [Undocumented];
1167 def MayAlias : InheritableAttr {
1168 // FIXME: this is a type attribute in GCC, but a declaration attribute here.
1169 let Spellings = [GCC<"may_alias">];
1170 let Documentation = [Undocumented];
1173 def MSABI : InheritableAttr {
1174 let Spellings = [GCC<"ms_abi">];
1175 // let Subjects = [Function, ObjCMethod];
1176 let Documentation = [MSABIDocs];
1179 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
1180 // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's
1181 // and AnyX86Interrupt's spellings must match.
1182 let Spellings = [GCC<"interrupt">];
1183 let Args = [UnsignedArgument<"Number">];
1184 let ParseKind = "Interrupt";
1185 let HasCustomParsing = 1;
1186 let Documentation = [Undocumented];
1189 def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1190 let Spellings = [GCC<"mips16">];
1191 let Subjects = SubjectList<[Function], ErrorDiag>;
1192 let Documentation = [Undocumented];
1195 def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1196 // NOTE: If you add any additional spellings, ARMInterrupt's,
1197 // MSP430Interrupt's and AnyX86Interrupt's spellings must match.
1198 let Spellings = [GCC<"interrupt">];
1199 let Subjects = SubjectList<[Function]>;
1200 let Args = [EnumArgument<"Interrupt", "InterruptType",
1201 ["vector=sw0", "vector=sw1", "vector=hw0",
1202 "vector=hw1", "vector=hw2", "vector=hw3",
1203 "vector=hw4", "vector=hw5", "eic", ""],
1204 ["sw0", "sw1", "hw0", "hw1", "hw2", "hw3",
1205 "hw4", "hw5", "eic", "eic"]
1207 let ParseKind = "Interrupt";
1208 let Documentation = [MipsInterruptDocs];
1211 def MicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1212 let Spellings = [GCC<"micromips">];
1213 let Subjects = SubjectList<[Function], ErrorDiag>;
1214 let Documentation = [MicroMipsDocs];
1217 def MipsLongCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
1218 let Spellings = [GCC<"long_call">, GCC<"far">];
1219 let Subjects = SubjectList<[Function]>;
1220 let Documentation = [MipsLongCallStyleDocs];
1223 def MipsShortCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
1224 let Spellings = [GCC<"short_call">, GCC<"near">];
1225 let Subjects = SubjectList<[Function]>;
1226 let Documentation = [MipsShortCallStyleDocs];
1230 let Spellings = [GCC<"mode">];
1231 let Subjects = SubjectList<[Var, Enum, TypedefName, Field], ErrorDiag>;
1232 let Args = [IdentifierArgument<"Mode">];
1233 let Documentation = [Undocumented];
1236 def Naked : InheritableAttr {
1237 let Spellings = [GCC<"naked">, Declspec<"naked">];
1238 let Subjects = SubjectList<[Function]>;
1239 let Documentation = [Undocumented];
1242 def NeonPolyVectorType : TypeAttr {
1243 let Spellings = [Clang<"neon_polyvector_type">];
1244 let Args = [IntArgument<"NumElements">];
1245 let Documentation = [Undocumented];
1248 def NeonVectorType : TypeAttr {
1249 let Spellings = [Clang<"neon_vector_type">];
1250 let Args = [IntArgument<"NumElements">];
1251 let Documentation = [Undocumented];
1254 def ReturnsTwice : InheritableAttr {
1255 let Spellings = [GCC<"returns_twice">];
1256 let Subjects = SubjectList<[Function]>;
1257 let Documentation = [Undocumented];
1260 def DisableTailCalls : InheritableAttr {
1261 let Spellings = [Clang<"disable_tail_calls">];
1262 let Subjects = SubjectList<[Function, ObjCMethod]>;
1263 let Documentation = [DisableTailCallsDocs];
1266 def NoAlias : InheritableAttr {
1267 let Spellings = [Declspec<"noalias">];
1268 let Subjects = SubjectList<[Function]>;
1269 let Documentation = [NoAliasDocs];
1272 def NoCommon : InheritableAttr {
1273 let Spellings = [GCC<"nocommon">];
1274 let Subjects = SubjectList<[Var]>;
1275 let Documentation = [Undocumented];
1278 def NoDebug : InheritableAttr {
1279 let Spellings = [GCC<"nodebug">];
1280 let Subjects = SubjectList<[FunctionLike, ObjCMethod, NonParmVar]>;
1281 let Documentation = [NoDebugDocs];
1284 def NoDuplicate : InheritableAttr {
1285 let Spellings = [Clang<"noduplicate">];
1286 let Subjects = SubjectList<[Function]>;
1287 let Documentation = [NoDuplicateDocs];
1290 def Convergent : InheritableAttr {
1291 let Spellings = [Clang<"convergent">];
1292 let Subjects = SubjectList<[Function]>;
1293 let Documentation = [ConvergentDocs];
1296 def NoInline : InheritableAttr {
1297 let Spellings = [GCC<"noinline">, Declspec<"noinline">];
1298 let Subjects = SubjectList<[Function]>;
1299 let Documentation = [Undocumented];
1302 def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1303 let Spellings = [GCC<"nomips16">];
1304 let Subjects = SubjectList<[Function], ErrorDiag>;
1305 let Documentation = [Undocumented];
1308 def NoMicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> {
1309 let Spellings = [GCC<"nomicromips">];
1310 let Subjects = SubjectList<[Function], ErrorDiag>;
1311 let Documentation = [MicroMipsDocs];
1314 // This is not a TargetSpecificAttr so that is silently accepted and
1315 // ignored on other targets as encouraged by the OpenCL spec.
1317 // See OpenCL 1.2 6.11.5: "It is our intention that a particular
1318 // implementation of OpenCL be free to ignore all attributes and the
1319 // resulting executable binary will produce the same result."
1321 // However, only AMD GPU targets will emit the corresponding IR
1324 // FIXME: This provides a sub-optimal error message if you attempt to
1325 // use this in CUDA, since CUDA does not use the same terminology.
1327 // FIXME: SubjectList should be for OpenCLKernelFunction, but is not to
1328 // workaround needing to see kernel attribute before others to know if
1329 // this should be rejected on non-kernels.
1331 def AMDGPUFlatWorkGroupSize : InheritableAttr {
1332 let Spellings = [Clang<"amdgpu_flat_work_group_size">];
1333 let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max">];
1334 let Documentation = [AMDGPUFlatWorkGroupSizeDocs];
1335 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1338 def AMDGPUWavesPerEU : InheritableAttr {
1339 let Spellings = [Clang<"amdgpu_waves_per_eu">];
1340 let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max", 1>];
1341 let Documentation = [AMDGPUWavesPerEUDocs];
1342 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1345 def AMDGPUNumSGPR : InheritableAttr {
1346 let Spellings = [Clang<"amdgpu_num_sgpr">];
1347 let Args = [UnsignedArgument<"NumSGPR">];
1348 let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1349 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1352 def AMDGPUNumVGPR : InheritableAttr {
1353 let Spellings = [Clang<"amdgpu_num_vgpr">];
1354 let Args = [UnsignedArgument<"NumVGPR">];
1355 let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1356 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
1359 def NoSplitStack : InheritableAttr {
1360 let Spellings = [GCC<"no_split_stack">];
1361 let Subjects = SubjectList<[Function], ErrorDiag>;
1362 let Documentation = [NoSplitStackDocs];
1365 def NonNull : InheritableParamAttr {
1366 let Spellings = [GCC<"nonnull">];
1367 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
1368 "functions, methods, and parameters">;
1369 let Args = [VariadicUnsignedArgument<"Args">];
1370 let AdditionalMembers =
1371 [{bool isNonNull(unsigned idx) const {
1374 for (const auto &V : args())
1379 // FIXME: We should merge duplicates into a single nonnull attribute.
1380 let DuplicatesAllowedWhileMerging = 1;
1381 let Documentation = [NonNullDocs];
1384 def ReturnsNonNull : InheritableAttr {
1385 let Spellings = [GCC<"returns_nonnull">];
1386 let Subjects = SubjectList<[ObjCMethod, Function]>;
1387 let Documentation = [ReturnsNonNullDocs];
1390 // pass_object_size(N) indicates that the parameter should have
1391 // __builtin_object_size with Type=N evaluated on the parameter at the callsite.
1392 def PassObjectSize : InheritableParamAttr {
1393 let Spellings = [Clang<"pass_object_size">];
1394 let Args = [IntArgument<"Type">];
1395 let Subjects = SubjectList<[ParmVar]>;
1396 let Documentation = [PassObjectSizeDocs];
1399 // Nullability type attributes.
1400 def TypeNonNull : TypeAttr {
1401 let Spellings = [Keyword<"_Nonnull">];
1402 let Documentation = [TypeNonNullDocs];
1405 def TypeNullable : TypeAttr {
1406 let Spellings = [Keyword<"_Nullable">];
1407 let Documentation = [TypeNullableDocs];
1410 def TypeNullUnspecified : TypeAttr {
1411 let Spellings = [Keyword<"_Null_unspecified">];
1412 let Documentation = [TypeNullUnspecifiedDocs];
1415 def ObjCKindOf : TypeAttr {
1416 let Spellings = [Keyword<"__kindof">];
1417 let Documentation = [Undocumented];
1420 def NoEscape : Attr {
1421 let Spellings = [Clang<"noescape">];
1422 let Subjects = SubjectList<[ParmVar]>;
1423 let Documentation = [NoEscapeDocs];
1426 def AssumeAligned : InheritableAttr {
1427 let Spellings = [GCC<"assume_aligned">];
1428 let Subjects = SubjectList<[ObjCMethod, Function]>;
1429 let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>];
1430 let Documentation = [AssumeAlignedDocs];
1433 def AllocAlign : InheritableAttr {
1434 let Spellings = [GCC<"alloc_align">];
1435 let Subjects = SubjectList<[HasFunctionProto]>;
1436 let Args = [IntArgument<"ParamIndex">];
1437 let Documentation = [AllocAlignDocs];
1440 def NoReturn : InheritableAttr {
1441 let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
1442 // FIXME: Does GCC allow this on the function instead?
1443 let Documentation = [Undocumented];
1446 def NoInstrumentFunction : InheritableAttr {
1447 let Spellings = [GCC<"no_instrument_function">];
1448 let Subjects = SubjectList<[Function]>;
1449 let Documentation = [Undocumented];
1452 def NotTailCalled : InheritableAttr {
1453 let Spellings = [Clang<"not_tail_called">];
1454 let Subjects = SubjectList<[Function]>;
1455 let Documentation = [NotTailCalledDocs];
1458 def NoThrow : InheritableAttr {
1459 let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
1460 let Subjects = SubjectList<[Function]>;
1461 let Documentation = [NoThrowDocs];
1464 def NvWeak : IgnoredAttr {
1465 // No Declspec spelling of this attribute; the CUDA headers use
1466 // __attribute__((nv_weak)) unconditionally. Does not receive an [[]]
1467 // spelling because it is a CUDA attribute.
1468 let Spellings = [GNU<"nv_weak">];
1469 let LangOpts = [CUDA];
1472 def ObjCBridge : InheritableAttr {
1473 let Spellings = [Clang<"objc_bridge">];
1474 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag>;
1475 let Args = [IdentifierArgument<"BridgedType">];
1476 let Documentation = [Undocumented];
1479 def ObjCBridgeMutable : InheritableAttr {
1480 let Spellings = [Clang<"objc_bridge_mutable">];
1481 let Subjects = SubjectList<[Record], ErrorDiag>;
1482 let Args = [IdentifierArgument<"BridgedType">];
1483 let Documentation = [Undocumented];
1486 def ObjCBridgeRelated : InheritableAttr {
1487 // TODO: this attribute does not have a [[]] spelling because it requires
1488 // custom parsing support.
1489 let Spellings = [GNU<"objc_bridge_related">];
1490 let Subjects = SubjectList<[Record], ErrorDiag>;
1491 let Args = [IdentifierArgument<"RelatedClass">,
1492 IdentifierArgument<"ClassMethod", 1>,
1493 IdentifierArgument<"InstanceMethod", 1>];
1494 let HasCustomParsing = 1;
1495 let Documentation = [Undocumented];
1498 def NSReturnsRetained : InheritableAttr {
1499 let Spellings = [Clang<"ns_returns_retained">];
1500 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1501 let Documentation = [Undocumented];
1504 def NSReturnsNotRetained : InheritableAttr {
1505 let Spellings = [Clang<"ns_returns_not_retained">];
1506 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1507 let Documentation = [Undocumented];
1510 def NSReturnsAutoreleased : InheritableAttr {
1511 let Spellings = [Clang<"ns_returns_autoreleased">];
1512 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1513 let Documentation = [Undocumented];
1516 def NSConsumesSelf : InheritableAttr {
1517 let Spellings = [Clang<"ns_consumes_self">];
1518 let Subjects = SubjectList<[ObjCMethod]>;
1519 let Documentation = [Undocumented];
1522 def NSConsumed : InheritableParamAttr {
1523 let Spellings = [Clang<"ns_consumed">];
1524 let Subjects = SubjectList<[ParmVar]>;
1525 let Documentation = [Undocumented];
1528 def ObjCException : InheritableAttr {
1529 let Spellings = [Clang<"objc_exception">];
1530 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1531 let Documentation = [Undocumented];
1534 def ObjCMethodFamily : InheritableAttr {
1535 let Spellings = [Clang<"objc_method_family">];
1536 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1537 let Args = [EnumArgument<"Family", "FamilyKind",
1538 ["none", "alloc", "copy", "init", "mutableCopy", "new"],
1539 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
1540 "OMF_mutableCopy", "OMF_new"]>];
1541 let Documentation = [ObjCMethodFamilyDocs];
1544 def ObjCNSObject : InheritableAttr {
1545 let Spellings = [Clang<"NSObject">];
1546 let Documentation = [Undocumented];
1549 def ObjCIndependentClass : InheritableAttr {
1550 let Spellings = [Clang<"objc_independent_class">];
1551 let Documentation = [Undocumented];
1554 def ObjCPreciseLifetime : InheritableAttr {
1555 let Spellings = [Clang<"objc_precise_lifetime">];
1556 let Subjects = SubjectList<[Var], ErrorDiag>;
1557 let Documentation = [Undocumented];
1560 def ObjCReturnsInnerPointer : InheritableAttr {
1561 let Spellings = [Clang<"objc_returns_inner_pointer">];
1562 let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
1563 let Documentation = [Undocumented];
1566 def ObjCRequiresSuper : InheritableAttr {
1567 let Spellings = [Clang<"objc_requires_super">];
1568 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1569 let Documentation = [ObjCRequiresSuperDocs];
1572 def ObjCRootClass : InheritableAttr {
1573 let Spellings = [Clang<"objc_root_class">];
1574 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1575 let Documentation = [Undocumented];
1578 def ObjCSubclassingRestricted : InheritableAttr {
1579 let Spellings = [Clang<"objc_subclassing_restricted">];
1580 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1581 let Documentation = [ObjCSubclassingRestrictedDocs];
1584 def ObjCExplicitProtocolImpl : InheritableAttr {
1585 let Spellings = [Clang<"objc_protocol_requires_explicit_implementation">];
1586 let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
1587 let Documentation = [Undocumented];
1590 def ObjCDesignatedInitializer : Attr {
1591 let Spellings = [Clang<"objc_designated_initializer">];
1592 let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag>;
1593 let Documentation = [Undocumented];
1596 def ObjCRuntimeName : Attr {
1597 let Spellings = [Clang<"objc_runtime_name">];
1598 let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
1599 let Args = [StringArgument<"MetadataName">];
1600 let Documentation = [ObjCRuntimeNameDocs];
1603 def ObjCRuntimeVisible : Attr {
1604 let Spellings = [Clang<"objc_runtime_visible">];
1605 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1606 let Documentation = [ObjCRuntimeVisibleDocs];
1609 def ObjCBoxable : Attr {
1610 let Spellings = [Clang<"objc_boxable">];
1611 let Subjects = SubjectList<[Record], ErrorDiag>;
1612 let Documentation = [ObjCBoxableDocs];
1615 def OptimizeNone : InheritableAttr {
1616 let Spellings = [Clang<"optnone">];
1617 let Subjects = SubjectList<[Function, ObjCMethod]>;
1618 let Documentation = [OptnoneDocs];
1621 def Overloadable : Attr {
1622 let Spellings = [Clang<"overloadable">];
1623 let Subjects = SubjectList<[Function], ErrorDiag>;
1624 let Documentation = [OverloadableDocs];
1627 def Override : InheritableAttr {
1628 let Spellings = [Keyword<"override">];
1629 let SemaHandler = 0;
1630 let Documentation = [Undocumented];
1633 def Ownership : InheritableAttr {
1634 let Spellings = [Clang<"ownership_holds">, Clang<"ownership_returns">,
1635 Clang<"ownership_takes">];
1636 let Accessors = [Accessor<"isHolds", [Clang<"ownership_holds">]>,
1637 Accessor<"isReturns", [Clang<"ownership_returns">]>,
1638 Accessor<"isTakes", [Clang<"ownership_takes">]>];
1639 let AdditionalMembers = [{
1640 enum OwnershipKind { Holds, Returns, Takes };
1641 OwnershipKind getOwnKind() const {
1642 return isHolds() ? Holds :
1647 let Args = [IdentifierArgument<"Module">, VariadicUnsignedArgument<"Args">];
1648 let Subjects = SubjectList<[HasFunctionProto]>;
1649 let Documentation = [Undocumented];
1652 def Packed : InheritableAttr {
1653 let Spellings = [GCC<"packed">];
1654 // let Subjects = [Tag, Field];
1655 let Documentation = [Undocumented];
1658 def IntelOclBicc : InheritableAttr {
1659 let Spellings = [Clang<"intel_ocl_bicc">];
1660 // let Subjects = [Function, ObjCMethod];
1661 let Documentation = [Undocumented];
1664 def Pcs : InheritableAttr {
1665 let Spellings = [GCC<"pcs">];
1666 let Args = [EnumArgument<"PCS", "PCSType",
1667 ["aapcs", "aapcs-vfp"],
1668 ["AAPCS", "AAPCS_VFP"]>];
1669 // let Subjects = [Function, ObjCMethod];
1670 let Documentation = [PcsDocs];
1673 def Pure : InheritableAttr {
1674 let Spellings = [GCC<"pure">];
1675 let Documentation = [Undocumented];
1678 def Regparm : TypeAttr {
1679 let Spellings = [GCC<"regparm">];
1680 let Args = [UnsignedArgument<"NumParams">];
1681 let Documentation = [RegparmDocs];
1684 def ReqdWorkGroupSize : InheritableAttr {
1685 // Does not have a [[]] spelling because it is an OpenCL-related attribute.
1686 let Spellings = [GNU<"reqd_work_group_size">];
1687 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
1688 UnsignedArgument<"ZDim">];
1689 let Subjects = SubjectList<[Function], ErrorDiag>;
1690 let Documentation = [Undocumented];
1693 def RequireConstantInit : InheritableAttr {
1694 let Spellings = [Clang<"require_constant_initialization">];
1695 let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
1696 let Documentation = [RequireConstantInitDocs];
1697 let LangOpts = [CPlusPlus];
1700 def WorkGroupSizeHint : InheritableAttr {
1701 // Does not have a [[]] spelling because it is an OpenCL-related attribute.
1702 let Spellings = [GNU<"work_group_size_hint">];
1703 let Args = [UnsignedArgument<"XDim">,
1704 UnsignedArgument<"YDim">,
1705 UnsignedArgument<"ZDim">];
1706 let Subjects = SubjectList<[Function], ErrorDiag>;
1707 let Documentation = [Undocumented];
1710 def InitPriority : InheritableAttr {
1711 let Spellings = [GCC<"init_priority">];
1712 let Args = [UnsignedArgument<"Priority">];
1713 let Subjects = SubjectList<[Var], ErrorDiag>;
1714 let Documentation = [Undocumented];
1717 def Section : InheritableAttr {
1718 let Spellings = [GCC<"section">, Declspec<"allocate">];
1719 let Args = [StringArgument<"Name">];
1721 SubjectList<[ Function, GlobalVar, ObjCMethod, ObjCProperty ], ErrorDiag>;
1722 let Documentation = [SectionDocs];
1725 def PragmaClangBSSSection : InheritableAttr {
1726 // This attribute has no spellings as it is only ever created implicitly.
1728 let Args = [StringArgument<"Name">];
1729 let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
1730 let Documentation = [Undocumented];
1733 def PragmaClangDataSection : InheritableAttr {
1734 // This attribute has no spellings as it is only ever created implicitly.
1736 let Args = [StringArgument<"Name">];
1737 let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
1738 let Documentation = [Undocumented];
1741 def PragmaClangRodataSection : InheritableAttr {
1742 // This attribute has no spellings as it is only ever created implicitly.
1744 let Args = [StringArgument<"Name">];
1745 let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
1746 let Documentation = [Undocumented];
1749 def PragmaClangTextSection : InheritableAttr {
1750 // This attribute has no spellings as it is only ever created implicitly.
1752 let Args = [StringArgument<"Name">];
1753 let Subjects = SubjectList<[Function], ErrorDiag>;
1754 let Documentation = [Undocumented];
1757 def Sentinel : InheritableAttr {
1758 let Spellings = [GCC<"sentinel">];
1759 let Args = [DefaultIntArgument<"Sentinel", 0>,
1760 DefaultIntArgument<"NullPos", 0>];
1761 // let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
1762 let Documentation = [Undocumented];
1765 def StdCall : InheritableAttr {
1766 let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
1767 // let Subjects = [Function, ObjCMethod];
1768 let Documentation = [StdCallDocs];
1771 def SwiftCall : InheritableAttr {
1772 let Spellings = [Clang<"swiftcall">];
1773 // let Subjects = SubjectList<[Function]>;
1774 let Documentation = [SwiftCallDocs];
1777 def SwiftContext : ParameterABIAttr {
1778 let Spellings = [Clang<"swift_context">];
1779 let Documentation = [SwiftContextDocs];
1782 def SwiftErrorResult : ParameterABIAttr {
1783 let Spellings = [Clang<"swift_error_result">];
1784 let Documentation = [SwiftErrorResultDocs];
1787 def SwiftIndirectResult : ParameterABIAttr {
1788 let Spellings = [Clang<"swift_indirect_result">];
1789 let Documentation = [SwiftIndirectResultDocs];
1792 def Suppress : StmtAttr {
1793 let Spellings = [CXX11<"gsl", "suppress">];
1794 let Args = [VariadicStringArgument<"DiagnosticIdentifiers">];
1795 let Documentation = [SuppressDocs];
1798 def SysVABI : InheritableAttr {
1799 let Spellings = [GCC<"sysv_abi">];
1800 // let Subjects = [Function, ObjCMethod];
1801 let Documentation = [Undocumented];
1804 def ThisCall : InheritableAttr {
1805 let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
1806 Keyword<"_thiscall">];
1807 // let Subjects = [Function, ObjCMethod];
1808 let Documentation = [ThisCallDocs];
1811 def VectorCall : InheritableAttr {
1812 let Spellings = [Clang<"vectorcall">, Keyword<"__vectorcall">,
1813 Keyword<"_vectorcall">];
1814 // let Subjects = [Function, ObjCMethod];
1815 let Documentation = [VectorCallDocs];
1818 def Pascal : InheritableAttr {
1819 let Spellings = [Clang<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
1820 // let Subjects = [Function, ObjCMethod];
1821 let Documentation = [Undocumented];
1824 def PreserveMost : InheritableAttr {
1825 let Spellings = [Clang<"preserve_most">];
1826 let Documentation = [PreserveMostDocs];
1829 def PreserveAll : InheritableAttr {
1830 let Spellings = [Clang<"preserve_all">];
1831 let Documentation = [PreserveAllDocs];
1834 def Target : InheritableAttr {
1835 let Spellings = [GCC<"target">];
1836 let Args = [StringArgument<"featuresStr">];
1837 let Subjects = SubjectList<[Function], ErrorDiag>;
1838 let Documentation = [TargetDocs];
1839 let AdditionalMembers = [{
1840 struct ParsedTargetAttr {
1841 std::vector<std::string> Features;
1842 StringRef Architecture;
1843 bool DuplicateArchitecture = false;
1845 ParsedTargetAttr parse() const {
1846 return parse(getFeaturesStr());
1848 static ParsedTargetAttr parse(StringRef Features) {
1849 ParsedTargetAttr Ret;
1850 SmallVector<StringRef, 1> AttrFeatures;
1851 Features.split(AttrFeatures, ",");
1853 // Grab the various features and prepend a "+" to turn on the feature to
1854 // the backend and add them to our existing set of features.
1855 for (auto &Feature : AttrFeatures) {
1856 // Go ahead and trim whitespace rather than either erroring or
1857 // accepting it weirdly.
1858 Feature = Feature.trim();
1860 // We don't support cpu tuning this way currently.
1861 // TODO: Support the fpmath option. It will require checking
1862 // overall feature validity for the function with the rest of the
1863 // attributes on the function.
1864 if (Feature.startswith("fpmath=") || Feature.startswith("tune="))
1867 // While we're here iterating check for a different target cpu.
1868 if (Feature.startswith("arch=")) {
1869 if (!Ret.Architecture.empty())
1870 Ret.DuplicateArchitecture = true;
1872 Ret.Architecture = Feature.split("=").second.trim();
1873 } else if (Feature.startswith("no-"))
1874 Ret.Features.push_back("-" + Feature.split("-").second.str());
1876 Ret.Features.push_back("+" + Feature.str());
1883 def TransparentUnion : InheritableAttr {
1884 let Spellings = [GCC<"transparent_union">];
1885 // let Subjects = SubjectList<[Record, TypedefName]>;
1886 let Documentation = [TransparentUnionDocs];
1887 let LangOpts = [COnly];
1890 def Unavailable : InheritableAttr {
1891 let Spellings = [Clang<"unavailable">];
1892 let Args = [StringArgument<"Message", 1>,
1893 EnumArgument<"ImplicitReason", "ImplicitReason",
1896 "IR_ARCForbiddenType",
1898 "IR_ARCForbiddenConversion",
1899 "IR_ARCInitReturnsUnrelated",
1900 "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>];
1901 let Documentation = [Undocumented];
1904 def DiagnoseIf : InheritableAttr {
1905 // Does not have a [[]] spelling because this attribute requires the ability
1906 // to parse function arguments but the attribute is not written in the type
1908 let Spellings = [GNU<"diagnose_if">];
1909 let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;
1910 let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
1911 EnumArgument<"DiagnosticType",
1913 ["error", "warning"],
1914 ["DT_Error", "DT_Warning"]>,
1915 BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
1916 NamedArgument<"Parent", 0, /*fake*/ 1>];
1917 let DuplicatesAllowedWhileMerging = 1;
1919 let AdditionalMembers = [{
1920 bool isError() const { return diagnosticType == DT_Error; }
1921 bool isWarning() const { return diagnosticType == DT_Warning; }
1923 let TemplateDependent = 1;
1924 let Documentation = [DiagnoseIfDocs];
1927 def ArcWeakrefUnavailable : InheritableAttr {
1928 let Spellings = [Clang<"objc_arc_weak_reference_unavailable">];
1929 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1930 let Documentation = [Undocumented];
1933 def ObjCGC : TypeAttr {
1934 let Spellings = [Clang<"objc_gc">];
1935 let Args = [IdentifierArgument<"Kind">];
1936 let Documentation = [Undocumented];
1939 def ObjCOwnership : InheritableAttr {
1940 let Spellings = [Clang<"objc_ownership">];
1941 let Args = [IdentifierArgument<"Kind">];
1943 let Documentation = [Undocumented];
1946 def ObjCRequiresPropertyDefs : InheritableAttr {
1947 let Spellings = [Clang<"objc_requires_property_definitions">];
1948 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1949 let Documentation = [Undocumented];
1952 def Unused : InheritableAttr {
1953 let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
1954 C2x<"", "maybe_unused">];
1955 let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
1956 Field, ObjCMethod, FunctionLike]>;
1957 let Documentation = [WarnMaybeUnusedDocs];
1960 def Used : InheritableAttr {
1961 let Spellings = [GCC<"used">];
1962 let Documentation = [Undocumented];
1965 def Uuid : InheritableAttr {
1966 let Spellings = [Declspec<"uuid">, Microsoft<"uuid">];
1967 let Args = [StringArgument<"Guid">];
1968 let Subjects = SubjectList<[Record, Enum]>;
1969 // FIXME: Allow expressing logical AND for LangOpts. Our condition should be:
1970 // CPlusPlus && (MicrosoftExt || Borland)
1971 let LangOpts = [MicrosoftExt, Borland];
1972 let Documentation = [Undocumented];
1975 def VectorSize : TypeAttr {
1976 let Spellings = [GCC<"vector_size">];
1977 let Args = [ExprArgument<"NumBytes">];
1978 let Documentation = [Undocumented];
1981 def VecTypeHint : InheritableAttr {
1982 // Does not have a [[]] spelling because it is an OpenCL-related attribute.
1983 let Spellings = [GNU<"vec_type_hint">];
1984 let Args = [TypeArgument<"TypeHint">];
1985 let Subjects = SubjectList<[Function], ErrorDiag>;
1986 let Documentation = [Undocumented];
1989 def Visibility : InheritableAttr {
1991 let Spellings = [GCC<"visibility">];
1992 let Args = [EnumArgument<"Visibility", "VisibilityType",
1993 ["default", "hidden", "internal", "protected"],
1994 ["Default", "Hidden", "Hidden", "Protected"]>];
1995 let MeaningfulToClassTemplateDefinition = 1;
1996 let Documentation = [Undocumented];
1999 def TypeVisibility : InheritableAttr {
2001 let Spellings = [Clang<"type_visibility">];
2002 let Args = [EnumArgument<"Visibility", "VisibilityType",
2003 ["default", "hidden", "internal", "protected"],
2004 ["Default", "Hidden", "Hidden", "Protected"]>];
2005 // let Subjects = [Tag, ObjCInterface, Namespace];
2006 let Documentation = [Undocumented];
2009 def VecReturn : InheritableAttr {
2010 let Spellings = [Clang<"vecreturn">];
2011 let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
2012 let Documentation = [Undocumented];
2015 def WarnUnused : InheritableAttr {
2016 let Spellings = [GCC<"warn_unused">];
2017 let Subjects = SubjectList<[Record]>;
2018 let Documentation = [Undocumented];
2021 def WarnUnusedResult : InheritableAttr {
2022 let Spellings = [CXX11<"", "nodiscard", 201603>, C2x<"", "nodiscard">,
2023 CXX11<"clang", "warn_unused_result">,
2024 GCC<"warn_unused_result">];
2025 let Subjects = SubjectList<[ObjCMethod, Enum, Record, FunctionLike]>;
2026 let Documentation = [WarnUnusedResultsDocs];
2029 def Weak : InheritableAttr {
2030 let Spellings = [GCC<"weak">];
2031 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
2032 let Documentation = [Undocumented];
2035 def WeakImport : InheritableAttr {
2036 let Spellings = [Clang<"weak_import">];
2037 let Documentation = [Undocumented];
2040 def WeakRef : InheritableAttr {
2041 let Spellings = [GCC<"weakref">];
2042 // A WeakRef that has an argument is treated as being an AliasAttr
2043 let Args = [StringArgument<"Aliasee", 1>];
2044 let Subjects = SubjectList<[Var, Function], ErrorDiag>;
2045 let Documentation = [Undocumented];
2048 def LTOVisibilityPublic : InheritableAttr {
2049 let Spellings = [Clang<"lto_visibility_public">];
2050 let Subjects = SubjectList<[Record]>;
2051 let Documentation = [LTOVisibilityDocs];
2054 def AnyX86Interrupt : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
2055 // NOTE: If you add any additional spellings, ARMInterrupt's,
2056 // MSP430Interrupt's and MipsInterrupt's spellings must match.
2057 let Spellings = [GCC<"interrupt">];
2058 let Subjects = SubjectList<[HasFunctionProto]>;
2059 let ParseKind = "Interrupt";
2060 let HasCustomParsing = 1;
2061 let Documentation = [Undocumented];
2064 def AnyX86NoCallerSavedRegisters : InheritableAttr,
2065 TargetSpecificAttr<TargetAnyX86> {
2066 let Spellings = [GCC<"no_caller_saved_registers">];
2067 let Documentation = [AnyX86NoCallerSavedRegistersDocs];
2070 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
2071 let Spellings = [GCC<"force_align_arg_pointer">];
2072 // Technically, this appertains to a FunctionDecl, but the target-specific
2073 // code silently allows anything function-like (such as typedefs or function
2074 // pointers), but does not apply the attribute to them.
2075 let Documentation = [X86ForceAlignArgPointerDocs];
2078 def NoSanitize : InheritableAttr {
2079 let Spellings = [Clang<"no_sanitize">];
2080 let Args = [VariadicStringArgument<"Sanitizers">];
2081 let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag>;
2082 let Documentation = [NoSanitizeDocs];
2083 let AdditionalMembers = [{
2084 SanitizerMask getMask() const {
2085 SanitizerMask Mask = 0;
2086 for (auto SanitizerName : sanitizers()) {
2087 SanitizerMask ParsedMask =
2088 parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
2089 Mask |= expandSanitizerGroups(ParsedMask);
2096 // Attributes to disable a specific sanitizer. No new sanitizers should be added
2097 // to this list; the no_sanitize attribute should be extended instead.
2098 def NoSanitizeSpecific : InheritableAttr {
2099 let Spellings = [GCC<"no_address_safety_analysis">,
2100 GCC<"no_sanitize_address">,
2101 GCC<"no_sanitize_thread">,
2102 Clang<"no_sanitize_memory">];
2103 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
2104 let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
2105 NoSanitizeMemoryDocs];
2109 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
2110 // Not all of these attributes will be given a [[]] spelling. The attributes
2111 // which require access to function parameter names cannot use the [[]] spelling
2112 // because they are not written in the type position. Some attributes are given
2113 // an updated captability-based name and the older name will only be supported
2114 // under the GNU-style spelling.
2115 def GuardedVar : InheritableAttr {
2116 let Spellings = [Clang<"guarded_var">];
2117 let Subjects = SubjectList<[Field, SharedVar]>;
2118 let Documentation = [Undocumented];
2121 def PtGuardedVar : InheritableAttr {
2122 let Spellings = [Clang<"pt_guarded_var">];
2123 let Subjects = SubjectList<[Field, SharedVar]>;
2124 let Documentation = [Undocumented];
2127 def Lockable : InheritableAttr {
2128 let Spellings = [GNU<"lockable">];
2129 let Subjects = SubjectList<[Record]>;
2130 let Documentation = [Undocumented];
2131 let ASTNode = 0; // Replaced by Capability
2134 def ScopedLockable : InheritableAttr {
2135 let Spellings = [Clang<"scoped_lockable">];
2136 let Subjects = SubjectList<[Record]>;
2137 let Documentation = [Undocumented];
2140 def Capability : InheritableAttr {
2141 let Spellings = [Clang<"capability">, Clang<"shared_capability">];
2142 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag>;
2143 let Args = [StringArgument<"Name">];
2144 let Accessors = [Accessor<"isShared",
2145 [Clang<"shared_capability">]>];
2146 let Documentation = [Undocumented];
2147 let AdditionalMembers = [{
2148 bool isMutex() const { return getName().equals_lower("mutex"); }
2149 bool isRole() const { return getName().equals_lower("role"); }
2153 def AssertCapability : InheritableAttr {
2154 let Spellings = [Clang<"assert_capability">,
2155 Clang<"assert_shared_capability">];
2156 let Subjects = SubjectList<[Function]>;
2158 let TemplateDependent = 1;
2159 let ParseArgumentsAsUnevaluated = 1;
2160 let DuplicatesAllowedWhileMerging = 1;
2161 let Args = [VariadicExprArgument<"Args">];
2162 let Accessors = [Accessor<"isShared",
2163 [Clang<"assert_shared_capability">]>];
2164 let Documentation = [AssertCapabilityDocs];
2167 def AcquireCapability : InheritableAttr {
2168 let Spellings = [Clang<"acquire_capability">,
2169 Clang<"acquire_shared_capability">,
2170 GNU<"exclusive_lock_function">,
2171 GNU<"shared_lock_function">];
2172 let Subjects = SubjectList<[Function]>;
2174 let TemplateDependent = 1;
2175 let ParseArgumentsAsUnevaluated = 1;
2176 let DuplicatesAllowedWhileMerging = 1;
2177 let Args = [VariadicExprArgument<"Args">];
2178 let Accessors = [Accessor<"isShared",
2179 [Clang<"acquire_shared_capability">,
2180 GNU<"shared_lock_function">]>];
2181 let Documentation = [AcquireCapabilityDocs];
2184 def TryAcquireCapability : InheritableAttr {
2185 let Spellings = [Clang<"try_acquire_capability">,
2186 Clang<"try_acquire_shared_capability">];
2187 let Subjects = SubjectList<[Function],
2190 let TemplateDependent = 1;
2191 let ParseArgumentsAsUnevaluated = 1;
2192 let DuplicatesAllowedWhileMerging = 1;
2193 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2194 let Accessors = [Accessor<"isShared",
2195 [Clang<"try_acquire_shared_capability">]>];
2196 let Documentation = [TryAcquireCapabilityDocs];
2199 def ReleaseCapability : InheritableAttr {
2200 let Spellings = [Clang<"release_capability">,
2201 Clang<"release_shared_capability">,
2202 Clang<"release_generic_capability">,
2203 Clang<"unlock_function">];
2204 let Subjects = SubjectList<[Function]>;
2206 let TemplateDependent = 1;
2207 let ParseArgumentsAsUnevaluated = 1;
2208 let DuplicatesAllowedWhileMerging = 1;
2209 let Args = [VariadicExprArgument<"Args">];
2210 let Accessors = [Accessor<"isShared",
2211 [Clang<"release_shared_capability">]>,
2212 Accessor<"isGeneric",
2213 [Clang<"release_generic_capability">,
2214 Clang<"unlock_function">]>];
2215 let Documentation = [ReleaseCapabilityDocs];
2218 def RequiresCapability : InheritableAttr {
2219 let Spellings = [Clang<"requires_capability">,
2220 Clang<"exclusive_locks_required">,
2221 Clang<"requires_shared_capability">,
2222 Clang<"shared_locks_required">];
2223 let Args = [VariadicExprArgument<"Args">];
2225 let TemplateDependent = 1;
2226 let ParseArgumentsAsUnevaluated = 1;
2227 let DuplicatesAllowedWhileMerging = 1;
2228 let Subjects = SubjectList<[Function]>;
2229 let Accessors = [Accessor<"isShared", [Clang<"requires_shared_capability">,
2230 Clang<"shared_locks_required">]>];
2231 let Documentation = [Undocumented];
2234 def NoThreadSafetyAnalysis : InheritableAttr {
2235 let Spellings = [Clang<"no_thread_safety_analysis">];
2236 let Subjects = SubjectList<[Function]>;
2237 let Documentation = [Undocumented];
2240 def GuardedBy : InheritableAttr {
2241 let Spellings = [GNU<"guarded_by">];
2242 let Args = [ExprArgument<"Arg">];
2244 let TemplateDependent = 1;
2245 let ParseArgumentsAsUnevaluated = 1;
2246 let DuplicatesAllowedWhileMerging = 1;
2247 let Subjects = SubjectList<[Field, SharedVar]>;
2248 let Documentation = [Undocumented];
2251 def PtGuardedBy : InheritableAttr {
2252 let Spellings = [GNU<"pt_guarded_by">];
2253 let Args = [ExprArgument<"Arg">];
2255 let TemplateDependent = 1;
2256 let ParseArgumentsAsUnevaluated = 1;
2257 let DuplicatesAllowedWhileMerging = 1;
2258 let Subjects = SubjectList<[Field, SharedVar]>;
2259 let Documentation = [Undocumented];
2262 def AcquiredAfter : InheritableAttr {
2263 let Spellings = [GNU<"acquired_after">];
2264 let Args = [VariadicExprArgument<"Args">];
2266 let TemplateDependent = 1;
2267 let ParseArgumentsAsUnevaluated = 1;
2268 let DuplicatesAllowedWhileMerging = 1;
2269 let Subjects = SubjectList<[Field, SharedVar]>;
2270 let Documentation = [Undocumented];
2273 def AcquiredBefore : InheritableAttr {
2274 let Spellings = [GNU<"acquired_before">];
2275 let Args = [VariadicExprArgument<"Args">];
2277 let TemplateDependent = 1;
2278 let ParseArgumentsAsUnevaluated = 1;
2279 let DuplicatesAllowedWhileMerging = 1;
2280 let Subjects = SubjectList<[Field, SharedVar]>;
2281 let Documentation = [Undocumented];
2284 def AssertExclusiveLock : InheritableAttr {
2285 let Spellings = [GNU<"assert_exclusive_lock">];
2286 let Args = [VariadicExprArgument<"Args">];
2288 let TemplateDependent = 1;
2289 let ParseArgumentsAsUnevaluated = 1;
2290 let DuplicatesAllowedWhileMerging = 1;
2291 let Subjects = SubjectList<[Function]>;
2292 let Documentation = [Undocumented];
2295 def AssertSharedLock : InheritableAttr {
2296 let Spellings = [GNU<"assert_shared_lock">];
2297 let Args = [VariadicExprArgument<"Args">];
2299 let TemplateDependent = 1;
2300 let ParseArgumentsAsUnevaluated = 1;
2301 let DuplicatesAllowedWhileMerging = 1;
2302 let Subjects = SubjectList<[Function]>;
2303 let Documentation = [Undocumented];
2306 // The first argument is an integer or boolean value specifying the return value
2307 // of a successful lock acquisition.
2308 def ExclusiveTrylockFunction : InheritableAttr {
2309 let Spellings = [GNU<"exclusive_trylock_function">];
2310 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2312 let TemplateDependent = 1;
2313 let ParseArgumentsAsUnevaluated = 1;
2314 let DuplicatesAllowedWhileMerging = 1;
2315 let Subjects = SubjectList<[Function]>;
2316 let Documentation = [Undocumented];
2319 // The first argument is an integer or boolean value specifying the return value
2320 // of a successful lock acquisition.
2321 def SharedTrylockFunction : InheritableAttr {
2322 let Spellings = [GNU<"shared_trylock_function">];
2323 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2325 let TemplateDependent = 1;
2326 let ParseArgumentsAsUnevaluated = 1;
2327 let DuplicatesAllowedWhileMerging = 1;
2328 let Subjects = SubjectList<[Function]>;
2329 let Documentation = [Undocumented];
2332 def LockReturned : InheritableAttr {
2333 let Spellings = [GNU<"lock_returned">];
2334 let Args = [ExprArgument<"Arg">];
2336 let TemplateDependent = 1;
2337 let ParseArgumentsAsUnevaluated = 1;
2338 let Subjects = SubjectList<[Function]>;
2339 let Documentation = [Undocumented];
2342 def LocksExcluded : InheritableAttr {
2343 let Spellings = [GNU<"locks_excluded">];
2344 let Args = [VariadicExprArgument<"Args">];
2346 let TemplateDependent = 1;
2347 let ParseArgumentsAsUnevaluated = 1;
2348 let DuplicatesAllowedWhileMerging = 1;
2349 let Subjects = SubjectList<[Function]>;
2350 let Documentation = [Undocumented];
2353 // C/C++ consumed attributes.
2355 def Consumable : InheritableAttr {
2356 let Spellings = [Clang<"consumable">];
2357 let Subjects = SubjectList<[CXXRecord]>;
2358 let Args = [EnumArgument<"DefaultState", "ConsumedState",
2359 ["unknown", "consumed", "unconsumed"],
2360 ["Unknown", "Consumed", "Unconsumed"]>];
2361 let Documentation = [ConsumableDocs];
2364 def ConsumableAutoCast : InheritableAttr {
2365 let Spellings = [Clang<"consumable_auto_cast_state">];
2366 let Subjects = SubjectList<[CXXRecord]>;
2367 let Documentation = [Undocumented];
2370 def ConsumableSetOnRead : InheritableAttr {
2371 let Spellings = [Clang<"consumable_set_state_on_read">];
2372 let Subjects = SubjectList<[CXXRecord]>;
2373 let Documentation = [Undocumented];
2376 def CallableWhen : InheritableAttr {
2377 let Spellings = [Clang<"callable_when">];
2378 let Subjects = SubjectList<[CXXMethod]>;
2379 let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
2380 ["unknown", "consumed", "unconsumed"],
2381 ["Unknown", "Consumed", "Unconsumed"]>];
2382 let Documentation = [CallableWhenDocs];
2385 def ParamTypestate : InheritableAttr {
2386 let Spellings = [Clang<"param_typestate">];
2387 let Subjects = SubjectList<[ParmVar]>;
2388 let Args = [EnumArgument<"ParamState", "ConsumedState",
2389 ["unknown", "consumed", "unconsumed"],
2390 ["Unknown", "Consumed", "Unconsumed"]>];
2391 let Documentation = [ParamTypestateDocs];
2394 def ReturnTypestate : InheritableAttr {
2395 let Spellings = [Clang<"return_typestate">];
2396 let Subjects = SubjectList<[Function, ParmVar]>;
2397 let Args = [EnumArgument<"State", "ConsumedState",
2398 ["unknown", "consumed", "unconsumed"],
2399 ["Unknown", "Consumed", "Unconsumed"]>];
2400 let Documentation = [ReturnTypestateDocs];
2403 def SetTypestate : InheritableAttr {
2404 let Spellings = [Clang<"set_typestate">];
2405 let Subjects = SubjectList<[CXXMethod]>;
2406 let Args = [EnumArgument<"NewState", "ConsumedState",
2407 ["unknown", "consumed", "unconsumed"],
2408 ["Unknown", "Consumed", "Unconsumed"]>];
2409 let Documentation = [SetTypestateDocs];
2412 def TestTypestate : InheritableAttr {
2413 let Spellings = [Clang<"test_typestate">];
2414 let Subjects = SubjectList<[CXXMethod]>;
2415 let Args = [EnumArgument<"TestState", "ConsumedState",
2416 ["consumed", "unconsumed"],
2417 ["Consumed", "Unconsumed"]>];
2418 let Documentation = [TestTypestateDocs];
2421 // Type safety attributes for `void *' pointers and type tags.
2423 def ArgumentWithTypeTag : InheritableAttr {
2424 let Spellings = [GNU<"argument_with_type_tag">,
2425 GNU<"pointer_with_type_tag">];
2426 let Args = [IdentifierArgument<"ArgumentKind">,
2427 UnsignedArgument<"ArgumentIdx">,
2428 UnsignedArgument<"TypeTagIdx">,
2429 BoolArgument<"IsPointer">];
2430 let HasCustomParsing = 1;
2431 let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
2434 def TypeTagForDatatype : InheritableAttr {
2435 let Spellings = [GNU<"type_tag_for_datatype">];
2436 let Args = [IdentifierArgument<"ArgumentKind">,
2437 TypeArgument<"MatchingCType">,
2438 BoolArgument<"LayoutCompatible">,
2439 BoolArgument<"MustBeNull">];
2440 // let Subjects = SubjectList<[Var], ErrorDiag>;
2441 let HasCustomParsing = 1;
2442 let Documentation = [TypeTagForDatatypeDocs];
2445 // Microsoft-related attributes
2447 def MSNoVTable : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
2448 let Spellings = [Declspec<"novtable">];
2449 let Subjects = SubjectList<[CXXRecord]>;
2450 let Documentation = [MSNoVTableDocs];
2454 let Spellings = [Declspec<"property">];
2457 def MSStruct : InheritableAttr {
2458 let Spellings = [GCC<"ms_struct">];
2459 let Subjects = SubjectList<[Record]>;
2460 let Documentation = [Undocumented];
2463 def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2464 let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
2465 let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2466 let Documentation = [DLLExportDocs];
2469 def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2470 let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
2471 let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2472 let Documentation = [DLLImportDocs];
2475 def SelectAny : InheritableAttr {
2476 let Spellings = [Declspec<"selectany">, GCC<"selectany">];
2477 let Documentation = [SelectAnyDocs];
2481 let Spellings = [Declspec<"thread">];
2482 let LangOpts = [MicrosoftExt];
2483 let Documentation = [ThreadDocs];
2484 let Subjects = SubjectList<[Var]>;
2487 def Win64 : IgnoredAttr {
2488 let Spellings = [Keyword<"__w64">];
2489 let LangOpts = [MicrosoftExt];
2492 def Ptr32 : TypeAttr {
2493 let Spellings = [Keyword<"__ptr32">];
2494 let Documentation = [Undocumented];
2497 def Ptr64 : TypeAttr {
2498 let Spellings = [Keyword<"__ptr64">];
2499 let Documentation = [Undocumented];
2502 def SPtr : TypeAttr {
2503 let Spellings = [Keyword<"__sptr">];
2504 let Documentation = [Undocumented];
2507 def UPtr : TypeAttr {
2508 let Spellings = [Keyword<"__uptr">];
2509 let Documentation = [Undocumented];
2512 def MSInheritance : InheritableAttr {
2513 let LangOpts = [MicrosoftExt];
2514 let Args = [DefaultBoolArgument<"BestCase", 1>];
2515 let Spellings = [Keyword<"__single_inheritance">,
2516 Keyword<"__multiple_inheritance">,
2517 Keyword<"__virtual_inheritance">,
2518 Keyword<"__unspecified_inheritance">];
2519 let AdditionalMembers = [{
2520 static bool hasVBPtrOffsetField(Spelling Inheritance) {
2521 return Inheritance == Keyword_unspecified_inheritance;
2524 // Only member pointers to functions need a this adjustment, since it can be
2525 // combined with the field offset for data pointers.
2526 static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
2527 return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
2530 static bool hasVBTableOffsetField(Spelling Inheritance) {
2531 return Inheritance >= Keyword_virtual_inheritance;
2534 static bool hasOnlyOneField(bool IsMemberFunction,
2535 Spelling Inheritance) {
2536 if (IsMemberFunction)
2537 return Inheritance <= Keyword_single_inheritance;
2538 return Inheritance <= Keyword_multiple_inheritance;
2541 let Documentation = [MSInheritanceDocs];
2544 def MSVtorDisp : InheritableAttr {
2545 // This attribute has no spellings as it is only ever created implicitly.
2547 let Args = [UnsignedArgument<"vdm">];
2548 let SemaHandler = 0;
2550 let AdditionalMembers = [{
2557 Mode getVtorDispMode() const { return Mode(vdm); }
2559 let Documentation = [Undocumented];
2562 def InitSeg : Attr {
2563 let Spellings = [Pragma<"", "init_seg">];
2564 let Args = [StringArgument<"Section">];
2565 let SemaHandler = 0;
2566 let Documentation = [InitSegDocs];
2567 let AdditionalMembers = [{
2568 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2569 OS << '(' << getSection() << ')';
2574 def LoopHint : Attr {
2575 /// #pragma clang loop <option> directive
2576 /// vectorize: vectorizes loop operations if State == Enable.
2577 /// vectorize_width: vectorize loop operations with width 'Value'.
2578 /// interleave: interleave multiple loop iterations if State == Enable.
2579 /// interleave_count: interleaves 'Value' loop interations.
2580 /// unroll: fully unroll loop if State == Enable.
2581 /// unroll_count: unrolls loop 'Value' times.
2582 /// distribute: attempt to distribute loop if State == Enable
2584 /// #pragma unroll <argument> directive
2585 /// <no arg>: fully unrolls loop.
2586 /// boolean: fully unrolls loop if State == Enable.
2587 /// expression: unrolls loop 'Value' times.
2589 let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">,
2590 Pragma<"", "nounroll">];
2592 /// State of the loop optimization specified by the spelling.
2593 let Args = [EnumArgument<"Option", "OptionType",
2594 ["vectorize", "vectorize_width", "interleave", "interleave_count",
2595 "unroll", "unroll_count", "distribute"],
2596 ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
2597 "Unroll", "UnrollCount", "Distribute"]>,
2598 EnumArgument<"State", "LoopHintState",
2599 ["enable", "disable", "numeric", "assume_safety", "full"],
2600 ["Enable", "Disable", "Numeric", "AssumeSafety", "Full"]>,
2601 ExprArgument<"Value">];
2603 let AdditionalMembers = [{
2604 static const char *getOptionName(int Option) {
2606 case Vectorize: return "vectorize";
2607 case VectorizeWidth: return "vectorize_width";
2608 case Interleave: return "interleave";
2609 case InterleaveCount: return "interleave_count";
2610 case Unroll: return "unroll";
2611 case UnrollCount: return "unroll_count";
2612 case Distribute: return "distribute";
2614 llvm_unreachable("Unhandled LoopHint option.");
2617 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2618 unsigned SpellingIndex = getSpellingListIndex();
2619 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
2620 // "nounroll" is already emitted as the pragma name.
2621 if (SpellingIndex == Pragma_nounroll)
2623 else if (SpellingIndex == Pragma_unroll) {
2624 OS << getValueString(Policy);
2628 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2629 OS << getOptionName(option) << getValueString(Policy);
2632 // Return a string containing the loop hint argument including the
2633 // enclosing parentheses.
2634 std::string getValueString(const PrintingPolicy &Policy) const {
2635 std::string ValueName;
2636 llvm::raw_string_ostream OS(ValueName);
2638 if (state == Numeric)
2639 value->printPretty(OS, nullptr, Policy);
2640 else if (state == Enable)
2642 else if (state == Full)
2644 else if (state == AssumeSafety)
2645 OS << "assume_safety";
2652 // Return a string suitable for identifying this attribute in diagnostics.
2653 std::string getDiagnosticName(const PrintingPolicy &Policy) const {
2654 unsigned SpellingIndex = getSpellingListIndex();
2655 if (SpellingIndex == Pragma_nounroll)
2656 return "#pragma nounroll";
2657 else if (SpellingIndex == Pragma_unroll)
2658 return "#pragma unroll" + (option == UnrollCount ? getValueString(Policy) : "");
2660 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2661 return getOptionName(option) + getValueString(Policy);
2665 let Documentation = [LoopHintDocs, UnrollHintDocs];
2668 def CapturedRecord : InheritableAttr {
2669 // This attribute has no spellings as it is only ever created implicitly.
2671 let SemaHandler = 0;
2672 let Documentation = [Undocumented];
2675 def OMPThreadPrivateDecl : InheritableAttr {
2676 // This attribute has no spellings as it is only ever created implicitly.
2678 let SemaHandler = 0;
2679 let Documentation = [Undocumented];
2682 def OMPCaptureNoInit : InheritableAttr {
2683 // This attribute has no spellings as it is only ever created implicitly.
2685 let SemaHandler = 0;
2686 let Documentation = [Undocumented];
2689 def OMPCaptureKind : Attr {
2690 // This attribute has no spellings as it is only ever created implicitly.
2692 let SemaHandler = 0;
2693 let Args = [UnsignedArgument<"CaptureKind">];
2694 let Documentation = [Undocumented];
2697 def OMPDeclareSimdDecl : Attr {
2698 let Spellings = [Pragma<"omp", "declare simd">];
2699 let Subjects = SubjectList<[Function]>;
2700 let SemaHandler = 0;
2701 let HasCustomParsing = 1;
2702 let Documentation = [OMPDeclareSimdDocs];
2704 EnumArgument<"BranchState", "BranchStateTy",
2705 [ "", "inbranch", "notinbranch" ],
2706 [ "BS_Undefined", "BS_Inbranch", "BS_Notinbranch" ]>,
2707 ExprArgument<"Simdlen">, VariadicExprArgument<"Uniforms">,
2708 VariadicExprArgument<"Aligneds">, VariadicExprArgument<"Alignments">,
2709 VariadicExprArgument<"Linears">, VariadicUnsignedArgument<"Modifiers">,
2710 VariadicExprArgument<"Steps">
2712 let AdditionalMembers = [{
2713 void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
2715 if (getBranchState() != BS_Undefined)
2716 OS << ConvertBranchStateTyToStr(getBranchState()) << " ";
2717 if (auto *E = getSimdlen()) {
2719 E->printPretty(OS, nullptr, Policy);
2722 if (uniforms_size() > 0) {
2724 StringRef Sep = "(";
2725 for (auto *E : uniforms()) {
2727 E->printPretty(OS, nullptr, Policy);
2732 alignments_iterator NI = alignments_begin();
2733 for (auto *E : aligneds()) {
2735 E->printPretty(OS, nullptr, Policy);
2738 (*NI)->printPretty(OS, nullptr, Policy);
2743 steps_iterator I = steps_begin();
2744 modifiers_iterator MI = modifiers_begin();
2745 for (auto *E : linears()) {
2747 if (*MI != OMPC_LINEAR_unknown)
2748 OS << getOpenMPSimpleClauseTypeName(OMPC_linear, *MI) << "(";
2749 E->printPretty(OS, nullptr, Policy);
2750 if (*MI != OMPC_LINEAR_unknown)
2754 (*I)->printPretty(OS, nullptr, Policy);
2764 def OMPDeclareTargetDecl : Attr {
2765 let Spellings = [Pragma<"omp", "declare target">];
2766 let SemaHandler = 0;
2767 let Documentation = [OMPDeclareTargetDocs];
2769 EnumArgument<"MapType", "MapTypeTy",
2771 [ "MT_To", "MT_Link" ]>
2773 let AdditionalMembers = [{
2774 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2775 // Use fake syntax because it is for testing and debugging purpose only.
2776 if (getMapType() != MT_To)
2777 OS << ConvertMapTypeTyToStr(getMapType()) << " ";
2782 def InternalLinkage : InheritableAttr {
2783 let Spellings = [Clang<"internal_linkage">];
2784 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
2785 let Documentation = [InternalLinkageDocs];