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 NamedArgument<string name, bit opt = 0, bit fake = 0> : Argument<name,
155 class TypeArgument<string name, bit opt = 0> : Argument<name, opt>;
156 class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>;
157 class VariadicUnsignedArgument<string name> : Argument<name, 1>;
158 class VariadicExprArgument<string name> : Argument<name, 1>;
159 class VariadicStringArgument<string name> : Argument<name, 1>;
161 // A version of the form major.minor[.subminor].
162 class VersionArgument<string name, bit opt = 0> : Argument<name, opt>;
164 // This one's a doozy, so it gets its own special type
165 // It can be an unsigned integer, or a type. Either can
167 class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>;
169 // A bool argument with a default value
170 class DefaultBoolArgument<string name, bit default> : BoolArgument<name, 1> {
171 bit Default = default;
174 // An integer argument with a default value
175 class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
176 int Default = default;
179 // This argument is more complex, it includes the enumerator type name,
180 // a list of strings to accept, and a list of enumerators to map them to.
181 class EnumArgument<string name, string type, list<string> values,
182 list<string> enums, bit opt = 0, bit fake = 0>
183 : Argument<name, opt, fake> {
185 list<string> Values = values;
186 list<string> Enums = enums;
189 // FIXME: There should be a VariadicArgument type that takes any other type
190 // of argument and generates the appropriate type.
191 class VariadicEnumArgument<string name, string type, list<string> values,
192 list<string> enums> : Argument<name, 1> {
194 list<string> Values = values;
195 list<string> Enums = enums;
198 // This handles one spelling of an attribute.
199 class Spelling<string name, string variety> {
201 string Variety = variety;
205 class GNU<string name> : Spelling<name, "GNU">;
206 class Declspec<string name> : Spelling<name, "Declspec">;
207 class Microsoft<string name> : Spelling<name, "Microsoft">;
208 class CXX11<string namespace, string name, int version = 1>
209 : Spelling<name, "CXX11"> {
210 string Namespace = namespace;
211 int Version = version;
213 class Keyword<string name> : Spelling<name, "Keyword">;
214 class Pragma<string namespace, string name> : Spelling<name, "Pragma"> {
215 string Namespace = namespace;
218 // The GCC spelling implies GNU<name, "GNU"> and CXX11<"gnu", name> and also
219 // sets KnownToGCC to 1. This spelling should be used for any GCC-compatible
221 class GCC<string name> : Spelling<name, "GCC"> {
225 class Accessor<string name, list<Spelling> spellings> {
227 list<Spelling> Spellings = spellings;
230 class SubjectDiag<bit warn> {
233 def WarnDiag : SubjectDiag<1>;
234 def ErrorDiag : SubjectDiag<0>;
236 class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag,
237 string customDiag = ""> {
238 list<AttrSubject> Subjects = subjects;
239 SubjectDiag Diag = diag;
240 string CustomDiag = customDiag;
243 class LangOpt<string name, bit negated = 0> {
245 bit Negated = negated;
247 def MicrosoftExt : LangOpt<"MicrosoftExt">;
248 def Borland : LangOpt<"Borland">;
249 def CUDA : LangOpt<"CUDA">;
250 def COnly : LangOpt<"CPlusPlus", 1>;
251 def CPlusPlus : LangOpt<"CPlusPlus">;
252 def OpenCL : LangOpt<"OpenCL">;
253 def RenderScript : LangOpt<"RenderScript">;
254 def ObjC : LangOpt<"ObjC1">;
255 def BlocksSupported : LangOpt<"Blocks">;
257 // Defines targets for target-specific attributes. The list of strings should
258 // specify architectures for which the target applies, based off the ArchType
259 // enumeration in Triple.h.
260 class TargetArch<list<string> arches> {
261 list<string> Arches = arches;
263 list<string> CXXABIs;
265 def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
266 def TargetAVR : TargetArch<["avr"]>;
267 def TargetMips : TargetArch<["mips", "mipsel"]>;
268 def TargetMSP430 : TargetArch<["msp430"]>;
269 def TargetX86 : TargetArch<["x86"]>;
270 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
271 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
272 let OSes = ["Win32"];
274 def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
275 let CXXABIs = ["Microsoft"];
278 // Attribute subject match rules that are used for #pragma clang attribute.
280 // A instance of AttrSubjectMatcherRule represents an individual match rule.
281 // An individual match rule can correspond to a number of different attribute
282 // subjects, e.g. "record" matching rule corresponds to the Record and
283 // CXXRecord attribute subjects.
285 // Match rules are used in the subject list of the #pragma clang attribute.
286 // Match rules can have sub-match rules that are instances of
287 // AttrSubjectMatcherSubRule. A sub-match rule can correspond to a number
288 // of different attribute subjects, and it can have a negated spelling as well.
289 // For example, "variable(unless(is_parameter))" matching rule corresponds to
290 // the NonParmVar attribute subject.
291 class AttrSubjectMatcherSubRule<string name, list<AttrSubject> subjects,
294 list<AttrSubject> Subjects = subjects;
295 bit Negated = negated;
296 // Lists language options, one of which is required to be true for the
297 // attribute to be applicable. If empty, the language options are taken
298 // from the parent matcher rule.
299 list<LangOpt> LangOpts = [];
301 class AttrSubjectMatcherRule<string name, list<AttrSubject> subjects,
302 list<AttrSubjectMatcherSubRule> subrules = []> {
304 list<AttrSubject> Subjects = subjects;
305 list<AttrSubjectMatcherSubRule> Constraints = subrules;
306 // Lists language options, one of which is required to be true for the
307 // attribute to be applicable. If empty, no language options are required.
308 list<LangOpt> LangOpts = [];
311 // function(is_member)
312 def SubRuleForCXXMethod : AttrSubjectMatcherSubRule<"is_member", [CXXMethod]> {
313 let LangOpts = [CPlusPlus];
315 def SubjectMatcherForFunction : AttrSubjectMatcherRule<"function", [Function], [
318 // hasType is abstract, it should be used with one of the sub-rules.
319 def SubjectMatcherForType : AttrSubjectMatcherRule<"hasType", [], [
320 AttrSubjectMatcherSubRule<"functionType", [FunctionLike]>
322 // FIXME: There's a matcher ambiguity with objc methods and blocks since
323 // functionType excludes them but functionProtoType includes them.
324 // AttrSubjectMatcherSubRule<"functionProtoType", [HasFunctionProto]>
326 def SubjectMatcherForTypedef : AttrSubjectMatcherRule<"type_alias",
328 def SubjectMatcherForRecord : AttrSubjectMatcherRule<"record", [Record,
331 AttrSubjectMatcherSubRule<"is_union", [Struct], 1>
333 def SubjectMatcherForEnum : AttrSubjectMatcherRule<"enum", [Enum]>;
334 def SubjectMatcherForEnumConstant : AttrSubjectMatcherRule<"enum_constant",
336 def SubjectMatcherForVar : AttrSubjectMatcherRule<"variable", [Var], [
337 AttrSubjectMatcherSubRule<"is_thread_local", [TLSVar]>,
338 AttrSubjectMatcherSubRule<"is_global", [GlobalVar]>,
339 AttrSubjectMatcherSubRule<"is_parameter", [ParmVar]>,
340 // unless(is_parameter)
341 AttrSubjectMatcherSubRule<"is_parameter", [NonParmVar], 1>
343 def SubjectMatcherForField : AttrSubjectMatcherRule<"field", [Field]>;
344 def SubjectMatcherForNamespace : AttrSubjectMatcherRule<"namespace",
346 let LangOpts = [CPlusPlus];
348 def SubjectMatcherForObjCInterface : AttrSubjectMatcherRule<"objc_interface",
350 let LangOpts = [ObjC];
352 def SubjectMatcherForObjCProtocol : AttrSubjectMatcherRule<"objc_protocol",
354 let LangOpts = [ObjC];
356 def SubjectMatcherForObjCCategory : AttrSubjectMatcherRule<"objc_category",
358 let LangOpts = [ObjC];
360 def SubjectMatcherForObjCMethod : AttrSubjectMatcherRule<"objc_method",
362 AttrSubjectMatcherSubRule<"is_instance", [ObjCInstanceMethod]>
364 let LangOpts = [ObjC];
366 def SubjectMatcherForObjCProperty : AttrSubjectMatcherRule<"objc_property",
368 let LangOpts = [ObjC];
370 def SubjectMatcherForBlock : AttrSubjectMatcherRule<"block", [Block]> {
371 let LangOpts = [BlocksSupported];
374 // Aggregate attribute subject match rules are abstract match rules that can't
375 // be used directly in #pragma clang attribute. Instead, users have to use
376 // subject match rules that correspond to attribute subjects that derive from
377 // the specified subject.
378 class AttrSubjectMatcherAggregateRule<AttrSubject subject> {
379 AttrSubject Subject = subject;
382 def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule<Named>;
385 // The various ways in which an attribute can be spelled in source
386 list<Spelling> Spellings;
387 // The things to which an attribute can appertain
388 SubjectList Subjects;
389 // The arguments allowed on an attribute
390 list<Argument> Args = [];
391 // Accessors which should be generated for the attribute.
392 list<Accessor> Accessors = [];
393 // Set to true for attributes with arguments which require delayed parsing.
395 // Set to false to prevent an attribute from being propagated from a template
396 // to the instantiation.
398 // Set to true for attributes which must be instantiated within templates
399 bit TemplateDependent = 0;
400 // Set to true for attributes that have a corresponding AST node.
402 // Set to true for attributes which have handler in Sema.
404 // Set to true for attributes that are completely ignored.
406 // Set to true if the attribute's parsing does not match its semantic
407 // content. Eg) It parses 3 args, but semantically takes 4 args. Opts out of
408 // common attribute error checking.
409 bit HasCustomParsing = 0;
410 // Set to true if all of the attribute's arguments should be parsed in an
411 // unevaluated context.
412 bit ParseArgumentsAsUnevaluated = 0;
413 // Set to true if this attribute can be duplicated on a subject when merging
414 // attributes. By default, attributes are not merged.
415 bit DuplicatesAllowedWhileMerging = 0;
416 // Set to true if this attribute meaningful when applied to or inherited
417 // in a class template definition.
418 bit MeaningfulToClassTemplateDefinition = 0;
419 // Set to true if this attribute can be used with '#pragma clang attribute'.
420 // By default, when this value is false, an attribute is supported by the
421 // '#pragma clang attribute' only when:
422 // - It has documentation.
423 // - It has a subject list whose subjects can be represented using subject
425 // - It has GNU/CXX11 spelling and doesn't require delayed parsing.
426 bit ForcePragmaAttributeSupport = 0;
427 // Lists language options, one of which is required to be true for the
428 // attribute to be applicable. If empty, no language options are required.
429 list<LangOpt> LangOpts = [];
430 // Any additional text that should be included verbatim in the class.
431 // Note: Any additional data members will leak and should be constructed
432 // externally on the ASTContext.
433 code AdditionalMembers = [{}];
434 // Any documentation that should be associated with the attribute. Since an
435 // attribute may be documented under multiple categories, more than one
436 // Documentation entry may be listed.
437 list<Documentation> Documentation;
440 /// A type attribute is not processed on a declaration or a statement.
441 class TypeAttr : Attr {
442 // By default, type attributes do not get an AST node.
446 /// A stmt attribute is not processed on a declaration or a type.
447 class StmtAttr : Attr;
449 /// An inheritable attribute is inherited by later redeclarations.
450 class InheritableAttr : Attr;
452 /// A target-specific attribute. This class is meant to be used as a mixin
453 /// with InheritableAttr or Attr depending on the attribute's needs.
454 class TargetSpecificAttr<TargetArch target> {
455 TargetArch Target = target;
456 // Attributes are generally required to have unique spellings for their names
457 // so that the parser can determine what kind of attribute it has parsed.
458 // However, target-specific attributes are special in that the attribute only
459 // "exists" for a given target. So two target-specific attributes can share
460 // the same name when they exist in different targets. To support this, a
461 // Kind can be explicitly specified for a target-specific attribute. This
462 // corresponds to the AttributeList::AT_* enum that is generated and it
463 // should contain a shared value between the attributes.
465 // Target-specific attributes which use this feature should ensure that the
466 // spellings match exactly between the attributes, and if the arguments or
467 // subjects differ, should specify HasCustomParsing = 1 and implement their
468 // own parsing and semantic handling requirements as-needed.
472 /// An inheritable parameter attribute is inherited by later
473 /// redeclarations, even when it's written on a parameter.
474 class InheritableParamAttr : InheritableAttr;
476 /// An attribute which changes the ABI rules for a specific parameter.
477 class ParameterABIAttr : InheritableParamAttr {
478 let Subjects = SubjectList<[ParmVar]>;
481 /// An ignored attribute, which we parse but discard with no checking.
482 class IgnoredAttr : Attr {
486 let Documentation = [Undocumented];
490 // Attributes begin here
494 let Spellings = [GCC<"abi_tag">];
495 let Args = [VariadicStringArgument<"Tags">];
496 let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag,
497 "ExpectedStructClassVariableFunctionOrInlineNamespace">;
498 let MeaningfulToClassTemplateDefinition = 1;
499 let Documentation = [AbiTagsDocs];
502 def AddressSpace : TypeAttr {
503 let Spellings = [GNU<"address_space">];
504 let Args = [IntArgument<"AddressSpace">];
505 let Documentation = [Undocumented];
509 let Spellings = [GCC<"alias">];
510 let Args = [StringArgument<"Aliasee">];
511 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
512 "ExpectedFunctionOrGlobalVar">;
513 let Documentation = [Undocumented];
516 def Aligned : InheritableAttr {
517 let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">,
518 Keyword<"_Alignas">];
519 // let Subjects = SubjectList<[NonBitField, NormalVar, Tag]>;
520 let Args = [AlignedArgument<"Alignment", 1>];
521 let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
522 Accessor<"isC11", [Keyword<"_Alignas">]>,
523 Accessor<"isAlignas", [Keyword<"alignas">,
524 Keyword<"_Alignas">]>,
525 Accessor<"isDeclspec",[Declspec<"align">]>];
526 let Documentation = [Undocumented];
529 def AlignValue : Attr {
531 // Unfortunately, this is semantically an assertion, not a directive
532 // (something else must ensure the alignment), so aligned_value is a
533 // probably a better name. We might want to add an aligned_value spelling in
534 // the future (and a corresponding C++ attribute), but this can be done
535 // later once we decide if we also want them to have slightly-different
536 // semantics than Intel's align_value.
538 // Intel's compiler on Windows also supports:
539 // , Declspec<"align_value">
541 let Args = [ExprArgument<"Alignment">];
542 let Subjects = SubjectList<[Var, TypedefName], WarnDiag,
543 "ExpectedVariableOrTypedef">;
544 let Documentation = [AlignValueDocs];
547 def AlignMac68k : InheritableAttr {
548 // This attribute has no spellings as it is only ever created implicitly.
551 let Documentation = [Undocumented];
554 def AlwaysInline : InheritableAttr {
555 let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
556 let Subjects = SubjectList<[Function]>;
557 let Documentation = [Undocumented];
560 def XRayInstrument : InheritableAttr {
561 let Spellings = [GNU<"xray_always_instrument">,
562 CXX11<"clang", "xray_always_instrument">,
563 GNU<"xray_never_instrument">,
564 CXX11<"clang", "xray_never_instrument">];
565 let Subjects = SubjectList<[CXXMethod, ObjCMethod, Function], WarnDiag,
566 "ExpectedFunctionOrMethod">;
567 let Accessors = [Accessor<"alwaysXRayInstrument",
568 [GNU<"xray_always_instrument">,
569 CXX11<"clang", "xray_always_instrument">]>,
570 Accessor<"neverXRayInstrument",
571 [GNU<"xray_never_instrument">,
572 CXX11<"clang", "xray_never_instrument">]>];
573 let Documentation = [XRayDocs];
576 def XRayLogArgs : InheritableAttr {
577 let Spellings = [GNU<"xray_log_args">, CXX11<"clang", "xray_log_args">];
578 let Subjects = SubjectList<
579 [CXXMethod, ObjCMethod, Function], WarnDiag, "ExpectedFunctionOrMethod"
581 let Args = [UnsignedArgument<"ArgumentCount">];
582 let Documentation = [XRayDocs];
585 def TLSModel : InheritableAttr {
586 let Spellings = [GCC<"tls_model">];
587 let Subjects = SubjectList<[TLSVar], ErrorDiag, "ExpectedTLSVar">;
588 let Args = [StringArgument<"Model">];
589 let Documentation = [TLSModelDocs];
592 def AnalyzerNoReturn : InheritableAttr {
593 let Spellings = [GNU<"analyzer_noreturn">];
594 let Documentation = [Undocumented];
597 def Annotate : InheritableParamAttr {
598 let Spellings = [GNU<"annotate">];
599 let Args = [StringArgument<"Annotation">];
600 // Ensure that the annotate attribute can be used with
601 // '#pragma clang attribute' even though it has no subject list.
602 let ForcePragmaAttributeSupport = 1;
603 let Documentation = [Undocumented];
606 def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> {
607 // NOTE: If you add any additional spellings, MSP430Interrupt's,
608 // MipsInterrupt's and AnyX86Interrupt's spellings must match.
609 let Spellings = [GNU<"interrupt">];
610 let Args = [EnumArgument<"Interrupt", "InterruptType",
611 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
612 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
614 let ParseKind = "Interrupt";
615 let HasCustomParsing = 1;
616 let Documentation = [ARMInterruptDocs];
619 def AVRInterrupt : InheritableAttr, TargetSpecificAttr<TargetAVR> {
620 let Spellings = [GNU<"interrupt">];
621 let Subjects = SubjectList<[Function]>;
622 let ParseKind = "Interrupt";
623 let Documentation = [AVRInterruptDocs];
626 def AVRSignal : InheritableAttr, TargetSpecificAttr<TargetAVR> {
627 let Spellings = [GNU<"signal">];
628 let Subjects = SubjectList<[Function]>;
629 let Documentation = [AVRSignalDocs];
632 def AsmLabel : InheritableAttr {
633 let Spellings = [Keyword<"asm">, Keyword<"__asm__">];
634 let Args = [StringArgument<"Label">];
636 let Documentation = [Undocumented];
639 def Availability : InheritableAttr {
640 let Spellings = [GNU<"availability">];
641 let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
642 VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
643 BoolArgument<"unavailable">, StringArgument<"message">,
644 BoolArgument<"strict">, StringArgument<"replacement">];
645 let AdditionalMembers =
646 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
647 return llvm::StringSwitch<llvm::StringRef>(Platform)
648 .Case("android", "Android")
650 .Case("macos", "macOS")
651 .Case("tvos", "tvOS")
652 .Case("watchos", "watchOS")
653 .Case("ios_app_extension", "iOS (App Extension)")
654 .Case("macos_app_extension", "macOS (App Extension)")
655 .Case("tvos_app_extension", "tvOS (App Extension)")
656 .Case("watchos_app_extension", "watchOS (App Extension)")
657 .Default(llvm::StringRef());
659 static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) {
660 return llvm::StringSwitch<llvm::StringRef>(Platform)
662 .Case("macos", "macOS")
663 .Case("tvos", "tvOS")
664 .Case("watchos", "watchOS")
665 .Case("ios_app_extension", "iOSApplicationExtension")
666 .Case("macos_app_extension", "macOSApplicationExtension")
667 .Case("tvos_app_extension", "tvOSApplicationExtension")
668 .Case("watchos_app_extension", "watchOSApplicationExtension")
671 static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) {
672 return llvm::StringSwitch<llvm::StringRef>(Platform)
674 .Case("macOS", "macos")
675 .Case("tvOS", "tvos")
676 .Case("watchOS", "watchos")
677 .Case("iOSApplicationExtension", "ios_app_extension")
678 .Case("macOSApplicationExtension", "macos_app_extension")
679 .Case("tvOSApplicationExtension", "tvos_app_extension")
680 .Case("watchOSApplicationExtension", "watchos_app_extension")
683 let HasCustomParsing = 1;
684 let DuplicatesAllowedWhileMerging = 1;
685 let Subjects = SubjectList<[Named]>;
686 let Documentation = [AvailabilityDocs];
689 def ExternalSourceSymbol : InheritableAttr {
690 let Spellings = [GNU<"external_source_symbol">,
691 CXX11<"clang", "external_source_symbol">];
692 let Args = [StringArgument<"language", 1>,
693 StringArgument<"definedIn", 1>,
694 BoolArgument<"generatedDeclaration", 1>];
695 let HasCustomParsing = 1;
696 let Subjects = SubjectList<[Named]>;
697 let Documentation = [ExternalSourceSymbolDocs];
700 def Blocks : InheritableAttr {
701 let Spellings = [GNU<"blocks">];
702 let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
703 let Documentation = [Undocumented];
706 def Bounded : IgnoredAttr {
707 let Spellings = [GNU<"bounded">];
710 def CarriesDependency : InheritableParamAttr {
711 let Spellings = [GNU<"carries_dependency">,
712 CXX11<"","carries_dependency", 200809>];
713 let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>;
714 let Documentation = [CarriesDependencyDocs];
717 def CDecl : InheritableAttr {
718 let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">];
719 // let Subjects = [Function, ObjCMethod];
720 let Documentation = [Undocumented];
723 // cf_audited_transfer indicates that the given function has been
724 // audited and has been marked with the appropriate cf_consumed and
725 // cf_returns_retained attributes. It is generally applied by
726 // '#pragma clang arc_cf_code_audited' rather than explicitly.
727 def CFAuditedTransfer : InheritableAttr {
728 let Spellings = [GNU<"cf_audited_transfer">];
729 let Subjects = SubjectList<[Function], ErrorDiag>;
730 let Documentation = [Undocumented];
733 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
734 // It indicates that the function has unknown or unautomatable
735 // transfer semantics.
736 def CFUnknownTransfer : InheritableAttr {
737 let Spellings = [GNU<"cf_unknown_transfer">];
738 let Subjects = SubjectList<[Function], ErrorDiag>;
739 let Documentation = [Undocumented];
742 def CFReturnsRetained : InheritableAttr {
743 let Spellings = [GNU<"cf_returns_retained">];
744 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
745 let Documentation = [Undocumented];
748 def CFReturnsNotRetained : InheritableAttr {
749 let Spellings = [GNU<"cf_returns_not_retained">];
750 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
751 let Documentation = [Undocumented];
754 def CFConsumed : InheritableParamAttr {
755 let Spellings = [GNU<"cf_consumed">];
756 let Subjects = SubjectList<[ParmVar]>;
757 let Documentation = [Undocumented];
760 def Cleanup : InheritableAttr {
761 let Spellings = [GCC<"cleanup">];
762 let Args = [FunctionArgument<"FunctionDecl">];
763 let Subjects = SubjectList<[Var]>;
764 let Documentation = [Undocumented];
767 def Cold : InheritableAttr {
768 let Spellings = [GCC<"cold">];
769 let Subjects = SubjectList<[Function]>;
770 let Documentation = [Undocumented];
773 def Common : InheritableAttr {
774 let Spellings = [GCC<"common">];
775 let Subjects = SubjectList<[Var]>;
776 let Documentation = [Undocumented];
779 def Const : InheritableAttr {
780 let Spellings = [GCC<"const">, GCC<"__const">];
781 let Documentation = [Undocumented];
784 def Constructor : InheritableAttr {
785 let Spellings = [GCC<"constructor">];
786 let Args = [DefaultIntArgument<"Priority", 65535>];
787 let Subjects = SubjectList<[Function]>;
788 let Documentation = [Undocumented];
791 // CUDA attributes are spelled __attribute__((attr)) or __declspec(__attr__).
793 def CUDAConstant : InheritableAttr {
794 let Spellings = [GNU<"constant">, Declspec<"__constant__">];
795 let Subjects = SubjectList<[Var]>;
796 let LangOpts = [CUDA];
797 let Documentation = [Undocumented];
800 def CUDACudartBuiltin : IgnoredAttr {
801 let Spellings = [GNU<"cudart_builtin">, Declspec<"__cudart_builtin__">];
802 let LangOpts = [CUDA];
805 def CUDADevice : InheritableAttr {
806 let Spellings = [GNU<"device">, Declspec<"__device__">];
807 let Subjects = SubjectList<[Function, Var]>;
808 let LangOpts = [CUDA];
809 let Documentation = [Undocumented];
812 def CUDADeviceBuiltin : IgnoredAttr {
813 let Spellings = [GNU<"device_builtin">, Declspec<"__device_builtin__">];
814 let LangOpts = [CUDA];
817 def CUDADeviceBuiltinSurfaceType : IgnoredAttr {
818 let Spellings = [GNU<"device_builtin_surface_type">,
819 Declspec<"__device_builtin_surface_type__">];
820 let LangOpts = [CUDA];
823 def CUDADeviceBuiltinTextureType : IgnoredAttr {
824 let Spellings = [GNU<"device_builtin_texture_type">,
825 Declspec<"__device_builtin_texture_type__">];
826 let LangOpts = [CUDA];
829 def CUDAGlobal : InheritableAttr {
830 let Spellings = [GNU<"global">, Declspec<"__global__">];
831 let Subjects = SubjectList<[Function]>;
832 let LangOpts = [CUDA];
833 let Documentation = [Undocumented];
836 def CUDAHost : InheritableAttr {
837 let Spellings = [GNU<"host">, Declspec<"__host__">];
838 let Subjects = SubjectList<[Function]>;
839 let LangOpts = [CUDA];
840 let Documentation = [Undocumented];
843 def CUDAInvalidTarget : InheritableAttr {
845 let Subjects = SubjectList<[Function]>;
846 let LangOpts = [CUDA];
847 let Documentation = [Undocumented];
850 def CUDALaunchBounds : InheritableAttr {
851 let Spellings = [GNU<"launch_bounds">, Declspec<"__launch_bounds__">];
852 let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>];
853 let LangOpts = [CUDA];
854 let Subjects = SubjectList<[ObjCMethod, FunctionLike], WarnDiag,
855 "ExpectedFunctionOrMethod">;
856 // An AST node is created for this attribute, but is not used by other parts
857 // of the compiler. However, this node needs to exist in the AST because
858 // non-LLVM backends may be relying on the attribute's presence.
859 let Documentation = [Undocumented];
862 def CUDAShared : InheritableAttr {
863 let Spellings = [GNU<"shared">, Declspec<"__shared__">];
864 let Subjects = SubjectList<[Var]>;
865 let LangOpts = [CUDA];
866 let Documentation = [Undocumented];
869 def C11NoReturn : InheritableAttr {
870 let Spellings = [Keyword<"_Noreturn">];
871 let Subjects = SubjectList<[Function], ErrorDiag>;
873 let Documentation = [C11NoReturnDocs];
876 def CXX11NoReturn : InheritableAttr {
877 let Spellings = [CXX11<"","noreturn", 200809>];
878 let Subjects = SubjectList<[Function], ErrorDiag>;
879 let Documentation = [CXX11NoReturnDocs];
882 def OpenCLKernel : InheritableAttr {
883 let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
884 let Subjects = SubjectList<[Function], ErrorDiag>;
885 let Documentation = [Undocumented];
888 def OpenCLUnrollHint : InheritableAttr {
889 let Spellings = [GNU<"opencl_unroll_hint">];
890 let Args = [UnsignedArgument<"UnrollHint">];
891 let Documentation = [OpenCLUnrollHintDocs];
894 def OpenCLIntelReqdSubGroupSize: InheritableAttr {
895 let Spellings = [GNU<"intel_reqd_sub_group_size">];
896 let Args = [UnsignedArgument<"SubGroupSize">];
897 let Subjects = SubjectList<[Function], ErrorDiag>;
898 let Documentation = [OpenCLIntelReqdSubGroupSizeDocs];
901 // This attribute is both a type attribute, and a declaration attribute (for
902 // parameter variables).
903 def OpenCLAccess : Attr {
904 let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
905 Keyword<"__write_only">, Keyword<"write_only">,
906 Keyword<"__read_write">, Keyword<"read_write">];
907 let Subjects = SubjectList<[ParmVar, TypedefName], ErrorDiag,
908 "ExpectedParameterOrTypedef">;
909 let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
910 Keyword<"read_only">]>,
911 Accessor<"isReadWrite", [Keyword<"__read_write">,
912 Keyword<"read_write">]>,
913 Accessor<"isWriteOnly", [Keyword<"__write_only">,
914 Keyword<"write_only">]>];
915 let Documentation = [OpenCLAccessDocs];
918 def OpenCLPrivateAddressSpace : TypeAttr {
919 let Spellings = [Keyword<"__private">, Keyword<"private">];
920 let Documentation = [OpenCLAddressSpacePrivateDocs];
923 def OpenCLGlobalAddressSpace : TypeAttr {
924 let Spellings = [Keyword<"__global">, Keyword<"global">];
925 let Documentation = [OpenCLAddressSpaceGlobalDocs];
928 def OpenCLLocalAddressSpace : TypeAttr {
929 let Spellings = [Keyword<"__local">, Keyword<"local">];
930 let Documentation = [OpenCLAddressSpaceLocalDocs];
933 def OpenCLConstantAddressSpace : TypeAttr {
934 let Spellings = [Keyword<"__constant">, Keyword<"constant">];
935 let Documentation = [OpenCLAddressSpaceConstantDocs];
938 def OpenCLGenericAddressSpace : TypeAttr {
939 let Spellings = [Keyword<"__generic">, Keyword<"generic">];
940 let Documentation = [OpenCLAddressSpaceGenericDocs];
943 def OpenCLNoSVM : Attr {
944 let Spellings = [GNU<"nosvm">];
945 let Subjects = SubjectList<[Var]>;
946 let Documentation = [OpenCLNoSVMDocs];
947 let LangOpts = [OpenCL];
951 def RenderScriptKernel : Attr {
952 let Spellings = [GNU<"kernel">];
953 let Subjects = SubjectList<[Function]>;
954 let Documentation = [RenderScriptKernelAttributeDocs];
955 let LangOpts = [RenderScript];
958 def Deprecated : InheritableAttr {
959 let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
960 CXX11<"","deprecated", 201309>];
961 let Args = [StringArgument<"Message", 1>,
962 // An optional string argument that enables us to provide a
964 StringArgument<"Replacement", 1>];
965 let MeaningfulToClassTemplateDefinition = 1;
966 let Documentation = [DeprecatedDocs];
969 def Destructor : InheritableAttr {
970 let Spellings = [GCC<"destructor">];
971 let Args = [DefaultIntArgument<"Priority", 65535>];
972 let Subjects = SubjectList<[Function]>;
973 let Documentation = [Undocumented];
976 def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
977 let Spellings = [Declspec<"empty_bases">];
978 let Subjects = SubjectList<[CXXRecord]>;
979 let Documentation = [EmptyBasesDocs];
982 def AllocSize : InheritableAttr {
983 let Spellings = [GCC<"alloc_size">];
984 let Subjects = SubjectList<[Function]>;
985 let Args = [IntArgument<"ElemSizeParam">, IntArgument<"NumElemsParam", 1>];
986 let TemplateDependent = 1;
987 let Documentation = [AllocSizeDocs];
990 def EnableIf : InheritableAttr {
991 let Spellings = [GNU<"enable_if">];
992 let Subjects = SubjectList<[Function]>;
993 let Args = [ExprArgument<"Cond">, StringArgument<"Message">];
994 let TemplateDependent = 1;
995 let Documentation = [EnableIfDocs];
998 def ExtVectorType : Attr {
999 let Spellings = [GNU<"ext_vector_type">];
1000 let Subjects = SubjectList<[TypedefName], ErrorDiag>;
1001 let Args = [ExprArgument<"NumElements">];
1003 let Documentation = [Undocumented];
1006 def FallThrough : StmtAttr {
1007 let Spellings = [CXX11<"", "fallthrough", 201603>,
1008 CXX11<"clang", "fallthrough">];
1009 // let Subjects = [NullStmt];
1010 let Documentation = [FallthroughDocs];
1013 def FastCall : InheritableAttr {
1014 let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
1015 Keyword<"_fastcall">];
1016 // let Subjects = [Function, ObjCMethod];
1017 let Documentation = [FastCallDocs];
1020 def RegCall : InheritableAttr {
1021 let Spellings = [GCC<"regcall">, Keyword<"__regcall">];
1022 let Documentation = [RegCallDocs];
1025 def Final : InheritableAttr {
1026 let Spellings = [Keyword<"final">, Keyword<"sealed">];
1027 let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
1028 let SemaHandler = 0;
1029 let Documentation = [Undocumented];
1032 def MinSize : InheritableAttr {
1033 let Spellings = [GNU<"minsize">];
1034 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
1035 let Documentation = [Undocumented];
1038 def FlagEnum : InheritableAttr {
1039 let Spellings = [GNU<"flag_enum">];
1040 let Subjects = SubjectList<[Enum]>;
1041 let Documentation = [FlagEnumDocs];
1044 def EnumExtensibility : InheritableAttr {
1045 let Spellings = [GNU<"enum_extensibility">,
1046 CXX11<"clang", "enum_extensibility">];
1047 let Subjects = SubjectList<[Enum]>;
1048 let Args = [EnumArgument<"Extensibility", "Kind",
1049 ["closed", "open"], ["Closed", "Open"]>];
1050 let Documentation = [EnumExtensibilityDocs];
1053 def Flatten : InheritableAttr {
1054 let Spellings = [GCC<"flatten">];
1055 let Subjects = SubjectList<[Function], ErrorDiag>;
1056 let Documentation = [FlattenDocs];
1059 def Format : InheritableAttr {
1060 let Spellings = [GCC<"format">];
1061 let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
1062 IntArgument<"FirstArg">];
1063 let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto], WarnDiag,
1064 "ExpectedFunctionWithProtoType">;
1065 let Documentation = [FormatDocs];
1068 def FormatArg : InheritableAttr {
1069 let Spellings = [GCC<"format_arg">];
1070 let Args = [IntArgument<"FormatIdx">];
1071 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto], WarnDiag,
1072 "ExpectedFunctionWithProtoType">;
1073 let Documentation = [Undocumented];
1076 def GNUInline : InheritableAttr {
1077 let Spellings = [GCC<"gnu_inline">];
1078 let Subjects = SubjectList<[Function]>;
1079 let Documentation = [Undocumented];
1082 def Hot : InheritableAttr {
1083 let Spellings = [GCC<"hot">];
1084 let Subjects = SubjectList<[Function]>;
1085 // An AST node is created for this attribute, but not actually used beyond
1086 // semantic checking for mutual exclusion with the Cold attribute.
1087 let Documentation = [Undocumented];
1090 def IBAction : InheritableAttr {
1091 let Spellings = [GNU<"ibaction">];
1092 let Subjects = SubjectList<[ObjCInstanceMethod], WarnDiag,
1093 "ExpectedObjCInstanceMethod">;
1094 // An AST node is created for this attribute, but is not used by other parts
1095 // of the compiler. However, this node needs to exist in the AST because
1096 // external tools rely on it.
1097 let Documentation = [Undocumented];
1100 def IBOutlet : InheritableAttr {
1101 let Spellings = [GNU<"iboutlet">];
1102 // let Subjects = [ObjCIvar, ObjCProperty];
1103 let Documentation = [Undocumented];
1106 def IBOutletCollection : InheritableAttr {
1107 let Spellings = [GNU<"iboutletcollection">];
1108 let Args = [TypeArgument<"Interface", 1>];
1109 // let Subjects = [ObjCIvar, ObjCProperty];
1110 let Documentation = [Undocumented];
1114 let Spellings = [GCC<"ifunc">];
1115 let Args = [StringArgument<"Resolver">];
1116 let Subjects = SubjectList<[Function]>;
1117 let Documentation = [IFuncDocs];
1120 def Restrict : InheritableAttr {
1121 let Spellings = [Declspec<"restrict">, GCC<"malloc">];
1122 let Subjects = SubjectList<[Function]>;
1123 let Documentation = [Undocumented];
1126 def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
1127 let Spellings = [Declspec<"layout_version">];
1128 let Args = [UnsignedArgument<"Version">];
1129 let Subjects = SubjectList<[CXXRecord]>;
1130 let Documentation = [LayoutVersionDocs];
1133 def MaxFieldAlignment : InheritableAttr {
1134 // This attribute has no spellings as it is only ever created implicitly.
1136 let Args = [UnsignedArgument<"Alignment">];
1137 let SemaHandler = 0;
1138 let Documentation = [Undocumented];
1141 def MayAlias : InheritableAttr {
1142 // FIXME: this is a type attribute in GCC, but a declaration attribute here.
1143 let Spellings = [GCC<"may_alias">];
1144 let Documentation = [Undocumented];
1147 def MSABI : InheritableAttr {
1148 let Spellings = [GCC<"ms_abi">];
1149 // let Subjects = [Function, ObjCMethod];
1150 let Documentation = [MSABIDocs];
1153 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
1154 // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's
1155 // and AnyX86Interrupt's spellings must match.
1156 let Spellings = [GNU<"interrupt">];
1157 let Args = [UnsignedArgument<"Number">];
1158 let ParseKind = "Interrupt";
1159 let HasCustomParsing = 1;
1160 let Documentation = [Undocumented];
1163 def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
1164 let Spellings = [GCC<"mips16">];
1165 let Subjects = SubjectList<[Function], ErrorDiag>;
1166 let Documentation = [Undocumented];
1169 def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips> {
1170 // NOTE: If you add any additional spellings, ARMInterrupt's,
1171 // MSP430Interrupt's and AnyX86Interrupt's spellings must match.
1172 let Spellings = [GNU<"interrupt">];
1173 let Subjects = SubjectList<[Function]>;
1174 let Args = [EnumArgument<"Interrupt", "InterruptType",
1175 ["vector=sw0", "vector=sw1", "vector=hw0",
1176 "vector=hw1", "vector=hw2", "vector=hw3",
1177 "vector=hw4", "vector=hw5", "eic", ""],
1178 ["sw0", "sw1", "hw0", "hw1", "hw2", "hw3",
1179 "hw4", "hw5", "eic", "eic"]
1181 let ParseKind = "Interrupt";
1182 let Documentation = [MipsInterruptDocs];
1185 def MicroMips : InheritableAttr, TargetSpecificAttr<TargetMips> {
1186 let Spellings = [GCC<"micromips">];
1187 let Subjects = SubjectList<[Function], ErrorDiag>;
1188 let Documentation = [MicroMipsDocs];
1192 let Spellings = [GCC<"mode">];
1193 let Subjects = SubjectList<[Var, Enum, TypedefName, Field], ErrorDiag,
1194 "ExpectedVariableEnumFieldOrTypedef">;
1195 let Args = [IdentifierArgument<"Mode">];
1196 let Documentation = [Undocumented];
1199 def Naked : InheritableAttr {
1200 let Spellings = [GCC<"naked">, Declspec<"naked">];
1201 let Subjects = SubjectList<[Function]>;
1202 let Documentation = [Undocumented];
1205 def NeonPolyVectorType : TypeAttr {
1206 let Spellings = [GNU<"neon_polyvector_type">];
1207 let Args = [IntArgument<"NumElements">];
1208 let Documentation = [Undocumented];
1211 def NeonVectorType : TypeAttr {
1212 let Spellings = [GNU<"neon_vector_type">];
1213 let Args = [IntArgument<"NumElements">];
1214 let Documentation = [Undocumented];
1217 def ReturnsTwice : InheritableAttr {
1218 let Spellings = [GCC<"returns_twice">];
1219 let Subjects = SubjectList<[Function]>;
1220 let Documentation = [Undocumented];
1223 def DisableTailCalls : InheritableAttr {
1224 let Spellings = [GNU<"disable_tail_calls">,
1225 CXX11<"clang", "disable_tail_calls">];
1226 let Subjects = SubjectList<[Function, ObjCMethod]>;
1227 let Documentation = [DisableTailCallsDocs];
1230 def NoAlias : InheritableAttr {
1231 let Spellings = [Declspec<"noalias">];
1232 let Subjects = SubjectList<[Function]>;
1233 let Documentation = [NoAliasDocs];
1236 def NoCommon : InheritableAttr {
1237 let Spellings = [GCC<"nocommon">];
1238 let Subjects = SubjectList<[Var]>;
1239 let Documentation = [Undocumented];
1242 def NoDebug : InheritableAttr {
1243 let Spellings = [GCC<"nodebug">];
1244 let Subjects = SubjectList<[FunctionLike, ObjCMethod, NonParmVar], WarnDiag,
1245 "ExpectedVariableOrFunction">;
1246 let Documentation = [NoDebugDocs];
1249 def NoDuplicate : InheritableAttr {
1250 let Spellings = [GNU<"noduplicate">, CXX11<"clang", "noduplicate">];
1251 let Subjects = SubjectList<[Function]>;
1252 let Documentation = [NoDuplicateDocs];
1255 def Convergent : InheritableAttr {
1256 let Spellings = [GNU<"convergent">, CXX11<"clang", "convergent">];
1257 let Subjects = SubjectList<[Function]>;
1258 let Documentation = [ConvergentDocs];
1261 def NoInline : InheritableAttr {
1262 let Spellings = [GCC<"noinline">, Declspec<"noinline">];
1263 let Subjects = SubjectList<[Function]>;
1264 let Documentation = [Undocumented];
1267 def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
1268 let Spellings = [GCC<"nomips16">];
1269 let Subjects = SubjectList<[Function], ErrorDiag>;
1270 let Documentation = [Undocumented];
1273 def NoMicroMips : InheritableAttr, TargetSpecificAttr<TargetMips> {
1274 let Spellings = [GCC<"nomicromips">];
1275 let Subjects = SubjectList<[Function], ErrorDiag>;
1276 let Documentation = [MicroMipsDocs];
1279 // This is not a TargetSpecificAttr so that is silently accepted and
1280 // ignored on other targets as encouraged by the OpenCL spec.
1282 // See OpenCL 1.2 6.11.5: "It is our intention that a particular
1283 // implementation of OpenCL be free to ignore all attributes and the
1284 // resulting executable binary will produce the same result."
1286 // However, only AMD GPU targets will emit the corresponding IR
1289 // FIXME: This provides a sub-optimal error message if you attempt to
1290 // use this in CUDA, since CUDA does not use the same terminology.
1292 // FIXME: SubjectList should be for OpenCLKernelFunction, but is not to
1293 // workaround needing to see kernel attribute before others to know if
1294 // this should be rejected on non-kernels.
1296 def AMDGPUFlatWorkGroupSize : InheritableAttr {
1297 let Spellings = [GNU<"amdgpu_flat_work_group_size">];
1298 let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max">];
1299 let Documentation = [AMDGPUFlatWorkGroupSizeDocs];
1300 let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1303 def AMDGPUWavesPerEU : InheritableAttr {
1304 let Spellings = [GNU<"amdgpu_waves_per_eu">];
1305 let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max", 1>];
1306 let Documentation = [AMDGPUWavesPerEUDocs];
1307 let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1310 def AMDGPUNumSGPR : InheritableAttr {
1311 let Spellings = [GNU<"amdgpu_num_sgpr">];
1312 let Args = [UnsignedArgument<"NumSGPR">];
1313 let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1314 let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1317 def AMDGPUNumVGPR : InheritableAttr {
1318 let Spellings = [GNU<"amdgpu_num_vgpr">];
1319 let Args = [UnsignedArgument<"NumVGPR">];
1320 let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
1321 let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;
1324 def NoSplitStack : InheritableAttr {
1325 let Spellings = [GCC<"no_split_stack">];
1326 let Subjects = SubjectList<[Function], ErrorDiag>;
1327 let Documentation = [NoSplitStackDocs];
1330 def NonNull : InheritableParamAttr {
1331 let Spellings = [GCC<"nonnull">];
1332 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
1333 "ExpectedFunctionMethodOrParameter">;
1334 let Args = [VariadicUnsignedArgument<"Args">];
1335 let AdditionalMembers =
1336 [{bool isNonNull(unsigned idx) const {
1339 for (const auto &V : args())
1344 // FIXME: We should merge duplicates into a single nonnull attribute.
1345 let DuplicatesAllowedWhileMerging = 1;
1346 let Documentation = [NonNullDocs];
1349 def ReturnsNonNull : InheritableAttr {
1350 let Spellings = [GCC<"returns_nonnull">];
1351 let Subjects = SubjectList<[ObjCMethod, Function], WarnDiag,
1352 "ExpectedFunctionOrMethod">;
1353 let Documentation = [ReturnsNonNullDocs];
1356 // pass_object_size(N) indicates that the parameter should have
1357 // __builtin_object_size with Type=N evaluated on the parameter at the callsite.
1358 def PassObjectSize : InheritableParamAttr {
1359 let Spellings = [GNU<"pass_object_size">];
1360 let Args = [IntArgument<"Type">];
1361 let Subjects = SubjectList<[ParmVar]>;
1362 let Documentation = [PassObjectSizeDocs];
1365 // Nullability type attributes.
1366 def TypeNonNull : TypeAttr {
1367 let Spellings = [Keyword<"_Nonnull">];
1368 let Documentation = [TypeNonNullDocs];
1371 def TypeNullable : TypeAttr {
1372 let Spellings = [Keyword<"_Nullable">];
1373 let Documentation = [TypeNullableDocs];
1376 def TypeNullUnspecified : TypeAttr {
1377 let Spellings = [Keyword<"_Null_unspecified">];
1378 let Documentation = [TypeNullUnspecifiedDocs];
1381 def ObjCKindOf : TypeAttr {
1382 let Spellings = [Keyword<"__kindof">];
1383 let Documentation = [Undocumented];
1386 def AssumeAligned : InheritableAttr {
1387 let Spellings = [GCC<"assume_aligned">];
1388 let Subjects = SubjectList<[ObjCMethod, Function]>;
1389 let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>];
1390 let Documentation = [AssumeAlignedDocs];
1393 def AllocAlign : InheritableAttr {
1394 let Spellings = [GCC<"alloc_align">];
1395 let Subjects = SubjectList<[HasFunctionProto], WarnDiag,
1396 "ExpectedFunctionWithProtoType">;
1397 let Args = [IntArgument<"ParamIndex">];
1398 let Documentation = [AllocAlignDocs];
1401 def NoReturn : InheritableAttr {
1402 let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
1403 // FIXME: Does GCC allow this on the function instead?
1404 let Documentation = [Undocumented];
1407 def NoInstrumentFunction : InheritableAttr {
1408 let Spellings = [GCC<"no_instrument_function">];
1409 let Subjects = SubjectList<[Function]>;
1410 let Documentation = [Undocumented];
1413 def NotTailCalled : InheritableAttr {
1414 let Spellings = [GNU<"not_tail_called">, CXX11<"clang", "not_tail_called">];
1415 let Subjects = SubjectList<[Function]>;
1416 let Documentation = [NotTailCalledDocs];
1419 def NoThrow : InheritableAttr {
1420 let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
1421 let Documentation = [Undocumented];
1424 def NvWeak : IgnoredAttr {
1425 // No Declspec spelling of this attribute; the CUDA headers use
1426 // __attribute__((nv_weak)) unconditionally.
1427 let Spellings = [GNU<"nv_weak">];
1428 let LangOpts = [CUDA];
1431 def ObjCBridge : InheritableAttr {
1432 let Spellings = [GNU<"objc_bridge">];
1433 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag,
1434 "ExpectedStructOrUnionOrTypedef">;
1435 let Args = [IdentifierArgument<"BridgedType">];
1436 let Documentation = [Undocumented];
1439 def ObjCBridgeMutable : InheritableAttr {
1440 let Spellings = [GNU<"objc_bridge_mutable">];
1441 let Subjects = SubjectList<[Record], ErrorDiag>;
1442 let Args = [IdentifierArgument<"BridgedType">];
1443 let Documentation = [Undocumented];
1446 def ObjCBridgeRelated : InheritableAttr {
1447 let Spellings = [GNU<"objc_bridge_related">];
1448 let Subjects = SubjectList<[Record], ErrorDiag>;
1449 let Args = [IdentifierArgument<"RelatedClass">,
1450 IdentifierArgument<"ClassMethod", 1>,
1451 IdentifierArgument<"InstanceMethod", 1>];
1452 let HasCustomParsing = 1;
1453 let Documentation = [Undocumented];
1456 def NSReturnsRetained : InheritableAttr {
1457 let Spellings = [GNU<"ns_returns_retained">];
1458 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1459 let Documentation = [Undocumented];
1462 def NSReturnsNotRetained : InheritableAttr {
1463 let Spellings = [GNU<"ns_returns_not_retained">];
1464 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1465 let Documentation = [Undocumented];
1468 def NSReturnsAutoreleased : InheritableAttr {
1469 let Spellings = [GNU<"ns_returns_autoreleased">];
1470 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1471 let Documentation = [Undocumented];
1474 def NSConsumesSelf : InheritableAttr {
1475 let Spellings = [GNU<"ns_consumes_self">];
1476 let Subjects = SubjectList<[ObjCMethod]>;
1477 let Documentation = [Undocumented];
1480 def NSConsumed : InheritableParamAttr {
1481 let Spellings = [GNU<"ns_consumed">];
1482 let Subjects = SubjectList<[ParmVar]>;
1483 let Documentation = [Undocumented];
1486 def ObjCException : InheritableAttr {
1487 let Spellings = [GNU<"objc_exception">];
1488 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1489 let Documentation = [Undocumented];
1492 def ObjCMethodFamily : InheritableAttr {
1493 let Spellings = [GNU<"objc_method_family">];
1494 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1495 let Args = [EnumArgument<"Family", "FamilyKind",
1496 ["none", "alloc", "copy", "init", "mutableCopy", "new"],
1497 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
1498 "OMF_mutableCopy", "OMF_new"]>];
1499 let Documentation = [ObjCMethodFamilyDocs];
1502 def ObjCNSObject : InheritableAttr {
1503 let Spellings = [GNU<"NSObject">];
1504 let Documentation = [Undocumented];
1507 def ObjCIndependentClass : InheritableAttr {
1508 let Spellings = [GNU<"objc_independent_class">];
1509 let Documentation = [Undocumented];
1512 def ObjCPreciseLifetime : InheritableAttr {
1513 let Spellings = [GNU<"objc_precise_lifetime">];
1514 let Subjects = SubjectList<[Var], ErrorDiag>;
1515 let Documentation = [Undocumented];
1518 def ObjCReturnsInnerPointer : InheritableAttr {
1519 let Spellings = [GNU<"objc_returns_inner_pointer">];
1520 let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
1521 let Documentation = [Undocumented];
1524 def ObjCRequiresSuper : InheritableAttr {
1525 let Spellings = [GNU<"objc_requires_super">];
1526 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1527 let Documentation = [ObjCRequiresSuperDocs];
1530 def ObjCRootClass : InheritableAttr {
1531 let Spellings = [GNU<"objc_root_class">];
1532 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1533 let Documentation = [Undocumented];
1536 def ObjCSubclassingRestricted : InheritableAttr {
1537 let Spellings = [GNU<"objc_subclassing_restricted">];
1538 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1539 let Documentation = [ObjCSubclassingRestrictedDocs];
1542 def ObjCExplicitProtocolImpl : InheritableAttr {
1543 let Spellings = [GNU<"objc_protocol_requires_explicit_implementation">];
1544 let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
1545 let Documentation = [Undocumented];
1548 def ObjCDesignatedInitializer : Attr {
1549 let Spellings = [GNU<"objc_designated_initializer">];
1550 let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag,
1551 "ExpectedObjCInterfaceDeclInitMethod">;
1552 let Documentation = [Undocumented];
1555 def ObjCRuntimeName : Attr {
1556 let Spellings = [GNU<"objc_runtime_name">];
1557 let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
1558 let Args = [StringArgument<"MetadataName">];
1559 let Documentation = [ObjCRuntimeNameDocs];
1562 def ObjCRuntimeVisible : Attr {
1563 let Spellings = [GNU<"objc_runtime_visible">];
1564 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1565 let Documentation = [ObjCRuntimeVisibleDocs];
1568 def ObjCBoxable : Attr {
1569 let Spellings = [GNU<"objc_boxable">];
1570 let Subjects = SubjectList<[Record], ErrorDiag, "ExpectedStructOrUnion">;
1571 let Documentation = [ObjCBoxableDocs];
1574 def OptimizeNone : InheritableAttr {
1575 let Spellings = [GNU<"optnone">, CXX11<"clang", "optnone">];
1576 let Subjects = SubjectList<[Function, ObjCMethod]>;
1577 let Documentation = [OptnoneDocs];
1580 def Overloadable : Attr {
1581 let Spellings = [GNU<"overloadable">];
1582 let Subjects = SubjectList<[Function], ErrorDiag>;
1583 let Documentation = [OverloadableDocs];
1586 def Override : InheritableAttr {
1587 let Spellings = [Keyword<"override">];
1588 let SemaHandler = 0;
1589 let Documentation = [Undocumented];
1592 def Ownership : InheritableAttr {
1593 let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
1594 GNU<"ownership_takes">];
1595 let Accessors = [Accessor<"isHolds", [GNU<"ownership_holds">]>,
1596 Accessor<"isReturns", [GNU<"ownership_returns">]>,
1597 Accessor<"isTakes", [GNU<"ownership_takes">]>];
1598 let AdditionalMembers = [{
1599 enum OwnershipKind { Holds, Returns, Takes };
1600 OwnershipKind getOwnKind() const {
1601 return isHolds() ? Holds :
1606 let Args = [IdentifierArgument<"Module">, VariadicUnsignedArgument<"Args">];
1607 let Subjects = SubjectList<[HasFunctionProto], WarnDiag,
1608 "ExpectedFunctionWithProtoType">;
1609 let Documentation = [Undocumented];
1612 def Packed : InheritableAttr {
1613 let Spellings = [GCC<"packed">];
1614 // let Subjects = [Tag, Field];
1615 let Documentation = [Undocumented];
1618 def IntelOclBicc : InheritableAttr {
1619 let Spellings = [GNU<"intel_ocl_bicc">];
1620 // let Subjects = [Function, ObjCMethod];
1621 let Documentation = [Undocumented];
1624 def Pcs : InheritableAttr {
1625 let Spellings = [GCC<"pcs">];
1626 let Args = [EnumArgument<"PCS", "PCSType",
1627 ["aapcs", "aapcs-vfp"],
1628 ["AAPCS", "AAPCS_VFP"]>];
1629 // let Subjects = [Function, ObjCMethod];
1630 let Documentation = [PcsDocs];
1633 def Pure : InheritableAttr {
1634 let Spellings = [GCC<"pure">];
1635 let Documentation = [Undocumented];
1638 def Regparm : TypeAttr {
1639 let Spellings = [GCC<"regparm">];
1640 let Args = [UnsignedArgument<"NumParams">];
1641 let Documentation = [RegparmDocs];
1644 def ReqdWorkGroupSize : InheritableAttr {
1645 let Spellings = [GNU<"reqd_work_group_size">];
1646 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
1647 UnsignedArgument<"ZDim">];
1648 let Subjects = SubjectList<[Function], ErrorDiag>;
1649 let Documentation = [Undocumented];
1652 def RequireConstantInit : InheritableAttr {
1653 let Spellings = [GNU<"require_constant_initialization">,
1654 CXX11<"clang", "require_constant_initialization">];
1655 let Subjects = SubjectList<[GlobalVar], ErrorDiag,
1656 "ExpectedStaticOrTLSVar">;
1657 let Documentation = [RequireConstantInitDocs];
1658 let LangOpts = [CPlusPlus];
1661 def WorkGroupSizeHint : InheritableAttr {
1662 let Spellings = [GNU<"work_group_size_hint">];
1663 let Args = [UnsignedArgument<"XDim">,
1664 UnsignedArgument<"YDim">,
1665 UnsignedArgument<"ZDim">];
1666 let Subjects = SubjectList<[Function], ErrorDiag>;
1667 let Documentation = [Undocumented];
1670 def InitPriority : InheritableAttr {
1671 let Spellings = [GNU<"init_priority">];
1672 let Args = [UnsignedArgument<"Priority">];
1673 let Subjects = SubjectList<[Var], ErrorDiag>;
1674 let Documentation = [Undocumented];
1677 def Section : InheritableAttr {
1678 let Spellings = [GCC<"section">, Declspec<"allocate">];
1679 let Args = [StringArgument<"Name">];
1680 let Subjects = SubjectList<[Function, GlobalVar,
1681 ObjCMethod, ObjCProperty], ErrorDiag,
1682 "ExpectedFunctionGlobalVarMethodOrProperty">;
1683 let Documentation = [SectionDocs];
1686 def Sentinel : InheritableAttr {
1687 let Spellings = [GCC<"sentinel">];
1688 let Args = [DefaultIntArgument<"Sentinel", 0>,
1689 DefaultIntArgument<"NullPos", 0>];
1690 // let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
1691 let Documentation = [Undocumented];
1694 def StdCall : InheritableAttr {
1695 let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
1696 // let Subjects = [Function, ObjCMethod];
1697 let Documentation = [StdCallDocs];
1700 def SwiftCall : InheritableAttr {
1701 let Spellings = [GCC<"swiftcall">];
1702 // let Subjects = SubjectList<[Function]>;
1703 let Documentation = [SwiftCallDocs];
1706 def SwiftContext : ParameterABIAttr {
1707 let Spellings = [GCC<"swift_context">];
1708 let Documentation = [SwiftContextDocs];
1711 def SwiftErrorResult : ParameterABIAttr {
1712 let Spellings = [GCC<"swift_error_result">];
1713 let Documentation = [SwiftErrorResultDocs];
1716 def SwiftIndirectResult : ParameterABIAttr {
1717 let Spellings = [GCC<"swift_indirect_result">];
1718 let Documentation = [SwiftIndirectResultDocs];
1721 def Suppress : StmtAttr {
1722 let Spellings = [CXX11<"gsl", "suppress">];
1723 let Args = [VariadicStringArgument<"DiagnosticIdentifiers">];
1724 let Documentation = [SuppressDocs];
1727 def SysVABI : InheritableAttr {
1728 let Spellings = [GCC<"sysv_abi">];
1729 // let Subjects = [Function, ObjCMethod];
1730 let Documentation = [Undocumented];
1733 def ThisCall : InheritableAttr {
1734 let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
1735 Keyword<"_thiscall">];
1736 // let Subjects = [Function, ObjCMethod];
1737 let Documentation = [ThisCallDocs];
1740 def VectorCall : InheritableAttr {
1741 let Spellings = [GNU<"vectorcall">, Keyword<"__vectorcall">,
1742 Keyword<"_vectorcall">];
1743 // let Subjects = [Function, ObjCMethod];
1744 let Documentation = [VectorCallDocs];
1747 def Pascal : InheritableAttr {
1748 let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
1749 // let Subjects = [Function, ObjCMethod];
1750 let Documentation = [Undocumented];
1753 def PreserveMost : InheritableAttr {
1754 let Spellings = [GNU<"preserve_most">];
1755 let Documentation = [PreserveMostDocs];
1758 def PreserveAll : InheritableAttr {
1759 let Spellings = [GNU<"preserve_all">];
1760 let Documentation = [PreserveAllDocs];
1763 def Target : InheritableAttr {
1764 let Spellings = [GCC<"target">];
1765 let Args = [StringArgument<"featuresStr">];
1766 let Subjects = SubjectList<[Function], ErrorDiag>;
1767 let Documentation = [TargetDocs];
1768 let AdditionalMembers = [{
1769 typedef std::pair<std::vector<std::string>, StringRef> ParsedTargetAttr;
1770 ParsedTargetAttr parse() const {
1771 ParsedTargetAttr Ret;
1772 SmallVector<StringRef, 1> AttrFeatures;
1773 getFeaturesStr().split(AttrFeatures, ",");
1775 // Grab the various features and prepend a "+" to turn on the feature to
1776 // the backend and add them to our existing set of features.
1777 for (auto &Feature : AttrFeatures) {
1778 // Go ahead and trim whitespace rather than either erroring or
1779 // accepting it weirdly.
1780 Feature = Feature.trim();
1782 // We don't support cpu tuning this way currently.
1783 // TODO: Support the fpmath option. It will require checking
1784 // overall feature validity for the function with the rest of the
1785 // attributes on the function.
1786 if (Feature.startswith("fpmath=") || Feature.startswith("tune="))
1789 // While we're here iterating check for a different target cpu.
1790 if (Feature.startswith("arch="))
1791 Ret.second = Feature.split("=").second.trim();
1792 else if (Feature.startswith("no-"))
1793 Ret.first.push_back("-" + Feature.split("-").second.str());
1795 Ret.first.push_back("+" + Feature.str());
1802 def TransparentUnion : InheritableAttr {
1803 let Spellings = [GCC<"transparent_union">];
1804 // let Subjects = SubjectList<[Record, TypedefName]>;
1805 let Documentation = [TransparentUnionDocs];
1806 let LangOpts = [COnly];
1809 def Unavailable : InheritableAttr {
1810 let Spellings = [GNU<"unavailable">];
1811 let Args = [StringArgument<"Message", 1>,
1812 EnumArgument<"ImplicitReason", "ImplicitReason",
1815 "IR_ARCForbiddenType",
1817 "IR_ARCForbiddenConversion",
1818 "IR_ARCInitReturnsUnrelated",
1819 "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>];
1820 let Documentation = [Undocumented];
1823 def DiagnoseIf : InheritableAttr {
1824 let Spellings = [GNU<"diagnose_if">];
1825 let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;
1826 let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
1827 EnumArgument<"DiagnosticType",
1829 ["error", "warning"],
1830 ["DT_Error", "DT_Warning"]>,
1831 BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
1832 NamedArgument<"Parent", 0, /*fake*/ 1>];
1833 let DuplicatesAllowedWhileMerging = 1;
1835 let AdditionalMembers = [{
1836 bool isError() const { return diagnosticType == DT_Error; }
1837 bool isWarning() const { return diagnosticType == DT_Warning; }
1839 let TemplateDependent = 1;
1840 let Documentation = [DiagnoseIfDocs];
1843 def ArcWeakrefUnavailable : InheritableAttr {
1844 let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
1845 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1846 let Documentation = [Undocumented];
1849 def ObjCGC : TypeAttr {
1850 let Spellings = [GNU<"objc_gc">];
1851 let Args = [IdentifierArgument<"Kind">];
1852 let Documentation = [Undocumented];
1855 def ObjCOwnership : InheritableAttr {
1856 let Spellings = [GNU<"objc_ownership">];
1857 let Args = [IdentifierArgument<"Kind">];
1859 let Documentation = [Undocumented];
1862 def ObjCRequiresPropertyDefs : InheritableAttr {
1863 let Spellings = [GNU<"objc_requires_property_definitions">];
1864 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1865 let Documentation = [Undocumented];
1868 def Unused : InheritableAttr {
1869 let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">];
1870 let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
1871 Field, ObjCMethod, FunctionLike], WarnDiag,
1872 "ExpectedForMaybeUnused">;
1873 let Documentation = [WarnMaybeUnusedDocs];
1876 def Used : InheritableAttr {
1877 let Spellings = [GCC<"used">];
1878 let Documentation = [Undocumented];
1881 def Uuid : InheritableAttr {
1882 let Spellings = [Declspec<"uuid">, Microsoft<"uuid">];
1883 let Args = [StringArgument<"Guid">];
1884 let Subjects = SubjectList<[Record, Enum], WarnDiag, "ExpectedEnumOrClass">;
1885 // FIXME: Allow expressing logical AND for LangOpts. Our condition should be:
1886 // CPlusPlus && (MicrosoftExt || Borland)
1887 let LangOpts = [MicrosoftExt, Borland];
1888 let Documentation = [Undocumented];
1891 def VectorSize : TypeAttr {
1892 let Spellings = [GCC<"vector_size">];
1893 let Args = [ExprArgument<"NumBytes">];
1894 let Documentation = [Undocumented];
1897 def VecTypeHint : InheritableAttr {
1898 let Spellings = [GNU<"vec_type_hint">];
1899 let Args = [TypeArgument<"TypeHint">];
1900 let Subjects = SubjectList<[Function], ErrorDiag>;
1901 let Documentation = [Undocumented];
1904 def Visibility : InheritableAttr {
1906 let Spellings = [GCC<"visibility">];
1907 let Args = [EnumArgument<"Visibility", "VisibilityType",
1908 ["default", "hidden", "internal", "protected"],
1909 ["Default", "Hidden", "Hidden", "Protected"]>];
1910 let MeaningfulToClassTemplateDefinition = 1;
1911 let Documentation = [Undocumented];
1914 def TypeVisibility : InheritableAttr {
1916 let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">];
1917 let Args = [EnumArgument<"Visibility", "VisibilityType",
1918 ["default", "hidden", "internal", "protected"],
1919 ["Default", "Hidden", "Hidden", "Protected"]>];
1920 // let Subjects = [Tag, ObjCInterface, Namespace];
1921 let Documentation = [Undocumented];
1924 def VecReturn : InheritableAttr {
1925 let Spellings = [GNU<"vecreturn">];
1926 let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
1927 let Documentation = [Undocumented];
1930 def WarnUnused : InheritableAttr {
1931 let Spellings = [GNU<"warn_unused">];
1932 let Subjects = SubjectList<[Record]>;
1933 let Documentation = [Undocumented];
1936 def WarnUnusedResult : InheritableAttr {
1937 let Spellings = [CXX11<"", "nodiscard", 201603>,
1938 CXX11<"clang", "warn_unused_result">,
1939 GCC<"warn_unused_result">];
1940 let Subjects = SubjectList<[ObjCMethod, Enum, CXXRecord, FunctionLike],
1941 WarnDiag, "ExpectedFunctionMethodEnumOrClass">;
1942 let Documentation = [WarnUnusedResultsDocs];
1945 def Weak : InheritableAttr {
1946 let Spellings = [GCC<"weak">];
1947 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
1948 let Documentation = [Undocumented];
1951 def WeakImport : InheritableAttr {
1952 let Spellings = [GNU<"weak_import">];
1953 let Documentation = [Undocumented];
1956 def WeakRef : InheritableAttr {
1957 let Spellings = [GCC<"weakref">];
1958 // A WeakRef that has an argument is treated as being an AliasAttr
1959 let Args = [StringArgument<"Aliasee", 1>];
1960 let Subjects = SubjectList<[Var, Function], ErrorDiag>;
1961 let Documentation = [Undocumented];
1964 def LTOVisibilityPublic : InheritableAttr {
1965 let Spellings = [CXX11<"clang", "lto_visibility_public">];
1966 let Subjects = SubjectList<[Record]>;
1967 let Documentation = [LTOVisibilityDocs];
1970 def AnyX86Interrupt : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
1971 // NOTE: If you add any additional spellings, ARMInterrupt's,
1972 // MSP430Interrupt's and MipsInterrupt's spellings must match.
1973 let Spellings = [GNU<"interrupt">];
1974 let Subjects = SubjectList<[HasFunctionProto]>;
1975 let ParseKind = "Interrupt";
1976 let HasCustomParsing = 1;
1977 let Documentation = [AnyX86InterruptDocs];
1980 def AnyX86NoCallerSavedRegisters : InheritableAttr,
1981 TargetSpecificAttr<TargetAnyX86> {
1982 let Spellings = [GCC<"no_caller_saved_registers">];
1983 let Documentation = [AnyX86NoCallerSavedRegistersDocs];
1986 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetX86> {
1987 let Spellings = [GNU<"force_align_arg_pointer">];
1988 // Technically, this appertains to a FunctionDecl, but the target-specific
1989 // code silently allows anything function-like (such as typedefs or function
1990 // pointers), but does not apply the attribute to them.
1991 let Documentation = [Undocumented];
1994 def NoSanitize : InheritableAttr {
1995 let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">];
1996 let Args = [VariadicStringArgument<"Sanitizers">];
1997 let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag,
1998 "ExpectedFunctionMethodOrGlobalVar">;
1999 let Documentation = [NoSanitizeDocs];
2000 let AdditionalMembers = [{
2001 SanitizerMask getMask() const {
2002 SanitizerMask Mask = 0;
2003 for (auto SanitizerName : sanitizers()) {
2004 SanitizerMask ParsedMask =
2005 parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
2006 Mask |= expandSanitizerGroups(ParsedMask);
2013 // Attributes to disable a specific sanitizer. No new sanitizers should be added
2014 // to this list; the no_sanitize attribute should be extended instead.
2015 def NoSanitizeSpecific : InheritableAttr {
2016 let Spellings = [GCC<"no_address_safety_analysis">,
2017 GCC<"no_sanitize_address">,
2018 GCC<"no_sanitize_thread">,
2019 GNU<"no_sanitize_memory">];
2020 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
2021 "ExpectedFunctionOrGlobalVar">;
2022 let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
2023 NoSanitizeMemoryDocs];
2027 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
2029 def GuardedVar : InheritableAttr {
2030 let Spellings = [GNU<"guarded_var">];
2031 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2032 "ExpectedFieldOrGlobalVar">;
2033 let Documentation = [Undocumented];
2036 def PtGuardedVar : InheritableAttr {
2037 let Spellings = [GNU<"pt_guarded_var">];
2038 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2039 "ExpectedFieldOrGlobalVar">;
2040 let Documentation = [Undocumented];
2043 def Lockable : InheritableAttr {
2044 let Spellings = [GNU<"lockable">];
2045 let Subjects = SubjectList<[Record]>;
2046 let Documentation = [Undocumented];
2047 let ASTNode = 0; // Replaced by Capability
2050 def ScopedLockable : InheritableAttr {
2051 let Spellings = [GNU<"scoped_lockable">];
2052 let Subjects = SubjectList<[Record]>;
2053 let Documentation = [Undocumented];
2056 def Capability : InheritableAttr {
2057 let Spellings = [GNU<"capability">, CXX11<"clang", "capability">,
2058 GNU<"shared_capability">,
2059 CXX11<"clang", "shared_capability">];
2060 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag,
2061 "ExpectedStructOrUnionOrTypedef">;
2062 let Args = [StringArgument<"Name">];
2063 let Accessors = [Accessor<"isShared",
2064 [GNU<"shared_capability">,
2065 CXX11<"clang","shared_capability">]>];
2066 let Documentation = [Undocumented];
2067 let AdditionalMembers = [{
2068 bool isMutex() const { return getName().equals_lower("mutex"); }
2069 bool isRole() const { return getName().equals_lower("role"); }
2073 def AssertCapability : InheritableAttr {
2074 let Spellings = [GNU<"assert_capability">,
2075 CXX11<"clang", "assert_capability">,
2076 GNU<"assert_shared_capability">,
2077 CXX11<"clang", "assert_shared_capability">];
2078 let Subjects = SubjectList<[Function]>;
2080 let TemplateDependent = 1;
2081 let ParseArgumentsAsUnevaluated = 1;
2082 let DuplicatesAllowedWhileMerging = 1;
2083 let Args = [ExprArgument<"Expr">];
2084 let Accessors = [Accessor<"isShared",
2085 [GNU<"assert_shared_capability">,
2086 CXX11<"clang", "assert_shared_capability">]>];
2087 let Documentation = [AssertCapabilityDocs];
2090 def AcquireCapability : InheritableAttr {
2091 let Spellings = [GNU<"acquire_capability">,
2092 CXX11<"clang", "acquire_capability">,
2093 GNU<"acquire_shared_capability">,
2094 CXX11<"clang", "acquire_shared_capability">,
2095 GNU<"exclusive_lock_function">,
2096 GNU<"shared_lock_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<"acquire_shared_capability">,
2105 CXX11<"clang", "acquire_shared_capability">,
2106 GNU<"shared_lock_function">]>];
2107 let Documentation = [AcquireCapabilityDocs];
2110 def TryAcquireCapability : InheritableAttr {
2111 let Spellings = [GNU<"try_acquire_capability">,
2112 CXX11<"clang", "try_acquire_capability">,
2113 GNU<"try_acquire_shared_capability">,
2114 CXX11<"clang", "try_acquire_shared_capability">];
2115 let Subjects = SubjectList<[Function],
2118 let TemplateDependent = 1;
2119 let ParseArgumentsAsUnevaluated = 1;
2120 let DuplicatesAllowedWhileMerging = 1;
2121 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2122 let Accessors = [Accessor<"isShared",
2123 [GNU<"try_acquire_shared_capability">,
2124 CXX11<"clang", "try_acquire_shared_capability">]>];
2125 let Documentation = [TryAcquireCapabilityDocs];
2128 def ReleaseCapability : InheritableAttr {
2129 let Spellings = [GNU<"release_capability">,
2130 CXX11<"clang", "release_capability">,
2131 GNU<"release_shared_capability">,
2132 CXX11<"clang", "release_shared_capability">,
2133 GNU<"release_generic_capability">,
2134 CXX11<"clang", "release_generic_capability">,
2135 GNU<"unlock_function">];
2136 let Subjects = SubjectList<[Function]>;
2138 let TemplateDependent = 1;
2139 let ParseArgumentsAsUnevaluated = 1;
2140 let DuplicatesAllowedWhileMerging = 1;
2141 let Args = [VariadicExprArgument<"Args">];
2142 let Accessors = [Accessor<"isShared",
2143 [GNU<"release_shared_capability">,
2144 CXX11<"clang", "release_shared_capability">]>,
2145 Accessor<"isGeneric",
2146 [GNU<"release_generic_capability">,
2147 CXX11<"clang", "release_generic_capability">,
2148 GNU<"unlock_function">]>];
2149 let Documentation = [ReleaseCapabilityDocs];
2152 def RequiresCapability : InheritableAttr {
2153 let Spellings = [GNU<"requires_capability">,
2154 CXX11<"clang", "requires_capability">,
2155 GNU<"exclusive_locks_required">,
2156 GNU<"requires_shared_capability">,
2157 CXX11<"clang", "requires_shared_capability">,
2158 GNU<"shared_locks_required">];
2159 let Args = [VariadicExprArgument<"Args">];
2161 let TemplateDependent = 1;
2162 let ParseArgumentsAsUnevaluated = 1;
2163 let DuplicatesAllowedWhileMerging = 1;
2164 let Subjects = SubjectList<[Function]>;
2165 let Accessors = [Accessor<"isShared", [GNU<"requires_shared_capability">,
2166 GNU<"shared_locks_required">,
2167 CXX11<"clang","requires_shared_capability">]>];
2168 let Documentation = [Undocumented];
2171 def NoThreadSafetyAnalysis : InheritableAttr {
2172 let Spellings = [GNU<"no_thread_safety_analysis">];
2173 let Subjects = SubjectList<[Function]>;
2174 let Documentation = [Undocumented];
2177 def GuardedBy : InheritableAttr {
2178 let Spellings = [GNU<"guarded_by">];
2179 let Args = [ExprArgument<"Arg">];
2181 let TemplateDependent = 1;
2182 let ParseArgumentsAsUnevaluated = 1;
2183 let DuplicatesAllowedWhileMerging = 1;
2184 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2185 "ExpectedFieldOrGlobalVar">;
2186 let Documentation = [Undocumented];
2189 def PtGuardedBy : InheritableAttr {
2190 let Spellings = [GNU<"pt_guarded_by">];
2191 let Args = [ExprArgument<"Arg">];
2193 let TemplateDependent = 1;
2194 let ParseArgumentsAsUnevaluated = 1;
2195 let DuplicatesAllowedWhileMerging = 1;
2196 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2197 "ExpectedFieldOrGlobalVar">;
2198 let Documentation = [Undocumented];
2201 def AcquiredAfter : InheritableAttr {
2202 let Spellings = [GNU<"acquired_after">];
2203 let Args = [VariadicExprArgument<"Args">];
2205 let TemplateDependent = 1;
2206 let ParseArgumentsAsUnevaluated = 1;
2207 let DuplicatesAllowedWhileMerging = 1;
2208 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2209 "ExpectedFieldOrGlobalVar">;
2210 let Documentation = [Undocumented];
2213 def AcquiredBefore : InheritableAttr {
2214 let Spellings = [GNU<"acquired_before">];
2215 let Args = [VariadicExprArgument<"Args">];
2217 let TemplateDependent = 1;
2218 let ParseArgumentsAsUnevaluated = 1;
2219 let DuplicatesAllowedWhileMerging = 1;
2220 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
2221 "ExpectedFieldOrGlobalVar">;
2222 let Documentation = [Undocumented];
2225 def AssertExclusiveLock : InheritableAttr {
2226 let Spellings = [GNU<"assert_exclusive_lock">];
2227 let Args = [VariadicExprArgument<"Args">];
2229 let TemplateDependent = 1;
2230 let ParseArgumentsAsUnevaluated = 1;
2231 let DuplicatesAllowedWhileMerging = 1;
2232 let Subjects = SubjectList<[Function]>;
2233 let Documentation = [Undocumented];
2236 def AssertSharedLock : InheritableAttr {
2237 let Spellings = [GNU<"assert_shared_lock">];
2238 let Args = [VariadicExprArgument<"Args">];
2240 let TemplateDependent = 1;
2241 let ParseArgumentsAsUnevaluated = 1;
2242 let DuplicatesAllowedWhileMerging = 1;
2243 let Subjects = SubjectList<[Function]>;
2244 let Documentation = [Undocumented];
2247 // The first argument is an integer or boolean value specifying the return value
2248 // of a successful lock acquisition.
2249 def ExclusiveTrylockFunction : InheritableAttr {
2250 let Spellings = [GNU<"exclusive_trylock_function">];
2251 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2253 let TemplateDependent = 1;
2254 let ParseArgumentsAsUnevaluated = 1;
2255 let DuplicatesAllowedWhileMerging = 1;
2256 let Subjects = SubjectList<[Function]>;
2257 let Documentation = [Undocumented];
2260 // The first argument is an integer or boolean value specifying the return value
2261 // of a successful lock acquisition.
2262 def SharedTrylockFunction : InheritableAttr {
2263 let Spellings = [GNU<"shared_trylock_function">];
2264 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
2266 let TemplateDependent = 1;
2267 let ParseArgumentsAsUnevaluated = 1;
2268 let DuplicatesAllowedWhileMerging = 1;
2269 let Subjects = SubjectList<[Function]>;
2270 let Documentation = [Undocumented];
2273 def LockReturned : InheritableAttr {
2274 let Spellings = [GNU<"lock_returned">];
2275 let Args = [ExprArgument<"Arg">];
2277 let TemplateDependent = 1;
2278 let ParseArgumentsAsUnevaluated = 1;
2279 let Subjects = SubjectList<[Function]>;
2280 let Documentation = [Undocumented];
2283 def LocksExcluded : InheritableAttr {
2284 let Spellings = [GNU<"locks_excluded">];
2285 let Args = [VariadicExprArgument<"Args">];
2287 let TemplateDependent = 1;
2288 let ParseArgumentsAsUnevaluated = 1;
2289 let DuplicatesAllowedWhileMerging = 1;
2290 let Subjects = SubjectList<[Function]>;
2291 let Documentation = [Undocumented];
2294 // C/C++ consumed attributes.
2296 def Consumable : InheritableAttr {
2297 let Spellings = [GNU<"consumable">];
2298 let Subjects = SubjectList<[CXXRecord]>;
2299 let Args = [EnumArgument<"DefaultState", "ConsumedState",
2300 ["unknown", "consumed", "unconsumed"],
2301 ["Unknown", "Consumed", "Unconsumed"]>];
2302 let Documentation = [ConsumableDocs];
2305 def ConsumableAutoCast : InheritableAttr {
2306 let Spellings = [GNU<"consumable_auto_cast_state">];
2307 let Subjects = SubjectList<[CXXRecord]>;
2308 let Documentation = [Undocumented];
2311 def ConsumableSetOnRead : InheritableAttr {
2312 let Spellings = [GNU<"consumable_set_state_on_read">];
2313 let Subjects = SubjectList<[CXXRecord]>;
2314 let Documentation = [Undocumented];
2317 def CallableWhen : InheritableAttr {
2318 let Spellings = [GNU<"callable_when">];
2319 let Subjects = SubjectList<[CXXMethod]>;
2320 let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
2321 ["unknown", "consumed", "unconsumed"],
2322 ["Unknown", "Consumed", "Unconsumed"]>];
2323 let Documentation = [CallableWhenDocs];
2326 def ParamTypestate : InheritableAttr {
2327 let Spellings = [GNU<"param_typestate">];
2328 let Subjects = SubjectList<[ParmVar]>;
2329 let Args = [EnumArgument<"ParamState", "ConsumedState",
2330 ["unknown", "consumed", "unconsumed"],
2331 ["Unknown", "Consumed", "Unconsumed"]>];
2332 let Documentation = [ParamTypestateDocs];
2335 def ReturnTypestate : InheritableAttr {
2336 let Spellings = [GNU<"return_typestate">];
2337 let Subjects = SubjectList<[Function, ParmVar]>;
2338 let Args = [EnumArgument<"State", "ConsumedState",
2339 ["unknown", "consumed", "unconsumed"],
2340 ["Unknown", "Consumed", "Unconsumed"]>];
2341 let Documentation = [ReturnTypestateDocs];
2344 def SetTypestate : InheritableAttr {
2345 let Spellings = [GNU<"set_typestate">];
2346 let Subjects = SubjectList<[CXXMethod]>;
2347 let Args = [EnumArgument<"NewState", "ConsumedState",
2348 ["unknown", "consumed", "unconsumed"],
2349 ["Unknown", "Consumed", "Unconsumed"]>];
2350 let Documentation = [SetTypestateDocs];
2353 def TestTypestate : InheritableAttr {
2354 let Spellings = [GNU<"test_typestate">];
2355 let Subjects = SubjectList<[CXXMethod]>;
2356 let Args = [EnumArgument<"TestState", "ConsumedState",
2357 ["consumed", "unconsumed"],
2358 ["Consumed", "Unconsumed"]>];
2359 let Documentation = [TestTypestateDocs];
2362 // Type safety attributes for `void *' pointers and type tags.
2364 def ArgumentWithTypeTag : InheritableAttr {
2365 let Spellings = [GNU<"argument_with_type_tag">,
2366 GNU<"pointer_with_type_tag">];
2367 let Args = [IdentifierArgument<"ArgumentKind">,
2368 UnsignedArgument<"ArgumentIdx">,
2369 UnsignedArgument<"TypeTagIdx">,
2370 BoolArgument<"IsPointer">];
2371 let HasCustomParsing = 1;
2372 let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
2375 def TypeTagForDatatype : InheritableAttr {
2376 let Spellings = [GNU<"type_tag_for_datatype">];
2377 let Args = [IdentifierArgument<"ArgumentKind">,
2378 TypeArgument<"MatchingCType">,
2379 BoolArgument<"LayoutCompatible">,
2380 BoolArgument<"MustBeNull">];
2381 // let Subjects = SubjectList<[Var], ErrorDiag>;
2382 let HasCustomParsing = 1;
2383 let Documentation = [TypeTagForDatatypeDocs];
2386 // Microsoft-related attributes
2388 def MSNoVTable : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
2389 let Spellings = [Declspec<"novtable">];
2390 let Subjects = SubjectList<[CXXRecord]>;
2391 let Documentation = [MSNoVTableDocs];
2395 let Spellings = [Declspec<"property">];
2398 def MSStruct : InheritableAttr {
2399 let Spellings = [GCC<"ms_struct">];
2400 let Subjects = SubjectList<[Record]>;
2401 let Documentation = [Undocumented];
2404 def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2405 let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
2406 let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2407 let Documentation = [DLLExportDocs];
2410 def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2411 let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
2412 let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
2413 let Documentation = [DLLImportDocs];
2416 def SelectAny : InheritableAttr, TargetSpecificAttr<TargetWindows> {
2417 let Spellings = [Declspec<"selectany">, GCC<"selectany">];
2418 let Documentation = [Undocumented];
2422 let Spellings = [Declspec<"thread">];
2423 let LangOpts = [MicrosoftExt];
2424 let Documentation = [ThreadDocs];
2425 let Subjects = SubjectList<[Var]>;
2428 def Win64 : IgnoredAttr {
2429 let Spellings = [Keyword<"__w64">];
2430 let LangOpts = [MicrosoftExt];
2433 def Ptr32 : TypeAttr {
2434 let Spellings = [Keyword<"__ptr32">];
2435 let Documentation = [Undocumented];
2438 def Ptr64 : TypeAttr {
2439 let Spellings = [Keyword<"__ptr64">];
2440 let Documentation = [Undocumented];
2443 def SPtr : TypeAttr {
2444 let Spellings = [Keyword<"__sptr">];
2445 let Documentation = [Undocumented];
2448 def UPtr : TypeAttr {
2449 let Spellings = [Keyword<"__uptr">];
2450 let Documentation = [Undocumented];
2453 def MSInheritance : InheritableAttr {
2454 let LangOpts = [MicrosoftExt];
2455 let Args = [DefaultBoolArgument<"BestCase", 1>];
2456 let Spellings = [Keyword<"__single_inheritance">,
2457 Keyword<"__multiple_inheritance">,
2458 Keyword<"__virtual_inheritance">,
2459 Keyword<"__unspecified_inheritance">];
2460 let AdditionalMembers = [{
2461 static bool hasVBPtrOffsetField(Spelling Inheritance) {
2462 return Inheritance == Keyword_unspecified_inheritance;
2465 // Only member pointers to functions need a this adjustment, since it can be
2466 // combined with the field offset for data pointers.
2467 static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
2468 return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
2471 static bool hasVBTableOffsetField(Spelling Inheritance) {
2472 return Inheritance >= Keyword_virtual_inheritance;
2475 static bool hasOnlyOneField(bool IsMemberFunction,
2476 Spelling Inheritance) {
2477 if (IsMemberFunction)
2478 return Inheritance <= Keyword_single_inheritance;
2479 return Inheritance <= Keyword_multiple_inheritance;
2482 let Documentation = [MSInheritanceDocs];
2485 def MSVtorDisp : InheritableAttr {
2486 // This attribute has no spellings as it is only ever created implicitly.
2488 let Args = [UnsignedArgument<"vdm">];
2489 let SemaHandler = 0;
2491 let AdditionalMembers = [{
2498 Mode getVtorDispMode() const { return Mode(vdm); }
2500 let Documentation = [Undocumented];
2503 def InitSeg : Attr {
2504 let Spellings = [Pragma<"", "init_seg">];
2505 let Args = [StringArgument<"Section">];
2506 let SemaHandler = 0;
2507 let Documentation = [InitSegDocs];
2508 let AdditionalMembers = [{
2509 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2510 OS << '(' << getSection() << ')';
2515 def LoopHint : Attr {
2516 /// #pragma clang loop <option> directive
2517 /// vectorize: vectorizes loop operations if State == Enable.
2518 /// vectorize_width: vectorize loop operations with width 'Value'.
2519 /// interleave: interleave multiple loop iterations if State == Enable.
2520 /// interleave_count: interleaves 'Value' loop interations.
2521 /// unroll: fully unroll loop if State == Enable.
2522 /// unroll_count: unrolls loop 'Value' times.
2523 /// distribute: attempt to distribute loop if State == Enable
2525 /// #pragma unroll <argument> directive
2526 /// <no arg>: fully unrolls loop.
2527 /// boolean: fully unrolls loop if State == Enable.
2528 /// expression: unrolls loop 'Value' times.
2530 let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">,
2531 Pragma<"", "nounroll">];
2533 /// State of the loop optimization specified by the spelling.
2534 let Args = [EnumArgument<"Option", "OptionType",
2535 ["vectorize", "vectorize_width", "interleave", "interleave_count",
2536 "unroll", "unroll_count", "distribute"],
2537 ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
2538 "Unroll", "UnrollCount", "Distribute"]>,
2539 EnumArgument<"State", "LoopHintState",
2540 ["enable", "disable", "numeric", "assume_safety", "full"],
2541 ["Enable", "Disable", "Numeric", "AssumeSafety", "Full"]>,
2542 ExprArgument<"Value">];
2544 let AdditionalMembers = [{
2545 static const char *getOptionName(int Option) {
2547 case Vectorize: return "vectorize";
2548 case VectorizeWidth: return "vectorize_width";
2549 case Interleave: return "interleave";
2550 case InterleaveCount: return "interleave_count";
2551 case Unroll: return "unroll";
2552 case UnrollCount: return "unroll_count";
2553 case Distribute: return "distribute";
2555 llvm_unreachable("Unhandled LoopHint option.");
2558 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2559 unsigned SpellingIndex = getSpellingListIndex();
2560 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
2561 // "nounroll" is already emitted as the pragma name.
2562 if (SpellingIndex == Pragma_nounroll)
2564 else if (SpellingIndex == Pragma_unroll) {
2565 OS << getValueString(Policy);
2569 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2570 OS << getOptionName(option) << getValueString(Policy);
2573 // Return a string containing the loop hint argument including the
2574 // enclosing parentheses.
2575 std::string getValueString(const PrintingPolicy &Policy) const {
2576 std::string ValueName;
2577 llvm::raw_string_ostream OS(ValueName);
2579 if (state == Numeric)
2580 value->printPretty(OS, nullptr, Policy);
2581 else if (state == Enable)
2583 else if (state == Full)
2585 else if (state == AssumeSafety)
2586 OS << "assume_safety";
2593 // Return a string suitable for identifying this attribute in diagnostics.
2594 std::string getDiagnosticName(const PrintingPolicy &Policy) const {
2595 unsigned SpellingIndex = getSpellingListIndex();
2596 if (SpellingIndex == Pragma_nounroll)
2597 return "#pragma nounroll";
2598 else if (SpellingIndex == Pragma_unroll)
2599 return "#pragma unroll" + (option == UnrollCount ? getValueString(Policy) : "");
2601 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2602 return getOptionName(option) + getValueString(Policy);
2606 let Documentation = [LoopHintDocs, UnrollHintDocs];
2609 def CapturedRecord : InheritableAttr {
2610 // This attribute has no spellings as it is only ever created implicitly.
2612 let SemaHandler = 0;
2613 let Documentation = [Undocumented];
2616 def OMPThreadPrivateDecl : InheritableAttr {
2617 // This attribute has no spellings as it is only ever created implicitly.
2619 let SemaHandler = 0;
2620 let Documentation = [Undocumented];
2623 def OMPCaptureNoInit : InheritableAttr {
2624 // This attribute has no spellings as it is only ever created implicitly.
2626 let SemaHandler = 0;
2627 let Documentation = [Undocumented];
2630 def OMPDeclareSimdDecl : Attr {
2631 let Spellings = [Pragma<"omp", "declare simd">];
2632 let Subjects = SubjectList<[Function]>;
2633 let SemaHandler = 0;
2634 let HasCustomParsing = 1;
2635 let Documentation = [OMPDeclareSimdDocs];
2637 EnumArgument<"BranchState", "BranchStateTy",
2638 [ "", "inbranch", "notinbranch" ],
2639 [ "BS_Undefined", "BS_Inbranch", "BS_Notinbranch" ]>,
2640 ExprArgument<"Simdlen">, VariadicExprArgument<"Uniforms">,
2641 VariadicExprArgument<"Aligneds">, VariadicExprArgument<"Alignments">,
2642 VariadicExprArgument<"Linears">, VariadicUnsignedArgument<"Modifiers">,
2643 VariadicExprArgument<"Steps">
2645 let AdditionalMembers = [{
2646 void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
2648 if (getBranchState() != BS_Undefined)
2649 OS << ConvertBranchStateTyToStr(getBranchState()) << " ";
2650 if (auto *E = getSimdlen()) {
2652 E->printPretty(OS, nullptr, Policy);
2655 if (uniforms_size() > 0) {
2657 StringRef Sep = "(";
2658 for (auto *E : uniforms()) {
2660 E->printPretty(OS, nullptr, Policy);
2665 alignments_iterator NI = alignments_begin();
2666 for (auto *E : aligneds()) {
2668 E->printPretty(OS, nullptr, Policy);
2671 (*NI)->printPretty(OS, nullptr, Policy);
2676 steps_iterator I = steps_begin();
2677 modifiers_iterator MI = modifiers_begin();
2678 for (auto *E : linears()) {
2680 if (*MI != OMPC_LINEAR_unknown)
2681 OS << getOpenMPSimpleClauseTypeName(OMPC_linear, *MI) << "(";
2682 E->printPretty(OS, nullptr, Policy);
2683 if (*MI != OMPC_LINEAR_unknown)
2687 (*I)->printPretty(OS, nullptr, Policy);
2697 def OMPDeclareTargetDecl : Attr {
2698 let Spellings = [Pragma<"omp", "declare target">];
2699 let SemaHandler = 0;
2700 let Documentation = [OMPDeclareTargetDocs];
2702 EnumArgument<"MapType", "MapTypeTy",
2704 [ "MT_To", "MT_Link" ]>
2706 let AdditionalMembers = [{
2707 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2708 // Use fake syntax because it is for testing and debugging purpose only.
2709 if (getMapType() != MT_To)
2710 OS << ConvertMapTypeTyToStr(getMapType()) << " ";
2715 def InternalLinkage : InheritableAttr {
2716 let Spellings = [GNU<"internal_linkage">, CXX11<"clang", "internal_linkage">];
2717 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
2718 let Documentation = [InternalLinkageDocs];