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.
73 class SubsetSubject<AttrSubject base, code check> : AttrSubject {
74 AttrSubject Base = base;
75 code CheckCode = check;
78 // This is the type of a variable which C++11 allows alignas(...) to appertain
80 def NormalVar : SubsetSubject<Var,
81 [{S->getStorageClass() != VarDecl::Register &&
82 S->getKind() != Decl::ImplicitParam &&
83 S->getKind() != Decl::ParmVar &&
84 S->getKind() != Decl::NonTypeTemplateParm}]>;
85 def NonParmVar : SubsetSubject<Var,
86 [{S->getKind() != Decl::ParmVar}]>;
87 def NonBitField : SubsetSubject<Field,
88 [{!S->isBitField()}]>;
90 def ObjCInstanceMethod : SubsetSubject<ObjCMethod,
91 [{S->isInstanceMethod()}]>;
93 def ObjCInterfaceDeclInitMethod : SubsetSubject<ObjCMethod,
94 [{S->getMethodFamily() == OMF_init &&
95 (isa<ObjCInterfaceDecl>(S->getDeclContext()) ||
96 (isa<ObjCCategoryDecl>(S->getDeclContext()) &&
97 cast<ObjCCategoryDecl>(S->getDeclContext())->IsClassExtension()))}]>;
99 def Struct : SubsetSubject<Record,
102 def TLSVar : SubsetSubject<Var,
103 [{S->getTLSKind() != 0}]>;
105 def SharedVar : SubsetSubject<Var,
106 [{S->hasGlobalStorage() && !S->getTLSKind()}]>;
108 def GlobalVar : SubsetSubject<Var,
109 [{S->hasGlobalStorage()}]>;
111 // FIXME: this hack is needed because DeclNodes.td defines the base Decl node
112 // type to be a class, not a definition. This makes it impossible to create an
113 // attribute subject which accepts a Decl. Normally, this is not a problem,
114 // because the attribute can have no Subjects clause to accomplish this. But in
115 // the case of a SubsetSubject, there's no way to express it without this hack.
116 def DeclBase : AttrSubject;
117 def FunctionLike : SubsetSubject<DeclBase,
118 [{S->getFunctionType(false) != nullptr}]>;
120 def OpenCLKernelFunction : SubsetSubject<Function, [{
121 S->hasAttr<OpenCLKernelAttr>()
124 // HasFunctionProto is a more strict version of FunctionLike, so it should
125 // never be specified in a Subjects list along with FunctionLike (due to the
126 // inclusive nature of subject testing).
127 def HasFunctionProto : SubsetSubject<DeclBase,
128 [{(S->getFunctionType(true) != nullptr &&
129 isa<FunctionProtoType>(S->getFunctionType())) ||
130 isa<ObjCMethodDecl>(S) ||
131 isa<BlockDecl>(S)}]>;
133 // A single argument to an attribute
134 class Argument<string name, bit optional, bit fake = 0> {
136 bit Optional = optional;
138 /// A fake argument is used to store and serialize additional information
139 /// in an attribute without actually changing its parsing or pretty-printing.
143 class BoolArgument<string name, bit opt = 0, bit fake = 0> : Argument<name, opt,
145 class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>;
146 class IntArgument<string name, bit opt = 0> : Argument<name, opt>;
147 class StringArgument<string name, bit opt = 0> : Argument<name, opt>;
148 class ExprArgument<string name, bit opt = 0> : Argument<name, opt>;
149 class FunctionArgument<string name, bit opt = 0, bit fake = 0> : Argument<name,
152 class TypeArgument<string name, bit opt = 0> : Argument<name, opt>;
153 class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>;
154 class VariadicUnsignedArgument<string name> : Argument<name, 1>;
155 class VariadicExprArgument<string name> : Argument<name, 1>;
156 class VariadicStringArgument<string name> : Argument<name, 1>;
158 // A version of the form major.minor[.subminor].
159 class VersionArgument<string name, bit opt = 0> : Argument<name, opt>;
161 // This one's a doozy, so it gets its own special type
162 // It can be an unsigned integer, or a type. Either can
164 class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>;
166 // A bool argument with a default value
167 class DefaultBoolArgument<string name, bit default> : BoolArgument<name, 1> {
168 bit Default = default;
171 // An integer argument with a default value
172 class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
173 int Default = default;
176 // This argument is more complex, it includes the enumerator type name,
177 // a list of strings to accept, and a list of enumerators to map them to.
178 class EnumArgument<string name, string type, list<string> values,
179 list<string> enums, bit opt = 0, bit fake = 0>
180 : Argument<name, opt, fake> {
182 list<string> Values = values;
183 list<string> Enums = enums;
186 // FIXME: There should be a VariadicArgument type that takes any other type
187 // of argument and generates the appropriate type.
188 class VariadicEnumArgument<string name, string type, list<string> values,
189 list<string> enums> : Argument<name, 1> {
191 list<string> Values = values;
192 list<string> Enums = enums;
195 // This handles one spelling of an attribute.
196 class Spelling<string name, string variety> {
198 string Variety = variety;
202 class GNU<string name> : Spelling<name, "GNU">;
203 class Declspec<string name> : Spelling<name, "Declspec">;
204 class Microsoft<string name> : Spelling<name, "Microsoft">;
205 class CXX11<string namespace, string name, int version = 1>
206 : Spelling<name, "CXX11"> {
207 string Namespace = namespace;
208 int Version = version;
210 class Keyword<string name> : Spelling<name, "Keyword">;
211 class Pragma<string namespace, string name> : Spelling<name, "Pragma"> {
212 string Namespace = namespace;
215 // The GCC spelling implies GNU<name, "GNU"> and CXX11<"gnu", name> and also
216 // sets KnownToGCC to 1. This spelling should be used for any GCC-compatible
218 class GCC<string name> : Spelling<name, "GCC"> {
222 class Accessor<string name, list<Spelling> spellings> {
224 list<Spelling> Spellings = spellings;
227 class SubjectDiag<bit warn> {
230 def WarnDiag : SubjectDiag<1>;
231 def ErrorDiag : SubjectDiag<0>;
233 class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag,
234 string customDiag = ""> {
235 list<AttrSubject> Subjects = subjects;
236 SubjectDiag Diag = diag;
237 string CustomDiag = customDiag;
240 class LangOpt<string name, bit negated = 0> {
242 bit Negated = negated;
244 def MicrosoftExt : LangOpt<"MicrosoftExt">;
245 def Borland : LangOpt<"Borland">;
246 def CUDA : LangOpt<"CUDA">;
247 def COnly : LangOpt<"CPlusPlus", 1>;
248 def CPlusPlus : LangOpt<"CPlusPlus">;
249 def OpenCL : LangOpt<"OpenCL">;
250 def RenderScript : LangOpt<"RenderScript">;
251 def ObjC : LangOpt<"ObjC1">;
252 def BlocksSupported : LangOpt<"Blocks">;
254 // Defines targets for target-specific attributes. The list of strings should
255 // specify architectures for which the target applies, based off the ArchType
256 // enumeration in Triple.h.
257 class TargetArch<list<string> arches> {
258 list<string> Arches = arches;
260 list<string> CXXABIs;
262 def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
263 def TargetAVR : TargetArch<["avr"]>;
264 def TargetMips : TargetArch<["mips", "mipsel"]>;
265 def TargetMSP430 : TargetArch<["msp430"]>;
266 def TargetX86 : TargetArch<["x86"]>;
267 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
268 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
269 let OSes = ["Win32"];
271 def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
272 let CXXABIs = ["Microsoft"];
275 // Attribute subject match rules that are used for #pragma clang attribute.
277 // A instance of AttrSubjectMatcherRule represents an individual match rule.
278 // An individual match rule can correspond to a number of different attribute
279 // subjects, e.g. "record" matching rule corresponds to the Record and
280 // CXXRecord attribute subjects.
282 // Match rules are used in the subject list of the #pragma clang attribute.
283 // Match rules can have sub-match rules that are instances of
284 // AttrSubjectMatcherSubRule. A sub-match rule can correspond to a number
285 // of different attribute subjects, and it can have a negated spelling as well.
286 // For example, "variable(unless(is_parameter))" matching rule corresponds to
287 // the NonParmVar attribute subject.
288 class AttrSubjectMatcherSubRule<string name, list<AttrSubject> subjects,
291 list<AttrSubject> Subjects = subjects;
292 bit Negated = negated;
293 // Lists language options, one of which is required to be true for the
294 // attribute to be applicable. If empty, the language options are taken
295 // from the parent matcher rule.
296 list<LangOpt> LangOpts = [];
298 class AttrSubjectMatcherRule<string name, list<AttrSubject> subjects,
299 list<AttrSubjectMatcherSubRule> subrules = []> {
301 list<AttrSubject> Subjects = subjects;
302 list<AttrSubjectMatcherSubRule> Constraints = subrules;
303 // Lists language options, one of which is required to be true for the
304 // attribute to be applicable. If empty, no language options are required.
305 list<LangOpt> LangOpts = [];
308 // function(is_member)
309 def SubRuleForCXXMethod : AttrSubjectMatcherSubRule<"is_member", [CXXMethod]> {
310 let LangOpts = [CPlusPlus];
312 def SubjectMatcherForFunction : AttrSubjectMatcherRule<"function", [Function], [
315 // hasType is abstract, it should be used with one of the sub-rules.
316 def SubjectMatcherForType : AttrSubjectMatcherRule<"hasType", [], [
317 AttrSubjectMatcherSubRule<"functionType", [FunctionLike]>
319 // FIXME: There's a matcher ambiguity with objc methods and blocks since
320 // functionType excludes them but functionProtoType includes them.
321 // AttrSubjectMatcherSubRule<"functionProtoType", [HasFunctionProto]>
323 def SubjectMatcherForTypedef : AttrSubjectMatcherRule<"type_alias",
325 def SubjectMatcherForRecord : AttrSubjectMatcherRule<"record", [Record,
328 AttrSubjectMatcherSubRule<"is_union", [Struct], 1>
330 def SubjectMatcherForEnum : AttrSubjectMatcherRule<"enum", [Enum]>;
331 def SubjectMatcherForEnumConstant : AttrSubjectMatcherRule<"enum_constant",
333 def SubjectMatcherForVar : AttrSubjectMatcherRule<"variable", [Var], [
334 AttrSubjectMatcherSubRule<"is_thread_local", [TLSVar]>,
335 AttrSubjectMatcherSubRule<"is_global", [GlobalVar]>,
336 AttrSubjectMatcherSubRule<"is_parameter", [ParmVar]>,
337 // unless(is_parameter)
338 AttrSubjectMatcherSubRule<"is_parameter", [NonParmVar], 1>
340 def SubjectMatcherForField : AttrSubjectMatcherRule<"field", [Field]>;
341 def SubjectMatcherForNamespace : AttrSubjectMatcherRule<"namespace",
343 let LangOpts = [CPlusPlus];
345 def SubjectMatcherForObjCInterface : AttrSubjectMatcherRule<"objc_interface",
347 let LangOpts = [ObjC];
349 def SubjectMatcherForObjCProtocol : AttrSubjectMatcherRule<"objc_protocol",
351 let LangOpts = [ObjC];
353 def SubjectMatcherForObjCCategory : AttrSubjectMatcherRule<"objc_category",
355 let LangOpts = [ObjC];
357 def SubjectMatcherForObjCMethod : AttrSubjectMatcherRule<"objc_method",
359 AttrSubjectMatcherSubRule<"is_instance", [ObjCInstanceMethod]>
361 let LangOpts = [ObjC];
363 def SubjectMatcherForObjCProperty : AttrSubjectMatcherRule<"objc_property",
365 let LangOpts = [ObjC];
367 def SubjectMatcherForBlock : AttrSubjectMatcherRule<"block", [Block]> {
368 let LangOpts = [BlocksSupported];
371 // Aggregate attribute subject match rules are abstract match rules that can't
372 // be used directly in #pragma clang attribute. Instead, users have to use
373 // subject match rules that correspond to attribute subjects that derive from
374 // the specified subject.
375 class AttrSubjectMatcherAggregateRule<AttrSubject subject> {
376 AttrSubject Subject = subject;
379 def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule<Named>;
382 // The various ways in which an attribute can be spelled in source
383 list<Spelling> Spellings;
384 // The things to which an attribute can appertain
385 SubjectList Subjects;
386 // The arguments allowed on an attribute
387 list<Argument> Args = [];
388 // Accessors which should be generated for the attribute.
389 list<Accessor> Accessors = [];
390 // Set to true for attributes with arguments which require delayed parsing.
392 // Set to false to prevent an attribute from being propagated from a template
393 // to the instantiation.
395 // Set to true for attributes which must be instantiated within templates
396 bit TemplateDependent = 0;
397 // Set to true for attributes that have a corresponding AST node.
399 // Set to true for attributes which have handler in Sema.
401 // Set to true for attributes that are completely ignored.
403 // Set to true if the attribute's parsing does not match its semantic
404 // content. Eg) It parses 3 args, but semantically takes 4 args. Opts out of
405 // common attribute error checking.
406 bit HasCustomParsing = 0;
407 // Set to true if all of the attribute's arguments should be parsed in an
408 // unevaluated context.
409 bit ParseArgumentsAsUnevaluated = 0;
410 // Set to true if this attribute can be duplicated on a subject when merging
411 // attributes. By default, attributes are not merged.
412 bit DuplicatesAllowedWhileMerging = 0;
413 // Set to true if this attribute meaningful when applied to or inherited
414 // in a class template definition.
415 bit MeaningfulToClassTemplateDefinition = 0;
416 // Set to true if this attribute can be used with '#pragma clang attribute'.
417 // By default, when this value is false, an attribute is supported by the
418 // '#pragma clang attribute' only when:
419 // - It has documentation.
420 // - It has a subject list whose subjects can be represented using subject
422 // - It has GNU/CXX11 spelling and doesn't require delayed parsing.
423 bit ForcePragmaAttributeSupport = 0;
424 // Lists language options, one of which is required to be true for the
425 // attribute to be applicable. If empty, no language options are required.
426 list<LangOpt> LangOpts = [];
427 // Any additional text that should be included verbatim in the class.
428 // Note: Any additional data members will leak and should be constructed
429 // externally on the ASTContext.
430 code AdditionalMembers = [{}];
431 // Any documentation that should be associated with the attribute. Since an
432 // attribute may be documented under multiple categories, more than one
433 // Documentation entry may be listed.
434 list<Documentation> Documentation;
437 /// A type attribute is not processed on a declaration or a statement.
438 class TypeAttr : Attr {
439 // By default, type attributes do not get an AST node.
443 /// A stmt attribute is not processed on a declaration or a type.
444 class StmtAttr : Attr;
446 /// An inheritable attribute is inherited by later redeclarations.
447 class InheritableAttr : Attr;
449 /// A target-specific attribute. This class is meant to be used as a mixin
450 /// with InheritableAttr or Attr depending on the attribute's needs.
451 class TargetSpecificAttr<TargetArch target> {
452 TargetArch Target = target;
453 // Attributes are generally required to have unique spellings for their names
454 // so that the parser can determine what kind of attribute it has parsed.
455 // However, target-specific attributes are special in that the attribute only
456 // "exists" for a given target. So two target-specific attributes can share
457 // the same name when they exist in different targets. To support this, a
458 // Kind can be explicitly specified for a target-specific attribute. This
459 // corresponds to the AttributeList::AT_* enum that is generated and it
460 // should contain a shared value between the attributes.
462 // Target-specific attributes which use this feature should ensure that the
463 // spellings match exactly between the attributes, and if the arguments or
464 // subjects differ, should specify HasCustomParsing = 1 and implement their
465 // own parsing and semantic handling requirements as-needed.
469 /// An inheritable parameter attribute is inherited by later
470 /// redeclarations, even when it's written on a parameter.
471 class InheritableParamAttr : InheritableAttr;
473 /// An attribute which changes the ABI rules for a specific parameter.
474 class ParameterABIAttr : InheritableParamAttr {
475 let Subjects = SubjectList<[ParmVar]>;
478 /// An ignored attribute, which we parse but discard with no checking.
479 class IgnoredAttr : Attr {
483 let Documentation = [Undocumented];
487 // Attributes begin here
491 let Spellings = [GCC<"abi_tag">];
492 let Args = [VariadicStringArgument<"Tags">];
493 let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag,
494 "ExpectedStructClassVariableFunctionOrInlineNamespace">;
495 let MeaningfulToClassTemplateDefinition = 1;
496 let Documentation = [AbiTagsDocs];
499 def AddressSpace : TypeAttr {
500 let Spellings = [GNU<"address_space">];
501 let Args = [IntArgument<"AddressSpace">];
502 let Documentation = [Undocumented];
506 let Spellings = [GCC<"alias">];
507 let Args = [StringArgument<"Aliasee">];
508 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
509 "ExpectedFunctionOrGlobalVar">;
510 let Documentation = [Undocumented];
513 def Aligned : InheritableAttr {
514 let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">,
515 Keyword<"_Alignas">];
516 // let Subjects = SubjectList<[NonBitField, NormalVar, Tag]>;
517 let Args = [AlignedArgument<"Alignment", 1>];
518 let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
519 Accessor<"isC11", [Keyword<"_Alignas">]>,
520 Accessor<"isAlignas", [Keyword<"alignas">,
521 Keyword<"_Alignas">]>,
522 Accessor<"isDeclspec",[Declspec<"align">]>];
523 let Documentation = [Undocumented];
526 def AlignValue : Attr {
528 // Unfortunately, this is semantically an assertion, not a directive
529 // (something else must ensure the alignment), so aligned_value is a
530 // probably a better name. We might want to add an aligned_value spelling in
531 // the future (and a corresponding C++ attribute), but this can be done
532 // later once we decide if we also want them to have slightly-different
533 // semantics than Intel's align_value.
535 // Intel's compiler on Windows also supports:
536 // , Declspec<"align_value">
538 let Args = [ExprArgument<"Alignment">];
539 let Subjects = SubjectList<[Var, TypedefName], WarnDiag,
540 "ExpectedVariableOrTypedef">;
541 let Documentation = [AlignValueDocs];
544 def AlignMac68k : InheritableAttr {
545 // This attribute has no spellings as it is only ever created implicitly.
548 let Documentation = [Undocumented];
551 def AlwaysInline : InheritableAttr {
552 let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
553 let Subjects = SubjectList<[Function]>;
554 let Documentation = [Undocumented];
557 def XRayInstrument : InheritableAttr {
558 let Spellings = [GNU<"xray_always_instrument">,
559 CXX11<"clang", "xray_always_instrument">,
560 GNU<"xray_never_instrument">,
561 CXX11<"clang", "xray_never_instrument">];
562 let Subjects = SubjectList<[CXXMethod, ObjCMethod, Function], WarnDiag,
563 "ExpectedFunctionOrMethod">;
564 let Accessors = [Accessor<"alwaysXRayInstrument",
565 [GNU<"xray_always_instrument">,
566 CXX11<"clang", "xray_always_instrument">]>,
567 Accessor<"neverXRayInstrument",
568 [GNU<"xray_never_instrument">,
569 CXX11<"clang", "xray_never_instrument">]>];
570 let Documentation = [XRayDocs];
573 def XRayLogArgs : InheritableAttr {
574 let Spellings = [GNU<"xray_log_args">, CXX11<"clang", "xray_log_args">];
575 let Subjects = SubjectList<
576 [CXXMethod, ObjCMethod, Function], WarnDiag, "ExpectedFunctionOrMethod"
578 let Args = [UnsignedArgument<"ArgumentCount">];
579 let Documentation = [XRayDocs];
582 def TLSModel : InheritableAttr {
583 let Spellings = [GCC<"tls_model">];
584 let Subjects = SubjectList<[TLSVar], ErrorDiag, "ExpectedTLSVar">;
585 let Args = [StringArgument<"Model">];
586 let Documentation = [TLSModelDocs];
589 def AnalyzerNoReturn : InheritableAttr {
590 let Spellings = [GNU<"analyzer_noreturn">];
591 let Documentation = [Undocumented];
594 def Annotate : InheritableParamAttr {
595 let Spellings = [GNU<"annotate">];
596 let Args = [StringArgument<"Annotation">];
597 // Ensure that the annotate attribute can be used with
598 // '#pragma clang attribute' even though it has no subject list.
599 let ForcePragmaAttributeSupport = 1;
600 let Documentation = [Undocumented];
603 def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> {
604 // NOTE: If you add any additional spellings, MSP430Interrupt's,
605 // MipsInterrupt's and AnyX86Interrupt's spellings must match.
606 let Spellings = [GNU<"interrupt">];
607 let Args = [EnumArgument<"Interrupt", "InterruptType",
608 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
609 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
611 let ParseKind = "Interrupt";
612 let HasCustomParsing = 1;
613 let Documentation = [ARMInterruptDocs];
616 def AVRInterrupt : InheritableAttr, TargetSpecificAttr<TargetAVR> {
617 let Spellings = [GNU<"interrupt">];
618 let Subjects = SubjectList<[Function]>;
619 let ParseKind = "Interrupt";
620 let Documentation = [AVRInterruptDocs];
623 def AVRSignal : InheritableAttr, TargetSpecificAttr<TargetAVR> {
624 let Spellings = [GNU<"signal">];
625 let Subjects = SubjectList<[Function]>;
626 let Documentation = [AVRSignalDocs];
629 def AsmLabel : InheritableAttr {
630 let Spellings = [Keyword<"asm">, Keyword<"__asm__">];
631 let Args = [StringArgument<"Label">];
633 let Documentation = [Undocumented];
636 def Availability : InheritableAttr {
637 let Spellings = [GNU<"availability">];
638 let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
639 VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
640 BoolArgument<"unavailable">, StringArgument<"message">,
641 BoolArgument<"strict">, StringArgument<"replacement">];
642 let AdditionalMembers =
643 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
644 return llvm::StringSwitch<llvm::StringRef>(Platform)
645 .Case("android", "Android")
647 .Case("macos", "macOS")
648 .Case("tvos", "tvOS")
649 .Case("watchos", "watchOS")
650 .Case("ios_app_extension", "iOS (App Extension)")
651 .Case("macos_app_extension", "macOS (App Extension)")
652 .Case("tvos_app_extension", "tvOS (App Extension)")
653 .Case("watchos_app_extension", "watchOS (App Extension)")
654 .Default(llvm::StringRef());
656 let HasCustomParsing = 1;
657 let DuplicatesAllowedWhileMerging = 1;
658 let Subjects = SubjectList<[Named]>;
659 let Documentation = [AvailabilityDocs];
662 def ExternalSourceSymbol : InheritableAttr {
663 let Spellings = [GNU<"external_source_symbol">,
664 CXX11<"clang", "external_source_symbol">];
665 let Args = [StringArgument<"language", 1>,
666 StringArgument<"definedIn", 1>,
667 BoolArgument<"generatedDeclaration", 1>];
668 let HasCustomParsing = 1;
669 let Subjects = SubjectList<[Named]>;
670 let Documentation = [ExternalSourceSymbolDocs];
673 def Blocks : InheritableAttr {
674 let Spellings = [GNU<"blocks">];
675 let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
676 let Documentation = [Undocumented];
679 def Bounded : IgnoredAttr {
680 let Spellings = [GNU<"bounded">];
683 def CarriesDependency : InheritableParamAttr {
684 let Spellings = [GNU<"carries_dependency">,
685 CXX11<"","carries_dependency", 200809>];
686 let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>;
687 let Documentation = [CarriesDependencyDocs];
690 def CDecl : InheritableAttr {
691 let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">];
692 // let Subjects = [Function, ObjCMethod];
693 let Documentation = [Undocumented];
696 // cf_audited_transfer indicates that the given function has been
697 // audited and has been marked with the appropriate cf_consumed and
698 // cf_returns_retained attributes. It is generally applied by
699 // '#pragma clang arc_cf_code_audited' rather than explicitly.
700 def CFAuditedTransfer : InheritableAttr {
701 let Spellings = [GNU<"cf_audited_transfer">];
702 let Subjects = SubjectList<[Function], ErrorDiag>;
703 let Documentation = [Undocumented];
706 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
707 // It indicates that the function has unknown or unautomatable
708 // transfer semantics.
709 def CFUnknownTransfer : InheritableAttr {
710 let Spellings = [GNU<"cf_unknown_transfer">];
711 let Subjects = SubjectList<[Function], ErrorDiag>;
712 let Documentation = [Undocumented];
715 def CFReturnsRetained : InheritableAttr {
716 let Spellings = [GNU<"cf_returns_retained">];
717 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
718 let Documentation = [Undocumented];
721 def CFReturnsNotRetained : InheritableAttr {
722 let Spellings = [GNU<"cf_returns_not_retained">];
723 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
724 let Documentation = [Undocumented];
727 def CFConsumed : InheritableParamAttr {
728 let Spellings = [GNU<"cf_consumed">];
729 let Subjects = SubjectList<[ParmVar]>;
730 let Documentation = [Undocumented];
733 def Cleanup : InheritableAttr {
734 let Spellings = [GCC<"cleanup">];
735 let Args = [FunctionArgument<"FunctionDecl">];
736 let Subjects = SubjectList<[Var]>;
737 let Documentation = [Undocumented];
740 def Cold : InheritableAttr {
741 let Spellings = [GCC<"cold">];
742 let Subjects = SubjectList<[Function]>;
743 let Documentation = [Undocumented];
746 def Common : InheritableAttr {
747 let Spellings = [GCC<"common">];
748 let Subjects = SubjectList<[Var]>;
749 let Documentation = [Undocumented];
752 def Const : InheritableAttr {
753 let Spellings = [GCC<"const">, GCC<"__const">];
754 let Documentation = [Undocumented];
757 def Constructor : InheritableAttr {
758 let Spellings = [GCC<"constructor">];
759 let Args = [DefaultIntArgument<"Priority", 65535>];
760 let Subjects = SubjectList<[Function]>;
761 let Documentation = [Undocumented];
764 // CUDA attributes are spelled __attribute__((attr)) or __declspec(__attr__).
766 def CUDAConstant : InheritableAttr {
767 let Spellings = [GNU<"constant">, Declspec<"__constant__">];
768 let Subjects = SubjectList<[Var]>;
769 let LangOpts = [CUDA];
770 let Documentation = [Undocumented];
773 def CUDACudartBuiltin : IgnoredAttr {
774 let Spellings = [GNU<"cudart_builtin">, Declspec<"__cudart_builtin__">];
775 let LangOpts = [CUDA];
778 def CUDADevice : InheritableAttr {
779 let Spellings = [GNU<"device">, Declspec<"__device__">];
780 let Subjects = SubjectList<[Function, Var]>;
781 let LangOpts = [CUDA];
782 let Documentation = [Undocumented];
785 def CUDADeviceBuiltin : IgnoredAttr {
786 let Spellings = [GNU<"device_builtin">, Declspec<"__device_builtin__">];
787 let LangOpts = [CUDA];
790 def CUDADeviceBuiltinSurfaceType : IgnoredAttr {
791 let Spellings = [GNU<"device_builtin_surface_type">,
792 Declspec<"__device_builtin_surface_type__">];
793 let LangOpts = [CUDA];
796 def CUDADeviceBuiltinTextureType : IgnoredAttr {
797 let Spellings = [GNU<"device_builtin_texture_type">,
798 Declspec<"__device_builtin_texture_type__">];
799 let LangOpts = [CUDA];
802 def CUDAGlobal : InheritableAttr {
803 let Spellings = [GNU<"global">, Declspec<"__global__">];
804 let Subjects = SubjectList<[Function]>;
805 let LangOpts = [CUDA];
806 let Documentation = [Undocumented];
809 def CUDAHost : InheritableAttr {
810 let Spellings = [GNU<"host">, Declspec<"__host__">];
811 let Subjects = SubjectList<[Function]>;
812 let LangOpts = [CUDA];
813 let Documentation = [Undocumented];
816 def CUDAInvalidTarget : InheritableAttr {
818 let Subjects = SubjectList<[Function]>;
819 let LangOpts = [CUDA];
820 let Documentation = [Undocumented];
823 def CUDALaunchBounds : InheritableAttr {
824 let Spellings = [GNU<"launch_bounds">, Declspec<"__launch_bounds__">];
825 let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>];
826 let LangOpts = [CUDA];
827 let Subjects = SubjectList<[ObjCMethod, FunctionLike], WarnDiag,
828 "ExpectedFunctionOrMethod">;
829 // An AST node is created for this attribute, but is not used by other parts
830 // of the compiler. However, this node needs to exist in the AST because
831 // non-LLVM backends may be relying on the attribute's presence.
832 let Documentation = [Undocumented];
835 def CUDAShared : InheritableAttr {
836 let Spellings = [GNU<"shared">, Declspec<"__shared__">];
837 let Subjects = SubjectList<[Var]>;
838 let LangOpts = [CUDA];
839 let Documentation = [Undocumented];
842 def C11NoReturn : InheritableAttr {
843 let Spellings = [Keyword<"_Noreturn">];
844 let Subjects = SubjectList<[Function], ErrorDiag>;
846 let Documentation = [C11NoReturnDocs];
849 def CXX11NoReturn : InheritableAttr {
850 let Spellings = [CXX11<"","noreturn", 200809>];
851 let Subjects = SubjectList<[Function], ErrorDiag>;
852 let Documentation = [CXX11NoReturnDocs];
855 def OpenCLKernel : InheritableAttr {
856 let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
857 let Subjects = SubjectList<[Function], ErrorDiag>;
858 let Documentation = [Undocumented];
861 def OpenCLUnrollHint : InheritableAttr {
862 let Spellings = [GNU<"opencl_unroll_hint">];
863 let Args = [UnsignedArgument<"UnrollHint">];
864 let Documentation = [OpenCLUnrollHintDocs];
867 // This attribute is both a type attribute, and a declaration attribute (for
868 // parameter variables).
869 def OpenCLAccess : Attr {
870 let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
871 Keyword<"__write_only">, Keyword<"write_only">,
872 Keyword<"__read_write">, Keyword<"read_write">];
873 let Subjects = SubjectList<[ParmVar, TypedefName], ErrorDiag,
874 "ExpectedParameterOrTypedef">;
875 let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
876 Keyword<"read_only">]>,
877 Accessor<"isReadWrite", [Keyword<"__read_write">,
878 Keyword<"read_write">]>,
879 Accessor<"isWriteOnly", [Keyword<"__write_only">,
880 Keyword<"write_only">]>];
881 let Documentation = [OpenCLAccessDocs];
884 def OpenCLPrivateAddressSpace : TypeAttr {
885 let Spellings = [Keyword<"__private">, Keyword<"private">];
886 let Documentation = [OpenCLAddressSpacePrivateDocs];
889 def OpenCLGlobalAddressSpace : TypeAttr {
890 let Spellings = [Keyword<"__global">, Keyword<"global">];
891 let Documentation = [OpenCLAddressSpaceGlobalDocs];
894 def OpenCLLocalAddressSpace : TypeAttr {
895 let Spellings = [Keyword<"__local">, Keyword<"local">];
896 let Documentation = [OpenCLAddressSpaceLocalDocs];
899 def OpenCLConstantAddressSpace : TypeAttr {
900 let Spellings = [Keyword<"__constant">, Keyword<"constant">];
901 let Documentation = [OpenCLAddressSpaceConstantDocs];
904 def OpenCLGenericAddressSpace : TypeAttr {
905 let Spellings = [Keyword<"__generic">, Keyword<"generic">];
906 let Documentation = [OpenCLAddressSpaceGenericDocs];
909 def OpenCLNoSVM : Attr {
910 let Spellings = [GNU<"nosvm">];
911 let Subjects = SubjectList<[Var]>;
912 let Documentation = [OpenCLNoSVMDocs];
913 let LangOpts = [OpenCL];
917 def RenderScriptKernel : Attr {
918 let Spellings = [GNU<"kernel">];
919 let Subjects = SubjectList<[Function]>;
920 let Documentation = [RenderScriptKernelAttributeDocs];
921 let LangOpts = [RenderScript];
924 def Deprecated : InheritableAttr {
925 let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
926 CXX11<"","deprecated", 201309>];
927 let Args = [StringArgument<"Message", 1>,
928 // An optional string argument that enables us to provide a
930 StringArgument<"Replacement", 1>];
931 let MeaningfulToClassTemplateDefinition = 1;
932 let Documentation = [DeprecatedDocs];
935 def Destructor : InheritableAttr {
936 let Spellings = [GCC<"destructor">];
937 let Args = [DefaultIntArgument<"Priority", 65535>];
938 let Subjects = SubjectList<[Function]>;
939 let Documentation = [Undocumented];
942 def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
943 let Spellings = [Declspec<"empty_bases">];
944 let Subjects = SubjectList<[CXXRecord]>;
945 let Documentation = [EmptyBasesDocs];
948 def AllocSize : InheritableAttr {
949 let Spellings = [GCC<"alloc_size">];
950 let Subjects = SubjectList<[Function]>;
951 let Args = [IntArgument<"ElemSizeParam">, IntArgument<"NumElemsParam", 1>];
952 let TemplateDependent = 1;
953 let Documentation = [AllocSizeDocs];
956 def EnableIf : InheritableAttr {
957 let Spellings = [GNU<"enable_if">];
958 let Subjects = SubjectList<[Function]>;
959 let Args = [ExprArgument<"Cond">, StringArgument<"Message">];
960 let TemplateDependent = 1;
961 let Documentation = [EnableIfDocs];
964 def ExtVectorType : Attr {
965 let Spellings = [GNU<"ext_vector_type">];
966 let Subjects = SubjectList<[TypedefName], ErrorDiag>;
967 let Args = [ExprArgument<"NumElements">];
969 let Documentation = [Undocumented];
972 def FallThrough : StmtAttr {
973 let Spellings = [CXX11<"", "fallthrough", 201603>,
974 CXX11<"clang", "fallthrough">];
975 // let Subjects = [NullStmt];
976 let Documentation = [FallthroughDocs];
979 def FastCall : InheritableAttr {
980 let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
981 Keyword<"_fastcall">];
982 // let Subjects = [Function, ObjCMethod];
983 let Documentation = [FastCallDocs];
986 def RegCall : InheritableAttr {
987 let Spellings = [GCC<"regcall">, Keyword<"__regcall">];
988 let Documentation = [RegCallDocs];
991 def Final : InheritableAttr {
992 let Spellings = [Keyword<"final">, Keyword<"sealed">];
993 let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
995 let Documentation = [Undocumented];
998 def MinSize : InheritableAttr {
999 let Spellings = [GNU<"minsize">];
1000 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
1001 let Documentation = [Undocumented];
1004 def FlagEnum : InheritableAttr {
1005 let Spellings = [GNU<"flag_enum">];
1006 let Subjects = SubjectList<[Enum]>;
1007 let Documentation = [FlagEnumDocs];
1010 def EnumExtensibility : InheritableAttr {
1011 let Spellings = [GNU<"enum_extensibility">,
1012 CXX11<"clang", "enum_extensibility">];
1013 let Subjects = SubjectList<[Enum]>;
1014 let Args = [EnumArgument<"Extensibility", "Kind",
1015 ["closed", "open"], ["Closed", "Open"]>];
1016 let Documentation = [EnumExtensibilityDocs];
1019 def Flatten : InheritableAttr {
1020 let Spellings = [GCC<"flatten">];
1021 let Subjects = SubjectList<[Function], ErrorDiag>;
1022 let Documentation = [FlattenDocs];
1025 def Format : InheritableAttr {
1026 let Spellings = [GCC<"format">];
1027 let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
1028 IntArgument<"FirstArg">];
1029 let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto], WarnDiag,
1030 "ExpectedFunctionWithProtoType">;
1031 let Documentation = [FormatDocs];
1034 def FormatArg : InheritableAttr {
1035 let Spellings = [GCC<"format_arg">];
1036 let Args = [IntArgument<"FormatIdx">];
1037 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto], WarnDiag,
1038 "ExpectedFunctionWithProtoType">;
1039 let Documentation = [Undocumented];
1042 def GNUInline : InheritableAttr {
1043 let Spellings = [GCC<"gnu_inline">];
1044 let Subjects = SubjectList<[Function]>;
1045 let Documentation = [Undocumented];
1048 def Hot : InheritableAttr {
1049 let Spellings = [GCC<"hot">];
1050 let Subjects = SubjectList<[Function]>;
1051 // An AST node is created for this attribute, but not actually used beyond
1052 // semantic checking for mutual exclusion with the Cold attribute.
1053 let Documentation = [Undocumented];
1056 def IBAction : InheritableAttr {
1057 let Spellings = [GNU<"ibaction">];
1058 let Subjects = SubjectList<[ObjCInstanceMethod], WarnDiag,
1059 "ExpectedObjCInstanceMethod">;
1060 // An AST node is created for this attribute, but is not used by other parts
1061 // of the compiler. However, this node needs to exist in the AST because
1062 // external tools rely on it.
1063 let Documentation = [Undocumented];
1066 def IBOutlet : InheritableAttr {
1067 let Spellings = [GNU<"iboutlet">];
1068 // let Subjects = [ObjCIvar, ObjCProperty];
1069 let Documentation = [Undocumented];
1072 def IBOutletCollection : InheritableAttr {
1073 let Spellings = [GNU<"iboutletcollection">];
1074 let Args = [TypeArgument<"Interface", 1>];
1075 // let Subjects = [ObjCIvar, ObjCProperty];
1076 let Documentation = [Undocumented];
1080 let Spellings = [GCC<"ifunc">];
1081 let Args = [StringArgument<"Resolver">];
1082 let Subjects = SubjectList<[Function]>;
1083 let Documentation = [IFuncDocs];
1086 def Restrict : InheritableAttr {
1087 let Spellings = [Declspec<"restrict">, GCC<"malloc">];
1088 let Subjects = SubjectList<[Function]>;
1089 let Documentation = [Undocumented];
1092 def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
1093 let Spellings = [Declspec<"layout_version">];
1094 let Args = [UnsignedArgument<"Version">];
1095 let Subjects = SubjectList<[CXXRecord]>;
1096 let Documentation = [LayoutVersionDocs];
1099 def MaxFieldAlignment : InheritableAttr {
1100 // This attribute has no spellings as it is only ever created implicitly.
1102 let Args = [UnsignedArgument<"Alignment">];
1103 let SemaHandler = 0;
1104 let Documentation = [Undocumented];
1107 def MayAlias : InheritableAttr {
1108 // FIXME: this is a type attribute in GCC, but a declaration attribute here.
1109 let Spellings = [GCC<"may_alias">];
1110 let Documentation = [Undocumented];
1113 def MSABI : InheritableAttr {
1114 let Spellings = [GCC<"ms_abi">];
1115 // let Subjects = [Function, ObjCMethod];
1116 let Documentation = [MSABIDocs];
1119 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
1120 // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's
1121 // and AnyX86Interrupt's spellings must match.
1122 let Spellings = [GNU<"interrupt">];
1123 let Args = [UnsignedArgument<"Number">];
1124 let ParseKind = "Interrupt";
1125 let HasCustomParsing = 1;
1126 let Documentation = [Undocumented];
1129 def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
1130 let Spellings = [GCC<"mips16">];
1131 let Subjects = SubjectList<[Function], ErrorDiag>;
1132 let Documentation = [Undocumented];
1135 def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips> {
1136 // NOTE: If you add any additional spellings, ARMInterrupt's,
1137 // MSP430Interrupt's and AnyX86Interrupt's spellings must match.
1138 let Spellings = [GNU<"interrupt">];
1139 let Subjects = SubjectList<[Function]>;
1140 let Args = [EnumArgument<"Interrupt", "InterruptType",
1141 ["vector=sw0", "vector=sw1", "vector=hw0",
1142 "vector=hw1", "vector=hw2", "vector=hw3",
1143 "vector=hw4", "vector=hw5", "eic", ""],
1144 ["sw0", "sw1", "hw0", "hw1", "hw2", "hw3",
1145 "hw4", "hw5", "eic", "eic"]
1147 let ParseKind = "Interrupt";
1148 let Documentation = [MipsInterruptDocs];
1152 let Spellings = [GCC<"mode">];
1153 let Subjects = SubjectList<[Var, Enum, TypedefName, Field], ErrorDiag,
1154 "ExpectedVariableEnumFieldOrTypedef">;
1155 let Args = [IdentifierArgument<"Mode">];
1156 let Documentation = [Undocumented];
1159 def Naked : InheritableAttr {
1160 let Spellings = [GCC<"naked">, Declspec<"naked">];
1161 let Subjects = SubjectList<[Function]>;
1162 let Documentation = [Undocumented];
1165 def NeonPolyVectorType : TypeAttr {
1166 let Spellings = [GNU<"neon_polyvector_type">];
1167 let Args = [IntArgument<"NumElements">];
1168 let Documentation = [Undocumented];
1171 def NeonVectorType : TypeAttr {
1172 let Spellings = [GNU<"neon_vector_type">];
1173 let Args = [IntArgument<"NumElements">];
1174 let Documentation = [Undocumented];
1177 def ReturnsTwice : InheritableAttr {
1178 let Spellings = [GCC<"returns_twice">];
1179 let Subjects = SubjectList<[Function]>;
1180 let Documentation = [Undocumented];
1183 def DisableTailCalls : InheritableAttr {
1184 let Spellings = [GNU<"disable_tail_calls">,
1185 CXX11<"clang", "disable_tail_calls">];
1186 let Subjects = SubjectList<[Function, ObjCMethod]>;
1187 let Documentation = [DisableTailCallsDocs];
1190 def NoAlias : InheritableAttr {
1191 let Spellings = [Declspec<"noalias">];
1192 let Subjects = SubjectList<[Function]>;
1193 let Documentation = [NoAliasDocs];
1196 def NoCommon : InheritableAttr {
1197 let Spellings = [GCC<"nocommon">];
1198 let Subjects = SubjectList<[Var]>;
1199 let Documentation = [Undocumented];
1202 def NoDebug : InheritableAttr {
1203 let Spellings = [GCC<"nodebug">];
1204 let Subjects = SubjectList<[FunctionLike, ObjCMethod, NonParmVar], WarnDiag,
1205 "ExpectedVariableOrFunction">;
1206 let Documentation = [NoDebugDocs];
1209 def NoDuplicate : InheritableAttr {
1210 let Spellings = [GNU<"noduplicate">, CXX11<"clang", "noduplicate">];
1211 let Subjects = SubjectList<[Function]>;
1212 let Documentation = [NoDuplicateDocs];
1215 def Convergent : InheritableAttr {
1216 let Spellings = [GNU<"convergent">, CXX11<"clang", "convergent">];
1217 let Subjects = SubjectList<[Function]>;
1218 let Documentation = [ConvergentDocs];
1221 def NoInline : InheritableAttr {
1222 let Spellings = [GCC<"noinline">, Declspec<"noinline">];
1223 let Subjects = SubjectList<[Function]>;
1224 let Documentation = [Undocumented];
1227 def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
1228 let Spellings = [GCC<"nomips16">];
1229 let Subjects = SubjectList<[Function], ErrorDiag>;
1230 let Documentation = [Undocumented];
1233 // This is not a TargetSpecificAttr so that is silently accepted and
1234 // ignored on other targets as encouraged by the OpenCL spec.
1236 // See OpenCL 1.2 6.11.5: "It is our intention that a particular
1237 // implementation of OpenCL be free to ignore all attributes and the
1238 // resulting executable binary will produce the same result."
1240 // However, only AMD GPU targets will emit the corresponding IR
1243 // FIXME: This provides a sub-optimal error message if you attempt to
1244 // use this in CUDA, since CUDA does not use the same terminology.
1246 // FIXME: SubjectList should be for OpenCLKernelFunction, but is not to
1247 // workaround needing to see kernel attribute before others to know if
1248 // this should be rejected on non-kernels.
1250 def AMDGPUFlatWorkGroupSize : InheritableAttr {
1251 let Spellings = [GNU<"amdgpu_flat_work_group_size">];
1252 let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max">];
1253 let Documentation = [AMDGPUFlatWorkGroupSizeDocs];
1254 let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1257 def AMDGPUWavesPerEU : InheritableAttr {
1258 let Spellings = [GNU<"amdgpu_waves_per_eu">];
1259 let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max", 1>];
1260 let Documentation = [AMDGPUWavesPerEUDocs];
1261 let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1264 def AMDGPUNumSGPR : InheritableAttr {
1265 let Spellings = [GNU<"amdgpu_num_sgpr">];
1266 let Args = [UnsignedArgument<"NumSGPR">];
1267 let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1268 let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1271 def AMDGPUNumVGPR : InheritableAttr {
1272 let Spellings = [GNU<"amdgpu_num_vgpr">];
1273 let Args = [UnsignedArgument<"NumVGPR">];
1274 let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1275 let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1278 def NoSplitStack : InheritableAttr {
1279 let Spellings = [GCC<"no_split_stack">];
1280 let Subjects = SubjectList<[Function], ErrorDiag>;
1281 let Documentation = [NoSplitStackDocs];
1284 def NonNull : InheritableParamAttr {
1285 let Spellings = [GCC<"nonnull">];
1286 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
1287 "ExpectedFunctionMethodOrParameter">;
1288 let Args = [VariadicUnsignedArgument<"Args">];
1289 let AdditionalMembers =
1290 [{bool isNonNull(unsigned idx) const {
1293 for (const auto &V : args())
1298 // FIXME: We should merge duplicates into a single nonnull attribute.
1299 let DuplicatesAllowedWhileMerging = 1;
1300 let Documentation = [NonNullDocs];
1303 def ReturnsNonNull : InheritableAttr {
1304 let Spellings = [GCC<"returns_nonnull">];
1305 let Subjects = SubjectList<[ObjCMethod, Function], WarnDiag,
1306 "ExpectedFunctionOrMethod">;
1307 let Documentation = [ReturnsNonNullDocs];
1310 // pass_object_size(N) indicates that the parameter should have
1311 // __builtin_object_size with Type=N evaluated on the parameter at the callsite.
1312 def PassObjectSize : InheritableParamAttr {
1313 let Spellings = [GNU<"pass_object_size">];
1314 let Args = [IntArgument<"Type">];
1315 let Subjects = SubjectList<[ParmVar]>;
1316 let Documentation = [PassObjectSizeDocs];
1319 // Nullability type attributes.
1320 def TypeNonNull : TypeAttr {
1321 let Spellings = [Keyword<"_Nonnull">];
1322 let Documentation = [TypeNonNullDocs];
1325 def TypeNullable : TypeAttr {
1326 let Spellings = [Keyword<"_Nullable">];
1327 let Documentation = [TypeNullableDocs];
1330 def TypeNullUnspecified : TypeAttr {
1331 let Spellings = [Keyword<"_Null_unspecified">];
1332 let Documentation = [TypeNullUnspecifiedDocs];
1335 def ObjCKindOf : TypeAttr {
1336 let Spellings = [Keyword<"__kindof">];
1337 let Documentation = [Undocumented];
1340 def AssumeAligned : InheritableAttr {
1341 let Spellings = [GCC<"assume_aligned">];
1342 let Subjects = SubjectList<[ObjCMethod, Function]>;
1343 let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>];
1344 let Documentation = [AssumeAlignedDocs];
1347 def AllocAlign : InheritableAttr {
1348 let Spellings = [GCC<"alloc_align">];
1349 let Subjects = SubjectList<[HasFunctionProto], WarnDiag,
1350 "ExpectedFunctionWithProtoType">;
1351 let Args = [IntArgument<"ParamIndex">];
1352 let Documentation = [AllocAlignDocs];
1355 def NoReturn : InheritableAttr {
1356 let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
1357 // FIXME: Does GCC allow this on the function instead?
1358 let Documentation = [Undocumented];
1361 def NoInstrumentFunction : InheritableAttr {
1362 let Spellings = [GCC<"no_instrument_function">];
1363 let Subjects = SubjectList<[Function]>;
1364 let Documentation = [Undocumented];
1367 def NotTailCalled : InheritableAttr {
1368 let Spellings = [GNU<"not_tail_called">, CXX11<"clang", "not_tail_called">];
1369 let Subjects = SubjectList<[Function]>;
1370 let Documentation = [NotTailCalledDocs];
1373 def NoThrow : InheritableAttr {
1374 let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
1375 let Documentation = [Undocumented];
1378 def NvWeak : IgnoredAttr {
1379 // No Declspec spelling of this attribute; the CUDA headers use
1380 // __attribute__((nv_weak)) unconditionally.
1381 let Spellings = [GNU<"nv_weak">];
1382 let LangOpts = [CUDA];
1385 def ObjCBridge : InheritableAttr {
1386 let Spellings = [GNU<"objc_bridge">];
1387 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag,
1388 "ExpectedStructOrUnionOrTypedef">;
1389 let Args = [IdentifierArgument<"BridgedType">];
1390 let Documentation = [Undocumented];
1393 def ObjCBridgeMutable : InheritableAttr {
1394 let Spellings = [GNU<"objc_bridge_mutable">];
1395 let Subjects = SubjectList<[Record], ErrorDiag>;
1396 let Args = [IdentifierArgument<"BridgedType">];
1397 let Documentation = [Undocumented];
1400 def ObjCBridgeRelated : InheritableAttr {
1401 let Spellings = [GNU<"objc_bridge_related">];
1402 let Subjects = SubjectList<[Record], ErrorDiag>;
1403 let Args = [IdentifierArgument<"RelatedClass">,
1404 IdentifierArgument<"ClassMethod", 1>,
1405 IdentifierArgument<"InstanceMethod", 1>];
1406 let HasCustomParsing = 1;
1407 let Documentation = [Undocumented];
1410 def NSReturnsRetained : InheritableAttr {
1411 let Spellings = [GNU<"ns_returns_retained">];
1412 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1413 let Documentation = [Undocumented];
1416 def NSReturnsNotRetained : InheritableAttr {
1417 let Spellings = [GNU<"ns_returns_not_retained">];
1418 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1419 let Documentation = [Undocumented];
1422 def NSReturnsAutoreleased : InheritableAttr {
1423 let Spellings = [GNU<"ns_returns_autoreleased">];
1424 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1425 let Documentation = [Undocumented];
1428 def NSConsumesSelf : InheritableAttr {
1429 let Spellings = [GNU<"ns_consumes_self">];
1430 let Subjects = SubjectList<[ObjCMethod]>;
1431 let Documentation = [Undocumented];
1434 def NSConsumed : InheritableParamAttr {
1435 let Spellings = [GNU<"ns_consumed">];
1436 let Subjects = SubjectList<[ParmVar]>;
1437 let Documentation = [Undocumented];
1440 def ObjCException : InheritableAttr {
1441 let Spellings = [GNU<"objc_exception">];
1442 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1443 let Documentation = [Undocumented];
1446 def ObjCMethodFamily : InheritableAttr {
1447 let Spellings = [GNU<"objc_method_family">];
1448 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1449 let Args = [EnumArgument<"Family", "FamilyKind",
1450 ["none", "alloc", "copy", "init", "mutableCopy", "new"],
1451 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
1452 "OMF_mutableCopy", "OMF_new"]>];
1453 let Documentation = [ObjCMethodFamilyDocs];
1456 def ObjCNSObject : InheritableAttr {
1457 let Spellings = [GNU<"NSObject">];
1458 let Documentation = [Undocumented];
1461 def ObjCIndependentClass : InheritableAttr {
1462 let Spellings = [GNU<"objc_independent_class">];
1463 let Documentation = [Undocumented];
1466 def ObjCPreciseLifetime : InheritableAttr {
1467 let Spellings = [GNU<"objc_precise_lifetime">];
1468 let Subjects = SubjectList<[Var], ErrorDiag>;
1469 let Documentation = [Undocumented];
1472 def ObjCReturnsInnerPointer : InheritableAttr {
1473 let Spellings = [GNU<"objc_returns_inner_pointer">];
1474 let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
1475 let Documentation = [Undocumented];
1478 def ObjCRequiresSuper : InheritableAttr {
1479 let Spellings = [GNU<"objc_requires_super">];
1480 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1481 let Documentation = [ObjCRequiresSuperDocs];
1484 def ObjCRootClass : InheritableAttr {
1485 let Spellings = [GNU<"objc_root_class">];
1486 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1487 let Documentation = [Undocumented];
1490 def ObjCSubclassingRestricted : InheritableAttr {
1491 let Spellings = [GNU<"objc_subclassing_restricted">];
1492 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1493 let Documentation = [ObjCSubclassingRestrictedDocs];
1496 def ObjCExplicitProtocolImpl : InheritableAttr {
1497 let Spellings = [GNU<"objc_protocol_requires_explicit_implementation">];
1498 let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
1499 let Documentation = [Undocumented];
1502 def ObjCDesignatedInitializer : Attr {
1503 let Spellings = [GNU<"objc_designated_initializer">];
1504 let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag,
1505 "ExpectedObjCInterfaceDeclInitMethod">;
1506 let Documentation = [Undocumented];
1509 def ObjCRuntimeName : Attr {
1510 let Spellings = [GNU<"objc_runtime_name">];
1511 let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
1512 let Args = [StringArgument<"MetadataName">];
1513 let Documentation = [ObjCRuntimeNameDocs];
1516 def ObjCRuntimeVisible : Attr {
1517 let Spellings = [GNU<"objc_runtime_visible">];
1518 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1519 let Documentation = [ObjCRuntimeVisibleDocs];
1522 def ObjCBoxable : Attr {
1523 let Spellings = [GNU<"objc_boxable">];
1524 let Subjects = SubjectList<[Record], ErrorDiag, "ExpectedStructOrUnion">;
1525 let Documentation = [ObjCBoxableDocs];
1528 def OptimizeNone : InheritableAttr {
1529 let Spellings = [GNU<"optnone">, CXX11<"clang", "optnone">];
1530 let Subjects = SubjectList<[Function, ObjCMethod]>;
1531 let Documentation = [OptnoneDocs];
1534 def Overloadable : Attr {
1535 let Spellings = [GNU<"overloadable">];
1536 let Subjects = SubjectList<[Function], ErrorDiag>;
1537 let Documentation = [OverloadableDocs];
1540 def Override : InheritableAttr {
1541 let Spellings = [Keyword<"override">];
1542 let SemaHandler = 0;
1543 let Documentation = [Undocumented];
1546 def Ownership : InheritableAttr {
1547 let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
1548 GNU<"ownership_takes">];
1549 let Accessors = [Accessor<"isHolds", [GNU<"ownership_holds">]>,
1550 Accessor<"isReturns", [GNU<"ownership_returns">]>,
1551 Accessor<"isTakes", [GNU<"ownership_takes">]>];
1552 let AdditionalMembers = [{
1553 enum OwnershipKind { Holds, Returns, Takes };
1554 OwnershipKind getOwnKind() const {
1555 return isHolds() ? Holds :
1560 let Args = [IdentifierArgument<"Module">, VariadicUnsignedArgument<"Args">];
1561 let Subjects = SubjectList<[HasFunctionProto], WarnDiag,
1562 "ExpectedFunctionWithProtoType">;
1563 let Documentation = [Undocumented];
1566 def Packed : InheritableAttr {
1567 let Spellings = [GCC<"packed">];
1568 // let Subjects = [Tag, Field];
1569 let Documentation = [Undocumented];
1572 def IntelOclBicc : InheritableAttr {
1573 let Spellings = [GNU<"intel_ocl_bicc">];
1574 // let Subjects = [Function, ObjCMethod];
1575 let Documentation = [Undocumented];
1578 def Pcs : InheritableAttr {
1579 let Spellings = [GCC<"pcs">];
1580 let Args = [EnumArgument<"PCS", "PCSType",
1581 ["aapcs", "aapcs-vfp"],
1582 ["AAPCS", "AAPCS_VFP"]>];
1583 // let Subjects = [Function, ObjCMethod];
1584 let Documentation = [PcsDocs];
1587 def Pure : InheritableAttr {
1588 let Spellings = [GCC<"pure">];
1589 let Documentation = [Undocumented];
1592 def Regparm : TypeAttr {
1593 let Spellings = [GCC<"regparm">];
1594 let Args = [UnsignedArgument<"NumParams">];
1595 let Documentation = [RegparmDocs];
1598 def ReqdWorkGroupSize : InheritableAttr {
1599 let Spellings = [GNU<"reqd_work_group_size">];
1600 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
1601 UnsignedArgument<"ZDim">];
1602 let Subjects = SubjectList<[Function], ErrorDiag>;
1603 let Documentation = [Undocumented];
1606 def RequireConstantInit : InheritableAttr {
1607 let Spellings = [GNU<"require_constant_initialization">,
1608 CXX11<"clang", "require_constant_initialization">];
1609 let Subjects = SubjectList<[GlobalVar], ErrorDiag,
1610 "ExpectedStaticOrTLSVar">;
1611 let Documentation = [RequireConstantInitDocs];
1612 let LangOpts = [CPlusPlus];
1615 def WorkGroupSizeHint : InheritableAttr {
1616 let Spellings = [GNU<"work_group_size_hint">];
1617 let Args = [UnsignedArgument<"XDim">,
1618 UnsignedArgument<"YDim">,
1619 UnsignedArgument<"ZDim">];
1620 let Subjects = SubjectList<[Function], ErrorDiag>;
1621 let Documentation = [Undocumented];
1624 def InitPriority : InheritableAttr {
1625 let Spellings = [GNU<"init_priority">];
1626 let Args = [UnsignedArgument<"Priority">];
1627 let Subjects = SubjectList<[Var], ErrorDiag>;
1628 let Documentation = [Undocumented];
1631 def Section : InheritableAttr {
1632 let Spellings = [GCC<"section">, Declspec<"allocate">];
1633 let Args = [StringArgument<"Name">];
1634 let Subjects = SubjectList<[Function, GlobalVar,
1635 ObjCMethod, ObjCProperty], ErrorDiag,
1636 "ExpectedFunctionGlobalVarMethodOrProperty">;
1637 let Documentation = [SectionDocs];
1640 def Sentinel : InheritableAttr {
1641 let Spellings = [GCC<"sentinel">];
1642 let Args = [DefaultIntArgument<"Sentinel", 0>,
1643 DefaultIntArgument<"NullPos", 0>];
1644 // let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
1645 let Documentation = [Undocumented];
1648 def StdCall : InheritableAttr {
1649 let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
1650 // let Subjects = [Function, ObjCMethod];
1651 let Documentation = [StdCallDocs];
1654 def SwiftCall : InheritableAttr {
1655 let Spellings = [GCC<"swiftcall">];
1656 // let Subjects = SubjectList<[Function]>;
1657 let Documentation = [SwiftCallDocs];
1660 def SwiftContext : ParameterABIAttr {
1661 let Spellings = [GCC<"swift_context">];
1662 let Documentation = [SwiftContextDocs];
1665 def SwiftErrorResult : ParameterABIAttr {
1666 let Spellings = [GCC<"swift_error_result">];
1667 let Documentation = [SwiftErrorResultDocs];
1670 def SwiftIndirectResult : ParameterABIAttr {
1671 let Spellings = [GCC<"swift_indirect_result">];
1672 let Documentation = [SwiftIndirectResultDocs];
1675 def Suppress : StmtAttr {
1676 let Spellings = [CXX11<"gsl", "suppress">];
1677 let Args = [VariadicStringArgument<"DiagnosticIdentifiers">];
1678 let Documentation = [SuppressDocs];
1681 def SysVABI : InheritableAttr {
1682 let Spellings = [GCC<"sysv_abi">];
1683 // let Subjects = [Function, ObjCMethod];
1684 let Documentation = [Undocumented];
1687 def ThisCall : InheritableAttr {
1688 let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
1689 Keyword<"_thiscall">];
1690 // let Subjects = [Function, ObjCMethod];
1691 let Documentation = [ThisCallDocs];
1694 def VectorCall : InheritableAttr {
1695 let Spellings = [GNU<"vectorcall">, Keyword<"__vectorcall">,
1696 Keyword<"_vectorcall">];
1697 // let Subjects = [Function, ObjCMethod];
1698 let Documentation = [VectorCallDocs];
1701 def Pascal : InheritableAttr {
1702 let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
1703 // let Subjects = [Function, ObjCMethod];
1704 let Documentation = [Undocumented];
1707 def PreserveMost : InheritableAttr {
1708 let Spellings = [GNU<"preserve_most">];
1709 let Documentation = [PreserveMostDocs];
1712 def PreserveAll : InheritableAttr {
1713 let Spellings = [GNU<"preserve_all">];
1714 let Documentation = [PreserveAllDocs];
1717 def Target : InheritableAttr {
1718 let Spellings = [GCC<"target">];
1719 let Args = [StringArgument<"featuresStr">];
1720 let Subjects = SubjectList<[Function], ErrorDiag>;
1721 let Documentation = [TargetDocs];
1722 let AdditionalMembers = [{
1723 typedef std::pair<std::vector<std::string>, StringRef> ParsedTargetAttr;
1724 ParsedTargetAttr parse() const {
1725 ParsedTargetAttr Ret;
1726 SmallVector<StringRef, 1> AttrFeatures;
1727 getFeaturesStr().split(AttrFeatures, ",");
1729 // Grab the various features and prepend a "+" to turn on the feature to
1730 // the backend and add them to our existing set of features.
1731 for (auto &Feature : AttrFeatures) {
1732 // Go ahead and trim whitespace rather than either erroring or
1733 // accepting it weirdly.
1734 Feature = Feature.trim();
1736 // We don't support cpu tuning this way currently.
1737 // TODO: Support the fpmath option. It will require checking
1738 // overall feature validity for the function with the rest of the
1739 // attributes on the function.
1740 if (Feature.startswith("fpmath=") || Feature.startswith("tune="))
1743 // While we're here iterating check for a different target cpu.
1744 if (Feature.startswith("arch="))
1745 Ret.second = Feature.split("=").second.trim();
1746 else if (Feature.startswith("no-"))
1747 Ret.first.push_back("-" + Feature.split("-").second.str());
1749 Ret.first.push_back("+" + Feature.str());
1756 def TransparentUnion : InheritableAttr {
1757 let Spellings = [GCC<"transparent_union">];
1758 // let Subjects = SubjectList<[Record, TypedefName]>;
1759 let Documentation = [TransparentUnionDocs];
1760 let LangOpts = [COnly];
1763 def Unavailable : InheritableAttr {
1764 let Spellings = [GNU<"unavailable">];
1765 let Args = [StringArgument<"Message", 1>,
1766 EnumArgument<"ImplicitReason", "ImplicitReason",
1769 "IR_ARCForbiddenType",
1771 "IR_ARCForbiddenConversion",
1772 "IR_ARCInitReturnsUnrelated",
1773 "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>];
1774 let Documentation = [Undocumented];
1777 def DiagnoseIf : InheritableAttr {
1778 let Spellings = [GNU<"diagnose_if">];
1779 let Subjects = SubjectList<[Function]>;
1780 let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
1781 EnumArgument<"DiagnosticType",
1783 ["error", "warning"],
1784 ["DT_Error", "DT_Warning"]>,
1785 BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
1786 FunctionArgument<"Parent", 0, /*fake*/ 1>];
1787 let DuplicatesAllowedWhileMerging = 1;
1789 let AdditionalMembers = [{
1790 bool isError() const { return diagnosticType == DT_Error; }
1791 bool isWarning() const { return diagnosticType == DT_Warning; }
1793 let TemplateDependent = 1;
1794 let Documentation = [DiagnoseIfDocs];
1797 def ArcWeakrefUnavailable : InheritableAttr {
1798 let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
1799 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1800 let Documentation = [Undocumented];
1803 def ObjCGC : TypeAttr {
1804 let Spellings = [GNU<"objc_gc">];
1805 let Args = [IdentifierArgument<"Kind">];
1806 let Documentation = [Undocumented];
1809 def ObjCOwnership : InheritableAttr {
1810 let Spellings = [GNU<"objc_ownership">];
1811 let Args = [IdentifierArgument<"Kind">];
1813 let Documentation = [Undocumented];
1816 def ObjCRequiresPropertyDefs : InheritableAttr {
1817 let Spellings = [GNU<"objc_requires_property_definitions">];
1818 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1819 let Documentation = [Undocumented];
1822 def Unused : InheritableAttr {
1823 let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">];
1824 let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
1825 Field, ObjCMethod, FunctionLike], WarnDiag,
1826 "ExpectedForMaybeUnused">;
1827 let Documentation = [WarnMaybeUnusedDocs];
1830 def Used : InheritableAttr {
1831 let Spellings = [GCC<"used">];
1832 let Documentation = [Undocumented];
1835 def Uuid : InheritableAttr {
1836 let Spellings = [Declspec<"uuid">, Microsoft<"uuid">];
1837 let Args = [StringArgument<"Guid">];
1838 let Subjects = SubjectList<[Record, Enum], WarnDiag, "ExpectedEnumOrClass">;
1839 // FIXME: Allow expressing logical AND for LangOpts. Our condition should be:
1840 // CPlusPlus && (MicrosoftExt || Borland)
1841 let LangOpts = [MicrosoftExt, Borland];
1842 let Documentation = [Undocumented];
1845 def VectorSize : TypeAttr {
1846 let Spellings = [GCC<"vector_size">];
1847 let Args = [ExprArgument<"NumBytes">];
1848 let Documentation = [Undocumented];
1851 def VecTypeHint : InheritableAttr {
1852 let Spellings = [GNU<"vec_type_hint">];
1853 let Args = [TypeArgument<"TypeHint">];
1854 let Subjects = SubjectList<[Function], ErrorDiag>;
1855 let Documentation = [Undocumented];
1858 def Visibility : InheritableAttr {
1860 let Spellings = [GCC<"visibility">];
1861 let Args = [EnumArgument<"Visibility", "VisibilityType",
1862 ["default", "hidden", "internal", "protected"],
1863 ["Default", "Hidden", "Hidden", "Protected"]>];
1864 let MeaningfulToClassTemplateDefinition = 1;
1865 let Documentation = [Undocumented];
1868 def TypeVisibility : InheritableAttr {
1870 let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">];
1871 let Args = [EnumArgument<"Visibility", "VisibilityType",
1872 ["default", "hidden", "internal", "protected"],
1873 ["Default", "Hidden", "Hidden", "Protected"]>];
1874 // let Subjects = [Tag, ObjCInterface, Namespace];
1875 let Documentation = [Undocumented];
1878 def VecReturn : InheritableAttr {
1879 let Spellings = [GNU<"vecreturn">];
1880 let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
1881 let Documentation = [Undocumented];
1884 def WarnUnused : InheritableAttr {
1885 let Spellings = [GNU<"warn_unused">];
1886 let Subjects = SubjectList<[Record]>;
1887 let Documentation = [Undocumented];
1890 def WarnUnusedResult : InheritableAttr {
1891 let Spellings = [CXX11<"", "nodiscard", 201603>,
1892 CXX11<"clang", "warn_unused_result">,
1893 GCC<"warn_unused_result">];
1894 let Subjects = SubjectList<[ObjCMethod, Enum, CXXRecord, FunctionLike],
1895 WarnDiag, "ExpectedFunctionMethodEnumOrClass">;
1896 let Documentation = [WarnUnusedResultsDocs];
1899 def Weak : InheritableAttr {
1900 let Spellings = [GCC<"weak">];
1901 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
1902 let Documentation = [Undocumented];
1905 def WeakImport : InheritableAttr {
1906 let Spellings = [GNU<"weak_import">];
1907 let Documentation = [Undocumented];
1910 def WeakRef : InheritableAttr {
1911 let Spellings = [GCC<"weakref">];
1912 // A WeakRef that has an argument is treated as being an AliasAttr
1913 let Args = [StringArgument<"Aliasee", 1>];
1914 let Subjects = SubjectList<[Var, Function], ErrorDiag>;
1915 let Documentation = [Undocumented];
1918 def LTOVisibilityPublic : InheritableAttr {
1919 let Spellings = [CXX11<"clang", "lto_visibility_public">];
1920 let Subjects = SubjectList<[Record]>;
1921 let Documentation = [LTOVisibilityDocs];
1924 def AnyX86Interrupt : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
1925 // NOTE: If you add any additional spellings, ARMInterrupt's,
1926 // MSP430Interrupt's and MipsInterrupt's spellings must match.
1927 let Spellings = [GNU<"interrupt">];
1928 let Subjects = SubjectList<[HasFunctionProto]>;
1929 let ParseKind = "Interrupt";
1930 let HasCustomParsing = 1;
1931 let Documentation = [AnyX86InterruptDocs];
1934 def AnyX86NoCallerSavedRegisters : InheritableAttr,
1935 TargetSpecificAttr<TargetAnyX86> {
1936 let Spellings = [GCC<"no_caller_saved_registers">];
1937 let Documentation = [AnyX86NoCallerSavedRegistersDocs];
1940 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetX86> {
1941 let Spellings = [GNU<"force_align_arg_pointer">];
1942 // Technically, this appertains to a FunctionDecl, but the target-specific
1943 // code silently allows anything function-like (such as typedefs or function
1944 // pointers), but does not apply the attribute to them.
1945 let Documentation = [Undocumented];
1948 def NoSanitize : InheritableAttr {
1949 let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">];
1950 let Args = [VariadicStringArgument<"Sanitizers">];
1951 let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag,
1952 "ExpectedFunctionMethodOrGlobalVar">;
1953 let Documentation = [NoSanitizeDocs];
1954 let AdditionalMembers = [{
1955 SanitizerMask getMask() const {
1956 SanitizerMask Mask = 0;
1957 for (auto SanitizerName : sanitizers()) {
1958 SanitizerMask ParsedMask =
1959 parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
1960 Mask |= expandSanitizerGroups(ParsedMask);
1967 // Attributes to disable a specific sanitizer. No new sanitizers should be added
1968 // to this list; the no_sanitize attribute should be extended instead.
1969 def NoSanitizeSpecific : InheritableAttr {
1970 let Spellings = [GCC<"no_address_safety_analysis">,
1971 GCC<"no_sanitize_address">,
1972 GCC<"no_sanitize_thread">,
1973 GNU<"no_sanitize_memory">];
1974 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
1975 "ExpectedFunctionOrGlobalVar">;
1976 let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
1977 NoSanitizeMemoryDocs];
1981 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
1983 def GuardedVar : InheritableAttr {
1984 let Spellings = [GNU<"guarded_var">];
1985 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1986 "ExpectedFieldOrGlobalVar">;
1987 let Documentation = [Undocumented];
1990 def PtGuardedVar : InheritableAttr {
1991 let Spellings = [GNU<"pt_guarded_var">];
1992 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1993 "ExpectedFieldOrGlobalVar">;
1994 let Documentation = [Undocumented];
1997 def Lockable : InheritableAttr {
1998 let Spellings = [GNU<"lockable">];
1999 let Subjects = SubjectList<[Record]>;
2000 let Documentation = [Undocumented];
2001 let ASTNode = 0; // Replaced by Capability
2004 def ScopedLockable : InheritableAttr {
2005 let Spellings = [GNU<"scoped_lockable">];
2006 let Subjects = SubjectList<[Record]>;
2007 let Documentation = [Undocumented];
2010 def Capability : InheritableAttr {
2011 let Spellings = [GNU<"capability">, CXX11<"clang", "capability">,
2012 GNU<"shared_capability">,
2013 CXX11<"clang", "shared_capability">];
2014 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag,
2015 "ExpectedStructOrUnionOrTypedef">;
2016 let Args = [StringArgument<"Name">];
2017 let Accessors = [Accessor<"isShared",
2018 [GNU<"shared_capability">,
2019 CXX11<"clang","shared_capability">]>];
2020 let Documentation = [Undocumented];
2021 let AdditionalMembers = [{
2022 bool isMutex() const { return getName().equals_lower("mutex"); }
2023 bool isRole() const { return getName().equals_lower("role"); }
2027 def AssertCapability : InheritableAttr {
2028 let Spellings = [GNU<"assert_capability">,
2029 CXX11<"clang", "assert_capability">,
2030 GNU<"assert_shared_capability">,
2031 CXX11<"clang", "assert_shared_capability">];
2032 let Subjects = SubjectList<[Function]>;
2034 let TemplateDependent = 1;
2035 let ParseArgumentsAsUnevaluated = 1;
2036 let DuplicatesAllowedWhileMerging = 1;
2037 let Args = [ExprArgument<"Expr">];
2038 let Accessors = [Accessor<"isShared",
2039 [GNU<"assert_shared_capability">,
2040 CXX11<"clang", "assert_shared_capability">]>];
2041 let Documentation = [AssertCapabilityDocs];
2044 def AcquireCapability : InheritableAttr {
2045 let Spellings = [GNU<"acquire_capability">,
2046 CXX11<"clang", "acquire_capability">,
2047 GNU<"acquire_shared_capability">,
2048 CXX11<"clang", "acquire_shared_capability">,
2049 GNU<"exclusive_lock_function">,
2050 GNU<"shared_lock_function">];
2051 let Subjects = SubjectList<[Function]>;
2053 let TemplateDependent = 1;
2054 let ParseArgumentsAsUnevaluated = 1;
2055 let DuplicatesAllowedWhileMerging = 1;
2056 let Args = [VariadicExprArgument<"Args">];
2057 let Accessors = [Accessor<"isShared",
2058 [GNU<"acquire_shared_capability">,
2059 CXX11<"clang", "acquire_shared_capability">,
2060 GNU<"shared_lock_function">]>];
2061 let Documentation = [AcquireCapabilityDocs];
2064 def TryAcquireCapability : InheritableAttr {
2065 let Spellings = [GNU<"try_acquire_capability">,
2066 CXX11<"clang", "try_acquire_capability">,
2067 GNU<"try_acquire_shared_capability">,
2068 CXX11<"clang", "try_acquire_shared_capability">];
2069 let Subjects = SubjectList<[Function],
2072 let TemplateDependent = 1;
2073 let ParseArgumentsAsUnevaluated = 1;
2074 let DuplicatesAllowedWhileMerging = 1;
2075 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2076 let Accessors = [Accessor<"isShared",
2077 [GNU<"try_acquire_shared_capability">,
2078 CXX11<"clang", "try_acquire_shared_capability">]>];
2079 let Documentation = [TryAcquireCapabilityDocs];
2082 def ReleaseCapability : InheritableAttr {
2083 let Spellings = [GNU<"release_capability">,
2084 CXX11<"clang", "release_capability">,
2085 GNU<"release_shared_capability">,
2086 CXX11<"clang", "release_shared_capability">,
2087 GNU<"release_generic_capability">,
2088 CXX11<"clang", "release_generic_capability">,
2089 GNU<"unlock_function">];
2090 let Subjects = SubjectList<[Function]>;
2092 let TemplateDependent = 1;
2093 let ParseArgumentsAsUnevaluated = 1;
2094 let DuplicatesAllowedWhileMerging = 1;
2095 let Args = [VariadicExprArgument<"Args">];
2096 let Accessors = [Accessor<"isShared",
2097 [GNU<"release_shared_capability">,
2098 CXX11<"clang", "release_shared_capability">]>,
2099 Accessor<"isGeneric",
2100 [GNU<"release_generic_capability">,
2101 CXX11<"clang", "release_generic_capability">,
2102 GNU<"unlock_function">]>];
2103 let Documentation = [ReleaseCapabilityDocs];
2106 def RequiresCapability : InheritableAttr {
2107 let Spellings = [GNU<"requires_capability">,
2108 CXX11<"clang", "requires_capability">,
2109 GNU<"exclusive_locks_required">,
2110 GNU<"requires_shared_capability">,
2111 CXX11<"clang", "requires_shared_capability">,
2112 GNU<"shared_locks_required">];
2113 let Args = [VariadicExprArgument<"Args">];
2115 let TemplateDependent = 1;
2116 let ParseArgumentsAsUnevaluated = 1;
2117 let DuplicatesAllowedWhileMerging = 1;
2118 let Subjects = SubjectList<[Function]>;
2119 let Accessors = [Accessor<"isShared", [GNU<"requires_shared_capability">,
2120 GNU<"shared_locks_required">,
2121 CXX11<"clang","requires_shared_capability">]>];
2122 let Documentation = [Undocumented];
2125 def NoThreadSafetyAnalysis : InheritableAttr {
2126 let Spellings = [GNU<"no_thread_safety_analysis">];
2127 let Subjects = SubjectList<[Function]>;
2128 let Documentation = [Undocumented];
2131 def GuardedBy : InheritableAttr {
2132 let Spellings = [GNU<"guarded_by">];
2133 let Args = [ExprArgument<"Arg">];
2135 let TemplateDependent = 1;
2136 let ParseArgumentsAsUnevaluated = 1;
2137 let DuplicatesAllowedWhileMerging = 1;
2138 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2139 "ExpectedFieldOrGlobalVar">;
2140 let Documentation = [Undocumented];
2143 def PtGuardedBy : InheritableAttr {
2144 let Spellings = [GNU<"pt_guarded_by">];
2145 let Args = [ExprArgument<"Arg">];
2147 let TemplateDependent = 1;
2148 let ParseArgumentsAsUnevaluated = 1;
2149 let DuplicatesAllowedWhileMerging = 1;
2150 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2151 "ExpectedFieldOrGlobalVar">;
2152 let Documentation = [Undocumented];
2155 def AcquiredAfter : InheritableAttr {
2156 let Spellings = [GNU<"acquired_after">];
2157 let Args = [VariadicExprArgument<"Args">];
2159 let TemplateDependent = 1;
2160 let ParseArgumentsAsUnevaluated = 1;
2161 let DuplicatesAllowedWhileMerging = 1;
2162 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2163 "ExpectedFieldOrGlobalVar">;
2164 let Documentation = [Undocumented];
2167 def AcquiredBefore : InheritableAttr {
2168 let Spellings = [GNU<"acquired_before">];
2169 let Args = [VariadicExprArgument<"Args">];
2171 let TemplateDependent = 1;
2172 let ParseArgumentsAsUnevaluated = 1;
2173 let DuplicatesAllowedWhileMerging = 1;
2174 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2175 "ExpectedFieldOrGlobalVar">;
2176 let Documentation = [Undocumented];
2179 def AssertExclusiveLock : InheritableAttr {
2180 let Spellings = [GNU<"assert_exclusive_lock">];
2181 let Args = [VariadicExprArgument<"Args">];
2183 let TemplateDependent = 1;
2184 let ParseArgumentsAsUnevaluated = 1;
2185 let DuplicatesAllowedWhileMerging = 1;
2186 let Subjects = SubjectList<[Function]>;
2187 let Documentation = [Undocumented];
2190 def AssertSharedLock : InheritableAttr {
2191 let Spellings = [GNU<"assert_shared_lock">];
2192 let Args = [VariadicExprArgument<"Args">];
2194 let TemplateDependent = 1;
2195 let ParseArgumentsAsUnevaluated = 1;
2196 let DuplicatesAllowedWhileMerging = 1;
2197 let Subjects = SubjectList<[Function]>;
2198 let Documentation = [Undocumented];
2201 // The first argument is an integer or boolean value specifying the return value
2202 // of a successful lock acquisition.
2203 def ExclusiveTrylockFunction : InheritableAttr {
2204 let Spellings = [GNU<"exclusive_trylock_function">];
2205 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2207 let TemplateDependent = 1;
2208 let ParseArgumentsAsUnevaluated = 1;
2209 let DuplicatesAllowedWhileMerging = 1;
2210 let Subjects = SubjectList<[Function]>;
2211 let Documentation = [Undocumented];
2214 // The first argument is an integer or boolean value specifying the return value
2215 // of a successful lock acquisition.
2216 def SharedTrylockFunction : InheritableAttr {
2217 let Spellings = [GNU<"shared_trylock_function">];
2218 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2220 let TemplateDependent = 1;
2221 let ParseArgumentsAsUnevaluated = 1;
2222 let DuplicatesAllowedWhileMerging = 1;
2223 let Subjects = SubjectList<[Function]>;
2224 let Documentation = [Undocumented];
2227 def LockReturned : InheritableAttr {
2228 let Spellings = [GNU<"lock_returned">];
2229 let Args = [ExprArgument<"Arg">];
2231 let TemplateDependent = 1;
2232 let ParseArgumentsAsUnevaluated = 1;
2233 let Subjects = SubjectList<[Function]>;
2234 let Documentation = [Undocumented];
2237 def LocksExcluded : InheritableAttr {
2238 let Spellings = [GNU<"locks_excluded">];
2239 let Args = [VariadicExprArgument<"Args">];
2241 let TemplateDependent = 1;
2242 let ParseArgumentsAsUnevaluated = 1;
2243 let DuplicatesAllowedWhileMerging = 1;
2244 let Subjects = SubjectList<[Function]>;
2245 let Documentation = [Undocumented];
2248 // C/C++ consumed attributes.
2250 def Consumable : InheritableAttr {
2251 let Spellings = [GNU<"consumable">];
2252 let Subjects = SubjectList<[CXXRecord]>;
2253 let Args = [EnumArgument<"DefaultState", "ConsumedState",
2254 ["unknown", "consumed", "unconsumed"],
2255 ["Unknown", "Consumed", "Unconsumed"]>];
2256 let Documentation = [ConsumableDocs];
2259 def ConsumableAutoCast : InheritableAttr {
2260 let Spellings = [GNU<"consumable_auto_cast_state">];
2261 let Subjects = SubjectList<[CXXRecord]>;
2262 let Documentation = [Undocumented];
2265 def ConsumableSetOnRead : InheritableAttr {
2266 let Spellings = [GNU<"consumable_set_state_on_read">];
2267 let Subjects = SubjectList<[CXXRecord]>;
2268 let Documentation = [Undocumented];
2271 def CallableWhen : InheritableAttr {
2272 let Spellings = [GNU<"callable_when">];
2273 let Subjects = SubjectList<[CXXMethod]>;
2274 let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
2275 ["unknown", "consumed", "unconsumed"],
2276 ["Unknown", "Consumed", "Unconsumed"]>];
2277 let Documentation = [CallableWhenDocs];
2280 def ParamTypestate : InheritableAttr {
2281 let Spellings = [GNU<"param_typestate">];
2282 let Subjects = SubjectList<[ParmVar]>;
2283 let Args = [EnumArgument<"ParamState", "ConsumedState",
2284 ["unknown", "consumed", "unconsumed"],
2285 ["Unknown", "Consumed", "Unconsumed"]>];
2286 let Documentation = [ParamTypestateDocs];
2289 def ReturnTypestate : InheritableAttr {
2290 let Spellings = [GNU<"return_typestate">];
2291 let Subjects = SubjectList<[Function, ParmVar]>;
2292 let Args = [EnumArgument<"State", "ConsumedState",
2293 ["unknown", "consumed", "unconsumed"],
2294 ["Unknown", "Consumed", "Unconsumed"]>];
2295 let Documentation = [ReturnTypestateDocs];
2298 def SetTypestate : InheritableAttr {
2299 let Spellings = [GNU<"set_typestate">];
2300 let Subjects = SubjectList<[CXXMethod]>;
2301 let Args = [EnumArgument<"NewState", "ConsumedState",
2302 ["unknown", "consumed", "unconsumed"],
2303 ["Unknown", "Consumed", "Unconsumed"]>];
2304 let Documentation = [SetTypestateDocs];
2307 def TestTypestate : InheritableAttr {
2308 let Spellings = [GNU<"test_typestate">];
2309 let Subjects = SubjectList<[CXXMethod]>;
2310 let Args = [EnumArgument<"TestState", "ConsumedState",
2311 ["consumed", "unconsumed"],
2312 ["Consumed", "Unconsumed"]>];
2313 let Documentation = [TestTypestateDocs];
2316 // Type safety attributes for `void *' pointers and type tags.
2318 def ArgumentWithTypeTag : InheritableAttr {
2319 let Spellings = [GNU<"argument_with_type_tag">,
2320 GNU<"pointer_with_type_tag">];
2321 let Args = [IdentifierArgument<"ArgumentKind">,
2322 UnsignedArgument<"ArgumentIdx">,
2323 UnsignedArgument<"TypeTagIdx">,
2324 BoolArgument<"IsPointer">];
2325 let HasCustomParsing = 1;
2326 let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
2329 def TypeTagForDatatype : InheritableAttr {
2330 let Spellings = [GNU<"type_tag_for_datatype">];
2331 let Args = [IdentifierArgument<"ArgumentKind">,
2332 TypeArgument<"MatchingCType">,
2333 BoolArgument<"LayoutCompatible">,
2334 BoolArgument<"MustBeNull">];
2335 // let Subjects = SubjectList<[Var], ErrorDiag>;
2336 let HasCustomParsing = 1;
2337 let Documentation = [TypeTagForDatatypeDocs];
2340 // Microsoft-related attributes
2342 def MSNoVTable : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
2343 let Spellings = [Declspec<"novtable">];
2344 let Subjects = SubjectList<[CXXRecord]>;
2345 let Documentation = [MSNoVTableDocs];
2349 let Spellings = [Declspec<"property">];
2352 def MSStruct : InheritableAttr {
2353 let Spellings = [GCC<"ms_struct">];
2354 let Subjects = SubjectList<[Record]>;
2355 let Documentation = [Undocumented];
2358 def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2359 let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
2360 let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2361 let Documentation = [DLLExportDocs];
2364 def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2365 let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
2366 let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2367 let Documentation = [DLLImportDocs];
2370 def SelectAny : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2371 let Spellings = [Declspec<"selectany">, GCC<"selectany">];
2372 let Documentation = [Undocumented];
2376 let Spellings = [Declspec<"thread">];
2377 let LangOpts = [MicrosoftExt];
2378 let Documentation = [ThreadDocs];
2379 let Subjects = SubjectList<[Var]>;
2382 def Win64 : IgnoredAttr {
2383 let Spellings = [Keyword<"__w64">];
2384 let LangOpts = [MicrosoftExt];
2387 def Ptr32 : TypeAttr {
2388 let Spellings = [Keyword<"__ptr32">];
2389 let Documentation = [Undocumented];
2392 def Ptr64 : TypeAttr {
2393 let Spellings = [Keyword<"__ptr64">];
2394 let Documentation = [Undocumented];
2397 def SPtr : TypeAttr {
2398 let Spellings = [Keyword<"__sptr">];
2399 let Documentation = [Undocumented];
2402 def UPtr : TypeAttr {
2403 let Spellings = [Keyword<"__uptr">];
2404 let Documentation = [Undocumented];
2407 def MSInheritance : InheritableAttr {
2408 let LangOpts = [MicrosoftExt];
2409 let Args = [DefaultBoolArgument<"BestCase", 1>];
2410 let Spellings = [Keyword<"__single_inheritance">,
2411 Keyword<"__multiple_inheritance">,
2412 Keyword<"__virtual_inheritance">,
2413 Keyword<"__unspecified_inheritance">];
2414 let AdditionalMembers = [{
2415 static bool hasVBPtrOffsetField(Spelling Inheritance) {
2416 return Inheritance == Keyword_unspecified_inheritance;
2419 // Only member pointers to functions need a this adjustment, since it can be
2420 // combined with the field offset for data pointers.
2421 static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
2422 return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
2425 static bool hasVBTableOffsetField(Spelling Inheritance) {
2426 return Inheritance >= Keyword_virtual_inheritance;
2429 static bool hasOnlyOneField(bool IsMemberFunction,
2430 Spelling Inheritance) {
2431 if (IsMemberFunction)
2432 return Inheritance <= Keyword_single_inheritance;
2433 return Inheritance <= Keyword_multiple_inheritance;
2436 let Documentation = [MSInheritanceDocs];
2439 def MSVtorDisp : InheritableAttr {
2440 // This attribute has no spellings as it is only ever created implicitly.
2442 let Args = [UnsignedArgument<"vdm">];
2443 let SemaHandler = 0;
2445 let AdditionalMembers = [{
2452 Mode getVtorDispMode() const { return Mode(vdm); }
2454 let Documentation = [Undocumented];
2457 def InitSeg : Attr {
2458 let Spellings = [Pragma<"", "init_seg">];
2459 let Args = [StringArgument<"Section">];
2460 let SemaHandler = 0;
2461 let Documentation = [InitSegDocs];
2462 let AdditionalMembers = [{
2463 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2464 OS << '(' << getSection() << ')';
2469 def LoopHint : Attr {
2470 /// #pragma clang loop <option> directive
2471 /// vectorize: vectorizes loop operations if State == Enable.
2472 /// vectorize_width: vectorize loop operations with width 'Value'.
2473 /// interleave: interleave multiple loop iterations if State == Enable.
2474 /// interleave_count: interleaves 'Value' loop interations.
2475 /// unroll: fully unroll loop if State == Enable.
2476 /// unroll_count: unrolls loop 'Value' times.
2477 /// distribute: attempt to distribute loop if State == Enable
2479 /// #pragma unroll <argument> directive
2480 /// <no arg>: fully unrolls loop.
2481 /// boolean: fully unrolls loop if State == Enable.
2482 /// expression: unrolls loop 'Value' times.
2484 let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">,
2485 Pragma<"", "nounroll">];
2487 /// State of the loop optimization specified by the spelling.
2488 let Args = [EnumArgument<"Option", "OptionType",
2489 ["vectorize", "vectorize_width", "interleave", "interleave_count",
2490 "unroll", "unroll_count", "distribute"],
2491 ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
2492 "Unroll", "UnrollCount", "Distribute"]>,
2493 EnumArgument<"State", "LoopHintState",
2494 ["enable", "disable", "numeric", "assume_safety", "full"],
2495 ["Enable", "Disable", "Numeric", "AssumeSafety", "Full"]>,
2496 ExprArgument<"Value">];
2498 let AdditionalMembers = [{
2499 static const char *getOptionName(int Option) {
2501 case Vectorize: return "vectorize";
2502 case VectorizeWidth: return "vectorize_width";
2503 case Interleave: return "interleave";
2504 case InterleaveCount: return "interleave_count";
2505 case Unroll: return "unroll";
2506 case UnrollCount: return "unroll_count";
2507 case Distribute: return "distribute";
2509 llvm_unreachable("Unhandled LoopHint option.");
2512 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2513 unsigned SpellingIndex = getSpellingListIndex();
2514 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
2515 // "nounroll" is already emitted as the pragma name.
2516 if (SpellingIndex == Pragma_nounroll)
2518 else if (SpellingIndex == Pragma_unroll) {
2519 OS << getValueString(Policy);
2523 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2524 OS << getOptionName(option) << getValueString(Policy);
2527 // Return a string containing the loop hint argument including the
2528 // enclosing parentheses.
2529 std::string getValueString(const PrintingPolicy &Policy) const {
2530 std::string ValueName;
2531 llvm::raw_string_ostream OS(ValueName);
2533 if (state == Numeric)
2534 value->printPretty(OS, nullptr, Policy);
2535 else if (state == Enable)
2537 else if (state == Full)
2539 else if (state == AssumeSafety)
2540 OS << "assume_safety";
2547 // Return a string suitable for identifying this attribute in diagnostics.
2548 std::string getDiagnosticName(const PrintingPolicy &Policy) const {
2549 unsigned SpellingIndex = getSpellingListIndex();
2550 if (SpellingIndex == Pragma_nounroll)
2551 return "#pragma nounroll";
2552 else if (SpellingIndex == Pragma_unroll)
2553 return "#pragma unroll" + (option == UnrollCount ? getValueString(Policy) : "");
2555 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2556 return getOptionName(option) + getValueString(Policy);
2560 let Documentation = [LoopHintDocs, UnrollHintDocs];
2563 def CapturedRecord : InheritableAttr {
2564 // This attribute has no spellings as it is only ever created implicitly.
2566 let SemaHandler = 0;
2567 let Documentation = [Undocumented];
2570 def OMPThreadPrivateDecl : InheritableAttr {
2571 // This attribute has no spellings as it is only ever created implicitly.
2573 let SemaHandler = 0;
2574 let Documentation = [Undocumented];
2577 def OMPCaptureNoInit : InheritableAttr {
2578 // This attribute has no spellings as it is only ever created implicitly.
2580 let SemaHandler = 0;
2581 let Documentation = [Undocumented];
2584 def OMPDeclareSimdDecl : Attr {
2585 let Spellings = [Pragma<"omp", "declare simd">];
2586 let Subjects = SubjectList<[Function]>;
2587 let SemaHandler = 0;
2588 let HasCustomParsing = 1;
2589 let Documentation = [OMPDeclareSimdDocs];
2591 EnumArgument<"BranchState", "BranchStateTy",
2592 [ "", "inbranch", "notinbranch" ],
2593 [ "BS_Undefined", "BS_Inbranch", "BS_Notinbranch" ]>,
2594 ExprArgument<"Simdlen">, VariadicExprArgument<"Uniforms">,
2595 VariadicExprArgument<"Aligneds">, VariadicExprArgument<"Alignments">,
2596 VariadicExprArgument<"Linears">, VariadicUnsignedArgument<"Modifiers">,
2597 VariadicExprArgument<"Steps">
2599 let AdditionalMembers = [{
2600 void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
2602 if (getBranchState() != BS_Undefined)
2603 OS << ConvertBranchStateTyToStr(getBranchState()) << " ";
2604 if (auto *E = getSimdlen()) {
2606 E->printPretty(OS, nullptr, Policy);
2609 if (uniforms_size() > 0) {
2611 StringRef Sep = "(";
2612 for (auto *E : uniforms()) {
2614 E->printPretty(OS, nullptr, Policy);
2619 alignments_iterator NI = alignments_begin();
2620 for (auto *E : aligneds()) {
2622 E->printPretty(OS, nullptr, Policy);
2625 (*NI)->printPretty(OS, nullptr, Policy);
2630 steps_iterator I = steps_begin();
2631 modifiers_iterator MI = modifiers_begin();
2632 for (auto *E : linears()) {
2634 if (*MI != OMPC_LINEAR_unknown)
2635 OS << getOpenMPSimpleClauseTypeName(OMPC_linear, *MI) << "(";
2636 E->printPretty(OS, nullptr, Policy);
2637 if (*MI != OMPC_LINEAR_unknown)
2641 (*I)->printPretty(OS, nullptr, Policy);
2651 def OMPDeclareTargetDecl : Attr {
2652 let Spellings = [Pragma<"omp", "declare target">];
2653 let SemaHandler = 0;
2654 let Documentation = [OMPDeclareTargetDocs];
2656 EnumArgument<"MapType", "MapTypeTy",
2658 [ "MT_To", "MT_Link" ]>
2660 let AdditionalMembers = [{
2661 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2662 // Use fake syntax because it is for testing and debugging purpose only.
2663 if (getMapType() != MT_To)
2664 OS << ConvertMapTypeTyToStr(getMapType()) << " ";
2669 def InternalLinkage : InheritableAttr {
2670 let Spellings = [GNU<"internal_linkage">, CXX11<"clang", "internal_linkage">];
2671 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
2672 let Documentation = [InternalLinkageDocs];