1//==--- Attr.td - attribute definitions -----------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 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). 14class AttrSubject; 15 16include "clang/Basic/DeclNodes.td" 17include "clang/Basic/StmtNodes.td" 18 19// A subset-subject is an AttrSubject constrained to operate only on some subset 20// of that subject. 21// 22// The description is used in output messages to specify what the subject 23// represents. FIXME: Deal with translation issues. 24// 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. 28class SubsetSubject<AttrSubject base, string description, code check> 29 : AttrSubject { 30 AttrSubject Base = base; 31 string Description = description; 32 code CheckCode = check; 33} 34 35// This is the type of a variable which C++11 allows alignas(...) to appertain 36// to. 37def 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}]>; 42def CXXVirtualMethod : SubsetSubject<CXXRecord, "virtual member function", 43 [{S->isVirtual()}]>; 44def NonBitField : SubsetSubject<Field, "non-bit field", 45 [{!S->isBitField()}]>; 46 47// A single argument to an attribute 48class Argument<string name, bit optional> { 49 string Name = name; 50 bit Optional = optional; 51} 52 53class BoolArgument<string name, bit opt = 0> : Argument<name, opt>; 54class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>; 55class IntArgument<string name, bit opt = 0> : Argument<name, opt>; 56class StringArgument<string name, bit opt = 0> : Argument<name, opt>; 57class ExprArgument<string name, bit opt = 0> : Argument<name, opt>; 58class FunctionArgument<string name, bit opt = 0> : Argument<name, opt>; 59class TypeArgument<string name, bit opt = 0> : Argument<name, opt>; 60class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>; 61class SourceLocArgument<string name, bit opt = 0> : Argument<name, opt>; 62class VariadicUnsignedArgument<string name> : Argument<name, 1>; 63class VariadicExprArgument<string name> : Argument<name, 1>; 64 65// A version of the form major.minor[.subminor]. 66class VersionArgument<string name, bit opt = 0> : Argument<name, opt>; 67 68// This one's a doozy, so it gets its own special type 69// It can be an unsigned integer, or a type. Either can 70// be dependent. 71class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>; 72 73// An integer argument with a default value 74class DefaultIntArgument<string name, int default> : IntArgument<name, 1> { 75 int Default = default; 76} 77 78// This argument is more complex, it includes the enumerator type name, 79// a list of strings to accept, and a list of enumerators to map them to. 80class EnumArgument<string name, string type, list<string> values, 81 list<string> enums, bit opt = 0> : Argument<name, opt> { 82 string Type = type; 83 list<string> Values = values; 84 list<string> Enums = enums; 85} 86 87// FIXME: There should be a VariadicArgument type that takes any other type 88// of argument and generates the appropriate type. 89class VariadicEnumArgument<string name, string type, list<string> values, 90 list<string> enums> : Argument<name, 1> { 91 string Type = type; 92 list<string> Values = values; 93 list<string> Enums = enums; 94} 95 96// This handles one spelling of an attribute. 97class Spelling<string name, string variety> { 98 string Name = name; 99 string Variety = variety; 100} 101 102class GNU<string name> : Spelling<name, "GNU">; 103class Declspec<string name> : Spelling<name, "Declspec">; 104class CXX11<string namespace, string name> : Spelling<name, "CXX11"> { 105 string Namespace = namespace; 106} 107class Keyword<string name> : Spelling<name, "Keyword">; 108 109class Accessor<string name, list<Spelling> spellings> { 110 string Name = name; 111 list<Spelling> Spellings = spellings; 112} 113 114class Attr { 115 // The various ways in which an attribute can be spelled in source 116 list<Spelling> Spellings; 117 // The things to which an attribute can appertain 118 list<AttrSubject> Subjects; 119 // The arguments allowed on an attribute 120 list<Argument> Args = []; 121 // Accessors which should be generated for the attribute. 122 list<Accessor> Accessors = []; 123 // Set to true for attributes with arguments which require delayed parsing. 124 bit LateParsed = 0; 125 // Set to false to prevent an attribute from being propagated from a template 126 // to the instantiation. 127 bit Clone = 1; 128 // Set to true for attributes which must be instantiated within templates 129 bit TemplateDependent = 0; 130 // Set to true for attributes that have a corresponding AST node. 131 bit ASTNode = 1; 132 // Set to true for attributes which have handler in Sema. 133 bit SemaHandler = 1; 134 // Set to true for attributes that are completely ignored. 135 bit Ignored = 0; 136 // Set to true if each of the spellings is a distinct attribute. 137 bit DistinctSpellings = 0; 138 // Set to true if the attribute's parsing does not match its semantic 139 // content. Eg) It parses 3 args, but semantically takes 4 args. Opts out of 140 // common attribute error checking. 141 bit HasCustomParsing = 0; 142 // Any additional text that should be included verbatim in the class. 143 code AdditionalMembers = [{}]; 144} 145 146/// A type attribute is not processed on a declaration or a statement. 147class TypeAttr : Attr { 148 let ASTNode = 0; 149} 150 151/// An inheritable attribute is inherited by later redeclarations. 152class InheritableAttr : Attr; 153 154/// A target-specific attribute that is meant to be processed via 155/// TargetAttributesSema::ProcessDeclAttribute. This class is meant to be used 156/// as a mixin with InheritableAttr or Attr depending on the attribute's needs. 157class TargetSpecificAttr; 158 159/// An inheritable parameter attribute is inherited by later 160/// redeclarations, even when it's written on a parameter. 161class InheritableParamAttr : InheritableAttr; 162 163/// An ignored attribute, which we parse but discard with no checking. 164class IgnoredAttr : Attr { 165 let Ignored = 1; 166 let ASTNode = 0; 167 let SemaHandler = 0; 168} 169 170// 171// Attributes begin here 172// 173 174def AddressSpace : TypeAttr { 175 let Spellings = [GNU<"address_space">]; 176 let Args = [IntArgument<"AddressSpace">]; 177} 178 179def Alias : Attr { 180 let Spellings = [GNU<"alias">, CXX11<"gnu", "alias">]; 181 let Args = [StringArgument<"Aliasee">]; 182} 183 184def Aligned : InheritableAttr { 185 let Spellings = [GNU<"aligned">, Declspec<"align">, CXX11<"gnu", "aligned">, 186 Keyword<"alignas">, Keyword<"_Alignas">]; 187 let Subjects = [NonBitField, NormalVar, Tag]; 188 let Args = [AlignedArgument<"Alignment", 1>]; 189 let Accessors = [Accessor<"isGNU", [GNU<"aligned">, CXX11<"gnu","aligned">]>, 190 Accessor<"isC11", [Keyword<"_Alignas">]>, 191 Accessor<"isAlignas", [Keyword<"alignas">, 192 Keyword<"_Alignas">]>, 193 Accessor<"isDeclspec",[Declspec<"align">]>]; 194} 195 196def AlignMac68k : InheritableAttr { 197 let Spellings = []; 198 let SemaHandler = 0; 199} 200 201def AllocSize : InheritableAttr { 202 let Spellings = [GNU<"alloc_size">, CXX11<"gnu", "alloc_size">]; 203 let Args = [VariadicUnsignedArgument<"Args">]; 204} 205 206def AlwaysInline : InheritableAttr { 207 let Spellings = [GNU<"always_inline">, CXX11<"gnu", "always_inline">]; 208} 209 210def TLSModel : InheritableAttr { 211 let Spellings = [GNU<"tls_model">, CXX11<"gnu", "tls_model">]; 212 let Subjects = [Var]; 213 let Args = [StringArgument<"Model">]; 214} 215 216def AnalyzerNoReturn : InheritableAttr { 217 let Spellings = [GNU<"analyzer_noreturn">]; 218} 219 220def Annotate : InheritableParamAttr { 221 let Spellings = [GNU<"annotate">]; 222 let Args = [StringArgument<"Annotation">]; 223} 224 225def ARMInterrupt : InheritableAttr, TargetSpecificAttr { 226 let Spellings = [GNU<"interrupt">]; 227 let Args = [EnumArgument<"Interrupt", "InterruptType", 228 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""], 229 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"], 230 1>]; 231} 232 233def AsmLabel : InheritableAttr { 234 let Spellings = []; 235 let Args = [StringArgument<"Label">]; 236 let SemaHandler = 0; 237} 238 239def Availability : InheritableAttr { 240 let Spellings = [GNU<"availability">]; 241 let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">, 242 VersionArgument<"deprecated">, VersionArgument<"obsoleted">, 243 BoolArgument<"unavailable">, StringArgument<"message">]; 244 let AdditionalMembers = 245[{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) { 246 return llvm::StringSwitch<llvm::StringRef>(Platform) 247 .Case("ios", "iOS") 248 .Case("macosx", "OS X") 249 .Default(llvm::StringRef()); 250} }]; 251 let HasCustomParsing = 1; 252} 253 254def Blocks : InheritableAttr { 255 let Spellings = [GNU<"blocks">]; 256 let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>]; 257} 258 259def Bounded : IgnoredAttr { 260 let Spellings = [GNU<"bounded">]; 261} 262 263def CarriesDependency : InheritableParamAttr { 264 let Spellings = [GNU<"carries_dependency">, CXX11<"","carries_dependency">, 265 CXX11<"std","carries_dependency">]; 266 let Subjects = [ParmVar, Function]; 267} 268 269def CDecl : InheritableAttr { 270 let Spellings = [GNU<"cdecl">, CXX11<"gnu", "cdecl">, Keyword<"__cdecl">, 271 Keyword<"_cdecl">]; 272} 273 274// cf_audited_transfer indicates that the given function has been 275// audited and has been marked with the appropriate cf_consumed and 276// cf_returns_retained attributes. It is generally applied by 277// '#pragma clang arc_cf_code_audited' rather than explicitly. 278def CFAuditedTransfer : InheritableAttr { 279 let Spellings = [GNU<"cf_audited_transfer">]; 280 let Subjects = [Function]; 281} 282 283// cf_unknown_transfer is an explicit opt-out of cf_audited_transfer. 284// It indicates that the function has unknown or unautomatable 285// transfer semantics. 286def CFUnknownTransfer : InheritableAttr { 287 let Spellings = [GNU<"cf_unknown_transfer">]; 288 let Subjects = [Function]; 289} 290 291def CFReturnsRetained : InheritableAttr { 292 let Spellings = [GNU<"cf_returns_retained">]; 293 let Subjects = [ObjCMethod, Function]; 294} 295 296def CFReturnsNotRetained : InheritableAttr { 297 let Spellings = [GNU<"cf_returns_not_retained">]; 298 let Subjects = [ObjCMethod, Function]; 299} 300 301def CFConsumed : InheritableParamAttr { 302 let Spellings = [GNU<"cf_consumed">]; 303 let Subjects = [ParmVar]; 304} 305 306def Cleanup : InheritableAttr { 307 let Spellings = [GNU<"cleanup">, CXX11<"gnu", "cleanup">]; 308 let Args = [FunctionArgument<"FunctionDecl">]; 309} 310 311def Cold : InheritableAttr { 312 let Spellings = [GNU<"cold">, CXX11<"gnu", "cold">]; 313} 314 315def Common : InheritableAttr { 316 let Spellings = [GNU<"common">, CXX11<"gnu", "common">]; 317} 318 319def Const : InheritableAttr { 320 let Spellings = [GNU<"const">, GNU<"__const">, 321 CXX11<"gnu", "const">, CXX11<"gnu", "__const">]; 322} 323 324def Constructor : InheritableAttr { 325 let Spellings = [GNU<"constructor">, CXX11<"gnu", "constructor">]; 326 let Args = [IntArgument<"Priority", 1>]; 327} 328 329def CUDAConstant : InheritableAttr { 330 let Spellings = [GNU<"constant">]; 331} 332 333def CUDADevice : InheritableAttr { 334 let Spellings = [GNU<"device">]; 335} 336 337def CUDAGlobal : InheritableAttr { 338 let Spellings = [GNU<"global">]; 339} 340 341def CUDAHost : InheritableAttr { 342 let Spellings = [GNU<"host">]; 343} 344 345def CUDALaunchBounds : InheritableAttr { 346 let Spellings = [GNU<"launch_bounds">]; 347 let Args = [IntArgument<"MaxThreads">, DefaultIntArgument<"MinBlocks", 0>]; 348} 349 350def CUDAShared : InheritableAttr { 351 let Spellings = [GNU<"shared">]; 352} 353 354def C11NoReturn : InheritableAttr { 355 let Spellings = [Keyword<"_Noreturn">]; 356 let Subjects = [Function]; 357 let SemaHandler = 0; 358} 359 360def CXX11NoReturn : InheritableAttr { 361 let Spellings = [CXX11<"","noreturn">, CXX11<"std","noreturn">]; 362 let Subjects = [Function]; 363} 364 365def OpenCLKernel : InheritableAttr { 366 let Spellings = [Keyword<"__kernel">, Keyword<"kernel">]; 367} 368 369def OpenCLImageAccess : Attr { 370 let Spellings = [GNU<"opencl_image_access">]; 371 let Args = [IntArgument<"Access">]; 372} 373 374def Deprecated : InheritableAttr { 375 let Spellings = [GNU<"deprecated">, 376 CXX11<"gnu", "deprecated">, CXX11<"","deprecated">]; 377 let Args = [StringArgument<"Message", 1>]; 378} 379 380def Destructor : InheritableAttr { 381 let Spellings = [GNU<"destructor">, CXX11<"gnu", "destructor">]; 382 let Args = [IntArgument<"Priority", 1>]; 383} 384 385def ExtVectorType : Attr { 386 let Spellings = [GNU<"ext_vector_type">]; 387 let Args = [ExprArgument<"NumElements">]; 388 let ASTNode = 0; 389} 390 391def FallThrough : Attr { 392 let Spellings = [CXX11<"clang", "fallthrough">]; 393 let Subjects = [NullStmt]; 394} 395 396def FastCall : InheritableAttr { 397 let Spellings = [GNU<"fastcall">, CXX11<"gnu", "fastcall">, 398 Keyword<"__fastcall">, Keyword<"_fastcall">]; 399} 400 401def Final : InheritableAttr { 402 let Spellings = [Keyword<"final">, Keyword<"sealed">]; 403 let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>]; 404 let SemaHandler = 0; 405} 406 407def MinSize : InheritableAttr { 408 let Spellings = [GNU<"minsize">]; 409 let Subjects = [Function]; 410} 411 412def Format : InheritableAttr { 413 let Spellings = [GNU<"format">, CXX11<"gnu", "format">]; 414 let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">, 415 IntArgument<"FirstArg">]; 416} 417 418def FormatArg : InheritableAttr { 419 let Spellings = [GNU<"format_arg">, CXX11<"gnu", "format_arg">]; 420 let Args = [IntArgument<"FormatIdx">]; 421} 422 423def GNUInline : InheritableAttr { 424 let Spellings = [GNU<"gnu_inline">, CXX11<"gnu", "gnu_inline">]; 425} 426 427def Hot : InheritableAttr { 428 let Spellings = [GNU<"hot">, CXX11<"gnu", "hot">]; 429} 430 431def IBAction : InheritableAttr { 432 let Spellings = [GNU<"ibaction">]; 433} 434 435def IBOutlet : InheritableAttr { 436 let Spellings = [GNU<"iboutlet">]; 437} 438 439def IBOutletCollection : InheritableAttr { 440 let Spellings = [GNU<"iboutletcollection">]; 441 let Args = [TypeArgument<"Interface", 1>]; 442} 443 444def Malloc : InheritableAttr { 445 let Spellings = [GNU<"malloc">, CXX11<"gnu", "malloc">]; 446} 447 448def MaxFieldAlignment : InheritableAttr { 449 let Spellings = []; 450 let Args = [UnsignedArgument<"Alignment">]; 451 let SemaHandler = 0; 452} 453 454def MayAlias : InheritableAttr { 455 let Spellings = [GNU<"may_alias">, CXX11<"gnu", "may_alias">]; 456} 457 458def MSABI : InheritableAttr { 459 let Spellings = [GNU<"ms_abi">, CXX11<"gnu", "ms_abi">]; 460} 461 462def MSP430Interrupt : InheritableAttr, TargetSpecificAttr { 463 let Spellings = []; 464 let Args = [UnsignedArgument<"Number">]; 465 let SemaHandler = 0; 466} 467 468def Mips16 : InheritableAttr, TargetSpecificAttr { 469 let Spellings = [GNU<"mips16">, CXX11<"gnu", "mips16">]; 470 let Subjects = [Function]; 471} 472 473def Mode : Attr { 474 let Spellings = [GNU<"mode">, CXX11<"gnu", "mode">]; 475 let Args = [IdentifierArgument<"Mode">]; 476} 477 478def Naked : InheritableAttr { 479 let Spellings = [GNU<"naked">, CXX11<"gnu", "naked">]; 480} 481 482def NeonPolyVectorType : TypeAttr { 483 let Spellings = [GNU<"neon_polyvector_type">]; 484 let Args = [IntArgument<"NumElements">]; 485} 486 487def NeonVectorType : TypeAttr { 488 let Spellings = [GNU<"neon_vector_type">]; 489 let Args = [IntArgument<"NumElements">]; 490} 491 492def ReturnsTwice : InheritableAttr { 493 let Spellings = [GNU<"returns_twice">, CXX11<"gnu", "returns_twice">]; 494} 495 496def NoCommon : InheritableAttr { 497 let Spellings = [GNU<"nocommon">, CXX11<"gnu", "nocommon">]; 498} 499 500def NoDebug : InheritableAttr { 501 let Spellings = [GNU<"nodebug">]; 502} 503 504def NoInline : InheritableAttr { 505 let Spellings = [GNU<"noinline">, CXX11<"gnu", "noinline">]; 506} 507 508def NoMips16 : InheritableAttr, TargetSpecificAttr { 509 let Spellings = [GNU<"nomips16">, CXX11<"gnu", "nomips16">]; 510 let Subjects = [Function]; 511} 512 513def NonNull : InheritableAttr { 514 let Spellings = [GNU<"nonnull">, CXX11<"gnu", "nonnull">]; 515 let Args = [VariadicUnsignedArgument<"Args">]; 516 let AdditionalMembers = 517[{bool isNonNull(unsigned idx) const { 518 for (args_iterator i = args_begin(), e = args_end(); 519 i != e; ++i) 520 if (*i == idx) 521 return true; 522 return false; 523 } }]; 524} 525 526def NoReturn : InheritableAttr { 527 let Spellings = [GNU<"noreturn">, CXX11<"gnu", "noreturn">]; 528 // FIXME: Does GCC allow this on the function instead? 529 let Subjects = [Function]; 530} 531 532def NoInstrumentFunction : InheritableAttr { 533 let Spellings = [GNU<"no_instrument_function">, 534 CXX11<"gnu", "no_instrument_function">]; 535 let Subjects = [Function]; 536} 537 538def NoThrow : InheritableAttr { 539 let Spellings = [GNU<"nothrow">, CXX11<"gnu", "nothrow">]; 540} 541 542def NSBridged : InheritableAttr { 543 let Spellings = [GNU<"ns_bridged">]; 544 let Subjects = [Record]; 545 let Args = [IdentifierArgument<"BridgedType", 1>]; 546} 547 548def ObjCBridge : InheritableAttr { 549 let Spellings = [GNU<"objc_bridge">]; 550 let Subjects = [Record]; 551 let Args = [IdentifierArgument<"BridgedType", 1>]; 552} 553 554def NSReturnsRetained : InheritableAttr { 555 let Spellings = [GNU<"ns_returns_retained">]; 556 let Subjects = [ObjCMethod, Function]; 557} 558 559def NSReturnsNotRetained : InheritableAttr { 560 let Spellings = [GNU<"ns_returns_not_retained">]; 561 let Subjects = [ObjCMethod, Function]; 562} 563 564def NSReturnsAutoreleased : InheritableAttr { 565 let Spellings = [GNU<"ns_returns_autoreleased">]; 566 let Subjects = [ObjCMethod, Function]; 567} 568 569def NSConsumesSelf : InheritableAttr { 570 let Spellings = [GNU<"ns_consumes_self">]; 571 let Subjects = [ObjCMethod]; 572} 573 574def NSConsumed : InheritableParamAttr { 575 let Spellings = [GNU<"ns_consumed">]; 576 let Subjects = [ParmVar]; 577} 578 579def ObjCException : InheritableAttr { 580 let Spellings = [GNU<"objc_exception">]; 581} 582 583def ObjCMethodFamily : InheritableAttr { 584 let Spellings = [GNU<"objc_method_family">]; 585 let Subjects = [ObjCMethod]; 586 let Args = [EnumArgument<"Family", "FamilyKind", 587 ["none", "alloc", "copy", "init", "mutableCopy", "new"], 588 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init", 589 "OMF_mutableCopy", "OMF_new"]>]; 590} 591 592def ObjCNSObject : InheritableAttr { 593 let Spellings = [GNU<"NSObject">]; 594} 595 596def ObjCPreciseLifetime : InheritableAttr { 597 let Spellings = [GNU<"objc_precise_lifetime">]; 598 let Subjects = [Var]; 599} 600 601def ObjCReturnsInnerPointer : InheritableAttr { 602 let Spellings = [GNU<"objc_returns_inner_pointer">]; 603 let Subjects = [ObjCMethod, ObjCProperty]; 604} 605 606def ObjCRequiresSuper : InheritableAttr { 607 let Spellings = [GNU<"objc_requires_super">]; 608 let Subjects = [ObjCMethod]; 609} 610 611def ObjCRootClass : InheritableAttr { 612 let Spellings = [GNU<"objc_root_class">]; 613 let Subjects = [ObjCInterface]; 614} 615 616def Overloadable : Attr { 617 let Spellings = [GNU<"overloadable">]; 618} 619 620def Override : InheritableAttr { 621 let Spellings = []; 622 let SemaHandler = 0; 623} 624 625def Ownership : InheritableAttr { 626 let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">, 627 GNU<"ownership_takes">]; 628 let DistinctSpellings = 1; 629 let Args = [EnumArgument<"OwnKind", "OwnershipKind", 630 ["ownership_holds", "ownership_returns", "ownership_takes"], 631 ["Holds", "Returns", "Takes"]>, 632 StringArgument<"Module">, VariadicUnsignedArgument<"Args">]; 633 let HasCustomParsing = 1; 634} 635 636def Packed : InheritableAttr { 637 let Spellings = [GNU<"packed">, CXX11<"gnu", "packed">]; 638} 639 640def PnaclCall : InheritableAttr { 641 let Spellings = [GNU<"pnaclcall">]; 642} 643 644def IntelOclBicc : InheritableAttr { 645 let Spellings = [GNU<"intel_ocl_bicc">]; 646} 647 648def Pcs : InheritableAttr { 649 let Spellings = [GNU<"pcs">, CXX11<"gnu", "pcs">]; 650 let Args = [EnumArgument<"PCS", "PCSType", 651 ["aapcs", "aapcs-vfp"], 652 ["AAPCS", "AAPCS_VFP"]>]; 653} 654 655def Pure : InheritableAttr { 656 let Spellings = [GNU<"pure">, CXX11<"gnu", "pure">]; 657} 658 659def Regparm : InheritableAttr { 660 let Spellings = [GNU<"regparm">, CXX11<"gnu", "regparm">]; 661 let Args = [UnsignedArgument<"NumParams">]; 662} 663 664def ReqdWorkGroupSize : InheritableAttr { 665 let Spellings = [GNU<"reqd_work_group_size">]; 666 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">, 667 UnsignedArgument<"ZDim">]; 668} 669 670def WorkGroupSizeHint : InheritableAttr { 671 let Spellings = [GNU<"work_group_size_hint">]; 672 let Args = [UnsignedArgument<"XDim">, 673 UnsignedArgument<"YDim">, 674 UnsignedArgument<"ZDim">]; 675} 676 677def InitPriority : InheritableAttr { 678 let Spellings = [GNU<"init_priority">]; 679 let Args = [UnsignedArgument<"Priority">]; 680} 681 682def Section : InheritableAttr { 683 let Spellings = [GNU<"section">, CXX11<"gnu", "section">]; 684 let Args = [StringArgument<"Name">]; 685} 686 687def Sentinel : InheritableAttr { 688 let Spellings = [GNU<"sentinel">, CXX11<"gnu", "sentinel">]; 689 let Args = [DefaultIntArgument<"Sentinel", 0>, 690 DefaultIntArgument<"NullPos", 0>]; 691} 692 693def StdCall : InheritableAttr { 694 let Spellings = [GNU<"stdcall">, CXX11<"gnu", "stdcall">, 695 Keyword<"__stdcall">, Keyword<"_stdcall">]; 696} 697 698def SysVABI : InheritableAttr { 699 let Spellings = [GNU<"sysv_abi">, CXX11<"gnu", "sysv_abi">]; 700} 701 702def ThisCall : InheritableAttr { 703 let Spellings = [GNU<"thiscall">, CXX11<"gnu", "thiscall">, 704 Keyword<"__thiscall">, Keyword<"_thiscall">]; 705} 706 707def Pascal : InheritableAttr { 708 let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">]; 709} 710 711def TransparentUnion : InheritableAttr { 712 let Spellings = [GNU<"transparent_union">, CXX11<"gnu", "transparent_union">]; 713} 714 715def Unavailable : InheritableAttr { 716 let Spellings = [GNU<"unavailable">]; 717 let Args = [StringArgument<"Message", 1>]; 718} 719 720def ArcWeakrefUnavailable : InheritableAttr { 721 let Spellings = [GNU<"objc_arc_weak_reference_unavailable">]; 722 let Subjects = [ObjCInterface]; 723} 724 725def ObjCGC : TypeAttr { 726 let Spellings = [GNU<"objc_gc">]; 727 let Args = [IdentifierArgument<"Kind">]; 728} 729 730def ObjCOwnership : InheritableAttr { 731 let Spellings = [GNU<"objc_ownership">]; 732 let Args = [IdentifierArgument<"Kind">]; 733 let ASTNode = 0; 734} 735 736def ObjCRequiresPropertyDefs : InheritableAttr { 737 let Spellings = [GNU<"objc_requires_property_definitions">]; 738 let Subjects = [ObjCInterface]; 739} 740 741def Unused : InheritableAttr { 742 let Spellings = [GNU<"unused">, CXX11<"gnu", "unused">]; 743} 744 745def Used : InheritableAttr { 746 let Spellings = [GNU<"used">, CXX11<"gnu", "used">]; 747} 748 749def Uuid : InheritableAttr { 750 let Spellings = [GNU<"uuid">]; 751 let Args = [StringArgument<"Guid">]; 752 let Subjects = [CXXRecord]; 753} 754 755def VectorSize : TypeAttr { 756 let Spellings = [GNU<"vector_size">, CXX11<"gnu", "vector_size">]; 757 let Args = [ExprArgument<"NumBytes">]; 758} 759 760def VecTypeHint : InheritableAttr { 761 let Spellings = [GNU<"vec_type_hint">]; 762 let Args = [TypeArgument<"TypeHint">]; 763} 764 765def Visibility : InheritableAttr { 766 let Clone = 0; 767 let Spellings = [GNU<"visibility">, CXX11<"gnu", "visibility">]; 768 let Args = [EnumArgument<"Visibility", "VisibilityType", 769 ["default", "hidden", "internal", "protected"], 770 ["Default", "Hidden", "Hidden", "Protected"]>]; 771} 772 773def TypeVisibility : InheritableAttr { 774 let Clone = 0; 775 let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">]; 776 let Args = [EnumArgument<"Visibility", "VisibilityType", 777 ["default", "hidden", "internal", "protected"], 778 ["Default", "Hidden", "Hidden", "Protected"]>]; 779} 780 781def VecReturn : InheritableAttr { 782 let Spellings = [GNU<"vecreturn">]; 783 let Subjects = [CXXRecord]; 784} 785 786def WarnUnused : InheritableAttr { 787 let Spellings = [GNU<"warn_unused">]; 788 let Subjects = [Record]; 789} 790 791def WarnUnusedResult : InheritableAttr { 792 let Spellings = [GNU<"warn_unused_result">, 793 CXX11<"clang", "warn_unused_result">, 794 CXX11<"gnu", "warn_unused_result">]; 795} 796 797def Weak : InheritableAttr { 798 let Spellings = [GNU<"weak">, CXX11<"gnu", "weak">]; 799} 800 801def WeakImport : InheritableAttr { 802 let Spellings = [GNU<"weak_import">]; 803} 804 805def WeakRef : InheritableAttr { 806 let Spellings = [GNU<"weakref">, CXX11<"gnu", "weakref">]; 807 // A WeakRef that has an argument is treated as being an AliasAttr 808 let Args = [StringArgument<"Aliasee", 1>]; 809} 810 811def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr { 812 let Spellings = []; 813} 814 815// Attribute to disable AddressSanitizer (or equivalent) checks. 816def NoSanitizeAddress : InheritableAttr { 817 let Spellings = [GNU<"no_address_safety_analysis">, 818 GNU<"no_sanitize_address">, 819 CXX11<"gnu", "no_address_safety_analysis">, 820 CXX11<"gnu", "no_sanitize_address">]; 821} 822 823// Attribute to disable ThreadSanitizer checks. 824def NoSanitizeThread : InheritableAttr { 825 let Spellings = [GNU<"no_sanitize_thread">]; 826} 827 828// Attribute to disable MemorySanitizer checks. 829def NoSanitizeMemory : InheritableAttr { 830 let Spellings = [GNU<"no_sanitize_memory">]; 831} 832 833// C/C++ Thread safety attributes (e.g. for deadlock, data race checking) 834 835def GuardedVar : InheritableAttr { 836 let Spellings = [GNU<"guarded_var">]; 837} 838 839def PtGuardedVar : InheritableAttr { 840 let Spellings = [GNU<"pt_guarded_var">]; 841} 842 843def Lockable : InheritableAttr { 844 let Spellings = [GNU<"lockable">]; 845} 846 847def ScopedLockable : InheritableAttr { 848 let Spellings = [GNU<"scoped_lockable">]; 849} 850 851def NoThreadSafetyAnalysis : InheritableAttr { 852 let Spellings = [GNU<"no_thread_safety_analysis">]; 853} 854 855def GuardedBy : InheritableAttr { 856 let Spellings = [GNU<"guarded_by">]; 857 let Args = [ExprArgument<"Arg">]; 858 let LateParsed = 1; 859 let TemplateDependent = 1; 860} 861 862def PtGuardedBy : InheritableAttr { 863 let Spellings = [GNU<"pt_guarded_by">]; 864 let Args = [ExprArgument<"Arg">]; 865 let LateParsed = 1; 866 let TemplateDependent = 1; 867} 868 869def AcquiredAfter : InheritableAttr { 870 let Spellings = [GNU<"acquired_after">]; 871 let Args = [VariadicExprArgument<"Args">]; 872 let LateParsed = 1; 873 let TemplateDependent = 1; 874} 875 876def AcquiredBefore : InheritableAttr { 877 let Spellings = [GNU<"acquired_before">]; 878 let Args = [VariadicExprArgument<"Args">]; 879 let LateParsed = 1; 880 let TemplateDependent = 1; 881} 882 883def ExclusiveLockFunction : InheritableAttr { 884 let Spellings = [GNU<"exclusive_lock_function">]; 885 let Args = [VariadicExprArgument<"Args">]; 886 let LateParsed = 1; 887 let TemplateDependent = 1; 888} 889 890def SharedLockFunction : InheritableAttr { 891 let Spellings = [GNU<"shared_lock_function">]; 892 let Args = [VariadicExprArgument<"Args">]; 893 let LateParsed = 1; 894 let TemplateDependent = 1; 895} 896 897def AssertExclusiveLock : InheritableAttr { 898 let Spellings = [GNU<"assert_exclusive_lock">]; 899 let Args = [VariadicExprArgument<"Args">]; 900 let LateParsed = 1; 901 let TemplateDependent = 1; 902} 903 904def AssertSharedLock : InheritableAttr { 905 let Spellings = [GNU<"assert_shared_lock">]; 906 let Args = [VariadicExprArgument<"Args">]; 907 let LateParsed = 1; 908 let TemplateDependent = 1; 909} 910 911// The first argument is an integer or boolean value specifying the return value 912// of a successful lock acquisition. 913def ExclusiveTrylockFunction : InheritableAttr { 914 let Spellings = [GNU<"exclusive_trylock_function">]; 915 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">]; 916 let LateParsed = 1; 917 let TemplateDependent = 1; 918} 919 920// The first argument is an integer or boolean value specifying the return value 921// of a successful lock acquisition. 922def SharedTrylockFunction : InheritableAttr { 923 let Spellings = [GNU<"shared_trylock_function">]; 924 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">]; 925 let LateParsed = 1; 926 let TemplateDependent = 1; 927} 928 929def UnlockFunction : InheritableAttr { 930 let Spellings = [GNU<"unlock_function">]; 931 let Args = [VariadicExprArgument<"Args">]; 932 let LateParsed = 1; 933 let TemplateDependent = 1; 934} 935 936def LockReturned : InheritableAttr { 937 let Spellings = [GNU<"lock_returned">]; 938 let Args = [ExprArgument<"Arg">]; 939 let LateParsed = 1; 940 let TemplateDependent = 1; 941} 942 943def LocksExcluded : InheritableAttr { 944 let Spellings = [GNU<"locks_excluded">]; 945 let Args = [VariadicExprArgument<"Args">]; 946 let LateParsed = 1; 947 let TemplateDependent = 1; 948} 949 950def ExclusiveLocksRequired : InheritableAttr { 951 let Spellings = [GNU<"exclusive_locks_required">]; 952 let Args = [VariadicExprArgument<"Args">]; 953 let LateParsed = 1; 954 let TemplateDependent = 1; 955} 956 957def SharedLocksRequired : InheritableAttr { 958 let Spellings = [GNU<"shared_locks_required">]; 959 let Args = [VariadicExprArgument<"Args">]; 960 let LateParsed = 1; 961 let TemplateDependent = 1; 962} 963 964// C/C++ consumed attributes. 965 966def Consumable : InheritableAttr { 967 let Spellings = [GNU<"consumable">]; 968 let Subjects = [CXXRecord]; 969 let Args = [EnumArgument<"DefaultState", "ConsumedState", 970 ["unknown", "consumed", "unconsumed"], 971 ["Unknown", "Consumed", "Unconsumed"]>]; 972} 973 974def CallableWhen : InheritableAttr { 975 let Spellings = [GNU<"callable_when">]; 976 let Subjects = [CXXMethod]; 977 let Args = [VariadicEnumArgument<"CallableState", "ConsumedState", 978 ["unknown", "consumed", "unconsumed"], 979 ["Unknown", "Consumed", "Unconsumed"]>]; 980} 981 982def ParamTypestate : InheritableAttr { 983 let Spellings = [GNU<"param_typestate">]; 984 let Subjects = [ParmVar]; 985 let Args = [EnumArgument<"ParamState", "ConsumedState", 986 ["unknown", "consumed", "unconsumed"], 987 ["Unknown", "Consumed", "Unconsumed"]>]; 988} 989 990def ReturnTypestate : InheritableAttr { 991 let Spellings = [GNU<"return_typestate">]; 992 let Subjects = [Function, ParmVar]; 993 let Args = [EnumArgument<"State", "ConsumedState", 994 ["unknown", "consumed", "unconsumed"], 995 ["Unknown", "Consumed", "Unconsumed"]>]; 996} 997 998def SetTypestate : InheritableAttr { 999 let Spellings = [GNU<"set_typestate">]; 1000 let Subjects = [CXXMethod]; 1001 let Args = [EnumArgument<"NewState", "ConsumedState", 1002 ["unknown", "consumed", "unconsumed"], 1003 ["Unknown", "Consumed", "Unconsumed"]>]; 1004} 1005 1006def TestTypestate : InheritableAttr { 1007 let Spellings = [GNU<"test_typestate">]; 1008 let Subjects = [CXXMethod]; 1009 let Args = [EnumArgument<"TestState", "ConsumedState", 1010 ["consumed", "unconsumed"], 1011 ["Consumed", "Unconsumed"]>]; 1012} 1013 1014// Type safety attributes for `void *' pointers and type tags. 1015 1016def ArgumentWithTypeTag : InheritableAttr { 1017 let Spellings = [GNU<"argument_with_type_tag">, 1018 GNU<"pointer_with_type_tag">]; 1019 let Args = [IdentifierArgument<"ArgumentKind">, 1020 UnsignedArgument<"ArgumentIdx">, 1021 UnsignedArgument<"TypeTagIdx">, 1022 BoolArgument<"IsPointer">]; 1023 let Subjects = [Function]; 1024 let HasCustomParsing = 1; 1025} 1026 1027def TypeTagForDatatype : InheritableAttr { 1028 let Spellings = [GNU<"type_tag_for_datatype">]; 1029 let Args = [IdentifierArgument<"ArgumentKind">, 1030 TypeArgument<"MatchingCType">, 1031 BoolArgument<"LayoutCompatible">, 1032 BoolArgument<"MustBeNull">]; 1033 let Subjects = [Var]; 1034 let HasCustomParsing = 1; 1035} 1036 1037// Microsoft-related attributes 1038 1039def MsProperty : IgnoredAttr { 1040 let Spellings = [Declspec<"property">]; 1041} 1042 1043def MsStruct : InheritableAttr { 1044 let Spellings = [Declspec<"ms_struct">]; 1045} 1046 1047def DLLExport : InheritableAttr, TargetSpecificAttr { 1048 let Spellings = [Declspec<"dllexport">]; 1049} 1050 1051def DLLImport : InheritableAttr, TargetSpecificAttr { 1052 let Spellings = [Declspec<"dllimport">]; 1053} 1054 1055def ForceInline : InheritableAttr { 1056 let Spellings = [Keyword<"__forceinline">]; 1057} 1058 1059def SelectAny : InheritableAttr { 1060 let Spellings = [Declspec<"selectany">]; 1061} 1062 1063def Win64 : InheritableAttr { 1064 let Spellings = [Keyword<"__w64">]; 1065} 1066 1067def Ptr32 : TypeAttr { 1068 let Spellings = [Keyword<"__ptr32">]; 1069} 1070 1071def Ptr64 : TypeAttr { 1072 let Spellings = [Keyword<"__ptr64">]; 1073} 1074 1075def SPtr : TypeAttr { 1076 let Spellings = [Keyword<"__sptr">]; 1077} 1078 1079def UPtr : TypeAttr { 1080 let Spellings = [Keyword<"__uptr">]; 1081} 1082 1083class MSInheritanceAttr : InheritableAttr; 1084 1085def SingleInheritance : MSInheritanceAttr { 1086 let Spellings = [Keyword<"__single_inheritance">]; 1087} 1088 1089def MultipleInheritance : MSInheritanceAttr { 1090 let Spellings = [Keyword<"__multiple_inheritance">]; 1091} 1092 1093def VirtualInheritance : MSInheritanceAttr { 1094 let Spellings = [Keyword<"__virtual_inheritance">]; 1095} 1096 1097// This attribute doesn't have any spellings, but we can apply it implicitly to 1098// incomplete types that lack any of the other attributes. 1099def UnspecifiedInheritance : MSInheritanceAttr { 1100 let Spellings = []; 1101} 1102 1103def Unaligned : IgnoredAttr { 1104 let Spellings = [Keyword<"__unaligned">]; 1105} 1106