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 def OpenCLIntelReqdSubGroupSize: InheritableAttr {
868 let Spellings = [GNU<"intel_reqd_sub_group_size">];
869 let Args = [UnsignedArgument<"SubGroupSize">];
870 let Subjects = SubjectList<[Function], ErrorDiag>;
871 let Documentation = [OpenCLIntelReqdSubGroupSizeDocs];
874 // This attribute is both a type attribute, and a declaration attribute (for
875 // parameter variables).
876 def OpenCLAccess : Attr {
877 let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
878 Keyword<"__write_only">, Keyword<"write_only">,
879 Keyword<"__read_write">, Keyword<"read_write">];
880 let Subjects = SubjectList<[ParmVar, TypedefName], ErrorDiag,
881 "ExpectedParameterOrTypedef">;
882 let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
883 Keyword<"read_only">]>,
884 Accessor<"isReadWrite", [Keyword<"__read_write">,
885 Keyword<"read_write">]>,
886 Accessor<"isWriteOnly", [Keyword<"__write_only">,
887 Keyword<"write_only">]>];
888 let Documentation = [OpenCLAccessDocs];
891 def OpenCLPrivateAddressSpace : TypeAttr {
892 let Spellings = [Keyword<"__private">, Keyword<"private">];
893 let Documentation = [OpenCLAddressSpacePrivateDocs];
896 def OpenCLGlobalAddressSpace : TypeAttr {
897 let Spellings = [Keyword<"__global">, Keyword<"global">];
898 let Documentation = [OpenCLAddressSpaceGlobalDocs];
901 def OpenCLLocalAddressSpace : TypeAttr {
902 let Spellings = [Keyword<"__local">, Keyword<"local">];
903 let Documentation = [OpenCLAddressSpaceLocalDocs];
906 def OpenCLConstantAddressSpace : TypeAttr {
907 let Spellings = [Keyword<"__constant">, Keyword<"constant">];
908 let Documentation = [OpenCLAddressSpaceConstantDocs];
911 def OpenCLGenericAddressSpace : TypeAttr {
912 let Spellings = [Keyword<"__generic">, Keyword<"generic">];
913 let Documentation = [OpenCLAddressSpaceGenericDocs];
916 def OpenCLNoSVM : Attr {
917 let Spellings = [GNU<"nosvm">];
918 let Subjects = SubjectList<[Var]>;
919 let Documentation = [OpenCLNoSVMDocs];
920 let LangOpts = [OpenCL];
924 def RenderScriptKernel : Attr {
925 let Spellings = [GNU<"kernel">];
926 let Subjects = SubjectList<[Function]>;
927 let Documentation = [RenderScriptKernelAttributeDocs];
928 let LangOpts = [RenderScript];
931 def Deprecated : InheritableAttr {
932 let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
933 CXX11<"","deprecated", 201309>];
934 let Args = [StringArgument<"Message", 1>,
935 // An optional string argument that enables us to provide a
937 StringArgument<"Replacement", 1>];
938 let MeaningfulToClassTemplateDefinition = 1;
939 let Documentation = [DeprecatedDocs];
942 def Destructor : InheritableAttr {
943 let Spellings = [GCC<"destructor">];
944 let Args = [DefaultIntArgument<"Priority", 65535>];
945 let Subjects = SubjectList<[Function]>;
946 let Documentation = [Undocumented];
949 def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
950 let Spellings = [Declspec<"empty_bases">];
951 let Subjects = SubjectList<[CXXRecord]>;
952 let Documentation = [EmptyBasesDocs];
955 def AllocSize : InheritableAttr {
956 let Spellings = [GCC<"alloc_size">];
957 let Subjects = SubjectList<[Function]>;
958 let Args = [IntArgument<"ElemSizeParam">, IntArgument<"NumElemsParam", 1>];
959 let TemplateDependent = 1;
960 let Documentation = [AllocSizeDocs];
963 def EnableIf : InheritableAttr {
964 let Spellings = [GNU<"enable_if">];
965 let Subjects = SubjectList<[Function]>;
966 let Args = [ExprArgument<"Cond">, StringArgument<"Message">];
967 let TemplateDependent = 1;
968 let Documentation = [EnableIfDocs];
971 def ExtVectorType : Attr {
972 let Spellings = [GNU<"ext_vector_type">];
973 let Subjects = SubjectList<[TypedefName], ErrorDiag>;
974 let Args = [ExprArgument<"NumElements">];
976 let Documentation = [Undocumented];
979 def FallThrough : StmtAttr {
980 let Spellings = [CXX11<"", "fallthrough", 201603>,
981 CXX11<"clang", "fallthrough">];
982 // let Subjects = [NullStmt];
983 let Documentation = [FallthroughDocs];
986 def FastCall : InheritableAttr {
987 let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
988 Keyword<"_fastcall">];
989 // let Subjects = [Function, ObjCMethod];
990 let Documentation = [FastCallDocs];
993 def RegCall : InheritableAttr {
994 let Spellings = [GCC<"regcall">, Keyword<"__regcall">];
995 let Documentation = [RegCallDocs];
998 def Final : InheritableAttr {
999 let Spellings = [Keyword<"final">, Keyword<"sealed">];
1000 let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
1001 let SemaHandler = 0;
1002 let Documentation = [Undocumented];
1005 def MinSize : InheritableAttr {
1006 let Spellings = [GNU<"minsize">];
1007 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
1008 let Documentation = [Undocumented];
1011 def FlagEnum : InheritableAttr {
1012 let Spellings = [GNU<"flag_enum">];
1013 let Subjects = SubjectList<[Enum]>;
1014 let Documentation = [FlagEnumDocs];
1017 def EnumExtensibility : InheritableAttr {
1018 let Spellings = [GNU<"enum_extensibility">,
1019 CXX11<"clang", "enum_extensibility">];
1020 let Subjects = SubjectList<[Enum]>;
1021 let Args = [EnumArgument<"Extensibility", "Kind",
1022 ["closed", "open"], ["Closed", "Open"]>];
1023 let Documentation = [EnumExtensibilityDocs];
1026 def Flatten : InheritableAttr {
1027 let Spellings = [GCC<"flatten">];
1028 let Subjects = SubjectList<[Function], ErrorDiag>;
1029 let Documentation = [FlattenDocs];
1032 def Format : InheritableAttr {
1033 let Spellings = [GCC<"format">];
1034 let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
1035 IntArgument<"FirstArg">];
1036 let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto], WarnDiag,
1037 "ExpectedFunctionWithProtoType">;
1038 let Documentation = [FormatDocs];
1041 def FormatArg : InheritableAttr {
1042 let Spellings = [GCC<"format_arg">];
1043 let Args = [IntArgument<"FormatIdx">];
1044 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto], WarnDiag,
1045 "ExpectedFunctionWithProtoType">;
1046 let Documentation = [Undocumented];
1049 def GNUInline : InheritableAttr {
1050 let Spellings = [GCC<"gnu_inline">];
1051 let Subjects = SubjectList<[Function]>;
1052 let Documentation = [Undocumented];
1055 def Hot : InheritableAttr {
1056 let Spellings = [GCC<"hot">];
1057 let Subjects = SubjectList<[Function]>;
1058 // An AST node is created for this attribute, but not actually used beyond
1059 // semantic checking for mutual exclusion with the Cold attribute.
1060 let Documentation = [Undocumented];
1063 def IBAction : InheritableAttr {
1064 let Spellings = [GNU<"ibaction">];
1065 let Subjects = SubjectList<[ObjCInstanceMethod], WarnDiag,
1066 "ExpectedObjCInstanceMethod">;
1067 // An AST node is created for this attribute, but is not used by other parts
1068 // of the compiler. However, this node needs to exist in the AST because
1069 // external tools rely on it.
1070 let Documentation = [Undocumented];
1073 def IBOutlet : InheritableAttr {
1074 let Spellings = [GNU<"iboutlet">];
1075 // let Subjects = [ObjCIvar, ObjCProperty];
1076 let Documentation = [Undocumented];
1079 def IBOutletCollection : InheritableAttr {
1080 let Spellings = [GNU<"iboutletcollection">];
1081 let Args = [TypeArgument<"Interface", 1>];
1082 // let Subjects = [ObjCIvar, ObjCProperty];
1083 let Documentation = [Undocumented];
1087 let Spellings = [GCC<"ifunc">];
1088 let Args = [StringArgument<"Resolver">];
1089 let Subjects = SubjectList<[Function]>;
1090 let Documentation = [IFuncDocs];
1093 def Restrict : InheritableAttr {
1094 let Spellings = [Declspec<"restrict">, GCC<"malloc">];
1095 let Subjects = SubjectList<[Function]>;
1096 let Documentation = [Undocumented];
1099 def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
1100 let Spellings = [Declspec<"layout_version">];
1101 let Args = [UnsignedArgument<"Version">];
1102 let Subjects = SubjectList<[CXXRecord]>;
1103 let Documentation = [LayoutVersionDocs];
1106 def MaxFieldAlignment : InheritableAttr {
1107 // This attribute has no spellings as it is only ever created implicitly.
1109 let Args = [UnsignedArgument<"Alignment">];
1110 let SemaHandler = 0;
1111 let Documentation = [Undocumented];
1114 def MayAlias : InheritableAttr {
1115 // FIXME: this is a type attribute in GCC, but a declaration attribute here.
1116 let Spellings = [GCC<"may_alias">];
1117 let Documentation = [Undocumented];
1120 def MSABI : InheritableAttr {
1121 let Spellings = [GCC<"ms_abi">];
1122 // let Subjects = [Function, ObjCMethod];
1123 let Documentation = [MSABIDocs];
1126 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
1127 // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's
1128 // and AnyX86Interrupt's spellings must match.
1129 let Spellings = [GNU<"interrupt">];
1130 let Args = [UnsignedArgument<"Number">];
1131 let ParseKind = "Interrupt";
1132 let HasCustomParsing = 1;
1133 let Documentation = [Undocumented];
1136 def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
1137 let Spellings = [GCC<"mips16">];
1138 let Subjects = SubjectList<[Function], ErrorDiag>;
1139 let Documentation = [Undocumented];
1142 def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips> {
1143 // NOTE: If you add any additional spellings, ARMInterrupt's,
1144 // MSP430Interrupt's and AnyX86Interrupt's spellings must match.
1145 let Spellings = [GNU<"interrupt">];
1146 let Subjects = SubjectList<[Function]>;
1147 let Args = [EnumArgument<"Interrupt", "InterruptType",
1148 ["vector=sw0", "vector=sw1", "vector=hw0",
1149 "vector=hw1", "vector=hw2", "vector=hw3",
1150 "vector=hw4", "vector=hw5", "eic", ""],
1151 ["sw0", "sw1", "hw0", "hw1", "hw2", "hw3",
1152 "hw4", "hw5", "eic", "eic"]
1154 let ParseKind = "Interrupt";
1155 let Documentation = [MipsInterruptDocs];
1159 let Spellings = [GCC<"mode">];
1160 let Subjects = SubjectList<[Var, Enum, TypedefName, Field], ErrorDiag,
1161 "ExpectedVariableEnumFieldOrTypedef">;
1162 let Args = [IdentifierArgument<"Mode">];
1163 let Documentation = [Undocumented];
1166 def Naked : InheritableAttr {
1167 let Spellings = [GCC<"naked">, Declspec<"naked">];
1168 let Subjects = SubjectList<[Function]>;
1169 let Documentation = [Undocumented];
1172 def NeonPolyVectorType : TypeAttr {
1173 let Spellings = [GNU<"neon_polyvector_type">];
1174 let Args = [IntArgument<"NumElements">];
1175 let Documentation = [Undocumented];
1178 def NeonVectorType : TypeAttr {
1179 let Spellings = [GNU<"neon_vector_type">];
1180 let Args = [IntArgument<"NumElements">];
1181 let Documentation = [Undocumented];
1184 def ReturnsTwice : InheritableAttr {
1185 let Spellings = [GCC<"returns_twice">];
1186 let Subjects = SubjectList<[Function]>;
1187 let Documentation = [Undocumented];
1190 def DisableTailCalls : InheritableAttr {
1191 let Spellings = [GNU<"disable_tail_calls">,
1192 CXX11<"clang", "disable_tail_calls">];
1193 let Subjects = SubjectList<[Function, ObjCMethod]>;
1194 let Documentation = [DisableTailCallsDocs];
1197 def NoAlias : InheritableAttr {
1198 let Spellings = [Declspec<"noalias">];
1199 let Subjects = SubjectList<[Function]>;
1200 let Documentation = [NoAliasDocs];
1203 def NoCommon : InheritableAttr {
1204 let Spellings = [GCC<"nocommon">];
1205 let Subjects = SubjectList<[Var]>;
1206 let Documentation = [Undocumented];
1209 def NoDebug : InheritableAttr {
1210 let Spellings = [GCC<"nodebug">];
1211 let Subjects = SubjectList<[FunctionLike, ObjCMethod, NonParmVar], WarnDiag,
1212 "ExpectedVariableOrFunction">;
1213 let Documentation = [NoDebugDocs];
1216 def NoDuplicate : InheritableAttr {
1217 let Spellings = [GNU<"noduplicate">, CXX11<"clang", "noduplicate">];
1218 let Subjects = SubjectList<[Function]>;
1219 let Documentation = [NoDuplicateDocs];
1222 def Convergent : InheritableAttr {
1223 let Spellings = [GNU<"convergent">, CXX11<"clang", "convergent">];
1224 let Subjects = SubjectList<[Function]>;
1225 let Documentation = [ConvergentDocs];
1228 def NoInline : InheritableAttr {
1229 let Spellings = [GCC<"noinline">, Declspec<"noinline">];
1230 let Subjects = SubjectList<[Function]>;
1231 let Documentation = [Undocumented];
1234 def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
1235 let Spellings = [GCC<"nomips16">];
1236 let Subjects = SubjectList<[Function], ErrorDiag>;
1237 let Documentation = [Undocumented];
1240 // This is not a TargetSpecificAttr so that is silently accepted and
1241 // ignored on other targets as encouraged by the OpenCL spec.
1243 // See OpenCL 1.2 6.11.5: "It is our intention that a particular
1244 // implementation of OpenCL be free to ignore all attributes and the
1245 // resulting executable binary will produce the same result."
1247 // However, only AMD GPU targets will emit the corresponding IR
1250 // FIXME: This provides a sub-optimal error message if you attempt to
1251 // use this in CUDA, since CUDA does not use the same terminology.
1253 // FIXME: SubjectList should be for OpenCLKernelFunction, but is not to
1254 // workaround needing to see kernel attribute before others to know if
1255 // this should be rejected on non-kernels.
1257 def AMDGPUFlatWorkGroupSize : InheritableAttr {
1258 let Spellings = [GNU<"amdgpu_flat_work_group_size">];
1259 let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max">];
1260 let Documentation = [AMDGPUFlatWorkGroupSizeDocs];
1261 let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1264 def AMDGPUWavesPerEU : InheritableAttr {
1265 let Spellings = [GNU<"amdgpu_waves_per_eu">];
1266 let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max", 1>];
1267 let Documentation = [AMDGPUWavesPerEUDocs];
1268 let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1271 def AMDGPUNumSGPR : InheritableAttr {
1272 let Spellings = [GNU<"amdgpu_num_sgpr">];
1273 let Args = [UnsignedArgument<"NumSGPR">];
1274 let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1275 let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1278 def AMDGPUNumVGPR : InheritableAttr {
1279 let Spellings = [GNU<"amdgpu_num_vgpr">];
1280 let Args = [UnsignedArgument<"NumVGPR">];
1281 let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1282 let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1285 def NoSplitStack : InheritableAttr {
1286 let Spellings = [GCC<"no_split_stack">];
1287 let Subjects = SubjectList<[Function], ErrorDiag>;
1288 let Documentation = [NoSplitStackDocs];
1291 def NonNull : InheritableParamAttr {
1292 let Spellings = [GCC<"nonnull">];
1293 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
1294 "ExpectedFunctionMethodOrParameter">;
1295 let Args = [VariadicUnsignedArgument<"Args">];
1296 let AdditionalMembers =
1297 [{bool isNonNull(unsigned idx) const {
1300 for (const auto &V : args())
1305 // FIXME: We should merge duplicates into a single nonnull attribute.
1306 let DuplicatesAllowedWhileMerging = 1;
1307 let Documentation = [NonNullDocs];
1310 def ReturnsNonNull : InheritableAttr {
1311 let Spellings = [GCC<"returns_nonnull">];
1312 let Subjects = SubjectList<[ObjCMethod, Function], WarnDiag,
1313 "ExpectedFunctionOrMethod">;
1314 let Documentation = [ReturnsNonNullDocs];
1317 // pass_object_size(N) indicates that the parameter should have
1318 // __builtin_object_size with Type=N evaluated on the parameter at the callsite.
1319 def PassObjectSize : InheritableParamAttr {
1320 let Spellings = [GNU<"pass_object_size">];
1321 let Args = [IntArgument<"Type">];
1322 let Subjects = SubjectList<[ParmVar]>;
1323 let Documentation = [PassObjectSizeDocs];
1326 // Nullability type attributes.
1327 def TypeNonNull : TypeAttr {
1328 let Spellings = [Keyword<"_Nonnull">];
1329 let Documentation = [TypeNonNullDocs];
1332 def TypeNullable : TypeAttr {
1333 let Spellings = [Keyword<"_Nullable">];
1334 let Documentation = [TypeNullableDocs];
1337 def TypeNullUnspecified : TypeAttr {
1338 let Spellings = [Keyword<"_Null_unspecified">];
1339 let Documentation = [TypeNullUnspecifiedDocs];
1342 def ObjCKindOf : TypeAttr {
1343 let Spellings = [Keyword<"__kindof">];
1344 let Documentation = [Undocumented];
1347 def AssumeAligned : InheritableAttr {
1348 let Spellings = [GCC<"assume_aligned">];
1349 let Subjects = SubjectList<[ObjCMethod, Function]>;
1350 let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>];
1351 let Documentation = [AssumeAlignedDocs];
1354 def AllocAlign : InheritableAttr {
1355 let Spellings = [GCC<"alloc_align">];
1356 let Subjects = SubjectList<[HasFunctionProto], WarnDiag,
1357 "ExpectedFunctionWithProtoType">;
1358 let Args = [IntArgument<"ParamIndex">];
1359 let Documentation = [AllocAlignDocs];
1362 def NoReturn : InheritableAttr {
1363 let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
1364 // FIXME: Does GCC allow this on the function instead?
1365 let Documentation = [Undocumented];
1368 def NoInstrumentFunction : InheritableAttr {
1369 let Spellings = [GCC<"no_instrument_function">];
1370 let Subjects = SubjectList<[Function]>;
1371 let Documentation = [Undocumented];
1374 def NotTailCalled : InheritableAttr {
1375 let Spellings = [GNU<"not_tail_called">, CXX11<"clang", "not_tail_called">];
1376 let Subjects = SubjectList<[Function]>;
1377 let Documentation = [NotTailCalledDocs];
1380 def NoThrow : InheritableAttr {
1381 let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
1382 let Documentation = [Undocumented];
1385 def NvWeak : IgnoredAttr {
1386 // No Declspec spelling of this attribute; the CUDA headers use
1387 // __attribute__((nv_weak)) unconditionally.
1388 let Spellings = [GNU<"nv_weak">];
1389 let LangOpts = [CUDA];
1392 def ObjCBridge : InheritableAttr {
1393 let Spellings = [GNU<"objc_bridge">];
1394 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag,
1395 "ExpectedStructOrUnionOrTypedef">;
1396 let Args = [IdentifierArgument<"BridgedType">];
1397 let Documentation = [Undocumented];
1400 def ObjCBridgeMutable : InheritableAttr {
1401 let Spellings = [GNU<"objc_bridge_mutable">];
1402 let Subjects = SubjectList<[Record], ErrorDiag>;
1403 let Args = [IdentifierArgument<"BridgedType">];
1404 let Documentation = [Undocumented];
1407 def ObjCBridgeRelated : InheritableAttr {
1408 let Spellings = [GNU<"objc_bridge_related">];
1409 let Subjects = SubjectList<[Record], ErrorDiag>;
1410 let Args = [IdentifierArgument<"RelatedClass">,
1411 IdentifierArgument<"ClassMethod", 1>,
1412 IdentifierArgument<"InstanceMethod", 1>];
1413 let HasCustomParsing = 1;
1414 let Documentation = [Undocumented];
1417 def NSReturnsRetained : InheritableAttr {
1418 let Spellings = [GNU<"ns_returns_retained">];
1419 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1420 let Documentation = [Undocumented];
1423 def NSReturnsNotRetained : InheritableAttr {
1424 let Spellings = [GNU<"ns_returns_not_retained">];
1425 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1426 let Documentation = [Undocumented];
1429 def NSReturnsAutoreleased : InheritableAttr {
1430 let Spellings = [GNU<"ns_returns_autoreleased">];
1431 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1432 let Documentation = [Undocumented];
1435 def NSConsumesSelf : InheritableAttr {
1436 let Spellings = [GNU<"ns_consumes_self">];
1437 let Subjects = SubjectList<[ObjCMethod]>;
1438 let Documentation = [Undocumented];
1441 def NSConsumed : InheritableParamAttr {
1442 let Spellings = [GNU<"ns_consumed">];
1443 let Subjects = SubjectList<[ParmVar]>;
1444 let Documentation = [Undocumented];
1447 def ObjCException : InheritableAttr {
1448 let Spellings = [GNU<"objc_exception">];
1449 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1450 let Documentation = [Undocumented];
1453 def ObjCMethodFamily : InheritableAttr {
1454 let Spellings = [GNU<"objc_method_family">];
1455 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1456 let Args = [EnumArgument<"Family", "FamilyKind",
1457 ["none", "alloc", "copy", "init", "mutableCopy", "new"],
1458 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
1459 "OMF_mutableCopy", "OMF_new"]>];
1460 let Documentation = [ObjCMethodFamilyDocs];
1463 def ObjCNSObject : InheritableAttr {
1464 let Spellings = [GNU<"NSObject">];
1465 let Documentation = [Undocumented];
1468 def ObjCIndependentClass : InheritableAttr {
1469 let Spellings = [GNU<"objc_independent_class">];
1470 let Documentation = [Undocumented];
1473 def ObjCPreciseLifetime : InheritableAttr {
1474 let Spellings = [GNU<"objc_precise_lifetime">];
1475 let Subjects = SubjectList<[Var], ErrorDiag>;
1476 let Documentation = [Undocumented];
1479 def ObjCReturnsInnerPointer : InheritableAttr {
1480 let Spellings = [GNU<"objc_returns_inner_pointer">];
1481 let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
1482 let Documentation = [Undocumented];
1485 def ObjCRequiresSuper : InheritableAttr {
1486 let Spellings = [GNU<"objc_requires_super">];
1487 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1488 let Documentation = [ObjCRequiresSuperDocs];
1491 def ObjCRootClass : InheritableAttr {
1492 let Spellings = [GNU<"objc_root_class">];
1493 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1494 let Documentation = [Undocumented];
1497 def ObjCSubclassingRestricted : InheritableAttr {
1498 let Spellings = [GNU<"objc_subclassing_restricted">];
1499 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1500 let Documentation = [ObjCSubclassingRestrictedDocs];
1503 def ObjCExplicitProtocolImpl : InheritableAttr {
1504 let Spellings = [GNU<"objc_protocol_requires_explicit_implementation">];
1505 let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
1506 let Documentation = [Undocumented];
1509 def ObjCDesignatedInitializer : Attr {
1510 let Spellings = [GNU<"objc_designated_initializer">];
1511 let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag,
1512 "ExpectedObjCInterfaceDeclInitMethod">;
1513 let Documentation = [Undocumented];
1516 def ObjCRuntimeName : Attr {
1517 let Spellings = [GNU<"objc_runtime_name">];
1518 let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
1519 let Args = [StringArgument<"MetadataName">];
1520 let Documentation = [ObjCRuntimeNameDocs];
1523 def ObjCRuntimeVisible : Attr {
1524 let Spellings = [GNU<"objc_runtime_visible">];
1525 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1526 let Documentation = [ObjCRuntimeVisibleDocs];
1529 def ObjCBoxable : Attr {
1530 let Spellings = [GNU<"objc_boxable">];
1531 let Subjects = SubjectList<[Record], ErrorDiag, "ExpectedStructOrUnion">;
1532 let Documentation = [ObjCBoxableDocs];
1535 def OptimizeNone : InheritableAttr {
1536 let Spellings = [GNU<"optnone">, CXX11<"clang", "optnone">];
1537 let Subjects = SubjectList<[Function, ObjCMethod]>;
1538 let Documentation = [OptnoneDocs];
1541 def Overloadable : Attr {
1542 let Spellings = [GNU<"overloadable">];
1543 let Subjects = SubjectList<[Function], ErrorDiag>;
1544 let Documentation = [OverloadableDocs];
1547 def Override : InheritableAttr {
1548 let Spellings = [Keyword<"override">];
1549 let SemaHandler = 0;
1550 let Documentation = [Undocumented];
1553 def Ownership : InheritableAttr {
1554 let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
1555 GNU<"ownership_takes">];
1556 let Accessors = [Accessor<"isHolds", [GNU<"ownership_holds">]>,
1557 Accessor<"isReturns", [GNU<"ownership_returns">]>,
1558 Accessor<"isTakes", [GNU<"ownership_takes">]>];
1559 let AdditionalMembers = [{
1560 enum OwnershipKind { Holds, Returns, Takes };
1561 OwnershipKind getOwnKind() const {
1562 return isHolds() ? Holds :
1567 let Args = [IdentifierArgument<"Module">, VariadicUnsignedArgument<"Args">];
1568 let Subjects = SubjectList<[HasFunctionProto], WarnDiag,
1569 "ExpectedFunctionWithProtoType">;
1570 let Documentation = [Undocumented];
1573 def Packed : InheritableAttr {
1574 let Spellings = [GCC<"packed">];
1575 // let Subjects = [Tag, Field];
1576 let Documentation = [Undocumented];
1579 def IntelOclBicc : InheritableAttr {
1580 let Spellings = [GNU<"intel_ocl_bicc">];
1581 // let Subjects = [Function, ObjCMethod];
1582 let Documentation = [Undocumented];
1585 def Pcs : InheritableAttr {
1586 let Spellings = [GCC<"pcs">];
1587 let Args = [EnumArgument<"PCS", "PCSType",
1588 ["aapcs", "aapcs-vfp"],
1589 ["AAPCS", "AAPCS_VFP"]>];
1590 // let Subjects = [Function, ObjCMethod];
1591 let Documentation = [PcsDocs];
1594 def Pure : InheritableAttr {
1595 let Spellings = [GCC<"pure">];
1596 let Documentation = [Undocumented];
1599 def Regparm : TypeAttr {
1600 let Spellings = [GCC<"regparm">];
1601 let Args = [UnsignedArgument<"NumParams">];
1602 let Documentation = [RegparmDocs];
1605 def ReqdWorkGroupSize : InheritableAttr {
1606 let Spellings = [GNU<"reqd_work_group_size">];
1607 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
1608 UnsignedArgument<"ZDim">];
1609 let Subjects = SubjectList<[Function], ErrorDiag>;
1610 let Documentation = [Undocumented];
1613 def RequireConstantInit : InheritableAttr {
1614 let Spellings = [GNU<"require_constant_initialization">,
1615 CXX11<"clang", "require_constant_initialization">];
1616 let Subjects = SubjectList<[GlobalVar], ErrorDiag,
1617 "ExpectedStaticOrTLSVar">;
1618 let Documentation = [RequireConstantInitDocs];
1619 let LangOpts = [CPlusPlus];
1622 def WorkGroupSizeHint : InheritableAttr {
1623 let Spellings = [GNU<"work_group_size_hint">];
1624 let Args = [UnsignedArgument<"XDim">,
1625 UnsignedArgument<"YDim">,
1626 UnsignedArgument<"ZDim">];
1627 let Subjects = SubjectList<[Function], ErrorDiag>;
1628 let Documentation = [Undocumented];
1631 def InitPriority : InheritableAttr {
1632 let Spellings = [GNU<"init_priority">];
1633 let Args = [UnsignedArgument<"Priority">];
1634 let Subjects = SubjectList<[Var], ErrorDiag>;
1635 let Documentation = [Undocumented];
1638 def Section : InheritableAttr {
1639 let Spellings = [GCC<"section">, Declspec<"allocate">];
1640 let Args = [StringArgument<"Name">];
1641 let Subjects = SubjectList<[Function, GlobalVar,
1642 ObjCMethod, ObjCProperty], ErrorDiag,
1643 "ExpectedFunctionGlobalVarMethodOrProperty">;
1644 let Documentation = [SectionDocs];
1647 def Sentinel : InheritableAttr {
1648 let Spellings = [GCC<"sentinel">];
1649 let Args = [DefaultIntArgument<"Sentinel", 0>,
1650 DefaultIntArgument<"NullPos", 0>];
1651 // let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
1652 let Documentation = [Undocumented];
1655 def StdCall : InheritableAttr {
1656 let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
1657 // let Subjects = [Function, ObjCMethod];
1658 let Documentation = [StdCallDocs];
1661 def SwiftCall : InheritableAttr {
1662 let Spellings = [GCC<"swiftcall">];
1663 // let Subjects = SubjectList<[Function]>;
1664 let Documentation = [SwiftCallDocs];
1667 def SwiftContext : ParameterABIAttr {
1668 let Spellings = [GCC<"swift_context">];
1669 let Documentation = [SwiftContextDocs];
1672 def SwiftErrorResult : ParameterABIAttr {
1673 let Spellings = [GCC<"swift_error_result">];
1674 let Documentation = [SwiftErrorResultDocs];
1677 def SwiftIndirectResult : ParameterABIAttr {
1678 let Spellings = [GCC<"swift_indirect_result">];
1679 let Documentation = [SwiftIndirectResultDocs];
1682 def Suppress : StmtAttr {
1683 let Spellings = [CXX11<"gsl", "suppress">];
1684 let Args = [VariadicStringArgument<"DiagnosticIdentifiers">];
1685 let Documentation = [SuppressDocs];
1688 def SysVABI : InheritableAttr {
1689 let Spellings = [GCC<"sysv_abi">];
1690 // let Subjects = [Function, ObjCMethod];
1691 let Documentation = [Undocumented];
1694 def ThisCall : InheritableAttr {
1695 let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
1696 Keyword<"_thiscall">];
1697 // let Subjects = [Function, ObjCMethod];
1698 let Documentation = [ThisCallDocs];
1701 def VectorCall : InheritableAttr {
1702 let Spellings = [GNU<"vectorcall">, Keyword<"__vectorcall">,
1703 Keyword<"_vectorcall">];
1704 // let Subjects = [Function, ObjCMethod];
1705 let Documentation = [VectorCallDocs];
1708 def Pascal : InheritableAttr {
1709 let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
1710 // let Subjects = [Function, ObjCMethod];
1711 let Documentation = [Undocumented];
1714 def PreserveMost : InheritableAttr {
1715 let Spellings = [GNU<"preserve_most">];
1716 let Documentation = [PreserveMostDocs];
1719 def PreserveAll : InheritableAttr {
1720 let Spellings = [GNU<"preserve_all">];
1721 let Documentation = [PreserveAllDocs];
1724 def Target : InheritableAttr {
1725 let Spellings = [GCC<"target">];
1726 let Args = [StringArgument<"featuresStr">];
1727 let Subjects = SubjectList<[Function], ErrorDiag>;
1728 let Documentation = [TargetDocs];
1729 let AdditionalMembers = [{
1730 typedef std::pair<std::vector<std::string>, StringRef> ParsedTargetAttr;
1731 ParsedTargetAttr parse() const {
1732 ParsedTargetAttr Ret;
1733 SmallVector<StringRef, 1> AttrFeatures;
1734 getFeaturesStr().split(AttrFeatures, ",");
1736 // Grab the various features and prepend a "+" to turn on the feature to
1737 // the backend and add them to our existing set of features.
1738 for (auto &Feature : AttrFeatures) {
1739 // Go ahead and trim whitespace rather than either erroring or
1740 // accepting it weirdly.
1741 Feature = Feature.trim();
1743 // We don't support cpu tuning this way currently.
1744 // TODO: Support the fpmath option. It will require checking
1745 // overall feature validity for the function with the rest of the
1746 // attributes on the function.
1747 if (Feature.startswith("fpmath=") || Feature.startswith("tune="))
1750 // While we're here iterating check for a different target cpu.
1751 if (Feature.startswith("arch="))
1752 Ret.second = Feature.split("=").second.trim();
1753 else if (Feature.startswith("no-"))
1754 Ret.first.push_back("-" + Feature.split("-").second.str());
1756 Ret.first.push_back("+" + Feature.str());
1763 def TransparentUnion : InheritableAttr {
1764 let Spellings = [GCC<"transparent_union">];
1765 // let Subjects = SubjectList<[Record, TypedefName]>;
1766 let Documentation = [TransparentUnionDocs];
1767 let LangOpts = [COnly];
1770 def Unavailable : InheritableAttr {
1771 let Spellings = [GNU<"unavailable">];
1772 let Args = [StringArgument<"Message", 1>,
1773 EnumArgument<"ImplicitReason", "ImplicitReason",
1776 "IR_ARCForbiddenType",
1778 "IR_ARCForbiddenConversion",
1779 "IR_ARCInitReturnsUnrelated",
1780 "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>];
1781 let Documentation = [Undocumented];
1784 def DiagnoseIf : InheritableAttr {
1785 let Spellings = [GNU<"diagnose_if">];
1786 let Subjects = SubjectList<[Function]>;
1787 let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
1788 EnumArgument<"DiagnosticType",
1790 ["error", "warning"],
1791 ["DT_Error", "DT_Warning"]>,
1792 BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
1793 FunctionArgument<"Parent", 0, /*fake*/ 1>];
1794 let DuplicatesAllowedWhileMerging = 1;
1796 let AdditionalMembers = [{
1797 bool isError() const { return diagnosticType == DT_Error; }
1798 bool isWarning() const { return diagnosticType == DT_Warning; }
1800 let TemplateDependent = 1;
1801 let Documentation = [DiagnoseIfDocs];
1804 def ArcWeakrefUnavailable : InheritableAttr {
1805 let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
1806 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1807 let Documentation = [Undocumented];
1810 def ObjCGC : TypeAttr {
1811 let Spellings = [GNU<"objc_gc">];
1812 let Args = [IdentifierArgument<"Kind">];
1813 let Documentation = [Undocumented];
1816 def ObjCOwnership : InheritableAttr {
1817 let Spellings = [GNU<"objc_ownership">];
1818 let Args = [IdentifierArgument<"Kind">];
1820 let Documentation = [Undocumented];
1823 def ObjCRequiresPropertyDefs : InheritableAttr {
1824 let Spellings = [GNU<"objc_requires_property_definitions">];
1825 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1826 let Documentation = [Undocumented];
1829 def Unused : InheritableAttr {
1830 let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">];
1831 let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
1832 Field, ObjCMethod, FunctionLike], WarnDiag,
1833 "ExpectedForMaybeUnused">;
1834 let Documentation = [WarnMaybeUnusedDocs];
1837 def Used : InheritableAttr {
1838 let Spellings = [GCC<"used">];
1839 let Documentation = [Undocumented];
1842 def Uuid : InheritableAttr {
1843 let Spellings = [Declspec<"uuid">, Microsoft<"uuid">];
1844 let Args = [StringArgument<"Guid">];
1845 let Subjects = SubjectList<[Record, Enum], WarnDiag, "ExpectedEnumOrClass">;
1846 // FIXME: Allow expressing logical AND for LangOpts. Our condition should be:
1847 // CPlusPlus && (MicrosoftExt || Borland)
1848 let LangOpts = [MicrosoftExt, Borland];
1849 let Documentation = [Undocumented];
1852 def VectorSize : TypeAttr {
1853 let Spellings = [GCC<"vector_size">];
1854 let Args = [ExprArgument<"NumBytes">];
1855 let Documentation = [Undocumented];
1858 def VecTypeHint : InheritableAttr {
1859 let Spellings = [GNU<"vec_type_hint">];
1860 let Args = [TypeArgument<"TypeHint">];
1861 let Subjects = SubjectList<[Function], ErrorDiag>;
1862 let Documentation = [Undocumented];
1865 def Visibility : InheritableAttr {
1867 let Spellings = [GCC<"visibility">];
1868 let Args = [EnumArgument<"Visibility", "VisibilityType",
1869 ["default", "hidden", "internal", "protected"],
1870 ["Default", "Hidden", "Hidden", "Protected"]>];
1871 let MeaningfulToClassTemplateDefinition = 1;
1872 let Documentation = [Undocumented];
1875 def TypeVisibility : InheritableAttr {
1877 let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">];
1878 let Args = [EnumArgument<"Visibility", "VisibilityType",
1879 ["default", "hidden", "internal", "protected"],
1880 ["Default", "Hidden", "Hidden", "Protected"]>];
1881 // let Subjects = [Tag, ObjCInterface, Namespace];
1882 let Documentation = [Undocumented];
1885 def VecReturn : InheritableAttr {
1886 let Spellings = [GNU<"vecreturn">];
1887 let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
1888 let Documentation = [Undocumented];
1891 def WarnUnused : InheritableAttr {
1892 let Spellings = [GNU<"warn_unused">];
1893 let Subjects = SubjectList<[Record]>;
1894 let Documentation = [Undocumented];
1897 def WarnUnusedResult : InheritableAttr {
1898 let Spellings = [CXX11<"", "nodiscard", 201603>,
1899 CXX11<"clang", "warn_unused_result">,
1900 GCC<"warn_unused_result">];
1901 let Subjects = SubjectList<[ObjCMethod, Enum, CXXRecord, FunctionLike],
1902 WarnDiag, "ExpectedFunctionMethodEnumOrClass">;
1903 let Documentation = [WarnUnusedResultsDocs];
1906 def Weak : InheritableAttr {
1907 let Spellings = [GCC<"weak">];
1908 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
1909 let Documentation = [Undocumented];
1912 def WeakImport : InheritableAttr {
1913 let Spellings = [GNU<"weak_import">];
1914 let Documentation = [Undocumented];
1917 def WeakRef : InheritableAttr {
1918 let Spellings = [GCC<"weakref">];
1919 // A WeakRef that has an argument is treated as being an AliasAttr
1920 let Args = [StringArgument<"Aliasee", 1>];
1921 let Subjects = SubjectList<[Var, Function], ErrorDiag>;
1922 let Documentation = [Undocumented];
1925 def LTOVisibilityPublic : InheritableAttr {
1926 let Spellings = [CXX11<"clang", "lto_visibility_public">];
1927 let Subjects = SubjectList<[Record]>;
1928 let Documentation = [LTOVisibilityDocs];
1931 def AnyX86Interrupt : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
1932 // NOTE: If you add any additional spellings, ARMInterrupt's,
1933 // MSP430Interrupt's and MipsInterrupt's spellings must match.
1934 let Spellings = [GNU<"interrupt">];
1935 let Subjects = SubjectList<[HasFunctionProto]>;
1936 let ParseKind = "Interrupt";
1937 let HasCustomParsing = 1;
1938 let Documentation = [AnyX86InterruptDocs];
1941 def AnyX86NoCallerSavedRegisters : InheritableAttr,
1942 TargetSpecificAttr<TargetAnyX86> {
1943 let Spellings = [GCC<"no_caller_saved_registers">];
1944 let Documentation = [AnyX86NoCallerSavedRegistersDocs];
1947 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetX86> {
1948 let Spellings = [GNU<"force_align_arg_pointer">];
1949 // Technically, this appertains to a FunctionDecl, but the target-specific
1950 // code silently allows anything function-like (such as typedefs or function
1951 // pointers), but does not apply the attribute to them.
1952 let Documentation = [Undocumented];
1955 def NoSanitize : InheritableAttr {
1956 let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">];
1957 let Args = [VariadicStringArgument<"Sanitizers">];
1958 let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag,
1959 "ExpectedFunctionMethodOrGlobalVar">;
1960 let Documentation = [NoSanitizeDocs];
1961 let AdditionalMembers = [{
1962 SanitizerMask getMask() const {
1963 SanitizerMask Mask = 0;
1964 for (auto SanitizerName : sanitizers()) {
1965 SanitizerMask ParsedMask =
1966 parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
1967 Mask |= expandSanitizerGroups(ParsedMask);
1974 // Attributes to disable a specific sanitizer. No new sanitizers should be added
1975 // to this list; the no_sanitize attribute should be extended instead.
1976 def NoSanitizeSpecific : InheritableAttr {
1977 let Spellings = [GCC<"no_address_safety_analysis">,
1978 GCC<"no_sanitize_address">,
1979 GCC<"no_sanitize_thread">,
1980 GNU<"no_sanitize_memory">];
1981 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
1982 "ExpectedFunctionOrGlobalVar">;
1983 let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
1984 NoSanitizeMemoryDocs];
1988 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
1990 def GuardedVar : InheritableAttr {
1991 let Spellings = [GNU<"guarded_var">];
1992 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1993 "ExpectedFieldOrGlobalVar">;
1994 let Documentation = [Undocumented];
1997 def PtGuardedVar : InheritableAttr {
1998 let Spellings = [GNU<"pt_guarded_var">];
1999 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2000 "ExpectedFieldOrGlobalVar">;
2001 let Documentation = [Undocumented];
2004 def Lockable : InheritableAttr {
2005 let Spellings = [GNU<"lockable">];
2006 let Subjects = SubjectList<[Record]>;
2007 let Documentation = [Undocumented];
2008 let ASTNode = 0; // Replaced by Capability
2011 def ScopedLockable : InheritableAttr {
2012 let Spellings = [GNU<"scoped_lockable">];
2013 let Subjects = SubjectList<[Record]>;
2014 let Documentation = [Undocumented];
2017 def Capability : InheritableAttr {
2018 let Spellings = [GNU<"capability">, CXX11<"clang", "capability">,
2019 GNU<"shared_capability">,
2020 CXX11<"clang", "shared_capability">];
2021 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag,
2022 "ExpectedStructOrUnionOrTypedef">;
2023 let Args = [StringArgument<"Name">];
2024 let Accessors = [Accessor<"isShared",
2025 [GNU<"shared_capability">,
2026 CXX11<"clang","shared_capability">]>];
2027 let Documentation = [Undocumented];
2028 let AdditionalMembers = [{
2029 bool isMutex() const { return getName().equals_lower("mutex"); }
2030 bool isRole() const { return getName().equals_lower("role"); }
2034 def AssertCapability : InheritableAttr {
2035 let Spellings = [GNU<"assert_capability">,
2036 CXX11<"clang", "assert_capability">,
2037 GNU<"assert_shared_capability">,
2038 CXX11<"clang", "assert_shared_capability">];
2039 let Subjects = SubjectList<[Function]>;
2041 let TemplateDependent = 1;
2042 let ParseArgumentsAsUnevaluated = 1;
2043 let DuplicatesAllowedWhileMerging = 1;
2044 let Args = [ExprArgument<"Expr">];
2045 let Accessors = [Accessor<"isShared",
2046 [GNU<"assert_shared_capability">,
2047 CXX11<"clang", "assert_shared_capability">]>];
2048 let Documentation = [AssertCapabilityDocs];
2051 def AcquireCapability : InheritableAttr {
2052 let Spellings = [GNU<"acquire_capability">,
2053 CXX11<"clang", "acquire_capability">,
2054 GNU<"acquire_shared_capability">,
2055 CXX11<"clang", "acquire_shared_capability">,
2056 GNU<"exclusive_lock_function">,
2057 GNU<"shared_lock_function">];
2058 let Subjects = SubjectList<[Function]>;
2060 let TemplateDependent = 1;
2061 let ParseArgumentsAsUnevaluated = 1;
2062 let DuplicatesAllowedWhileMerging = 1;
2063 let Args = [VariadicExprArgument<"Args">];
2064 let Accessors = [Accessor<"isShared",
2065 [GNU<"acquire_shared_capability">,
2066 CXX11<"clang", "acquire_shared_capability">,
2067 GNU<"shared_lock_function">]>];
2068 let Documentation = [AcquireCapabilityDocs];
2071 def TryAcquireCapability : InheritableAttr {
2072 let Spellings = [GNU<"try_acquire_capability">,
2073 CXX11<"clang", "try_acquire_capability">,
2074 GNU<"try_acquire_shared_capability">,
2075 CXX11<"clang", "try_acquire_shared_capability">];
2076 let Subjects = SubjectList<[Function],
2079 let TemplateDependent = 1;
2080 let ParseArgumentsAsUnevaluated = 1;
2081 let DuplicatesAllowedWhileMerging = 1;
2082 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2083 let Accessors = [Accessor<"isShared",
2084 [GNU<"try_acquire_shared_capability">,
2085 CXX11<"clang", "try_acquire_shared_capability">]>];
2086 let Documentation = [TryAcquireCapabilityDocs];
2089 def ReleaseCapability : InheritableAttr {
2090 let Spellings = [GNU<"release_capability">,
2091 CXX11<"clang", "release_capability">,
2092 GNU<"release_shared_capability">,
2093 CXX11<"clang", "release_shared_capability">,
2094 GNU<"release_generic_capability">,
2095 CXX11<"clang", "release_generic_capability">,
2096 GNU<"unlock_function">];
2097 let Subjects = SubjectList<[Function]>;
2099 let TemplateDependent = 1;
2100 let ParseArgumentsAsUnevaluated = 1;
2101 let DuplicatesAllowedWhileMerging = 1;
2102 let Args = [VariadicExprArgument<"Args">];
2103 let Accessors = [Accessor<"isShared",
2104 [GNU<"release_shared_capability">,
2105 CXX11<"clang", "release_shared_capability">]>,
2106 Accessor<"isGeneric",
2107 [GNU<"release_generic_capability">,
2108 CXX11<"clang", "release_generic_capability">,
2109 GNU<"unlock_function">]>];
2110 let Documentation = [ReleaseCapabilityDocs];
2113 def RequiresCapability : InheritableAttr {
2114 let Spellings = [GNU<"requires_capability">,
2115 CXX11<"clang", "requires_capability">,
2116 GNU<"exclusive_locks_required">,
2117 GNU<"requires_shared_capability">,
2118 CXX11<"clang", "requires_shared_capability">,
2119 GNU<"shared_locks_required">];
2120 let Args = [VariadicExprArgument<"Args">];
2122 let TemplateDependent = 1;
2123 let ParseArgumentsAsUnevaluated = 1;
2124 let DuplicatesAllowedWhileMerging = 1;
2125 let Subjects = SubjectList<[Function]>;
2126 let Accessors = [Accessor<"isShared", [GNU<"requires_shared_capability">,
2127 GNU<"shared_locks_required">,
2128 CXX11<"clang","requires_shared_capability">]>];
2129 let Documentation = [Undocumented];
2132 def NoThreadSafetyAnalysis : InheritableAttr {
2133 let Spellings = [GNU<"no_thread_safety_analysis">];
2134 let Subjects = SubjectList<[Function]>;
2135 let Documentation = [Undocumented];
2138 def GuardedBy : InheritableAttr {
2139 let Spellings = [GNU<"guarded_by">];
2140 let Args = [ExprArgument<"Arg">];
2142 let TemplateDependent = 1;
2143 let ParseArgumentsAsUnevaluated = 1;
2144 let DuplicatesAllowedWhileMerging = 1;
2145 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2146 "ExpectedFieldOrGlobalVar">;
2147 let Documentation = [Undocumented];
2150 def PtGuardedBy : InheritableAttr {
2151 let Spellings = [GNU<"pt_guarded_by">];
2152 let Args = [ExprArgument<"Arg">];
2154 let TemplateDependent = 1;
2155 let ParseArgumentsAsUnevaluated = 1;
2156 let DuplicatesAllowedWhileMerging = 1;
2157 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2158 "ExpectedFieldOrGlobalVar">;
2159 let Documentation = [Undocumented];
2162 def AcquiredAfter : InheritableAttr {
2163 let Spellings = [GNU<"acquired_after">];
2164 let Args = [VariadicExprArgument<"Args">];
2166 let TemplateDependent = 1;
2167 let ParseArgumentsAsUnevaluated = 1;
2168 let DuplicatesAllowedWhileMerging = 1;
2169 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2170 "ExpectedFieldOrGlobalVar">;
2171 let Documentation = [Undocumented];
2174 def AcquiredBefore : InheritableAttr {
2175 let Spellings = [GNU<"acquired_before">];
2176 let Args = [VariadicExprArgument<"Args">];
2178 let TemplateDependent = 1;
2179 let ParseArgumentsAsUnevaluated = 1;
2180 let DuplicatesAllowedWhileMerging = 1;
2181 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2182 "ExpectedFieldOrGlobalVar">;
2183 let Documentation = [Undocumented];
2186 def AssertExclusiveLock : InheritableAttr {
2187 let Spellings = [GNU<"assert_exclusive_lock">];
2188 let Args = [VariadicExprArgument<"Args">];
2190 let TemplateDependent = 1;
2191 let ParseArgumentsAsUnevaluated = 1;
2192 let DuplicatesAllowedWhileMerging = 1;
2193 let Subjects = SubjectList<[Function]>;
2194 let Documentation = [Undocumented];
2197 def AssertSharedLock : InheritableAttr {
2198 let Spellings = [GNU<"assert_shared_lock">];
2199 let Args = [VariadicExprArgument<"Args">];
2201 let TemplateDependent = 1;
2202 let ParseArgumentsAsUnevaluated = 1;
2203 let DuplicatesAllowedWhileMerging = 1;
2204 let Subjects = SubjectList<[Function]>;
2205 let Documentation = [Undocumented];
2208 // The first argument is an integer or boolean value specifying the return value
2209 // of a successful lock acquisition.
2210 def ExclusiveTrylockFunction : InheritableAttr {
2211 let Spellings = [GNU<"exclusive_trylock_function">];
2212 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2214 let TemplateDependent = 1;
2215 let ParseArgumentsAsUnevaluated = 1;
2216 let DuplicatesAllowedWhileMerging = 1;
2217 let Subjects = SubjectList<[Function]>;
2218 let Documentation = [Undocumented];
2221 // The first argument is an integer or boolean value specifying the return value
2222 // of a successful lock acquisition.
2223 def SharedTrylockFunction : InheritableAttr {
2224 let Spellings = [GNU<"shared_trylock_function">];
2225 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2227 let TemplateDependent = 1;
2228 let ParseArgumentsAsUnevaluated = 1;
2229 let DuplicatesAllowedWhileMerging = 1;
2230 let Subjects = SubjectList<[Function]>;
2231 let Documentation = [Undocumented];
2234 def LockReturned : InheritableAttr {
2235 let Spellings = [GNU<"lock_returned">];
2236 let Args = [ExprArgument<"Arg">];
2238 let TemplateDependent = 1;
2239 let ParseArgumentsAsUnevaluated = 1;
2240 let Subjects = SubjectList<[Function]>;
2241 let Documentation = [Undocumented];
2244 def LocksExcluded : InheritableAttr {
2245 let Spellings = [GNU<"locks_excluded">];
2246 let Args = [VariadicExprArgument<"Args">];
2248 let TemplateDependent = 1;
2249 let ParseArgumentsAsUnevaluated = 1;
2250 let DuplicatesAllowedWhileMerging = 1;
2251 let Subjects = SubjectList<[Function]>;
2252 let Documentation = [Undocumented];
2255 // C/C++ consumed attributes.
2257 def Consumable : InheritableAttr {
2258 let Spellings = [GNU<"consumable">];
2259 let Subjects = SubjectList<[CXXRecord]>;
2260 let Args = [EnumArgument<"DefaultState", "ConsumedState",
2261 ["unknown", "consumed", "unconsumed"],
2262 ["Unknown", "Consumed", "Unconsumed"]>];
2263 let Documentation = [ConsumableDocs];
2266 def ConsumableAutoCast : InheritableAttr {
2267 let Spellings = [GNU<"consumable_auto_cast_state">];
2268 let Subjects = SubjectList<[CXXRecord]>;
2269 let Documentation = [Undocumented];
2272 def ConsumableSetOnRead : InheritableAttr {
2273 let Spellings = [GNU<"consumable_set_state_on_read">];
2274 let Subjects = SubjectList<[CXXRecord]>;
2275 let Documentation = [Undocumented];
2278 def CallableWhen : InheritableAttr {
2279 let Spellings = [GNU<"callable_when">];
2280 let Subjects = SubjectList<[CXXMethod]>;
2281 let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
2282 ["unknown", "consumed", "unconsumed"],
2283 ["Unknown", "Consumed", "Unconsumed"]>];
2284 let Documentation = [CallableWhenDocs];
2287 def ParamTypestate : InheritableAttr {
2288 let Spellings = [GNU<"param_typestate">];
2289 let Subjects = SubjectList<[ParmVar]>;
2290 let Args = [EnumArgument<"ParamState", "ConsumedState",
2291 ["unknown", "consumed", "unconsumed"],
2292 ["Unknown", "Consumed", "Unconsumed"]>];
2293 let Documentation = [ParamTypestateDocs];
2296 def ReturnTypestate : InheritableAttr {
2297 let Spellings = [GNU<"return_typestate">];
2298 let Subjects = SubjectList<[Function, ParmVar]>;
2299 let Args = [EnumArgument<"State", "ConsumedState",
2300 ["unknown", "consumed", "unconsumed"],
2301 ["Unknown", "Consumed", "Unconsumed"]>];
2302 let Documentation = [ReturnTypestateDocs];
2305 def SetTypestate : InheritableAttr {
2306 let Spellings = [GNU<"set_typestate">];
2307 let Subjects = SubjectList<[CXXMethod]>;
2308 let Args = [EnumArgument<"NewState", "ConsumedState",
2309 ["unknown", "consumed", "unconsumed"],
2310 ["Unknown", "Consumed", "Unconsumed"]>];
2311 let Documentation = [SetTypestateDocs];
2314 def TestTypestate : InheritableAttr {
2315 let Spellings = [GNU<"test_typestate">];
2316 let Subjects = SubjectList<[CXXMethod]>;
2317 let Args = [EnumArgument<"TestState", "ConsumedState",
2318 ["consumed", "unconsumed"],
2319 ["Consumed", "Unconsumed"]>];
2320 let Documentation = [TestTypestateDocs];
2323 // Type safety attributes for `void *' pointers and type tags.
2325 def ArgumentWithTypeTag : InheritableAttr {
2326 let Spellings = [GNU<"argument_with_type_tag">,
2327 GNU<"pointer_with_type_tag">];
2328 let Args = [IdentifierArgument<"ArgumentKind">,
2329 UnsignedArgument<"ArgumentIdx">,
2330 UnsignedArgument<"TypeTagIdx">,
2331 BoolArgument<"IsPointer">];
2332 let HasCustomParsing = 1;
2333 let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
2336 def TypeTagForDatatype : InheritableAttr {
2337 let Spellings = [GNU<"type_tag_for_datatype">];
2338 let Args = [IdentifierArgument<"ArgumentKind">,
2339 TypeArgument<"MatchingCType">,
2340 BoolArgument<"LayoutCompatible">,
2341 BoolArgument<"MustBeNull">];
2342 // let Subjects = SubjectList<[Var], ErrorDiag>;
2343 let HasCustomParsing = 1;
2344 let Documentation = [TypeTagForDatatypeDocs];
2347 // Microsoft-related attributes
2349 def MSNoVTable : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
2350 let Spellings = [Declspec<"novtable">];
2351 let Subjects = SubjectList<[CXXRecord]>;
2352 let Documentation = [MSNoVTableDocs];
2356 let Spellings = [Declspec<"property">];
2359 def MSStruct : InheritableAttr {
2360 let Spellings = [GCC<"ms_struct">];
2361 let Subjects = SubjectList<[Record]>;
2362 let Documentation = [Undocumented];
2365 def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2366 let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
2367 let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2368 let Documentation = [DLLExportDocs];
2371 def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2372 let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
2373 let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2374 let Documentation = [DLLImportDocs];
2377 def SelectAny : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2378 let Spellings = [Declspec<"selectany">, GCC<"selectany">];
2379 let Documentation = [Undocumented];
2383 let Spellings = [Declspec<"thread">];
2384 let LangOpts = [MicrosoftExt];
2385 let Documentation = [ThreadDocs];
2386 let Subjects = SubjectList<[Var]>;
2389 def Win64 : IgnoredAttr {
2390 let Spellings = [Keyword<"__w64">];
2391 let LangOpts = [MicrosoftExt];
2394 def Ptr32 : TypeAttr {
2395 let Spellings = [Keyword<"__ptr32">];
2396 let Documentation = [Undocumented];
2399 def Ptr64 : TypeAttr {
2400 let Spellings = [Keyword<"__ptr64">];
2401 let Documentation = [Undocumented];
2404 def SPtr : TypeAttr {
2405 let Spellings = [Keyword<"__sptr">];
2406 let Documentation = [Undocumented];
2409 def UPtr : TypeAttr {
2410 let Spellings = [Keyword<"__uptr">];
2411 let Documentation = [Undocumented];
2414 def MSInheritance : InheritableAttr {
2415 let LangOpts = [MicrosoftExt];
2416 let Args = [DefaultBoolArgument<"BestCase", 1>];
2417 let Spellings = [Keyword<"__single_inheritance">,
2418 Keyword<"__multiple_inheritance">,
2419 Keyword<"__virtual_inheritance">,
2420 Keyword<"__unspecified_inheritance">];
2421 let AdditionalMembers = [{
2422 static bool hasVBPtrOffsetField(Spelling Inheritance) {
2423 return Inheritance == Keyword_unspecified_inheritance;
2426 // Only member pointers to functions need a this adjustment, since it can be
2427 // combined with the field offset for data pointers.
2428 static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
2429 return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
2432 static bool hasVBTableOffsetField(Spelling Inheritance) {
2433 return Inheritance >= Keyword_virtual_inheritance;
2436 static bool hasOnlyOneField(bool IsMemberFunction,
2437 Spelling Inheritance) {
2438 if (IsMemberFunction)
2439 return Inheritance <= Keyword_single_inheritance;
2440 return Inheritance <= Keyword_multiple_inheritance;
2443 let Documentation = [MSInheritanceDocs];
2446 def MSVtorDisp : InheritableAttr {
2447 // This attribute has no spellings as it is only ever created implicitly.
2449 let Args = [UnsignedArgument<"vdm">];
2450 let SemaHandler = 0;
2452 let AdditionalMembers = [{
2459 Mode getVtorDispMode() const { return Mode(vdm); }
2461 let Documentation = [Undocumented];
2464 def InitSeg : Attr {
2465 let Spellings = [Pragma<"", "init_seg">];
2466 let Args = [StringArgument<"Section">];
2467 let SemaHandler = 0;
2468 let Documentation = [InitSegDocs];
2469 let AdditionalMembers = [{
2470 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2471 OS << '(' << getSection() << ')';
2476 def LoopHint : Attr {
2477 /// #pragma clang loop <option> directive
2478 /// vectorize: vectorizes loop operations if State == Enable.
2479 /// vectorize_width: vectorize loop operations with width 'Value'.
2480 /// interleave: interleave multiple loop iterations if State == Enable.
2481 /// interleave_count: interleaves 'Value' loop interations.
2482 /// unroll: fully unroll loop if State == Enable.
2483 /// unroll_count: unrolls loop 'Value' times.
2484 /// distribute: attempt to distribute loop if State == Enable
2486 /// #pragma unroll <argument> directive
2487 /// <no arg>: fully unrolls loop.
2488 /// boolean: fully unrolls loop if State == Enable.
2489 /// expression: unrolls loop 'Value' times.
2491 let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">,
2492 Pragma<"", "nounroll">];
2494 /// State of the loop optimization specified by the spelling.
2495 let Args = [EnumArgument<"Option", "OptionType",
2496 ["vectorize", "vectorize_width", "interleave", "interleave_count",
2497 "unroll", "unroll_count", "distribute"],
2498 ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
2499 "Unroll", "UnrollCount", "Distribute"]>,
2500 EnumArgument<"State", "LoopHintState",
2501 ["enable", "disable", "numeric", "assume_safety", "full"],
2502 ["Enable", "Disable", "Numeric", "AssumeSafety", "Full"]>,
2503 ExprArgument<"Value">];
2505 let AdditionalMembers = [{
2506 static const char *getOptionName(int Option) {
2508 case Vectorize: return "vectorize";
2509 case VectorizeWidth: return "vectorize_width";
2510 case Interleave: return "interleave";
2511 case InterleaveCount: return "interleave_count";
2512 case Unroll: return "unroll";
2513 case UnrollCount: return "unroll_count";
2514 case Distribute: return "distribute";
2516 llvm_unreachable("Unhandled LoopHint option.");
2519 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2520 unsigned SpellingIndex = getSpellingListIndex();
2521 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
2522 // "nounroll" is already emitted as the pragma name.
2523 if (SpellingIndex == Pragma_nounroll)
2525 else if (SpellingIndex == Pragma_unroll) {
2526 OS << getValueString(Policy);
2530 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2531 OS << getOptionName(option) << getValueString(Policy);
2534 // Return a string containing the loop hint argument including the
2535 // enclosing parentheses.
2536 std::string getValueString(const PrintingPolicy &Policy) const {
2537 std::string ValueName;
2538 llvm::raw_string_ostream OS(ValueName);
2540 if (state == Numeric)
2541 value->printPretty(OS, nullptr, Policy);
2542 else if (state == Enable)
2544 else if (state == Full)
2546 else if (state == AssumeSafety)
2547 OS << "assume_safety";
2554 // Return a string suitable for identifying this attribute in diagnostics.
2555 std::string getDiagnosticName(const PrintingPolicy &Policy) const {
2556 unsigned SpellingIndex = getSpellingListIndex();
2557 if (SpellingIndex == Pragma_nounroll)
2558 return "#pragma nounroll";
2559 else if (SpellingIndex == Pragma_unroll)
2560 return "#pragma unroll" + (option == UnrollCount ? getValueString(Policy) : "");
2562 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2563 return getOptionName(option) + getValueString(Policy);
2567 let Documentation = [LoopHintDocs, UnrollHintDocs];
2570 def CapturedRecord : InheritableAttr {
2571 // This attribute has no spellings as it is only ever created implicitly.
2573 let SemaHandler = 0;
2574 let Documentation = [Undocumented];
2577 def OMPThreadPrivateDecl : InheritableAttr {
2578 // This attribute has no spellings as it is only ever created implicitly.
2580 let SemaHandler = 0;
2581 let Documentation = [Undocumented];
2584 def OMPCaptureNoInit : InheritableAttr {
2585 // This attribute has no spellings as it is only ever created implicitly.
2587 let SemaHandler = 0;
2588 let Documentation = [Undocumented];
2591 def OMPDeclareSimdDecl : Attr {
2592 let Spellings = [Pragma<"omp", "declare simd">];
2593 let Subjects = SubjectList<[Function]>;
2594 let SemaHandler = 0;
2595 let HasCustomParsing = 1;
2596 let Documentation = [OMPDeclareSimdDocs];
2598 EnumArgument<"BranchState", "BranchStateTy",
2599 [ "", "inbranch", "notinbranch" ],
2600 [ "BS_Undefined", "BS_Inbranch", "BS_Notinbranch" ]>,
2601 ExprArgument<"Simdlen">, VariadicExprArgument<"Uniforms">,
2602 VariadicExprArgument<"Aligneds">, VariadicExprArgument<"Alignments">,
2603 VariadicExprArgument<"Linears">, VariadicUnsignedArgument<"Modifiers">,
2604 VariadicExprArgument<"Steps">
2606 let AdditionalMembers = [{
2607 void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
2609 if (getBranchState() != BS_Undefined)
2610 OS << ConvertBranchStateTyToStr(getBranchState()) << " ";
2611 if (auto *E = getSimdlen()) {
2613 E->printPretty(OS, nullptr, Policy);
2616 if (uniforms_size() > 0) {
2618 StringRef Sep = "(";
2619 for (auto *E : uniforms()) {
2621 E->printPretty(OS, nullptr, Policy);
2626 alignments_iterator NI = alignments_begin();
2627 for (auto *E : aligneds()) {
2629 E->printPretty(OS, nullptr, Policy);
2632 (*NI)->printPretty(OS, nullptr, Policy);
2637 steps_iterator I = steps_begin();
2638 modifiers_iterator MI = modifiers_begin();
2639 for (auto *E : linears()) {
2641 if (*MI != OMPC_LINEAR_unknown)
2642 OS << getOpenMPSimpleClauseTypeName(OMPC_linear, *MI) << "(";
2643 E->printPretty(OS, nullptr, Policy);
2644 if (*MI != OMPC_LINEAR_unknown)
2648 (*I)->printPretty(OS, nullptr, Policy);
2658 def OMPDeclareTargetDecl : Attr {
2659 let Spellings = [Pragma<"omp", "declare target">];
2660 let SemaHandler = 0;
2661 let Documentation = [OMPDeclareTargetDocs];
2663 EnumArgument<"MapType", "MapTypeTy",
2665 [ "MT_To", "MT_Link" ]>
2667 let AdditionalMembers = [{
2668 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2669 // Use fake syntax because it is for testing and debugging purpose only.
2670 if (getMapType() != MT_To)
2671 OS << ConvertMapTypeTyToStr(getMapType()) << " ";
2676 def InternalLinkage : InheritableAttr {
2677 let Spellings = [GNU<"internal_linkage">, CXX11<"clang", "internal_linkage">];
2678 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
2679 let Documentation = [InternalLinkageDocs];