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 // An attribute's subject is whatever it appertains to. In this file, it is
11 // more accurately a list of things that an attribute can appertain to. All
12 // Decls and Stmts are possibly AttrSubjects (even though the syntax may not
13 // allow attributes on a given Decl or Stmt).
16 include "clang/Basic/DeclNodes.td"
17 include "clang/Basic/StmtNodes.td"
19 // A subset-subject is an AttrSubject constrained to operate only on some subset
22 // The description is used in output messages to specify what the subject
23 // represents. FIXME: Deal with translation issues.
25 // The code fragment is a boolean expression that will confirm that the subject
26 // meets the requirements; the subject will have the name S, and will have the
27 // type specified by the base. It should be a simple boolean expression.
28 class SubsetSubject<AttrSubject base, string description, code check>
30 AttrSubject Base = base;
31 string Description = description;
32 code CheckCode = check;
35 // This is the type of a variable which C++11 allows alignas(...) to appertain
37 def NormalVar : SubsetSubject<Var, "non-register, non-parameter variable",
38 [{S->getStorageClass() != VarDecl::Register &&
39 S->getKind() != Decl::ImplicitParam &&
40 S->getKind() != Decl::ParmVar &&
41 S->getKind() != Decl::NonTypeTemplateParm}]>;
42 def NonBitField : SubsetSubject<Field, "non-bit field",
43 [{!S->isBitField()}]>;
45 // A single argument to an attribute
46 class Argument<string name, bit optional> {
48 bit Optional = optional;
51 class BoolArgument<string name, bit opt = 0> : Argument<name, opt>;
52 class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>;
53 class IntArgument<string name, bit opt = 0> : Argument<name, opt>;
54 class StringArgument<string name, bit opt = 0> : Argument<name, opt>;
55 class ExprArgument<string name, bit opt = 0> : Argument<name, opt>;
56 class FunctionArgument<string name, bit opt = 0> : Argument<name, opt>;
57 class TypeArgument<string name, bit opt = 0> : Argument<name, opt>;
58 class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>;
59 class SourceLocArgument<string name, bit opt = 0> : Argument<name, opt>;
60 class VariadicUnsignedArgument<string name> : Argument<name, 1>;
61 class VariadicExprArgument<string name> : Argument<name, 1>;
63 // A version of the form major.minor[.subminor].
64 class VersionArgument<string name, bit opt = 0> : Argument<name, opt>;
66 // This one's a doozy, so it gets its own special type
67 // It can be an unsigned integer, or a type. Either can
69 class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>;
71 // An integer argument with a default value
72 class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
73 int Default = default;
76 // This argument is more complex, it includes the enumerator type name,
77 // a list of strings to accept, and a list of enumerators to map them to.
78 class EnumArgument<string name, string type, list<string> values,
79 list<string> enums, bit opt = 0> : Argument<name, opt> {
81 list<string> Values = values;
82 list<string> Enums = enums;
85 // FIXME: There should be a VariadicArgument type that takes any other type
86 // of argument and generates the appropriate type.
87 class VariadicEnumArgument<string name, string type, list<string> values,
88 list<string> enums> : Argument<name, 1> {
90 list<string> Values = values;
91 list<string> Enums = enums;
94 // This handles one spelling of an attribute.
95 class Spelling<string name, string variety> {
97 string Variety = variety;
100 class GNU<string name> : Spelling<name, "GNU">;
101 class Declspec<string name> : Spelling<name, "Declspec">;
102 class CXX11<string namespace, string name> : Spelling<name, "CXX11"> {
103 string Namespace = namespace;
105 class Keyword<string name> : Spelling<name, "Keyword">;
107 class Accessor<string name, list<Spelling> spellings> {
109 list<Spelling> Spellings = spellings;
113 // The various ways in which an attribute can be spelled in source
114 list<Spelling> Spellings;
115 // The things to which an attribute can appertain
116 list<AttrSubject> Subjects;
117 // The arguments allowed on an attribute
118 list<Argument> Args = [];
119 // Accessors which should be generated for the attribute.
120 list<Accessor> Accessors = [];
121 // Set to true for attributes with arguments which require delayed parsing.
123 // Set to false to prevent an attribute from being propagated from a template
124 // to the instantiation.
126 // Set to true for attributes which must be instantiated within templates
127 bit TemplateDependent = 0;
128 // Set to true for attributes that have a corresponding AST node.
130 // Set to true for attributes which have handler in Sema.
132 // Set to true for attributes that are completely ignored.
134 // Set to true if each of the spellings is a distinct attribute.
135 bit DistinctSpellings = 0;
136 // Set to true if the attribute's parsing does not match its semantic
137 // content. Eg) It parses 3 args, but semantically takes 4 args. Opts out of
138 // common attribute error checking.
139 bit HasCustomParsing = 0;
140 // Any additional text that should be included verbatim in the class.
141 code AdditionalMembers = [{}];
144 /// A type attribute is not processed on a declaration or a statement.
145 class TypeAttr : Attr {
149 /// An inheritable attribute is inherited by later redeclarations.
150 class InheritableAttr : Attr;
152 /// A target-specific attribute that is meant to be processed via
153 /// TargetAttributesSema::ProcessDeclAttribute. This class is meant to be used
154 /// as a mixin with InheritableAttr or Attr depending on the attribute's needs.
155 class TargetSpecificAttr;
157 /// An inheritable parameter attribute is inherited by later
158 /// redeclarations, even when it's written on a parameter.
159 class InheritableParamAttr : InheritableAttr;
161 /// An ignored attribute, which we parse but discard with no checking.
162 class IgnoredAttr : Attr {
169 // Attributes begin here
172 def AddressSpace : TypeAttr {
173 let Spellings = [GNU<"address_space">];
174 let Args = [IntArgument<"AddressSpace">];
178 let Spellings = [GNU<"alias">, CXX11<"gnu", "alias">];
179 let Args = [StringArgument<"Aliasee">];
182 def Aligned : InheritableAttr {
183 let Spellings = [GNU<"aligned">, Declspec<"align">, CXX11<"gnu", "aligned">,
184 Keyword<"alignas">, Keyword<"_Alignas">];
185 let Subjects = [NonBitField, NormalVar, Tag];
186 let Args = [AlignedArgument<"Alignment", 1>];
187 let Accessors = [Accessor<"isGNU", [GNU<"aligned">, CXX11<"gnu","aligned">]>,
188 Accessor<"isC11", [Keyword<"_Alignas">]>,
189 Accessor<"isAlignas", [Keyword<"alignas">,
190 Keyword<"_Alignas">]>,
191 Accessor<"isDeclspec",[Declspec<"align">]>];
194 def AlignMac68k : InheritableAttr {
199 def AllocSize : InheritableAttr {
200 let Spellings = [GNU<"alloc_size">, CXX11<"gnu", "alloc_size">];
201 let Args = [VariadicUnsignedArgument<"Args">];
204 def AlwaysInline : InheritableAttr {
205 let Spellings = [GNU<"always_inline">, CXX11<"gnu", "always_inline">];
208 def TLSModel : InheritableAttr {
209 let Spellings = [GNU<"tls_model">, CXX11<"gnu", "tls_model">];
210 let Subjects = [Var];
211 let Args = [StringArgument<"Model">];
214 def AnalyzerNoReturn : InheritableAttr {
215 let Spellings = [GNU<"analyzer_noreturn">];
218 def Annotate : InheritableParamAttr {
219 let Spellings = [GNU<"annotate">];
220 let Args = [StringArgument<"Annotation">];
223 def ARMInterrupt : InheritableAttr, TargetSpecificAttr {
224 let Spellings = [GNU<"interrupt">];
225 let Args = [EnumArgument<"Interrupt", "InterruptType",
226 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
227 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
231 def AsmLabel : InheritableAttr {
233 let Args = [StringArgument<"Label">];
237 def Availability : InheritableAttr {
238 let Spellings = [GNU<"availability">];
239 let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
240 VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
241 BoolArgument<"unavailable">, StringArgument<"message">];
242 let AdditionalMembers =
243 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
244 return llvm::StringSwitch<llvm::StringRef>(Platform)
246 .Case("macosx", "OS X")
247 .Default(llvm::StringRef());
249 let HasCustomParsing = 1;
252 def Blocks : InheritableAttr {
253 let Spellings = [GNU<"blocks">];
254 let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
257 def Bounded : IgnoredAttr {
258 let Spellings = [GNU<"bounded">];
261 def CarriesDependency : InheritableParamAttr {
262 let Spellings = [GNU<"carries_dependency">, CXX11<"","carries_dependency">,
263 CXX11<"std","carries_dependency">];
264 let Subjects = [ParmVar, Function];
267 def CDecl : InheritableAttr {
268 let Spellings = [GNU<"cdecl">, CXX11<"gnu", "cdecl">, Keyword<"__cdecl">,
272 // cf_audited_transfer indicates that the given function has been
273 // audited and has been marked with the appropriate cf_consumed and
274 // cf_returns_retained attributes. It is generally applied by
275 // '#pragma clang arc_cf_code_audited' rather than explicitly.
276 def CFAuditedTransfer : InheritableAttr {
277 let Spellings = [GNU<"cf_audited_transfer">];
278 let Subjects = [Function];
281 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
282 // It indicates that the function has unknown or unautomatable
283 // transfer semantics.
284 def CFUnknownTransfer : InheritableAttr {
285 let Spellings = [GNU<"cf_unknown_transfer">];
286 let Subjects = [Function];
289 def CFReturnsRetained : InheritableAttr {
290 let Spellings = [GNU<"cf_returns_retained">];
291 let Subjects = [ObjCMethod, Function];
294 def CFReturnsNotRetained : InheritableAttr {
295 let Spellings = [GNU<"cf_returns_not_retained">];
296 let Subjects = [ObjCMethod, Function];
299 def CFConsumed : InheritableParamAttr {
300 let Spellings = [GNU<"cf_consumed">];
301 let Subjects = [ParmVar];
304 def Cleanup : InheritableAttr {
305 let Spellings = [GNU<"cleanup">, CXX11<"gnu", "cleanup">];
306 let Args = [FunctionArgument<"FunctionDecl">];
309 def Cold : InheritableAttr {
310 let Spellings = [GNU<"cold">, CXX11<"gnu", "cold">];
313 def Common : InheritableAttr {
314 let Spellings = [GNU<"common">, CXX11<"gnu", "common">];
317 def Const : InheritableAttr {
318 let Spellings = [GNU<"const">, GNU<"__const">,
319 CXX11<"gnu", "const">, CXX11<"gnu", "__const">];
322 def Constructor : InheritableAttr {
323 let Spellings = [GNU<"constructor">, CXX11<"gnu", "constructor">];
324 let Args = [IntArgument<"Priority", 1>];
327 def CUDAConstant : InheritableAttr {
328 let Spellings = [GNU<"constant">];
331 def CUDADevice : InheritableAttr {
332 let Spellings = [GNU<"device">];
335 def CUDAGlobal : InheritableAttr {
336 let Spellings = [GNU<"global">];
339 def CUDAHost : InheritableAttr {
340 let Spellings = [GNU<"host">];
343 def CUDALaunchBounds : InheritableAttr {
344 let Spellings = [GNU<"launch_bounds">];
345 let Args = [IntArgument<"MaxThreads">, DefaultIntArgument<"MinBlocks", 0>];
348 def CUDAShared : InheritableAttr {
349 let Spellings = [GNU<"shared">];
352 def C11NoReturn : InheritableAttr {
353 let Spellings = [Keyword<"_Noreturn">];
354 let Subjects = [Function];
358 def CXX11NoReturn : InheritableAttr {
359 let Spellings = [CXX11<"","noreturn">, CXX11<"std","noreturn">];
360 let Subjects = [Function];
363 def OpenCLKernel : InheritableAttr {
364 let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
367 def OpenCLImageAccess : Attr {
368 let Spellings = [GNU<"opencl_image_access">];
369 let Args = [IntArgument<"Access">];
372 def Deprecated : InheritableAttr {
373 let Spellings = [GNU<"deprecated">,
374 CXX11<"gnu", "deprecated">, CXX11<"","deprecated">];
375 let Args = [StringArgument<"Message", 1>];
378 def Destructor : InheritableAttr {
379 let Spellings = [GNU<"destructor">, CXX11<"gnu", "destructor">];
380 let Args = [IntArgument<"Priority", 1>];
383 def ExtVectorType : Attr {
384 let Spellings = [GNU<"ext_vector_type">];
385 let Args = [ExprArgument<"NumElements">];
389 def FallThrough : Attr {
390 let Spellings = [CXX11<"clang", "fallthrough">];
391 let Subjects = [NullStmt];
394 def FastCall : InheritableAttr {
395 let Spellings = [GNU<"fastcall">, CXX11<"gnu", "fastcall">,
396 Keyword<"__fastcall">, Keyword<"_fastcall">];
399 def Final : InheritableAttr {
400 let Spellings = [Keyword<"final">, Keyword<"sealed">];
401 let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
405 def MinSize : InheritableAttr {
406 let Spellings = [GNU<"minsize">];
407 let Subjects = [Function];
410 def Format : InheritableAttr {
411 let Spellings = [GNU<"format">, CXX11<"gnu", "format">];
412 let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
413 IntArgument<"FirstArg">];
416 def FormatArg : InheritableAttr {
417 let Spellings = [GNU<"format_arg">, CXX11<"gnu", "format_arg">];
418 let Args = [IntArgument<"FormatIdx">];
421 def GNUInline : InheritableAttr {
422 let Spellings = [GNU<"gnu_inline">, CXX11<"gnu", "gnu_inline">];
425 def Hot : InheritableAttr {
426 let Spellings = [GNU<"hot">, CXX11<"gnu", "hot">];
429 def IBAction : InheritableAttr {
430 let Spellings = [GNU<"ibaction">];
433 def IBOutlet : InheritableAttr {
434 let Spellings = [GNU<"iboutlet">];
437 def IBOutletCollection : InheritableAttr {
438 let Spellings = [GNU<"iboutletcollection">];
439 let Args = [TypeArgument<"Interface", 1>];
442 def Malloc : InheritableAttr {
443 let Spellings = [GNU<"malloc">, CXX11<"gnu", "malloc">];
446 def MaxFieldAlignment : InheritableAttr {
448 let Args = [UnsignedArgument<"Alignment">];
452 def MayAlias : InheritableAttr {
453 let Spellings = [GNU<"may_alias">, CXX11<"gnu", "may_alias">];
456 def MSABI : InheritableAttr {
457 let Spellings = [GNU<"ms_abi">, CXX11<"gnu", "ms_abi">];
460 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr {
462 let Args = [UnsignedArgument<"Number">];
466 def Mips16 : InheritableAttr, TargetSpecificAttr {
467 let Spellings = [GNU<"mips16">, CXX11<"gnu", "mips16">];
468 let Subjects = [Function];
472 let Spellings = [GNU<"mode">, CXX11<"gnu", "mode">];
473 let Args = [IdentifierArgument<"Mode">];
476 def Naked : InheritableAttr {
477 let Spellings = [GNU<"naked">, CXX11<"gnu", "naked">];
480 def NeonPolyVectorType : TypeAttr {
481 let Spellings = [GNU<"neon_polyvector_type">];
482 let Args = [IntArgument<"NumElements">];
485 def NeonVectorType : TypeAttr {
486 let Spellings = [GNU<"neon_vector_type">];
487 let Args = [IntArgument<"NumElements">];
490 def ReturnsTwice : InheritableAttr {
491 let Spellings = [GNU<"returns_twice">, CXX11<"gnu", "returns_twice">];
494 def NoCommon : InheritableAttr {
495 let Spellings = [GNU<"nocommon">, CXX11<"gnu", "nocommon">];
498 def NoDebug : InheritableAttr {
499 let Spellings = [GNU<"nodebug">];
502 def NoInline : InheritableAttr {
503 let Spellings = [GNU<"noinline">, CXX11<"gnu", "noinline">];
506 def NoMips16 : InheritableAttr, TargetSpecificAttr {
507 let Spellings = [GNU<"nomips16">, CXX11<"gnu", "nomips16">];
508 let Subjects = [Function];
511 def NonNull : InheritableAttr {
512 let Spellings = [GNU<"nonnull">, CXX11<"gnu", "nonnull">];
513 let Args = [VariadicUnsignedArgument<"Args">];
514 let AdditionalMembers =
515 [{bool isNonNull(unsigned idx) const {
516 for (args_iterator i = args_begin(), e = args_end();
524 def NoReturn : InheritableAttr {
525 let Spellings = [GNU<"noreturn">, CXX11<"gnu", "noreturn">];
526 // FIXME: Does GCC allow this on the function instead?
527 let Subjects = [Function];
530 def NoInstrumentFunction : InheritableAttr {
531 let Spellings = [GNU<"no_instrument_function">,
532 CXX11<"gnu", "no_instrument_function">];
533 let Subjects = [Function];
536 def NoThrow : InheritableAttr {
537 let Spellings = [GNU<"nothrow">, CXX11<"gnu", "nothrow">];
540 def NSBridged : InheritableAttr {
541 let Spellings = [GNU<"ns_bridged">];
542 let Subjects = [Record];
543 let Args = [IdentifierArgument<"BridgedType", 1>];
546 def ObjCBridge : InheritableAttr {
547 let Spellings = [GNU<"objc_bridge">];
548 let Subjects = [Record];
549 let Args = [IdentifierArgument<"BridgedType", 1>];
552 def NSReturnsRetained : InheritableAttr {
553 let Spellings = [GNU<"ns_returns_retained">];
554 let Subjects = [ObjCMethod, Function];
557 def NSReturnsNotRetained : InheritableAttr {
558 let Spellings = [GNU<"ns_returns_not_retained">];
559 let Subjects = [ObjCMethod, Function];
562 def NSReturnsAutoreleased : InheritableAttr {
563 let Spellings = [GNU<"ns_returns_autoreleased">];
564 let Subjects = [ObjCMethod, Function];
567 def NSConsumesSelf : InheritableAttr {
568 let Spellings = [GNU<"ns_consumes_self">];
569 let Subjects = [ObjCMethod];
572 def NSConsumed : InheritableParamAttr {
573 let Spellings = [GNU<"ns_consumed">];
574 let Subjects = [ParmVar];
577 def ObjCException : InheritableAttr {
578 let Spellings = [GNU<"objc_exception">];
581 def ObjCMethodFamily : InheritableAttr {
582 let Spellings = [GNU<"objc_method_family">];
583 let Subjects = [ObjCMethod];
584 let Args = [EnumArgument<"Family", "FamilyKind",
585 ["none", "alloc", "copy", "init", "mutableCopy", "new"],
586 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
587 "OMF_mutableCopy", "OMF_new"]>];
590 def ObjCNSObject : InheritableAttr {
591 let Spellings = [GNU<"NSObject">];
594 def ObjCPreciseLifetime : InheritableAttr {
595 let Spellings = [GNU<"objc_precise_lifetime">];
596 let Subjects = [Var];
599 def ObjCReturnsInnerPointer : InheritableAttr {
600 let Spellings = [GNU<"objc_returns_inner_pointer">];
601 let Subjects = [ObjCMethod, ObjCProperty];
604 def ObjCRequiresSuper : InheritableAttr {
605 let Spellings = [GNU<"objc_requires_super">];
606 let Subjects = [ObjCMethod];
609 def ObjCRootClass : InheritableAttr {
610 let Spellings = [GNU<"objc_root_class">];
611 let Subjects = [ObjCInterface];
614 def Overloadable : Attr {
615 let Spellings = [GNU<"overloadable">];
618 def Override : InheritableAttr {
623 def Ownership : InheritableAttr {
624 let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
625 GNU<"ownership_takes">];
626 let DistinctSpellings = 1;
627 let Args = [EnumArgument<"OwnKind", "OwnershipKind",
628 ["ownership_holds", "ownership_returns", "ownership_takes"],
629 ["Holds", "Returns", "Takes"]>,
630 StringArgument<"Module">, VariadicUnsignedArgument<"Args">];
631 let HasCustomParsing = 1;
634 def Packed : InheritableAttr {
635 let Spellings = [GNU<"packed">, CXX11<"gnu", "packed">];
638 def PnaclCall : InheritableAttr {
639 let Spellings = [GNU<"pnaclcall">];
642 def IntelOclBicc : InheritableAttr {
643 let Spellings = [GNU<"intel_ocl_bicc">];
646 def Pcs : InheritableAttr {
647 let Spellings = [GNU<"pcs">, CXX11<"gnu", "pcs">];
648 let Args = [EnumArgument<"PCS", "PCSType",
649 ["aapcs", "aapcs-vfp"],
650 ["AAPCS", "AAPCS_VFP"]>];
653 def Pure : InheritableAttr {
654 let Spellings = [GNU<"pure">, CXX11<"gnu", "pure">];
657 def Regparm : InheritableAttr {
658 let Spellings = [GNU<"regparm">, CXX11<"gnu", "regparm">];
659 let Args = [UnsignedArgument<"NumParams">];
662 def ReqdWorkGroupSize : InheritableAttr {
663 let Spellings = [GNU<"reqd_work_group_size">];
664 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
665 UnsignedArgument<"ZDim">];
668 def WorkGroupSizeHint : InheritableAttr {
669 let Spellings = [GNU<"work_group_size_hint">];
670 let Args = [UnsignedArgument<"XDim">,
671 UnsignedArgument<"YDim">,
672 UnsignedArgument<"ZDim">];
675 def InitPriority : InheritableAttr {
676 let Spellings = [GNU<"init_priority">];
677 let Args = [UnsignedArgument<"Priority">];
680 def Section : InheritableAttr {
681 let Spellings = [GNU<"section">, CXX11<"gnu", "section">];
682 let Args = [StringArgument<"Name">];
685 def Sentinel : InheritableAttr {
686 let Spellings = [GNU<"sentinel">, CXX11<"gnu", "sentinel">];
687 let Args = [DefaultIntArgument<"Sentinel", 0>,
688 DefaultIntArgument<"NullPos", 0>];
691 def StdCall : InheritableAttr {
692 let Spellings = [GNU<"stdcall">, CXX11<"gnu", "stdcall">,
693 Keyword<"__stdcall">, Keyword<"_stdcall">];
696 def SysVABI : InheritableAttr {
697 let Spellings = [GNU<"sysv_abi">, CXX11<"gnu", "sysv_abi">];
700 def ThisCall : InheritableAttr {
701 let Spellings = [GNU<"thiscall">, CXX11<"gnu", "thiscall">,
702 Keyword<"__thiscall">, Keyword<"_thiscall">];
705 def Pascal : InheritableAttr {
706 let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
709 def TransparentUnion : InheritableAttr {
710 let Spellings = [GNU<"transparent_union">, CXX11<"gnu", "transparent_union">];
713 def Unavailable : InheritableAttr {
714 let Spellings = [GNU<"unavailable">];
715 let Args = [StringArgument<"Message", 1>];
718 def ArcWeakrefUnavailable : InheritableAttr {
719 let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
720 let Subjects = [ObjCInterface];
723 def ObjCGC : TypeAttr {
724 let Spellings = [GNU<"objc_gc">];
725 let Args = [IdentifierArgument<"Kind">];
728 def ObjCOwnership : InheritableAttr {
729 let Spellings = [GNU<"objc_ownership">];
730 let Args = [IdentifierArgument<"Kind">];
734 def ObjCRequiresPropertyDefs : InheritableAttr {
735 let Spellings = [GNU<"objc_requires_property_definitions">];
736 let Subjects = [ObjCInterface];
739 def Unused : InheritableAttr {
740 let Spellings = [GNU<"unused">, CXX11<"gnu", "unused">];
743 def Used : InheritableAttr {
744 let Spellings = [GNU<"used">, CXX11<"gnu", "used">];
747 def Uuid : InheritableAttr {
748 let Spellings = [GNU<"uuid">];
749 let Args = [StringArgument<"Guid">];
750 let Subjects = [CXXRecord];
753 def VectorSize : TypeAttr {
754 let Spellings = [GNU<"vector_size">, CXX11<"gnu", "vector_size">];
755 let Args = [ExprArgument<"NumBytes">];
758 def VecTypeHint : InheritableAttr {
759 let Spellings = [GNU<"vec_type_hint">];
760 let Args = [TypeArgument<"TypeHint">];
763 def Visibility : InheritableAttr {
765 let Spellings = [GNU<"visibility">, CXX11<"gnu", "visibility">];
766 let Args = [EnumArgument<"Visibility", "VisibilityType",
767 ["default", "hidden", "internal", "protected"],
768 ["Default", "Hidden", "Hidden", "Protected"]>];
771 def TypeVisibility : InheritableAttr {
773 let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">];
774 let Args = [EnumArgument<"Visibility", "VisibilityType",
775 ["default", "hidden", "internal", "protected"],
776 ["Default", "Hidden", "Hidden", "Protected"]>];
779 def VecReturn : InheritableAttr {
780 let Spellings = [GNU<"vecreturn">];
781 let Subjects = [CXXRecord];
784 def WarnUnused : InheritableAttr {
785 let Spellings = [GNU<"warn_unused">];
786 let Subjects = [Record];
789 def WarnUnusedResult : InheritableAttr {
790 let Spellings = [GNU<"warn_unused_result">,
791 CXX11<"clang", "warn_unused_result">,
792 CXX11<"gnu", "warn_unused_result">];
795 def Weak : InheritableAttr {
796 let Spellings = [GNU<"weak">, CXX11<"gnu", "weak">];
799 def WeakImport : InheritableAttr {
800 let Spellings = [GNU<"weak_import">];
803 def WeakRef : InheritableAttr {
804 let Spellings = [GNU<"weakref">, CXX11<"gnu", "weakref">];
805 // A WeakRef that has an argument is treated as being an AliasAttr
806 let Args = [StringArgument<"Aliasee", 1>];
809 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr {
813 // Attribute to disable AddressSanitizer (or equivalent) checks.
814 def NoSanitizeAddress : InheritableAttr {
815 let Spellings = [GNU<"no_address_safety_analysis">,
816 GNU<"no_sanitize_address">,
817 CXX11<"gnu", "no_address_safety_analysis">,
818 CXX11<"gnu", "no_sanitize_address">];
821 // Attribute to disable ThreadSanitizer checks.
822 def NoSanitizeThread : InheritableAttr {
823 let Spellings = [GNU<"no_sanitize_thread">];
826 // Attribute to disable MemorySanitizer checks.
827 def NoSanitizeMemory : InheritableAttr {
828 let Spellings = [GNU<"no_sanitize_memory">];
831 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
833 def GuardedVar : InheritableAttr {
834 let Spellings = [GNU<"guarded_var">];
837 def PtGuardedVar : InheritableAttr {
838 let Spellings = [GNU<"pt_guarded_var">];
841 def Lockable : InheritableAttr {
842 let Spellings = [GNU<"lockable">];
845 def ScopedLockable : InheritableAttr {
846 let Spellings = [GNU<"scoped_lockable">];
849 def NoThreadSafetyAnalysis : InheritableAttr {
850 let Spellings = [GNU<"no_thread_safety_analysis">];
853 def GuardedBy : InheritableAttr {
854 let Spellings = [GNU<"guarded_by">];
855 let Args = [ExprArgument<"Arg">];
857 let TemplateDependent = 1;
860 def PtGuardedBy : InheritableAttr {
861 let Spellings = [GNU<"pt_guarded_by">];
862 let Args = [ExprArgument<"Arg">];
864 let TemplateDependent = 1;
867 def AcquiredAfter : InheritableAttr {
868 let Spellings = [GNU<"acquired_after">];
869 let Args = [VariadicExprArgument<"Args">];
871 let TemplateDependent = 1;
874 def AcquiredBefore : InheritableAttr {
875 let Spellings = [GNU<"acquired_before">];
876 let Args = [VariadicExprArgument<"Args">];
878 let TemplateDependent = 1;
881 def ExclusiveLockFunction : InheritableAttr {
882 let Spellings = [GNU<"exclusive_lock_function">];
883 let Args = [VariadicExprArgument<"Args">];
885 let TemplateDependent = 1;
888 def SharedLockFunction : InheritableAttr {
889 let Spellings = [GNU<"shared_lock_function">];
890 let Args = [VariadicExprArgument<"Args">];
892 let TemplateDependent = 1;
895 def AssertExclusiveLock : InheritableAttr {
896 let Spellings = [GNU<"assert_exclusive_lock">];
897 let Args = [VariadicExprArgument<"Args">];
899 let TemplateDependent = 1;
902 def AssertSharedLock : InheritableAttr {
903 let Spellings = [GNU<"assert_shared_lock">];
904 let Args = [VariadicExprArgument<"Args">];
906 let TemplateDependent = 1;
909 // The first argument is an integer or boolean value specifying the return value
910 // of a successful lock acquisition.
911 def ExclusiveTrylockFunction : InheritableAttr {
912 let Spellings = [GNU<"exclusive_trylock_function">];
913 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
915 let TemplateDependent = 1;
918 // The first argument is an integer or boolean value specifying the return value
919 // of a successful lock acquisition.
920 def SharedTrylockFunction : InheritableAttr {
921 let Spellings = [GNU<"shared_trylock_function">];
922 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
924 let TemplateDependent = 1;
927 def UnlockFunction : InheritableAttr {
928 let Spellings = [GNU<"unlock_function">];
929 let Args = [VariadicExprArgument<"Args">];
931 let TemplateDependent = 1;
934 def LockReturned : InheritableAttr {
935 let Spellings = [GNU<"lock_returned">];
936 let Args = [ExprArgument<"Arg">];
938 let TemplateDependent = 1;
941 def LocksExcluded : InheritableAttr {
942 let Spellings = [GNU<"locks_excluded">];
943 let Args = [VariadicExprArgument<"Args">];
945 let TemplateDependent = 1;
948 def ExclusiveLocksRequired : InheritableAttr {
949 let Spellings = [GNU<"exclusive_locks_required">];
950 let Args = [VariadicExprArgument<"Args">];
952 let TemplateDependent = 1;
955 def SharedLocksRequired : InheritableAttr {
956 let Spellings = [GNU<"shared_locks_required">];
957 let Args = [VariadicExprArgument<"Args">];
959 let TemplateDependent = 1;
962 // C/C++ consumed attributes.
964 def Consumable : InheritableAttr {
965 let Spellings = [GNU<"consumable">];
966 let Subjects = [CXXRecord];
967 let Args = [EnumArgument<"DefaultState", "ConsumedState",
968 ["unknown", "consumed", "unconsumed"],
969 ["Unknown", "Consumed", "Unconsumed"]>];
972 def CallableWhen : InheritableAttr {
973 let Spellings = [GNU<"callable_when">];
974 let Subjects = [CXXMethod];
975 let Args = [VariadicEnumArgument<"CallableState", "ConsumedState",
976 ["unknown", "consumed", "unconsumed"],
977 ["Unknown", "Consumed", "Unconsumed"]>];
980 def ParamTypestate : InheritableAttr {
981 let Spellings = [GNU<"param_typestate">];
982 let Subjects = [ParmVar];
983 let Args = [EnumArgument<"ParamState", "ConsumedState",
984 ["unknown", "consumed", "unconsumed"],
985 ["Unknown", "Consumed", "Unconsumed"]>];
988 def ReturnTypestate : InheritableAttr {
989 let Spellings = [GNU<"return_typestate">];
990 let Subjects = [Function, ParmVar];
991 let Args = [EnumArgument<"State", "ConsumedState",
992 ["unknown", "consumed", "unconsumed"],
993 ["Unknown", "Consumed", "Unconsumed"]>];
996 def SetTypestate : InheritableAttr {
997 let Spellings = [GNU<"set_typestate">];
998 let Subjects = [CXXMethod];
999 let Args = [EnumArgument<"NewState", "ConsumedState",
1000 ["unknown", "consumed", "unconsumed"],
1001 ["Unknown", "Consumed", "Unconsumed"]>];
1004 def TestTypestate : InheritableAttr {
1005 let Spellings = [GNU<"test_typestate">];
1006 let Subjects = [CXXMethod];
1007 let Args = [EnumArgument<"TestState", "ConsumedState",
1008 ["consumed", "unconsumed"],
1009 ["Consumed", "Unconsumed"]>];
1012 // Type safety attributes for `void *' pointers and type tags.
1014 def ArgumentWithTypeTag : InheritableAttr {
1015 let Spellings = [GNU<"argument_with_type_tag">,
1016 GNU<"pointer_with_type_tag">];
1017 let Args = [IdentifierArgument<"ArgumentKind">,
1018 UnsignedArgument<"ArgumentIdx">,
1019 UnsignedArgument<"TypeTagIdx">,
1020 BoolArgument<"IsPointer">];
1021 let Subjects = [Function];
1022 let HasCustomParsing = 1;
1025 def TypeTagForDatatype : InheritableAttr {
1026 let Spellings = [GNU<"type_tag_for_datatype">];
1027 let Args = [IdentifierArgument<"ArgumentKind">,
1028 TypeArgument<"MatchingCType">,
1029 BoolArgument<"LayoutCompatible">,
1030 BoolArgument<"MustBeNull">];
1031 let Subjects = [Var];
1032 let HasCustomParsing = 1;
1035 // Microsoft-related attributes
1037 def MsProperty : IgnoredAttr {
1038 let Spellings = [Declspec<"property">];
1041 def MsStruct : InheritableAttr {
1042 let Spellings = [Declspec<"ms_struct">];
1045 def DLLExport : InheritableAttr, TargetSpecificAttr {
1046 let Spellings = [Declspec<"dllexport">];
1049 def DLLImport : InheritableAttr, TargetSpecificAttr {
1050 let Spellings = [Declspec<"dllimport">];
1053 def ForceInline : InheritableAttr {
1054 let Spellings = [Keyword<"__forceinline">];
1057 def SelectAny : InheritableAttr {
1058 let Spellings = [Declspec<"selectany">];
1061 def Win64 : InheritableAttr {
1062 let Spellings = [Keyword<"__w64">];
1065 def Ptr32 : TypeAttr {
1066 let Spellings = [Keyword<"__ptr32">];
1069 def Ptr64 : TypeAttr {
1070 let Spellings = [Keyword<"__ptr64">];
1073 def SPtr : TypeAttr {
1074 let Spellings = [Keyword<"__sptr">];
1077 def UPtr : TypeAttr {
1078 let Spellings = [Keyword<"__uptr">];
1081 class MSInheritanceAttr : InheritableAttr;
1083 def SingleInheritance : MSInheritanceAttr {
1084 let Spellings = [Keyword<"__single_inheritance">];
1087 def MultipleInheritance : MSInheritanceAttr {
1088 let Spellings = [Keyword<"__multiple_inheritance">];
1091 def VirtualInheritance : MSInheritanceAttr {
1092 let Spellings = [Keyword<"__virtual_inheritance">];
1095 // This attribute doesn't have any spellings, but we can apply it implicitly to
1096 // incomplete types that lack any of the other attributes.
1097 def UnspecifiedInheritance : MSInheritanceAttr {
1101 def Unaligned : IgnoredAttr {
1102 let Spellings = [Keyword<"__unaligned">];