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 MSABI : InheritableAttr {
421 let Spellings = [GNU<"ms_abi">, CXX11<"gnu", "ms_abi">];
424 def MSP430Interrupt : InheritableAttr {
426 let Args = [UnsignedArgument<"Number">];
430 def MBlazeInterruptHandler : InheritableAttr {
435 def MBlazeSaveVolatiles : InheritableAttr {
440 def Mips16 : InheritableAttr {
441 let Spellings = [GNU<"mips16">, CXX11<"gnu", "mips16">];
442 let Subjects = [Function];
446 let Spellings = [GNU<"mode">, CXX11<"gnu", "mode">];
447 let Args = [IdentifierArgument<"Mode">];
451 def Naked : InheritableAttr {
452 let Spellings = [GNU<"naked">, CXX11<"gnu", "naked">];
455 def NeonPolyVectorType : Attr {
456 let Spellings = [GNU<"neon_polyvector_type">];
457 let Args = [IntArgument<"NumElements">];
461 def NeonVectorType : Attr {
462 let Spellings = [GNU<"neon_vector_type">];
463 let Args = [IntArgument<"NumElements">];
467 def ReturnsTwice : InheritableAttr {
468 let Spellings = [GNU<"returns_twice">, CXX11<"gnu", "returns_twice">];
471 def NoCommon : InheritableAttr {
472 let Spellings = [GNU<"nocommon">, CXX11<"gnu", "nocommon">];
475 def NoDebug : InheritableAttr {
476 let Spellings = [GNU<"nodebug">];
479 def NoInline : InheritableAttr {
480 let Spellings = [GNU<"noinline">, CXX11<"gnu", "noinline">];
483 def NoMips16 : InheritableAttr {
484 let Spellings = [GNU<"nomips16">, CXX11<"gnu", "nomips16">];
485 let Subjects = [Function];
488 def NonNull : InheritableAttr {
489 let Spellings = [GNU<"nonnull">, CXX11<"gnu", "nonnull">];
490 let Args = [VariadicUnsignedArgument<"Args">];
491 let AdditionalMembers =
492 [{bool isNonNull(unsigned idx) const {
493 for (args_iterator i = args_begin(), e = args_end();
501 def NoReturn : InheritableAttr {
502 let Spellings = [GNU<"noreturn">, CXX11<"gnu", "noreturn">];
503 // FIXME: Does GCC allow this on the function instead?
504 let Subjects = [Function];
507 def NoInstrumentFunction : InheritableAttr {
508 let Spellings = [GNU<"no_instrument_function">,
509 CXX11<"gnu", "no_instrument_function">];
510 let Subjects = [Function];
513 def NoThrow : InheritableAttr {
514 let Spellings = [GNU<"nothrow">, CXX11<"gnu", "nothrow">];
517 def NSBridged : InheritableAttr {
518 let Spellings = [GNU<"ns_bridged">];
519 let Subjects = [Record];
520 let Args = [IdentifierArgument<"BridgedType">];
523 def NSReturnsRetained : InheritableAttr {
524 let Spellings = [GNU<"ns_returns_retained">];
525 let Subjects = [ObjCMethod, Function];
528 def NSReturnsNotRetained : InheritableAttr {
529 let Spellings = [GNU<"ns_returns_not_retained">];
530 let Subjects = [ObjCMethod, Function];
533 def NSReturnsAutoreleased : InheritableAttr {
534 let Spellings = [GNU<"ns_returns_autoreleased">];
535 let Subjects = [ObjCMethod, Function];
538 def NSConsumesSelf : InheritableAttr {
539 let Spellings = [GNU<"ns_consumes_self">];
540 let Subjects = [ObjCMethod];
543 def NSConsumed : InheritableParamAttr {
544 let Spellings = [GNU<"ns_consumed">];
545 let Subjects = [ParmVar];
548 def ObjCException : InheritableAttr {
549 let Spellings = [GNU<"objc_exception">];
552 def ObjCMethodFamily : InheritableAttr {
553 let Spellings = [GNU<"objc_method_family">];
554 let Subjects = [ObjCMethod];
555 let Args = [EnumArgument<"Family", "FamilyKind",
556 ["none", "alloc", "copy", "init", "mutableCopy", "new"],
557 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
558 "OMF_mutableCopy", "OMF_new"]>];
561 def ObjCNSObject : InheritableAttr {
562 let Spellings = [GNU<"NSObject">];
565 def ObjCPreciseLifetime : Attr {
566 let Spellings = [GNU<"objc_precise_lifetime">];
567 let Subjects = [Var];
570 def ObjCReturnsInnerPointer : Attr {
571 let Spellings = [GNU<"objc_returns_inner_pointer">];
572 let Subjects = [ObjCMethod];
575 def ObjCRequiresSuper : InheritableAttr {
576 let Spellings = [GNU<"objc_requires_super">];
577 let Subjects = [ObjCMethod];
580 def ObjCRootClass : Attr {
581 let Spellings = [GNU<"objc_root_class">];
582 let Subjects = [ObjCInterface];
585 def Overloadable : Attr {
586 let Spellings = [GNU<"overloadable">];
589 def Override : InheritableAttr {
594 def Ownership : InheritableAttr {
595 let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
596 GNU<"ownership_takes">];
597 let DistinctSpellings = 1;
598 let Args = [EnumArgument<"OwnKind", "OwnershipKind",
599 ["ownership_holds", "ownership_returns", "ownership_takes"],
600 ["Holds", "Returns", "Takes"]>,
601 StringArgument<"Module">, VariadicUnsignedArgument<"Args">];
604 def Packed : InheritableAttr {
605 let Spellings = [GNU<"packed">, CXX11<"gnu", "packed">];
608 def PnaclCall : InheritableAttr {
609 let Spellings = [GNU<"pnaclcall">];
612 def IntelOclBicc : InheritableAttr {
613 let Spellings = [GNU<"intel_ocl_bicc">];
616 def Pcs : InheritableAttr {
617 let Spellings = [GNU<"pcs">, CXX11<"gnu", "pcs">];
618 let Args = [EnumArgument<"PCS", "PCSType",
619 ["aapcs", "aapcs-vfp"],
620 ["AAPCS", "AAPCS_VFP"]>];
623 def Pure : InheritableAttr {
624 let Spellings = [GNU<"pure">, CXX11<"gnu", "pure">];
627 def Regparm : InheritableAttr {
628 let Spellings = [GNU<"regparm">, CXX11<"gnu", "regparm">];
629 let Args = [UnsignedArgument<"NumParams">];
632 def ReqdWorkGroupSize : InheritableAttr {
633 let Spellings = [GNU<"reqd_work_group_size">];
634 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
635 UnsignedArgument<"ZDim">];
638 def Endian : InheritableAttr {
639 let Spellings = [GNU<"endian">];
640 let Args = [IdentifierArgument<"platform">];
643 def WorkGroupSizeHint : InheritableAttr {
644 let Spellings = [GNU<"work_group_size_hint">];
645 let Args = [UnsignedArgument<"XDim">,
646 UnsignedArgument<"YDim">,
647 UnsignedArgument<"ZDim">];
650 def InitPriority : InheritableAttr {
651 let Spellings = [GNU<"init_priority">];
652 let Args = [UnsignedArgument<"Priority">];
655 def Section : InheritableAttr {
656 let Spellings = [GNU<"section">, CXX11<"gnu", "section">];
657 let Args = [StringArgument<"Name">];
660 def Sentinel : InheritableAttr {
661 let Spellings = [GNU<"sentinel">, CXX11<"gnu", "sentinel">];
662 let Args = [DefaultIntArgument<"Sentinel", 0>,
663 DefaultIntArgument<"NullPos", 0>];
666 def StdCall : InheritableAttr {
667 let Spellings = [GNU<"stdcall">, CXX11<"gnu", "stdcall">,
668 Keyword<"__stdcall">, Keyword<"_stdcall">];
671 def SysVABI : InheritableAttr {
672 let Spellings = [GNU<"sysv_abi">, CXX11<"gnu", "sysv_abi">];
675 def ThisCall : InheritableAttr {
676 let Spellings = [GNU<"thiscall">, CXX11<"gnu", "thiscall">,
677 Keyword<"__thiscall">, Keyword<"_thiscall">];
680 def Pascal : InheritableAttr {
681 let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
684 def TransparentUnion : InheritableAttr {
685 let Spellings = [GNU<"transparent_union">, CXX11<"gnu", "transparent_union">];
688 def Unavailable : InheritableAttr {
689 let Spellings = [GNU<"unavailable">];
690 let Args = [StringArgument<"Message">];
693 def ArcWeakrefUnavailable : InheritableAttr {
694 let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
695 let Subjects = [ObjCInterface];
699 let Spellings = [GNU<"objc_gc">];
700 let Args = [IdentifierArgument<"Kind">];
704 def ObjCOwnership : Attr {
705 let Spellings = [GNU<"objc_ownership">];
706 let Args = [IdentifierArgument<"Kind">];
710 def ObjCRequiresPropertyDefs : InheritableAttr {
711 let Spellings = [GNU<"objc_requires_property_definitions">];
712 let Subjects = [ObjCInterface];
715 def Unused : InheritableAttr {
716 let Spellings = [GNU<"unused">, CXX11<"gnu", "unused">];
719 def Used : InheritableAttr {
720 let Spellings = [GNU<"used">, CXX11<"gnu", "used">];
723 def Uuid : InheritableAttr {
724 let Spellings = [GNU<"uuid">];
725 let Args = [StringArgument<"Guid">];
726 let Subjects = [CXXRecord];
729 def VectorSize : Attr {
730 let Spellings = [GNU<"vector_size">, CXX11<"gnu", "vector_size">];
731 let Args = [ExprArgument<"NumBytes">];
735 def VecTypeHint : InheritableAttr {
736 let Spellings = [GNU<"vec_type_hint">];
737 let Args = [TypeArgument<"TypeHint">, SourceLocArgument<"TypeLoc">];
740 def Visibility : InheritableAttr {
742 let Spellings = [GNU<"visibility">, CXX11<"gnu", "visibility">];
743 let Args = [EnumArgument<"Visibility", "VisibilityType",
744 ["default", "hidden", "internal", "protected"],
745 ["Default", "Hidden", "Hidden", "Protected"]>];
748 def TypeVisibility : InheritableAttr {
750 let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">];
751 let Args = [EnumArgument<"Visibility", "VisibilityType",
752 ["default", "hidden", "internal", "protected"],
753 ["Default", "Hidden", "Hidden", "Protected"]>];
756 def VecReturn : InheritableAttr {
757 let Spellings = [GNU<"vecreturn">];
758 let Subjects = [CXXRecord];
761 def WarnUnusedResult : InheritableAttr {
762 let Spellings = [GNU<"warn_unused_result">,
763 CXX11<"clang", "warn_unused_result">,
764 CXX11<"gnu", "warn_unused_result">];
767 def Weak : InheritableAttr {
768 let Spellings = [GNU<"weak">, CXX11<"gnu", "weak">];
771 def WeakImport : InheritableAttr {
772 let Spellings = [GNU<"weak_import">];
775 def WeakRef : InheritableAttr {
776 let Spellings = [GNU<"weakref">, CXX11<"gnu", "weakref">];
779 def X86ForceAlignArgPointer : InheritableAttr {
783 // Attribute to disable AddressSanitizer (or equivalent) checks.
784 def NoSanitizeAddress : InheritableAttr {
785 let Spellings = [GNU<"no_address_safety_analysis">,
786 GNU<"no_sanitize_address">];
789 // Attribute to disable ThreadSanitizer checks.
790 def NoSanitizeThread : InheritableAttr {
791 let Spellings = [GNU<"no_sanitize_thread">];
794 // Attribute to disable MemorySanitizer checks.
795 def NoSanitizeMemory : InheritableAttr {
796 let Spellings = [GNU<"no_sanitize_memory">];
799 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
801 def GuardedVar : InheritableAttr {
802 let Spellings = [GNU<"guarded_var">];
805 def PtGuardedVar : InheritableAttr {
806 let Spellings = [GNU<"pt_guarded_var">];
809 def Lockable : InheritableAttr {
810 let Spellings = [GNU<"lockable">];
813 def ScopedLockable : InheritableAttr {
814 let Spellings = [GNU<"scoped_lockable">];
817 def NoThreadSafetyAnalysis : InheritableAttr {
818 let Spellings = [GNU<"no_thread_safety_analysis">];
821 def GuardedBy : InheritableAttr {
822 let Spellings = [GNU<"guarded_by">];
823 let Args = [ExprArgument<"Arg">];
825 let TemplateDependent = 1;
828 def PtGuardedBy : InheritableAttr {
829 let Spellings = [GNU<"pt_guarded_by">];
830 let Args = [ExprArgument<"Arg">];
832 let TemplateDependent = 1;
835 def AcquiredAfter : InheritableAttr {
836 let Spellings = [GNU<"acquired_after">];
837 let Args = [VariadicExprArgument<"Args">];
839 let TemplateDependent = 1;
842 def AcquiredBefore : InheritableAttr {
843 let Spellings = [GNU<"acquired_before">];
844 let Args = [VariadicExprArgument<"Args">];
846 let TemplateDependent = 1;
849 def ExclusiveLockFunction : InheritableAttr {
850 let Spellings = [GNU<"exclusive_lock_function">];
851 let Args = [VariadicExprArgument<"Args">];
853 let TemplateDependent = 1;
856 def SharedLockFunction : InheritableAttr {
857 let Spellings = [GNU<"shared_lock_function">];
858 let Args = [VariadicExprArgument<"Args">];
860 let TemplateDependent = 1;
863 // The first argument is an integer or boolean value specifying the return value
864 // of a successful lock acquisition.
865 def ExclusiveTrylockFunction : InheritableAttr {
866 let Spellings = [GNU<"exclusive_trylock_function">];
867 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
869 let TemplateDependent = 1;
872 // The first argument is an integer or boolean value specifying the return value
873 // of a successful lock acquisition.
874 def SharedTrylockFunction : InheritableAttr {
875 let Spellings = [GNU<"shared_trylock_function">];
876 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
878 let TemplateDependent = 1;
881 def UnlockFunction : InheritableAttr {
882 let Spellings = [GNU<"unlock_function">];
883 let Args = [VariadicExprArgument<"Args">];
885 let TemplateDependent = 1;
888 def LockReturned : InheritableAttr {
889 let Spellings = [GNU<"lock_returned">];
890 let Args = [ExprArgument<"Arg">];
892 let TemplateDependent = 1;
895 def LocksExcluded : InheritableAttr {
896 let Spellings = [GNU<"locks_excluded">];
897 let Args = [VariadicExprArgument<"Args">];
899 let TemplateDependent = 1;
902 def ExclusiveLocksRequired : InheritableAttr {
903 let Spellings = [GNU<"exclusive_locks_required">];
904 let Args = [VariadicExprArgument<"Args">];
906 let TemplateDependent = 1;
909 def SharedLocksRequired : InheritableAttr {
910 let Spellings = [GNU<"shared_locks_required">];
911 let Args = [VariadicExprArgument<"Args">];
913 let TemplateDependent = 1;
916 // Type safety attributes for `void *' pointers and type tags.
918 def ArgumentWithTypeTag : InheritableAttr {
919 let Spellings = [GNU<"argument_with_type_tag">,
920 GNU<"pointer_with_type_tag">];
921 let Args = [IdentifierArgument<"ArgumentKind">,
922 UnsignedArgument<"ArgumentIdx">,
923 UnsignedArgument<"TypeTagIdx">,
924 BoolArgument<"IsPointer">];
925 let Subjects = [Function];
928 def TypeTagForDatatype : InheritableAttr {
929 let Spellings = [GNU<"type_tag_for_datatype">];
930 let Args = [IdentifierArgument<"ArgumentKind">,
931 TypeArgument<"MatchingCType">,
932 BoolArgument<"LayoutCompatible">,
933 BoolArgument<"MustBeNull">];
934 let Subjects = [Var];
937 // Microsoft-related attributes
939 def MsProperty : Attr {
940 let Spellings = [Declspec<"property">];
943 def MsStruct : InheritableAttr {
944 let Spellings = [Declspec<"ms_struct">];
947 def DLLExport : InheritableAttr {
948 let Spellings = [Declspec<"dllexport">];
951 def DLLImport : InheritableAttr {
952 let Spellings = [Declspec<"dllimport">];
955 def ForceInline : InheritableAttr {
956 let Spellings = [Keyword<"__forceinline">];
959 def Win64 : InheritableAttr {
960 let Spellings = [Keyword<"__w64">];
963 def Ptr32 : InheritableAttr {
964 let Spellings = [Keyword<"__ptr32">];
967 def Ptr64 : InheritableAttr {
968 let Spellings = [Keyword<"__ptr64">];
971 class MSInheritanceAttr : InheritableAttr;
973 def SingleInheritance : MSInheritanceAttr {
974 let Spellings = [Keyword<"__single_inheritance">];
977 def MultipleInheritance : MSInheritanceAttr {
978 let Spellings = [Keyword<"__multiple_inheritance">];
981 def VirtualInheritance : MSInheritanceAttr {
982 let Spellings = [Keyword<"__virtual_inheritance">];
985 // This attribute doesn't have any spellings, but we can apply it implicitly to
986 // incomplete types that lack any of the other attributes.
987 def UnspecifiedInheritance : MSInheritanceAttr {
991 def Unaligned : IgnoredAttr {
992 let Spellings = [Keyword<"__unaligned">];