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) != nullptr}]>;
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) != nullptr &&
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, bit fake = 0> {
134 bit Optional = optional;
136 /// A fake argument is used to store and serialize additional information
137 /// in an attribute without actually changing its parsing or pretty-printing.
141 class BoolArgument<string name, bit opt = 0> : Argument<name, opt>;
142 class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>;
143 class IntArgument<string name, bit opt = 0> : Argument<name, opt>;
144 class StringArgument<string name, bit opt = 0> : Argument<name, opt>;
145 class ExprArgument<string name, bit opt = 0> : Argument<name, opt>;
146 class FunctionArgument<string name, bit opt = 0> : Argument<name, opt>;
147 class TypeArgument<string name, bit opt = 0> : Argument<name, opt>;
148 class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>;
149 class VariadicUnsignedArgument<string name> : Argument<name, 1>;
150 class VariadicExprArgument<string name> : Argument<name, 1>;
151 class VariadicStringArgument<string name> : Argument<name, 1>;
153 // A version of the form major.minor[.subminor].
154 class VersionArgument<string name, bit opt = 0> : Argument<name, opt>;
156 // This one's a doozy, so it gets its own special type
157 // It can be an unsigned integer, or a type. Either can
159 class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>;
161 // A bool argument with a default value
162 class DefaultBoolArgument<string name, bit default> : BoolArgument<name, 1> {
163 bit Default = default;
166 // An integer argument with a default value
167 class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
168 int Default = default;
171 // This argument is more complex, it includes the enumerator type name,
172 // a list of strings to accept, and a list of enumerators to map them to.
173 class EnumArgument<string name, string type, list<string> values,
174 list<string> enums, bit opt = 0, bit fake = 0>
175 : Argument<name, opt, fake> {
177 list<string> Values = values;
178 list<string> Enums = enums;
181 // FIXME: There should be a VariadicArgument type that takes any other type
182 // of argument and generates the appropriate type.
183 class VariadicEnumArgument<string name, string type, list<string> values,
184 list<string> enums> : Argument<name, 1> {
186 list<string> Values = values;
187 list<string> Enums = enums;
190 // This handles one spelling of an attribute.
191 class Spelling<string name, string variety> {
193 string Variety = variety;
197 class GNU<string name> : Spelling<name, "GNU">;
198 class Declspec<string name> : Spelling<name, "Declspec">;
199 class CXX11<string namespace, string name, int version = 1>
200 : Spelling<name, "CXX11"> {
201 string Namespace = namespace;
202 int Version = version;
204 class Keyword<string name> : Spelling<name, "Keyword">;
205 class Pragma<string namespace, string name> : Spelling<name, "Pragma"> {
206 string Namespace = namespace;
209 // The GCC spelling implies GNU<name, "GNU"> and CXX11<"gnu", name> and also
210 // sets KnownToGCC to 1. This spelling should be used for any GCC-compatible
212 class GCC<string name> : Spelling<name, "GCC"> {
216 class Accessor<string name, list<Spelling> spellings> {
218 list<Spelling> Spellings = spellings;
221 class SubjectDiag<bit warn> {
224 def WarnDiag : SubjectDiag<1>;
225 def ErrorDiag : SubjectDiag<0>;
227 class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag,
228 string customDiag = ""> {
229 list<AttrSubject> Subjects = subjects;
230 SubjectDiag Diag = diag;
231 string CustomDiag = customDiag;
234 class LangOpt<string name, bit negated = 0> {
236 bit Negated = negated;
238 def MicrosoftExt : LangOpt<"MicrosoftExt">;
239 def Borland : LangOpt<"Borland">;
240 def CUDA : LangOpt<"CUDA">;
241 def COnly : LangOpt<"CPlusPlus", 1>;
243 // Defines targets for target-specific attributes. The list of strings should
244 // specify architectures for which the target applies, based off the ArchType
245 // enumeration in Triple.h.
246 class TargetArch<list<string> arches> {
247 list<string> Arches = arches;
249 list<string> CXXABIs;
251 def TargetARM : TargetArch<["arm", "thumb"]>;
252 def TargetMips : TargetArch<["mips", "mipsel"]>;
253 def TargetMSP430 : TargetArch<["msp430"]>;
254 def TargetX86 : TargetArch<["x86"]>;
255 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
256 let OSes = ["Win32"];
258 def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
259 let CXXABIs = ["Microsoft"];
263 // The various ways in which an attribute can be spelled in source
264 list<Spelling> Spellings;
265 // The things to which an attribute can appertain
266 SubjectList Subjects;
267 // The arguments allowed on an attribute
268 list<Argument> Args = [];
269 // Accessors which should be generated for the attribute.
270 list<Accessor> Accessors = [];
271 // Set to true for attributes with arguments which require delayed parsing.
273 // Set to false to prevent an attribute from being propagated from a template
274 // to the instantiation.
276 // Set to true for attributes which must be instantiated within templates
277 bit TemplateDependent = 0;
278 // Set to true for attributes that have a corresponding AST node.
280 // Set to true for attributes which have handler in Sema.
282 // Set to true for attributes that are completely ignored.
284 // Set to true if the attribute's parsing does not match its semantic
285 // content. Eg) It parses 3 args, but semantically takes 4 args. Opts out of
286 // common attribute error checking.
287 bit HasCustomParsing = 0;
288 // Set to true if all of the attribute's arguments should be parsed in an
289 // unevaluated context.
290 bit ParseArgumentsAsUnevaluated = 0;
291 // Set to true if this attribute can be duplicated on a subject when merging
292 // attributes. By default, attributes are not merged.
293 bit DuplicatesAllowedWhileMerging = 0;
294 // Lists language options, one of which is required to be true for the
295 // attribute to be applicable. If empty, no language options are required.
296 list<LangOpt> LangOpts = [];
297 // Any additional text that should be included verbatim in the class.
298 // Note: Any additional data members will leak and should be constructed
299 // externally on the ASTContext.
300 code AdditionalMembers = [{}];
301 // Any documentation that should be associated with the attribute. Since an
302 // attribute may be documented under multiple categories, more than one
303 // Documentation entry may be listed.
304 list<Documentation> Documentation;
307 /// A type attribute is not processed on a declaration or a statement.
308 class TypeAttr : Attr {
309 // By default, type attributes do not get an AST node.
313 /// An inheritable attribute is inherited by later redeclarations.
314 class InheritableAttr : Attr;
316 /// A target-specific attribute. This class is meant to be used as a mixin
317 /// with InheritableAttr or Attr depending on the attribute's needs.
318 class TargetSpecificAttr<TargetArch target> {
319 TargetArch Target = target;
320 // Attributes are generally required to have unique spellings for their names
321 // so that the parser can determine what kind of attribute it has parsed.
322 // However, target-specific attributes are special in that the attribute only
323 // "exists" for a given target. So two target-specific attributes can share
324 // the same name when they exist in different targets. To support this, a
325 // Kind can be explicitly specified for a target-specific attribute. This
326 // corresponds to the AttributeList::AT_* enum that is generated and it
327 // should contain a shared value between the attributes.
329 // Target-specific attributes which use this feature should ensure that the
330 // spellings match exactly betweeen the attributes, and if the arguments or
331 // subjects differ, should specify HasCustomParsing = 1 and implement their
332 // own parsing and semantic handling requirements as-needed.
336 /// An inheritable parameter attribute is inherited by later
337 /// redeclarations, even when it's written on a parameter.
338 class InheritableParamAttr : InheritableAttr;
340 /// An ignored attribute, which we parse but discard with no checking.
341 class IgnoredAttr : Attr {
345 let Documentation = [Undocumented];
349 // Attributes begin here
352 def AddressSpace : TypeAttr {
353 let Spellings = [GNU<"address_space">];
354 let Args = [IntArgument<"AddressSpace">];
355 let Documentation = [Undocumented];
359 let Spellings = [GCC<"alias">];
360 let Args = [StringArgument<"Aliasee">];
361 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
362 "ExpectedFunctionGlobalVarMethodOrProperty">;
363 let Documentation = [Undocumented];
366 def Aligned : InheritableAttr {
367 let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">,
368 Keyword<"_Alignas">];
369 // let Subjects = SubjectList<[NonBitField, NormalVar, Tag]>;
370 let Args = [AlignedArgument<"Alignment", 1>];
371 let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
372 Accessor<"isC11", [Keyword<"_Alignas">]>,
373 Accessor<"isAlignas", [Keyword<"alignas">,
374 Keyword<"_Alignas">]>,
375 Accessor<"isDeclspec",[Declspec<"align">]>];
376 let Documentation = [Undocumented];
379 def AlignValue : Attr {
381 // Unfortunately, this is semantically an assertion, not a directive
382 // (something else must ensure the alignment), so aligned_value is a
383 // probably a better name. We might want to add an aligned_value spelling in
384 // the future (and a corresponding C++ attribute), but this can be done
385 // later once we decide if we also want them to have slightly-different
386 // semantics than Intel's align_value.
388 // Intel's compiler on Windows also supports:
389 // , Declspec<"align_value">
391 let Args = [ExprArgument<"Alignment">];
392 let Subjects = SubjectList<[Var, TypedefName], WarnDiag,
393 "ExpectedVariableOrTypedef">;
394 let Documentation = [AlignValueDocs];
397 def AlignMac68k : InheritableAttr {
398 // This attribute has no spellings as it is only ever created implicitly.
401 let Documentation = [Undocumented];
404 def AlwaysInline : InheritableAttr {
405 let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
406 let Subjects = SubjectList<[Function]>;
407 let Documentation = [Undocumented];
410 def TLSModel : InheritableAttr {
411 let Spellings = [GCC<"tls_model">];
412 let Subjects = SubjectList<[TLSVar], ErrorDiag, "ExpectedTLSVar">;
413 let Args = [StringArgument<"Model">];
414 let Documentation = [TLSModelDocs];
417 def AnalyzerNoReturn : InheritableAttr {
418 let Spellings = [GNU<"analyzer_noreturn">];
419 let Documentation = [Undocumented];
422 def Annotate : InheritableParamAttr {
423 let Spellings = [GNU<"annotate">];
424 let Args = [StringArgument<"Annotation">];
425 let Documentation = [Undocumented];
428 def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> {
429 // NOTE: If you add any additional spellings, MSP430Interrupt's and
430 // MipsInterrupt's spellings must match.
431 let Spellings = [GNU<"interrupt">];
432 let Args = [EnumArgument<"Interrupt", "InterruptType",
433 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
434 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
436 let ParseKind = "Interrupt";
437 let HasCustomParsing = 1;
438 let Documentation = [ARMInterruptDocs];
441 def AsmLabel : InheritableAttr {
442 let Spellings = [Keyword<"asm">, Keyword<"__asm__">];
443 let Args = [StringArgument<"Label">];
445 let Documentation = [Undocumented];
448 def Availability : InheritableAttr {
449 let Spellings = [GNU<"availability">];
450 let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
451 VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
452 BoolArgument<"unavailable">, StringArgument<"message">];
453 let AdditionalMembers =
454 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
455 return llvm::StringSwitch<llvm::StringRef>(Platform)
456 .Case("android", "Android")
458 .Case("macosx", "OS X")
459 .Case("tvos", "tvOS")
460 .Case("watchos", "watchOS")
461 .Case("ios_app_extension", "iOS (App Extension)")
462 .Case("macosx_app_extension", "OS X (App Extension)")
463 .Case("tvos_app_extension", "tvOS (App Extension)")
464 .Case("watchos_app_extension", "watchOS (App Extension)")
465 .Default(llvm::StringRef());
467 let HasCustomParsing = 1;
468 let DuplicatesAllowedWhileMerging = 1;
469 // let Subjects = SubjectList<[Named]>;
470 let Documentation = [AvailabilityDocs];
473 def Blocks : InheritableAttr {
474 let Spellings = [GNU<"blocks">];
475 let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
476 let Documentation = [Undocumented];
479 def Bounded : IgnoredAttr {
480 let Spellings = [GNU<"bounded">];
483 def CarriesDependency : InheritableParamAttr {
484 let Spellings = [GNU<"carries_dependency">,
485 CXX11<"","carries_dependency", 200809>];
486 let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>;
487 let Documentation = [CarriesDependencyDocs];
490 def CDecl : InheritableAttr {
491 let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">];
492 // let Subjects = [Function, ObjCMethod];
493 let Documentation = [Undocumented];
496 // cf_audited_transfer indicates that the given function has been
497 // audited and has been marked with the appropriate cf_consumed and
498 // cf_returns_retained attributes. It is generally applied by
499 // '#pragma clang arc_cf_code_audited' rather than explicitly.
500 def CFAuditedTransfer : InheritableAttr {
501 let Spellings = [GNU<"cf_audited_transfer">];
502 let Subjects = SubjectList<[Function], ErrorDiag>;
503 let Documentation = [Undocumented];
506 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
507 // It indicates that the function has unknown or unautomatable
508 // transfer semantics.
509 def CFUnknownTransfer : InheritableAttr {
510 let Spellings = [GNU<"cf_unknown_transfer">];
511 let Subjects = SubjectList<[Function], ErrorDiag>;
512 let Documentation = [Undocumented];
515 def CFReturnsRetained : InheritableAttr {
516 let Spellings = [GNU<"cf_returns_retained">];
517 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
518 let Documentation = [Undocumented];
521 def CFReturnsNotRetained : InheritableAttr {
522 let Spellings = [GNU<"cf_returns_not_retained">];
523 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
524 let Documentation = [Undocumented];
527 def CFConsumed : InheritableParamAttr {
528 let Spellings = [GNU<"cf_consumed">];
529 let Subjects = SubjectList<[ParmVar]>;
530 let Documentation = [Undocumented];
533 def Cleanup : InheritableAttr {
534 let Spellings = [GCC<"cleanup">];
535 let Args = [FunctionArgument<"FunctionDecl">];
536 let Subjects = SubjectList<[Var]>;
537 let Documentation = [Undocumented];
540 def Cold : InheritableAttr {
541 let Spellings = [GCC<"cold">];
542 let Subjects = SubjectList<[Function]>;
543 let Documentation = [Undocumented];
546 def Common : InheritableAttr {
547 let Spellings = [GCC<"common">];
548 let Subjects = SubjectList<[Var]>;
549 let Documentation = [Undocumented];
552 def Const : InheritableAttr {
553 let Spellings = [GCC<"const">, GCC<"__const">];
554 let Documentation = [Undocumented];
557 def Constructor : InheritableAttr {
558 let Spellings = [GCC<"constructor">];
559 let Args = [DefaultIntArgument<"Priority", 65535>];
560 let Subjects = SubjectList<[Function]>;
561 let Documentation = [Undocumented];
564 def CUDAConstant : InheritableAttr {
565 let Spellings = [GNU<"constant">];
566 let Subjects = SubjectList<[Var]>;
567 let LangOpts = [CUDA];
568 let Documentation = [Undocumented];
571 def CUDACudartBuiltin : IgnoredAttr {
572 let Spellings = [GNU<"cudart_builtin">];
573 let LangOpts = [CUDA];
576 def CUDADevice : InheritableAttr {
577 let Spellings = [GNU<"device">];
578 let Subjects = SubjectList<[Function, Var]>;
579 let LangOpts = [CUDA];
580 let Documentation = [Undocumented];
583 def CUDADeviceBuiltin : IgnoredAttr {
584 let Spellings = [GNU<"device_builtin">];
585 let LangOpts = [CUDA];
588 def CUDADeviceBuiltinSurfaceType : IgnoredAttr {
589 let Spellings = [GNU<"device_builtin_surface_type">];
590 let LangOpts = [CUDA];
593 def CUDADeviceBuiltinTextureType : IgnoredAttr {
594 let Spellings = [GNU<"device_builtin_texture_type">];
595 let LangOpts = [CUDA];
598 def CUDAGlobal : InheritableAttr {
599 let Spellings = [GNU<"global">];
600 let Subjects = SubjectList<[Function]>;
601 let LangOpts = [CUDA];
602 let Documentation = [Undocumented];
605 def CUDAHost : InheritableAttr {
606 let Spellings = [GNU<"host">];
607 let Subjects = SubjectList<[Function]>;
608 let LangOpts = [CUDA];
609 let Documentation = [Undocumented];
612 def CUDAInvalidTarget : InheritableAttr {
614 let Subjects = SubjectList<[Function]>;
615 let LangOpts = [CUDA];
616 let Documentation = [Undocumented];
619 def CUDALaunchBounds : InheritableAttr {
620 let Spellings = [GNU<"launch_bounds">];
621 let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>];
622 let LangOpts = [CUDA];
623 let Subjects = SubjectList<[ObjCMethod, FunctionLike], WarnDiag,
624 "ExpectedFunctionOrMethod">;
625 // An AST node is created for this attribute, but is not used by other parts
626 // of the compiler. However, this node needs to exist in the AST because
627 // non-LLVM backends may be relying on the attribute's presence.
628 let Documentation = [Undocumented];
631 def CUDAShared : InheritableAttr {
632 let Spellings = [GNU<"shared">];
633 let Subjects = SubjectList<[Var]>;
634 let LangOpts = [CUDA];
635 let Documentation = [Undocumented];
638 def C11NoReturn : InheritableAttr {
639 let Spellings = [Keyword<"_Noreturn">];
640 let Subjects = SubjectList<[Function], ErrorDiag>;
642 let Documentation = [C11NoReturnDocs];
645 def CXX11NoReturn : InheritableAttr {
646 let Spellings = [CXX11<"","noreturn", 200809>];
647 let Subjects = SubjectList<[Function], ErrorDiag>;
648 let Documentation = [CXX11NoReturnDocs];
651 def OpenCLKernel : InheritableAttr {
652 let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
653 let Subjects = SubjectList<[Function], ErrorDiag>;
654 let Documentation = [Undocumented];
657 // This attribute is both a type attribute, and a declaration attribute (for
658 // parameter variables).
659 def OpenCLImageAccess : Attr {
660 let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
661 Keyword<"__write_only">, Keyword<"write_only">,
662 Keyword<"__read_write">, Keyword<"read_write">];
663 let Subjects = SubjectList<[ParmVar], ErrorDiag>;
664 let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
665 Keyword<"read_only">]>,
666 Accessor<"isReadWrite", [Keyword<"__read_write">,
667 Keyword<"read_write">]>,
668 Accessor<"isWriteOnly", [Keyword<"__write_only">,
669 Keyword<"write_only">]>];
670 let Documentation = [Undocumented];
673 def OpenCLPrivateAddressSpace : TypeAttr {
674 let Spellings = [Keyword<"__private">, Keyword<"private">];
675 let Documentation = [OpenCLAddressSpacePrivateDocs];
678 def OpenCLGlobalAddressSpace : TypeAttr {
679 let Spellings = [Keyword<"__global">, Keyword<"global">];
680 let Documentation = [OpenCLAddressSpaceGlobalDocs];
683 def OpenCLLocalAddressSpace : TypeAttr {
684 let Spellings = [Keyword<"__local">, Keyword<"local">];
685 let Documentation = [OpenCLAddressSpaceLocalDocs];
688 def OpenCLConstantAddressSpace : TypeAttr {
689 let Spellings = [Keyword<"__constant">, Keyword<"constant">];
690 let Documentation = [OpenCLAddressSpaceConstantDocs];
693 def OpenCLGenericAddressSpace : TypeAttr {
694 let Spellings = [Keyword<"__generic">, Keyword<"generic">];
695 let Documentation = [OpenCLAddressSpaceGenericDocs];
698 def Deprecated : InheritableAttr {
699 let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
700 CXX11<"","deprecated", 201309>];
701 let Args = [StringArgument<"Message", 1>];
702 let Documentation = [Undocumented];
705 def Destructor : InheritableAttr {
706 let Spellings = [GCC<"destructor">];
707 let Args = [DefaultIntArgument<"Priority", 65535>];
708 let Subjects = SubjectList<[Function]>;
709 let Documentation = [Undocumented];
712 def EnableIf : InheritableAttr {
713 let Spellings = [GNU<"enable_if">];
714 let Subjects = SubjectList<[Function]>;
715 let Args = [ExprArgument<"Cond">, StringArgument<"Message">];
716 let TemplateDependent = 1;
717 let Documentation = [EnableIfDocs];
720 def ExtVectorType : Attr {
721 let Spellings = [GNU<"ext_vector_type">];
722 let Subjects = SubjectList<[TypedefName], ErrorDiag>;
723 let Args = [ExprArgument<"NumElements">];
725 let Documentation = [Undocumented];
728 def FallThrough : Attr {
729 let Spellings = [CXX11<"clang", "fallthrough">];
730 // let Subjects = [NullStmt];
731 let Documentation = [FallthroughDocs];
734 def FastCall : InheritableAttr {
735 let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
736 Keyword<"_fastcall">];
737 // let Subjects = [Function, ObjCMethod];
738 let Documentation = [FastCallDocs];
741 def Final : InheritableAttr {
742 let Spellings = [Keyword<"final">, Keyword<"sealed">];
743 let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
745 let Documentation = [Undocumented];
748 def MinSize : InheritableAttr {
749 let Spellings = [GNU<"minsize">];
750 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
751 let Documentation = [Undocumented];
754 def FlagEnum : InheritableAttr {
755 let Spellings = [GNU<"flag_enum">];
756 let Subjects = SubjectList<[Enum]>;
757 let Documentation = [FlagEnumDocs];
758 let LangOpts = [COnly];
761 def Flatten : InheritableAttr {
762 let Spellings = [GCC<"flatten">];
763 let Subjects = SubjectList<[Function], ErrorDiag>;
764 let Documentation = [FlattenDocs];
767 def Format : InheritableAttr {
768 let Spellings = [GCC<"format">];
769 let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
770 IntArgument<"FirstArg">];
771 let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto], WarnDiag,
772 "ExpectedFunctionWithProtoType">;
773 let Documentation = [FormatDocs];
776 def FormatArg : InheritableAttr {
777 let Spellings = [GCC<"format_arg">];
778 let Args = [IntArgument<"FormatIdx">];
779 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto], WarnDiag,
780 "ExpectedFunctionWithProtoType">;
781 let Documentation = [Undocumented];
784 def GNUInline : InheritableAttr {
785 let Spellings = [GCC<"gnu_inline">];
786 let Subjects = SubjectList<[Function]>;
787 let Documentation = [Undocumented];
790 def Hot : InheritableAttr {
791 let Spellings = [GCC<"hot">];
792 let Subjects = SubjectList<[Function]>;
793 // An AST node is created for this attribute, but not actually used beyond
794 // semantic checking for mutual exclusion with the Cold attribute.
795 let Documentation = [Undocumented];
798 def IBAction : InheritableAttr {
799 let Spellings = [GNU<"ibaction">];
800 let Subjects = SubjectList<[ObjCInstanceMethod], WarnDiag,
801 "ExpectedObjCInstanceMethod">;
802 // An AST node is created for this attribute, but is not used by other parts
803 // of the compiler. However, this node needs to exist in the AST because
804 // external tools rely on it.
805 let Documentation = [Undocumented];
808 def IBOutlet : InheritableAttr {
809 let Spellings = [GNU<"iboutlet">];
810 // let Subjects = [ObjCIvar, ObjCProperty];
811 let Documentation = [Undocumented];
814 def IBOutletCollection : InheritableAttr {
815 let Spellings = [GNU<"iboutletcollection">];
816 let Args = [TypeArgument<"Interface", 1>];
817 // let Subjects = [ObjCIvar, ObjCProperty];
818 let Documentation = [Undocumented];
821 def Restrict : InheritableAttr {
822 let Spellings = [Declspec<"restrict">, GCC<"malloc">];
823 let Subjects = SubjectList<[Function]>;
824 let Documentation = [Undocumented];
827 def MaxFieldAlignment : InheritableAttr {
828 // This attribute has no spellings as it is only ever created implicitly.
830 let Args = [UnsignedArgument<"Alignment">];
832 let Documentation = [Undocumented];
835 def MayAlias : InheritableAttr {
836 // FIXME: this is a type attribute in GCC, but a declaration attribute here.
837 let Spellings = [GCC<"may_alias">];
838 let Documentation = [Undocumented];
841 def MSABI : InheritableAttr {
842 let Spellings = [GCC<"ms_abi">];
843 // let Subjects = [Function, ObjCMethod];
844 let Documentation = [MSABIDocs];
847 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
848 // NOTE: If you add any additional spellings, ARMInterrupt's and
849 // MipsInterrupt's spellings must match.
850 let Spellings = [GNU<"interrupt">];
851 let Args = [UnsignedArgument<"Number">];
852 let ParseKind = "Interrupt";
853 let HasCustomParsing = 1;
854 let Documentation = [Undocumented];
857 def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
858 let Spellings = [GCC<"mips16">];
859 let Subjects = SubjectList<[Function], ErrorDiag>;
860 let Documentation = [Undocumented];
863 def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips> {
864 // NOTE: If you add any additional spellings, ARMInterrupt's and
865 // MSP430Interrupt's spellings must match.
866 let Spellings = [GNU<"interrupt">];
867 let Subjects = SubjectList<[Function]>;
868 let Args = [EnumArgument<"Interrupt", "InterruptType",
869 ["vector=sw0", "vector=sw1", "vector=hw0",
870 "vector=hw1", "vector=hw2", "vector=hw3",
871 "vector=hw4", "vector=hw5", "eic", ""],
872 ["sw0", "sw1", "hw0", "hw1", "hw2", "hw3",
873 "hw4", "hw5", "eic", "eic"]
875 let ParseKind = "Interrupt";
876 let Documentation = [MipsInterruptDocs];
880 let Spellings = [GCC<"mode">];
881 let Args = [IdentifierArgument<"Mode">];
882 let Documentation = [Undocumented];
885 def Naked : InheritableAttr {
886 let Spellings = [GCC<"naked">, Declspec<"naked">];
887 let Subjects = SubjectList<[Function]>;
888 let Documentation = [Undocumented];
891 def NeonPolyVectorType : TypeAttr {
892 let Spellings = [GNU<"neon_polyvector_type">];
893 let Args = [IntArgument<"NumElements">];
894 let Documentation = [Undocumented];
897 def NeonVectorType : TypeAttr {
898 let Spellings = [GNU<"neon_vector_type">];
899 let Args = [IntArgument<"NumElements">];
900 let Documentation = [Undocumented];
903 def ReturnsTwice : InheritableAttr {
904 let Spellings = [GCC<"returns_twice">];
905 let Subjects = SubjectList<[Function]>;
906 let Documentation = [Undocumented];
909 def DisableTailCalls : InheritableAttr {
910 let Spellings = [GNU<"disable_tail_calls">,
911 CXX11<"clang", "disable_tail_calls">];
912 let Subjects = SubjectList<[Function, ObjCMethod]>;
913 let Documentation = [DisableTailCallsDocs];
916 def NoAlias : InheritableAttr {
917 let Spellings = [Declspec<"noalias">];
918 let Subjects = SubjectList<[Function]>;
919 let Documentation = [NoAliasDocs];
922 def NoCommon : InheritableAttr {
923 let Spellings = [GCC<"nocommon">];
924 let Subjects = SubjectList<[Var]>;
925 let Documentation = [Undocumented];
928 def NoDebug : InheritableAttr {
929 let Spellings = [GCC<"nodebug">];
930 let Documentation = [Undocumented];
933 def NoDuplicate : InheritableAttr {
934 let Spellings = [GNU<"noduplicate">, CXX11<"clang", "noduplicate">];
935 let Subjects = SubjectList<[Function]>;
936 let Documentation = [NoDuplicateDocs];
939 def NoInline : InheritableAttr {
940 let Spellings = [GCC<"noinline">, Declspec<"noinline">];
941 let Subjects = SubjectList<[Function]>;
942 let Documentation = [Undocumented];
945 def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
946 let Spellings = [GCC<"nomips16">];
947 let Subjects = SubjectList<[Function], ErrorDiag>;
948 let Documentation = [Undocumented];
951 // This is not a TargetSpecificAttr so that is silently accepted and
952 // ignored on other targets as encouraged by the OpenCL spec.
954 // See OpenCL 1.2 6.11.5: "It is our intention that a particular
955 // implementation of OpenCL be free to ignore all attributes and the
956 // resulting executable binary will produce the same result."
958 // However, only AMD GPU targets will emit the corresponding IR
961 // FIXME: This provides a sub-optimal error message if you attempt to
962 // use this in CUDA, since CUDA does not use the same terminology.
963 def AMDGPUNumVGPR : InheritableAttr {
964 let Spellings = [GNU<"amdgpu_num_vgpr">];
965 let Args = [UnsignedArgument<"NumVGPR">];
966 let Documentation = [AMDGPUNumVGPRDocs];
968 // FIXME: This should be for OpenCLKernelFunction, but is not to
969 // workaround needing to see kernel attribute before others to know if
970 // this should be rejected on non-kernels.
971 let Subjects = SubjectList<[Function], ErrorDiag,
972 "ExpectedKernelFunction">;
975 def AMDGPUNumSGPR : InheritableAttr {
976 let Spellings = [GNU<"amdgpu_num_sgpr">];
977 let Args = [UnsignedArgument<"NumSGPR">];
978 let Documentation = [AMDGPUNumSGPRDocs];
979 let Subjects = SubjectList<[Function], ErrorDiag,
980 "ExpectedKernelFunction">;
983 def NoSplitStack : InheritableAttr {
984 let Spellings = [GCC<"no_split_stack">];
985 let Subjects = SubjectList<[Function], ErrorDiag>;
986 let Documentation = [NoSplitStackDocs];
989 def NonNull : InheritableAttr {
990 let Spellings = [GCC<"nonnull">];
991 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
992 "ExpectedFunctionMethodOrParameter">;
993 let Args = [VariadicUnsignedArgument<"Args">];
994 let AdditionalMembers =
995 [{bool isNonNull(unsigned idx) const {
998 for (const auto &V : args())
1003 // FIXME: We should merge duplicates into a single nonnull attribute.
1004 let DuplicatesAllowedWhileMerging = 1;
1005 let Documentation = [NonNullDocs];
1008 def ReturnsNonNull : InheritableAttr {
1009 let Spellings = [GCC<"returns_nonnull">];
1010 let Subjects = SubjectList<[ObjCMethod, Function], WarnDiag,
1011 "ExpectedFunctionOrMethod">;
1012 let Documentation = [ReturnsNonNullDocs];
1015 // pass_object_size(N) indicates that the parameter should have
1016 // __builtin_object_size with Type=N evaluated on the parameter at the callsite.
1017 def PassObjectSize : InheritableParamAttr {
1018 let Spellings = [GNU<"pass_object_size">];
1019 let Args = [IntArgument<"Type">];
1020 let Subjects = SubjectList<[ParmVar]>;
1021 let Documentation = [PassObjectSizeDocs];
1024 // Nullability type attributes.
1025 def TypeNonNull : TypeAttr {
1026 let Spellings = [Keyword<"_Nonnull">];
1027 let Documentation = [TypeNonNullDocs];
1030 def TypeNullable : TypeAttr {
1031 let Spellings = [Keyword<"_Nullable">];
1032 let Documentation = [TypeNullableDocs];
1035 def TypeNullUnspecified : TypeAttr {
1036 let Spellings = [Keyword<"_Null_unspecified">];
1037 let Documentation = [TypeNullUnspecifiedDocs];
1040 def ObjCKindOf : TypeAttr {
1041 let Spellings = [Keyword<"__kindof">];
1042 let Documentation = [Undocumented];
1045 def AssumeAligned : InheritableAttr {
1046 let Spellings = [GCC<"assume_aligned">];
1047 let Subjects = SubjectList<[ObjCMethod, Function]>;
1048 let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>];
1049 let Documentation = [AssumeAlignedDocs];
1052 def NoReturn : InheritableAttr {
1053 let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
1054 // FIXME: Does GCC allow this on the function instead?
1055 let Documentation = [Undocumented];
1058 def NoInstrumentFunction : InheritableAttr {
1059 let Spellings = [GCC<"no_instrument_function">];
1060 let Subjects = SubjectList<[Function]>;
1061 let Documentation = [Undocumented];
1064 def NotTailCalled : InheritableAttr {
1065 let Spellings = [GNU<"not_tail_called">, CXX11<"clang", "not_tail_called">];
1066 let Subjects = SubjectList<[Function]>;
1067 let Documentation = [NotTailCalledDocs];
1070 def NoThrow : InheritableAttr {
1071 let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
1072 let Documentation = [Undocumented];
1075 def NvWeak : IgnoredAttr {
1076 let Spellings = [GNU<"nv_weak">];
1077 let LangOpts = [CUDA];
1080 def ObjCBridge : InheritableAttr {
1081 let Spellings = [GNU<"objc_bridge">];
1082 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag,
1083 "ExpectedStructOrUnionOrTypedef">;
1084 let Args = [IdentifierArgument<"BridgedType">];
1085 let Documentation = [Undocumented];
1088 def ObjCBridgeMutable : InheritableAttr {
1089 let Spellings = [GNU<"objc_bridge_mutable">];
1090 let Subjects = SubjectList<[Record], ErrorDiag>;
1091 let Args = [IdentifierArgument<"BridgedType">];
1092 let Documentation = [Undocumented];
1095 def ObjCBridgeRelated : InheritableAttr {
1096 let Spellings = [GNU<"objc_bridge_related">];
1097 let Subjects = SubjectList<[Record], ErrorDiag>;
1098 let Args = [IdentifierArgument<"RelatedClass">,
1099 IdentifierArgument<"ClassMethod", 1>,
1100 IdentifierArgument<"InstanceMethod", 1>];
1101 let HasCustomParsing = 1;
1102 let Documentation = [Undocumented];
1105 def NSReturnsRetained : InheritableAttr {
1106 let Spellings = [GNU<"ns_returns_retained">];
1107 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1108 let Documentation = [Undocumented];
1111 def NSReturnsNotRetained : InheritableAttr {
1112 let Spellings = [GNU<"ns_returns_not_retained">];
1113 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1114 let Documentation = [Undocumented];
1117 def NSReturnsAutoreleased : InheritableAttr {
1118 let Spellings = [GNU<"ns_returns_autoreleased">];
1119 // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
1120 let Documentation = [Undocumented];
1123 def NSConsumesSelf : InheritableAttr {
1124 let Spellings = [GNU<"ns_consumes_self">];
1125 let Subjects = SubjectList<[ObjCMethod]>;
1126 let Documentation = [Undocumented];
1129 def NSConsumed : InheritableParamAttr {
1130 let Spellings = [GNU<"ns_consumed">];
1131 let Subjects = SubjectList<[ParmVar]>;
1132 let Documentation = [Undocumented];
1135 def ObjCException : InheritableAttr {
1136 let Spellings = [GNU<"objc_exception">];
1137 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1138 let Documentation = [Undocumented];
1141 def ObjCMethodFamily : InheritableAttr {
1142 let Spellings = [GNU<"objc_method_family">];
1143 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1144 let Args = [EnumArgument<"Family", "FamilyKind",
1145 ["none", "alloc", "copy", "init", "mutableCopy", "new"],
1146 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
1147 "OMF_mutableCopy", "OMF_new"]>];
1148 let Documentation = [ObjCMethodFamilyDocs];
1151 def ObjCNSObject : InheritableAttr {
1152 let Spellings = [GNU<"NSObject">];
1153 let Documentation = [Undocumented];
1156 def ObjCIndependentClass : InheritableAttr {
1157 let Spellings = [GNU<"objc_independent_class">];
1158 let Documentation = [Undocumented];
1161 def ObjCPreciseLifetime : InheritableAttr {
1162 let Spellings = [GNU<"objc_precise_lifetime">];
1163 let Subjects = SubjectList<[Var], ErrorDiag>;
1164 let Documentation = [Undocumented];
1167 def ObjCReturnsInnerPointer : InheritableAttr {
1168 let Spellings = [GNU<"objc_returns_inner_pointer">];
1169 let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
1170 let Documentation = [Undocumented];
1173 def ObjCRequiresSuper : InheritableAttr {
1174 let Spellings = [GNU<"objc_requires_super">];
1175 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1176 let Documentation = [ObjCRequiresSuperDocs];
1179 def ObjCRootClass : InheritableAttr {
1180 let Spellings = [GNU<"objc_root_class">];
1181 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1182 let Documentation = [Undocumented];
1185 def ObjCExplicitProtocolImpl : InheritableAttr {
1186 let Spellings = [GNU<"objc_protocol_requires_explicit_implementation">];
1187 let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
1188 let Documentation = [Undocumented];
1191 def ObjCDesignatedInitializer : Attr {
1192 let Spellings = [GNU<"objc_designated_initializer">];
1193 let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag,
1194 "ExpectedObjCInterfaceDeclInitMethod">;
1195 let Documentation = [Undocumented];
1198 def ObjCRuntimeName : Attr {
1199 let Spellings = [GNU<"objc_runtime_name">];
1200 let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
1201 let Args = [StringArgument<"MetadataName">];
1202 let Documentation = [ObjCRuntimeNameDocs];
1205 def ObjCBoxable : Attr {
1206 let Spellings = [GNU<"objc_boxable">];
1207 let Subjects = SubjectList<[Record], ErrorDiag, "ExpectedStructOrUnion">;
1208 let Documentation = [ObjCBoxableDocs];
1211 def OptimizeNone : InheritableAttr {
1212 let Spellings = [GNU<"optnone">, CXX11<"clang", "optnone">];
1213 let Subjects = SubjectList<[Function, ObjCMethod]>;
1214 let Documentation = [OptnoneDocs];
1217 def Overloadable : Attr {
1218 let Spellings = [GNU<"overloadable">];
1219 let Subjects = SubjectList<[Function], ErrorDiag>;
1220 let Documentation = [OverloadableDocs];
1223 def Override : InheritableAttr {
1224 let Spellings = [Keyword<"override">];
1225 let SemaHandler = 0;
1226 let Documentation = [Undocumented];
1229 def Ownership : InheritableAttr {
1230 let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
1231 GNU<"ownership_takes">];
1232 let Accessors = [Accessor<"isHolds", [GNU<"ownership_holds">]>,
1233 Accessor<"isReturns", [GNU<"ownership_returns">]>,
1234 Accessor<"isTakes", [GNU<"ownership_takes">]>];
1235 let AdditionalMembers = [{
1236 enum OwnershipKind { Holds, Returns, Takes };
1237 OwnershipKind getOwnKind() const {
1238 return isHolds() ? Holds :
1243 let Args = [IdentifierArgument<"Module">, VariadicUnsignedArgument<"Args">];
1244 let Subjects = SubjectList<[HasFunctionProto], WarnDiag,
1245 "ExpectedFunctionWithProtoType">;
1246 let Documentation = [Undocumented];
1249 def Packed : InheritableAttr {
1250 let Spellings = [GCC<"packed">];
1251 // let Subjects = [Tag, Field];
1252 let Documentation = [Undocumented];
1255 def IntelOclBicc : InheritableAttr {
1256 let Spellings = [GNU<"intel_ocl_bicc">];
1257 // let Subjects = [Function, ObjCMethod];
1258 let Documentation = [Undocumented];
1261 def Pcs : InheritableAttr {
1262 let Spellings = [GCC<"pcs">];
1263 let Args = [EnumArgument<"PCS", "PCSType",
1264 ["aapcs", "aapcs-vfp"],
1265 ["AAPCS", "AAPCS_VFP"]>];
1266 // let Subjects = [Function, ObjCMethod];
1267 let Documentation = [PcsDocs];
1270 def Pure : InheritableAttr {
1271 let Spellings = [GCC<"pure">];
1272 let Documentation = [Undocumented];
1275 def Regparm : TypeAttr {
1276 let Spellings = [GCC<"regparm">];
1277 let Args = [UnsignedArgument<"NumParams">];
1278 let Documentation = [RegparmDocs];
1281 def ReqdWorkGroupSize : InheritableAttr {
1282 let Spellings = [GNU<"reqd_work_group_size">];
1283 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
1284 UnsignedArgument<"ZDim">];
1285 let Subjects = SubjectList<[Function], ErrorDiag>;
1286 let Documentation = [Undocumented];
1289 def WorkGroupSizeHint : InheritableAttr {
1290 let Spellings = [GNU<"work_group_size_hint">];
1291 let Args = [UnsignedArgument<"XDim">,
1292 UnsignedArgument<"YDim">,
1293 UnsignedArgument<"ZDim">];
1294 let Subjects = SubjectList<[Function], ErrorDiag>;
1295 let Documentation = [Undocumented];
1298 def InitPriority : InheritableAttr {
1299 let Spellings = [GNU<"init_priority">];
1300 let Args = [UnsignedArgument<"Priority">];
1301 let Subjects = SubjectList<[Var], ErrorDiag>;
1302 let Documentation = [Undocumented];
1305 def Section : InheritableAttr {
1306 let Spellings = [GCC<"section">, Declspec<"allocate">];
1307 let Args = [StringArgument<"Name">];
1308 let Subjects = SubjectList<[Function, GlobalVar,
1309 ObjCMethod, ObjCProperty], ErrorDiag,
1310 "ExpectedFunctionGlobalVarMethodOrProperty">;
1311 let Documentation = [SectionDocs];
1314 def Sentinel : InheritableAttr {
1315 let Spellings = [GCC<"sentinel">];
1316 let Args = [DefaultIntArgument<"Sentinel", 0>,
1317 DefaultIntArgument<"NullPos", 0>];
1318 // let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
1319 let Documentation = [Undocumented];
1322 def StdCall : InheritableAttr {
1323 let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
1324 // let Subjects = [Function, ObjCMethod];
1325 let Documentation = [StdCallDocs];
1328 def SysVABI : InheritableAttr {
1329 let Spellings = [GCC<"sysv_abi">];
1330 // let Subjects = [Function, ObjCMethod];
1331 let Documentation = [Undocumented];
1334 def ThisCall : InheritableAttr {
1335 let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
1336 Keyword<"_thiscall">];
1337 // let Subjects = [Function, ObjCMethod];
1338 let Documentation = [ThisCallDocs];
1341 def VectorCall : InheritableAttr {
1342 let Spellings = [GNU<"vectorcall">, Keyword<"__vectorcall">,
1343 Keyword<"_vectorcall">];
1344 // let Subjects = [Function, ObjCMethod];
1345 let Documentation = [VectorCallDocs];
1348 def Pascal : InheritableAttr {
1349 let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
1350 // let Subjects = [Function, ObjCMethod];
1351 let Documentation = [Undocumented];
1354 def Target : InheritableAttr {
1355 let Spellings = [GCC<"target">];
1356 let Args = [StringArgument<"featuresStr">];
1357 let Subjects = SubjectList<[Function], ErrorDiag>;
1358 let Documentation = [TargetDocs];
1359 let AdditionalMembers = [{
1360 typedef std::pair<std::vector<std::string>, StringRef> ParsedTargetAttr;
1361 ParsedTargetAttr parse() const {
1362 ParsedTargetAttr Ret;
1363 SmallVector<StringRef, 1> AttrFeatures;
1364 getFeaturesStr().split(AttrFeatures, ",");
1366 // Grab the various features and prepend a "+" to turn on the feature to
1367 // the backend and add them to our existing set of features.
1368 for (auto &Feature : AttrFeatures) {
1369 // Go ahead and trim whitespace rather than either erroring or
1370 // accepting it weirdly.
1371 Feature = Feature.trim();
1373 // We don't support cpu tuning this way currently.
1374 // TODO: Support the fpmath option. It will require checking
1375 // overall feature validity for the function with the rest of the
1376 // attributes on the function.
1377 if (Feature.startswith("fpmath=") || Feature.startswith("tune="))
1380 // While we're here iterating check for a different target cpu.
1381 if (Feature.startswith("arch="))
1382 Ret.second = Feature.split("=").second.trim();
1383 else if (Feature.startswith("no-"))
1384 Ret.first.push_back("-" + Feature.split("-").second.str());
1386 Ret.first.push_back("+" + Feature.str());
1393 def TransparentUnion : InheritableAttr {
1394 let Spellings = [GCC<"transparent_union">];
1395 // let Subjects = SubjectList<[Record, TypedefName]>;
1396 let Documentation = [Undocumented];
1399 def Unavailable : InheritableAttr {
1400 let Spellings = [GNU<"unavailable">];
1401 let Args = [StringArgument<"Message", 1>,
1402 EnumArgument<"ImplicitReason", "ImplicitReason",
1405 "IR_ARCForbiddenType",
1407 "IR_ARCForbiddenConversion",
1408 "IR_ARCInitReturnsUnrelated",
1409 "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>];
1410 let Documentation = [Undocumented];
1413 def ArcWeakrefUnavailable : InheritableAttr {
1414 let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
1415 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1416 let Documentation = [Undocumented];
1419 def ObjCGC : TypeAttr {
1420 let Spellings = [GNU<"objc_gc">];
1421 let Args = [IdentifierArgument<"Kind">];
1422 let Documentation = [Undocumented];
1425 def ObjCOwnership : InheritableAttr {
1426 let Spellings = [GNU<"objc_ownership">];
1427 let Args = [IdentifierArgument<"Kind">];
1429 let Documentation = [Undocumented];
1432 def ObjCRequiresPropertyDefs : InheritableAttr {
1433 let Spellings = [GNU<"objc_requires_property_definitions">];
1434 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1435 let Documentation = [Undocumented];
1438 def Unused : InheritableAttr {
1439 let Spellings = [GCC<"unused">];
1440 let Subjects = SubjectList<[Var, ObjCIvar, Type, Label, Field, ObjCMethod,
1441 FunctionLike], WarnDiag,
1442 "ExpectedVariableFunctionOrLabel">;
1443 let Documentation = [Undocumented];
1446 def Used : InheritableAttr {
1447 let Spellings = [GCC<"used">];
1448 let Documentation = [Undocumented];
1451 def Uuid : InheritableAttr {
1452 let Spellings = [Declspec<"uuid">];
1453 let Args = [StringArgument<"Guid">];
1454 // let Subjects = SubjectList<[CXXRecord]>;
1455 let LangOpts = [MicrosoftExt, Borland];
1456 let Documentation = [Undocumented];
1459 def VectorSize : TypeAttr {
1460 let Spellings = [GCC<"vector_size">];
1461 let Args = [ExprArgument<"NumBytes">];
1462 let Documentation = [Undocumented];
1465 def VecTypeHint : InheritableAttr {
1466 let Spellings = [GNU<"vec_type_hint">];
1467 let Args = [TypeArgument<"TypeHint">];
1468 let Subjects = SubjectList<[Function], ErrorDiag>;
1469 let Documentation = [Undocumented];
1472 def Visibility : InheritableAttr {
1474 let Spellings = [GCC<"visibility">];
1475 let Args = [EnumArgument<"Visibility", "VisibilityType",
1476 ["default", "hidden", "internal", "protected"],
1477 ["Default", "Hidden", "Hidden", "Protected"]>];
1478 let Documentation = [Undocumented];
1481 def TypeVisibility : InheritableAttr {
1483 let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">];
1484 let Args = [EnumArgument<"Visibility", "VisibilityType",
1485 ["default", "hidden", "internal", "protected"],
1486 ["Default", "Hidden", "Hidden", "Protected"]>];
1487 // let Subjects = [Tag, ObjCInterface, Namespace];
1488 let Documentation = [Undocumented];
1491 def VecReturn : InheritableAttr {
1492 let Spellings = [GNU<"vecreturn">];
1493 let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
1494 let Documentation = [Undocumented];
1497 def WarnUnused : InheritableAttr {
1498 let Spellings = [GNU<"warn_unused">];
1499 let Subjects = SubjectList<[Record]>;
1500 let Documentation = [Undocumented];
1503 def WarnUnusedResult : InheritableAttr {
1504 let Spellings = [GCC<"warn_unused_result">,
1505 CXX11<"clang", "warn_unused_result">];
1506 let Subjects = SubjectList<[ObjCMethod, CXXRecord, FunctionLike], WarnDiag,
1507 "ExpectedFunctionMethodOrClass">;
1508 let Documentation = [Undocumented];
1511 def Weak : InheritableAttr {
1512 let Spellings = [GCC<"weak">];
1513 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
1514 let Documentation = [Undocumented];
1517 def WeakImport : InheritableAttr {
1518 let Spellings = [GNU<"weak_import">];
1519 let Documentation = [Undocumented];
1522 def WeakRef : InheritableAttr {
1523 let Spellings = [GCC<"weakref">];
1524 // A WeakRef that has an argument is treated as being an AliasAttr
1525 let Args = [StringArgument<"Aliasee", 1>];
1526 let Subjects = SubjectList<[Var, Function], ErrorDiag>;
1527 let Documentation = [Undocumented];
1530 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetX86> {
1531 let Spellings = [GNU<"force_align_arg_pointer">];
1532 // Technically, this appertains to a FunctionDecl, but the target-specific
1533 // code silently allows anything function-like (such as typedefs or function
1534 // pointers), but does not apply the attribute to them.
1535 let Documentation = [Undocumented];
1538 def NoSanitize : InheritableAttr {
1539 let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">];
1540 let Args = [VariadicStringArgument<"Sanitizers">];
1541 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
1542 let Documentation = [NoSanitizeDocs];
1543 let AdditionalMembers = [{
1544 SanitizerMask getMask() const {
1545 SanitizerMask Mask = 0;
1546 for (auto SanitizerName : sanitizers()) {
1547 SanitizerMask ParsedMask =
1548 parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
1549 Mask |= expandSanitizerGroups(ParsedMask);
1556 // Attributes to disable a specific sanitizer. No new sanitizers should be added
1557 // to this list; the no_sanitize attribute should be extended instead.
1558 def NoSanitizeSpecific : InheritableAttr {
1559 let Spellings = [GCC<"no_address_safety_analysis">,
1560 GCC<"no_sanitize_address">,
1561 GCC<"no_sanitize_thread">,
1562 GNU<"no_sanitize_memory">];
1563 let Subjects = SubjectList<[Function], ErrorDiag>;
1564 let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
1565 NoSanitizeMemoryDocs];
1569 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
1571 def GuardedVar : InheritableAttr {
1572 let Spellings = [GNU<"guarded_var">];
1573 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1574 "ExpectedFieldOrGlobalVar">;
1575 let Documentation = [Undocumented];
1578 def PtGuardedVar : InheritableAttr {
1579 let Spellings = [GNU<"pt_guarded_var">];
1580 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1581 "ExpectedFieldOrGlobalVar">;
1582 let Documentation = [Undocumented];
1585 def Lockable : InheritableAttr {
1586 let Spellings = [GNU<"lockable">];
1587 let Subjects = SubjectList<[Record]>;
1588 let Documentation = [Undocumented];
1589 let ASTNode = 0; // Replaced by Capability
1592 def ScopedLockable : InheritableAttr {
1593 let Spellings = [GNU<"scoped_lockable">];
1594 let Subjects = SubjectList<[Record]>;
1595 let Documentation = [Undocumented];
1598 def Capability : InheritableAttr {
1599 let Spellings = [GNU<"capability">, CXX11<"clang", "capability">,
1600 GNU<"shared_capability">,
1601 CXX11<"clang", "shared_capability">];
1602 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag,
1603 "ExpectedStructOrUnionOrTypedef">;
1604 let Args = [StringArgument<"Name">];
1605 let Accessors = [Accessor<"isShared",
1606 [GNU<"shared_capability">,
1607 CXX11<"clang","shared_capability">]>];
1608 let Documentation = [Undocumented];
1609 let AdditionalMembers = [{
1610 bool isMutex() const { return getName().equals_lower("mutex"); }
1611 bool isRole() const { return getName().equals_lower("role"); }
1615 def AssertCapability : InheritableAttr {
1616 let Spellings = [GNU<"assert_capability">,
1617 CXX11<"clang", "assert_capability">,
1618 GNU<"assert_shared_capability">,
1619 CXX11<"clang", "assert_shared_capability">];
1620 let Subjects = SubjectList<[Function]>;
1622 let TemplateDependent = 1;
1623 let ParseArgumentsAsUnevaluated = 1;
1624 let DuplicatesAllowedWhileMerging = 1;
1625 let Args = [ExprArgument<"Expr">];
1626 let Accessors = [Accessor<"isShared",
1627 [GNU<"assert_shared_capability">,
1628 CXX11<"clang", "assert_shared_capability">]>];
1629 let Documentation = [AssertCapabilityDocs];
1632 def AcquireCapability : InheritableAttr {
1633 let Spellings = [GNU<"acquire_capability">,
1634 CXX11<"clang", "acquire_capability">,
1635 GNU<"acquire_shared_capability">,
1636 CXX11<"clang", "acquire_shared_capability">,
1637 GNU<"exclusive_lock_function">,
1638 GNU<"shared_lock_function">];
1639 let Subjects = SubjectList<[Function]>;
1641 let TemplateDependent = 1;
1642 let ParseArgumentsAsUnevaluated = 1;
1643 let DuplicatesAllowedWhileMerging = 1;
1644 let Args = [VariadicExprArgument<"Args">];
1645 let Accessors = [Accessor<"isShared",
1646 [GNU<"acquire_shared_capability">,
1647 CXX11<"clang", "acquire_shared_capability">,
1648 GNU<"shared_lock_function">]>];
1649 let Documentation = [AcquireCapabilityDocs];
1652 def TryAcquireCapability : InheritableAttr {
1653 let Spellings = [GNU<"try_acquire_capability">,
1654 CXX11<"clang", "try_acquire_capability">,
1655 GNU<"try_acquire_shared_capability">,
1656 CXX11<"clang", "try_acquire_shared_capability">];
1657 let Subjects = SubjectList<[Function],
1660 let TemplateDependent = 1;
1661 let ParseArgumentsAsUnevaluated = 1;
1662 let DuplicatesAllowedWhileMerging = 1;
1663 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1664 let Accessors = [Accessor<"isShared",
1665 [GNU<"try_acquire_shared_capability">,
1666 CXX11<"clang", "try_acquire_shared_capability">]>];
1667 let Documentation = [TryAcquireCapabilityDocs];
1670 def ReleaseCapability : InheritableAttr {
1671 let Spellings = [GNU<"release_capability">,
1672 CXX11<"clang", "release_capability">,
1673 GNU<"release_shared_capability">,
1674 CXX11<"clang", "release_shared_capability">,
1675 GNU<"release_generic_capability">,
1676 CXX11<"clang", "release_generic_capability">,
1677 GNU<"unlock_function">];
1678 let Subjects = SubjectList<[Function]>;
1680 let TemplateDependent = 1;
1681 let ParseArgumentsAsUnevaluated = 1;
1682 let DuplicatesAllowedWhileMerging = 1;
1683 let Args = [VariadicExprArgument<"Args">];
1684 let Accessors = [Accessor<"isShared",
1685 [GNU<"release_shared_capability">,
1686 CXX11<"clang", "release_shared_capability">]>,
1687 Accessor<"isGeneric",
1688 [GNU<"release_generic_capability">,
1689 CXX11<"clang", "release_generic_capability">,
1690 GNU<"unlock_function">]>];
1691 let Documentation = [ReleaseCapabilityDocs];
1694 def RequiresCapability : InheritableAttr {
1695 let Spellings = [GNU<"requires_capability">,
1696 CXX11<"clang", "requires_capability">,
1697 GNU<"exclusive_locks_required">,
1698 GNU<"requires_shared_capability">,
1699 CXX11<"clang", "requires_shared_capability">,
1700 GNU<"shared_locks_required">];
1701 let Args = [VariadicExprArgument<"Args">];
1703 let TemplateDependent = 1;
1704 let ParseArgumentsAsUnevaluated = 1;
1705 let DuplicatesAllowedWhileMerging = 1;
1706 let Subjects = SubjectList<[Function]>;
1707 let Accessors = [Accessor<"isShared", [GNU<"requires_shared_capability">,
1708 GNU<"shared_locks_required">,
1709 CXX11<"clang","requires_shared_capability">]>];
1710 let Documentation = [Undocumented];
1713 def NoThreadSafetyAnalysis : InheritableAttr {
1714 let Spellings = [GNU<"no_thread_safety_analysis">];
1715 let Subjects = SubjectList<[Function]>;
1716 let Documentation = [Undocumented];
1719 def GuardedBy : InheritableAttr {
1720 let Spellings = [GNU<"guarded_by">];
1721 let Args = [ExprArgument<"Arg">];
1723 let TemplateDependent = 1;
1724 let ParseArgumentsAsUnevaluated = 1;
1725 let DuplicatesAllowedWhileMerging = 1;
1726 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1727 "ExpectedFieldOrGlobalVar">;
1728 let Documentation = [Undocumented];
1731 def PtGuardedBy : InheritableAttr {
1732 let Spellings = [GNU<"pt_guarded_by">];
1733 let Args = [ExprArgument<"Arg">];
1735 let TemplateDependent = 1;
1736 let ParseArgumentsAsUnevaluated = 1;
1737 let DuplicatesAllowedWhileMerging = 1;
1738 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1739 "ExpectedFieldOrGlobalVar">;
1740 let Documentation = [Undocumented];
1743 def AcquiredAfter : InheritableAttr {
1744 let Spellings = [GNU<"acquired_after">];
1745 let Args = [VariadicExprArgument<"Args">];
1747 let TemplateDependent = 1;
1748 let ParseArgumentsAsUnevaluated = 1;
1749 let DuplicatesAllowedWhileMerging = 1;
1750 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1751 "ExpectedFieldOrGlobalVar">;
1752 let Documentation = [Undocumented];
1755 def AcquiredBefore : InheritableAttr {
1756 let Spellings = [GNU<"acquired_before">];
1757 let Args = [VariadicExprArgument<"Args">];
1759 let TemplateDependent = 1;
1760 let ParseArgumentsAsUnevaluated = 1;
1761 let DuplicatesAllowedWhileMerging = 1;
1762 let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1763 "ExpectedFieldOrGlobalVar">;
1764 let Documentation = [Undocumented];
1767 def AssertExclusiveLock : InheritableAttr {
1768 let Spellings = [GNU<"assert_exclusive_lock">];
1769 let Args = [VariadicExprArgument<"Args">];
1771 let TemplateDependent = 1;
1772 let ParseArgumentsAsUnevaluated = 1;
1773 let DuplicatesAllowedWhileMerging = 1;
1774 let Subjects = SubjectList<[Function]>;
1775 let Documentation = [Undocumented];
1778 def AssertSharedLock : InheritableAttr {
1779 let Spellings = [GNU<"assert_shared_lock">];
1780 let Args = [VariadicExprArgument<"Args">];
1782 let TemplateDependent = 1;
1783 let ParseArgumentsAsUnevaluated = 1;
1784 let DuplicatesAllowedWhileMerging = 1;
1785 let Subjects = SubjectList<[Function]>;
1786 let Documentation = [Undocumented];
1789 // The first argument is an integer or boolean value specifying the return value
1790 // of a successful lock acquisition.
1791 def ExclusiveTrylockFunction : InheritableAttr {
1792 let Spellings = [GNU<"exclusive_trylock_function">];
1793 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1795 let TemplateDependent = 1;
1796 let ParseArgumentsAsUnevaluated = 1;
1797 let DuplicatesAllowedWhileMerging = 1;
1798 let Subjects = SubjectList<[Function]>;
1799 let Documentation = [Undocumented];
1802 // The first argument is an integer or boolean value specifying the return value
1803 // of a successful lock acquisition.
1804 def SharedTrylockFunction : InheritableAttr {
1805 let Spellings = [GNU<"shared_trylock_function">];
1806 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1808 let TemplateDependent = 1;
1809 let ParseArgumentsAsUnevaluated = 1;
1810 let DuplicatesAllowedWhileMerging = 1;
1811 let Subjects = SubjectList<[Function]>;
1812 let Documentation = [Undocumented];
1815 def LockReturned : InheritableAttr {
1816 let Spellings = [GNU<"lock_returned">];
1817 let Args = [ExprArgument<"Arg">];
1819 let TemplateDependent = 1;
1820 let ParseArgumentsAsUnevaluated = 1;
1821 let Subjects = SubjectList<[Function]>;
1822 let Documentation = [Undocumented];
1825 def LocksExcluded : InheritableAttr {
1826 let Spellings = [GNU<"locks_excluded">];
1827 let Args = [VariadicExprArgument<"Args">];
1829 let TemplateDependent = 1;
1830 let ParseArgumentsAsUnevaluated = 1;
1831 let DuplicatesAllowedWhileMerging = 1;
1832 let Subjects = SubjectList<[Function]>;
1833 let Documentation = [Undocumented];
1836 // C/C++ consumed attributes.
1838 def Consumable : InheritableAttr {
1839 let Spellings = [GNU<"consumable">];
1840 let Subjects = SubjectList<[CXXRecord]>;
1841 let Args = [EnumArgument<"DefaultState", "ConsumedState",
1842 ["unknown", "consumed", "unconsumed"],
1843 ["Unknown", "Consumed", "Unconsumed"]>];
1844 let Documentation = [ConsumableDocs];
1847 def ConsumableAutoCast : InheritableAttr {
1848 let Spellings = [GNU<"consumable_auto_cast_state">];
1849 let Subjects = SubjectList<[CXXRecord]>;
1850 let Documentation = [Undocumented];
1853 def ConsumableSetOnRead : InheritableAttr {
1854 let Spellings = [GNU<"consumable_set_state_on_read">];
1855 let Subjects = SubjectList<[CXXRecord]>;
1856 let Documentation = [Undocumented];
1859 def CallableWhen : InheritableAttr {
1860 let Spellings = [GNU<"callable_when">];
1861 let Subjects = SubjectList<[CXXMethod]>;
1862 let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
1863 ["unknown", "consumed", "unconsumed"],
1864 ["Unknown", "Consumed", "Unconsumed"]>];
1865 let Documentation = [CallableWhenDocs];
1868 def ParamTypestate : InheritableAttr {
1869 let Spellings = [GNU<"param_typestate">];
1870 let Subjects = SubjectList<[ParmVar]>;
1871 let Args = [EnumArgument<"ParamState", "ConsumedState",
1872 ["unknown", "consumed", "unconsumed"],
1873 ["Unknown", "Consumed", "Unconsumed"]>];
1874 let Documentation = [ParamTypestateDocs];
1877 def ReturnTypestate : InheritableAttr {
1878 let Spellings = [GNU<"return_typestate">];
1879 let Subjects = SubjectList<[Function, ParmVar]>;
1880 let Args = [EnumArgument<"State", "ConsumedState",
1881 ["unknown", "consumed", "unconsumed"],
1882 ["Unknown", "Consumed", "Unconsumed"]>];
1883 let Documentation = [ReturnTypestateDocs];
1886 def SetTypestate : InheritableAttr {
1887 let Spellings = [GNU<"set_typestate">];
1888 let Subjects = SubjectList<[CXXMethod]>;
1889 let Args = [EnumArgument<"NewState", "ConsumedState",
1890 ["unknown", "consumed", "unconsumed"],
1891 ["Unknown", "Consumed", "Unconsumed"]>];
1892 let Documentation = [SetTypestateDocs];
1895 def TestTypestate : InheritableAttr {
1896 let Spellings = [GNU<"test_typestate">];
1897 let Subjects = SubjectList<[CXXMethod]>;
1898 let Args = [EnumArgument<"TestState", "ConsumedState",
1899 ["consumed", "unconsumed"],
1900 ["Consumed", "Unconsumed"]>];
1901 let Documentation = [TestTypestateDocs];
1904 // Type safety attributes for `void *' pointers and type tags.
1906 def ArgumentWithTypeTag : InheritableAttr {
1907 let Spellings = [GNU<"argument_with_type_tag">,
1908 GNU<"pointer_with_type_tag">];
1909 let Args = [IdentifierArgument<"ArgumentKind">,
1910 UnsignedArgument<"ArgumentIdx">,
1911 UnsignedArgument<"TypeTagIdx">,
1912 BoolArgument<"IsPointer">];
1913 let HasCustomParsing = 1;
1914 let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
1917 def TypeTagForDatatype : InheritableAttr {
1918 let Spellings = [GNU<"type_tag_for_datatype">];
1919 let Args = [IdentifierArgument<"ArgumentKind">,
1920 TypeArgument<"MatchingCType">,
1921 BoolArgument<"LayoutCompatible">,
1922 BoolArgument<"MustBeNull">];
1923 // let Subjects = SubjectList<[Var], ErrorDiag>;
1924 let HasCustomParsing = 1;
1925 let Documentation = [TypeTagForDatatypeDocs];
1928 // Microsoft-related attributes
1930 def MSNoVTable : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
1931 let Spellings = [Declspec<"novtable">];
1932 let Subjects = SubjectList<[CXXRecord]>;
1933 let Documentation = [MSNoVTableDocs];
1937 let Spellings = [Declspec<"property">];
1940 def MSStruct : InheritableAttr {
1941 let Spellings = [GCC<"ms_struct">];
1942 let Subjects = SubjectList<[Record]>;
1943 let Documentation = [Undocumented];
1946 def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
1947 let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
1948 let Subjects = SubjectList<[Function, Var, CXXRecord]>;
1949 let Documentation = [Undocumented];
1952 def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
1953 let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
1954 let Subjects = SubjectList<[Function, Var, CXXRecord]>;
1955 let Documentation = [Undocumented];
1958 def SelectAny : InheritableAttr {
1959 let Spellings = [Declspec<"selectany">];
1960 let LangOpts = [MicrosoftExt];
1961 let Documentation = [Undocumented];
1965 let Spellings = [Declspec<"thread">];
1966 let LangOpts = [MicrosoftExt];
1967 let Documentation = [ThreadDocs];
1968 let Subjects = SubjectList<[Var]>;
1971 def Win64 : IgnoredAttr {
1972 let Spellings = [Keyword<"__w64">];
1973 let LangOpts = [MicrosoftExt];
1976 def Ptr32 : TypeAttr {
1977 let Spellings = [Keyword<"__ptr32">];
1978 let Documentation = [Undocumented];
1981 def Ptr64 : TypeAttr {
1982 let Spellings = [Keyword<"__ptr64">];
1983 let Documentation = [Undocumented];
1986 def SPtr : TypeAttr {
1987 let Spellings = [Keyword<"__sptr">];
1988 let Documentation = [Undocumented];
1991 def UPtr : TypeAttr {
1992 let Spellings = [Keyword<"__uptr">];
1993 let Documentation = [Undocumented];
1996 def MSInheritance : InheritableAttr {
1997 let LangOpts = [MicrosoftExt];
1998 let Args = [DefaultBoolArgument<"BestCase", 1>];
1999 let Spellings = [Keyword<"__single_inheritance">,
2000 Keyword<"__multiple_inheritance">,
2001 Keyword<"__virtual_inheritance">,
2002 Keyword<"__unspecified_inheritance">];
2003 let AdditionalMembers = [{
2004 static bool hasVBPtrOffsetField(Spelling Inheritance) {
2005 return Inheritance == Keyword_unspecified_inheritance;
2008 // Only member pointers to functions need a this adjustment, since it can be
2009 // combined with the field offset for data pointers.
2010 static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
2011 return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
2014 static bool hasVBTableOffsetField(Spelling Inheritance) {
2015 return Inheritance >= Keyword_virtual_inheritance;
2018 static bool hasOnlyOneField(bool IsMemberFunction,
2019 Spelling Inheritance) {
2020 if (IsMemberFunction)
2021 return Inheritance <= Keyword_single_inheritance;
2022 return Inheritance <= Keyword_multiple_inheritance;
2025 let Documentation = [MSInheritanceDocs];
2028 def MSVtorDisp : InheritableAttr {
2029 // This attribute has no spellings as it is only ever created implicitly.
2031 let Args = [UnsignedArgument<"vdm">];
2032 let SemaHandler = 0;
2034 let AdditionalMembers = [{
2041 Mode getVtorDispMode() const { return Mode(vdm); }
2043 let Documentation = [Undocumented];
2046 def InitSeg : Attr {
2047 let Spellings = [Pragma<"", "init_seg">];
2048 let Args = [StringArgument<"Section">];
2049 let SemaHandler = 0;
2050 let Documentation = [InitSegDocs];
2051 let AdditionalMembers = [{
2052 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2053 OS << '(' << getSection() << ')';
2058 def Unaligned : IgnoredAttr {
2059 let Spellings = [Keyword<"__unaligned">];
2062 def LoopHint : Attr {
2063 /// #pragma clang loop <option> directive
2064 /// vectorize: vectorizes loop operations if State == Enable.
2065 /// vectorize_width: vectorize loop operations with width 'Value'.
2066 /// interleave: interleave multiple loop iterations if State == Enable.
2067 /// interleave_count: interleaves 'Value' loop interations.
2068 /// unroll: fully unroll loop if State == Enable.
2069 /// unroll_count: unrolls loop 'Value' times.
2071 /// #pragma unroll <argument> directive
2072 /// <no arg>: fully unrolls loop.
2073 /// boolean: fully unrolls loop if State == Enable.
2074 /// expression: unrolls loop 'Value' times.
2076 let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">,
2077 Pragma<"", "nounroll">];
2079 /// State of the loop optimization specified by the spelling.
2080 let Args = [EnumArgument<"Option", "OptionType",
2081 ["vectorize", "vectorize_width", "interleave", "interleave_count",
2082 "unroll", "unroll_count"],
2083 ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
2084 "Unroll", "UnrollCount"]>,
2085 EnumArgument<"State", "LoopHintState",
2086 ["enable", "disable", "numeric", "assume_safety", "full"],
2087 ["Enable", "Disable", "Numeric", "AssumeSafety", "Full"]>,
2088 ExprArgument<"Value">];
2090 let AdditionalMembers = [{
2091 static const char *getOptionName(int Option) {
2093 case Vectorize: return "vectorize";
2094 case VectorizeWidth: return "vectorize_width";
2095 case Interleave: return "interleave";
2096 case InterleaveCount: return "interleave_count";
2097 case Unroll: return "unroll";
2098 case UnrollCount: return "unroll_count";
2100 llvm_unreachable("Unhandled LoopHint option.");
2103 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
2104 unsigned SpellingIndex = getSpellingListIndex();
2105 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
2106 // "nounroll" is already emitted as the pragma name.
2107 if (SpellingIndex == Pragma_nounroll)
2109 else if (SpellingIndex == Pragma_unroll) {
2110 OS << getValueString(Policy);
2114 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2115 OS << getOptionName(option) << getValueString(Policy);
2118 // Return a string containing the loop hint argument including the
2119 // enclosing parentheses.
2120 std::string getValueString(const PrintingPolicy &Policy) const {
2121 std::string ValueName;
2122 llvm::raw_string_ostream OS(ValueName);
2124 if (state == Numeric)
2125 value->printPretty(OS, nullptr, Policy);
2126 else if (state == Enable)
2128 else if (state == Full)
2130 else if (state == AssumeSafety)
2131 OS << "assume_safety";
2138 // Return a string suitable for identifying this attribute in diagnostics.
2139 std::string getDiagnosticName(const PrintingPolicy &Policy) const {
2140 unsigned SpellingIndex = getSpellingListIndex();
2141 if (SpellingIndex == Pragma_nounroll)
2142 return "#pragma nounroll";
2143 else if (SpellingIndex == Pragma_unroll)
2144 return "#pragma unroll" + (option == UnrollCount ? getValueString(Policy) : "");
2146 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
2147 return getOptionName(option) + getValueString(Policy);
2151 let Documentation = [LoopHintDocs, UnrollHintDocs];
2154 def CapturedRecord : InheritableAttr {
2155 // This attribute has no spellings as it is only ever created implicitly.
2157 let SemaHandler = 0;
2158 let Documentation = [Undocumented];
2161 def OMPThreadPrivateDecl : InheritableAttr {
2162 // This attribute has no spellings as it is only ever created implicitly.
2164 let SemaHandler = 0;
2165 let Documentation = [Undocumented];
2168 def InternalLinkage : InheritableAttr {
2169 let Spellings = [GNU<"internal_linkage">, CXX11<"clang", "internal_linkage">];
2170 let Subjects = SubjectList<[Var, Function, CXXRecord]>;
2171 let Documentation = [InternalLinkageDocs];