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 def OpenCLKernelFunction : SubsetSubject<Function, [{
119 S->hasAttr<OpenCLKernelAttr>()
122 // HasFunctionProto is a more strict version of FunctionLike, so it should
123 // never be specified in a Subjects list along with FunctionLike (due to the
124 // inclusive nature of subject testing).
125 def HasFunctionProto : SubsetSubject<DeclBase,
126 [{(S->getFunctionType(true) != NULL &&
127 isa<FunctionProtoType>(S->getFunctionType())) ||
128 isa<ObjCMethodDecl>(S) ||
129 isa<BlockDecl>(S)}]>;
131 // A single argument to an attribute
132 class Argument<string name, bit optional> {
134 bit Optional = optional;
137 class BoolArgument<string name, bit opt = 0> : Argument<name, opt>;
138 class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>;
139 class IntArgument<string name, bit opt = 0> : Argument<name, opt>;
140 class StringArgument<string name, bit opt = 0> : Argument<name, opt>;
141 class ExprArgument<string name, bit opt = 0> : Argument<name, opt>;
142 class FunctionArgument<string name, bit opt = 0> : Argument<name, opt>;
143 class TypeArgument<string name, bit opt = 0> : Argument<name, opt>;
144 class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>;
145 class VariadicUnsignedArgument<string name> : Argument<name, 1>;
146 class VariadicExprArgument<string name> : Argument<name, 1>;
147 class VariadicStringArgument<string name> : Argument<name, 1>;
149 // A version of the form major.minor[.subminor].
150 class VersionArgument<string name, bit opt = 0> : Argument<name, opt>;
152 // This one's a doozy, so it gets its own special type
153 // It can be an unsigned integer, or a type. Either can
155 class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>;
157 // A bool argument with a default value
158 class DefaultBoolArgument<string name, bit default> : BoolArgument<name, 1> {
159 bit Default = default;
162 // An integer argument with a default value
163 class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
164 int Default = default;
167 // This argument is more complex, it includes the enumerator type name,
168 // a list of strings to accept, and a list of enumerators to map them to.
169 class EnumArgument<string name, string type, list<string> values,
170 list<string> enums, bit opt = 0> : Argument<name, opt> {
172 list<string> Values = values;
173 list<string> Enums = enums;
176 // FIXME: There should be a VariadicArgument type that takes any other type
177 // of argument and generates the appropriate type.
178 class VariadicEnumArgument<string name, string type, list<string> values,
179 list<string> enums> : Argument<name, 1> {
181 list<string> Values = values;
182 list<string> Enums = enums;
185 // This handles one spelling of an attribute.
186 class Spelling<string name, string variety> {
188 string Variety = variety;
192 class GNU<string name> : Spelling<name, "GNU">;
193 class Declspec<string name> : Spelling<name, "Declspec">;
194 class CXX11<string namespace, string name, int version = 1>
195 : Spelling<name, "CXX11"> {
196 string Namespace = namespace;
197 int Version = version;
198 } class Keyword<string name> : Spelling<name, "Keyword">;
199 class Pragma<string namespace, string name> : Spelling<name, "Pragma"> {
200 string Namespace = namespace;
203 // The GCC spelling implies GNU<name, "GNU"> and CXX11<"gnu", name> and also
204 // sets KnownToGCC to 1. This spelling should be used for any GCC-compatible
206 class GCC<string name> : Spelling<name, "GCC"> {
210 class Accessor<string name, list<Spelling> spellings> {
212 list<Spelling> Spellings = spellings;
215 class SubjectDiag<bit warn> {
218 def WarnDiag : SubjectDiag<1>;
219 def ErrorDiag : SubjectDiag<0>;
221 class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag,
222 string customDiag = ""> {
223 list<AttrSubject> Subjects = subjects;
224 SubjectDiag Diag = diag;
225 string CustomDiag = customDiag;
228 class LangOpt<string name, bit negated = 0> {
230 bit Negated = negated;
232 def MicrosoftExt : LangOpt<"MicrosoftExt">;
233 def Borland : LangOpt<"Borland">;
234 def CUDA : LangOpt<"CUDA">;
235 def COnly : LangOpt<"CPlusPlus", 1>;
237 // Defines targets for target-specific attributes. The list of strings should
238 // specify architectures for which the target applies, based off the ArchType
239 // enumeration in Triple.h.
240 class TargetArch<list<string> arches> {
241 list<string> Arches = arches;
244 def TargetARM : TargetArch<["arm", "thumb"]>;
245 def TargetMSP430 : TargetArch<["msp430"]>;
246 def TargetX86 : TargetArch<["x86"]>;
247 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
248 let OSes = ["Win32"];
250 def TargetMips : TargetArch<["mips", "mipsel"]>;
253 // The various ways in which an attribute can be spelled in source
254 list<Spelling> Spellings;
255 // The things to which an attribute can appertain
256 SubjectList Subjects;
257 // The arguments allowed on an attribute
258 list<Argument> Args = [];
259 // Accessors which should be generated for the attribute.
260 list<Accessor> Accessors = [];
261 // Set to true for attributes with arguments which require delayed parsing.
263 // Set to false to prevent an attribute from being propagated from a template
264 // to the instantiation.
266 // Set to true for attributes which must be instantiated within templates
267 bit TemplateDependent = 0;
268 // Set to true for attributes that have a corresponding AST node.
270 // Set to true for attributes which have handler in Sema.
272 // Set to true for attributes that are completely ignored.
274 // Set to true if the attribute's parsing does not match its semantic
275 // content. Eg) It parses 3 args, but semantically takes 4 args. Opts out of
276 // common attribute error checking.
277 bit HasCustomParsing = 0;
278 // Set to true if all of the attribute's arguments should be parsed in an
279 // unevaluated context.
280 bit ParseArgumentsAsUnevaluated = 0;
281 // Set to true if this attribute can be duplicated on a subject when merging
282 // attributes. By default, attributes are not merged.
283 bit DuplicatesAllowedWhileMerging = 0;
284 // Lists language options, one of which is required to be true for the
285 // attribute to be applicable. If empty, no language options are required.
286 list<LangOpt> LangOpts = [];
287 // Any additional text that should be included verbatim in the class.
288 code AdditionalMembers = [{}];
289 // Any documentation that should be associated with the attribute. Since an
290 // attribute may be documented under multiple categories, more than one
291 // Documentation entry may be listed.
292 list<Documentation> Documentation;
295 /// A type attribute is not processed on a declaration or a statement.
296 class TypeAttr : Attr {
297 // By default, type attributes do not get an AST node.
301 /// An inheritable attribute is inherited by later redeclarations.
302 class InheritableAttr : Attr;
304 /// A target-specific attribute. This class is meant to be used as a mixin
305 /// with InheritableAttr or Attr depending on the attribute's needs.
306 class TargetSpecificAttr<TargetArch target> {
307 TargetArch Target = target;
308 // Attributes are generally required to have unique spellings for their names
309 // so that the parser can determine what kind of attribute it has parsed.
310 // However, target-specific attributes are special in that the attribute only
311 // "exists" for a given target. So two target-specific attributes can share
312 // the same name when they exist in different targets. To support this, a
313 // Kind can be explicitly specified for a target-specific attribute. This
314 // corresponds to the AttributeList::AT_* enum that is generated and it
315 // should contain a shared value between the attributes.
317 // Target-specific attributes which use this feature should ensure that the
318 // spellings match exactly betweeen the attributes, and if the arguments or
319 // subjects differ, should specify HasCustomParsing = 1 and implement their
320 // own parsing and semantic handling requirements as-needed.
324 /// An inheritable parameter attribute is inherited by later
325 /// redeclarations, even when it's written on a parameter.
326 class InheritableParamAttr : InheritableAttr;
328 /// An ignored attribute, which we parse but discard with no checking.
329 class IgnoredAttr : Attr {
333 let Documentation = [Undocumented];
337 // Attributes begin here
340 def AddressSpace : TypeAttr {
341 let Spellings = [GNU<"address_space">];
342 let Args = [IntArgument<"AddressSpace">];
343 let Documentation = [Undocumented];
347 let Spellings = [GCC<"alias">];
348 let Args = [StringArgument<"Aliasee">];
349 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
350 "ExpectedFunctionGlobalVarMethodOrProperty">;
351 let Documentation = [Undocumented];
354 def Aligned : InheritableAttr {
355 let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">,
356 Keyword<"_Alignas">];
357 // let Subjects = SubjectList<[NonBitField, NormalVar, Tag]>;
358 let Args = [AlignedArgument<"Alignment", 1>];
359 let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
360 Accessor<"isC11", [Keyword<"_Alignas">]>,
361 Accessor<"isAlignas", [Keyword<"alignas">,
362 Keyword<"_Alignas">]>,
363 Accessor<"isDeclspec",[Declspec<"align">]>];
364 let Documentation = [Undocumented];
367 def AlignValue : Attr {
369 // Unfortunately, this is semantically an assertion, not a directive
370 // (something else must ensure the alignment), so aligned_value is a
371 // probably a better name. We might want to add an aligned_value spelling in
372 // the future (and a corresponding C++ attribute), but this can be done
373 // later once we decide if we also want them to have slightly-different
374 // semantics than Intel's align_value.
376 // Intel's compiler on Windows also supports:
377 // , Declspec<"align_value">
379 let Args = [ExprArgument<"Alignment">];
380 let Subjects = SubjectList<[Var, TypedefName], WarnDiag,
381 "ExpectedVariableOrTypedef">;
382 let Documentation = [AlignValueDocs];
385 def AlignMac68k : InheritableAttr {
386 // This attribute has no spellings as it is only ever created implicitly.
389 let Documentation = [Undocumented];
392 def AlwaysInline : InheritableAttr {
393 let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
394 let Subjects = SubjectList<[Function]>;
395 let Documentation = [Undocumented];
398 def TLSModel : InheritableAttr {
399 let Spellings = [GCC<"tls_model">];
400 let Subjects = SubjectList<[TLSVar], ErrorDiag, "ExpectedTLSVar">;
401 let Args = [StringArgument<"Model">];
402 let Documentation = [TLSModelDocs];
405 def AnalyzerNoReturn : InheritableAttr {
406 let Spellings = [GNU<"analyzer_noreturn">];
407 let Documentation = [Undocumented];
410 def Annotate : InheritableParamAttr {
411 let Spellings = [GNU<"annotate">];
412 let Args = [StringArgument<"Annotation">];
413 let Documentation = [Undocumented];
416 def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> {
417 // NOTE: If you add any additional spellings, MSP430Interrupt's spellings
419 let Spellings = [GNU<"interrupt">];
420 let Args = [EnumArgument<"Interrupt", "InterruptType",
421 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
422 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
424 let ParseKind = "Interrupt";
425 let HasCustomParsing = 1;
426 let Documentation = [ARMInterruptDocs];
429 def AsmLabel : InheritableAttr {
430 let Spellings = [Keyword<"asm">, Keyword<"__asm__">];
431 let Args = [StringArgument<"Label">];
433 let Documentation = [Undocumented];
436 def Availability : InheritableAttr {
437 let Spellings = [GNU<"availability">];
438 let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
439 VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
440 BoolArgument<"unavailable">, StringArgument<"message">];
441 let AdditionalMembers =
442 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
443 return llvm::StringSwitch<llvm::StringRef>(Platform)
444 .Case("android", "Android")
446 .Case("macosx", "OS X")
447 .Case("ios_app_extension", "iOS (App Extension)")
448 .Case("macosx_app_extension", "OS X (App Extension)")
449 .Default(llvm::StringRef());
451 let HasCustomParsing = 1;
452 let DuplicatesAllowedWhileMerging = 1;
453 // let Subjects = SubjectList<[Named]>;
454 let Documentation = [AvailabilityDocs];
457 def Blocks : InheritableAttr {
458 let Spellings = [GNU<"blocks">];
459 let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
460 let Documentation = [Undocumented];
463 def Bounded : IgnoredAttr {
464 let Spellings = [GNU<"bounded">];
467 def CarriesDependency : InheritableParamAttr {
468 let Spellings = [GNU<"carries_dependency">,
469 CXX11<"","carries_dependency", 200809>];
470 let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>;
471 let Documentation = [CarriesDependencyDocs];
474 def CDecl : InheritableAttr {
475 let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">];
476 // let Subjects = [Function, ObjCMethod];
477 let Documentation = [Undocumented];
480 // cf_audited_transfer indicates that the given function has been
481 // audited and has been marked with the appropriate cf_consumed and
482 // cf_returns_retained attributes. It is generally applied by
483 // '#pragma clang arc_cf_code_audited' rather than explicitly.
484 def CFAuditedTransfer : InheritableAttr {
485 let Spellings = [GNU<"cf_audited_transfer">];
486 let Subjects = SubjectList<[Function], ErrorDiag>;
487 let Documentation = [Undocumented];
490 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
491 // It indicates that the function has unknown or unautomatable
492 // transfer semantics.
493 def CFUnknownTransfer : InheritableAttr {
494 let Spellings = [GNU<"cf_unknown_transfer">];
495 let Subjects = SubjectList<[Function], ErrorDiag>;
496 let Documentation = [Undocumented];
499 def CFReturnsRetained : InheritableAttr {
500 let Spellings = [GNU<"cf_returns_retained">];
501 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
502 let Documentation = [Undocumented];
505 def CFReturnsNotRetained : InheritableAttr {
506 let Spellings = [GNU<"cf_returns_not_retained">];
507 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
508 let Documentation = [Undocumented];
511 def CFConsumed : InheritableParamAttr {
512 let Spellings = [GNU<"cf_consumed">];
513 let Subjects = SubjectList<[ParmVar]>;
514 let Documentation = [Undocumented];
517 def Cleanup : InheritableAttr {
518 let Spellings = [GCC<"cleanup">];
519 let Args = [FunctionArgument<"FunctionDecl">];
520 let Subjects = SubjectList<[Var]>;
521 let Documentation = [Undocumented];
524 def Cold : InheritableAttr {
525 let Spellings = [GCC<"cold">];
526 let Subjects = SubjectList<[Function]>;
527 let Documentation = [Undocumented];
530 def Common : InheritableAttr {
531 let Spellings = [GCC<"common">];
532 let Subjects = SubjectList<[Var]>;
533 let Documentation = [Undocumented];
536 def Const : InheritableAttr {
537 let Spellings = [GCC<"const">, GCC<"__const">];
538 let Documentation = [Undocumented];
541 def Constructor : InheritableAttr {
542 let Spellings = [GCC<"constructor">];
543 let Args = [DefaultIntArgument<"Priority", 65535>];
544 let Subjects = SubjectList<[Function]>;
545 let Documentation = [Undocumented];
548 def CUDAConstant : InheritableAttr {
549 let Spellings = [GNU<"constant">];
550 let Subjects = SubjectList<[Var]>;
551 let LangOpts = [CUDA];
552 let Documentation = [Undocumented];
555 def CUDADevice : InheritableAttr {
556 let Spellings = [GNU<"device">];
557 let Subjects = SubjectList<[Function, Var]>;
558 let LangOpts = [CUDA];
559 let Documentation = [Undocumented];
562 def CUDAGlobal : InheritableAttr {
563 let Spellings = [GNU<"global">];
564 let Subjects = SubjectList<[Function]>;
565 let LangOpts = [CUDA];
566 let Documentation = [Undocumented];
569 def CUDAHost : InheritableAttr {
570 let Spellings = [GNU<"host">];
571 let Subjects = SubjectList<[Function]>;
572 let LangOpts = [CUDA];
573 let Documentation = [Undocumented];
576 def CUDAInvalidTarget : InheritableAttr {
578 let Subjects = SubjectList<[Function]>;
579 let LangOpts = [CUDA];
580 let Documentation = [Undocumented];
583 def CUDALaunchBounds : InheritableAttr {
584 let Spellings = [GNU<"launch_bounds">];
585 let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>];
586 let LangOpts = [CUDA];
587 let Subjects = SubjectList<[ObjCMethod, FunctionLike], WarnDiag,
588 "ExpectedFunctionOrMethod">;
589 // An AST node is created for this attribute, but is not used by other parts
590 // of the compiler. However, this node needs to exist in the AST because
591 // non-LLVM backends may be relying on the attribute's presence.
592 let Documentation = [Undocumented];
595 def CUDAShared : InheritableAttr {
596 let Spellings = [GNU<"shared">];
597 let Subjects = SubjectList<[Var]>;
598 let LangOpts = [CUDA];
599 let Documentation = [Undocumented];
602 def C11NoReturn : InheritableAttr {
603 let Spellings = [Keyword<"_Noreturn">];
604 let Subjects = SubjectList<[Function], ErrorDiag>;
606 let Documentation = [C11NoReturnDocs];
609 def CXX11NoReturn : InheritableAttr {
610 let Spellings = [CXX11<"","noreturn", 200809>];
611 let Subjects = SubjectList<[Function], ErrorDiag>;
612 let Documentation = [CXX11NoReturnDocs];
615 def OpenCLKernel : InheritableAttr {
616 let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
617 let Subjects = SubjectList<[Function], ErrorDiag>;
618 let Documentation = [Undocumented];
621 // This attribute is both a type attribute, and a declaration attribute (for
622 // parameter variables).
623 def OpenCLImageAccess : Attr {
624 let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
625 Keyword<"__write_only">, Keyword<"write_only">,
626 Keyword<"__read_write">, Keyword<"read_write">];
627 let Subjects = SubjectList<[ParmVar], ErrorDiag>;
628 let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
629 Keyword<"read_only">]>,
630 Accessor<"isReadWrite", [Keyword<"__read_write">,
631 Keyword<"read_write">]>,
632 Accessor<"isWriteOnly", [Keyword<"__write_only">,
633 Keyword<"write_only">]>];
634 let Documentation = [Undocumented];
637 def OpenCLPrivateAddressSpace : TypeAttr {
638 let Spellings = [Keyword<"__private">, Keyword<"private">];
639 let Documentation = [OpenCLAddressSpacePrivateDocs];
642 def OpenCLGlobalAddressSpace : TypeAttr {
643 let Spellings = [Keyword<"__global">, Keyword<"global">];
644 let Documentation = [OpenCLAddressSpaceGlobalDocs];
647 def OpenCLLocalAddressSpace : TypeAttr {
648 let Spellings = [Keyword<"__local">, Keyword<"local">];
649 let Documentation = [OpenCLAddressSpaceLocalDocs];
652 def OpenCLConstantAddressSpace : TypeAttr {
653 let Spellings = [Keyword<"__constant">, Keyword<"constant">];
654 let Documentation = [OpenCLAddressSpaceConstantDocs];
657 def OpenCLGenericAddressSpace : TypeAttr {
658 let Spellings = [Keyword<"__generic">, Keyword<"generic">];
659 let Documentation = [OpenCLAddressSpaceGenericDocs];
662 def Deprecated : InheritableAttr {
663 let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
664 CXX11<"","deprecated", 201309>];
665 let Args = [StringArgument<"Message", 1>];
666 let Documentation = [Undocumented];
669 def Destructor : InheritableAttr {
670 let Spellings = [GCC<"destructor">];
671 let Args = [DefaultIntArgument<"Priority", 65535>];
672 let Subjects = SubjectList<[Function]>;
673 let Documentation = [Undocumented];
676 def EnableIf : InheritableAttr {
677 let Spellings = [GNU<"enable_if">];
678 let Subjects = SubjectList<[Function]>;
679 let Args = [ExprArgument<"Cond">, StringArgument<"Message">];
680 let TemplateDependent = 1;
681 let Documentation = [EnableIfDocs];
684 def ExtVectorType : Attr {
685 let Spellings = [GNU<"ext_vector_type">];
686 let Subjects = SubjectList<[TypedefName], ErrorDiag>;
687 let Args = [ExprArgument<"NumElements">];
689 let Documentation = [Undocumented];
692 def FallThrough : Attr {
693 let Spellings = [CXX11<"clang", "fallthrough">];
694 // let Subjects = [NullStmt];
695 let Documentation = [FallthroughDocs];
698 def FastCall : InheritableAttr {
699 let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
700 Keyword<"_fastcall">];
701 // let Subjects = [Function, ObjCMethod];
702 let Documentation = [FastCallDocs];
705 def Final : InheritableAttr {
706 let Spellings = [Keyword<"final">, Keyword<"sealed">];
707 let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
709 let Documentation = [Undocumented];
712 def MinSize : InheritableAttr {
713 let Spellings = [GNU<"minsize">];
714 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
715 let Documentation = [Undocumented];
718 def FlagEnum : InheritableAttr {
719 let Spellings = [GNU<"flag_enum">];
720 let Subjects = SubjectList<[Enum]>;
721 let Documentation = [FlagEnumDocs];
722 let LangOpts = [COnly];
723 let AdditionalMembers = [{
725 llvm::APInt FlagBits;
727 llvm::APInt &getFlagBits() {
731 const llvm::APInt &getFlagBits() const {
737 def Flatten : InheritableAttr {
738 let Spellings = [GCC<"flatten">];
739 let Subjects = SubjectList<[Function], ErrorDiag>;
740 let Documentation = [FlattenDocs];
743 def Format : InheritableAttr {
744 let Spellings = [GCC<"format">];
745 let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
746 IntArgument<"FirstArg">];
747 let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto], WarnDiag,
749 let Documentation = [FormatDocs];
752 def FormatArg : InheritableAttr {
753 let Spellings = [GCC<"format_arg">];
754 let Args = [IntArgument<"FormatIdx">];
755 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto], WarnDiag,
757 let Documentation = [Undocumented];
760 def GNUInline : InheritableAttr {
761 let Spellings = [GCC<"gnu_inline">];
762 let Subjects = SubjectList<[Function]>;
763 let Documentation = [Undocumented];
766 def Hot : InheritableAttr {
767 let Spellings = [GCC<"hot">];
768 let Subjects = SubjectList<[Function]>;
769 // An AST node is created for this attribute, but not actually used beyond
770 // semantic checking for mutual exclusion with the Cold attribute.
771 let Documentation = [Undocumented];
774 def IBAction : InheritableAttr {
775 let Spellings = [GNU<"ibaction">];
776 let Subjects = SubjectList<[ObjCInstanceMethod], WarnDiag,
777 "ExpectedObjCInstanceMethod">;
778 // An AST node is created for this attribute, but is not used by other parts
779 // of the compiler. However, this node needs to exist in the AST because
780 // external tools rely on it.
781 let Documentation = [Undocumented];
784 def IBOutlet : InheritableAttr {
785 let Spellings = [GNU<"iboutlet">];
786 // let Subjects = [ObjCIvar, ObjCProperty];
787 let Documentation = [Undocumented];
790 def IBOutletCollection : InheritableAttr {
791 let Spellings = [GNU<"iboutletcollection">];
792 let Args = [TypeArgument<"Interface", 1>];
793 // let Subjects = [ObjCIvar, ObjCProperty];
794 let Documentation = [Undocumented];
797 def Restrict : InheritableAttr {
798 let Spellings = [Declspec<"restrict">, GCC<"malloc">];
799 let Subjects = SubjectList<[Function]>;
800 let Documentation = [Undocumented];
803 def MaxFieldAlignment : InheritableAttr {
804 // This attribute has no spellings as it is only ever created implicitly.
806 let Args = [UnsignedArgument<"Alignment">];
808 let Documentation = [Undocumented];
811 def MayAlias : InheritableAttr {
812 // FIXME: this is a type attribute in GCC, but a declaration attribute here.
813 let Spellings = [GCC<"may_alias">];
814 let Documentation = [Undocumented];
817 def MSABI : InheritableAttr {
818 let Spellings = [GCC<"ms_abi">];
819 // let Subjects = [Function, ObjCMethod];
820 let Documentation = [MSABIDocs];
823 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
824 // NOTE: If you add any additional spellings, ARMInterrupt's spellings must
826 let Spellings = [GNU<"interrupt">];
827 let Args = [UnsignedArgument<"Number">];
828 let ParseKind = "Interrupt";
829 let HasCustomParsing = 1;
830 let Documentation = [Undocumented];
833 def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
834 let Spellings = [GCC<"mips16">];
835 let Subjects = SubjectList<[Function], ErrorDiag>;
836 let Documentation = [Undocumented];
840 let Spellings = [GCC<"mode">];
841 let Args = [IdentifierArgument<"Mode">];
842 let Documentation = [Undocumented];
845 def Naked : InheritableAttr {
846 let Spellings = [GCC<"naked">, Declspec<"naked">];
847 let Subjects = SubjectList<[Function]>;
848 let Documentation = [Undocumented];
851 def NeonPolyVectorType : TypeAttr {
852 let Spellings = [GNU<"neon_polyvector_type">];
853 let Args = [IntArgument<"NumElements">];
854 let Documentation = [Undocumented];
857 def NeonVectorType : TypeAttr {
858 let Spellings = [GNU<"neon_vector_type">];
859 let Args = [IntArgument<"NumElements">];
860 let Documentation = [Undocumented];
863 def ReturnsTwice : InheritableAttr {
864 let Spellings = [GCC<"returns_twice">];
865 let Subjects = SubjectList<[Function]>;
866 let Documentation = [Undocumented];
869 def NoCommon : InheritableAttr {
870 let Spellings = [GCC<"nocommon">];
871 let Subjects = SubjectList<[Var]>;
872 let Documentation = [Undocumented];
875 def NoDebug : InheritableAttr {
876 let Spellings = [GCC<"nodebug">];
877 let Documentation = [Undocumented];
880 def NoDuplicate : InheritableAttr {
881 let Spellings = [GNU<"noduplicate">, CXX11<"clang", "noduplicate">];
882 let Subjects = SubjectList<[Function]>;
883 let Documentation = [NoDuplicateDocs];
886 def NoInline : InheritableAttr {
887 let Spellings = [GCC<"noinline">, Declspec<"noinline">];
888 let Subjects = SubjectList<[Function]>;
889 let Documentation = [Undocumented];
892 def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
893 let Spellings = [GCC<"nomips16">];
894 let Subjects = SubjectList<[Function], ErrorDiag>;
895 let Documentation = [Undocumented];
898 // This is not a TargetSpecificAttr so that is silently accepted and
899 // ignored on other targets as encouraged by the OpenCL spec.
901 // See OpenCL 1.2 6.11.5: "It is our intention that a particular
902 // implementation of OpenCL be free to ignore all attributes and the
903 // resulting executable binary will produce the same result."
905 // However, only AMD GPU targets will emit the corresponding IR
908 // FIXME: This provides a sub-optimal error message if you attempt to
909 // use this in CUDA, since CUDA does not use the same terminology.
910 def AMDGPUNumVGPR : InheritableAttr {
911 let Spellings = [GNU<"amdgpu_num_vgpr">];
912 let Args = [UnsignedArgument<"NumVGPR">];
913 let Documentation = [AMDGPUNumVGPRDocs];
915 // FIXME: This should be for OpenCLKernelFunction, but is not to
916 // workaround needing to see kernel attribute before others to know if
917 // this should be rejected on non-kernels.
918 let Subjects = SubjectList<[Function], ErrorDiag,
919 "ExpectedKernelFunction">;
922 def AMDGPUNumSGPR : InheritableAttr {
923 let Spellings = [GNU<"amdgpu_num_sgpr">];
924 let Args = [UnsignedArgument<"NumSGPR">];
925 let Documentation = [AMDGPUNumSGPRDocs];
926 let Subjects = SubjectList<[Function], ErrorDiag,
927 "ExpectedKernelFunction">;
930 def NoSplitStack : InheritableAttr {
931 let Spellings = [GCC<"no_split_stack">];
932 let Subjects = SubjectList<[Function], ErrorDiag>;
933 let Documentation = [NoSplitStackDocs];
936 def NonNull : InheritableAttr {
937 let Spellings = [GCC<"nonnull">];
938 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
939 "ExpectedFunctionMethodOrParameter">;
940 let Args = [VariadicUnsignedArgument<"Args">];
941 let AdditionalMembers =
942 [{bool isNonNull(unsigned idx) const {
945 for (const auto &V : args())
950 // FIXME: We should merge duplicates into a single nonnull attribute.
951 let DuplicatesAllowedWhileMerging = 1;
952 let Documentation = [Undocumented];
955 def ReturnsNonNull : InheritableAttr {
956 let Spellings = [GCC<"returns_nonnull">];
957 let Subjects = SubjectList<[ObjCMethod, Function], WarnDiag,
958 "ExpectedFunctionOrMethod">;
959 let Documentation = [Undocumented];
962 def AssumeAligned : InheritableAttr {
963 let Spellings = [GCC<"assume_aligned">];
964 let Subjects = SubjectList<[ObjCMethod, Function]>;
965 let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>];
966 let Documentation = [AssumeAlignedDocs];
969 def NoReturn : InheritableAttr {
970 let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
971 // FIXME: Does GCC allow this on the function instead?
972 let Documentation = [Undocumented];
975 def NoInstrumentFunction : InheritableAttr {
976 let Spellings = [GCC<"no_instrument_function">];
977 let Subjects = SubjectList<[Function]>;
978 let Documentation = [Undocumented];
981 def NoThrow : InheritableAttr {
982 let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
983 let Documentation = [Undocumented];
986 def ObjCBridge : InheritableAttr {
987 let Spellings = [GNU<"objc_bridge">];
988 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag,
989 "ExpectedStructOrUnionOrTypedef">;
990 let Args = [IdentifierArgument<"BridgedType">];
991 let Documentation = [Undocumented];
994 def ObjCBridgeMutable : InheritableAttr {
995 let Spellings = [GNU<"objc_bridge_mutable">];
996 let Subjects = SubjectList<[Record], ErrorDiag>;
997 let Args = [IdentifierArgument<"BridgedType">];
998 let Documentation = [Undocumented];
1001 def ObjCBridgeRelated : InheritableAttr {
1002 let Spellings = [GNU<"objc_bridge_related">];
1003 let Subjects = SubjectList<[Record], ErrorDiag>;
1004 let Args = [IdentifierArgument<"RelatedClass">,
1005 IdentifierArgument<"ClassMethod">,
1006 IdentifierArgument<"InstanceMethod">];
1007 let HasCustomParsing = 1;
1008 let Documentation = [Undocumented];
1011 def NSReturnsRetained : InheritableAttr {
1012 let Spellings = [GNU<"ns_returns_retained">];
1013 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1014 let Documentation = [Undocumented];
1017 def NSReturnsNotRetained : InheritableAttr {
1018 let Spellings = [GNU<"ns_returns_not_retained">];
1019 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1020 let Documentation = [Undocumented];
1023 def NSReturnsAutoreleased : InheritableAttr {
1024 let Spellings = [GNU<"ns_returns_autoreleased">];
1025 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1026 let Documentation = [Undocumented];
1029 def NSConsumesSelf : InheritableAttr {
1030 let Spellings = [GNU<"ns_consumes_self">];
1031 let Subjects = SubjectList<[ObjCMethod]>;
1032 let Documentation = [Undocumented];
1035 def NSConsumed : InheritableParamAttr {
1036 let Spellings = [GNU<"ns_consumed">];
1037 let Subjects = SubjectList<[ParmVar]>;
1038 let Documentation = [Undocumented];
1041 def ObjCException : InheritableAttr {
1042 let Spellings = [GNU<"objc_exception">];
1043 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1044 let Documentation = [Undocumented];
1047 def ObjCMethodFamily : InheritableAttr {
1048 let Spellings = [GNU<"objc_method_family">];
1049 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1050 let Args = [EnumArgument<"Family", "FamilyKind",
1051 ["none", "alloc", "copy", "init", "mutableCopy", "new"],
1052 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
1053 "OMF_mutableCopy", "OMF_new"]>];
1054 let Documentation = [ObjCMethodFamilyDocs];
1057 def ObjCNSObject : InheritableAttr {
1058 let Spellings = [GNU<"NSObject">];
1059 let Documentation = [Undocumented];
1062 def ObjCIndependentClass : InheritableAttr {
1063 let Spellings = [GNU<"objc_independent_class">];
1064 let Documentation = [Undocumented];
1067 def ObjCPreciseLifetime : InheritableAttr {
1068 let Spellings = [GNU<"objc_precise_lifetime">];
1069 let Subjects = SubjectList<[Var], ErrorDiag>;
1070 let Documentation = [Undocumented];
1073 def ObjCReturnsInnerPointer : InheritableAttr {
1074 let Spellings = [GNU<"objc_returns_inner_pointer">];
1075 let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
1076 let Documentation = [Undocumented];
1079 def ObjCRequiresSuper : InheritableAttr {
1080 let Spellings = [GNU<"objc_requires_super">];
1081 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1082 let Documentation = [ObjCRequiresSuperDocs];
1085 def ObjCRootClass : InheritableAttr {
1086 let Spellings = [GNU<"objc_root_class">];
1087 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1088 let Documentation = [Undocumented];
1091 def ObjCExplicitProtocolImpl : InheritableAttr {
1092 let Spellings = [GNU<"objc_protocol_requires_explicit_implementation">];
1093 let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
1094 let Documentation = [Undocumented];
1097 def ObjCDesignatedInitializer : Attr {
1098 let Spellings = [GNU<"objc_designated_initializer">];
1099 let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag,
1100 "ExpectedObjCInterfaceDeclInitMethod">;
1101 let Documentation = [Undocumented];
1104 def ObjCRuntimeName : Attr {
1105 let Spellings = [GNU<"objc_runtime_name">];
1106 let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
1107 let Args = [StringArgument<"MetadataName">];
1108 let Documentation = [ObjCRuntimeNameDocs];
1111 def OptimizeNone : InheritableAttr {
1112 let Spellings = [GNU<"optnone">, CXX11<"clang", "optnone">];
1113 let Subjects = SubjectList<[Function, ObjCMethod]>;
1114 let Documentation = [OptnoneDocs];
1117 def Overloadable : Attr {
1118 let Spellings = [GNU<"overloadable">];
1119 let Subjects = SubjectList<[Function], ErrorDiag>;
1120 let Documentation = [OverloadableDocs];
1123 def Override : InheritableAttr {
1124 let Spellings = [Keyword<"override">];
1125 let SemaHandler = 0;
1126 let Documentation = [Undocumented];
1129 def Ownership : InheritableAttr {
1130 let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
1131 GNU<"ownership_takes">];
1132 let Accessors = [Accessor<"isHolds", [GNU<"ownership_holds">]>,
1133 Accessor<"isReturns", [GNU<"ownership_returns">]>,
1134 Accessor<"isTakes", [GNU<"ownership_takes">]>];
1135 let AdditionalMembers = [{
1136 enum OwnershipKind { Holds, Returns, Takes };
1137 OwnershipKind getOwnKind() const {
1138 return isHolds() ? Holds :
1143 let Args = [IdentifierArgument<"Module">, VariadicUnsignedArgument<"Args">];
1144 let Subjects = SubjectList<[HasFunctionProto], WarnDiag, "ExpectedFunction">;
1145 let Documentation = [Undocumented];
1148 def Packed : InheritableAttr {
1149 let Spellings = [GCC<"packed">];
1150 // let Subjects = [Tag, Field];
1151 let Documentation = [Undocumented];
1154 def IntelOclBicc : InheritableAttr {
1155 let Spellings = [GNU<"intel_ocl_bicc">];
1156 // let Subjects = [Function, ObjCMethod];
1157 let Documentation = [Undocumented];
1160 def Pcs : InheritableAttr {
1161 let Spellings = [GCC<"pcs">];
1162 let Args = [EnumArgument<"PCS", "PCSType",
1163 ["aapcs", "aapcs-vfp"],
1164 ["AAPCS", "AAPCS_VFP"]>];
1165 // let Subjects = [Function, ObjCMethod];
1166 let Documentation = [PcsDocs];
1169 def Pure : InheritableAttr {
1170 let Spellings = [GCC<"pure">];
1171 let Documentation = [Undocumented];
1174 def Regparm : TypeAttr {
1175 let Spellings = [GCC<"regparm">];
1176 let Args = [UnsignedArgument<"NumParams">];
1177 let Documentation = [RegparmDocs];
1180 def ReqdWorkGroupSize : InheritableAttr {
1181 let Spellings = [GNU<"reqd_work_group_size">];
1182 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
1183 UnsignedArgument<"ZDim">];
1184 let Subjects = SubjectList<[Function], ErrorDiag>;
1185 let Documentation = [Undocumented];
1188 def WorkGroupSizeHint : InheritableAttr {
1189 let Spellings = [GNU<"work_group_size_hint">];
1190 let Args = [UnsignedArgument<"XDim">,
1191 UnsignedArgument<"YDim">,
1192 UnsignedArgument<"ZDim">];
1193 let Subjects = SubjectList<[Function], ErrorDiag>;
1194 let Documentation = [Undocumented];
1197 def InitPriority : InheritableAttr {
1198 let Spellings = [GNU<"init_priority">];
1199 let Args = [UnsignedArgument<"Priority">];
1200 let Subjects = SubjectList<[Var], ErrorDiag>;
1201 let Documentation = [Undocumented];
1204 def Section : InheritableAttr {
1205 let Spellings = [GCC<"section">, Declspec<"allocate">];
1206 let Args = [StringArgument<"Name">];
1207 let Subjects = SubjectList<[Function, GlobalVar,
1208 ObjCMethod, ObjCProperty], ErrorDiag,
1209 "ExpectedFunctionGlobalVarMethodOrProperty">;
1210 let Documentation = [SectionDocs];
1213 def Sentinel : InheritableAttr {
1214 let Spellings = [GCC<"sentinel">];
1215 let Args = [DefaultIntArgument<"Sentinel", 0>,
1216 DefaultIntArgument<"NullPos", 0>];
1217 // let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
1218 let Documentation = [Undocumented];
1221 def StdCall : InheritableAttr {
1222 let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
1223 // let Subjects = [Function, ObjCMethod];
1224 let Documentation = [StdCallDocs];
1227 def SysVABI : InheritableAttr {
1228 let Spellings = [GCC<"sysv_abi">];
1229 // let Subjects = [Function, ObjCMethod];
1230 let Documentation = [Undocumented];
1233 def ThisCall : InheritableAttr {
1234 let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
1235 Keyword<"_thiscall">];
1236 // let Subjects = [Function, ObjCMethod];
1237 let Documentation = [ThisCallDocs];
1240 def VectorCall : InheritableAttr {
1241 let Spellings = [GNU<"vectorcall">, Keyword<"__vectorcall">,
1242 Keyword<"_vectorcall">];
1243 // let Subjects = [Function, ObjCMethod];
1244 let Documentation = [VectorCallDocs];
1247 def Pascal : InheritableAttr {
1248 let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
1249 // let Subjects = [Function, ObjCMethod];
1250 let Documentation = [Undocumented];
1253 def TransparentUnion : InheritableAttr {
1254 let Spellings = [GCC<"transparent_union">];
1255 // let Subjects = SubjectList<[Record, TypedefName]>;
1256 let Documentation = [Undocumented];
1259 def Unavailable : InheritableAttr {
1260 let Spellings = [GNU<"unavailable">];
1261 let Args = [StringArgument<"Message", 1>];
1262 let Documentation = [Undocumented];
1265 def ArcWeakrefUnavailable : InheritableAttr {
1266 let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
1267 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1268 let Documentation = [Undocumented];
1271 def ObjCGC : TypeAttr {
1272 let Spellings = [GNU<"objc_gc">];
1273 let Args = [IdentifierArgument<"Kind">];
1274 let Documentation = [Undocumented];
1277 def ObjCOwnership : InheritableAttr {
1278 let Spellings = [GNU<"objc_ownership">];
1279 let Args = [IdentifierArgument<"Kind">];
1281 let Documentation = [Undocumented];
1284 def ObjCRequiresPropertyDefs : InheritableAttr {
1285 let Spellings = [GNU<"objc_requires_property_definitions">];
1286 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1287 let Documentation = [Undocumented];
1290 def Unused : InheritableAttr {
1291 let Spellings = [GCC<"unused">];
1292 let Subjects = SubjectList<[Var, ObjCIvar, Type, Label, Field, ObjCMethod,
1293 FunctionLike], WarnDiag,
1294 "ExpectedVariableFunctionOrLabel">;
1295 let Documentation = [Undocumented];
1298 def Used : InheritableAttr {
1299 let Spellings = [GCC<"used">];
1300 let Documentation = [Undocumented];
1303 def Uuid : InheritableAttr {
1304 let Spellings = [Declspec<"uuid">];
1305 let Args = [StringArgument<"Guid">];
1306 // let Subjects = SubjectList<[CXXRecord]>;
1307 let LangOpts = [MicrosoftExt, Borland];
1308 let Documentation = [Undocumented];
1311 def VectorSize : TypeAttr {
1312 let Spellings = [GCC<"vector_size">];
1313 let Args = [ExprArgument<"NumBytes">];
1314 let Documentation = [Undocumented];
1317 def VecTypeHint : InheritableAttr {
1318 let Spellings = [GNU<"vec_type_hint">];
1319 let Args = [TypeArgument<"TypeHint">];
1320 let Subjects = SubjectList<[Function], ErrorDiag>;
1321 let Documentation = [Undocumented];
1324 def Visibility : InheritableAttr {
1326 let Spellings = [GCC<"visibility">];
1327 let Args = [EnumArgument<"Visibility", "VisibilityType",
1328 ["default", "hidden", "internal", "protected"],
1329 ["Default", "Hidden", "Hidden", "Protected"]>];
1330 let Documentation = [Undocumented];
1333 def TypeVisibility : InheritableAttr {
1335 let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">];
1336 let Args = [EnumArgument<"Visibility", "VisibilityType",
1337 ["default", "hidden", "internal", "protected"],
1338 ["Default", "Hidden", "Hidden", "Protected"]>];
1339 // let Subjects = [Tag, ObjCInterface, Namespace];
1340 let Documentation = [Undocumented];
1343 def VecReturn : InheritableAttr {
1344 let Spellings = [GNU<"vecreturn">];
1345 let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
1346 let Documentation = [Undocumented];
1349 def WarnUnused : InheritableAttr {
1350 let Spellings = [GNU<"warn_unused">];
1351 let Subjects = SubjectList<[Record]>;
1352 let Documentation = [Undocumented];
1355 def WarnUnusedResult : InheritableAttr {
1356 let Spellings = [GCC<"warn_unused_result">,
1357 CXX11<"clang", "warn_unused_result">];
1358 let Subjects = SubjectList<[ObjCMethod, CXXRecord, FunctionLike], WarnDiag,
1359 "ExpectedFunctionMethodOrClass">;
1360 let Documentation = [Undocumented];
1363 def Weak : InheritableAttr {
1364 let Spellings = [GCC<"weak">];
1365 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
1366 let Documentation = [Undocumented];
1369 def WeakImport : InheritableAttr {
1370 let Spellings = [GNU<"weak_import">];
1371 let Documentation = [Undocumented];
1374 def WeakRef : InheritableAttr {
1375 let Spellings = [GCC<"weakref">];
1376 // A WeakRef that has an argument is treated as being an AliasAttr
1377 let Args = [StringArgument<"Aliasee", 1>];
1378 let Subjects = SubjectList<[Var, Function], ErrorDiag>;
1379 let Documentation = [Undocumented];
1382 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetX86> {
1383 let Spellings = [GNU<"force_align_arg_pointer">];
1384 // Technically, this appertains to a FunctionDecl, but the target-specific
1385 // code silently allows anything function-like (such as typedefs or function
1386 // pointers), but does not apply the attribute to them.
1387 let Documentation = [Undocumented];
1390 def NoSanitize : InheritableAttr {
1391 let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">];
1392 let Args = [VariadicStringArgument<"Sanitizers">];
1393 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
1394 let Documentation = [NoSanitizeDocs];
1395 let AdditionalMembers = [{
1396 SanitizerMask getMask() const {
1397 SanitizerMask Mask = 0;
1398 for (auto SanitizerName : sanitizers()) {
1399 SanitizerMask ParsedMask =
1400 parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
1401 Mask |= expandSanitizerGroups(ParsedMask);
1408 // Attributes to disable a specific sanitizer. No new sanitizers should be added
1409 // to this list; the no_sanitize attribute should be extended instead.
1410 def NoSanitizeSpecific : InheritableAttr {
1411 let Spellings = [GCC<"no_address_safety_analysis">,
1412 GCC<"no_sanitize_address">,
1413 GCC<"no_sanitize_thread">,
1414 GNU<"no_sanitize_memory">];
1415 let Subjects = SubjectList<[Function], ErrorDiag>;
1416 let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
1417 NoSanitizeMemoryDocs];
1421 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
1423 def GuardedVar : InheritableAttr {
1424 let Spellings = [GNU<"guarded_var">];
1425 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1426 "ExpectedFieldOrGlobalVar">;
1427 let Documentation = [Undocumented];
1430 def PtGuardedVar : InheritableAttr {
1431 let Spellings = [GNU<"pt_guarded_var">];
1432 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1433 "ExpectedFieldOrGlobalVar">;
1434 let Documentation = [Undocumented];
1437 def Lockable : InheritableAttr {
1438 let Spellings = [GNU<"lockable">];
1439 let Subjects = SubjectList<[Record]>;
1440 let Documentation = [Undocumented];
1441 let ASTNode = 0; // Replaced by Capability
1444 def ScopedLockable : InheritableAttr {
1445 let Spellings = [GNU<"scoped_lockable">];
1446 let Subjects = SubjectList<[Record]>;
1447 let Documentation = [Undocumented];
1450 def Capability : InheritableAttr {
1451 let Spellings = [GNU<"capability">, CXX11<"clang", "capability">,
1452 GNU<"shared_capability">,
1453 CXX11<"clang", "shared_capability">];
1454 let Subjects = SubjectList<[Struct, TypedefName], ErrorDiag,
1455 "ExpectedStructOrTypedef">;
1456 let Args = [StringArgument<"Name">];
1457 let Accessors = [Accessor<"isShared",
1458 [GNU<"shared_capability">,
1459 CXX11<"clang","shared_capability">]>];
1460 let Documentation = [Undocumented];
1461 let AdditionalMembers = [{
1462 bool isMutex() const { return getName().equals_lower("mutex"); }
1463 bool isRole() const { return getName().equals_lower("role"); }
1467 def AssertCapability : InheritableAttr {
1468 let Spellings = [GNU<"assert_capability">,
1469 CXX11<"clang", "assert_capability">,
1470 GNU<"assert_shared_capability">,
1471 CXX11<"clang", "assert_shared_capability">];
1472 let Subjects = SubjectList<[Function]>;
1474 let TemplateDependent = 1;
1475 let ParseArgumentsAsUnevaluated = 1;
1476 let DuplicatesAllowedWhileMerging = 1;
1477 let Args = [ExprArgument<"Expr">];
1478 let Accessors = [Accessor<"isShared",
1479 [GNU<"assert_shared_capability">,
1480 CXX11<"clang", "assert_shared_capability">]>];
1481 let Documentation = [AssertCapabilityDocs];
1484 def AcquireCapability : InheritableAttr {
1485 let Spellings = [GNU<"acquire_capability">,
1486 CXX11<"clang", "acquire_capability">,
1487 GNU<"acquire_shared_capability">,
1488 CXX11<"clang", "acquire_shared_capability">,
1489 GNU<"exclusive_lock_function">,
1490 GNU<"shared_lock_function">];
1491 let Subjects = SubjectList<[Function]>;
1493 let TemplateDependent = 1;
1494 let ParseArgumentsAsUnevaluated = 1;
1495 let DuplicatesAllowedWhileMerging = 1;
1496 let Args = [VariadicExprArgument<"Args">];
1497 let Accessors = [Accessor<"isShared",
1498 [GNU<"acquire_shared_capability">,
1499 CXX11<"clang", "acquire_shared_capability">,
1500 GNU<"shared_lock_function">]>];
1501 let Documentation = [AcquireCapabilityDocs];
1504 def TryAcquireCapability : InheritableAttr {
1505 let Spellings = [GNU<"try_acquire_capability">,
1506 CXX11<"clang", "try_acquire_capability">,
1507 GNU<"try_acquire_shared_capability">,
1508 CXX11<"clang", "try_acquire_shared_capability">];
1509 let Subjects = SubjectList<[Function],
1512 let TemplateDependent = 1;
1513 let ParseArgumentsAsUnevaluated = 1;
1514 let DuplicatesAllowedWhileMerging = 1;
1515 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1516 let Accessors = [Accessor<"isShared",
1517 [GNU<"try_acquire_shared_capability">,
1518 CXX11<"clang", "try_acquire_shared_capability">]>];
1519 let Documentation = [TryAcquireCapabilityDocs];
1522 def ReleaseCapability : InheritableAttr {
1523 let Spellings = [GNU<"release_capability">,
1524 CXX11<"clang", "release_capability">,
1525 GNU<"release_shared_capability">,
1526 CXX11<"clang", "release_shared_capability">,
1527 GNU<"release_generic_capability">,
1528 CXX11<"clang", "release_generic_capability">,
1529 GNU<"unlock_function">];
1530 let Subjects = SubjectList<[Function]>;
1532 let TemplateDependent = 1;
1533 let ParseArgumentsAsUnevaluated = 1;
1534 let DuplicatesAllowedWhileMerging = 1;
1535 let Args = [VariadicExprArgument<"Args">];
1536 let Accessors = [Accessor<"isShared",
1537 [GNU<"release_shared_capability">,
1538 CXX11<"clang", "release_shared_capability">]>,
1539 Accessor<"isGeneric",
1540 [GNU<"release_generic_capability">,
1541 CXX11<"clang", "release_generic_capability">,
1542 GNU<"unlock_function">]>];
1543 let Documentation = [ReleaseCapabilityDocs];
1546 def RequiresCapability : InheritableAttr {
1547 let Spellings = [GNU<"requires_capability">,
1548 CXX11<"clang", "requires_capability">,
1549 GNU<"exclusive_locks_required">,
1550 GNU<"requires_shared_capability">,
1551 CXX11<"clang", "requires_shared_capability">,
1552 GNU<"shared_locks_required">];
1553 let Args = [VariadicExprArgument<"Args">];
1555 let TemplateDependent = 1;
1556 let ParseArgumentsAsUnevaluated = 1;
1557 let DuplicatesAllowedWhileMerging = 1;
1558 let Subjects = SubjectList<[Function]>;
1559 let Accessors = [Accessor<"isShared", [GNU<"requires_shared_capability">,
1560 GNU<"shared_locks_required">,
1561 CXX11<"clang","requires_shared_capability">]>];
1562 let Documentation = [Undocumented];
1565 def NoThreadSafetyAnalysis : InheritableAttr {
1566 let Spellings = [GNU<"no_thread_safety_analysis">];
1567 let Subjects = SubjectList<[Function]>;
1568 let Documentation = [Undocumented];
1571 def GuardedBy : InheritableAttr {
1572 let Spellings = [GNU<"guarded_by">];
1573 let Args = [ExprArgument<"Arg">];
1575 let TemplateDependent = 1;
1576 let ParseArgumentsAsUnevaluated = 1;
1577 let DuplicatesAllowedWhileMerging = 1;
1578 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1579 "ExpectedFieldOrGlobalVar">;
1580 let Documentation = [Undocumented];
1583 def PtGuardedBy : InheritableAttr {
1584 let Spellings = [GNU<"pt_guarded_by">];
1585 let Args = [ExprArgument<"Arg">];
1587 let TemplateDependent = 1;
1588 let ParseArgumentsAsUnevaluated = 1;
1589 let DuplicatesAllowedWhileMerging = 1;
1590 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1591 "ExpectedFieldOrGlobalVar">;
1592 let Documentation = [Undocumented];
1595 def AcquiredAfter : InheritableAttr {
1596 let Spellings = [GNU<"acquired_after">];
1597 let Args = [VariadicExprArgument<"Args">];
1599 let TemplateDependent = 1;
1600 let ParseArgumentsAsUnevaluated = 1;
1601 let DuplicatesAllowedWhileMerging = 1;
1602 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1603 "ExpectedFieldOrGlobalVar">;
1604 let Documentation = [Undocumented];
1607 def AcquiredBefore : InheritableAttr {
1608 let Spellings = [GNU<"acquired_before">];
1609 let Args = [VariadicExprArgument<"Args">];
1611 let TemplateDependent = 1;
1612 let ParseArgumentsAsUnevaluated = 1;
1613 let DuplicatesAllowedWhileMerging = 1;
1614 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1615 "ExpectedFieldOrGlobalVar">;
1616 let Documentation = [Undocumented];
1619 def AssertExclusiveLock : InheritableAttr {
1620 let Spellings = [GNU<"assert_exclusive_lock">];
1621 let Args = [VariadicExprArgument<"Args">];
1623 let TemplateDependent = 1;
1624 let ParseArgumentsAsUnevaluated = 1;
1625 let DuplicatesAllowedWhileMerging = 1;
1626 let Subjects = SubjectList<[Function]>;
1627 let Documentation = [Undocumented];
1630 def AssertSharedLock : InheritableAttr {
1631 let Spellings = [GNU<"assert_shared_lock">];
1632 let Args = [VariadicExprArgument<"Args">];
1634 let TemplateDependent = 1;
1635 let ParseArgumentsAsUnevaluated = 1;
1636 let DuplicatesAllowedWhileMerging = 1;
1637 let Subjects = SubjectList<[Function]>;
1638 let Documentation = [Undocumented];
1641 // The first argument is an integer or boolean value specifying the return value
1642 // of a successful lock acquisition.
1643 def ExclusiveTrylockFunction : InheritableAttr {
1644 let Spellings = [GNU<"exclusive_trylock_function">];
1645 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1647 let TemplateDependent = 1;
1648 let ParseArgumentsAsUnevaluated = 1;
1649 let DuplicatesAllowedWhileMerging = 1;
1650 let Subjects = SubjectList<[Function]>;
1651 let Documentation = [Undocumented];
1654 // The first argument is an integer or boolean value specifying the return value
1655 // of a successful lock acquisition.
1656 def SharedTrylockFunction : InheritableAttr {
1657 let Spellings = [GNU<"shared_trylock_function">];
1658 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1660 let TemplateDependent = 1;
1661 let ParseArgumentsAsUnevaluated = 1;
1662 let DuplicatesAllowedWhileMerging = 1;
1663 let Subjects = SubjectList<[Function]>;
1664 let Documentation = [Undocumented];
1667 def LockReturned : InheritableAttr {
1668 let Spellings = [GNU<"lock_returned">];
1669 let Args = [ExprArgument<"Arg">];
1671 let TemplateDependent = 1;
1672 let ParseArgumentsAsUnevaluated = 1;
1673 let Subjects = SubjectList<[Function]>;
1674 let Documentation = [Undocumented];
1677 def LocksExcluded : InheritableAttr {
1678 let Spellings = [GNU<"locks_excluded">];
1679 let Args = [VariadicExprArgument<"Args">];
1681 let TemplateDependent = 1;
1682 let ParseArgumentsAsUnevaluated = 1;
1683 let DuplicatesAllowedWhileMerging = 1;
1684 let Subjects = SubjectList<[Function]>;
1685 let Documentation = [Undocumented];
1688 // C/C++ consumed attributes.
1690 def Consumable : InheritableAttr {
1691 let Spellings = [GNU<"consumable">];
1692 let Subjects = SubjectList<[CXXRecord]>;
1693 let Args = [EnumArgument<"DefaultState", "ConsumedState",
1694 ["unknown", "consumed", "unconsumed"],
1695 ["Unknown", "Consumed", "Unconsumed"]>];
1696 let Documentation = [ConsumableDocs];
1699 def ConsumableAutoCast : InheritableAttr {
1700 let Spellings = [GNU<"consumable_auto_cast_state">];
1701 let Subjects = SubjectList<[CXXRecord]>;
1702 let Documentation = [Undocumented];
1705 def ConsumableSetOnRead : InheritableAttr {
1706 let Spellings = [GNU<"consumable_set_state_on_read">];
1707 let Subjects = SubjectList<[CXXRecord]>;
1708 let Documentation = [Undocumented];
1711 def CallableWhen : InheritableAttr {
1712 let Spellings = [GNU<"callable_when">];
1713 let Subjects = SubjectList<[CXXMethod]>;
1714 let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
1715 ["unknown", "consumed", "unconsumed"],
1716 ["Unknown", "Consumed", "Unconsumed"]>];
1717 let Documentation = [CallableWhenDocs];
1720 def ParamTypestate : InheritableAttr {
1721 let Spellings = [GNU<"param_typestate">];
1722 let Subjects = SubjectList<[ParmVar]>;
1723 let Args = [EnumArgument<"ParamState", "ConsumedState",
1724 ["unknown", "consumed", "unconsumed"],
1725 ["Unknown", "Consumed", "Unconsumed"]>];
1726 let Documentation = [ParamTypestateDocs];
1729 def ReturnTypestate : InheritableAttr {
1730 let Spellings = [GNU<"return_typestate">];
1731 let Subjects = SubjectList<[Function, ParmVar]>;
1732 let Args = [EnumArgument<"State", "ConsumedState",
1733 ["unknown", "consumed", "unconsumed"],
1734 ["Unknown", "Consumed", "Unconsumed"]>];
1735 let Documentation = [ReturnTypestateDocs];
1738 def SetTypestate : InheritableAttr {
1739 let Spellings = [GNU<"set_typestate">];
1740 let Subjects = SubjectList<[CXXMethod]>;
1741 let Args = [EnumArgument<"NewState", "ConsumedState",
1742 ["unknown", "consumed", "unconsumed"],
1743 ["Unknown", "Consumed", "Unconsumed"]>];
1744 let Documentation = [SetTypestateDocs];
1747 def TestTypestate : InheritableAttr {
1748 let Spellings = [GNU<"test_typestate">];
1749 let Subjects = SubjectList<[CXXMethod]>;
1750 let Args = [EnumArgument<"TestState", "ConsumedState",
1751 ["consumed", "unconsumed"],
1752 ["Consumed", "Unconsumed"]>];
1753 let Documentation = [TestTypestateDocs];
1756 // Type safety attributes for `void *' pointers and type tags.
1758 def ArgumentWithTypeTag : InheritableAttr {
1759 let Spellings = [GNU<"argument_with_type_tag">,
1760 GNU<"pointer_with_type_tag">];
1761 let Args = [IdentifierArgument<"ArgumentKind">,
1762 UnsignedArgument<"ArgumentIdx">,
1763 UnsignedArgument<"TypeTagIdx">,
1764 BoolArgument<"IsPointer">];
1765 let HasCustomParsing = 1;
1766 let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
1769 def TypeTagForDatatype : InheritableAttr {
1770 let Spellings = [GNU<"type_tag_for_datatype">];
1771 let Args = [IdentifierArgument<"ArgumentKind">,
1772 TypeArgument<"MatchingCType">,
1773 BoolArgument<"LayoutCompatible">,
1774 BoolArgument<"MustBeNull">];
1775 // let Subjects = SubjectList<[Var], ErrorDiag>;
1776 let HasCustomParsing = 1;
1777 let Documentation = [TypeTagForDatatypeDocs];
1780 // Microsoft-related attributes
1782 def MSNoVTable : InheritableAttr {
1783 let Spellings = [Declspec<"novtable">];
1784 let Subjects = SubjectList<[CXXRecord]>;
1785 let Documentation = [MSNoVTableDocs];
1789 let Spellings = [Declspec<"property">];
1792 def MSStruct : InheritableAttr {
1793 let Spellings = [GCC<"ms_struct">];
1794 let Subjects = SubjectList<[Record]>;
1795 let Documentation = [Undocumented];
1798 def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
1799 let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
1800 let Subjects = SubjectList<[Function, Var, CXXRecord]>;
1801 let Documentation = [Undocumented];
1804 def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
1805 let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
1806 let Subjects = SubjectList<[Function, Var, CXXRecord]>;
1807 let Documentation = [Undocumented];
1810 def SelectAny : InheritableAttr {
1811 let Spellings = [Declspec<"selectany">];
1812 let LangOpts = [MicrosoftExt];
1813 let Documentation = [Undocumented];
1817 let Spellings = [Declspec<"thread">];
1818 let LangOpts = [MicrosoftExt];
1819 let Documentation = [ThreadDocs];
1820 let Subjects = SubjectList<[Var]>;
1823 def Win64 : IgnoredAttr {
1824 let Spellings = [Keyword<"__w64">];
1825 let LangOpts = [MicrosoftExt];
1828 def Ptr32 : TypeAttr {
1829 let Spellings = [Keyword<"__ptr32">];
1830 let Documentation = [Undocumented];
1833 def Ptr64 : TypeAttr {
1834 let Spellings = [Keyword<"__ptr64">];
1835 let Documentation = [Undocumented];
1838 def SPtr : TypeAttr {
1839 let Spellings = [Keyword<"__sptr">];
1840 let Documentation = [Undocumented];
1843 def UPtr : TypeAttr {
1844 let Spellings = [Keyword<"__uptr">];
1845 let Documentation = [Undocumented];
1848 def MSInheritance : InheritableAttr {
1849 let LangOpts = [MicrosoftExt];
1850 let Args = [DefaultBoolArgument<"BestCase", 1>];
1851 let Spellings = [Keyword<"__single_inheritance">,
1852 Keyword<"__multiple_inheritance">,
1853 Keyword<"__virtual_inheritance">,
1854 Keyword<"__unspecified_inheritance">];
1855 let AdditionalMembers = [{
1856 static bool hasVBPtrOffsetField(Spelling Inheritance) {
1857 return Inheritance == Keyword_unspecified_inheritance;
1860 // Only member pointers to functions need a this adjustment, since it can be
1861 // combined with the field offset for data pointers.
1862 static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
1863 return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
1866 static bool hasVBTableOffsetField(Spelling Inheritance) {
1867 return Inheritance >= Keyword_virtual_inheritance;
1870 static bool hasOnlyOneField(bool IsMemberFunction,
1871 Spelling Inheritance) {
1872 if (IsMemberFunction)
1873 return Inheritance <= Keyword_single_inheritance;
1874 return Inheritance <= Keyword_multiple_inheritance;
1877 let Documentation = [MSInheritanceDocs];
1880 def MSVtorDisp : InheritableAttr {
1881 // This attribute has no spellings as it is only ever created implicitly.
1883 let Args = [UnsignedArgument<"vdm">];
1884 let SemaHandler = 0;
1886 let AdditionalMembers = [{
1893 Mode getVtorDispMode() const { return Mode(vdm); }
1895 let Documentation = [Undocumented];
1898 def InitSeg : Attr {
1899 let Spellings = [Pragma<"", "init_seg">];
1900 let Args = [StringArgument<"Section">];
1901 let SemaHandler = 0;
1902 let Documentation = [InitSegDocs];
1903 let AdditionalMembers = [{
1904 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
1905 OS << '(' << getSection() << ')';
1910 def Unaligned : IgnoredAttr {
1911 let Spellings = [Keyword<"__unaligned">];
1914 def LoopHint : Attr {
1915 /// #pragma clang loop <option> directive
1916 /// vectorize: vectorizes loop operations if State == Enable.
1917 /// vectorize_width: vectorize loop operations with width 'Value'.
1918 /// interleave: interleave multiple loop iterations if State == Enable.
1919 /// interleave_count: interleaves 'Value' loop interations.
1920 /// unroll: fully unroll loop if State == Enable.
1921 /// unroll_count: unrolls loop 'Value' times.
1923 /// #pragma unroll <argument> directive
1924 /// <no arg>: fully unrolls loop.
1925 /// boolean: fully unrolls loop if State == Enable.
1926 /// expression: unrolls loop 'Value' times.
1928 let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">,
1929 Pragma<"", "nounroll">];
1931 /// State of the loop optimization specified by the spelling.
1932 let Args = [EnumArgument<"Option", "OptionType",
1933 ["vectorize", "vectorize_width", "interleave", "interleave_count",
1934 "unroll", "unroll_count"],
1935 ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
1936 "Unroll", "UnrollCount"]>,
1937 EnumArgument<"State", "LoopHintState",
1938 ["default", "enable", "disable"],
1939 ["Default", "Enable", "Disable"]>,
1940 ExprArgument<"Value">];
1942 let AdditionalMembers = [{
1943 static const char *getOptionName(int Option) {
1945 case Vectorize: return "vectorize";
1946 case VectorizeWidth: return "vectorize_width";
1947 case Interleave: return "interleave";
1948 case InterleaveCount: return "interleave_count";
1949 case Unroll: return "unroll";
1950 case UnrollCount: return "unroll_count";
1952 llvm_unreachable("Unhandled LoopHint option.");
1955 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
1956 unsigned SpellingIndex = getSpellingListIndex();
1957 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
1958 // "nounroll" is already emitted as the pragma name.
1959 if (SpellingIndex == Pragma_nounroll) {
1963 else if (SpellingIndex == Pragma_unroll) {
1964 OS << getValueString(Policy) << "\n";
1968 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
1969 OS << getOptionName(option) << getValueString(Policy) << "\n";
1972 // Return a string containing the loop hint argument including the
1973 // enclosing parentheses.
1974 std::string getValueString(const PrintingPolicy &Policy) const {
1975 std::string ValueName;
1976 llvm::raw_string_ostream OS(ValueName);
1978 if (option == VectorizeWidth || option == InterleaveCount ||
1979 option == UnrollCount)
1980 value->printPretty(OS, nullptr, Policy);
1981 else if (state == Default)
1983 else if (state == Enable)
1984 OS << (option == Unroll ? "full" : "enable");
1991 // Return a string suitable for identifying this attribute in diagnostics.
1992 std::string getDiagnosticName(const PrintingPolicy &Policy) const {
1993 unsigned SpellingIndex = getSpellingListIndex();
1994 if (SpellingIndex == Pragma_nounroll)
1995 return "#pragma nounroll";
1996 else if (SpellingIndex == Pragma_unroll)
1997 return "#pragma unroll" + getValueString(Policy);
1999 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2000 return getOptionName(option) + getValueString(Policy);
2004 let Documentation = [LoopHintDocs, UnrollHintDocs];
2007 def CapturedRecord : InheritableAttr {
2008 // This attribute has no spellings as it is only ever created implicitly.
2010 let SemaHandler = 0;
2011 let Documentation = [Undocumented];
2014 def OMPThreadPrivateDecl : InheritableAttr {
2015 // This attribute has no spellings as it is only ever created implicitly.
2017 let SemaHandler = 0;
2018 let Documentation = [Undocumented];