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;
199 class Keyword<string name> : Spelling<name, "Keyword">;
200 class Pragma<string namespace, string name> : Spelling<name, "Pragma"> {
201 string Namespace = namespace;
204 // The GCC spelling implies GNU<name, "GNU"> and CXX11<"gnu", name> and also
205 // sets KnownToGCC to 1. This spelling should be used for any GCC-compatible
207 class GCC<string name> : Spelling<name, "GCC"> {
211 class Accessor<string name, list<Spelling> spellings> {
213 list<Spelling> Spellings = spellings;
216 class SubjectDiag<bit warn> {
219 def WarnDiag : SubjectDiag<1>;
220 def ErrorDiag : SubjectDiag<0>;
222 class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag,
223 string customDiag = ""> {
224 list<AttrSubject> Subjects = subjects;
225 SubjectDiag Diag = diag;
226 string CustomDiag = customDiag;
229 class LangOpt<string name, bit negated = 0> {
231 bit Negated = negated;
233 def MicrosoftExt : LangOpt<"MicrosoftExt">;
234 def Borland : LangOpt<"Borland">;
235 def CUDA : LangOpt<"CUDA">;
236 def COnly : LangOpt<"CPlusPlus", 1>;
238 // Defines targets for target-specific attributes. The list of strings should
239 // specify architectures for which the target applies, based off the ArchType
240 // enumeration in Triple.h.
241 class TargetArch<list<string> arches> {
242 list<string> Arches = arches;
245 def TargetARM : TargetArch<["arm", "thumb"]>;
246 def TargetMSP430 : TargetArch<["msp430"]>;
247 def TargetX86 : TargetArch<["x86"]>;
248 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
249 let OSes = ["Win32"];
251 def TargetMips : TargetArch<["mips", "mipsel"]>;
254 // The various ways in which an attribute can be spelled in source
255 list<Spelling> Spellings;
256 // The things to which an attribute can appertain
257 SubjectList Subjects;
258 // The arguments allowed on an attribute
259 list<Argument> Args = [];
260 // Accessors which should be generated for the attribute.
261 list<Accessor> Accessors = [];
262 // Set to true for attributes with arguments which require delayed parsing.
264 // Set to false to prevent an attribute from being propagated from a template
265 // to the instantiation.
267 // Set to true for attributes which must be instantiated within templates
268 bit TemplateDependent = 0;
269 // Set to true for attributes that have a corresponding AST node.
271 // Set to true for attributes which have handler in Sema.
273 // Set to true for attributes that are completely ignored.
275 // Set to true if the attribute's parsing does not match its semantic
276 // content. Eg) It parses 3 args, but semantically takes 4 args. Opts out of
277 // common attribute error checking.
278 bit HasCustomParsing = 0;
279 // Set to true if all of the attribute's arguments should be parsed in an
280 // unevaluated context.
281 bit ParseArgumentsAsUnevaluated = 0;
282 // Set to true if this attribute can be duplicated on a subject when merging
283 // attributes. By default, attributes are not merged.
284 bit DuplicatesAllowedWhileMerging = 0;
285 // Lists language options, one of which is required to be true for the
286 // attribute to be applicable. If empty, no language options are required.
287 list<LangOpt> LangOpts = [];
288 // Any additional text that should be included verbatim in the class.
289 code AdditionalMembers = [{}];
290 // Any documentation that should be associated with the attribute. Since an
291 // attribute may be documented under multiple categories, more than one
292 // Documentation entry may be listed.
293 list<Documentation> Documentation;
296 /// A type attribute is not processed on a declaration or a statement.
297 class TypeAttr : Attr {
298 // By default, type attributes do not get an AST node.
302 /// An inheritable attribute is inherited by later redeclarations.
303 class InheritableAttr : Attr;
305 /// A target-specific attribute. This class is meant to be used as a mixin
306 /// with InheritableAttr or Attr depending on the attribute's needs.
307 class TargetSpecificAttr<TargetArch target> {
308 TargetArch Target = target;
309 // Attributes are generally required to have unique spellings for their names
310 // so that the parser can determine what kind of attribute it has parsed.
311 // However, target-specific attributes are special in that the attribute only
312 // "exists" for a given target. So two target-specific attributes can share
313 // the same name when they exist in different targets. To support this, a
314 // Kind can be explicitly specified for a target-specific attribute. This
315 // corresponds to the AttributeList::AT_* enum that is generated and it
316 // should contain a shared value between the attributes.
318 // Target-specific attributes which use this feature should ensure that the
319 // spellings match exactly betweeen the attributes, and if the arguments or
320 // subjects differ, should specify HasCustomParsing = 1 and implement their
321 // own parsing and semantic handling requirements as-needed.
325 /// An inheritable parameter attribute is inherited by later
326 /// redeclarations, even when it's written on a parameter.
327 class InheritableParamAttr : InheritableAttr;
329 /// An ignored attribute, which we parse but discard with no checking.
330 class IgnoredAttr : Attr {
334 let Documentation = [Undocumented];
338 // Attributes begin here
341 def AddressSpace : TypeAttr {
342 let Spellings = [GNU<"address_space">];
343 let Args = [IntArgument<"AddressSpace">];
344 let Documentation = [Undocumented];
348 let Spellings = [GCC<"alias">];
349 let Args = [StringArgument<"Aliasee">];
350 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
351 "ExpectedFunctionGlobalVarMethodOrProperty">;
352 let Documentation = [Undocumented];
355 def Aligned : InheritableAttr {
356 let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">,
357 Keyword<"_Alignas">];
358 // let Subjects = SubjectList<[NonBitField, NormalVar, Tag]>;
359 let Args = [AlignedArgument<"Alignment", 1>];
360 let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
361 Accessor<"isC11", [Keyword<"_Alignas">]>,
362 Accessor<"isAlignas", [Keyword<"alignas">,
363 Keyword<"_Alignas">]>,
364 Accessor<"isDeclspec",[Declspec<"align">]>];
365 let Documentation = [Undocumented];
368 def AlignValue : Attr {
370 // Unfortunately, this is semantically an assertion, not a directive
371 // (something else must ensure the alignment), so aligned_value is a
372 // probably a better name. We might want to add an aligned_value spelling in
373 // the future (and a corresponding C++ attribute), but this can be done
374 // later once we decide if we also want them to have slightly-different
375 // semantics than Intel's align_value.
377 // Intel's compiler on Windows also supports:
378 // , Declspec<"align_value">
380 let Args = [ExprArgument<"Alignment">];
381 let Subjects = SubjectList<[Var, TypedefName], WarnDiag,
382 "ExpectedVariableOrTypedef">;
383 let Documentation = [AlignValueDocs];
386 def AlignMac68k : InheritableAttr {
387 // This attribute has no spellings as it is only ever created implicitly.
390 let Documentation = [Undocumented];
393 def AlwaysInline : InheritableAttr {
394 let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
395 let Subjects = SubjectList<[Function]>;
396 let Documentation = [Undocumented];
399 def TLSModel : InheritableAttr {
400 let Spellings = [GCC<"tls_model">];
401 let Subjects = SubjectList<[TLSVar], ErrorDiag, "ExpectedTLSVar">;
402 let Args = [StringArgument<"Model">];
403 let Documentation = [TLSModelDocs];
406 def AnalyzerNoReturn : InheritableAttr {
407 let Spellings = [GNU<"analyzer_noreturn">];
408 let Documentation = [Undocumented];
411 def Annotate : InheritableParamAttr {
412 let Spellings = [GNU<"annotate">];
413 let Args = [StringArgument<"Annotation">];
414 let Documentation = [Undocumented];
417 def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> {
418 // NOTE: If you add any additional spellings, MSP430Interrupt's spellings
420 let Spellings = [GNU<"interrupt">];
421 let Args = [EnumArgument<"Interrupt", "InterruptType",
422 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
423 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
425 let ParseKind = "Interrupt";
426 let HasCustomParsing = 1;
427 let Documentation = [ARMInterruptDocs];
430 def AsmLabel : InheritableAttr {
431 let Spellings = [Keyword<"asm">, Keyword<"__asm__">];
432 let Args = [StringArgument<"Label">];
434 let Documentation = [Undocumented];
437 def Availability : InheritableAttr {
438 let Spellings = [GNU<"availability">];
439 let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
440 VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
441 BoolArgument<"unavailable">, StringArgument<"message">];
442 let AdditionalMembers =
443 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
444 return llvm::StringSwitch<llvm::StringRef>(Platform)
445 .Case("android", "Android")
447 .Case("macosx", "OS X")
448 .Case("ios_app_extension", "iOS (App Extension)")
449 .Case("macosx_app_extension", "OS X (App Extension)")
450 .Default(llvm::StringRef());
452 let HasCustomParsing = 1;
453 let DuplicatesAllowedWhileMerging = 1;
454 // let Subjects = SubjectList<[Named]>;
455 let Documentation = [AvailabilityDocs];
458 def Blocks : InheritableAttr {
459 let Spellings = [GNU<"blocks">];
460 let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
461 let Documentation = [Undocumented];
464 def Bounded : IgnoredAttr {
465 let Spellings = [GNU<"bounded">];
468 def CarriesDependency : InheritableParamAttr {
469 let Spellings = [GNU<"carries_dependency">,
470 CXX11<"","carries_dependency", 200809>];
471 let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>;
472 let Documentation = [CarriesDependencyDocs];
475 def CDecl : InheritableAttr {
476 let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">];
477 // let Subjects = [Function, ObjCMethod];
478 let Documentation = [Undocumented];
481 // cf_audited_transfer indicates that the given function has been
482 // audited and has been marked with the appropriate cf_consumed and
483 // cf_returns_retained attributes. It is generally applied by
484 // '#pragma clang arc_cf_code_audited' rather than explicitly.
485 def CFAuditedTransfer : InheritableAttr {
486 let Spellings = [GNU<"cf_audited_transfer">];
487 let Subjects = SubjectList<[Function], ErrorDiag>;
488 let Documentation = [Undocumented];
491 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
492 // It indicates that the function has unknown or unautomatable
493 // transfer semantics.
494 def CFUnknownTransfer : InheritableAttr {
495 let Spellings = [GNU<"cf_unknown_transfer">];
496 let Subjects = SubjectList<[Function], ErrorDiag>;
497 let Documentation = [Undocumented];
500 def CFReturnsRetained : InheritableAttr {
501 let Spellings = [GNU<"cf_returns_retained">];
502 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
503 let Documentation = [Undocumented];
506 def CFReturnsNotRetained : InheritableAttr {
507 let Spellings = [GNU<"cf_returns_not_retained">];
508 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
509 let Documentation = [Undocumented];
512 def CFConsumed : InheritableParamAttr {
513 let Spellings = [GNU<"cf_consumed">];
514 let Subjects = SubjectList<[ParmVar]>;
515 let Documentation = [Undocumented];
518 def Cleanup : InheritableAttr {
519 let Spellings = [GCC<"cleanup">];
520 let Args = [FunctionArgument<"FunctionDecl">];
521 let Subjects = SubjectList<[Var]>;
522 let Documentation = [Undocumented];
525 def Cold : InheritableAttr {
526 let Spellings = [GCC<"cold">];
527 let Subjects = SubjectList<[Function]>;
528 let Documentation = [Undocumented];
531 def Common : InheritableAttr {
532 let Spellings = [GCC<"common">];
533 let Subjects = SubjectList<[Var]>;
534 let Documentation = [Undocumented];
537 def Const : InheritableAttr {
538 let Spellings = [GCC<"const">, GCC<"__const">];
539 let Documentation = [Undocumented];
542 def Constructor : InheritableAttr {
543 let Spellings = [GCC<"constructor">];
544 let Args = [DefaultIntArgument<"Priority", 65535>];
545 let Subjects = SubjectList<[Function]>;
546 let Documentation = [Undocumented];
549 def CUDAConstant : InheritableAttr {
550 let Spellings = [GNU<"constant">];
551 let Subjects = SubjectList<[Var]>;
552 let LangOpts = [CUDA];
553 let Documentation = [Undocumented];
556 def CUDADevice : InheritableAttr {
557 let Spellings = [GNU<"device">];
558 let Subjects = SubjectList<[Function, Var]>;
559 let LangOpts = [CUDA];
560 let Documentation = [Undocumented];
563 def CUDAGlobal : InheritableAttr {
564 let Spellings = [GNU<"global">];
565 let Subjects = SubjectList<[Function]>;
566 let LangOpts = [CUDA];
567 let Documentation = [Undocumented];
570 def CUDAHost : InheritableAttr {
571 let Spellings = [GNU<"host">];
572 let Subjects = SubjectList<[Function]>;
573 let LangOpts = [CUDA];
574 let Documentation = [Undocumented];
577 def CUDAInvalidTarget : InheritableAttr {
579 let Subjects = SubjectList<[Function]>;
580 let LangOpts = [CUDA];
581 let Documentation = [Undocumented];
584 def CUDALaunchBounds : InheritableAttr {
585 let Spellings = [GNU<"launch_bounds">];
586 let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>];
587 let LangOpts = [CUDA];
588 let Subjects = SubjectList<[ObjCMethod, FunctionLike], WarnDiag,
589 "ExpectedFunctionOrMethod">;
590 // An AST node is created for this attribute, but is not used by other parts
591 // of the compiler. However, this node needs to exist in the AST because
592 // non-LLVM backends may be relying on the attribute's presence.
593 let Documentation = [Undocumented];
596 def CUDAShared : InheritableAttr {
597 let Spellings = [GNU<"shared">];
598 let Subjects = SubjectList<[Var]>;
599 let LangOpts = [CUDA];
600 let Documentation = [Undocumented];
603 def C11NoReturn : InheritableAttr {
604 let Spellings = [Keyword<"_Noreturn">];
605 let Subjects = SubjectList<[Function], ErrorDiag>;
607 let Documentation = [C11NoReturnDocs];
610 def CXX11NoReturn : InheritableAttr {
611 let Spellings = [CXX11<"","noreturn", 200809>];
612 let Subjects = SubjectList<[Function], ErrorDiag>;
613 let Documentation = [CXX11NoReturnDocs];
616 def OpenCLKernel : InheritableAttr {
617 let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
618 let Subjects = SubjectList<[Function], ErrorDiag>;
619 let Documentation = [Undocumented];
622 // This attribute is both a type attribute, and a declaration attribute (for
623 // parameter variables).
624 def OpenCLImageAccess : Attr {
625 let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
626 Keyword<"__write_only">, Keyword<"write_only">,
627 Keyword<"__read_write">, Keyword<"read_write">];
628 let Subjects = SubjectList<[ParmVar], ErrorDiag>;
629 let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
630 Keyword<"read_only">]>,
631 Accessor<"isReadWrite", [Keyword<"__read_write">,
632 Keyword<"read_write">]>,
633 Accessor<"isWriteOnly", [Keyword<"__write_only">,
634 Keyword<"write_only">]>];
635 let Documentation = [Undocumented];
638 def OpenCLPrivateAddressSpace : TypeAttr {
639 let Spellings = [Keyword<"__private">, Keyword<"private">];
640 let Documentation = [OpenCLAddressSpacePrivateDocs];
643 def OpenCLGlobalAddressSpace : TypeAttr {
644 let Spellings = [Keyword<"__global">, Keyword<"global">];
645 let Documentation = [OpenCLAddressSpaceGlobalDocs];
648 def OpenCLLocalAddressSpace : TypeAttr {
649 let Spellings = [Keyword<"__local">, Keyword<"local">];
650 let Documentation = [OpenCLAddressSpaceLocalDocs];
653 def OpenCLConstantAddressSpace : TypeAttr {
654 let Spellings = [Keyword<"__constant">, Keyword<"constant">];
655 let Documentation = [OpenCLAddressSpaceConstantDocs];
658 def OpenCLGenericAddressSpace : TypeAttr {
659 let Spellings = [Keyword<"__generic">, Keyword<"generic">];
660 let Documentation = [OpenCLAddressSpaceGenericDocs];
663 def Deprecated : InheritableAttr {
664 let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
665 CXX11<"","deprecated", 201309>];
666 let Args = [StringArgument<"Message", 1>];
667 let Documentation = [Undocumented];
670 def Destructor : InheritableAttr {
671 let Spellings = [GCC<"destructor">];
672 let Args = [DefaultIntArgument<"Priority", 65535>];
673 let Subjects = SubjectList<[Function]>;
674 let Documentation = [Undocumented];
677 def EnableIf : InheritableAttr {
678 let Spellings = [GNU<"enable_if">];
679 let Subjects = SubjectList<[Function]>;
680 let Args = [ExprArgument<"Cond">, StringArgument<"Message">];
681 let TemplateDependent = 1;
682 let Documentation = [EnableIfDocs];
685 def ExtVectorType : Attr {
686 let Spellings = [GNU<"ext_vector_type">];
687 let Subjects = SubjectList<[TypedefName], ErrorDiag>;
688 let Args = [ExprArgument<"NumElements">];
690 let Documentation = [Undocumented];
693 def FallThrough : Attr {
694 let Spellings = [CXX11<"clang", "fallthrough">];
695 // let Subjects = [NullStmt];
696 let Documentation = [FallthroughDocs];
699 def FastCall : InheritableAttr {
700 let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
701 Keyword<"_fastcall">];
702 // let Subjects = [Function, ObjCMethod];
703 let Documentation = [FastCallDocs];
706 def Final : InheritableAttr {
707 let Spellings = [Keyword<"final">, Keyword<"sealed">];
708 let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
710 let Documentation = [Undocumented];
713 def MinSize : InheritableAttr {
714 let Spellings = [GNU<"minsize">];
715 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
716 let Documentation = [Undocumented];
719 def FlagEnum : InheritableAttr {
720 let Spellings = [GNU<"flag_enum">];
721 let Subjects = SubjectList<[Enum]>;
722 let Documentation = [FlagEnumDocs];
723 let LangOpts = [COnly];
724 let AdditionalMembers = [{
726 llvm::APInt FlagBits;
728 llvm::APInt &getFlagBits() {
732 const llvm::APInt &getFlagBits() const {
738 def Flatten : InheritableAttr {
739 let Spellings = [GCC<"flatten">];
740 let Subjects = SubjectList<[Function], ErrorDiag>;
741 let Documentation = [FlattenDocs];
744 def Format : InheritableAttr {
745 let Spellings = [GCC<"format">];
746 let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
747 IntArgument<"FirstArg">];
748 let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto], WarnDiag,
750 let Documentation = [FormatDocs];
753 def FormatArg : InheritableAttr {
754 let Spellings = [GCC<"format_arg">];
755 let Args = [IntArgument<"FormatIdx">];
756 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto], WarnDiag,
758 let Documentation = [Undocumented];
761 def GNUInline : InheritableAttr {
762 let Spellings = [GCC<"gnu_inline">];
763 let Subjects = SubjectList<[Function]>;
764 let Documentation = [Undocumented];
767 def Hot : InheritableAttr {
768 let Spellings = [GCC<"hot">];
769 let Subjects = SubjectList<[Function]>;
770 // An AST node is created for this attribute, but not actually used beyond
771 // semantic checking for mutual exclusion with the Cold attribute.
772 let Documentation = [Undocumented];
775 def IBAction : InheritableAttr {
776 let Spellings = [GNU<"ibaction">];
777 let Subjects = SubjectList<[ObjCInstanceMethod], WarnDiag,
778 "ExpectedObjCInstanceMethod">;
779 // An AST node is created for this attribute, but is not used by other parts
780 // of the compiler. However, this node needs to exist in the AST because
781 // external tools rely on it.
782 let Documentation = [Undocumented];
785 def IBOutlet : InheritableAttr {
786 let Spellings = [GNU<"iboutlet">];
787 // let Subjects = [ObjCIvar, ObjCProperty];
788 let Documentation = [Undocumented];
791 def IBOutletCollection : InheritableAttr {
792 let Spellings = [GNU<"iboutletcollection">];
793 let Args = [TypeArgument<"Interface", 1>];
794 // let Subjects = [ObjCIvar, ObjCProperty];
795 let Documentation = [Undocumented];
798 def Restrict : InheritableAttr {
799 let Spellings = [Declspec<"restrict">, GCC<"malloc">];
800 let Subjects = SubjectList<[Function]>;
801 let Documentation = [Undocumented];
804 def MaxFieldAlignment : InheritableAttr {
805 // This attribute has no spellings as it is only ever created implicitly.
807 let Args = [UnsignedArgument<"Alignment">];
809 let Documentation = [Undocumented];
812 def MayAlias : InheritableAttr {
813 // FIXME: this is a type attribute in GCC, but a declaration attribute here.
814 let Spellings = [GCC<"may_alias">];
815 let Documentation = [Undocumented];
818 def MSABI : InheritableAttr {
819 let Spellings = [GCC<"ms_abi">];
820 // let Subjects = [Function, ObjCMethod];
821 let Documentation = [MSABIDocs];
824 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
825 // NOTE: If you add any additional spellings, ARMInterrupt's spellings must
827 let Spellings = [GNU<"interrupt">];
828 let Args = [UnsignedArgument<"Number">];
829 let ParseKind = "Interrupt";
830 let HasCustomParsing = 1;
831 let Documentation = [Undocumented];
834 def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
835 let Spellings = [GCC<"mips16">];
836 let Subjects = SubjectList<[Function], ErrorDiag>;
837 let Documentation = [Undocumented];
841 let Spellings = [GCC<"mode">];
842 let Args = [IdentifierArgument<"Mode">];
843 let Documentation = [Undocumented];
846 def Naked : InheritableAttr {
847 let Spellings = [GCC<"naked">, Declspec<"naked">];
848 let Subjects = SubjectList<[Function]>;
849 let Documentation = [Undocumented];
852 def NeonPolyVectorType : TypeAttr {
853 let Spellings = [GNU<"neon_polyvector_type">];
854 let Args = [IntArgument<"NumElements">];
855 let Documentation = [Undocumented];
858 def NeonVectorType : TypeAttr {
859 let Spellings = [GNU<"neon_vector_type">];
860 let Args = [IntArgument<"NumElements">];
861 let Documentation = [Undocumented];
864 def ReturnsTwice : InheritableAttr {
865 let Spellings = [GCC<"returns_twice">];
866 let Subjects = SubjectList<[Function]>;
867 let Documentation = [Undocumented];
870 def NoCommon : InheritableAttr {
871 let Spellings = [GCC<"nocommon">];
872 let Subjects = SubjectList<[Var]>;
873 let Documentation = [Undocumented];
876 def NoDebug : InheritableAttr {
877 let Spellings = [GCC<"nodebug">];
878 let Documentation = [Undocumented];
881 def NoDuplicate : InheritableAttr {
882 let Spellings = [GNU<"noduplicate">, CXX11<"clang", "noduplicate">];
883 let Subjects = SubjectList<[Function]>;
884 let Documentation = [NoDuplicateDocs];
887 def NoInline : InheritableAttr {
888 let Spellings = [GCC<"noinline">, Declspec<"noinline">];
889 let Subjects = SubjectList<[Function]>;
890 let Documentation = [Undocumented];
893 def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
894 let Spellings = [GCC<"nomips16">];
895 let Subjects = SubjectList<[Function], ErrorDiag>;
896 let Documentation = [Undocumented];
899 // This is not a TargetSpecificAttr so that is silently accepted and
900 // ignored on other targets as encouraged by the OpenCL spec.
902 // See OpenCL 1.2 6.11.5: "It is our intention that a particular
903 // implementation of OpenCL be free to ignore all attributes and the
904 // resulting executable binary will produce the same result."
906 // However, only AMD GPU targets will emit the corresponding IR
909 // FIXME: This provides a sub-optimal error message if you attempt to
910 // use this in CUDA, since CUDA does not use the same terminology.
911 def AMDGPUNumVGPR : InheritableAttr {
912 let Spellings = [GNU<"amdgpu_num_vgpr">];
913 let Args = [UnsignedArgument<"NumVGPR">];
914 let Documentation = [AMDGPUNumVGPRDocs];
916 // FIXME: This should be for OpenCLKernelFunction, but is not to
917 // workaround needing to see kernel attribute before others to know if
918 // this should be rejected on non-kernels.
919 let Subjects = SubjectList<[Function], ErrorDiag,
920 "ExpectedKernelFunction">;
923 def AMDGPUNumSGPR : InheritableAttr {
924 let Spellings = [GNU<"amdgpu_num_sgpr">];
925 let Args = [UnsignedArgument<"NumSGPR">];
926 let Documentation = [AMDGPUNumSGPRDocs];
927 let Subjects = SubjectList<[Function], ErrorDiag,
928 "ExpectedKernelFunction">;
931 def NoSplitStack : InheritableAttr {
932 let Spellings = [GCC<"no_split_stack">];
933 let Subjects = SubjectList<[Function], ErrorDiag>;
934 let Documentation = [NoSplitStackDocs];
937 def NonNull : InheritableAttr {
938 let Spellings = [GCC<"nonnull">];
939 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
940 "ExpectedFunctionMethodOrParameter">;
941 let Args = [VariadicUnsignedArgument<"Args">];
942 let AdditionalMembers =
943 [{bool isNonNull(unsigned idx) const {
946 for (const auto &V : args())
951 // FIXME: We should merge duplicates into a single nonnull attribute.
952 let DuplicatesAllowedWhileMerging = 1;
953 let Documentation = [NonNullDocs];
956 def ReturnsNonNull : InheritableAttr {
957 let Spellings = [GCC<"returns_nonnull">];
958 let Subjects = SubjectList<[ObjCMethod, Function], WarnDiag,
959 "ExpectedFunctionOrMethod">;
960 let Documentation = [ReturnsNonNullDocs];
963 // Nullability type attributes.
964 def TypeNonNull : TypeAttr {
965 let Spellings = [Keyword<"_Nonnull">];
966 let Documentation = [TypeNonNullDocs];
969 def TypeNullable : TypeAttr {
970 let Spellings = [Keyword<"_Nullable">];
971 let Documentation = [TypeNullableDocs];
974 def TypeNullUnspecified : TypeAttr {
975 let Spellings = [Keyword<"_Null_unspecified">];
976 let Documentation = [TypeNullUnspecifiedDocs];
979 def AssumeAligned : InheritableAttr {
980 let Spellings = [GCC<"assume_aligned">];
981 let Subjects = SubjectList<[ObjCMethod, Function]>;
982 let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>];
983 let Documentation = [AssumeAlignedDocs];
986 def NoReturn : InheritableAttr {
987 let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
988 // FIXME: Does GCC allow this on the function instead?
989 let Documentation = [Undocumented];
992 def NoInstrumentFunction : InheritableAttr {
993 let Spellings = [GCC<"no_instrument_function">];
994 let Subjects = SubjectList<[Function]>;
995 let Documentation = [Undocumented];
998 def NoThrow : InheritableAttr {
999 let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
1000 let Documentation = [Undocumented];
1003 def ObjCBridge : InheritableAttr {
1004 let Spellings = [GNU<"objc_bridge">];
1005 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag,
1006 "ExpectedStructOrUnionOrTypedef">;
1007 let Args = [IdentifierArgument<"BridgedType">];
1008 let Documentation = [Undocumented];
1011 def ObjCBridgeMutable : InheritableAttr {
1012 let Spellings = [GNU<"objc_bridge_mutable">];
1013 let Subjects = SubjectList<[Record], ErrorDiag>;
1014 let Args = [IdentifierArgument<"BridgedType">];
1015 let Documentation = [Undocumented];
1018 def ObjCBridgeRelated : InheritableAttr {
1019 let Spellings = [GNU<"objc_bridge_related">];
1020 let Subjects = SubjectList<[Record], ErrorDiag>;
1021 let Args = [IdentifierArgument<"RelatedClass">,
1022 IdentifierArgument<"ClassMethod">,
1023 IdentifierArgument<"InstanceMethod">];
1024 let HasCustomParsing = 1;
1025 let Documentation = [Undocumented];
1028 def NSReturnsRetained : InheritableAttr {
1029 let Spellings = [GNU<"ns_returns_retained">];
1030 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1031 let Documentation = [Undocumented];
1034 def NSReturnsNotRetained : InheritableAttr {
1035 let Spellings = [GNU<"ns_returns_not_retained">];
1036 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1037 let Documentation = [Undocumented];
1040 def NSReturnsAutoreleased : InheritableAttr {
1041 let Spellings = [GNU<"ns_returns_autoreleased">];
1042 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1043 let Documentation = [Undocumented];
1046 def NSConsumesSelf : InheritableAttr {
1047 let Spellings = [GNU<"ns_consumes_self">];
1048 let Subjects = SubjectList<[ObjCMethod]>;
1049 let Documentation = [Undocumented];
1052 def NSConsumed : InheritableParamAttr {
1053 let Spellings = [GNU<"ns_consumed">];
1054 let Subjects = SubjectList<[ParmVar]>;
1055 let Documentation = [Undocumented];
1058 def ObjCException : InheritableAttr {
1059 let Spellings = [GNU<"objc_exception">];
1060 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1061 let Documentation = [Undocumented];
1064 def ObjCMethodFamily : InheritableAttr {
1065 let Spellings = [GNU<"objc_method_family">];
1066 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1067 let Args = [EnumArgument<"Family", "FamilyKind",
1068 ["none", "alloc", "copy", "init", "mutableCopy", "new"],
1069 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
1070 "OMF_mutableCopy", "OMF_new"]>];
1071 let Documentation = [ObjCMethodFamilyDocs];
1074 def ObjCNSObject : InheritableAttr {
1075 let Spellings = [GNU<"NSObject">];
1076 let Documentation = [Undocumented];
1079 def ObjCIndependentClass : InheritableAttr {
1080 let Spellings = [GNU<"objc_independent_class">];
1081 let Documentation = [Undocumented];
1084 def ObjCPreciseLifetime : InheritableAttr {
1085 let Spellings = [GNU<"objc_precise_lifetime">];
1086 let Subjects = SubjectList<[Var], ErrorDiag>;
1087 let Documentation = [Undocumented];
1090 def ObjCReturnsInnerPointer : InheritableAttr {
1091 let Spellings = [GNU<"objc_returns_inner_pointer">];
1092 let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
1093 let Documentation = [Undocumented];
1096 def ObjCRequiresSuper : InheritableAttr {
1097 let Spellings = [GNU<"objc_requires_super">];
1098 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1099 let Documentation = [ObjCRequiresSuperDocs];
1102 def ObjCRootClass : InheritableAttr {
1103 let Spellings = [GNU<"objc_root_class">];
1104 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1105 let Documentation = [Undocumented];
1108 def ObjCExplicitProtocolImpl : InheritableAttr {
1109 let Spellings = [GNU<"objc_protocol_requires_explicit_implementation">];
1110 let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
1111 let Documentation = [Undocumented];
1114 def ObjCDesignatedInitializer : Attr {
1115 let Spellings = [GNU<"objc_designated_initializer">];
1116 let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag,
1117 "ExpectedObjCInterfaceDeclInitMethod">;
1118 let Documentation = [Undocumented];
1121 def ObjCRuntimeName : Attr {
1122 let Spellings = [GNU<"objc_runtime_name">];
1123 let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
1124 let Args = [StringArgument<"MetadataName">];
1125 let Documentation = [ObjCRuntimeNameDocs];
1128 def ObjCBoxable : Attr {
1129 let Spellings = [GNU<"objc_boxable">];
1130 let Subjects = SubjectList<[Record], ErrorDiag, "ExpectedStructOrUnion">;
1131 let Documentation = [Undocumented];
1134 def OptimizeNone : InheritableAttr {
1135 let Spellings = [GNU<"optnone">, CXX11<"clang", "optnone">];
1136 let Subjects = SubjectList<[Function, ObjCMethod]>;
1137 let Documentation = [OptnoneDocs];
1140 def Overloadable : Attr {
1141 let Spellings = [GNU<"overloadable">];
1142 let Subjects = SubjectList<[Function], ErrorDiag>;
1143 let Documentation = [OverloadableDocs];
1146 def Override : InheritableAttr {
1147 let Spellings = [Keyword<"override">];
1148 let SemaHandler = 0;
1149 let Documentation = [Undocumented];
1152 def Ownership : InheritableAttr {
1153 let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
1154 GNU<"ownership_takes">];
1155 let Accessors = [Accessor<"isHolds", [GNU<"ownership_holds">]>,
1156 Accessor<"isReturns", [GNU<"ownership_returns">]>,
1157 Accessor<"isTakes", [GNU<"ownership_takes">]>];
1158 let AdditionalMembers = [{
1159 enum OwnershipKind { Holds, Returns, Takes };
1160 OwnershipKind getOwnKind() const {
1161 return isHolds() ? Holds :
1166 let Args = [IdentifierArgument<"Module">, VariadicUnsignedArgument<"Args">];
1167 let Subjects = SubjectList<[HasFunctionProto], WarnDiag, "ExpectedFunction">;
1168 let Documentation = [Undocumented];
1171 def Packed : InheritableAttr {
1172 let Spellings = [GCC<"packed">];
1173 // let Subjects = [Tag, Field];
1174 let Documentation = [Undocumented];
1177 def IntelOclBicc : InheritableAttr {
1178 let Spellings = [GNU<"intel_ocl_bicc">];
1179 // let Subjects = [Function, ObjCMethod];
1180 let Documentation = [Undocumented];
1183 def Pcs : InheritableAttr {
1184 let Spellings = [GCC<"pcs">];
1185 let Args = [EnumArgument<"PCS", "PCSType",
1186 ["aapcs", "aapcs-vfp"],
1187 ["AAPCS", "AAPCS_VFP"]>];
1188 // let Subjects = [Function, ObjCMethod];
1189 let Documentation = [PcsDocs];
1192 def Pure : InheritableAttr {
1193 let Spellings = [GCC<"pure">];
1194 let Documentation = [Undocumented];
1197 def Regparm : TypeAttr {
1198 let Spellings = [GCC<"regparm">];
1199 let Args = [UnsignedArgument<"NumParams">];
1200 let Documentation = [RegparmDocs];
1203 def ReqdWorkGroupSize : InheritableAttr {
1204 let Spellings = [GNU<"reqd_work_group_size">];
1205 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
1206 UnsignedArgument<"ZDim">];
1207 let Subjects = SubjectList<[Function], ErrorDiag>;
1208 let Documentation = [Undocumented];
1211 def WorkGroupSizeHint : InheritableAttr {
1212 let Spellings = [GNU<"work_group_size_hint">];
1213 let Args = [UnsignedArgument<"XDim">,
1214 UnsignedArgument<"YDim">,
1215 UnsignedArgument<"ZDim">];
1216 let Subjects = SubjectList<[Function], ErrorDiag>;
1217 let Documentation = [Undocumented];
1220 def InitPriority : InheritableAttr {
1221 let Spellings = [GNU<"init_priority">];
1222 let Args = [UnsignedArgument<"Priority">];
1223 let Subjects = SubjectList<[Var], ErrorDiag>;
1224 let Documentation = [Undocumented];
1227 def Section : InheritableAttr {
1228 let Spellings = [GCC<"section">, Declspec<"allocate">];
1229 let Args = [StringArgument<"Name">];
1230 let Subjects = SubjectList<[Function, GlobalVar,
1231 ObjCMethod, ObjCProperty], ErrorDiag,
1232 "ExpectedFunctionGlobalVarMethodOrProperty">;
1233 let Documentation = [SectionDocs];
1236 def Sentinel : InheritableAttr {
1237 let Spellings = [GCC<"sentinel">];
1238 let Args = [DefaultIntArgument<"Sentinel", 0>,
1239 DefaultIntArgument<"NullPos", 0>];
1240 // let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
1241 let Documentation = [Undocumented];
1244 def StdCall : InheritableAttr {
1245 let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
1246 // let Subjects = [Function, ObjCMethod];
1247 let Documentation = [StdCallDocs];
1250 def SysVABI : InheritableAttr {
1251 let Spellings = [GCC<"sysv_abi">];
1252 // let Subjects = [Function, ObjCMethod];
1253 let Documentation = [Undocumented];
1256 def ThisCall : InheritableAttr {
1257 let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
1258 Keyword<"_thiscall">];
1259 // let Subjects = [Function, ObjCMethod];
1260 let Documentation = [ThisCallDocs];
1263 def VectorCall : InheritableAttr {
1264 let Spellings = [GNU<"vectorcall">, Keyword<"__vectorcall">,
1265 Keyword<"_vectorcall">];
1266 // let Subjects = [Function, ObjCMethod];
1267 let Documentation = [VectorCallDocs];
1270 def Pascal : InheritableAttr {
1271 let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
1272 // let Subjects = [Function, ObjCMethod];
1273 let Documentation = [Undocumented];
1276 def Target : InheritableAttr {
1277 let Spellings = [GCC<"target">];
1278 let Args = [StringArgument<"features">];
1280 SubjectList<[Function], ErrorDiag, "ExpectedFunctionMethodOrClass">;
1281 let Documentation = [Undocumented];
1284 def TransparentUnion : InheritableAttr {
1285 let Spellings = [GCC<"transparent_union">];
1286 // let Subjects = SubjectList<[Record, TypedefName]>;
1287 let Documentation = [Undocumented];
1290 def Unavailable : InheritableAttr {
1291 let Spellings = [GNU<"unavailable">];
1292 let Args = [StringArgument<"Message", 1>];
1293 let Documentation = [Undocumented];
1296 def ArcWeakrefUnavailable : InheritableAttr {
1297 let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
1298 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1299 let Documentation = [Undocumented];
1302 def ObjCGC : TypeAttr {
1303 let Spellings = [GNU<"objc_gc">];
1304 let Args = [IdentifierArgument<"Kind">];
1305 let Documentation = [Undocumented];
1308 def ObjCOwnership : InheritableAttr {
1309 let Spellings = [GNU<"objc_ownership">];
1310 let Args = [IdentifierArgument<"Kind">];
1312 let Documentation = [Undocumented];
1315 def ObjCRequiresPropertyDefs : InheritableAttr {
1316 let Spellings = [GNU<"objc_requires_property_definitions">];
1317 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1318 let Documentation = [Undocumented];
1321 def Unused : InheritableAttr {
1322 let Spellings = [GCC<"unused">];
1323 let Subjects = SubjectList<[Var, ObjCIvar, Type, Label, Field, ObjCMethod,
1324 FunctionLike], WarnDiag,
1325 "ExpectedVariableFunctionOrLabel">;
1326 let Documentation = [Undocumented];
1329 def Used : InheritableAttr {
1330 let Spellings = [GCC<"used">];
1331 let Documentation = [Undocumented];
1334 def Uuid : InheritableAttr {
1335 let Spellings = [Declspec<"uuid">];
1336 let Args = [StringArgument<"Guid">];
1337 // let Subjects = SubjectList<[CXXRecord]>;
1338 let LangOpts = [MicrosoftExt, Borland];
1339 let Documentation = [Undocumented];
1342 def VectorSize : TypeAttr {
1343 let Spellings = [GCC<"vector_size">];
1344 let Args = [ExprArgument<"NumBytes">];
1345 let Documentation = [Undocumented];
1348 def VecTypeHint : InheritableAttr {
1349 let Spellings = [GNU<"vec_type_hint">];
1350 let Args = [TypeArgument<"TypeHint">];
1351 let Subjects = SubjectList<[Function], ErrorDiag>;
1352 let Documentation = [Undocumented];
1355 def Visibility : InheritableAttr {
1357 let Spellings = [GCC<"visibility">];
1358 let Args = [EnumArgument<"Visibility", "VisibilityType",
1359 ["default", "hidden", "internal", "protected"],
1360 ["Default", "Hidden", "Hidden", "Protected"]>];
1361 let Documentation = [Undocumented];
1364 def TypeVisibility : InheritableAttr {
1366 let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">];
1367 let Args = [EnumArgument<"Visibility", "VisibilityType",
1368 ["default", "hidden", "internal", "protected"],
1369 ["Default", "Hidden", "Hidden", "Protected"]>];
1370 // let Subjects = [Tag, ObjCInterface, Namespace];
1371 let Documentation = [Undocumented];
1374 def VecReturn : InheritableAttr {
1375 let Spellings = [GNU<"vecreturn">];
1376 let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
1377 let Documentation = [Undocumented];
1380 def WarnUnused : InheritableAttr {
1381 let Spellings = [GNU<"warn_unused">];
1382 let Subjects = SubjectList<[Record]>;
1383 let Documentation = [Undocumented];
1386 def WarnUnusedResult : InheritableAttr {
1387 let Spellings = [GCC<"warn_unused_result">,
1388 CXX11<"clang", "warn_unused_result">];
1389 let Subjects = SubjectList<[ObjCMethod, CXXRecord, FunctionLike], WarnDiag,
1390 "ExpectedFunctionMethodOrClass">;
1391 let Documentation = [Undocumented];
1394 def Weak : InheritableAttr {
1395 let Spellings = [GCC<"weak">];
1396 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
1397 let Documentation = [Undocumented];
1400 def WeakImport : InheritableAttr {
1401 let Spellings = [GNU<"weak_import">];
1402 let Documentation = [Undocumented];
1405 def WeakRef : InheritableAttr {
1406 let Spellings = [GCC<"weakref">];
1407 // A WeakRef that has an argument is treated as being an AliasAttr
1408 let Args = [StringArgument<"Aliasee", 1>];
1409 let Subjects = SubjectList<[Var, Function], ErrorDiag>;
1410 let Documentation = [Undocumented];
1413 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetX86> {
1414 let Spellings = [GNU<"force_align_arg_pointer">];
1415 // Technically, this appertains to a FunctionDecl, but the target-specific
1416 // code silently allows anything function-like (such as typedefs or function
1417 // pointers), but does not apply the attribute to them.
1418 let Documentation = [Undocumented];
1421 def NoSanitize : InheritableAttr {
1422 let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">];
1423 let Args = [VariadicStringArgument<"Sanitizers">];
1424 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
1425 let Documentation = [NoSanitizeDocs];
1426 let AdditionalMembers = [{
1427 SanitizerMask getMask() const {
1428 SanitizerMask Mask = 0;
1429 for (auto SanitizerName : sanitizers()) {
1430 SanitizerMask ParsedMask =
1431 parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
1432 Mask |= expandSanitizerGroups(ParsedMask);
1439 // Attributes to disable a specific sanitizer. No new sanitizers should be added
1440 // to this list; the no_sanitize attribute should be extended instead.
1441 def NoSanitizeSpecific : InheritableAttr {
1442 let Spellings = [GCC<"no_address_safety_analysis">,
1443 GCC<"no_sanitize_address">,
1444 GCC<"no_sanitize_thread">,
1445 GNU<"no_sanitize_memory">];
1446 let Subjects = SubjectList<[Function], ErrorDiag>;
1447 let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
1448 NoSanitizeMemoryDocs];
1452 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
1454 def GuardedVar : InheritableAttr {
1455 let Spellings = [GNU<"guarded_var">];
1456 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1457 "ExpectedFieldOrGlobalVar">;
1458 let Documentation = [Undocumented];
1461 def PtGuardedVar : InheritableAttr {
1462 let Spellings = [GNU<"pt_guarded_var">];
1463 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1464 "ExpectedFieldOrGlobalVar">;
1465 let Documentation = [Undocumented];
1468 def Lockable : InheritableAttr {
1469 let Spellings = [GNU<"lockable">];
1470 let Subjects = SubjectList<[Record]>;
1471 let Documentation = [Undocumented];
1472 let ASTNode = 0; // Replaced by Capability
1475 def ScopedLockable : InheritableAttr {
1476 let Spellings = [GNU<"scoped_lockable">];
1477 let Subjects = SubjectList<[Record]>;
1478 let Documentation = [Undocumented];
1481 def Capability : InheritableAttr {
1482 let Spellings = [GNU<"capability">, CXX11<"clang", "capability">,
1483 GNU<"shared_capability">,
1484 CXX11<"clang", "shared_capability">];
1485 let Subjects = SubjectList<[Struct, TypedefName], ErrorDiag,
1486 "ExpectedStructOrTypedef">;
1487 let Args = [StringArgument<"Name">];
1488 let Accessors = [Accessor<"isShared",
1489 [GNU<"shared_capability">,
1490 CXX11<"clang","shared_capability">]>];
1491 let Documentation = [Undocumented];
1492 let AdditionalMembers = [{
1493 bool isMutex() const { return getName().equals_lower("mutex"); }
1494 bool isRole() const { return getName().equals_lower("role"); }
1498 def AssertCapability : InheritableAttr {
1499 let Spellings = [GNU<"assert_capability">,
1500 CXX11<"clang", "assert_capability">,
1501 GNU<"assert_shared_capability">,
1502 CXX11<"clang", "assert_shared_capability">];
1503 let Subjects = SubjectList<[Function]>;
1505 let TemplateDependent = 1;
1506 let ParseArgumentsAsUnevaluated = 1;
1507 let DuplicatesAllowedWhileMerging = 1;
1508 let Args = [ExprArgument<"Expr">];
1509 let Accessors = [Accessor<"isShared",
1510 [GNU<"assert_shared_capability">,
1511 CXX11<"clang", "assert_shared_capability">]>];
1512 let Documentation = [AssertCapabilityDocs];
1515 def AcquireCapability : InheritableAttr {
1516 let Spellings = [GNU<"acquire_capability">,
1517 CXX11<"clang", "acquire_capability">,
1518 GNU<"acquire_shared_capability">,
1519 CXX11<"clang", "acquire_shared_capability">,
1520 GNU<"exclusive_lock_function">,
1521 GNU<"shared_lock_function">];
1522 let Subjects = SubjectList<[Function]>;
1524 let TemplateDependent = 1;
1525 let ParseArgumentsAsUnevaluated = 1;
1526 let DuplicatesAllowedWhileMerging = 1;
1527 let Args = [VariadicExprArgument<"Args">];
1528 let Accessors = [Accessor<"isShared",
1529 [GNU<"acquire_shared_capability">,
1530 CXX11<"clang", "acquire_shared_capability">,
1531 GNU<"shared_lock_function">]>];
1532 let Documentation = [AcquireCapabilityDocs];
1535 def TryAcquireCapability : InheritableAttr {
1536 let Spellings = [GNU<"try_acquire_capability">,
1537 CXX11<"clang", "try_acquire_capability">,
1538 GNU<"try_acquire_shared_capability">,
1539 CXX11<"clang", "try_acquire_shared_capability">];
1540 let Subjects = SubjectList<[Function],
1543 let TemplateDependent = 1;
1544 let ParseArgumentsAsUnevaluated = 1;
1545 let DuplicatesAllowedWhileMerging = 1;
1546 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1547 let Accessors = [Accessor<"isShared",
1548 [GNU<"try_acquire_shared_capability">,
1549 CXX11<"clang", "try_acquire_shared_capability">]>];
1550 let Documentation = [TryAcquireCapabilityDocs];
1553 def ReleaseCapability : InheritableAttr {
1554 let Spellings = [GNU<"release_capability">,
1555 CXX11<"clang", "release_capability">,
1556 GNU<"release_shared_capability">,
1557 CXX11<"clang", "release_shared_capability">,
1558 GNU<"release_generic_capability">,
1559 CXX11<"clang", "release_generic_capability">,
1560 GNU<"unlock_function">];
1561 let Subjects = SubjectList<[Function]>;
1563 let TemplateDependent = 1;
1564 let ParseArgumentsAsUnevaluated = 1;
1565 let DuplicatesAllowedWhileMerging = 1;
1566 let Args = [VariadicExprArgument<"Args">];
1567 let Accessors = [Accessor<"isShared",
1568 [GNU<"release_shared_capability">,
1569 CXX11<"clang", "release_shared_capability">]>,
1570 Accessor<"isGeneric",
1571 [GNU<"release_generic_capability">,
1572 CXX11<"clang", "release_generic_capability">,
1573 GNU<"unlock_function">]>];
1574 let Documentation = [ReleaseCapabilityDocs];
1577 def RequiresCapability : InheritableAttr {
1578 let Spellings = [GNU<"requires_capability">,
1579 CXX11<"clang", "requires_capability">,
1580 GNU<"exclusive_locks_required">,
1581 GNU<"requires_shared_capability">,
1582 CXX11<"clang", "requires_shared_capability">,
1583 GNU<"shared_locks_required">];
1584 let Args = [VariadicExprArgument<"Args">];
1586 let TemplateDependent = 1;
1587 let ParseArgumentsAsUnevaluated = 1;
1588 let DuplicatesAllowedWhileMerging = 1;
1589 let Subjects = SubjectList<[Function]>;
1590 let Accessors = [Accessor<"isShared", [GNU<"requires_shared_capability">,
1591 GNU<"shared_locks_required">,
1592 CXX11<"clang","requires_shared_capability">]>];
1593 let Documentation = [Undocumented];
1596 def NoThreadSafetyAnalysis : InheritableAttr {
1597 let Spellings = [GNU<"no_thread_safety_analysis">];
1598 let Subjects = SubjectList<[Function]>;
1599 let Documentation = [Undocumented];
1602 def GuardedBy : InheritableAttr {
1603 let Spellings = [GNU<"guarded_by">];
1604 let Args = [ExprArgument<"Arg">];
1606 let TemplateDependent = 1;
1607 let ParseArgumentsAsUnevaluated = 1;
1608 let DuplicatesAllowedWhileMerging = 1;
1609 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1610 "ExpectedFieldOrGlobalVar">;
1611 let Documentation = [Undocumented];
1614 def PtGuardedBy : InheritableAttr {
1615 let Spellings = [GNU<"pt_guarded_by">];
1616 let Args = [ExprArgument<"Arg">];
1618 let TemplateDependent = 1;
1619 let ParseArgumentsAsUnevaluated = 1;
1620 let DuplicatesAllowedWhileMerging = 1;
1621 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1622 "ExpectedFieldOrGlobalVar">;
1623 let Documentation = [Undocumented];
1626 def AcquiredAfter : InheritableAttr {
1627 let Spellings = [GNU<"acquired_after">];
1628 let Args = [VariadicExprArgument<"Args">];
1630 let TemplateDependent = 1;
1631 let ParseArgumentsAsUnevaluated = 1;
1632 let DuplicatesAllowedWhileMerging = 1;
1633 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1634 "ExpectedFieldOrGlobalVar">;
1635 let Documentation = [Undocumented];
1638 def AcquiredBefore : InheritableAttr {
1639 let Spellings = [GNU<"acquired_before">];
1640 let Args = [VariadicExprArgument<"Args">];
1642 let TemplateDependent = 1;
1643 let ParseArgumentsAsUnevaluated = 1;
1644 let DuplicatesAllowedWhileMerging = 1;
1645 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1646 "ExpectedFieldOrGlobalVar">;
1647 let Documentation = [Undocumented];
1650 def AssertExclusiveLock : InheritableAttr {
1651 let Spellings = [GNU<"assert_exclusive_lock">];
1652 let Args = [VariadicExprArgument<"Args">];
1654 let TemplateDependent = 1;
1655 let ParseArgumentsAsUnevaluated = 1;
1656 let DuplicatesAllowedWhileMerging = 1;
1657 let Subjects = SubjectList<[Function]>;
1658 let Documentation = [Undocumented];
1661 def AssertSharedLock : InheritableAttr {
1662 let Spellings = [GNU<"assert_shared_lock">];
1663 let Args = [VariadicExprArgument<"Args">];
1665 let TemplateDependent = 1;
1666 let ParseArgumentsAsUnevaluated = 1;
1667 let DuplicatesAllowedWhileMerging = 1;
1668 let Subjects = SubjectList<[Function]>;
1669 let Documentation = [Undocumented];
1672 // The first argument is an integer or boolean value specifying the return value
1673 // of a successful lock acquisition.
1674 def ExclusiveTrylockFunction : InheritableAttr {
1675 let Spellings = [GNU<"exclusive_trylock_function">];
1676 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1678 let TemplateDependent = 1;
1679 let ParseArgumentsAsUnevaluated = 1;
1680 let DuplicatesAllowedWhileMerging = 1;
1681 let Subjects = SubjectList<[Function]>;
1682 let Documentation = [Undocumented];
1685 // The first argument is an integer or boolean value specifying the return value
1686 // of a successful lock acquisition.
1687 def SharedTrylockFunction : InheritableAttr {
1688 let Spellings = [GNU<"shared_trylock_function">];
1689 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1691 let TemplateDependent = 1;
1692 let ParseArgumentsAsUnevaluated = 1;
1693 let DuplicatesAllowedWhileMerging = 1;
1694 let Subjects = SubjectList<[Function]>;
1695 let Documentation = [Undocumented];
1698 def LockReturned : InheritableAttr {
1699 let Spellings = [GNU<"lock_returned">];
1700 let Args = [ExprArgument<"Arg">];
1702 let TemplateDependent = 1;
1703 let ParseArgumentsAsUnevaluated = 1;
1704 let Subjects = SubjectList<[Function]>;
1705 let Documentation = [Undocumented];
1708 def LocksExcluded : InheritableAttr {
1709 let Spellings = [GNU<"locks_excluded">];
1710 let Args = [VariadicExprArgument<"Args">];
1712 let TemplateDependent = 1;
1713 let ParseArgumentsAsUnevaluated = 1;
1714 let DuplicatesAllowedWhileMerging = 1;
1715 let Subjects = SubjectList<[Function]>;
1716 let Documentation = [Undocumented];
1719 // C/C++ consumed attributes.
1721 def Consumable : InheritableAttr {
1722 let Spellings = [GNU<"consumable">];
1723 let Subjects = SubjectList<[CXXRecord]>;
1724 let Args = [EnumArgument<"DefaultState", "ConsumedState",
1725 ["unknown", "consumed", "unconsumed"],
1726 ["Unknown", "Consumed", "Unconsumed"]>];
1727 let Documentation = [ConsumableDocs];
1730 def ConsumableAutoCast : InheritableAttr {
1731 let Spellings = [GNU<"consumable_auto_cast_state">];
1732 let Subjects = SubjectList<[CXXRecord]>;
1733 let Documentation = [Undocumented];
1736 def ConsumableSetOnRead : InheritableAttr {
1737 let Spellings = [GNU<"consumable_set_state_on_read">];
1738 let Subjects = SubjectList<[CXXRecord]>;
1739 let Documentation = [Undocumented];
1742 def CallableWhen : InheritableAttr {
1743 let Spellings = [GNU<"callable_when">];
1744 let Subjects = SubjectList<[CXXMethod]>;
1745 let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
1746 ["unknown", "consumed", "unconsumed"],
1747 ["Unknown", "Consumed", "Unconsumed"]>];
1748 let Documentation = [CallableWhenDocs];
1751 def ParamTypestate : InheritableAttr {
1752 let Spellings = [GNU<"param_typestate">];
1753 let Subjects = SubjectList<[ParmVar]>;
1754 let Args = [EnumArgument<"ParamState", "ConsumedState",
1755 ["unknown", "consumed", "unconsumed"],
1756 ["Unknown", "Consumed", "Unconsumed"]>];
1757 let Documentation = [ParamTypestateDocs];
1760 def ReturnTypestate : InheritableAttr {
1761 let Spellings = [GNU<"return_typestate">];
1762 let Subjects = SubjectList<[Function, ParmVar]>;
1763 let Args = [EnumArgument<"State", "ConsumedState",
1764 ["unknown", "consumed", "unconsumed"],
1765 ["Unknown", "Consumed", "Unconsumed"]>];
1766 let Documentation = [ReturnTypestateDocs];
1769 def SetTypestate : InheritableAttr {
1770 let Spellings = [GNU<"set_typestate">];
1771 let Subjects = SubjectList<[CXXMethod]>;
1772 let Args = [EnumArgument<"NewState", "ConsumedState",
1773 ["unknown", "consumed", "unconsumed"],
1774 ["Unknown", "Consumed", "Unconsumed"]>];
1775 let Documentation = [SetTypestateDocs];
1778 def TestTypestate : InheritableAttr {
1779 let Spellings = [GNU<"test_typestate">];
1780 let Subjects = SubjectList<[CXXMethod]>;
1781 let Args = [EnumArgument<"TestState", "ConsumedState",
1782 ["consumed", "unconsumed"],
1783 ["Consumed", "Unconsumed"]>];
1784 let Documentation = [TestTypestateDocs];
1787 // Type safety attributes for `void *' pointers and type tags.
1789 def ArgumentWithTypeTag : InheritableAttr {
1790 let Spellings = [GNU<"argument_with_type_tag">,
1791 GNU<"pointer_with_type_tag">];
1792 let Args = [IdentifierArgument<"ArgumentKind">,
1793 UnsignedArgument<"ArgumentIdx">,
1794 UnsignedArgument<"TypeTagIdx">,
1795 BoolArgument<"IsPointer">];
1796 let HasCustomParsing = 1;
1797 let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
1800 def TypeTagForDatatype : InheritableAttr {
1801 let Spellings = [GNU<"type_tag_for_datatype">];
1802 let Args = [IdentifierArgument<"ArgumentKind">,
1803 TypeArgument<"MatchingCType">,
1804 BoolArgument<"LayoutCompatible">,
1805 BoolArgument<"MustBeNull">];
1806 // let Subjects = SubjectList<[Var], ErrorDiag>;
1807 let HasCustomParsing = 1;
1808 let Documentation = [TypeTagForDatatypeDocs];
1811 // Microsoft-related attributes
1813 def MSNoVTable : InheritableAttr {
1814 let Spellings = [Declspec<"novtable">];
1815 let Subjects = SubjectList<[CXXRecord]>;
1816 let Documentation = [MSNoVTableDocs];
1820 let Spellings = [Declspec<"property">];
1823 def MSStruct : InheritableAttr {
1824 let Spellings = [GCC<"ms_struct">];
1825 let Subjects = SubjectList<[Record]>;
1826 let Documentation = [Undocumented];
1829 def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
1830 let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
1831 let Subjects = SubjectList<[Function, Var, CXXRecord]>;
1832 let Documentation = [Undocumented];
1835 def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
1836 let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
1837 let Subjects = SubjectList<[Function, Var, CXXRecord]>;
1838 let Documentation = [Undocumented];
1841 def SelectAny : InheritableAttr {
1842 let Spellings = [Declspec<"selectany">];
1843 let LangOpts = [MicrosoftExt];
1844 let Documentation = [Undocumented];
1848 let Spellings = [Declspec<"thread">];
1849 let LangOpts = [MicrosoftExt];
1850 let Documentation = [ThreadDocs];
1851 let Subjects = SubjectList<[Var]>;
1854 def Win64 : IgnoredAttr {
1855 let Spellings = [Keyword<"__w64">];
1856 let LangOpts = [MicrosoftExt];
1859 def Ptr32 : TypeAttr {
1860 let Spellings = [Keyword<"__ptr32">];
1861 let Documentation = [Undocumented];
1864 def Ptr64 : TypeAttr {
1865 let Spellings = [Keyword<"__ptr64">];
1866 let Documentation = [Undocumented];
1869 def SPtr : TypeAttr {
1870 let Spellings = [Keyword<"__sptr">];
1871 let Documentation = [Undocumented];
1874 def UPtr : TypeAttr {
1875 let Spellings = [Keyword<"__uptr">];
1876 let Documentation = [Undocumented];
1879 def MSInheritance : InheritableAttr {
1880 let LangOpts = [MicrosoftExt];
1881 let Args = [DefaultBoolArgument<"BestCase", 1>];
1882 let Spellings = [Keyword<"__single_inheritance">,
1883 Keyword<"__multiple_inheritance">,
1884 Keyword<"__virtual_inheritance">,
1885 Keyword<"__unspecified_inheritance">];
1886 let AdditionalMembers = [{
1887 static bool hasVBPtrOffsetField(Spelling Inheritance) {
1888 return Inheritance == Keyword_unspecified_inheritance;
1891 // Only member pointers to functions need a this adjustment, since it can be
1892 // combined with the field offset for data pointers.
1893 static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
1894 return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
1897 static bool hasVBTableOffsetField(Spelling Inheritance) {
1898 return Inheritance >= Keyword_virtual_inheritance;
1901 static bool hasOnlyOneField(bool IsMemberFunction,
1902 Spelling Inheritance) {
1903 if (IsMemberFunction)
1904 return Inheritance <= Keyword_single_inheritance;
1905 return Inheritance <= Keyword_multiple_inheritance;
1908 let Documentation = [MSInheritanceDocs];
1911 def MSVtorDisp : InheritableAttr {
1912 // This attribute has no spellings as it is only ever created implicitly.
1914 let Args = [UnsignedArgument<"vdm">];
1915 let SemaHandler = 0;
1917 let AdditionalMembers = [{
1924 Mode getVtorDispMode() const { return Mode(vdm); }
1926 let Documentation = [Undocumented];
1929 def InitSeg : Attr {
1930 let Spellings = [Pragma<"", "init_seg">];
1931 let Args = [StringArgument<"Section">];
1932 let SemaHandler = 0;
1933 let Documentation = [InitSegDocs];
1934 let AdditionalMembers = [{
1935 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
1936 OS << '(' << getSection() << ')';
1941 def Unaligned : IgnoredAttr {
1942 let Spellings = [Keyword<"__unaligned">];
1945 def LoopHint : Attr {
1946 /// #pragma clang loop <option> directive
1947 /// vectorize: vectorizes loop operations if State == Enable.
1948 /// vectorize_width: vectorize loop operations with width 'Value'.
1949 /// interleave: interleave multiple loop iterations if State == Enable.
1950 /// interleave_count: interleaves 'Value' loop interations.
1951 /// unroll: fully unroll loop if State == Enable.
1952 /// unroll_count: unrolls loop 'Value' times.
1954 /// #pragma unroll <argument> directive
1955 /// <no arg>: fully unrolls loop.
1956 /// boolean: fully unrolls loop if State == Enable.
1957 /// expression: unrolls loop 'Value' times.
1959 let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">,
1960 Pragma<"", "nounroll">];
1962 /// State of the loop optimization specified by the spelling.
1963 let Args = [EnumArgument<"Option", "OptionType",
1964 ["vectorize", "vectorize_width", "interleave", "interleave_count",
1965 "unroll", "unroll_count"],
1966 ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
1967 "Unroll", "UnrollCount"]>,
1968 EnumArgument<"State", "LoopHintState",
1969 ["default", "enable", "disable", "assume_safety"],
1970 ["Default", "Enable", "Disable", "AssumeSafety"]>,
1971 ExprArgument<"Value">];
1973 let AdditionalMembers = [{
1974 static const char *getOptionName(int Option) {
1976 case Vectorize: return "vectorize";
1977 case VectorizeWidth: return "vectorize_width";
1978 case Interleave: return "interleave";
1979 case InterleaveCount: return "interleave_count";
1980 case Unroll: return "unroll";
1981 case UnrollCount: return "unroll_count";
1983 llvm_unreachable("Unhandled LoopHint option.");
1986 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
1987 unsigned SpellingIndex = getSpellingListIndex();
1988 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
1989 // "nounroll" is already emitted as the pragma name.
1990 if (SpellingIndex == Pragma_nounroll) {
1994 else if (SpellingIndex == Pragma_unroll) {
1995 OS << getValueString(Policy) << "\n";
1999 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2000 OS << getOptionName(option) << getValueString(Policy) << "\n";
2003 // Return a string containing the loop hint argument including the
2004 // enclosing parentheses.
2005 std::string getValueString(const PrintingPolicy &Policy) const {
2006 std::string ValueName;
2007 llvm::raw_string_ostream OS(ValueName);
2009 if (option == VectorizeWidth || option == InterleaveCount ||
2010 option == UnrollCount)
2011 value->printPretty(OS, nullptr, Policy);
2012 else if (state == Default)
2014 else if (state == Enable)
2015 OS << (option == Unroll ? "full" : "enable");
2016 else if (state == AssumeSafety)
2017 OS << "assume_safety";
2024 // Return a string suitable for identifying this attribute in diagnostics.
2025 std::string getDiagnosticName(const PrintingPolicy &Policy) const {
2026 unsigned SpellingIndex = getSpellingListIndex();
2027 if (SpellingIndex == Pragma_nounroll)
2028 return "#pragma nounroll";
2029 else if (SpellingIndex == Pragma_unroll)
2030 return "#pragma unroll" + getValueString(Policy);
2032 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2033 return getOptionName(option) + getValueString(Policy);
2037 let Documentation = [LoopHintDocs, UnrollHintDocs];
2040 def CapturedRecord : InheritableAttr {
2041 // This attribute has no spellings as it is only ever created implicitly.
2043 let SemaHandler = 0;
2044 let Documentation = [Undocumented];
2047 def OMPThreadPrivateDecl : InheritableAttr {
2048 // This attribute has no spellings as it is only ever created implicitly.
2050 let SemaHandler = 0;
2051 let Documentation = [Undocumented];