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//////////////////////////////////////////////////////////////////////////////// 6 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). 11class AttrSubject; 12 13include "clang/Basic/DeclNodes.td" 14include "clang/Basic/StmtNodes.td" 15 16// A subset-subject is an AttrSubject constrained to operate only on some subset 17// of that subject. 18// 19// The description is used in output messages to specify what the subject 20// represents. FIXME: Deal with translation issues. 21// 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. 25class SubsetSubject<AttrSubject base, string description, code check> 26 : AttrSubject { 27 AttrSubject Base = base; 28 string Description = description; 29 code CheckCode = check; 30} 31 32// This is the type of a variable which C++11 allows alignas(...) to appertain 33// to. 34def 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}]>; 39def CXXVirtualMethod : SubsetSubject<CXXRecord, "virtual member function", 40 [{S->isVirtual()}]>; 41def NonBitField : SubsetSubject<Field, "non-bit field", 42 [{!S->isBitField()}]>; 43 44// A single argument to an attribute 45class Argument<string name> { 46 string Name = name; 47} 48 49class BoolArgument<string name> : Argument<name>; 50class IdentifierArgument<string name> : Argument<name>; 51class IntArgument<string name> : Argument<name>; 52class StringArgument<string name> : Argument<name>; 53class ExprArgument<string name> : Argument<name>; 54class FunctionArgument<string name> : Argument<name>; 55class TypeArgument<string name> : Argument<name>; 56class UnsignedArgument<string name> : Argument<name>; 57class SourceLocArgument<string name> : Argument<name>; 58class VariadicUnsignedArgument<string name> : Argument<name>; 59class VariadicExprArgument<string name> : Argument<name>; 60 61// A version of the form major.minor[.subminor]. 62class VersionArgument<string name> : Argument<name>; 63 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 66// be dependent. 67class AlignedArgument<string name> : Argument<name>; 68 69// An integer argument with a default value 70class DefaultIntArgument<string name, int default> : IntArgument<name> { 71 int Default = default; 72} 73 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. 76class EnumArgument<string name, string type, list<string> values, 77 list<string> enums> : Argument<name> { 78 string Type = type; 79 list<string> Values = values; 80 list<string> Enums = enums; 81} 82 83// This handles one spelling of an attribute. 84class Spelling<string name, string variety> { 85 string Name = name; 86 string Variety = variety; 87} 88 89class GNU<string name> : Spelling<name, "GNU">; 90class Declspec<string name> : Spelling<name, "Declspec">; 91class CXX11<string namespace, string name> : Spelling<name, "CXX11"> { 92 string Namespace = namespace; 93} 94class Keyword<string name> : Spelling<name, "Keyword">; 95 96class Accessor<string name, list<Spelling> spellings> { 97 string Name = name; 98 list<Spelling> Spellings = spellings; 99} 100 101class Attr { 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. 111 bit LateParsed = 0; 112 // Set to false to prevent an attribute from being propagated from a template 113 // to the instantiation. 114 bit Clone = 1; 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. 118 bit ASTNode = 1; 119 // Set to true for attributes which have handler in Sema. 120 bit SemaHandler = 1; 121 // Set to true for attributes that are completely ignored. 122 bit Ignored = 0; 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 = [{}]; 127} 128 129/// An inheritable attribute is inherited by later redeclarations. 130class InheritableAttr : Attr; 131 132/// An inheritable parameter attribute is inherited by later 133/// redeclarations, even when it's written on a parameter. 134class InheritableParamAttr : InheritableAttr; 135 136/// An ignored attribute, which we parse but discard with no checking. 137class IgnoredAttr : Attr { 138 let Ignored = 1; 139 let ASTNode = 0; 140 let SemaHandler = 0; 141} 142 143// 144// Attributes begin here 145// 146 147def AddressSpace : Attr { 148 let Spellings = [GNU<"address_space">]; 149 let Args = [IntArgument<"AddressSpace">]; 150 let ASTNode = 0; 151} 152 153def Alias : InheritableAttr { 154 let Spellings = [GNU<"alias">, CXX11<"gnu", "alias">]; 155 let Args = [StringArgument<"Aliasee">]; 156} 157 158def 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">]>]; 168} 169 170def AlignMac68k : InheritableAttr { 171 let Spellings = []; 172 let SemaHandler = 0; 173} 174 175def AllocSize : Attr { 176 let Spellings = [GNU<"alloc_size">, CXX11<"gnu", "alloc_size">]; 177 let Args = [VariadicUnsignedArgument<"Args">]; 178} 179 180def AlwaysInline : InheritableAttr { 181 let Spellings = [GNU<"always_inline">, CXX11<"gnu", "always_inline">]; 182} 183 184def TLSModel : InheritableAttr { 185 let Spellings = [GNU<"tls_model">, CXX11<"gnu", "tls_model">]; 186 let Subjects = [Var]; 187 let Args = [StringArgument<"Model">]; 188} 189 190def AnalyzerNoReturn : InheritableAttr { 191 let Spellings = [GNU<"analyzer_noreturn">]; 192} 193 194def Annotate : InheritableParamAttr { 195 let Spellings = [GNU<"annotate">]; 196 let Args = [StringArgument<"Annotation">]; 197} 198 199def AsmLabel : InheritableAttr { 200 let Spellings = []; 201 let Args = [StringArgument<"Label">]; 202 let SemaHandler = 0; 203} 204 205def 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) 213 .Case("ios", "iOS") 214 .Case("macosx", "OS X") 215 .Default(llvm::StringRef()); 216} }]; 217} 218 219def Blocks : InheritableAttr { 220 let Spellings = [GNU<"blocks">]; 221 let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>]; 222} 223 224def Bounded : IgnoredAttr { 225 let Spellings = [GNU<"bounded">]; 226} 227 228def CarriesDependency : InheritableParamAttr { 229 let Spellings = [GNU<"carries_dependency">, CXX11<"","carries_dependency">, 230 CXX11<"std","carries_dependency">]; 231 let Subjects = [ParmVar, Function]; 232} 233 234def CDecl : InheritableAttr { 235 let Spellings = [GNU<"cdecl">, CXX11<"gnu", "cdecl">, Keyword<"__cdecl">, 236 Keyword<"_cdecl">]; 237} 238 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. 243def CFAuditedTransfer : InheritableAttr { 244 let Spellings = [GNU<"cf_audited_transfer">]; 245 let Subjects = [Function]; 246} 247 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. 251def CFUnknownTransfer : InheritableAttr { 252 let Spellings = [GNU<"cf_unknown_transfer">]; 253 let Subjects = [Function]; 254} 255 256def CFReturnsRetained : InheritableAttr { 257 let Spellings = [GNU<"cf_returns_retained">]; 258 let Subjects = [ObjCMethod, Function]; 259} 260 261def CFReturnsNotRetained : InheritableAttr { 262 let Spellings = [GNU<"cf_returns_not_retained">]; 263 let Subjects = [ObjCMethod, Function]; 264} 265 266def CFConsumed : InheritableParamAttr { 267 let Spellings = [GNU<"cf_consumed">]; 268 let Subjects = [ParmVar]; 269} 270 271def Cleanup : InheritableAttr { 272 let Spellings = [GNU<"cleanup">, CXX11<"gnu", "cleanup">]; 273 let Args = [FunctionArgument<"FunctionDecl">]; 274} 275 276def Cold : InheritableAttr { 277 let Spellings = [GNU<"cold">, CXX11<"gnu", "cold">]; 278} 279 280def Common : InheritableAttr { 281 let Spellings = [GNU<"common">, CXX11<"gnu", "common">]; 282} 283 284def Const : InheritableAttr { 285 let Spellings = [GNU<"const">, GNU<"__const">, CXX11<"gnu", "const">]; 286} 287 288def Constructor : InheritableAttr { 289 let Spellings = [GNU<"constructor">, CXX11<"gnu", "constructor">]; 290 let Args = [IntArgument<"Priority">]; 291} 292 293def CUDAConstant : InheritableAttr { 294 let Spellings = [GNU<"constant">]; 295} 296 297def CUDADevice : InheritableAttr { 298 let Spellings = [GNU<"device">]; 299} 300 301def CUDAGlobal : InheritableAttr { 302 let Spellings = [GNU<"global">]; 303} 304 305def CUDAHost : InheritableAttr { 306 let Spellings = [GNU<"host">]; 307} 308 309def CUDALaunchBounds : InheritableAttr { 310 let Spellings = [GNU<"launch_bounds">]; 311 let Args = [IntArgument<"MaxThreads">, DefaultIntArgument<"MinBlocks", 0>]; 312} 313 314def CUDAShared : InheritableAttr { 315 let Spellings = [GNU<"shared">]; 316} 317 318def C11NoReturn : InheritableAttr { 319 let Spellings = [Keyword<"_Noreturn">]; 320 let Subjects = [Function]; 321 let SemaHandler = 0; 322} 323 324def CXX11NoReturn : InheritableAttr { 325 let Spellings = [CXX11<"","noreturn">, CXX11<"std","noreturn">]; 326 let Subjects = [Function]; 327} 328 329def OpenCLKernel : Attr { 330 let Spellings = [Keyword<"__kernel">, Keyword<"kernel">]; 331} 332 333def OpenCLImageAccess : Attr { 334 let Spellings = [GNU<"opencl_image_access">]; 335 let Args = [IntArgument<"Access">]; 336 let ASTNode = 0; 337} 338 339def Kernel : Attr { 340 let Spellings = [GNU<"kernel">]; 341} 342 343def Deprecated : InheritableAttr { 344 let Spellings = [GNU<"deprecated">, CXX11<"gnu", "deprecated">]; 345 let Args = [StringArgument<"Message">]; 346} 347 348def Destructor : InheritableAttr { 349 let Spellings = [GNU<"destructor">, CXX11<"gnu", "destructor">]; 350 let Args = [IntArgument<"Priority">]; 351} 352 353def ExtVectorType : Attr { 354 let Spellings = [GNU<"ext_vector_type">]; 355 let Args = [ExprArgument<"NumElements">]; 356 let ASTNode = 0; 357} 358 359def FallThrough : Attr { 360 let Spellings = [CXX11<"clang", "fallthrough">]; 361 let Subjects = [NullStmt]; 362} 363 364def FastCall : InheritableAttr { 365 let Spellings = [GNU<"fastcall">, CXX11<"gnu", "fastcall">, 366 Keyword<"__fastcall">, Keyword<"_fastcall">]; 367} 368 369def Final : InheritableAttr { 370 let Spellings = []; 371 let SemaHandler = 0; 372} 373 374def MinSize : InheritableAttr { 375 let Spellings = [GNU<"minsize">]; 376 let Subjects = [Function]; 377} 378 379def Format : InheritableAttr { 380 let Spellings = [GNU<"format">, CXX11<"gnu", "format">]; 381 let Args = [StringArgument<"Type">, IntArgument<"FormatIdx">, 382 IntArgument<"FirstArg">]; 383} 384 385def FormatArg : InheritableAttr { 386 let Spellings = [GNU<"format_arg">, CXX11<"gnu", "format_arg">]; 387 let Args = [IntArgument<"FormatIdx">]; 388} 389 390def GNUInline : InheritableAttr { 391 let Spellings = [GNU<"gnu_inline">, CXX11<"gnu", "gnu_inline">]; 392} 393 394def Hot : InheritableAttr { 395 let Spellings = [GNU<"hot">, CXX11<"gnu", "hot">]; 396} 397 398def IBAction : InheritableAttr { 399 let Spellings = [GNU<"ibaction">]; 400} 401 402def IBOutlet : InheritableAttr { 403 let Spellings = [GNU<"iboutlet">]; 404} 405 406def IBOutletCollection : InheritableAttr { 407 let Spellings = [GNU<"iboutletcollection">]; 408 let Args = [TypeArgument<"Interface">, SourceLocArgument<"InterfaceLoc">]; 409} 410 411def Malloc : InheritableAttr { 412 let Spellings = [GNU<"malloc">, CXX11<"gnu", "malloc">]; 413} 414 415def MaxFieldAlignment : InheritableAttr { 416 let Spellings = []; 417 let Args = [UnsignedArgument<"Alignment">]; 418 let SemaHandler = 0; 419} 420 421def MayAlias : InheritableAttr { 422 let Spellings = [GNU<"may_alias">, CXX11<"gnu", "may_alias">]; 423} 424 425def MSP430Interrupt : InheritableAttr { 426 let Spellings = []; 427 let Args = [UnsignedArgument<"Number">]; 428 let SemaHandler = 0; 429} 430 431def MBlazeInterruptHandler : InheritableAttr { 432 let Spellings = []; 433 let SemaHandler = 0; 434} 435 436def MBlazeSaveVolatiles : InheritableAttr { 437 let Spellings = []; 438 let SemaHandler = 0; 439} 440 441def Mips16 : InheritableAttr { 442 let Spellings = [GNU<"mips16">, CXX11<"gnu", "mips16">]; 443 let Subjects = [Function]; 444} 445 446def Mode : Attr { 447 let Spellings = [GNU<"mode">, CXX11<"gnu", "mode">]; 448 let Args = [IdentifierArgument<"Mode">]; 449 let ASTNode = 0; 450} 451 452def Naked : InheritableAttr { 453 let Spellings = [GNU<"naked">, CXX11<"gnu", "naked">]; 454} 455 456def NeonPolyVectorType : Attr { 457 let Spellings = [GNU<"neon_polyvector_type">]; 458 let Args = [IntArgument<"NumElements">]; 459 let ASTNode = 0; 460} 461 462def NeonVectorType : Attr { 463 let Spellings = [GNU<"neon_vector_type">]; 464 let Args = [IntArgument<"NumElements">]; 465 let ASTNode = 0; 466} 467 468def ReturnsTwice : InheritableAttr { 469 let Spellings = [GNU<"returns_twice">, CXX11<"gnu", "returns_twice">]; 470} 471 472def NoCommon : InheritableAttr { 473 let Spellings = [GNU<"nocommon">, CXX11<"gnu", "nocommon">]; 474} 475 476def NoDebug : InheritableAttr { 477 let Spellings = [GNU<"nodebug">]; 478} 479 480def NoInline : InheritableAttr { 481 let Spellings = [GNU<"noinline">, CXX11<"gnu", "noinline">]; 482} 483 484def NoMips16 : InheritableAttr { 485 let Spellings = [GNU<"nomips16">, CXX11<"gnu", "nomips16">]; 486 let Subjects = [Function]; 487} 488 489def NonNull : InheritableAttr { 490 let Spellings = [GNU<"nonnull">, CXX11<"gnu", "nonnull">]; 491 let Args = [VariadicUnsignedArgument<"Args">]; 492 let AdditionalMembers = 493[{bool isNonNull(unsigned idx) const { 494 for (args_iterator i = args_begin(), e = args_end(); 495 i != e; ++i) 496 if (*i == idx) 497 return true; 498 return false; 499 } }]; 500} 501 502def NoReturn : InheritableAttr { 503 let Spellings = [GNU<"noreturn">, CXX11<"gnu", "noreturn">]; 504 // FIXME: Does GCC allow this on the function instead? 505 let Subjects = [Function]; 506} 507 508def NoInstrumentFunction : InheritableAttr { 509 let Spellings = [GNU<"no_instrument_function">, 510 CXX11<"gnu", "no_instrument_function">]; 511 let Subjects = [Function]; 512} 513 514def NoThrow : InheritableAttr { 515 let Spellings = [GNU<"nothrow">, CXX11<"gnu", "nothrow">]; 516} 517 518def NSBridged : InheritableAttr { 519 let Spellings = [GNU<"ns_bridged">]; 520 let Subjects = [Record]; 521 let Args = [IdentifierArgument<"BridgedType">]; 522} 523 524def NSReturnsRetained : InheritableAttr { 525 let Spellings = [GNU<"ns_returns_retained">]; 526 let Subjects = [ObjCMethod, Function]; 527} 528 529def NSReturnsNotRetained : InheritableAttr { 530 let Spellings = [GNU<"ns_returns_not_retained">]; 531 let Subjects = [ObjCMethod, Function]; 532} 533 534def NSReturnsAutoreleased : InheritableAttr { 535 let Spellings = [GNU<"ns_returns_autoreleased">]; 536 let Subjects = [ObjCMethod, Function]; 537} 538 539def NSConsumesSelf : InheritableAttr { 540 let Spellings = [GNU<"ns_consumes_self">]; 541 let Subjects = [ObjCMethod]; 542} 543 544def NSConsumed : InheritableParamAttr { 545 let Spellings = [GNU<"ns_consumed">]; 546 let Subjects = [ParmVar]; 547} 548 549def ObjCException : InheritableAttr { 550 let Spellings = [GNU<"objc_exception">]; 551} 552 553def ObjCMethodFamily : InheritableAttr { 554 let Spellings = [GNU<"objc_method_family">]; 555 let Subjects = [ObjCMethod]; 556 let Args = [EnumArgument<"Family", "FamilyKind", 557 ["none", "alloc", "copy", "init", "mutableCopy", "new"], 558 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init", 559 "OMF_mutableCopy", "OMF_new"]>]; 560} 561 562def ObjCNSObject : InheritableAttr { 563 let Spellings = [GNU<"NSObject">]; 564} 565 566def ObjCPreciseLifetime : Attr { 567 let Spellings = [GNU<"objc_precise_lifetime">]; 568 let Subjects = [Var]; 569} 570 571def ObjCReturnsInnerPointer : Attr { 572 let Spellings = [GNU<"objc_returns_inner_pointer">]; 573 let Subjects = [ObjCMethod]; 574} 575 576def ObjCRequiresSuper : InheritableAttr { 577 let Spellings = [GNU<"objc_requires_super">]; 578 let Subjects = [ObjCMethod]; 579} 580 581def ObjCRootClass : Attr { 582 let Spellings = [GNU<"objc_root_class">]; 583 let Subjects = [ObjCInterface]; 584} 585 586def Overloadable : Attr { 587 let Spellings = [GNU<"overloadable">]; 588} 589 590def Override : InheritableAttr { 591 let Spellings = []; 592 let SemaHandler = 0; 593} 594 595def Ownership : InheritableAttr { 596 let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">, 597 GNU<"ownership_takes">]; 598 let DistinctSpellings = 1; 599 let Args = [EnumArgument<"OwnKind", "OwnershipKind", 600 ["ownership_holds", "ownership_returns", "ownership_takes"], 601 ["Holds", "Returns", "Takes"]>, 602 StringArgument<"Module">, VariadicUnsignedArgument<"Args">]; 603} 604 605def Packed : InheritableAttr { 606 let Spellings = [GNU<"packed">, CXX11<"gnu", "packed">]; 607} 608 609def PnaclCall : InheritableAttr { 610 let Spellings = [GNU<"pnaclcall">]; 611} 612 613def IntelOclBicc : InheritableAttr { 614 let Spellings = [GNU<"intel_ocl_bicc">]; 615} 616 617def Pcs : InheritableAttr { 618 let Spellings = [GNU<"pcs">, CXX11<"gnu", "pcs">]; 619 let Args = [EnumArgument<"PCS", "PCSType", 620 ["aapcs", "aapcs-vfp"], 621 ["AAPCS", "AAPCS_VFP"]>]; 622} 623 624def Pure : InheritableAttr { 625 let Spellings = [GNU<"pure">, CXX11<"gnu", "pure">]; 626} 627 628def Regparm : InheritableAttr { 629 let Spellings = [GNU<"regparm">, CXX11<"gnu", "regparm">]; 630 let Args = [UnsignedArgument<"NumParams">]; 631} 632 633def ReqdWorkGroupSize : InheritableAttr { 634 let Spellings = [GNU<"reqd_work_group_size">]; 635 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">, 636 UnsignedArgument<"ZDim">]; 637} 638 639def Endian : InheritableAttr { 640 let Spellings = [GNU<"endian">]; 641 let Args = [IdentifierArgument<"platform">]; 642} 643 644def WorkGroupSizeHint : InheritableAttr { 645 let Spellings = [GNU<"work_group_size_hint">]; 646 let Args = [UnsignedArgument<"XDim">, 647 UnsignedArgument<"YDim">, 648 UnsignedArgument<"ZDim">]; 649} 650 651def InitPriority : InheritableAttr { 652 let Spellings = [GNU<"init_priority">]; 653 let Args = [UnsignedArgument<"Priority">]; 654} 655 656def Section : InheritableAttr { 657 let Spellings = [GNU<"section">, CXX11<"gnu", "section">]; 658 let Args = [StringArgument<"Name">]; 659} 660 661def Sentinel : InheritableAttr { 662 let Spellings = [GNU<"sentinel">, CXX11<"gnu", "sentinel">]; 663 let Args = [DefaultIntArgument<"Sentinel", 0>, 664 DefaultIntArgument<"NullPos", 0>]; 665} 666 667def StdCall : InheritableAttr { 668 let Spellings = [GNU<"stdcall">, CXX11<"gnu", "stdcall">, 669 Keyword<"__stdcall">, Keyword<"_stdcall">]; 670} 671 672def ThisCall : InheritableAttr { 673 let Spellings = [GNU<"thiscall">, CXX11<"gnu", "thiscall">, 674 Keyword<"__thiscall">, Keyword<"_thiscall">]; 675} 676 677def Pascal : InheritableAttr { 678 let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">]; 679} 680 681def TransparentUnion : InheritableAttr { 682 let Spellings = [GNU<"transparent_union">, CXX11<"gnu", "transparent_union">]; 683} 684 685def Unavailable : InheritableAttr { 686 let Spellings = [GNU<"unavailable">]; 687 let Args = [StringArgument<"Message">]; 688} 689 690def ArcWeakrefUnavailable : InheritableAttr { 691 let Spellings = [GNU<"objc_arc_weak_reference_unavailable">]; 692 let Subjects = [ObjCInterface]; 693} 694 695def ObjCGC : Attr { 696 let Spellings = [GNU<"objc_gc">]; 697 let Args = [IdentifierArgument<"Kind">]; 698 let ASTNode = 0; 699} 700 701def ObjCOwnership : Attr { 702 let Spellings = [GNU<"objc_ownership">]; 703 let Args = [IdentifierArgument<"Kind">]; 704 let ASTNode = 0; 705} 706 707def ObjCRequiresPropertyDefs : InheritableAttr { 708 let Spellings = [GNU<"objc_requires_property_definitions">]; 709 let Subjects = [ObjCInterface]; 710} 711 712def Unused : InheritableAttr { 713 let Spellings = [GNU<"unused">, CXX11<"gnu", "unused">]; 714} 715 716def Used : InheritableAttr { 717 let Spellings = [GNU<"used">, CXX11<"gnu", "used">]; 718} 719 720def Uuid : InheritableAttr { 721 let Spellings = [GNU<"uuid">]; 722 let Args = [StringArgument<"Guid">]; 723 let Subjects = [CXXRecord]; 724} 725 726def VectorSize : Attr { 727 let Spellings = [GNU<"vector_size">, CXX11<"gnu", "vector_size">]; 728 let Args = [ExprArgument<"NumBytes">]; 729 let ASTNode = 0; 730} 731 732def VecTypeHint : InheritableAttr { 733 let Spellings = [GNU<"vec_type_hint">]; 734 let Args = [TypeArgument<"TypeHint">, SourceLocArgument<"TypeLoc">]; 735} 736 737def Visibility : InheritableAttr { 738 let Clone = 0; 739 let Spellings = [GNU<"visibility">, CXX11<"gnu", "visibility">]; 740 let Args = [EnumArgument<"Visibility", "VisibilityType", 741 ["default", "hidden", "internal", "protected"], 742 ["Default", "Hidden", "Hidden", "Protected"]>]; 743} 744 745def TypeVisibility : InheritableAttr { 746 let Clone = 0; 747 let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">]; 748 let Args = [EnumArgument<"Visibility", "VisibilityType", 749 ["default", "hidden", "internal", "protected"], 750 ["Default", "Hidden", "Hidden", "Protected"]>]; 751} 752 753def VecReturn : InheritableAttr { 754 let Spellings = [GNU<"vecreturn">]; 755 let Subjects = [CXXRecord]; 756} 757 758def WarnUnusedResult : InheritableAttr { 759 let Spellings = [GNU<"warn_unused_result">, 760 CXX11<"clang", "warn_unused_result">, 761 CXX11<"gnu", "warn_unused_result">]; 762} 763 764def Weak : InheritableAttr { 765 let Spellings = [GNU<"weak">, CXX11<"gnu", "weak">]; 766} 767 768def WeakImport : InheritableAttr { 769 let Spellings = [GNU<"weak_import">]; 770} 771 772def WeakRef : InheritableAttr { 773 let Spellings = [GNU<"weakref">, CXX11<"gnu", "weakref">]; 774} 775 776def X86ForceAlignArgPointer : InheritableAttr { 777 let Spellings = []; 778} 779 780// Attribute to disable AddressSanitizer (or equivalent) checks. 781def NoSanitizeAddress : InheritableAttr { 782 let Spellings = [GNU<"no_address_safety_analysis">, 783 GNU<"no_sanitize_address">]; 784} 785 786// Attribute to disable ThreadSanitizer checks. 787def NoSanitizeThread : InheritableAttr { 788 let Spellings = [GNU<"no_sanitize_thread">]; 789} 790 791// Attribute to disable MemorySanitizer checks. 792def NoSanitizeMemory : InheritableAttr { 793 let Spellings = [GNU<"no_sanitize_memory">]; 794} 795 796// C/C++ Thread safety attributes (e.g. for deadlock, data race checking) 797 798def GuardedVar : InheritableAttr { 799 let Spellings = [GNU<"guarded_var">]; 800} 801 802def PtGuardedVar : InheritableAttr { 803 let Spellings = [GNU<"pt_guarded_var">]; 804} 805 806def Lockable : InheritableAttr { 807 let Spellings = [GNU<"lockable">]; 808} 809 810def ScopedLockable : InheritableAttr { 811 let Spellings = [GNU<"scoped_lockable">]; 812} 813 814def NoThreadSafetyAnalysis : InheritableAttr { 815 let Spellings = [GNU<"no_thread_safety_analysis">]; 816} 817 818def GuardedBy : InheritableAttr { 819 let Spellings = [GNU<"guarded_by">]; 820 let Args = [ExprArgument<"Arg">]; 821 let LateParsed = 1; 822 let TemplateDependent = 1; 823} 824 825def PtGuardedBy : InheritableAttr { 826 let Spellings = [GNU<"pt_guarded_by">]; 827 let Args = [ExprArgument<"Arg">]; 828 let LateParsed = 1; 829 let TemplateDependent = 1; 830} 831 832def AcquiredAfter : InheritableAttr { 833 let Spellings = [GNU<"acquired_after">]; 834 let Args = [VariadicExprArgument<"Args">]; 835 let LateParsed = 1; 836 let TemplateDependent = 1; 837} 838 839def AcquiredBefore : InheritableAttr { 840 let Spellings = [GNU<"acquired_before">]; 841 let Args = [VariadicExprArgument<"Args">]; 842 let LateParsed = 1; 843 let TemplateDependent = 1; 844} 845 846def ExclusiveLockFunction : InheritableAttr { 847 let Spellings = [GNU<"exclusive_lock_function">]; 848 let Args = [VariadicExprArgument<"Args">]; 849 let LateParsed = 1; 850 let TemplateDependent = 1; 851} 852 853def SharedLockFunction : InheritableAttr { 854 let Spellings = [GNU<"shared_lock_function">]; 855 let Args = [VariadicExprArgument<"Args">]; 856 let LateParsed = 1; 857 let TemplateDependent = 1; 858} 859 860// The first argument is an integer or boolean value specifying the return value 861// of a successful lock acquisition. 862def ExclusiveTrylockFunction : InheritableAttr { 863 let Spellings = [GNU<"exclusive_trylock_function">]; 864 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">]; 865 let LateParsed = 1; 866 let TemplateDependent = 1; 867} 868 869// The first argument is an integer or boolean value specifying the return value 870// of a successful lock acquisition. 871def SharedTrylockFunction : InheritableAttr { 872 let Spellings = [GNU<"shared_trylock_function">]; 873 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">]; 874 let LateParsed = 1; 875 let TemplateDependent = 1; 876} 877 878def UnlockFunction : InheritableAttr { 879 let Spellings = [GNU<"unlock_function">]; 880 let Args = [VariadicExprArgument<"Args">]; 881 let LateParsed = 1; 882 let TemplateDependent = 1; 883} 884 885def LockReturned : InheritableAttr { 886 let Spellings = [GNU<"lock_returned">]; 887 let Args = [ExprArgument<"Arg">]; 888 let LateParsed = 1; 889 let TemplateDependent = 1; 890} 891 892def LocksExcluded : InheritableAttr { 893 let Spellings = [GNU<"locks_excluded">]; 894 let Args = [VariadicExprArgument<"Args">]; 895 let LateParsed = 1; 896 let TemplateDependent = 1; 897} 898 899def ExclusiveLocksRequired : InheritableAttr { 900 let Spellings = [GNU<"exclusive_locks_required">]; 901 let Args = [VariadicExprArgument<"Args">]; 902 let LateParsed = 1; 903 let TemplateDependent = 1; 904} 905 906def SharedLocksRequired : InheritableAttr { 907 let Spellings = [GNU<"shared_locks_required">]; 908 let Args = [VariadicExprArgument<"Args">]; 909 let LateParsed = 1; 910 let TemplateDependent = 1; 911} 912 913// Type safety attributes for `void *' pointers and type tags. 914 915def ArgumentWithTypeTag : InheritableAttr { 916 let Spellings = [GNU<"argument_with_type_tag">, 917 GNU<"pointer_with_type_tag">]; 918 let Args = [IdentifierArgument<"ArgumentKind">, 919 UnsignedArgument<"ArgumentIdx">, 920 UnsignedArgument<"TypeTagIdx">, 921 BoolArgument<"IsPointer">]; 922 let Subjects = [Function]; 923} 924 925def TypeTagForDatatype : InheritableAttr { 926 let Spellings = [GNU<"type_tag_for_datatype">]; 927 let Args = [IdentifierArgument<"ArgumentKind">, 928 TypeArgument<"MatchingCType">, 929 BoolArgument<"LayoutCompatible">, 930 BoolArgument<"MustBeNull">]; 931 let Subjects = [Var]; 932} 933 934// Microsoft-related attributes 935 936def MsStruct : InheritableAttr { 937 let Spellings = [Declspec<"ms_struct">]; 938} 939 940def DLLExport : InheritableAttr { 941 let Spellings = [Declspec<"dllexport">]; 942} 943 944def DLLImport : InheritableAttr { 945 let Spellings = [Declspec<"dllimport">]; 946} 947 948def ForceInline : InheritableAttr { 949 let Spellings = [Keyword<"__forceinline">]; 950} 951 952def Win64 : InheritableAttr { 953 let Spellings = [Keyword<"__w64">]; 954} 955 956def Ptr32 : InheritableAttr { 957 let Spellings = [Keyword<"__ptr32">]; 958} 959 960def Ptr64 : InheritableAttr { 961 let Spellings = [Keyword<"__ptr64">]; 962} 963 964def SingleInheritance : InheritableAttr { 965 let Spellings = [Keyword<"__single_inheritance">]; 966} 967 968def MultipleInheritance : InheritableAttr { 969 let Spellings = [Keyword<"__multiple_inheritance">]; 970} 971 972def VirtualInheritance : InheritableAttr { 973 let Spellings = [Keyword<"__virtual_inheritance">]; 974} 975 976def Unaligned : IgnoredAttr { 977 let Spellings = [Keyword<"__unaligned">]; 978} 979