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 NonBitField : SubsetSubject<Field,
86 [{!S->isBitField()}]>;
88 def ObjCInstanceMethod : SubsetSubject<ObjCMethod,
89 [{S->isInstanceMethod()}]>;
91 def ObjCInterfaceDeclInitMethod : SubsetSubject<ObjCMethod,
92 [{S->getMethodFamily() == OMF_init &&
93 (isa<ObjCInterfaceDecl>(S->getDeclContext()) ||
94 (isa<ObjCCategoryDecl>(S->getDeclContext()) &&
95 cast<ObjCCategoryDecl>(S->getDeclContext())->IsClassExtension()))}]>;
97 def Struct : SubsetSubject<Record,
100 def TLSVar : SubsetSubject<Var,
101 [{S->getTLSKind() != 0}]>;
103 def SharedVar : SubsetSubject<Var,
104 [{S->hasGlobalStorage() && !S->getTLSKind()}]>;
106 def GlobalVar : SubsetSubject<Var,
107 [{S->hasGlobalStorage()}]>;
109 // FIXME: this hack is needed because DeclNodes.td defines the base Decl node
110 // type to be a class, not a definition. This makes it impossible to create an
111 // attribute subject which accepts a Decl. Normally, this is not a problem,
112 // because the attribute can have no Subjects clause to accomplish this. But in
113 // the case of a SubsetSubject, there's no way to express it without this hack.
114 def DeclBase : AttrSubject;
115 def FunctionLike : SubsetSubject<DeclBase,
116 [{S->getFunctionType(false) != NULL}]>;
118 // HasFunctionProto is a more strict version of FunctionLike, so it should
119 // never be specified in a Subjects list along with FunctionLike (due to the
120 // inclusive nature of subject testing).
121 def HasFunctionProto : SubsetSubject<DeclBase,
122 [{(S->getFunctionType(true) != NULL &&
123 isa<FunctionProtoType>(S->getFunctionType())) ||
124 isa<ObjCMethodDecl>(S) ||
125 isa<BlockDecl>(S)}]>;
127 // A single argument to an attribute
128 class Argument<string name, bit optional> {
130 bit Optional = optional;
133 class BoolArgument<string name, bit opt = 0> : Argument<name, opt>;
134 class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>;
135 class IntArgument<string name, bit opt = 0> : Argument<name, opt>;
136 class StringArgument<string name, bit opt = 0> : Argument<name, opt>;
137 class ExprArgument<string name, bit opt = 0> : Argument<name, opt>;
138 class FunctionArgument<string name, bit opt = 0> : Argument<name, opt>;
139 class TypeArgument<string name, bit opt = 0> : Argument<name, opt>;
140 class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>;
141 class VariadicUnsignedArgument<string name> : Argument<name, 1>;
142 class VariadicExprArgument<string name> : Argument<name, 1>;
144 // A version of the form major.minor[.subminor].
145 class VersionArgument<string name, bit opt = 0> : Argument<name, opt>;
147 // This one's a doozy, so it gets its own special type
148 // It can be an unsigned integer, or a type. Either can
150 class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>;
152 // A bool argument with a default value
153 class DefaultBoolArgument<string name, bit default> : BoolArgument<name, 1> {
154 bit Default = default;
157 // An integer argument with a default value
158 class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
159 int Default = default;
162 // This argument is more complex, it includes the enumerator type name,
163 // a list of strings to accept, and a list of enumerators to map them to.
164 class EnumArgument<string name, string type, list<string> values,
165 list<string> enums, bit opt = 0> : Argument<name, opt> {
167 list<string> Values = values;
168 list<string> Enums = enums;
171 // FIXME: There should be a VariadicArgument type that takes any other type
172 // of argument and generates the appropriate type.
173 class VariadicEnumArgument<string name, string type, list<string> values,
174 list<string> enums> : Argument<name, 1> {
176 list<string> Values = values;
177 list<string> Enums = enums;
180 // This handles one spelling of an attribute.
181 class Spelling<string name, string variety> {
183 string Variety = variety;
187 class GNU<string name> : Spelling<name, "GNU">;
188 class Declspec<string name> : Spelling<name, "Declspec">;
189 class CXX11<string namespace, string name> : Spelling<name, "CXX11"> {
190 string Namespace = namespace;
192 class Keyword<string name> : Spelling<name, "Keyword">;
193 class Pragma<string namespace, string name> : Spelling<name, "Pragma"> {
194 string Namespace = namespace;
197 // The GCC spelling implies GNU<name, "GNU"> and CXX11<"gnu", name> and also
198 // sets KnownToGCC to 1. This spelling should be used for any GCC-compatible
200 class GCC<string name> : Spelling<name, "GCC"> {
204 class Accessor<string name, list<Spelling> spellings> {
206 list<Spelling> Spellings = spellings;
209 class SubjectDiag<bit warn> {
212 def WarnDiag : SubjectDiag<1>;
213 def ErrorDiag : SubjectDiag<0>;
215 class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag,
216 string customDiag = ""> {
217 list<AttrSubject> Subjects = subjects;
218 SubjectDiag Diag = diag;
219 string CustomDiag = customDiag;
222 class LangOpt<string name> {
225 def MicrosoftExt : LangOpt<"MicrosoftExt">;
226 def Borland : LangOpt<"Borland">;
227 def CUDA : LangOpt<"CUDA">;
229 // Defines targets for target-specific attributes. The list of strings should
230 // specify architectures for which the target applies, based off the ArchType
231 // enumeration in Triple.h.
232 class TargetArch<list<string> arches> {
233 list<string> Arches = arches;
236 def TargetARM : TargetArch<["arm", "thumb"]>;
237 def TargetMSP430 : TargetArch<["msp430"]>;
238 def TargetX86 : TargetArch<["x86"]>;
239 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
240 let OSes = ["Win32"];
242 def TargetMips : TargetArch<["mips", "mipsel"]>;
245 // The various ways in which an attribute can be spelled in source
246 list<Spelling> Spellings;
247 // The things to which an attribute can appertain
248 SubjectList Subjects;
249 // The arguments allowed on an attribute
250 list<Argument> Args = [];
251 // Accessors which should be generated for the attribute.
252 list<Accessor> Accessors = [];
253 // Set to true for attributes with arguments which require delayed parsing.
255 // Set to false to prevent an attribute from being propagated from a template
256 // to the instantiation.
258 // Set to true for attributes which must be instantiated within templates
259 bit TemplateDependent = 0;
260 // Set to true for attributes that have a corresponding AST node.
262 // Set to true for attributes which have handler in Sema.
264 // Set to true for attributes that are completely ignored.
266 // Set to true if the attribute's parsing does not match its semantic
267 // content. Eg) It parses 3 args, but semantically takes 4 args. Opts out of
268 // common attribute error checking.
269 bit HasCustomParsing = 0;
270 // Set to true if all of the attribute's arguments should be parsed in an
271 // unevaluated context.
272 bit ParseArgumentsAsUnevaluated = 0;
273 // Set to true if this attribute can be duplicated on a subject when merging
274 // attributes. By default, attributes are not merged.
275 bit DuplicatesAllowedWhileMerging = 0;
276 // Lists language options, one of which is required to be true for the
277 // attribute to be applicable. If empty, no language options are required.
278 list<LangOpt> LangOpts = [];
279 // Any additional text that should be included verbatim in the class.
280 code AdditionalMembers = [{}];
281 // Any documentation that should be associated with the attribute. Since an
282 // attribute may be documented under multiple categories, more than one
283 // Documentation entry may be listed.
284 list<Documentation> Documentation;
287 /// A type attribute is not processed on a declaration or a statement.
288 class TypeAttr : Attr {
289 // By default, type attributes do not get an AST node.
293 /// An inheritable attribute is inherited by later redeclarations.
294 class InheritableAttr : Attr;
296 /// A target-specific attribute. This class is meant to be used as a mixin
297 /// with InheritableAttr or Attr depending on the attribute's needs.
298 class TargetSpecificAttr<TargetArch target> {
299 TargetArch Target = target;
300 // Attributes are generally required to have unique spellings for their names
301 // so that the parser can determine what kind of attribute it has parsed.
302 // However, target-specific attributes are special in that the attribute only
303 // "exists" for a given target. So two target-specific attributes can share
304 // the same name when they exist in different targets. To support this, a
305 // Kind can be explicitly specified for a target-specific attribute. This
306 // corresponds to the AttributeList::AT_* enum that is generated and it
307 // should contain a shared value between the attributes.
309 // Target-specific attributes which use this feature should ensure that the
310 // spellings match exactly betweeen the attributes, and if the arguments or
311 // subjects differ, should specify HasCustomParsing = 1 and implement their
312 // own parsing and semantic handling requirements as-needed.
316 /// An inheritable parameter attribute is inherited by later
317 /// redeclarations, even when it's written on a parameter.
318 class InheritableParamAttr : InheritableAttr;
320 /// An ignored attribute, which we parse but discard with no checking.
321 class IgnoredAttr : Attr {
325 let Documentation = [Undocumented];
329 // Attributes begin here
332 def AddressSpace : TypeAttr {
333 let Spellings = [GNU<"address_space">];
334 let Args = [IntArgument<"AddressSpace">];
335 let Documentation = [Undocumented];
339 let Spellings = [GCC<"alias">];
340 let Args = [StringArgument<"Aliasee">];
341 let Documentation = [Undocumented];
344 def Aligned : InheritableAttr {
345 let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">,
346 Keyword<"_Alignas">];
347 // let Subjects = SubjectList<[NonBitField, NormalVar, Tag]>;
348 let Args = [AlignedArgument<"Alignment", 1>];
349 let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
350 Accessor<"isC11", [Keyword<"_Alignas">]>,
351 Accessor<"isAlignas", [Keyword<"alignas">,
352 Keyword<"_Alignas">]>,
353 Accessor<"isDeclspec",[Declspec<"align">]>];
354 let Documentation = [Undocumented];
357 def AlignMac68k : InheritableAttr {
358 // This attribute has no spellings as it is only ever created implicitly.
361 let Documentation = [Undocumented];
364 def AlwaysInline : InheritableAttr {
365 let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
366 let Subjects = SubjectList<[Function]>;
367 let Documentation = [Undocumented];
370 def TLSModel : InheritableAttr {
371 let Spellings = [GCC<"tls_model">];
372 let Subjects = SubjectList<[TLSVar], ErrorDiag, "ExpectedTLSVar">;
373 let Args = [StringArgument<"Model">];
374 let Documentation = [TLSModelDocs];
377 def AnalyzerNoReturn : InheritableAttr {
378 let Spellings = [GNU<"analyzer_noreturn">];
379 let Documentation = [Undocumented];
382 def Annotate : InheritableParamAttr {
383 let Spellings = [GNU<"annotate">];
384 let Args = [StringArgument<"Annotation">];
385 let Documentation = [Undocumented];
388 def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> {
389 // NOTE: If you add any additional spellings, MSP430Interrupt's spellings
391 let Spellings = [GNU<"interrupt">];
392 let Args = [EnumArgument<"Interrupt", "InterruptType",
393 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
394 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
396 let ParseKind = "Interrupt";
397 let HasCustomParsing = 1;
398 let Documentation = [ARMInterruptDocs];
401 def AsmLabel : InheritableAttr {
402 let Spellings = [Keyword<"asm">, Keyword<"__asm__">];
403 let Args = [StringArgument<"Label">];
405 let Documentation = [Undocumented];
408 def Availability : InheritableAttr {
409 let Spellings = [GNU<"availability">];
410 let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
411 VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
412 BoolArgument<"unavailable">, StringArgument<"message">];
413 let AdditionalMembers =
414 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
415 return llvm::StringSwitch<llvm::StringRef>(Platform)
417 .Case("macosx", "OS X")
418 .Default(llvm::StringRef());
420 let HasCustomParsing = 1;
421 let DuplicatesAllowedWhileMerging = 1;
422 // let Subjects = SubjectList<[Named]>;
423 let Documentation = [AvailabilityDocs];
426 def Blocks : InheritableAttr {
427 let Spellings = [GNU<"blocks">];
428 let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
429 let Documentation = [Undocumented];
432 def Bounded : IgnoredAttr {
433 let Spellings = [GNU<"bounded">];
436 def CarriesDependency : InheritableParamAttr {
437 let Spellings = [GNU<"carries_dependency">, CXX11<"","carries_dependency">];
438 let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>;
439 let Documentation = [CarriesDependencyDocs];
442 def CDecl : InheritableAttr {
443 let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">];
444 // let Subjects = [Function, ObjCMethod];
445 let Documentation = [Undocumented];
448 // cf_audited_transfer indicates that the given function has been
449 // audited and has been marked with the appropriate cf_consumed and
450 // cf_returns_retained attributes. It is generally applied by
451 // '#pragma clang arc_cf_code_audited' rather than explicitly.
452 def CFAuditedTransfer : InheritableAttr {
453 let Spellings = [GNU<"cf_audited_transfer">];
454 let Subjects = SubjectList<[Function], ErrorDiag>;
455 let Documentation = [Undocumented];
458 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
459 // It indicates that the function has unknown or unautomatable
460 // transfer semantics.
461 def CFUnknownTransfer : InheritableAttr {
462 let Spellings = [GNU<"cf_unknown_transfer">];
463 let Subjects = SubjectList<[Function], ErrorDiag>;
464 let Documentation = [Undocumented];
467 def CFReturnsRetained : InheritableAttr {
468 let Spellings = [GNU<"cf_returns_retained">];
469 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
470 let Documentation = [Undocumented];
473 def CFReturnsNotRetained : InheritableAttr {
474 let Spellings = [GNU<"cf_returns_not_retained">];
475 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
476 let Documentation = [Undocumented];
479 def CFConsumed : InheritableParamAttr {
480 let Spellings = [GNU<"cf_consumed">];
481 let Subjects = SubjectList<[ParmVar]>;
482 let Documentation = [Undocumented];
485 def Cleanup : InheritableAttr {
486 let Spellings = [GCC<"cleanup">];
487 let Args = [FunctionArgument<"FunctionDecl">];
488 let Subjects = SubjectList<[Var]>;
489 let Documentation = [Undocumented];
492 def Cold : InheritableAttr {
493 let Spellings = [GCC<"cold">];
494 let Subjects = SubjectList<[Function]>;
495 let Documentation = [Undocumented];
498 def Common : InheritableAttr {
499 let Spellings = [GCC<"common">];
500 let Subjects = SubjectList<[Var]>;
501 let Documentation = [Undocumented];
504 def Const : InheritableAttr {
505 let Spellings = [GCC<"const">, GCC<"__const">];
506 let Documentation = [Undocumented];
509 def Constructor : InheritableAttr {
510 let Spellings = [GCC<"constructor">];
511 let Args = [DefaultIntArgument<"Priority", 65535>];
512 let Subjects = SubjectList<[Function]>;
513 let Documentation = [Undocumented];
516 def CUDAConstant : InheritableAttr {
517 let Spellings = [GNU<"constant">];
518 let Subjects = SubjectList<[Var]>;
519 let LangOpts = [CUDA];
520 let Documentation = [Undocumented];
523 def CUDADevice : InheritableAttr {
524 let Spellings = [GNU<"device">];
525 let Subjects = SubjectList<[Function, Var]>;
526 let LangOpts = [CUDA];
527 let Documentation = [Undocumented];
530 def CUDAGlobal : InheritableAttr {
531 let Spellings = [GNU<"global">];
532 let Subjects = SubjectList<[Function]>;
533 let LangOpts = [CUDA];
534 let Documentation = [Undocumented];
537 def CUDAHost : InheritableAttr {
538 let Spellings = [GNU<"host">];
539 let Subjects = SubjectList<[Function]>;
540 let LangOpts = [CUDA];
541 let Documentation = [Undocumented];
544 def CUDALaunchBounds : InheritableAttr {
545 let Spellings = [GNU<"launch_bounds">];
546 let Args = [IntArgument<"MaxThreads">, DefaultIntArgument<"MinBlocks", 0>];
547 let LangOpts = [CUDA];
548 let Subjects = SubjectList<[ObjCMethod, FunctionLike], WarnDiag,
549 "ExpectedFunctionOrMethod">;
550 // An AST node is created for this attribute, but is not used by other parts
551 // of the compiler. However, this node needs to exist in the AST because
552 // non-LLVM backends may be relying on the attribute's presence.
553 let Documentation = [Undocumented];
556 def CUDAShared : InheritableAttr {
557 let Spellings = [GNU<"shared">];
558 let Subjects = SubjectList<[Var]>;
559 let LangOpts = [CUDA];
560 let Documentation = [Undocumented];
563 def C11NoReturn : InheritableAttr {
564 let Spellings = [Keyword<"_Noreturn">];
565 let Subjects = SubjectList<[Function], ErrorDiag>;
567 let Documentation = [C11NoReturnDocs];
570 def CXX11NoReturn : InheritableAttr {
571 let Spellings = [CXX11<"","noreturn">];
572 let Subjects = SubjectList<[Function], ErrorDiag>;
573 let Documentation = [CXX11NoReturnDocs];
576 def OpenCLKernel : InheritableAttr {
577 let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
578 let Subjects = SubjectList<[Function], ErrorDiag>;
579 let Documentation = [Undocumented];
582 // This attribute is both a type attribute, and a declaration attribute (for
583 // parameter variables).
584 def OpenCLImageAccess : Attr {
585 let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
586 Keyword<"__write_only">, Keyword<"write_only">,
587 Keyword<"__read_write">, Keyword<"read_write">];
588 let Subjects = SubjectList<[ParmVar], ErrorDiag>;
589 let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
590 Keyword<"read_only">]>,
591 Accessor<"isReadWrite", [Keyword<"__read_write">,
592 Keyword<"read_write">]>,
593 Accessor<"isWriteOnly", [Keyword<"__write_only">,
594 Keyword<"write_only">]>];
595 let Documentation = [Undocumented];
598 def OpenCLPrivateAddressSpace : TypeAttr {
599 let Spellings = [Keyword<"__private">, Keyword<"private">];
600 let Documentation = [Undocumented];
603 def OpenCLGlobalAddressSpace : TypeAttr {
604 let Spellings = [Keyword<"__global">, Keyword<"global">];
605 let Documentation = [Undocumented];
608 def OpenCLLocalAddressSpace : TypeAttr {
609 let Spellings = [Keyword<"__local">, Keyword<"local">];
610 let Documentation = [Undocumented];
613 def OpenCLConstantAddressSpace : TypeAttr {
614 let Spellings = [Keyword<"__constant">, Keyword<"constant">];
615 let Documentation = [Undocumented];
618 def Deprecated : InheritableAttr {
619 let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
620 CXX11<"","deprecated">];
621 let Args = [StringArgument<"Message", 1>];
622 let Documentation = [Undocumented];
625 def Destructor : InheritableAttr {
626 let Spellings = [GCC<"destructor">];
627 let Args = [DefaultIntArgument<"Priority", 65535>];
628 let Subjects = SubjectList<[Function]>;
629 let Documentation = [Undocumented];
632 def EnableIf : InheritableAttr {
633 let Spellings = [GNU<"enable_if">];
634 let Subjects = SubjectList<[Function]>;
635 let Args = [ExprArgument<"Cond">, StringArgument<"Message">];
636 let TemplateDependent = 1;
637 let Documentation = [EnableIfDocs];
640 def ExtVectorType : Attr {
641 let Spellings = [GNU<"ext_vector_type">];
642 let Subjects = SubjectList<[TypedefName], ErrorDiag>;
643 let Args = [ExprArgument<"NumElements">];
645 let Documentation = [Undocumented];
648 def FallThrough : Attr {
649 let Spellings = [CXX11<"clang", "fallthrough">];
650 // let Subjects = [NullStmt];
651 let Documentation = [FallthroughDocs];
654 def FastCall : InheritableAttr {
655 let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
656 Keyword<"_fastcall">];
657 // let Subjects = [Function, ObjCMethod];
658 let Documentation = [Undocumented];
661 def Final : InheritableAttr {
662 let Spellings = [Keyword<"final">, Keyword<"sealed">];
663 let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
665 let Documentation = [Undocumented];
668 def MinSize : InheritableAttr {
669 let Spellings = [GNU<"minsize">];
670 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
671 let Documentation = [Undocumented];
674 def Flatten : InheritableAttr {
675 let Spellings = [GCC<"flatten">];
676 let Subjects = SubjectList<[Function], ErrorDiag>;
677 let Documentation = [FlattenDocs];
680 def Format : InheritableAttr {
681 let Spellings = [GCC<"format">];
682 let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
683 IntArgument<"FirstArg">];
684 let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto], WarnDiag,
686 let Documentation = [FormatDocs];
689 def FormatArg : InheritableAttr {
690 let Spellings = [GCC<"format_arg">];
691 let Args = [IntArgument<"FormatIdx">];
692 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto], WarnDiag,
694 let Documentation = [Undocumented];
697 def GNUInline : InheritableAttr {
698 let Spellings = [GCC<"gnu_inline">];
699 let Subjects = SubjectList<[Function]>;
700 let Documentation = [Undocumented];
703 def Hot : InheritableAttr {
704 let Spellings = [GCC<"hot">];
705 let Subjects = SubjectList<[Function]>;
706 // An AST node is created for this attribute, but not actually used beyond
707 // semantic checking for mutual exclusion with the Cold attribute.
708 let Documentation = [Undocumented];
711 def IBAction : InheritableAttr {
712 let Spellings = [GNU<"ibaction">];
713 let Subjects = SubjectList<[ObjCInstanceMethod], WarnDiag,
714 "ExpectedObjCInstanceMethod">;
715 // An AST node is created for this attribute, but is not used by other parts
716 // of the compiler. However, this node needs to exist in the AST because
717 // external tools rely on it.
718 let Documentation = [Undocumented];
721 def IBOutlet : InheritableAttr {
722 let Spellings = [GNU<"iboutlet">];
723 // let Subjects = [ObjCIvar, ObjCProperty];
724 let Documentation = [Undocumented];
727 def IBOutletCollection : InheritableAttr {
728 let Spellings = [GNU<"iboutletcollection">];
729 let Args = [TypeArgument<"Interface", 1>];
730 // let Subjects = [ObjCIvar, ObjCProperty];
731 let Documentation = [Undocumented];
734 def Malloc : InheritableAttr {
735 let Spellings = [GCC<"malloc">];
736 // let Subjects = [Function];
737 let Documentation = [Undocumented];
740 def MaxFieldAlignment : InheritableAttr {
741 // This attribute has no spellings as it is only ever created implicitly.
743 let Args = [UnsignedArgument<"Alignment">];
745 let Documentation = [Undocumented];
748 def MayAlias : InheritableAttr {
749 // FIXME: this is a type attribute in GCC, but a declaration attribute here.
750 let Spellings = [GCC<"may_alias">];
751 let Documentation = [Undocumented];
754 def MSABI : InheritableAttr {
755 let Spellings = [GCC<"ms_abi">];
756 // let Subjects = [Function, ObjCMethod];
757 let Documentation = [Undocumented];
760 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
761 // NOTE: If you add any additional spellings, ARMInterrupt's spellings must
763 let Spellings = [GNU<"interrupt">];
764 let Args = [UnsignedArgument<"Number">];
765 let ParseKind = "Interrupt";
766 let HasCustomParsing = 1;
767 let Documentation = [Undocumented];
770 def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
771 let Spellings = [GCC<"mips16">];
772 let Subjects = SubjectList<[Function], ErrorDiag>;
773 let Documentation = [Undocumented];
777 let Spellings = [GCC<"mode">];
778 let Args = [IdentifierArgument<"Mode">];
779 let Documentation = [Undocumented];
782 def Naked : InheritableAttr {
783 let Spellings = [GCC<"naked">, Declspec<"naked">];
784 let Subjects = SubjectList<[Function]>;
785 let Documentation = [Undocumented];
788 def NeonPolyVectorType : TypeAttr {
789 let Spellings = [GNU<"neon_polyvector_type">];
790 let Args = [IntArgument<"NumElements">];
791 let Documentation = [Undocumented];
794 def NeonVectorType : TypeAttr {
795 let Spellings = [GNU<"neon_vector_type">];
796 let Args = [IntArgument<"NumElements">];
797 let Documentation = [Undocumented];
800 def ReturnsTwice : InheritableAttr {
801 let Spellings = [GCC<"returns_twice">];
802 let Subjects = SubjectList<[Function]>;
803 let Documentation = [Undocumented];
806 def NoCommon : InheritableAttr {
807 let Spellings = [GCC<"nocommon">];
808 let Subjects = SubjectList<[Var]>;
809 let Documentation = [Undocumented];
812 def NoDebug : InheritableAttr {
813 let Spellings = [GNU<"nodebug">];
814 let Documentation = [Undocumented];
817 def NoDuplicate : InheritableAttr {
818 let Spellings = [GNU<"noduplicate">, CXX11<"clang", "noduplicate">];
819 let Subjects = SubjectList<[Function]>;
820 let Documentation = [NoDuplicateDocs];
823 def NoInline : InheritableAttr {
824 let Spellings = [GCC<"noinline">, Declspec<"noinline">];
825 let Subjects = SubjectList<[Function]>;
826 let Documentation = [Undocumented];
829 def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
830 let Spellings = [GCC<"nomips16">];
831 let Subjects = SubjectList<[Function], ErrorDiag>;
832 let Documentation = [Undocumented];
835 def NoSplitStack : InheritableAttr {
836 let Spellings = [GCC<"no_split_stack">];
837 let Subjects = SubjectList<[Function], ErrorDiag>;
838 let Documentation = [NoSplitStackDocs];
841 def NonNull : InheritableAttr {
842 let Spellings = [GCC<"nonnull">];
843 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
844 "ExpectedFunctionMethodOrParameter">;
845 let Args = [VariadicUnsignedArgument<"Args">];
846 let AdditionalMembers =
847 [{bool isNonNull(unsigned idx) const {
848 for (const auto &V : args())
853 let Documentation = [Undocumented];
856 def ReturnsNonNull : InheritableAttr {
857 let Spellings = [GCC<"returns_nonnull">];
858 let Subjects = SubjectList<[ObjCMethod, Function], WarnDiag,
859 "ExpectedFunctionOrMethod">;
860 let Documentation = [Undocumented];
863 def NoReturn : InheritableAttr {
864 let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
865 // FIXME: Does GCC allow this on the function instead?
866 let Documentation = [Undocumented];
869 def NoInstrumentFunction : InheritableAttr {
870 let Spellings = [GCC<"no_instrument_function">];
871 let Subjects = SubjectList<[Function]>;
872 let Documentation = [Undocumented];
875 def NoThrow : InheritableAttr {
876 let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
877 let Documentation = [Undocumented];
880 def ObjCBridge : InheritableAttr {
881 let Spellings = [GNU<"objc_bridge">];
882 let Subjects = SubjectList<[Record], ErrorDiag>;
883 let Args = [IdentifierArgument<"BridgedType">];
884 let Documentation = [Undocumented];
887 def ObjCBridgeMutable : InheritableAttr {
888 let Spellings = [GNU<"objc_bridge_mutable">];
889 let Subjects = SubjectList<[Record], ErrorDiag>;
890 let Args = [IdentifierArgument<"BridgedType">];
891 let Documentation = [Undocumented];
894 def ObjCBridgeRelated : InheritableAttr {
895 let Spellings = [GNU<"objc_bridge_related">];
896 let Subjects = SubjectList<[Record], ErrorDiag>;
897 let Args = [IdentifierArgument<"RelatedClass">,
898 IdentifierArgument<"ClassMethod">,
899 IdentifierArgument<"InstanceMethod">];
900 let HasCustomParsing = 1;
901 let Documentation = [Undocumented];
904 def NSReturnsRetained : InheritableAttr {
905 let Spellings = [GNU<"ns_returns_retained">];
906 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
907 let Documentation = [Undocumented];
910 def NSReturnsNotRetained : InheritableAttr {
911 let Spellings = [GNU<"ns_returns_not_retained">];
912 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
913 let Documentation = [Undocumented];
916 def NSReturnsAutoreleased : InheritableAttr {
917 let Spellings = [GNU<"ns_returns_autoreleased">];
918 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
919 let Documentation = [Undocumented];
922 def NSConsumesSelf : InheritableAttr {
923 let Spellings = [GNU<"ns_consumes_self">];
924 let Subjects = SubjectList<[ObjCMethod]>;
925 let Documentation = [Undocumented];
928 def NSConsumed : InheritableParamAttr {
929 let Spellings = [GNU<"ns_consumed">];
930 let Subjects = SubjectList<[ParmVar]>;
931 let Documentation = [Undocumented];
934 def ObjCException : InheritableAttr {
935 let Spellings = [GNU<"objc_exception">];
936 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
937 let Documentation = [Undocumented];
940 def ObjCMethodFamily : InheritableAttr {
941 let Spellings = [GNU<"objc_method_family">];
942 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
943 let Args = [EnumArgument<"Family", "FamilyKind",
944 ["none", "alloc", "copy", "init", "mutableCopy", "new"],
945 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
946 "OMF_mutableCopy", "OMF_new"]>];
947 let Documentation = [ObjCMethodFamilyDocs];
950 def ObjCNSObject : InheritableAttr {
951 let Spellings = [GNU<"NSObject">];
952 let Documentation = [Undocumented];
955 def ObjCPreciseLifetime : InheritableAttr {
956 let Spellings = [GNU<"objc_precise_lifetime">];
957 let Subjects = SubjectList<[Var], ErrorDiag>;
958 let Documentation = [Undocumented];
961 def ObjCReturnsInnerPointer : InheritableAttr {
962 let Spellings = [GNU<"objc_returns_inner_pointer">];
963 let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
964 let Documentation = [Undocumented];
967 def ObjCRequiresSuper : InheritableAttr {
968 let Spellings = [GNU<"objc_requires_super">];
969 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
970 let Documentation = [ObjCRequiresSuperDocs];
973 def ObjCRootClass : InheritableAttr {
974 let Spellings = [GNU<"objc_root_class">];
975 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
976 let Documentation = [Undocumented];
979 def ObjCExplicitProtocolImpl : InheritableAttr {
980 let Spellings = [GNU<"objc_protocol_requires_explicit_implementation">];
981 let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
982 let Documentation = [Undocumented];
985 def ObjCDesignatedInitializer : Attr {
986 let Spellings = [GNU<"objc_designated_initializer">];
987 let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag,
988 "ExpectedObjCInterfaceDeclInitMethod">;
989 let Documentation = [Undocumented];
992 def ObjCRuntimeName : Attr {
993 let Spellings = [GNU<"objc_runtime_name">];
994 let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
995 let Args = [StringArgument<"MetadataName">];
996 let Documentation = [ObjCRuntimeNameDocs];
999 def OptimizeNone : InheritableAttr {
1000 let Spellings = [GNU<"optnone">, CXX11<"clang", "optnone">];
1001 let Subjects = SubjectList<[Function, ObjCMethod]>;
1002 let Documentation = [OptnoneDocs];
1005 def Overloadable : Attr {
1006 let Spellings = [GNU<"overloadable">];
1007 let Subjects = SubjectList<[Function], ErrorDiag>;
1008 let Documentation = [OverloadableDocs];
1011 def Override : InheritableAttr {
1012 let Spellings = [Keyword<"override">];
1013 let SemaHandler = 0;
1014 let Documentation = [Undocumented];
1017 def Ownership : InheritableAttr {
1018 let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
1019 GNU<"ownership_takes">];
1020 let Accessors = [Accessor<"isHolds", [GNU<"ownership_holds">]>,
1021 Accessor<"isReturns", [GNU<"ownership_returns">]>,
1022 Accessor<"isTakes", [GNU<"ownership_takes">]>];
1023 let AdditionalMembers = [{
1024 enum OwnershipKind { Holds, Returns, Takes };
1025 OwnershipKind getOwnKind() const {
1026 return isHolds() ? Holds :
1031 let Args = [IdentifierArgument<"Module">, VariadicUnsignedArgument<"Args">];
1032 let Subjects = SubjectList<[HasFunctionProto], WarnDiag, "ExpectedFunction">;
1033 let Documentation = [Undocumented];
1036 def Packed : InheritableAttr {
1037 let Spellings = [GCC<"packed">];
1038 // let Subjects = [Tag, Field];
1039 let Documentation = [Undocumented];
1042 def PnaclCall : InheritableAttr {
1043 let Spellings = [GNU<"pnaclcall">];
1044 // let Subjects = [Function, ObjCMethod];
1045 let Documentation = [Undocumented];
1048 def IntelOclBicc : InheritableAttr {
1049 let Spellings = [GNU<"intel_ocl_bicc">];
1050 // let Subjects = [Function, ObjCMethod];
1051 let Documentation = [Undocumented];
1054 def Pcs : InheritableAttr {
1055 let Spellings = [GCC<"pcs">];
1056 let Args = [EnumArgument<"PCS", "PCSType",
1057 ["aapcs", "aapcs-vfp"],
1058 ["AAPCS", "AAPCS_VFP"]>];
1059 // let Subjects = [Function, ObjCMethod];
1060 let Documentation = [PcsDocs];
1063 def Pure : InheritableAttr {
1064 let Spellings = [GCC<"pure">];
1065 let Documentation = [Undocumented];
1068 def Regparm : TypeAttr {
1069 let Spellings = [GCC<"regparm">];
1070 let Args = [UnsignedArgument<"NumParams">];
1071 let Documentation = [Undocumented];
1074 def ReqdWorkGroupSize : InheritableAttr {
1075 let Spellings = [GNU<"reqd_work_group_size">];
1076 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
1077 UnsignedArgument<"ZDim">];
1078 let Subjects = SubjectList<[Function], ErrorDiag>;
1079 let Documentation = [Undocumented];
1082 def WorkGroupSizeHint : InheritableAttr {
1083 let Spellings = [GNU<"work_group_size_hint">];
1084 let Args = [UnsignedArgument<"XDim">,
1085 UnsignedArgument<"YDim">,
1086 UnsignedArgument<"ZDim">];
1087 let Subjects = SubjectList<[Function], ErrorDiag>;
1088 let Documentation = [Undocumented];
1091 def InitPriority : InheritableAttr {
1092 let Spellings = [GNU<"init_priority">];
1093 let Args = [UnsignedArgument<"Priority">];
1094 let Subjects = SubjectList<[Var], ErrorDiag>;
1095 let Documentation = [Undocumented];
1098 def Section : InheritableAttr {
1099 let Spellings = [GCC<"section">, Declspec<"allocate">];
1100 let Args = [StringArgument<"Name">];
1101 let Subjects = SubjectList<[Function, GlobalVar,
1102 ObjCMethod, ObjCProperty], ErrorDiag,
1103 "ExpectedFunctionGlobalVarMethodOrProperty">;
1104 let Documentation = [SectionDocs];
1107 def Sentinel : InheritableAttr {
1108 let Spellings = [GCC<"sentinel">];
1109 let Args = [DefaultIntArgument<"Sentinel", 0>,
1110 DefaultIntArgument<"NullPos", 0>];
1111 // let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
1112 let Documentation = [Undocumented];
1115 def StdCall : InheritableAttr {
1116 let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
1117 // let Subjects = [Function, ObjCMethod];
1118 let Documentation = [Undocumented];
1121 def SysVABI : InheritableAttr {
1122 let Spellings = [GCC<"sysv_abi">];
1123 // let Subjects = [Function, ObjCMethod];
1124 let Documentation = [Undocumented];
1127 def ThisCall : InheritableAttr {
1128 let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
1129 Keyword<"_thiscall">];
1130 // let Subjects = [Function, ObjCMethod];
1131 let Documentation = [Undocumented];
1134 def Pascal : InheritableAttr {
1135 let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
1136 // let Subjects = [Function, ObjCMethod];
1137 let Documentation = [Undocumented];
1140 def TransparentUnion : InheritableAttr {
1141 let Spellings = [GCC<"transparent_union">];
1142 // let Subjects = SubjectList<[Record, TypedefName]>;
1143 let Documentation = [Undocumented];
1146 def Unavailable : InheritableAttr {
1147 let Spellings = [GNU<"unavailable">];
1148 let Args = [StringArgument<"Message", 1>];
1149 let Documentation = [Undocumented];
1152 def ArcWeakrefUnavailable : InheritableAttr {
1153 let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
1154 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1155 let Documentation = [Undocumented];
1158 def ObjCGC : TypeAttr {
1159 let Spellings = [GNU<"objc_gc">];
1160 let Args = [IdentifierArgument<"Kind">];
1161 let Documentation = [Undocumented];
1164 def ObjCOwnership : InheritableAttr {
1165 let Spellings = [GNU<"objc_ownership">];
1166 let Args = [IdentifierArgument<"Kind">];
1168 let Documentation = [Undocumented];
1171 def ObjCRequiresPropertyDefs : InheritableAttr {
1172 let Spellings = [GNU<"objc_requires_property_definitions">];
1173 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1174 let Documentation = [Undocumented];
1177 def Unused : InheritableAttr {
1178 let Spellings = [GCC<"unused">];
1179 let Subjects = SubjectList<[Var, ObjCIvar, Type, Label, Field, ObjCMethod,
1180 FunctionLike], WarnDiag,
1181 "ExpectedVariableFunctionOrLabel">;
1182 let Documentation = [Undocumented];
1185 def Used : InheritableAttr {
1186 let Spellings = [GCC<"used">];
1187 let Documentation = [Undocumented];
1190 def Uuid : InheritableAttr {
1191 let Spellings = [Declspec<"uuid">];
1192 let Args = [StringArgument<"Guid">];
1193 // let Subjects = SubjectList<[CXXRecord]>;
1194 let LangOpts = [MicrosoftExt, Borland];
1195 let Documentation = [Undocumented];
1198 def VectorSize : TypeAttr {
1199 let Spellings = [GCC<"vector_size">];
1200 let Args = [ExprArgument<"NumBytes">];
1201 let Documentation = [Undocumented];
1204 def VecTypeHint : InheritableAttr {
1205 let Spellings = [GNU<"vec_type_hint">];
1206 let Args = [TypeArgument<"TypeHint">];
1207 let Subjects = SubjectList<[Function], ErrorDiag>;
1208 let Documentation = [Undocumented];
1211 def Visibility : InheritableAttr {
1213 let Spellings = [GCC<"visibility">];
1214 let Args = [EnumArgument<"Visibility", "VisibilityType",
1215 ["default", "hidden", "internal", "protected"],
1216 ["Default", "Hidden", "Hidden", "Protected"]>];
1217 let Documentation = [Undocumented];
1220 def TypeVisibility : InheritableAttr {
1222 let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">];
1223 let Args = [EnumArgument<"Visibility", "VisibilityType",
1224 ["default", "hidden", "internal", "protected"],
1225 ["Default", "Hidden", "Hidden", "Protected"]>];
1226 // let Subjects = [Tag, ObjCInterface, Namespace];
1227 let Documentation = [Undocumented];
1230 def VecReturn : InheritableAttr {
1231 let Spellings = [GNU<"vecreturn">];
1232 let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
1233 let Documentation = [Undocumented];
1236 def WarnUnused : InheritableAttr {
1237 let Spellings = [GNU<"warn_unused">];
1238 let Subjects = SubjectList<[Record]>;
1239 let Documentation = [Undocumented];
1242 def WarnUnusedResult : InheritableAttr {
1243 let Spellings = [GCC<"warn_unused_result">,
1244 CXX11<"clang", "warn_unused_result">];
1245 let Subjects = SubjectList<[ObjCMethod, CXXRecord, FunctionLike], WarnDiag,
1246 "ExpectedFunctionMethodOrClass">;
1247 let Documentation = [Undocumented];
1250 def Weak : InheritableAttr {
1251 let Spellings = [GCC<"weak">];
1252 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
1253 let Documentation = [Undocumented];
1256 def WeakImport : InheritableAttr {
1257 let Spellings = [GNU<"weak_import">];
1258 let Documentation = [Undocumented];
1261 def WeakRef : InheritableAttr {
1262 let Spellings = [GCC<"weakref">];
1263 // A WeakRef that has an argument is treated as being an AliasAttr
1264 let Args = [StringArgument<"Aliasee", 1>];
1265 let Subjects = SubjectList<[Var, Function], ErrorDiag>;
1266 let Documentation = [Undocumented];
1269 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetX86> {
1270 let Spellings = [GNU<"force_align_arg_pointer">];
1271 // Technically, this appertains to a FunctionDecl, but the target-specific
1272 // code silently allows anything function-like (such as typedefs or function
1273 // pointers), but does not apply the attribute to them.
1274 let Documentation = [Undocumented];
1277 // Attribute to disable AddressSanitizer (or equivalent) checks.
1278 def NoSanitizeAddress : InheritableAttr {
1279 let Spellings = [GCC<"no_address_safety_analysis">,
1280 GCC<"no_sanitize_address">];
1281 let Subjects = SubjectList<[Function], ErrorDiag>;
1282 let Documentation = [NoSanitizeAddressDocs];
1285 // Attribute to disable ThreadSanitizer checks.
1286 def NoSanitizeThread : InheritableAttr {
1287 let Spellings = [GNU<"no_sanitize_thread">];
1288 let Subjects = SubjectList<[Function], ErrorDiag>;
1289 let Documentation = [NoSanitizeThreadDocs];
1292 // Attribute to disable MemorySanitizer checks.
1293 def NoSanitizeMemory : InheritableAttr {
1294 let Spellings = [GNU<"no_sanitize_memory">];
1295 let Subjects = SubjectList<[Function], ErrorDiag>;
1296 let Documentation = [NoSanitizeMemoryDocs];
1299 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
1301 def GuardedVar : InheritableAttr {
1302 let Spellings = [GNU<"guarded_var">];
1303 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1304 "ExpectedFieldOrGlobalVar">;
1305 let Documentation = [Undocumented];
1308 def PtGuardedVar : InheritableAttr {
1309 let Spellings = [GNU<"pt_guarded_var">];
1310 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1311 "ExpectedFieldOrGlobalVar">;
1312 let Documentation = [Undocumented];
1315 def Lockable : InheritableAttr {
1316 let Spellings = [GNU<"lockable">];
1317 let Subjects = SubjectList<[Record]>;
1318 let Documentation = [Undocumented];
1319 let ASTNode = 0; // Replaced by Capability
1322 def ScopedLockable : InheritableAttr {
1323 let Spellings = [GNU<"scoped_lockable">];
1324 let Subjects = SubjectList<[Record]>;
1325 let Documentation = [Undocumented];
1328 def Capability : InheritableAttr {
1329 let Spellings = [GNU<"capability">, CXX11<"clang", "capability">,
1330 GNU<"shared_capability">,
1331 CXX11<"clang", "shared_capability">];
1332 let Subjects = SubjectList<[Struct, TypedefName], ErrorDiag,
1333 "ExpectedStructOrTypedef">;
1334 let Args = [StringArgument<"Name">];
1335 let Accessors = [Accessor<"isShared",
1336 [GNU<"shared_capability">,
1337 CXX11<"clang","shared_capability">]>];
1338 let Documentation = [Undocumented];
1339 let AdditionalMembers = [{
1340 bool isMutex() const { return getName().equals_lower("mutex"); }
1341 bool isRole() const { return getName().equals_lower("role"); }
1345 def AssertCapability : InheritableAttr {
1346 let Spellings = [GNU<"assert_capability">,
1347 CXX11<"clang", "assert_capability">,
1348 GNU<"assert_shared_capability">,
1349 CXX11<"clang", "assert_shared_capability">];
1350 let Subjects = SubjectList<[Function]>;
1352 let TemplateDependent = 1;
1353 let ParseArgumentsAsUnevaluated = 1;
1354 let DuplicatesAllowedWhileMerging = 1;
1355 let Args = [ExprArgument<"Expr">];
1356 let Accessors = [Accessor<"isShared",
1357 [GNU<"assert_shared_capability">,
1358 CXX11<"clang", "assert_shared_capability">]>];
1359 let Documentation = [AssertCapabilityDocs];
1362 def AcquireCapability : InheritableAttr {
1363 let Spellings = [GNU<"acquire_capability">,
1364 CXX11<"clang", "acquire_capability">,
1365 GNU<"acquire_shared_capability">,
1366 CXX11<"clang", "acquire_shared_capability">,
1367 GNU<"exclusive_lock_function">,
1368 GNU<"shared_lock_function">];
1369 let Subjects = SubjectList<[Function]>;
1371 let TemplateDependent = 1;
1372 let ParseArgumentsAsUnevaluated = 1;
1373 let DuplicatesAllowedWhileMerging = 1;
1374 let Args = [VariadicExprArgument<"Args">];
1375 let Accessors = [Accessor<"isShared",
1376 [GNU<"acquire_shared_capability">,
1377 CXX11<"clang", "acquire_shared_capability">,
1378 GNU<"shared_lock_function">]>];
1379 let Documentation = [AcquireCapabilityDocs];
1382 def TryAcquireCapability : InheritableAttr {
1383 let Spellings = [GNU<"try_acquire_capability">,
1384 CXX11<"clang", "try_acquire_capability">,
1385 GNU<"try_acquire_shared_capability">,
1386 CXX11<"clang", "try_acquire_shared_capability">];
1387 let Subjects = SubjectList<[Function],
1390 let TemplateDependent = 1;
1391 let ParseArgumentsAsUnevaluated = 1;
1392 let DuplicatesAllowedWhileMerging = 1;
1393 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1394 let Accessors = [Accessor<"isShared",
1395 [GNU<"try_acquire_shared_capability">,
1396 CXX11<"clang", "try_acquire_shared_capability">]>];
1397 let Documentation = [TryAcquireCapabilityDocs];
1400 def ReleaseCapability : InheritableAttr {
1401 let Spellings = [GNU<"release_capability">,
1402 CXX11<"clang", "release_capability">,
1403 GNU<"release_shared_capability">,
1404 CXX11<"clang", "release_shared_capability">,
1405 GNU<"release_generic_capability">,
1406 CXX11<"clang", "release_generic_capability">,
1407 GNU<"unlock_function">];
1408 let Subjects = SubjectList<[Function]>;
1410 let TemplateDependent = 1;
1411 let ParseArgumentsAsUnevaluated = 1;
1412 let DuplicatesAllowedWhileMerging = 1;
1413 let Args = [VariadicExprArgument<"Args">];
1414 let Accessors = [Accessor<"isShared",
1415 [GNU<"release_shared_capability">,
1416 CXX11<"clang", "release_shared_capability">]>,
1417 Accessor<"isGeneric",
1418 [GNU<"release_generic_capability">,
1419 CXX11<"clang", "release_generic_capability">,
1420 GNU<"unlock_function">]>];
1421 let Documentation = [ReleaseCapabilityDocs];
1424 def RequiresCapability : InheritableAttr {
1425 let Spellings = [GNU<"requires_capability">,
1426 CXX11<"clang", "requires_capability">,
1427 GNU<"exclusive_locks_required">,
1428 GNU<"requires_shared_capability">,
1429 CXX11<"clang", "requires_shared_capability">,
1430 GNU<"shared_locks_required">];
1431 let Args = [VariadicExprArgument<"Args">];
1433 let TemplateDependent = 1;
1434 let ParseArgumentsAsUnevaluated = 1;
1435 let DuplicatesAllowedWhileMerging = 1;
1436 let Subjects = SubjectList<[Function]>;
1437 let Accessors = [Accessor<"isShared", [GNU<"requires_shared_capability">,
1438 GNU<"shared_locks_required">,
1439 CXX11<"clang","requires_shared_capability">]>];
1440 let Documentation = [Undocumented];
1443 def NoThreadSafetyAnalysis : InheritableAttr {
1444 let Spellings = [GNU<"no_thread_safety_analysis">];
1445 let Subjects = SubjectList<[Function]>;
1446 let Documentation = [Undocumented];
1449 def GuardedBy : InheritableAttr {
1450 let Spellings = [GNU<"guarded_by">];
1451 let Args = [ExprArgument<"Arg">];
1453 let TemplateDependent = 1;
1454 let ParseArgumentsAsUnevaluated = 1;
1455 let DuplicatesAllowedWhileMerging = 1;
1456 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1457 "ExpectedFieldOrGlobalVar">;
1458 let Documentation = [Undocumented];
1461 def PtGuardedBy : InheritableAttr {
1462 let Spellings = [GNU<"pt_guarded_by">];
1463 let Args = [ExprArgument<"Arg">];
1465 let TemplateDependent = 1;
1466 let ParseArgumentsAsUnevaluated = 1;
1467 let DuplicatesAllowedWhileMerging = 1;
1468 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1469 "ExpectedFieldOrGlobalVar">;
1470 let Documentation = [Undocumented];
1473 def AcquiredAfter : InheritableAttr {
1474 let Spellings = [GNU<"acquired_after">];
1475 let Args = [VariadicExprArgument<"Args">];
1477 let TemplateDependent = 1;
1478 let ParseArgumentsAsUnevaluated = 1;
1479 let DuplicatesAllowedWhileMerging = 1;
1480 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1481 "ExpectedFieldOrGlobalVar">;
1482 let Documentation = [Undocumented];
1485 def AcquiredBefore : InheritableAttr {
1486 let Spellings = [GNU<"acquired_before">];
1487 let Args = [VariadicExprArgument<"Args">];
1489 let TemplateDependent = 1;
1490 let ParseArgumentsAsUnevaluated = 1;
1491 let DuplicatesAllowedWhileMerging = 1;
1492 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1493 "ExpectedFieldOrGlobalVar">;
1494 let Documentation = [Undocumented];
1497 def AssertExclusiveLock : InheritableAttr {
1498 let Spellings = [GNU<"assert_exclusive_lock">];
1499 let Args = [VariadicExprArgument<"Args">];
1501 let TemplateDependent = 1;
1502 let ParseArgumentsAsUnevaluated = 1;
1503 let DuplicatesAllowedWhileMerging = 1;
1504 let Subjects = SubjectList<[Function]>;
1505 let Documentation = [Undocumented];
1508 def AssertSharedLock : InheritableAttr {
1509 let Spellings = [GNU<"assert_shared_lock">];
1510 let Args = [VariadicExprArgument<"Args">];
1512 let TemplateDependent = 1;
1513 let ParseArgumentsAsUnevaluated = 1;
1514 let DuplicatesAllowedWhileMerging = 1;
1515 let Subjects = SubjectList<[Function]>;
1516 let Documentation = [Undocumented];
1519 // The first argument is an integer or boolean value specifying the return value
1520 // of a successful lock acquisition.
1521 def ExclusiveTrylockFunction : InheritableAttr {
1522 let Spellings = [GNU<"exclusive_trylock_function">];
1523 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1525 let TemplateDependent = 1;
1526 let ParseArgumentsAsUnevaluated = 1;
1527 let DuplicatesAllowedWhileMerging = 1;
1528 let Subjects = SubjectList<[Function]>;
1529 let Documentation = [Undocumented];
1532 // The first argument is an integer or boolean value specifying the return value
1533 // of a successful lock acquisition.
1534 def SharedTrylockFunction : InheritableAttr {
1535 let Spellings = [GNU<"shared_trylock_function">];
1536 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1538 let TemplateDependent = 1;
1539 let ParseArgumentsAsUnevaluated = 1;
1540 let DuplicatesAllowedWhileMerging = 1;
1541 let Subjects = SubjectList<[Function]>;
1542 let Documentation = [Undocumented];
1545 def LockReturned : InheritableAttr {
1546 let Spellings = [GNU<"lock_returned">];
1547 let Args = [ExprArgument<"Arg">];
1549 let TemplateDependent = 1;
1550 let ParseArgumentsAsUnevaluated = 1;
1551 let Subjects = SubjectList<[Function]>;
1552 let Documentation = [Undocumented];
1555 def LocksExcluded : InheritableAttr {
1556 let Spellings = [GNU<"locks_excluded">];
1557 let Args = [VariadicExprArgument<"Args">];
1559 let TemplateDependent = 1;
1560 let ParseArgumentsAsUnevaluated = 1;
1561 let DuplicatesAllowedWhileMerging = 1;
1562 let Subjects = SubjectList<[Function]>;
1563 let Documentation = [Undocumented];
1566 // C/C++ consumed attributes.
1568 def Consumable : InheritableAttr {
1569 let Spellings = [GNU<"consumable">];
1570 let Subjects = SubjectList<[CXXRecord]>;
1571 let Args = [EnumArgument<"DefaultState", "ConsumedState",
1572 ["unknown", "consumed", "unconsumed"],
1573 ["Unknown", "Consumed", "Unconsumed"]>];
1574 let Documentation = [ConsumableDocs];
1577 def ConsumableAutoCast : InheritableAttr {
1578 let Spellings = [GNU<"consumable_auto_cast_state">];
1579 let Subjects = SubjectList<[CXXRecord]>;
1580 let Documentation = [Undocumented];
1583 def ConsumableSetOnRead : InheritableAttr {
1584 let Spellings = [GNU<"consumable_set_state_on_read">];
1585 let Subjects = SubjectList<[CXXRecord]>;
1586 let Documentation = [Undocumented];
1589 def CallableWhen : InheritableAttr {
1590 let Spellings = [GNU<"callable_when">];
1591 let Subjects = SubjectList<[CXXMethod]>;
1592 let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
1593 ["unknown", "consumed", "unconsumed"],
1594 ["Unknown", "Consumed", "Unconsumed"]>];
1595 let Documentation = [CallableWhenDocs];
1598 def ParamTypestate : InheritableAttr {
1599 let Spellings = [GNU<"param_typestate">];
1600 let Subjects = SubjectList<[ParmVar]>;
1601 let Args = [EnumArgument<"ParamState", "ConsumedState",
1602 ["unknown", "consumed", "unconsumed"],
1603 ["Unknown", "Consumed", "Unconsumed"]>];
1604 let Documentation = [ParamTypestateDocs];
1607 def ReturnTypestate : InheritableAttr {
1608 let Spellings = [GNU<"return_typestate">];
1609 let Subjects = SubjectList<[Function, ParmVar]>;
1610 let Args = [EnumArgument<"State", "ConsumedState",
1611 ["unknown", "consumed", "unconsumed"],
1612 ["Unknown", "Consumed", "Unconsumed"]>];
1613 let Documentation = [ReturnTypestateDocs];
1616 def SetTypestate : InheritableAttr {
1617 let Spellings = [GNU<"set_typestate">];
1618 let Subjects = SubjectList<[CXXMethod]>;
1619 let Args = [EnumArgument<"NewState", "ConsumedState",
1620 ["unknown", "consumed", "unconsumed"],
1621 ["Unknown", "Consumed", "Unconsumed"]>];
1622 let Documentation = [SetTypestateDocs];
1625 def TestTypestate : InheritableAttr {
1626 let Spellings = [GNU<"test_typestate">];
1627 let Subjects = SubjectList<[CXXMethod]>;
1628 let Args = [EnumArgument<"TestState", "ConsumedState",
1629 ["consumed", "unconsumed"],
1630 ["Consumed", "Unconsumed"]>];
1631 let Documentation = [TestTypestateDocs];
1634 // Type safety attributes for `void *' pointers and type tags.
1636 def ArgumentWithTypeTag : InheritableAttr {
1637 let Spellings = [GNU<"argument_with_type_tag">,
1638 GNU<"pointer_with_type_tag">];
1639 let Args = [IdentifierArgument<"ArgumentKind">,
1640 UnsignedArgument<"ArgumentIdx">,
1641 UnsignedArgument<"TypeTagIdx">,
1642 BoolArgument<"IsPointer">];
1643 let HasCustomParsing = 1;
1644 let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
1647 def TypeTagForDatatype : InheritableAttr {
1648 let Spellings = [GNU<"type_tag_for_datatype">];
1649 let Args = [IdentifierArgument<"ArgumentKind">,
1650 TypeArgument<"MatchingCType">,
1651 BoolArgument<"LayoutCompatible">,
1652 BoolArgument<"MustBeNull">];
1653 // let Subjects = SubjectList<[Var], ErrorDiag>;
1654 let HasCustomParsing = 1;
1655 let Documentation = [TypeTagForDatatypeDocs];
1658 // Microsoft-related attributes
1660 def MsProperty : IgnoredAttr {
1661 let Spellings = [Declspec<"property">];
1664 def MsStruct : InheritableAttr {
1665 let Spellings = [GCC<"ms_struct">];
1666 let Subjects = SubjectList<[Record]>;
1667 let Documentation = [Undocumented];
1670 def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
1671 let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
1672 let Subjects = SubjectList<[Function, Var, CXXRecord]>;
1673 let Documentation = [Undocumented];
1676 def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
1677 let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
1678 let Subjects = SubjectList<[Function, Var, CXXRecord]>;
1679 let Documentation = [Undocumented];
1682 def SelectAny : InheritableAttr {
1683 let Spellings = [Declspec<"selectany">];
1684 let LangOpts = [MicrosoftExt];
1685 let Documentation = [Undocumented];
1689 let Spellings = [Declspec<"thread">];
1690 let LangOpts = [MicrosoftExt];
1691 let Documentation = [ThreadDocs];
1692 let Subjects = SubjectList<[Var]>;
1695 def Win64 : IgnoredAttr {
1696 let Spellings = [Keyword<"__w64">];
1697 let LangOpts = [MicrosoftExt];
1700 def Ptr32 : TypeAttr {
1701 let Spellings = [Keyword<"__ptr32">];
1702 let Documentation = [Undocumented];
1705 def Ptr64 : TypeAttr {
1706 let Spellings = [Keyword<"__ptr64">];
1707 let Documentation = [Undocumented];
1710 def SPtr : TypeAttr {
1711 let Spellings = [Keyword<"__sptr">];
1712 let Documentation = [Undocumented];
1715 def UPtr : TypeAttr {
1716 let Spellings = [Keyword<"__uptr">];
1717 let Documentation = [Undocumented];
1720 def MSInheritance : InheritableAttr {
1721 let LangOpts = [MicrosoftExt];
1722 let Args = [DefaultBoolArgument<"BestCase", 1>];
1723 let Spellings = [Keyword<"__single_inheritance">,
1724 Keyword<"__multiple_inheritance">,
1725 Keyword<"__virtual_inheritance">,
1726 Keyword<"__unspecified_inheritance">];
1727 let AdditionalMembers = [{
1728 static bool hasVBPtrOffsetField(Spelling Inheritance) {
1729 return Inheritance == Keyword_unspecified_inheritance;
1732 // Only member pointers to functions need a this adjustment, since it can be
1733 // combined with the field offset for data pointers.
1734 static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
1735 return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
1738 static bool hasVBTableOffsetField(Spelling Inheritance) {
1739 return Inheritance >= Keyword_virtual_inheritance;
1742 static bool hasOnlyOneField(bool IsMemberFunction,
1743 Spelling Inheritance) {
1744 if (IsMemberFunction)
1745 return Inheritance <= Keyword_single_inheritance;
1746 return Inheritance <= Keyword_multiple_inheritance;
1749 let Documentation = [MSInheritanceDocs];
1752 def MSVtorDisp : InheritableAttr {
1753 // This attribute has no spellings as it is only ever created implicitly.
1755 let Args = [UnsignedArgument<"vdm">];
1756 let SemaHandler = 0;
1758 let AdditionalMembers = [{
1765 Mode getVtorDispMode() const { return Mode(vdm); }
1767 let Documentation = [Undocumented];
1770 def InitSeg : Attr {
1771 let Spellings = [Pragma<"", "init_seg">];
1772 let Args = [StringArgument<"Section">];
1773 let SemaHandler = 0;
1774 let Documentation = [InitSegDocs];
1775 let AdditionalMembers = [{
1776 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
1777 OS << '(' << getSection() << ')';
1782 def Unaligned : IgnoredAttr {
1783 let Spellings = [Keyword<"__unaligned">];
1786 def LoopHint : Attr {
1787 /// vectorize: vectorizes loop operations if 'value != 0'.
1788 /// vectorize_width: vectorize loop operations with width 'value'.
1789 /// interleave: interleave multiple loop iterations if 'value != 0'.
1790 /// interleave_count: interleaves 'value' loop interations.
1791 /// unroll: unroll loop if 'value != 0'.
1792 /// unroll_count: unrolls loop 'value' times.
1794 let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">];
1796 /// State of the loop optimization specified by the spelling.
1797 let Args = [EnumArgument<"Option", "OptionType",
1798 ["vectorize", "vectorize_width", "interleave", "interleave_count",
1799 "unroll", "unroll_count"],
1800 ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
1801 "Unroll", "UnrollCount"]>,
1802 DefaultIntArgument<"Value", 1>];
1804 let AdditionalMembers = [{
1805 static StringRef getOptionName(int Option) {
1807 case Vectorize: return "vectorize";
1808 case VectorizeWidth: return "vectorize_width";
1809 case Interleave: return "interleave";
1810 case InterleaveCount: return "interleave_count";
1811 case Unroll: return "unroll";
1812 case UnrollCount: return "unroll_count";
1814 llvm_unreachable("Unhandled LoopHint option.");
1817 static StringRef getValueName(int Value) {
1823 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
1824 unsigned SpellingIndex = getSpellingListIndex();
1825 if (SpellingIndex == Pragma_unroll) {
1826 // String "unroll" of "#pragma unroll" is already emitted as the
1828 if (option == UnrollCount)
1833 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
1834 OS << getOptionName(option);
1839 // Prints the loop hint argument including the enclosing parentheses to OS.
1840 void printArgument(raw_ostream &OS) const {
1842 if (option == VectorizeWidth || option == InterleaveCount ||
1843 option == UnrollCount)
1852 // Return a string suitable for identifying this attribute in diagnostics.
1853 std::string getDiagnosticName() const {
1854 std::string DiagnosticName;
1855 llvm::raw_string_ostream OS(DiagnosticName);
1856 unsigned SpellingIndex = getSpellingListIndex();
1857 if (SpellingIndex == Pragma_unroll && option == Unroll)
1858 OS << "#pragma unroll";
1859 else if (SpellingIndex == Pragma_unroll && option == UnrollCount) {
1860 OS << "#pragma unroll";
1863 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
1864 OS << getOptionName(option);
1871 let Documentation = [LoopHintDocs, UnrollHintDocs];