1 ////////////////////////////////////////////////////////////////////////////////
2 // Note: This file is a work in progress. Please do not apply non-trivial
3 // updates unless you have talked to Sean Hunt <rideau3@gmail.com> prior.
4 // Merely adding a new attribute is a trivial update.
5 ////////////////////////////////////////////////////////////////////////////////
7 // An attribute's subject is whatever it appertains to. In this file, it is
8 // more accurately a list of things that an attribute can appertain to. All
9 // Decls and Stmts are possibly AttrSubjects (even though the syntax may not
10 // allow attributes on a given Decl or Stmt).
13 include "clang/Basic/DeclNodes.td"
14 include "clang/Basic/StmtNodes.td"
16 // A subset-subject is an AttrSubject constrained to operate only on some subset
19 // The description is used in output messages to specify what the subject
20 // represents. FIXME: Deal with translation issues.
22 // The code fragment is a boolean expression that will confirm that the subject
23 // meets the requirements; the subject will have the name S, and will have the
24 // type specified by the base. It should be a simple boolean expression.
25 class SubsetSubject<AttrSubject base, string description, code check>
27 AttrSubject Base = base;
28 string Description = description;
29 code CheckCode = check;
32 // This is the type of a variable which C++11 allows alignas(...) to appertain
34 def NormalVar : SubsetSubject<Var, "non-register, non-parameter variable",
35 [{S->getStorageClass() != VarDecl::Register &&
36 S->getKind() != Decl::ImplicitParam &&
37 S->getKind() != Decl::ParmVar &&
38 S->getKind() != Decl::NonTypeTemplateParm}]>;
39 def CXXVirtualMethod : SubsetSubject<CXXRecord, "virtual member function",
41 def NonBitField : SubsetSubject<Field, "non-bit field",
42 [{!S->isBitField()}]>;
44 // A single argument to an attribute
45 class Argument<string name> {
49 class BoolArgument<string name> : Argument<name>;
50 class IdentifierArgument<string name> : Argument<name>;
51 class IntArgument<string name> : Argument<name>;
52 class StringArgument<string name> : Argument<name>;
53 class ExprArgument<string name> : Argument<name>;
54 class FunctionArgument<string name> : Argument<name>;
55 class TypeArgument<string name> : Argument<name>;
56 class UnsignedArgument<string name> : Argument<name>;
57 class SourceLocArgument<string name> : Argument<name>;
58 class VariadicUnsignedArgument<string name> : Argument<name>;
59 class VariadicExprArgument<string name> : Argument<name>;
61 // A version of the form major.minor[.subminor].
62 class VersionArgument<string name> : Argument<name>;
64 // This one's a doozy, so it gets its own special type
65 // It can be an unsigned integer, or a type. Either can
67 class AlignedArgument<string name> : Argument<name>;
69 // An integer argument with a default value
70 class DefaultIntArgument<string name, int default> : IntArgument<name> {
71 int Default = default;
74 // This argument is more complex, it includes the enumerator type name,
75 // a list of strings to accept, and a list of enumerators to map them to.
76 class EnumArgument<string name, string type, list<string> values,
77 list<string> enums> : Argument<name> {
79 list<string> Values = values;
80 list<string> Enums = enums;
83 // This handles one spelling of an attribute.
84 class Spelling<string name, string variety> {
86 string Variety = variety;
89 class GNU<string name> : Spelling<name, "GNU">;
90 class Declspec<string name> : Spelling<name, "Declspec">;
91 class CXX11<string namespace, string name> : Spelling<name, "CXX11"> {
92 string Namespace = namespace;
94 class Keyword<string name> : Spelling<name, "Keyword">;
96 class Accessor<string name, list<Spelling> spellings> {
98 list<Spelling> Spellings = spellings;
102 // The various ways in which an attribute can be spelled in source
103 list<Spelling> Spellings;
104 // The things to which an attribute can appertain
105 list<AttrSubject> Subjects;
106 // The arguments allowed on an attribute
107 list<Argument> Args = [];
108 // Accessors which should be generated for the attribute.
109 list<Accessor> Accessors = [];
110 // Set to true for attributes with arguments which require delayed parsing.
112 // Set to false to prevent an attribute from being propagated from a template
113 // to the instantiation.
115 // Set to true for attributes which must be instantiated within templates
116 bit TemplateDependent = 0;
117 // Set to true for attributes that have a corresponding AST node.
119 // Set to true for attributes which have handler in Sema.
121 // Set to true for attributes that are completely ignored.
123 // Set to true if each of the spellings is a distinct attribute.
124 bit DistinctSpellings = 0;
125 // Any additional text that should be included verbatim in the class.
126 code AdditionalMembers = [{}];
129 /// An inheritable attribute is inherited by later redeclarations.
130 class InheritableAttr : Attr;
132 /// An inheritable parameter attribute is inherited by later
133 /// redeclarations, even when it's written on a parameter.
134 class InheritableParamAttr : InheritableAttr;
136 /// An ignored attribute, which we parse but discard with no checking.
137 class IgnoredAttr : Attr {
144 // Attributes begin here
147 def AddressSpace : Attr {
148 let Spellings = [GNU<"address_space">];
149 let Args = [IntArgument<"AddressSpace">];
153 def Alias : InheritableAttr {
154 let Spellings = [GNU<"alias">, CXX11<"gnu", "alias">];
155 let Args = [StringArgument<"Aliasee">];
158 def Aligned : InheritableAttr {
159 let Spellings = [GNU<"aligned">, Declspec<"align">, CXX11<"gnu", "aligned">,
160 Keyword<"alignas">, Keyword<"_Alignas">];
161 let Subjects = [NonBitField, NormalVar, Tag];
162 let Args = [AlignedArgument<"Alignment">];
163 let Accessors = [Accessor<"isGNU", [GNU<"aligned">, CXX11<"gnu","aligned">]>,
164 Accessor<"isC11", [Keyword<"_Alignas">]>,
165 Accessor<"isAlignas", [Keyword<"alignas">,
166 Keyword<"_Alignas">]>,
167 Accessor<"isDeclspec",[Declspec<"align">]>];
170 def AlignMac68k : InheritableAttr {
175 def AllocSize : Attr {
176 let Spellings = [GNU<"alloc_size">, CXX11<"gnu", "alloc_size">];
177 let Args = [VariadicUnsignedArgument<"Args">];
180 def AlwaysInline : InheritableAttr {
181 let Spellings = [GNU<"always_inline">, CXX11<"gnu", "always_inline">];
184 def TLSModel : InheritableAttr {
185 let Spellings = [GNU<"tls_model">, CXX11<"gnu", "tls_model">];
186 let Subjects = [Var];
187 let Args = [StringArgument<"Model">];
190 def AnalyzerNoReturn : InheritableAttr {
191 let Spellings = [GNU<"analyzer_noreturn">];
194 def Annotate : InheritableParamAttr {
195 let Spellings = [GNU<"annotate">];
196 let Args = [StringArgument<"Annotation">];
199 def AsmLabel : InheritableAttr {
201 let Args = [StringArgument<"Label">];
205 def Availability : InheritableAttr {
206 let Spellings = [GNU<"availability">];
207 let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
208 VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
209 BoolArgument<"unavailable">, StringArgument<"message">];
210 let AdditionalMembers =
211 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
212 return llvm::StringSwitch<llvm::StringRef>(Platform)
214 .Case("macosx", "OS X")
215 .Default(llvm::StringRef());
219 def Blocks : InheritableAttr {
220 let Spellings = [GNU<"blocks">];
221 let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
224 def Bounded : IgnoredAttr {
225 let Spellings = [GNU<"bounded">];
228 def CarriesDependency : InheritableParamAttr {
229 let Spellings = [GNU<"carries_dependency">, CXX11<"","carries_dependency">,
230 CXX11<"std","carries_dependency">];
231 let Subjects = [ParmVar, Function];
234 def CDecl : InheritableAttr {
235 let Spellings = [GNU<"cdecl">, CXX11<"gnu", "cdecl">, Keyword<"__cdecl">,
239 // cf_audited_transfer indicates that the given function has been
240 // audited and has been marked with the appropriate cf_consumed and
241 // cf_returns_retained attributes. It is generally applied by
242 // '#pragma clang arc_cf_code_audited' rather than explicitly.
243 def CFAuditedTransfer : InheritableAttr {
244 let Spellings = [GNU<"cf_audited_transfer">];
245 let Subjects = [Function];
248 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
249 // It indicates that the function has unknown or unautomatable
250 // transfer semantics.
251 def CFUnknownTransfer : InheritableAttr {
252 let Spellings = [GNU<"cf_unknown_transfer">];
253 let Subjects = [Function];
256 def CFReturnsRetained : InheritableAttr {
257 let Spellings = [GNU<"cf_returns_retained">];
258 let Subjects = [ObjCMethod, Function];
261 def CFReturnsNotRetained : InheritableAttr {
262 let Spellings = [GNU<"cf_returns_not_retained">];
263 let Subjects = [ObjCMethod, Function];
266 def CFConsumed : InheritableParamAttr {
267 let Spellings = [GNU<"cf_consumed">];
268 let Subjects = [ParmVar];
271 def Cleanup : InheritableAttr {
272 let Spellings = [GNU<"cleanup">, CXX11<"gnu", "cleanup">];
273 let Args = [FunctionArgument<"FunctionDecl">];
276 def Cold : InheritableAttr {
277 let Spellings = [GNU<"cold">, CXX11<"gnu", "cold">];
280 def Common : InheritableAttr {
281 let Spellings = [GNU<"common">, CXX11<"gnu", "common">];
284 def Const : InheritableAttr {
285 let Spellings = [GNU<"const">, GNU<"__const">, CXX11<"gnu", "const">];
288 def Constructor : InheritableAttr {
289 let Spellings = [GNU<"constructor">, CXX11<"gnu", "constructor">];
290 let Args = [IntArgument<"Priority">];
293 def CUDAConstant : InheritableAttr {
294 let Spellings = [GNU<"constant">];
297 def CUDADevice : InheritableAttr {
298 let Spellings = [GNU<"device">];
301 def CUDAGlobal : InheritableAttr {
302 let Spellings = [GNU<"global">];
305 def CUDAHost : InheritableAttr {
306 let Spellings = [GNU<"host">];
309 def CUDALaunchBounds : InheritableAttr {
310 let Spellings = [GNU<"launch_bounds">];
311 let Args = [IntArgument<"MaxThreads">, DefaultIntArgument<"MinBlocks", 0>];
314 def CUDAShared : InheritableAttr {
315 let Spellings = [GNU<"shared">];
318 def C11NoReturn : InheritableAttr {
319 let Spellings = [Keyword<"_Noreturn">];
320 let Subjects = [Function];
324 def CXX11NoReturn : InheritableAttr {
325 let Spellings = [CXX11<"","noreturn">, CXX11<"std","noreturn">];
326 let Subjects = [Function];
329 def OpenCLKernel : Attr {
330 let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
333 def OpenCLImageAccess : Attr {
334 let Spellings = [GNU<"opencl_image_access">];
335 let Args = [IntArgument<"Access">];
338 def Deprecated : InheritableAttr {
339 let Spellings = [GNU<"deprecated">, CXX11<"gnu", "deprecated">];
340 let Args = [StringArgument<"Message">];
343 def Destructor : InheritableAttr {
344 let Spellings = [GNU<"destructor">, CXX11<"gnu", "destructor">];
345 let Args = [IntArgument<"Priority">];
348 def ExtVectorType : Attr {
349 let Spellings = [GNU<"ext_vector_type">];
350 let Args = [ExprArgument<"NumElements">];
354 def FallThrough : Attr {
355 let Spellings = [CXX11<"clang", "fallthrough">];
356 let Subjects = [NullStmt];
359 def FastCall : InheritableAttr {
360 let Spellings = [GNU<"fastcall">, CXX11<"gnu", "fastcall">,
361 Keyword<"__fastcall">, Keyword<"_fastcall">];
364 def Final : InheritableAttr {
369 def MinSize : InheritableAttr {
370 let Spellings = [GNU<"minsize">];
371 let Subjects = [Function];
374 def Format : InheritableAttr {
375 let Spellings = [GNU<"format">, CXX11<"gnu", "format">];
376 let Args = [StringArgument<"Type">, IntArgument<"FormatIdx">,
377 IntArgument<"FirstArg">];
380 def FormatArg : InheritableAttr {
381 let Spellings = [GNU<"format_arg">, CXX11<"gnu", "format_arg">];
382 let Args = [IntArgument<"FormatIdx">];
385 def GNUInline : InheritableAttr {
386 let Spellings = [GNU<"gnu_inline">, CXX11<"gnu", "gnu_inline">];
389 def Hot : InheritableAttr {
390 let Spellings = [GNU<"hot">, CXX11<"gnu", "hot">];
393 def IBAction : InheritableAttr {
394 let Spellings = [GNU<"ibaction">];
397 def IBOutlet : InheritableAttr {
398 let Spellings = [GNU<"iboutlet">];
401 def IBOutletCollection : InheritableAttr {
402 let Spellings = [GNU<"iboutletcollection">];
403 let Args = [TypeArgument<"Interface">, SourceLocArgument<"InterfaceLoc">];
406 def Malloc : InheritableAttr {
407 let Spellings = [GNU<"malloc">, CXX11<"gnu", "malloc">];
410 def MaxFieldAlignment : InheritableAttr {
412 let Args = [UnsignedArgument<"Alignment">];
416 def MayAlias : InheritableAttr {
417 let Spellings = [GNU<"may_alias">, CXX11<"gnu", "may_alias">];
420 def MSP430Interrupt : InheritableAttr {
422 let Args = [UnsignedArgument<"Number">];
426 def MBlazeInterruptHandler : InheritableAttr {
431 def MBlazeSaveVolatiles : InheritableAttr {
436 def Mips16 : InheritableAttr {
437 let Spellings = [GNU<"mips16">, CXX11<"gnu", "mips16">];
438 let Subjects = [Function];
442 let Spellings = [GNU<"mode">, CXX11<"gnu", "mode">];
443 let Args = [IdentifierArgument<"Mode">];
447 def Naked : InheritableAttr {
448 let Spellings = [GNU<"naked">, CXX11<"gnu", "naked">];
451 def NeonPolyVectorType : Attr {
452 let Spellings = [GNU<"neon_polyvector_type">];
453 let Args = [IntArgument<"NumElements">];
457 def NeonVectorType : Attr {
458 let Spellings = [GNU<"neon_vector_type">];
459 let Args = [IntArgument<"NumElements">];
463 def ReturnsTwice : InheritableAttr {
464 let Spellings = [GNU<"returns_twice">, CXX11<"gnu", "returns_twice">];
467 def NoCommon : InheritableAttr {
468 let Spellings = [GNU<"nocommon">, CXX11<"gnu", "nocommon">];
471 def NoDebug : InheritableAttr {
472 let Spellings = [GNU<"nodebug">];
475 def NoInline : InheritableAttr {
476 let Spellings = [GNU<"noinline">, CXX11<"gnu", "noinline">];
479 def NoMips16 : InheritableAttr {
480 let Spellings = [GNU<"nomips16">, CXX11<"gnu", "nomips16">];
481 let Subjects = [Function];
484 def NonNull : InheritableAttr {
485 let Spellings = [GNU<"nonnull">, CXX11<"gnu", "nonnull">];
486 let Args = [VariadicUnsignedArgument<"Args">];
487 let AdditionalMembers =
488 [{bool isNonNull(unsigned idx) const {
489 for (args_iterator i = args_begin(), e = args_end();
497 def NoReturn : InheritableAttr {
498 let Spellings = [GNU<"noreturn">, CXX11<"gnu", "noreturn">];
499 // FIXME: Does GCC allow this on the function instead?
500 let Subjects = [Function];
503 def NoInstrumentFunction : InheritableAttr {
504 let Spellings = [GNU<"no_instrument_function">,
505 CXX11<"gnu", "no_instrument_function">];
506 let Subjects = [Function];
509 def NoThrow : InheritableAttr {
510 let Spellings = [GNU<"nothrow">, CXX11<"gnu", "nothrow">];
513 def NSBridged : InheritableAttr {
514 let Spellings = [GNU<"ns_bridged">];
515 let Subjects = [Record];
516 let Args = [IdentifierArgument<"BridgedType">];
519 def NSReturnsRetained : InheritableAttr {
520 let Spellings = [GNU<"ns_returns_retained">];
521 let Subjects = [ObjCMethod, Function];
524 def NSReturnsNotRetained : InheritableAttr {
525 let Spellings = [GNU<"ns_returns_not_retained">];
526 let Subjects = [ObjCMethod, Function];
529 def NSReturnsAutoreleased : InheritableAttr {
530 let Spellings = [GNU<"ns_returns_autoreleased">];
531 let Subjects = [ObjCMethod, Function];
534 def NSConsumesSelf : InheritableAttr {
535 let Spellings = [GNU<"ns_consumes_self">];
536 let Subjects = [ObjCMethod];
539 def NSConsumed : InheritableParamAttr {
540 let Spellings = [GNU<"ns_consumed">];
541 let Subjects = [ParmVar];
544 def ObjCException : InheritableAttr {
545 let Spellings = [GNU<"objc_exception">];
548 def ObjCMethodFamily : InheritableAttr {
549 let Spellings = [GNU<"objc_method_family">];
550 let Subjects = [ObjCMethod];
551 let Args = [EnumArgument<"Family", "FamilyKind",
552 ["none", "alloc", "copy", "init", "mutableCopy", "new"],
553 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
554 "OMF_mutableCopy", "OMF_new"]>];
557 def ObjCNSObject : InheritableAttr {
558 let Spellings = [GNU<"NSObject">];
561 def ObjCPreciseLifetime : Attr {
562 let Spellings = [GNU<"objc_precise_lifetime">];
563 let Subjects = [Var];
566 def ObjCReturnsInnerPointer : Attr {
567 let Spellings = [GNU<"objc_returns_inner_pointer">];
568 let Subjects = [ObjCMethod];
571 def ObjCRequiresSuper : InheritableAttr {
572 let Spellings = [GNU<"objc_requires_super">];
573 let Subjects = [ObjCMethod];
576 def ObjCRootClass : Attr {
577 let Spellings = [GNU<"objc_root_class">];
578 let Subjects = [ObjCInterface];
581 def Overloadable : Attr {
582 let Spellings = [GNU<"overloadable">];
585 def Override : InheritableAttr {
590 def Ownership : InheritableAttr {
591 let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
592 GNU<"ownership_takes">];
593 let DistinctSpellings = 1;
594 let Args = [EnumArgument<"OwnKind", "OwnershipKind",
595 ["ownership_holds", "ownership_returns", "ownership_takes"],
596 ["Holds", "Returns", "Takes"]>,
597 StringArgument<"Module">, VariadicUnsignedArgument<"Args">];
600 def Packed : InheritableAttr {
601 let Spellings = [GNU<"packed">, CXX11<"gnu", "packed">];
604 def PnaclCall : InheritableAttr {
605 let Spellings = [GNU<"pnaclcall">];
608 def IntelOclBicc : InheritableAttr {
609 let Spellings = [GNU<"intel_ocl_bicc">];
612 def Pcs : InheritableAttr {
613 let Spellings = [GNU<"pcs">, CXX11<"gnu", "pcs">];
614 let Args = [EnumArgument<"PCS", "PCSType",
615 ["aapcs", "aapcs-vfp"],
616 ["AAPCS", "AAPCS_VFP"]>];
619 def Pure : InheritableAttr {
620 let Spellings = [GNU<"pure">, CXX11<"gnu", "pure">];
623 def Regparm : InheritableAttr {
624 let Spellings = [GNU<"regparm">, CXX11<"gnu", "regparm">];
625 let Args = [UnsignedArgument<"NumParams">];
628 def ReqdWorkGroupSize : InheritableAttr {
629 let Spellings = [GNU<"reqd_work_group_size">];
630 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
631 UnsignedArgument<"ZDim">];
634 def Endian : InheritableAttr {
635 let Spellings = [GNU<"endian">];
636 let Args = [IdentifierArgument<"platform">];
639 def WorkGroupSizeHint : InheritableAttr {
640 let Spellings = [GNU<"work_group_size_hint">];
641 let Args = [UnsignedArgument<"XDim">,
642 UnsignedArgument<"YDim">,
643 UnsignedArgument<"ZDim">];
646 def InitPriority : InheritableAttr {
647 let Spellings = [GNU<"init_priority">];
648 let Args = [UnsignedArgument<"Priority">];
651 def Section : InheritableAttr {
652 let Spellings = [GNU<"section">, CXX11<"gnu", "section">];
653 let Args = [StringArgument<"Name">];
656 def Sentinel : InheritableAttr {
657 let Spellings = [GNU<"sentinel">, CXX11<"gnu", "sentinel">];
658 let Args = [DefaultIntArgument<"Sentinel", 0>,
659 DefaultIntArgument<"NullPos", 0>];
662 def StdCall : InheritableAttr {
663 let Spellings = [GNU<"stdcall">, CXX11<"gnu", "stdcall">,
664 Keyword<"__stdcall">, Keyword<"_stdcall">];
667 def ThisCall : InheritableAttr {
668 let Spellings = [GNU<"thiscall">, CXX11<"gnu", "thiscall">,
669 Keyword<"__thiscall">, Keyword<"_thiscall">];
672 def Pascal : InheritableAttr {
673 let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
676 def TransparentUnion : InheritableAttr {
677 let Spellings = [GNU<"transparent_union">, CXX11<"gnu", "transparent_union">];
680 def Unavailable : InheritableAttr {
681 let Spellings = [GNU<"unavailable">];
682 let Args = [StringArgument<"Message">];
685 def ArcWeakrefUnavailable : InheritableAttr {
686 let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
687 let Subjects = [ObjCInterface];
691 let Spellings = [GNU<"objc_gc">];
692 let Args = [IdentifierArgument<"Kind">];
696 def ObjCOwnership : Attr {
697 let Spellings = [GNU<"objc_ownership">];
698 let Args = [IdentifierArgument<"Kind">];
702 def ObjCRequiresPropertyDefs : InheritableAttr {
703 let Spellings = [GNU<"objc_requires_property_definitions">];
704 let Subjects = [ObjCInterface];
707 def Unused : InheritableAttr {
708 let Spellings = [GNU<"unused">, CXX11<"gnu", "unused">];
711 def Used : InheritableAttr {
712 let Spellings = [GNU<"used">, CXX11<"gnu", "used">];
715 def Uuid : InheritableAttr {
716 let Spellings = [GNU<"uuid">];
717 let Args = [StringArgument<"Guid">];
718 let Subjects = [CXXRecord];
721 def VectorSize : Attr {
722 let Spellings = [GNU<"vector_size">, CXX11<"gnu", "vector_size">];
723 let Args = [ExprArgument<"NumBytes">];
727 def VecTypeHint : InheritableAttr {
728 let Spellings = [GNU<"vec_type_hint">];
729 let Args = [TypeArgument<"TypeHint">, SourceLocArgument<"TypeLoc">];
732 def Visibility : InheritableAttr {
734 let Spellings = [GNU<"visibility">, CXX11<"gnu", "visibility">];
735 let Args = [EnumArgument<"Visibility", "VisibilityType",
736 ["default", "hidden", "internal", "protected"],
737 ["Default", "Hidden", "Hidden", "Protected"]>];
740 def TypeVisibility : InheritableAttr {
742 let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">];
743 let Args = [EnumArgument<"Visibility", "VisibilityType",
744 ["default", "hidden", "internal", "protected"],
745 ["Default", "Hidden", "Hidden", "Protected"]>];
748 def VecReturn : InheritableAttr {
749 let Spellings = [GNU<"vecreturn">];
750 let Subjects = [CXXRecord];
753 def WarnUnusedResult : InheritableAttr {
754 let Spellings = [GNU<"warn_unused_result">,
755 CXX11<"clang", "warn_unused_result">,
756 CXX11<"gnu", "warn_unused_result">];
759 def Weak : InheritableAttr {
760 let Spellings = [GNU<"weak">, CXX11<"gnu", "weak">];
763 def WeakImport : InheritableAttr {
764 let Spellings = [GNU<"weak_import">];
767 def WeakRef : InheritableAttr {
768 let Spellings = [GNU<"weakref">, CXX11<"gnu", "weakref">];
771 def X86ForceAlignArgPointer : InheritableAttr {
775 // Attribute to disable AddressSanitizer (or equivalent) checks.
776 def NoSanitizeAddress : InheritableAttr {
777 let Spellings = [GNU<"no_address_safety_analysis">,
778 GNU<"no_sanitize_address">];
781 // Attribute to disable ThreadSanitizer checks.
782 def NoSanitizeThread : InheritableAttr {
783 let Spellings = [GNU<"no_sanitize_thread">];
786 // Attribute to disable MemorySanitizer checks.
787 def NoSanitizeMemory : InheritableAttr {
788 let Spellings = [GNU<"no_sanitize_memory">];
791 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
793 def GuardedVar : InheritableAttr {
794 let Spellings = [GNU<"guarded_var">];
797 def PtGuardedVar : InheritableAttr {
798 let Spellings = [GNU<"pt_guarded_var">];
801 def Lockable : InheritableAttr {
802 let Spellings = [GNU<"lockable">];
805 def ScopedLockable : InheritableAttr {
806 let Spellings = [GNU<"scoped_lockable">];
809 def NoThreadSafetyAnalysis : InheritableAttr {
810 let Spellings = [GNU<"no_thread_safety_analysis">];
813 def GuardedBy : InheritableAttr {
814 let Spellings = [GNU<"guarded_by">];
815 let Args = [ExprArgument<"Arg">];
817 let TemplateDependent = 1;
820 def PtGuardedBy : InheritableAttr {
821 let Spellings = [GNU<"pt_guarded_by">];
822 let Args = [ExprArgument<"Arg">];
824 let TemplateDependent = 1;
827 def AcquiredAfter : InheritableAttr {
828 let Spellings = [GNU<"acquired_after">];
829 let Args = [VariadicExprArgument<"Args">];
831 let TemplateDependent = 1;
834 def AcquiredBefore : InheritableAttr {
835 let Spellings = [GNU<"acquired_before">];
836 let Args = [VariadicExprArgument<"Args">];
838 let TemplateDependent = 1;
841 def ExclusiveLockFunction : InheritableAttr {
842 let Spellings = [GNU<"exclusive_lock_function">];
843 let Args = [VariadicExprArgument<"Args">];
845 let TemplateDependent = 1;
848 def SharedLockFunction : InheritableAttr {
849 let Spellings = [GNU<"shared_lock_function">];
850 let Args = [VariadicExprArgument<"Args">];
852 let TemplateDependent = 1;
855 // The first argument is an integer or boolean value specifying the return value
856 // of a successful lock acquisition.
857 def ExclusiveTrylockFunction : InheritableAttr {
858 let Spellings = [GNU<"exclusive_trylock_function">];
859 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
861 let TemplateDependent = 1;
864 // The first argument is an integer or boolean value specifying the return value
865 // of a successful lock acquisition.
866 def SharedTrylockFunction : InheritableAttr {
867 let Spellings = [GNU<"shared_trylock_function">];
868 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
870 let TemplateDependent = 1;
873 def UnlockFunction : InheritableAttr {
874 let Spellings = [GNU<"unlock_function">];
875 let Args = [VariadicExprArgument<"Args">];
877 let TemplateDependent = 1;
880 def LockReturned : InheritableAttr {
881 let Spellings = [GNU<"lock_returned">];
882 let Args = [ExprArgument<"Arg">];
884 let TemplateDependent = 1;
887 def LocksExcluded : InheritableAttr {
888 let Spellings = [GNU<"locks_excluded">];
889 let Args = [VariadicExprArgument<"Args">];
891 let TemplateDependent = 1;
894 def ExclusiveLocksRequired : InheritableAttr {
895 let Spellings = [GNU<"exclusive_locks_required">];
896 let Args = [VariadicExprArgument<"Args">];
898 let TemplateDependent = 1;
901 def SharedLocksRequired : InheritableAttr {
902 let Spellings = [GNU<"shared_locks_required">];
903 let Args = [VariadicExprArgument<"Args">];
905 let TemplateDependent = 1;
908 // Type safety attributes for `void *' pointers and type tags.
910 def ArgumentWithTypeTag : InheritableAttr {
911 let Spellings = [GNU<"argument_with_type_tag">,
912 GNU<"pointer_with_type_tag">];
913 let Args = [IdentifierArgument<"ArgumentKind">,
914 UnsignedArgument<"ArgumentIdx">,
915 UnsignedArgument<"TypeTagIdx">,
916 BoolArgument<"IsPointer">];
917 let Subjects = [Function];
920 def TypeTagForDatatype : InheritableAttr {
921 let Spellings = [GNU<"type_tag_for_datatype">];
922 let Args = [IdentifierArgument<"ArgumentKind">,
923 TypeArgument<"MatchingCType">,
924 BoolArgument<"LayoutCompatible">,
925 BoolArgument<"MustBeNull">];
926 let Subjects = [Var];
929 // Microsoft-related attributes
931 def MsProperty : Attr {
932 let Spellings = [Declspec<"property">];
935 def MsStruct : InheritableAttr {
936 let Spellings = [Declspec<"ms_struct">];
939 def DLLExport : InheritableAttr {
940 let Spellings = [Declspec<"dllexport">];
943 def DLLImport : InheritableAttr {
944 let Spellings = [Declspec<"dllimport">];
947 def ForceInline : InheritableAttr {
948 let Spellings = [Keyword<"__forceinline">];
951 def Win64 : InheritableAttr {
952 let Spellings = [Keyword<"__w64">];
955 def Ptr32 : InheritableAttr {
956 let Spellings = [Keyword<"__ptr32">];
959 def Ptr64 : InheritableAttr {
960 let Spellings = [Keyword<"__ptr64">];
963 class MSInheritanceAttr : InheritableAttr;
965 def SingleInheritance : MSInheritanceAttr {
966 let Spellings = [Keyword<"__single_inheritance">];
969 def MultipleInheritance : MSInheritanceAttr {
970 let Spellings = [Keyword<"__multiple_inheritance">];
973 def VirtualInheritance : MSInheritanceAttr {
974 let Spellings = [Keyword<"__virtual_inheritance">];
977 // This attribute doesn't have any spellings, but we can apply it implicitly to
978 // incomplete types that lack any of the other attributes.
979 def UnspecifiedInheritance : MSInheritanceAttr {
983 def Unaligned : IgnoredAttr {
984 let Spellings = [Keyword<"__unaligned">];