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// The documentation is organized by category. Attributes can have category- 11// specific documentation that is collated within the larger document. 12class DocumentationCategory<string name> { 13 string Name = name; 14 code Content = [{}]; 15} 16def DocCatFunction : DocumentationCategory<"Function Attributes">; 17def DocCatVariable : DocumentationCategory<"Variable Attributes">; 18def DocCatType : DocumentationCategory<"Type Attributes">; 19def DocCatStmt : DocumentationCategory<"Statement Attributes">; 20// Attributes listed under the Undocumented category do not generate any public 21// documentation. Ideally, this category should be used for internal-only 22// attributes which contain no spellings. 23def DocCatUndocumented : DocumentationCategory<"Undocumented">; 24 25class DocDeprecated<string replacement = ""> { 26 // If the Replacement field is empty, no replacement will be listed with the 27 // documentation. Otherwise, the documentation will specify the attribute has 28 // been superseded by this replacement. 29 string Replacement = replacement; 30} 31 32// Specifies the documentation to be associated with the given category. 33class Documentation { 34 DocumentationCategory Category; 35 code Content; 36 37 // If the heading is empty, one may be picked automatically. If the attribute 38 // only has one spelling, no heading is required as the attribute's sole 39 // spelling is sufficient. If all spellings are semantically common, the 40 // heading will be the semantic spelling. If the spellings are not 41 // semantically common and no heading is provided, an error will be emitted. 42 string Heading = ""; 43 44 // When set, specifies that the attribute is deprecated and can optionally 45 // specify a replacement attribute. 46 DocDeprecated Deprecated; 47} 48 49// Specifies that the attribute is explicitly undocumented. This can be a 50// helpful placeholder for the attribute while working on the implementation, 51// but should not be used once feature work has been completed. 52def Undocumented : Documentation { 53 let Category = DocCatUndocumented; 54} 55 56include "clang/Basic/AttrDocs.td" 57 58// An attribute's subject is whatever it appertains to. In this file, it is 59// more accurately a list of things that an attribute can appertain to. All 60// Decls and Stmts are possibly AttrSubjects (even though the syntax may not 61// allow attributes on a given Decl or Stmt). 62class AttrSubject; 63 64include "clang/Basic/DeclNodes.td" 65include "clang/Basic/StmtNodes.td" 66 67// A subset-subject is an AttrSubject constrained to operate only on some subset 68// of that subject. 69// 70// The code fragment is a boolean expression that will confirm that the subject 71// meets the requirements; the subject will have the name S, and will have the 72// type specified by the base. It should be a simple boolean expression. 73class SubsetSubject<AttrSubject base, code check> : AttrSubject { 74 AttrSubject Base = base; 75 code CheckCode = check; 76} 77 78// This is the type of a variable which C++11 allows alignas(...) to appertain 79// to. 80def NormalVar : SubsetSubject<Var, 81 [{S->getStorageClass() != VarDecl::Register && 82 S->getKind() != Decl::ImplicitParam && 83 S->getKind() != Decl::ParmVar && 84 S->getKind() != Decl::NonTypeTemplateParm}]>; 85def NonBitField : SubsetSubject<Field, 86 [{!S->isBitField()}]>; 87 88def ObjCInstanceMethod : SubsetSubject<ObjCMethod, 89 [{S->isInstanceMethod()}]>; 90 91def ObjCInterfaceDeclInitMethod : SubsetSubject<ObjCMethod, 92 [{S->getMethodFamily() == OMF_init && 93 (isa<ObjCInterfaceDecl>(S->getDeclContext()) || 94 (isa<ObjCCategoryDecl>(S->getDeclContext()) && 95 cast<ObjCCategoryDecl>(S->getDeclContext())->IsClassExtension()))}]>; 96 97def Struct : SubsetSubject<Record, 98 [{!S->isUnion()}]>; 99 100def TLSVar : SubsetSubject<Var, 101 [{S->getTLSKind() != 0}]>; 102 103def SharedVar : SubsetSubject<Var, 104 [{S->hasGlobalStorage() && !S->getTLSKind()}]>; 105 106def GlobalVar : SubsetSubject<Var, 107 [{S->hasGlobalStorage()}]>; 108 109// FIXME: this hack is needed because DeclNodes.td defines the base Decl node 110// type to be a class, not a definition. This makes it impossible to create an 111// attribute subject which accepts a Decl. Normally, this is not a problem, 112// because the attribute can have no Subjects clause to accomplish this. But in 113// the case of a SubsetSubject, there's no way to express it without this hack. 114def DeclBase : AttrSubject; 115def FunctionLike : SubsetSubject<DeclBase, 116 [{S->getFunctionType(false) != NULL}]>; 117 118// HasFunctionProto is a more strict version of FunctionLike, so it should 119// never be specified in a Subjects list along with FunctionLike (due to the 120// inclusive nature of subject testing). 121def HasFunctionProto : SubsetSubject<DeclBase, 122 [{(S->getFunctionType(true) != NULL && 123 isa<FunctionProtoType>(S->getFunctionType())) || 124 isa<ObjCMethodDecl>(S) || 125 isa<BlockDecl>(S)}]>; 126 127// A single argument to an attribute 128class Argument<string name, bit optional> { 129 string Name = name; 130 bit Optional = optional; 131} 132 133class BoolArgument<string name, bit opt = 0> : Argument<name, opt>; 134class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>; 135class IntArgument<string name, bit opt = 0> : Argument<name, opt>; 136class StringArgument<string name, bit opt = 0> : Argument<name, opt>; 137class ExprArgument<string name, bit opt = 0> : Argument<name, opt>; 138class FunctionArgument<string name, bit opt = 0> : Argument<name, opt>; 139class TypeArgument<string name, bit opt = 0> : Argument<name, opt>; 140class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>; 141class VariadicUnsignedArgument<string name> : Argument<name, 1>; 142class VariadicExprArgument<string name> : Argument<name, 1>; 143 144// A version of the form major.minor[.subminor]. 145class VersionArgument<string name, bit opt = 0> : Argument<name, opt>; 146 147// This one's a doozy, so it gets its own special type 148// It can be an unsigned integer, or a type. Either can 149// be dependent. 150class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>; 151 152// A bool argument with a default value 153class DefaultBoolArgument<string name, bit default> : BoolArgument<name, 1> { 154 bit Default = default; 155} 156 157// An integer argument with a default value 158class DefaultIntArgument<string name, int default> : IntArgument<name, 1> { 159 int Default = default; 160} 161 162// This argument is more complex, it includes the enumerator type name, 163// a list of strings to accept, and a list of enumerators to map them to. 164class EnumArgument<string name, string type, list<string> values, 165 list<string> enums, bit opt = 0> : Argument<name, opt> { 166 string Type = type; 167 list<string> Values = values; 168 list<string> Enums = enums; 169} 170 171// FIXME: There should be a VariadicArgument type that takes any other type 172// of argument and generates the appropriate type. 173class VariadicEnumArgument<string name, string type, list<string> values, 174 list<string> enums> : Argument<name, 1> { 175 string Type = type; 176 list<string> Values = values; 177 list<string> Enums = enums; 178} 179 180// This handles one spelling of an attribute. 181class Spelling<string name, string variety> { 182 string Name = name; 183 string Variety = variety; 184 bit KnownToGCC; 185} 186 187class GNU<string name> : Spelling<name, "GNU">; 188class Declspec<string name> : Spelling<name, "Declspec">; 189class CXX11<string namespace, string name> : Spelling<name, "CXX11"> { 190 string Namespace = namespace; 191} 192class Keyword<string name> : Spelling<name, "Keyword">; 193class Pragma<string namespace, string name> : Spelling<name, "Pragma"> { 194 string Namespace = namespace; 195} 196 197// The GCC spelling implies GNU<name, "GNU"> and CXX11<"gnu", name> and also 198// sets KnownToGCC to 1. This spelling should be used for any GCC-compatible 199// attributes. 200class GCC<string name> : Spelling<name, "GCC"> { 201 let KnownToGCC = 1; 202} 203 204class Accessor<string name, list<Spelling> spellings> { 205 string Name = name; 206 list<Spelling> Spellings = spellings; 207} 208 209class SubjectDiag<bit warn> { 210 bit Warn = warn; 211} 212def WarnDiag : SubjectDiag<1>; 213def ErrorDiag : SubjectDiag<0>; 214 215class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag, 216 string customDiag = ""> { 217 list<AttrSubject> Subjects = subjects; 218 SubjectDiag Diag = diag; 219 string CustomDiag = customDiag; 220} 221 222class LangOpt<string name> { 223 string Name = name; 224} 225def MicrosoftExt : LangOpt<"MicrosoftExt">; 226def Borland : LangOpt<"Borland">; 227def CUDA : LangOpt<"CUDA">; 228 229// Defines targets for target-specific attributes. The list of strings should 230// specify architectures for which the target applies, based off the ArchType 231// enumeration in Triple.h. 232class TargetArch<list<string> arches> { 233 list<string> Arches = arches; 234 list<string> OSes; 235} 236def TargetARM : TargetArch<["arm", "thumb"]>; 237def TargetMSP430 : TargetArch<["msp430"]>; 238def TargetX86 : TargetArch<["x86"]>; 239def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> { 240 let OSes = ["Win32"]; 241} 242def TargetMips : TargetArch<["mips", "mipsel"]>; 243 244class Attr { 245 // The various ways in which an attribute can be spelled in source 246 list<Spelling> Spellings; 247 // The things to which an attribute can appertain 248 SubjectList Subjects; 249 // The arguments allowed on an attribute 250 list<Argument> Args = []; 251 // Accessors which should be generated for the attribute. 252 list<Accessor> Accessors = []; 253 // Set to true for attributes with arguments which require delayed parsing. 254 bit LateParsed = 0; 255 // Set to false to prevent an attribute from being propagated from a template 256 // to the instantiation. 257 bit Clone = 1; 258 // Set to true for attributes which must be instantiated within templates 259 bit TemplateDependent = 0; 260 // Set to true for attributes that have a corresponding AST node. 261 bit ASTNode = 1; 262 // Set to true for attributes which have handler in Sema. 263 bit SemaHandler = 1; 264 // Set to true for attributes that are completely ignored. 265 bit Ignored = 0; 266 // Set to true if the attribute's parsing does not match its semantic 267 // content. Eg) It parses 3 args, but semantically takes 4 args. Opts out of 268 // common attribute error checking. 269 bit HasCustomParsing = 0; 270 // Set to true if all of the attribute's arguments should be parsed in an 271 // unevaluated context. 272 bit ParseArgumentsAsUnevaluated = 0; 273 // Set to true if this attribute can be duplicated on a subject when merging 274 // attributes. By default, attributes are not merged. 275 bit DuplicatesAllowedWhileMerging = 0; 276 // Lists language options, one of which is required to be true for the 277 // attribute to be applicable. If empty, no language options are required. 278 list<LangOpt> LangOpts = []; 279 // Any additional text that should be included verbatim in the class. 280 code AdditionalMembers = [{}]; 281 // Any documentation that should be associated with the attribute. Since an 282 // attribute may be documented under multiple categories, more than one 283 // Documentation entry may be listed. 284 list<Documentation> Documentation; 285} 286 287/// A type attribute is not processed on a declaration or a statement. 288class TypeAttr : Attr { 289 // By default, type attributes do not get an AST node. 290 let ASTNode = 0; 291} 292 293/// An inheritable attribute is inherited by later redeclarations. 294class InheritableAttr : Attr; 295 296/// A target-specific attribute. This class is meant to be used as a mixin 297/// with InheritableAttr or Attr depending on the attribute's needs. 298class TargetSpecificAttr<TargetArch target> { 299 TargetArch Target = target; 300 // Attributes are generally required to have unique spellings for their names 301 // so that the parser can determine what kind of attribute it has parsed. 302 // However, target-specific attributes are special in that the attribute only 303 // "exists" for a given target. So two target-specific attributes can share 304 // the same name when they exist in different targets. To support this, a 305 // Kind can be explicitly specified for a target-specific attribute. This 306 // corresponds to the AttributeList::AT_* enum that is generated and it 307 // should contain a shared value between the attributes. 308 // 309 // Target-specific attributes which use this feature should ensure that the 310 // spellings match exactly betweeen the attributes, and if the arguments or 311 // subjects differ, should specify HasCustomParsing = 1 and implement their 312 // own parsing and semantic handling requirements as-needed. 313 string ParseKind; 314} 315 316/// An inheritable parameter attribute is inherited by later 317/// redeclarations, even when it's written on a parameter. 318class InheritableParamAttr : InheritableAttr; 319 320/// An ignored attribute, which we parse but discard with no checking. 321class IgnoredAttr : Attr { 322 let Ignored = 1; 323 let ASTNode = 0; 324 let SemaHandler = 0; 325 let Documentation = [Undocumented]; 326} 327 328// 329// Attributes begin here 330// 331 332def AddressSpace : TypeAttr { 333 let Spellings = [GNU<"address_space">]; 334 let Args = [IntArgument<"AddressSpace">]; 335 let Documentation = [Undocumented]; 336} 337 338def Alias : Attr { 339 let Spellings = [GCC<"alias">]; 340 let Args = [StringArgument<"Aliasee">]; 341 let Documentation = [Undocumented]; 342} 343 344def Aligned : InheritableAttr { 345 let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">, 346 Keyword<"_Alignas">]; 347// let Subjects = SubjectList<[NonBitField, NormalVar, Tag]>; 348 let Args = [AlignedArgument<"Alignment", 1>]; 349 let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>, 350 Accessor<"isC11", [Keyword<"_Alignas">]>, 351 Accessor<"isAlignas", [Keyword<"alignas">, 352 Keyword<"_Alignas">]>, 353 Accessor<"isDeclspec",[Declspec<"align">]>]; 354 let Documentation = [Undocumented]; 355} 356 357def AlignMac68k : InheritableAttr { 358 // This attribute has no spellings as it is only ever created implicitly. 359 let Spellings = []; 360 let SemaHandler = 0; 361 let Documentation = [Undocumented]; 362} 363 364def AlwaysInline : InheritableAttr { 365 let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">]; 366 let Subjects = SubjectList<[Function]>; 367 let Documentation = [Undocumented]; 368} 369 370def TLSModel : InheritableAttr { 371 let Spellings = [GCC<"tls_model">]; 372 let Subjects = SubjectList<[TLSVar], ErrorDiag, "ExpectedTLSVar">; 373 let Args = [StringArgument<"Model">]; 374 let Documentation = [TLSModelDocs]; 375} 376 377def AnalyzerNoReturn : InheritableAttr { 378 let Spellings = [GNU<"analyzer_noreturn">]; 379 let Documentation = [Undocumented]; 380} 381 382def Annotate : InheritableParamAttr { 383 let Spellings = [GNU<"annotate">]; 384 let Args = [StringArgument<"Annotation">]; 385 let Documentation = [Undocumented]; 386} 387 388def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> { 389 // NOTE: If you add any additional spellings, MSP430Interrupt's spellings 390 // must match. 391 let Spellings = [GNU<"interrupt">]; 392 let Args = [EnumArgument<"Interrupt", "InterruptType", 393 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""], 394 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"], 395 1>]; 396 let ParseKind = "Interrupt"; 397 let HasCustomParsing = 1; 398 let Documentation = [ARMInterruptDocs]; 399} 400 401def AsmLabel : InheritableAttr { 402 let Spellings = [Keyword<"asm">, Keyword<"__asm__">]; 403 let Args = [StringArgument<"Label">]; 404 let SemaHandler = 0; 405 let Documentation = [Undocumented]; 406} 407 408def Availability : InheritableAttr { 409 let Spellings = [GNU<"availability">]; 410 let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">, 411 VersionArgument<"deprecated">, VersionArgument<"obsoleted">, 412 BoolArgument<"unavailable">, StringArgument<"message">]; 413 let AdditionalMembers = 414[{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) { 415 return llvm::StringSwitch<llvm::StringRef>(Platform) 416 .Case("ios", "iOS") 417 .Case("macosx", "OS X") 418 .Default(llvm::StringRef()); 419} }]; 420 let HasCustomParsing = 1; 421 let DuplicatesAllowedWhileMerging = 1; 422// let Subjects = SubjectList<[Named]>; 423 let Documentation = [AvailabilityDocs]; 424} 425 426def Blocks : InheritableAttr { 427 let Spellings = [GNU<"blocks">]; 428 let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>]; 429 let Documentation = [Undocumented]; 430} 431 432def Bounded : IgnoredAttr { 433 let Spellings = [GNU<"bounded">]; 434} 435 436def CarriesDependency : InheritableParamAttr { 437 let Spellings = [GNU<"carries_dependency">, CXX11<"","carries_dependency">]; 438 let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>; 439 let Documentation = [CarriesDependencyDocs]; 440} 441 442def CDecl : InheritableAttr { 443 let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">]; 444// let Subjects = [Function, ObjCMethod]; 445 let Documentation = [Undocumented]; 446} 447 448// cf_audited_transfer indicates that the given function has been 449// audited and has been marked with the appropriate cf_consumed and 450// cf_returns_retained attributes. It is generally applied by 451// '#pragma clang arc_cf_code_audited' rather than explicitly. 452def CFAuditedTransfer : InheritableAttr { 453 let Spellings = [GNU<"cf_audited_transfer">]; 454 let Subjects = SubjectList<[Function], ErrorDiag>; 455 let Documentation = [Undocumented]; 456} 457 458// cf_unknown_transfer is an explicit opt-out of cf_audited_transfer. 459// It indicates that the function has unknown or unautomatable 460// transfer semantics. 461def CFUnknownTransfer : InheritableAttr { 462 let Spellings = [GNU<"cf_unknown_transfer">]; 463 let Subjects = SubjectList<[Function], ErrorDiag>; 464 let Documentation = [Undocumented]; 465} 466 467def CFReturnsRetained : InheritableAttr { 468 let Spellings = [GNU<"cf_returns_retained">]; 469// let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>; 470 let Documentation = [Undocumented]; 471} 472 473def CFReturnsNotRetained : InheritableAttr { 474 let Spellings = [GNU<"cf_returns_not_retained">]; 475// let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>; 476 let Documentation = [Undocumented]; 477} 478 479def CFConsumed : InheritableParamAttr { 480 let Spellings = [GNU<"cf_consumed">]; 481 let Subjects = SubjectList<[ParmVar]>; 482 let Documentation = [Undocumented]; 483} 484 485def Cleanup : InheritableAttr { 486 let Spellings = [GCC<"cleanup">]; 487 let Args = [FunctionArgument<"FunctionDecl">]; 488 let Subjects = SubjectList<[Var]>; 489 let Documentation = [Undocumented]; 490} 491 492def Cold : InheritableAttr { 493 let Spellings = [GCC<"cold">]; 494 let Subjects = SubjectList<[Function]>; 495 let Documentation = [Undocumented]; 496} 497 498def Common : InheritableAttr { 499 let Spellings = [GCC<"common">]; 500 let Subjects = SubjectList<[Var]>; 501 let Documentation = [Undocumented]; 502} 503 504def Const : InheritableAttr { 505 let Spellings = [GCC<"const">, GCC<"__const">]; 506 let Documentation = [Undocumented]; 507} 508 509def Constructor : InheritableAttr { 510 let Spellings = [GCC<"constructor">]; 511 let Args = [DefaultIntArgument<"Priority", 65535>]; 512 let Subjects = SubjectList<[Function]>; 513 let Documentation = [Undocumented]; 514} 515 516def CUDAConstant : InheritableAttr { 517 let Spellings = [GNU<"constant">]; 518 let Subjects = SubjectList<[Var]>; 519 let LangOpts = [CUDA]; 520 let Documentation = [Undocumented]; 521} 522 523def CUDADevice : InheritableAttr { 524 let Spellings = [GNU<"device">]; 525 let Subjects = SubjectList<[Function, Var]>; 526 let LangOpts = [CUDA]; 527 let Documentation = [Undocumented]; 528} 529 530def CUDAGlobal : InheritableAttr { 531 let Spellings = [GNU<"global">]; 532 let Subjects = SubjectList<[Function]>; 533 let LangOpts = [CUDA]; 534 let Documentation = [Undocumented]; 535} 536 537def CUDAHost : InheritableAttr { 538 let Spellings = [GNU<"host">]; 539 let Subjects = SubjectList<[Function]>; 540 let LangOpts = [CUDA]; 541 let Documentation = [Undocumented]; 542} 543 544def CUDALaunchBounds : InheritableAttr { 545 let Spellings = [GNU<"launch_bounds">]; 546 let Args = [IntArgument<"MaxThreads">, DefaultIntArgument<"MinBlocks", 0>]; 547 let LangOpts = [CUDA]; 548 let Subjects = SubjectList<[ObjCMethod, FunctionLike], WarnDiag, 549 "ExpectedFunctionOrMethod">; 550 // An AST node is created for this attribute, but is not used by other parts 551 // of the compiler. However, this node needs to exist in the AST because 552 // non-LLVM backends may be relying on the attribute's presence. 553 let Documentation = [Undocumented]; 554} 555 556def CUDAShared : InheritableAttr { 557 let Spellings = [GNU<"shared">]; 558 let Subjects = SubjectList<[Var]>; 559 let LangOpts = [CUDA]; 560 let Documentation = [Undocumented]; 561} 562 563def C11NoReturn : InheritableAttr { 564 let Spellings = [Keyword<"_Noreturn">]; 565 let Subjects = SubjectList<[Function], ErrorDiag>; 566 let SemaHandler = 0; 567 let Documentation = [C11NoReturnDocs]; 568} 569 570def CXX11NoReturn : InheritableAttr { 571 let Spellings = [CXX11<"","noreturn">]; 572 let Subjects = SubjectList<[Function], ErrorDiag>; 573 let Documentation = [CXX11NoReturnDocs]; 574} 575 576def OpenCLKernel : InheritableAttr { 577 let Spellings = [Keyword<"__kernel">, Keyword<"kernel">]; 578 let Subjects = SubjectList<[Function], ErrorDiag>; 579 let Documentation = [Undocumented]; 580} 581 582// This attribute is both a type attribute, and a declaration attribute (for 583// parameter variables). 584def OpenCLImageAccess : Attr { 585 let Spellings = [Keyword<"__read_only">, Keyword<"read_only">, 586 Keyword<"__write_only">, Keyword<"write_only">, 587 Keyword<"__read_write">, Keyword<"read_write">]; 588 let Subjects = SubjectList<[ParmVar], ErrorDiag>; 589 let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">, 590 Keyword<"read_only">]>, 591 Accessor<"isReadWrite", [Keyword<"__read_write">, 592 Keyword<"read_write">]>, 593 Accessor<"isWriteOnly", [Keyword<"__write_only">, 594 Keyword<"write_only">]>]; 595 let Documentation = [Undocumented]; 596} 597 598def OpenCLPrivateAddressSpace : TypeAttr { 599 let Spellings = [Keyword<"__private">, Keyword<"private">]; 600 let Documentation = [Undocumented]; 601} 602 603def OpenCLGlobalAddressSpace : TypeAttr { 604 let Spellings = [Keyword<"__global">, Keyword<"global">]; 605 let Documentation = [Undocumented]; 606} 607 608def OpenCLLocalAddressSpace : TypeAttr { 609 let Spellings = [Keyword<"__local">, Keyword<"local">]; 610 let Documentation = [Undocumented]; 611} 612 613def OpenCLConstantAddressSpace : TypeAttr { 614 let Spellings = [Keyword<"__constant">, Keyword<"constant">]; 615 let Documentation = [Undocumented]; 616} 617 618def Kernel : Attr { 619 let Spellings = [GNU<"kernel">]; 620 let Documentation = [Undocumented]; 621} 622 623def Deprecated : InheritableAttr { 624 let Spellings = [GCC<"deprecated">, Declspec<"deprecated">, 625 CXX11<"","deprecated">]; 626 let Args = [StringArgument<"Message", 1>]; 627 let Documentation = [Undocumented]; 628} 629 630def Destructor : InheritableAttr { 631 let Spellings = [GCC<"destructor">]; 632 let Args = [DefaultIntArgument<"Priority", 65535>]; 633 let Subjects = SubjectList<[Function]>; 634 let Documentation = [Undocumented]; 635} 636 637def EnableIf : InheritableAttr { 638 let Spellings = [GNU<"enable_if">]; 639 let Subjects = SubjectList<[Function]>; 640 let Args = [ExprArgument<"Cond">, StringArgument<"Message">]; 641 let TemplateDependent = 1; 642 let Documentation = [EnableIfDocs]; 643} 644 645def ExtVectorType : Attr { 646 let Spellings = [GNU<"ext_vector_type">]; 647 let Subjects = SubjectList<[TypedefName], ErrorDiag>; 648 let Args = [ExprArgument<"NumElements">]; 649 let ASTNode = 0; 650 let Documentation = [Undocumented]; 651} 652 653def FallThrough : Attr { 654 let Spellings = [CXX11<"clang", "fallthrough">]; 655// let Subjects = [NullStmt]; 656 let Documentation = [FallthroughDocs]; 657} 658 659def FastCall : InheritableAttr { 660 let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">, 661 Keyword<"_fastcall">]; 662// let Subjects = [Function, ObjCMethod]; 663 let Documentation = [Undocumented]; 664} 665 666def Final : InheritableAttr { 667 let Spellings = [Keyword<"final">, Keyword<"sealed">]; 668 let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>]; 669 let SemaHandler = 0; 670 let Documentation = [Undocumented]; 671} 672 673def MinSize : InheritableAttr { 674 let Spellings = [GNU<"minsize">]; 675 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>; 676 let Documentation = [Undocumented]; 677} 678 679def Flatten : InheritableAttr { 680 let Spellings = [GCC<"flatten">]; 681 let Subjects = SubjectList<[Function], ErrorDiag>; 682 let Documentation = [FlattenDocs]; 683} 684 685def Format : InheritableAttr { 686 let Spellings = [GCC<"format">]; 687 let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">, 688 IntArgument<"FirstArg">]; 689 let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto], WarnDiag, 690 "ExpectedFunction">; 691 let Documentation = [FormatDocs]; 692} 693 694def FormatArg : InheritableAttr { 695 let Spellings = [GCC<"format_arg">]; 696 let Args = [IntArgument<"FormatIdx">]; 697 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto], WarnDiag, 698 "ExpectedFunction">; 699 let Documentation = [Undocumented]; 700} 701 702def GNUInline : InheritableAttr { 703 let Spellings = [GCC<"gnu_inline">]; 704 let Subjects = SubjectList<[Function]>; 705 let Documentation = [Undocumented]; 706} 707 708def Hot : InheritableAttr { 709 let Spellings = [GCC<"hot">]; 710 let Subjects = SubjectList<[Function]>; 711 // An AST node is created for this attribute, but not actually used beyond 712 // semantic checking for mutual exclusion with the Cold attribute. 713 let Documentation = [Undocumented]; 714} 715 716def IBAction : InheritableAttr { 717 let Spellings = [GNU<"ibaction">]; 718 let Subjects = SubjectList<[ObjCInstanceMethod], WarnDiag, 719 "ExpectedObjCInstanceMethod">; 720 // An AST node is created for this attribute, but is not used by other parts 721 // of the compiler. However, this node needs to exist in the AST because 722 // external tools rely on it. 723 let Documentation = [Undocumented]; 724} 725 726def IBOutlet : InheritableAttr { 727 let Spellings = [GNU<"iboutlet">]; 728// let Subjects = [ObjCIvar, ObjCProperty]; 729 let Documentation = [Undocumented]; 730} 731 732def IBOutletCollection : InheritableAttr { 733 let Spellings = [GNU<"iboutletcollection">]; 734 let Args = [TypeArgument<"Interface", 1>]; 735// let Subjects = [ObjCIvar, ObjCProperty]; 736 let Documentation = [Undocumented]; 737} 738 739def Malloc : InheritableAttr { 740 let Spellings = [GCC<"malloc">]; 741// let Subjects = [Function]; 742 let Documentation = [Undocumented]; 743} 744 745def MaxFieldAlignment : InheritableAttr { 746 // This attribute has no spellings as it is only ever created implicitly. 747 let Spellings = []; 748 let Args = [UnsignedArgument<"Alignment">]; 749 let SemaHandler = 0; 750 let Documentation = [Undocumented]; 751} 752 753def MayAlias : InheritableAttr { 754 // FIXME: this is a type attribute in GCC, but a declaration attribute here. 755 let Spellings = [GCC<"may_alias">]; 756 let Documentation = [Undocumented]; 757} 758 759def MSABI : InheritableAttr { 760 let Spellings = [GCC<"ms_abi">]; 761// let Subjects = [Function, ObjCMethod]; 762 let Documentation = [Undocumented]; 763} 764 765def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> { 766 // NOTE: If you add any additional spellings, ARMInterrupt's spellings must 767 // match. 768 let Spellings = [GNU<"interrupt">]; 769 let Args = [UnsignedArgument<"Number">]; 770 let ParseKind = "Interrupt"; 771 let HasCustomParsing = 1; 772 let Documentation = [Undocumented]; 773} 774 775def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips> { 776 let Spellings = [GCC<"mips16">]; 777 let Subjects = SubjectList<[Function], ErrorDiag>; 778 let Documentation = [Undocumented]; 779} 780 781def Mode : Attr { 782 let Spellings = [GCC<"mode">]; 783 let Args = [IdentifierArgument<"Mode">]; 784 let Documentation = [Undocumented]; 785} 786 787def Naked : InheritableAttr { 788 let Spellings = [GCC<"naked">, Declspec<"naked">]; 789 let Subjects = SubjectList<[Function]>; 790 let Documentation = [Undocumented]; 791} 792 793def NeonPolyVectorType : TypeAttr { 794 let Spellings = [GNU<"neon_polyvector_type">]; 795 let Args = [IntArgument<"NumElements">]; 796 let Documentation = [Undocumented]; 797} 798 799def NeonVectorType : TypeAttr { 800 let Spellings = [GNU<"neon_vector_type">]; 801 let Args = [IntArgument<"NumElements">]; 802 let Documentation = [Undocumented]; 803} 804 805def ReturnsTwice : InheritableAttr { 806 let Spellings = [GCC<"returns_twice">]; 807 let Subjects = SubjectList<[Function]>; 808 let Documentation = [Undocumented]; 809} 810 811def NoCommon : InheritableAttr { 812 let Spellings = [GCC<"nocommon">]; 813 let Subjects = SubjectList<[Var]>; 814 let Documentation = [Undocumented]; 815} 816 817def NoDebug : InheritableAttr { 818 let Spellings = [GNU<"nodebug">]; 819 let Documentation = [Undocumented]; 820} 821 822def NoDuplicate : InheritableAttr { 823 let Spellings = [GNU<"noduplicate">, CXX11<"clang", "noduplicate">]; 824 let Subjects = SubjectList<[Function]>; 825 let Documentation = [NoDuplicateDocs]; 826} 827 828def NoInline : InheritableAttr { 829 let Spellings = [GCC<"noinline">, Declspec<"noinline">]; 830 let Subjects = SubjectList<[Function]>; 831 let Documentation = [Undocumented]; 832} 833 834def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips> { 835 let Spellings = [GCC<"nomips16">]; 836 let Subjects = SubjectList<[Function], ErrorDiag>; 837 let Documentation = [Undocumented]; 838} 839 840def NoSplitStack : InheritableAttr { 841 let Spellings = [GCC<"no_split_stack">]; 842 let Subjects = SubjectList<[Function], ErrorDiag>; 843 let Documentation = [NoSplitStackDocs]; 844} 845 846def NonNull : InheritableAttr { 847 let Spellings = [GCC<"nonnull">]; 848 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag, 849 "ExpectedFunctionMethodOrParameter">; 850 let Args = [VariadicUnsignedArgument<"Args">]; 851 let AdditionalMembers = 852[{bool isNonNull(unsigned idx) const { 853 for (const auto &V : args()) 854 if (V == idx) 855 return true; 856 return false; 857 } }]; 858 let Documentation = [Undocumented]; 859} 860 861def ReturnsNonNull : InheritableAttr { 862 let Spellings = [GCC<"returns_nonnull">]; 863 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto], WarnDiag, 864 "ExpectedFunctionOrMethod">; 865 let Documentation = [Undocumented]; 866} 867 868def NoReturn : InheritableAttr { 869 let Spellings = [GCC<"noreturn">, Declspec<"noreturn">]; 870 // FIXME: Does GCC allow this on the function instead? 871 let Documentation = [Undocumented]; 872} 873 874def NoInstrumentFunction : InheritableAttr { 875 let Spellings = [GCC<"no_instrument_function">]; 876 let Subjects = SubjectList<[Function]>; 877 let Documentation = [Undocumented]; 878} 879 880def NoThrow : InheritableAttr { 881 let Spellings = [GCC<"nothrow">, Declspec<"nothrow">]; 882 let Documentation = [Undocumented]; 883} 884 885def ObjCBridge : InheritableAttr { 886 let Spellings = [GNU<"objc_bridge">]; 887 let Subjects = SubjectList<[Record], ErrorDiag>; 888 let Args = [IdentifierArgument<"BridgedType">]; 889 let Documentation = [Undocumented]; 890} 891 892def ObjCBridgeMutable : InheritableAttr { 893 let Spellings = [GNU<"objc_bridge_mutable">]; 894 let Subjects = SubjectList<[Record], ErrorDiag>; 895 let Args = [IdentifierArgument<"BridgedType">]; 896 let Documentation = [Undocumented]; 897} 898 899def ObjCBridgeRelated : InheritableAttr { 900 let Spellings = [GNU<"objc_bridge_related">]; 901 let Subjects = SubjectList<[Record], ErrorDiag>; 902 let Args = [IdentifierArgument<"RelatedClass">, 903 IdentifierArgument<"ClassMethod">, 904 IdentifierArgument<"InstanceMethod">]; 905 let HasCustomParsing = 1; 906 let Documentation = [Undocumented]; 907} 908 909def NSReturnsRetained : InheritableAttr { 910 let Spellings = [GNU<"ns_returns_retained">]; 911// let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>; 912 let Documentation = [Undocumented]; 913} 914 915def NSReturnsNotRetained : InheritableAttr { 916 let Spellings = [GNU<"ns_returns_not_retained">]; 917// let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>; 918 let Documentation = [Undocumented]; 919} 920 921def NSReturnsAutoreleased : InheritableAttr { 922 let Spellings = [GNU<"ns_returns_autoreleased">]; 923// let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>; 924 let Documentation = [Undocumented]; 925} 926 927def NSConsumesSelf : InheritableAttr { 928 let Spellings = [GNU<"ns_consumes_self">]; 929 let Subjects = SubjectList<[ObjCMethod]>; 930 let Documentation = [Undocumented]; 931} 932 933def NSConsumed : InheritableParamAttr { 934 let Spellings = [GNU<"ns_consumed">]; 935 let Subjects = SubjectList<[ParmVar]>; 936 let Documentation = [Undocumented]; 937} 938 939def ObjCException : InheritableAttr { 940 let Spellings = [GNU<"objc_exception">]; 941 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; 942 let Documentation = [Undocumented]; 943} 944 945def ObjCMethodFamily : InheritableAttr { 946 let Spellings = [GNU<"objc_method_family">]; 947 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>; 948 let Args = [EnumArgument<"Family", "FamilyKind", 949 ["none", "alloc", "copy", "init", "mutableCopy", "new"], 950 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init", 951 "OMF_mutableCopy", "OMF_new"]>]; 952 let Documentation = [ObjCMethodFamilyDocs]; 953} 954 955def ObjCNSObject : InheritableAttr { 956 let Spellings = [GNU<"NSObject">]; 957 let Documentation = [Undocumented]; 958} 959 960def ObjCPreciseLifetime : InheritableAttr { 961 let Spellings = [GNU<"objc_precise_lifetime">]; 962 let Subjects = SubjectList<[Var], ErrorDiag>; 963 let Documentation = [Undocumented]; 964} 965 966def ObjCReturnsInnerPointer : InheritableAttr { 967 let Spellings = [GNU<"objc_returns_inner_pointer">]; 968 let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>; 969 let Documentation = [Undocumented]; 970} 971 972def ObjCRequiresSuper : InheritableAttr { 973 let Spellings = [GNU<"objc_requires_super">]; 974 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>; 975 let Documentation = [ObjCRequiresSuperDocs]; 976} 977 978def ObjCRootClass : InheritableAttr { 979 let Spellings = [GNU<"objc_root_class">]; 980 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; 981 let Documentation = [Undocumented]; 982} 983 984def ObjCExplicitProtocolImpl : InheritableAttr { 985 let Spellings = [GNU<"objc_protocol_requires_explicit_implementation">]; 986 let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>; 987 let Documentation = [Undocumented]; 988} 989 990def ObjCDesignatedInitializer : Attr { 991 let Spellings = [GNU<"objc_designated_initializer">]; 992 let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag, 993 "ExpectedObjCInterfaceDeclInitMethod">; 994 let Documentation = [Undocumented]; 995} 996 997def OptimizeNone : InheritableAttr { 998 let Spellings = [GNU<"optnone">, CXX11<"clang", "optnone">]; 999 let Subjects = SubjectList<[Function, ObjCMethod]>; 1000 let Documentation = [OptnoneDocs]; 1001} 1002 1003def Overloadable : Attr { 1004 let Spellings = [GNU<"overloadable">]; 1005 let Subjects = SubjectList<[Function], ErrorDiag>; 1006 let Documentation = [OverloadableDocs]; 1007} 1008 1009def Override : InheritableAttr { 1010 let Spellings = [Keyword<"override">]; 1011 let SemaHandler = 0; 1012 let Documentation = [Undocumented]; 1013} 1014 1015def Ownership : InheritableAttr { 1016 let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">, 1017 GNU<"ownership_takes">]; 1018 let Accessors = [Accessor<"isHolds", [GNU<"ownership_holds">]>, 1019 Accessor<"isReturns", [GNU<"ownership_returns">]>, 1020 Accessor<"isTakes", [GNU<"ownership_takes">]>]; 1021 let AdditionalMembers = [{ 1022 enum OwnershipKind { Holds, Returns, Takes }; 1023 OwnershipKind getOwnKind() const { 1024 return isHolds() ? Holds : 1025 isTakes() ? Takes : 1026 Returns; 1027 } 1028 }]; 1029 let Args = [IdentifierArgument<"Module">, VariadicUnsignedArgument<"Args">]; 1030 let Subjects = SubjectList<[HasFunctionProto], WarnDiag, "ExpectedFunction">; 1031 let Documentation = [Undocumented]; 1032} 1033 1034def Packed : InheritableAttr { 1035 let Spellings = [GCC<"packed">]; 1036// let Subjects = [Tag, Field]; 1037 let Documentation = [Undocumented]; 1038} 1039 1040def PnaclCall : InheritableAttr { 1041 let Spellings = [GNU<"pnaclcall">]; 1042// let Subjects = [Function, ObjCMethod]; 1043 let Documentation = [Undocumented]; 1044} 1045 1046def IntelOclBicc : InheritableAttr { 1047 let Spellings = [GNU<"intel_ocl_bicc">]; 1048// let Subjects = [Function, ObjCMethod]; 1049 let Documentation = [Undocumented]; 1050} 1051 1052def Pcs : InheritableAttr { 1053 let Spellings = [GCC<"pcs">]; 1054 let Args = [EnumArgument<"PCS", "PCSType", 1055 ["aapcs", "aapcs-vfp"], 1056 ["AAPCS", "AAPCS_VFP"]>]; 1057// let Subjects = [Function, ObjCMethod]; 1058 let Documentation = [PcsDocs]; 1059} 1060 1061def Pure : InheritableAttr { 1062 let Spellings = [GCC<"pure">]; 1063 let Documentation = [Undocumented]; 1064} 1065 1066def Regparm : TypeAttr { 1067 let Spellings = [GCC<"regparm">]; 1068 let Args = [UnsignedArgument<"NumParams">]; 1069 let Documentation = [Undocumented]; 1070} 1071 1072def ReqdWorkGroupSize : InheritableAttr { 1073 let Spellings = [GNU<"reqd_work_group_size">]; 1074 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">, 1075 UnsignedArgument<"ZDim">]; 1076 let Subjects = SubjectList<[Function], ErrorDiag>; 1077 let Documentation = [Undocumented]; 1078} 1079 1080def WorkGroupSizeHint : InheritableAttr { 1081 let Spellings = [GNU<"work_group_size_hint">]; 1082 let Args = [UnsignedArgument<"XDim">, 1083 UnsignedArgument<"YDim">, 1084 UnsignedArgument<"ZDim">]; 1085 let Subjects = SubjectList<[Function], ErrorDiag>; 1086 let Documentation = [Undocumented]; 1087} 1088 1089def InitPriority : InheritableAttr { 1090 let Spellings = [GNU<"init_priority">]; 1091 let Args = [UnsignedArgument<"Priority">]; 1092 let Subjects = SubjectList<[Var], ErrorDiag>; 1093 let Documentation = [Undocumented]; 1094} 1095 1096def Section : InheritableAttr { 1097 let Spellings = [GCC<"section">, Declspec<"allocate">]; 1098 let Args = [StringArgument<"Name">]; 1099 let Subjects = SubjectList<[Function, GlobalVar, 1100 ObjCMethod, ObjCProperty], ErrorDiag, 1101 "ExpectedFunctionGlobalVarMethodOrProperty">; 1102 let Documentation = [SectionDocs]; 1103} 1104 1105def Sentinel : InheritableAttr { 1106 let Spellings = [GCC<"sentinel">]; 1107 let Args = [DefaultIntArgument<"Sentinel", 0>, 1108 DefaultIntArgument<"NullPos", 0>]; 1109// let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>; 1110 let Documentation = [Undocumented]; 1111} 1112 1113def StdCall : InheritableAttr { 1114 let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">]; 1115// let Subjects = [Function, ObjCMethod]; 1116 let Documentation = [Undocumented]; 1117} 1118 1119def SysVABI : InheritableAttr { 1120 let Spellings = [GCC<"sysv_abi">]; 1121// let Subjects = [Function, ObjCMethod]; 1122 let Documentation = [Undocumented]; 1123} 1124 1125def ThisCall : InheritableAttr { 1126 let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">, 1127 Keyword<"_thiscall">]; 1128// let Subjects = [Function, ObjCMethod]; 1129 let Documentation = [Undocumented]; 1130} 1131 1132def Pascal : InheritableAttr { 1133 let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">]; 1134// let Subjects = [Function, ObjCMethod]; 1135 let Documentation = [Undocumented]; 1136} 1137 1138def TransparentUnion : InheritableAttr { 1139 let Spellings = [GCC<"transparent_union">]; 1140// let Subjects = SubjectList<[Record, TypedefName]>; 1141 let Documentation = [Undocumented]; 1142} 1143 1144def Unavailable : InheritableAttr { 1145 let Spellings = [GNU<"unavailable">]; 1146 let Args = [StringArgument<"Message", 1>]; 1147 let Documentation = [Undocumented]; 1148} 1149 1150def ArcWeakrefUnavailable : InheritableAttr { 1151 let Spellings = [GNU<"objc_arc_weak_reference_unavailable">]; 1152 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; 1153 let Documentation = [Undocumented]; 1154} 1155 1156def ObjCGC : TypeAttr { 1157 let Spellings = [GNU<"objc_gc">]; 1158 let Args = [IdentifierArgument<"Kind">]; 1159 let Documentation = [Undocumented]; 1160} 1161 1162def ObjCOwnership : InheritableAttr { 1163 let Spellings = [GNU<"objc_ownership">]; 1164 let Args = [IdentifierArgument<"Kind">]; 1165 let ASTNode = 0; 1166 let Documentation = [Undocumented]; 1167} 1168 1169def ObjCRequiresPropertyDefs : InheritableAttr { 1170 let Spellings = [GNU<"objc_requires_property_definitions">]; 1171 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; 1172 let Documentation = [Undocumented]; 1173} 1174 1175def Unused : InheritableAttr { 1176 let Spellings = [GCC<"unused">]; 1177 let Subjects = SubjectList<[Var, ObjCIvar, Type, Label, Field, ObjCMethod, 1178 FunctionLike], WarnDiag, 1179 "ExpectedVariableFunctionOrLabel">; 1180 let Documentation = [Undocumented]; 1181} 1182 1183def Used : InheritableAttr { 1184 let Spellings = [GCC<"used">]; 1185 let Documentation = [Undocumented]; 1186} 1187 1188def Uuid : InheritableAttr { 1189 let Spellings = [Declspec<"uuid">]; 1190 let Args = [StringArgument<"Guid">]; 1191// let Subjects = SubjectList<[CXXRecord]>; 1192 let LangOpts = [MicrosoftExt, Borland]; 1193 let Documentation = [Undocumented]; 1194} 1195 1196def VectorSize : TypeAttr { 1197 let Spellings = [GCC<"vector_size">]; 1198 let Args = [ExprArgument<"NumBytes">]; 1199 let Documentation = [Undocumented]; 1200} 1201 1202def VecTypeHint : InheritableAttr { 1203 let Spellings = [GNU<"vec_type_hint">]; 1204 let Args = [TypeArgument<"TypeHint">]; 1205 let Subjects = SubjectList<[Function], ErrorDiag>; 1206 let Documentation = [Undocumented]; 1207} 1208 1209def Visibility : InheritableAttr { 1210 let Clone = 0; 1211 let Spellings = [GCC<"visibility">]; 1212 let Args = [EnumArgument<"Visibility", "VisibilityType", 1213 ["default", "hidden", "internal", "protected"], 1214 ["Default", "Hidden", "Hidden", "Protected"]>]; 1215 let Documentation = [Undocumented]; 1216} 1217 1218def TypeVisibility : InheritableAttr { 1219 let Clone = 0; 1220 let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">]; 1221 let Args = [EnumArgument<"Visibility", "VisibilityType", 1222 ["default", "hidden", "internal", "protected"], 1223 ["Default", "Hidden", "Hidden", "Protected"]>]; 1224// let Subjects = [Tag, ObjCInterface, Namespace]; 1225 let Documentation = [Undocumented]; 1226} 1227 1228def VecReturn : InheritableAttr { 1229 let Spellings = [GNU<"vecreturn">]; 1230 let Subjects = SubjectList<[CXXRecord], ErrorDiag>; 1231 let Documentation = [Undocumented]; 1232} 1233 1234def WarnUnused : InheritableAttr { 1235 let Spellings = [GNU<"warn_unused">]; 1236 let Subjects = SubjectList<[Record]>; 1237 let Documentation = [Undocumented]; 1238} 1239 1240def WarnUnusedResult : InheritableAttr { 1241 let Spellings = [GCC<"warn_unused_result">, 1242 CXX11<"clang", "warn_unused_result">]; 1243 let Subjects = SubjectList<[ObjCMethod, CXXRecord, FunctionLike], WarnDiag, 1244 "ExpectedFunctionMethodOrClass">; 1245 let Documentation = [Undocumented]; 1246} 1247 1248def Weak : InheritableAttr { 1249 let Spellings = [GCC<"weak">]; 1250 let Subjects = SubjectList<[Var, Function, CXXRecord]>; 1251 let Documentation = [Undocumented]; 1252} 1253 1254def WeakImport : InheritableAttr { 1255 let Spellings = [GNU<"weak_import">]; 1256 let Documentation = [Undocumented]; 1257} 1258 1259def WeakRef : InheritableAttr { 1260 let Spellings = [GCC<"weakref">]; 1261 // A WeakRef that has an argument is treated as being an AliasAttr 1262 let Args = [StringArgument<"Aliasee", 1>]; 1263 let Subjects = SubjectList<[Var, Function], ErrorDiag>; 1264 let Documentation = [Undocumented]; 1265} 1266 1267def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetX86> { 1268 let Spellings = [GNU<"force_align_arg_pointer">]; 1269 // Technically, this appertains to a FunctionDecl, but the target-specific 1270 // code silently allows anything function-like (such as typedefs or function 1271 // pointers), but does not apply the attribute to them. 1272 let Documentation = [Undocumented]; 1273} 1274 1275// Attribute to disable AddressSanitizer (or equivalent) checks. 1276def NoSanitizeAddress : InheritableAttr { 1277 let Spellings = [GCC<"no_address_safety_analysis">, 1278 GCC<"no_sanitize_address">]; 1279 let Subjects = SubjectList<[Function], ErrorDiag>; 1280 let Documentation = [NoSanitizeAddressDocs]; 1281} 1282 1283// Attribute to disable ThreadSanitizer checks. 1284def NoSanitizeThread : InheritableAttr { 1285 let Spellings = [GNU<"no_sanitize_thread">]; 1286 let Subjects = SubjectList<[Function], ErrorDiag>; 1287 let Documentation = [NoSanitizeThreadDocs]; 1288} 1289 1290// Attribute to disable MemorySanitizer checks. 1291def NoSanitizeMemory : InheritableAttr { 1292 let Spellings = [GNU<"no_sanitize_memory">]; 1293 let Subjects = SubjectList<[Function], ErrorDiag>; 1294 let Documentation = [NoSanitizeMemoryDocs]; 1295} 1296 1297// C/C++ Thread safety attributes (e.g. for deadlock, data race checking) 1298 1299def GuardedVar : InheritableAttr { 1300 let Spellings = [GNU<"guarded_var">]; 1301 let Subjects = SubjectList<[Field, SharedVar], WarnDiag, 1302 "ExpectedFieldOrGlobalVar">; 1303 let Documentation = [Undocumented]; 1304} 1305 1306def PtGuardedVar : InheritableAttr { 1307 let Spellings = [GNU<"pt_guarded_var">]; 1308 let Subjects = SubjectList<[Field, SharedVar], WarnDiag, 1309 "ExpectedFieldOrGlobalVar">; 1310 let Documentation = [Undocumented]; 1311} 1312 1313def Lockable : InheritableAttr { 1314 let Spellings = [GNU<"lockable">]; 1315 let Subjects = SubjectList<[Record]>; 1316 let Documentation = [Undocumented]; 1317 let ASTNode = 0; // Replaced by Capability 1318} 1319 1320def ScopedLockable : InheritableAttr { 1321 let Spellings = [GNU<"scoped_lockable">]; 1322 let Subjects = SubjectList<[Record]>; 1323 let Documentation = [Undocumented]; 1324} 1325 1326def Capability : InheritableAttr { 1327 let Spellings = [GNU<"capability">, CXX11<"clang", "capability">, 1328 GNU<"shared_capability">, 1329 CXX11<"clang", "shared_capability">]; 1330 let Subjects = SubjectList<[Struct, TypedefName], ErrorDiag, 1331 "ExpectedStructOrTypedef">; 1332 let Args = [StringArgument<"Name">]; 1333 let Accessors = [Accessor<"isShared", 1334 [GNU<"shared_capability">, 1335 CXX11<"clang","shared_capability">]>]; 1336 let Documentation = [Undocumented]; 1337 let AdditionalMembers = [{ 1338 bool isMutex() const { return getName().equals_lower("mutex"); } 1339 bool isRole() const { return getName().equals_lower("role"); } 1340 }]; 1341} 1342 1343def AssertCapability : InheritableAttr { 1344 let Spellings = [GNU<"assert_capability">, 1345 CXX11<"clang", "assert_capability">, 1346 GNU<"assert_shared_capability">, 1347 CXX11<"clang", "assert_shared_capability">]; 1348 let Subjects = SubjectList<[Function]>; 1349 let LateParsed = 1; 1350 let TemplateDependent = 1; 1351 let ParseArgumentsAsUnevaluated = 1; 1352 let DuplicatesAllowedWhileMerging = 1; 1353 let Args = [ExprArgument<"Expr">]; 1354 let Accessors = [Accessor<"isShared", 1355 [GNU<"assert_shared_capability">, 1356 CXX11<"clang", "assert_shared_capability">]>]; 1357 let Documentation = [AssertCapabilityDocs]; 1358} 1359 1360def AcquireCapability : InheritableAttr { 1361 let Spellings = [GNU<"acquire_capability">, 1362 CXX11<"clang", "acquire_capability">, 1363 GNU<"acquire_shared_capability">, 1364 CXX11<"clang", "acquire_shared_capability">, 1365 GNU<"exclusive_lock_function">, 1366 GNU<"shared_lock_function">]; 1367 let Subjects = SubjectList<[Function]>; 1368 let LateParsed = 1; 1369 let TemplateDependent = 1; 1370 let ParseArgumentsAsUnevaluated = 1; 1371 let DuplicatesAllowedWhileMerging = 1; 1372 let Args = [VariadicExprArgument<"Args">]; 1373 let Accessors = [Accessor<"isShared", 1374 [GNU<"acquire_shared_capability">, 1375 CXX11<"clang", "acquire_shared_capability">, 1376 GNU<"shared_lock_function">]>]; 1377 let Documentation = [AcquireCapabilityDocs]; 1378} 1379 1380def TryAcquireCapability : InheritableAttr { 1381 let Spellings = [GNU<"try_acquire_capability">, 1382 CXX11<"clang", "try_acquire_capability">, 1383 GNU<"try_acquire_shared_capability">, 1384 CXX11<"clang", "try_acquire_shared_capability">]; 1385 let Subjects = SubjectList<[Function], 1386 ErrorDiag>; 1387 let LateParsed = 1; 1388 let TemplateDependent = 1; 1389 let ParseArgumentsAsUnevaluated = 1; 1390 let DuplicatesAllowedWhileMerging = 1; 1391 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">]; 1392 let Accessors = [Accessor<"isShared", 1393 [GNU<"try_acquire_shared_capability">, 1394 CXX11<"clang", "try_acquire_shared_capability">]>]; 1395 let Documentation = [TryAcquireCapabilityDocs]; 1396} 1397 1398def ReleaseCapability : InheritableAttr { 1399 let Spellings = [GNU<"release_capability">, 1400 CXX11<"clang", "release_capability">, 1401 GNU<"release_shared_capability">, 1402 CXX11<"clang", "release_shared_capability">, 1403 GNU<"release_generic_capability">, 1404 CXX11<"clang", "release_generic_capability">, 1405 GNU<"unlock_function">]; 1406 let Subjects = SubjectList<[Function]>; 1407 let LateParsed = 1; 1408 let TemplateDependent = 1; 1409 let ParseArgumentsAsUnevaluated = 1; 1410 let DuplicatesAllowedWhileMerging = 1; 1411 let Args = [VariadicExprArgument<"Args">]; 1412 let Accessors = [Accessor<"isShared", 1413 [GNU<"release_shared_capability">, 1414 CXX11<"clang", "release_shared_capability">]>, 1415 Accessor<"isGeneric", 1416 [GNU<"release_generic_capability">, 1417 CXX11<"clang", "release_generic_capability">, 1418 GNU<"unlock_function">]>]; 1419 let Documentation = [ReleaseCapabilityDocs]; 1420} 1421 1422def RequiresCapability : InheritableAttr { 1423 let Spellings = [GNU<"requires_capability">, 1424 CXX11<"clang", "requires_capability">, 1425 GNU<"exclusive_locks_required">, 1426 GNU<"requires_shared_capability">, 1427 CXX11<"clang", "requires_shared_capability">, 1428 GNU<"shared_locks_required">]; 1429 let Args = [VariadicExprArgument<"Args">]; 1430 let LateParsed = 1; 1431 let TemplateDependent = 1; 1432 let ParseArgumentsAsUnevaluated = 1; 1433 let DuplicatesAllowedWhileMerging = 1; 1434 let Subjects = SubjectList<[Function]>; 1435 let Accessors = [Accessor<"isShared", [GNU<"requires_shared_capability">, 1436 GNU<"shared_locks_required">, 1437 CXX11<"clang","requires_shared_capability">]>]; 1438 let Documentation = [Undocumented]; 1439} 1440 1441def NoThreadSafetyAnalysis : InheritableAttr { 1442 let Spellings = [GNU<"no_thread_safety_analysis">]; 1443 let Subjects = SubjectList<[Function]>; 1444 let Documentation = [Undocumented]; 1445} 1446 1447def GuardedBy : InheritableAttr { 1448 let Spellings = [GNU<"guarded_by">]; 1449 let Args = [ExprArgument<"Arg">]; 1450 let LateParsed = 1; 1451 let TemplateDependent = 1; 1452 let ParseArgumentsAsUnevaluated = 1; 1453 let DuplicatesAllowedWhileMerging = 1; 1454 let Subjects = SubjectList<[Field, SharedVar], WarnDiag, 1455 "ExpectedFieldOrGlobalVar">; 1456 let Documentation = [Undocumented]; 1457} 1458 1459def PtGuardedBy : InheritableAttr { 1460 let Spellings = [GNU<"pt_guarded_by">]; 1461 let Args = [ExprArgument<"Arg">]; 1462 let LateParsed = 1; 1463 let TemplateDependent = 1; 1464 let ParseArgumentsAsUnevaluated = 1; 1465 let DuplicatesAllowedWhileMerging = 1; 1466 let Subjects = SubjectList<[Field, SharedVar], WarnDiag, 1467 "ExpectedFieldOrGlobalVar">; 1468 let Documentation = [Undocumented]; 1469} 1470 1471def AcquiredAfter : InheritableAttr { 1472 let Spellings = [GNU<"acquired_after">]; 1473 let Args = [VariadicExprArgument<"Args">]; 1474 let LateParsed = 1; 1475 let TemplateDependent = 1; 1476 let ParseArgumentsAsUnevaluated = 1; 1477 let DuplicatesAllowedWhileMerging = 1; 1478 let Subjects = SubjectList<[Field, SharedVar], WarnDiag, 1479 "ExpectedFieldOrGlobalVar">; 1480 let Documentation = [Undocumented]; 1481} 1482 1483def AcquiredBefore : InheritableAttr { 1484 let Spellings = [GNU<"acquired_before">]; 1485 let Args = [VariadicExprArgument<"Args">]; 1486 let LateParsed = 1; 1487 let TemplateDependent = 1; 1488 let ParseArgumentsAsUnevaluated = 1; 1489 let DuplicatesAllowedWhileMerging = 1; 1490 let Subjects = SubjectList<[Field, SharedVar], WarnDiag, 1491 "ExpectedFieldOrGlobalVar">; 1492 let Documentation = [Undocumented]; 1493} 1494 1495def AssertExclusiveLock : InheritableAttr { 1496 let Spellings = [GNU<"assert_exclusive_lock">]; 1497 let Args = [VariadicExprArgument<"Args">]; 1498 let LateParsed = 1; 1499 let TemplateDependent = 1; 1500 let ParseArgumentsAsUnevaluated = 1; 1501 let DuplicatesAllowedWhileMerging = 1; 1502 let Subjects = SubjectList<[Function]>; 1503 let Documentation = [Undocumented]; 1504} 1505 1506def AssertSharedLock : InheritableAttr { 1507 let Spellings = [GNU<"assert_shared_lock">]; 1508 let Args = [VariadicExprArgument<"Args">]; 1509 let LateParsed = 1; 1510 let TemplateDependent = 1; 1511 let ParseArgumentsAsUnevaluated = 1; 1512 let DuplicatesAllowedWhileMerging = 1; 1513 let Subjects = SubjectList<[Function]>; 1514 let Documentation = [Undocumented]; 1515} 1516 1517// The first argument is an integer or boolean value specifying the return value 1518// of a successful lock acquisition. 1519def ExclusiveTrylockFunction : InheritableAttr { 1520 let Spellings = [GNU<"exclusive_trylock_function">]; 1521 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">]; 1522 let LateParsed = 1; 1523 let TemplateDependent = 1; 1524 let ParseArgumentsAsUnevaluated = 1; 1525 let DuplicatesAllowedWhileMerging = 1; 1526 let Subjects = SubjectList<[Function]>; 1527 let Documentation = [Undocumented]; 1528} 1529 1530// The first argument is an integer or boolean value specifying the return value 1531// of a successful lock acquisition. 1532def SharedTrylockFunction : InheritableAttr { 1533 let Spellings = [GNU<"shared_trylock_function">]; 1534 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">]; 1535 let LateParsed = 1; 1536 let TemplateDependent = 1; 1537 let ParseArgumentsAsUnevaluated = 1; 1538 let DuplicatesAllowedWhileMerging = 1; 1539 let Subjects = SubjectList<[Function]>; 1540 let Documentation = [Undocumented]; 1541} 1542 1543def LockReturned : InheritableAttr { 1544 let Spellings = [GNU<"lock_returned">]; 1545 let Args = [ExprArgument<"Arg">]; 1546 let LateParsed = 1; 1547 let TemplateDependent = 1; 1548 let ParseArgumentsAsUnevaluated = 1; 1549 let Subjects = SubjectList<[Function]>; 1550 let Documentation = [Undocumented]; 1551} 1552 1553def LocksExcluded : InheritableAttr { 1554 let Spellings = [GNU<"locks_excluded">]; 1555 let Args = [VariadicExprArgument<"Args">]; 1556 let LateParsed = 1; 1557 let TemplateDependent = 1; 1558 let ParseArgumentsAsUnevaluated = 1; 1559 let DuplicatesAllowedWhileMerging = 1; 1560 let Subjects = SubjectList<[Function]>; 1561 let Documentation = [Undocumented]; 1562} 1563 1564// C/C++ consumed attributes. 1565 1566def Consumable : InheritableAttr { 1567 let Spellings = [GNU<"consumable">]; 1568 let Subjects = SubjectList<[CXXRecord]>; 1569 let Args = [EnumArgument<"DefaultState", "ConsumedState", 1570 ["unknown", "consumed", "unconsumed"], 1571 ["Unknown", "Consumed", "Unconsumed"]>]; 1572 let Documentation = [ConsumableDocs]; 1573} 1574 1575def ConsumableAutoCast : InheritableAttr { 1576 let Spellings = [GNU<"consumable_auto_cast_state">]; 1577 let Subjects = SubjectList<[CXXRecord]>; 1578 let Documentation = [Undocumented]; 1579} 1580 1581def ConsumableSetOnRead : InheritableAttr { 1582 let Spellings = [GNU<"consumable_set_state_on_read">]; 1583 let Subjects = SubjectList<[CXXRecord]>; 1584 let Documentation = [Undocumented]; 1585} 1586 1587def CallableWhen : InheritableAttr { 1588 let Spellings = [GNU<"callable_when">]; 1589 let Subjects = SubjectList<[CXXMethod]>; 1590 let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState", 1591 ["unknown", "consumed", "unconsumed"], 1592 ["Unknown", "Consumed", "Unconsumed"]>]; 1593 let Documentation = [CallableWhenDocs]; 1594} 1595 1596def ParamTypestate : InheritableAttr { 1597 let Spellings = [GNU<"param_typestate">]; 1598 let Subjects = SubjectList<[ParmVar]>; 1599 let Args = [EnumArgument<"ParamState", "ConsumedState", 1600 ["unknown", "consumed", "unconsumed"], 1601 ["Unknown", "Consumed", "Unconsumed"]>]; 1602 let Documentation = [ParamTypestateDocs]; 1603} 1604 1605def ReturnTypestate : InheritableAttr { 1606 let Spellings = [GNU<"return_typestate">]; 1607 let Subjects = SubjectList<[Function, ParmVar]>; 1608 let Args = [EnumArgument<"State", "ConsumedState", 1609 ["unknown", "consumed", "unconsumed"], 1610 ["Unknown", "Consumed", "Unconsumed"]>]; 1611 let Documentation = [ReturnTypestateDocs]; 1612} 1613 1614def SetTypestate : InheritableAttr { 1615 let Spellings = [GNU<"set_typestate">]; 1616 let Subjects = SubjectList<[CXXMethod]>; 1617 let Args = [EnumArgument<"NewState", "ConsumedState", 1618 ["unknown", "consumed", "unconsumed"], 1619 ["Unknown", "Consumed", "Unconsumed"]>]; 1620 let Documentation = [SetTypestateDocs]; 1621} 1622 1623def TestTypestate : InheritableAttr { 1624 let Spellings = [GNU<"test_typestate">]; 1625 let Subjects = SubjectList<[CXXMethod]>; 1626 let Args = [EnumArgument<"TestState", "ConsumedState", 1627 ["consumed", "unconsumed"], 1628 ["Consumed", "Unconsumed"]>]; 1629 let Documentation = [TestTypestateDocs]; 1630} 1631 1632// Type safety attributes for `void *' pointers and type tags. 1633 1634def ArgumentWithTypeTag : InheritableAttr { 1635 let Spellings = [GNU<"argument_with_type_tag">, 1636 GNU<"pointer_with_type_tag">]; 1637 let Args = [IdentifierArgument<"ArgumentKind">, 1638 UnsignedArgument<"ArgumentIdx">, 1639 UnsignedArgument<"TypeTagIdx">, 1640 BoolArgument<"IsPointer">]; 1641 let HasCustomParsing = 1; 1642 let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs]; 1643} 1644 1645def TypeTagForDatatype : InheritableAttr { 1646 let Spellings = [GNU<"type_tag_for_datatype">]; 1647 let Args = [IdentifierArgument<"ArgumentKind">, 1648 TypeArgument<"MatchingCType">, 1649 BoolArgument<"LayoutCompatible">, 1650 BoolArgument<"MustBeNull">]; 1651// let Subjects = SubjectList<[Var], ErrorDiag>; 1652 let HasCustomParsing = 1; 1653 let Documentation = [TypeTagForDatatypeDocs]; 1654} 1655 1656// Microsoft-related attributes 1657 1658def MsProperty : IgnoredAttr { 1659 let Spellings = [Declspec<"property">]; 1660} 1661 1662def MsStruct : InheritableAttr { 1663 let Spellings = [GCC<"ms_struct">]; 1664 let Subjects = SubjectList<[Record]>; 1665 let Documentation = [Undocumented]; 1666} 1667 1668def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> { 1669 let Spellings = [Declspec<"dllexport">, GCC<"dllexport">]; 1670 let Subjects = SubjectList<[Function, Var, CXXRecord]>; 1671 let Documentation = [Undocumented]; 1672} 1673 1674def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> { 1675 let Spellings = [Declspec<"dllimport">, GCC<"dllimport">]; 1676 let Subjects = SubjectList<[Function, Var, CXXRecord]>; 1677 let Documentation = [Undocumented]; 1678} 1679 1680def SelectAny : InheritableAttr { 1681 let Spellings = [Declspec<"selectany">]; 1682 let LangOpts = [MicrosoftExt]; 1683 let Documentation = [Undocumented]; 1684} 1685 1686def Thread : Attr { 1687 let Spellings = [Declspec<"thread">]; 1688 let LangOpts = [MicrosoftExt]; 1689 let Documentation = [ThreadDocs]; 1690 let Subjects = SubjectList<[Var]>; 1691} 1692 1693def Win64 : IgnoredAttr { 1694 let Spellings = [Keyword<"__w64">]; 1695 let LangOpts = [MicrosoftExt]; 1696} 1697 1698def Ptr32 : TypeAttr { 1699 let Spellings = [Keyword<"__ptr32">]; 1700 let Documentation = [Undocumented]; 1701} 1702 1703def Ptr64 : TypeAttr { 1704 let Spellings = [Keyword<"__ptr64">]; 1705 let Documentation = [Undocumented]; 1706} 1707 1708def SPtr : TypeAttr { 1709 let Spellings = [Keyword<"__sptr">]; 1710 let Documentation = [Undocumented]; 1711} 1712 1713def UPtr : TypeAttr { 1714 let Spellings = [Keyword<"__uptr">]; 1715 let Documentation = [Undocumented]; 1716} 1717 1718def MSInheritance : InheritableAttr { 1719 let LangOpts = [MicrosoftExt]; 1720 let Args = [DefaultBoolArgument<"BestCase", 1>]; 1721 let Spellings = [Keyword<"__single_inheritance">, 1722 Keyword<"__multiple_inheritance">, 1723 Keyword<"__virtual_inheritance">, 1724 Keyword<"__unspecified_inheritance">]; 1725 let AdditionalMembers = [{ 1726 static bool hasVBPtrOffsetField(Spelling Inheritance) { 1727 return Inheritance == Keyword_unspecified_inheritance; 1728 } 1729 1730 // Only member pointers to functions need a this adjustment, since it can be 1731 // combined with the field offset for data pointers. 1732 static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) { 1733 return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance; 1734 } 1735 1736 static bool hasVBTableOffsetField(Spelling Inheritance) { 1737 return Inheritance >= Keyword_virtual_inheritance; 1738 } 1739 1740 static bool hasOnlyOneField(bool IsMemberFunction, 1741 Spelling Inheritance) { 1742 if (IsMemberFunction) 1743 return Inheritance <= Keyword_single_inheritance; 1744 return Inheritance <= Keyword_multiple_inheritance; 1745 } 1746 }]; 1747 let Documentation = [MSInheritanceDocs]; 1748} 1749 1750def MSVtorDisp : InheritableAttr { 1751 // This attribute has no spellings as it is only ever created implicitly. 1752 let Spellings = []; 1753 let Args = [UnsignedArgument<"vdm">]; 1754 let SemaHandler = 0; 1755 1756 let AdditionalMembers = [{ 1757 enum Mode { 1758 Never, 1759 ForVBaseOverride, 1760 ForVFTable 1761 }; 1762 1763 Mode getVtorDispMode() const { return Mode(vdm); } 1764 }]; 1765 let Documentation = [Undocumented]; 1766} 1767 1768def Unaligned : IgnoredAttr { 1769 let Spellings = [Keyword<"__unaligned">]; 1770} 1771 1772def LoopHint : Attr { 1773 /// vectorize: vectorizes loop operations if 'value != 0'. 1774 /// vectorize_width: vectorize loop operations with width 'value'. 1775 /// interleave: interleave multiple loop iterations if 'value != 0'. 1776 /// interleave_count: interleaves 'value' loop interations. 1777 /// unroll: unroll loop if 'value != 0'. 1778 /// unroll_count: unrolls loop 'value' times. 1779 1780 let Spellings = [Pragma<"clang", "loop">]; 1781 1782 /// State of the loop optimization specified by the spelling. 1783 let Args = [EnumArgument<"Option", "OptionType", 1784 ["vectorize", "vectorize_width", "interleave", "interleave_count", 1785 "unroll", "unroll_count"], 1786 ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount", 1787 "Unroll", "UnrollCount"]>, 1788 DefaultIntArgument<"Value", 1>]; 1789 1790 let AdditionalMembers = [{ 1791 static StringRef getOptionName(int Option) { 1792 switch(Option) { 1793 case Vectorize: return "vectorize"; 1794 case VectorizeWidth: return "vectorize_width"; 1795 case Interleave: return "interleave"; 1796 case InterleaveCount: return "interleave_count"; 1797 case Unroll: return "unroll"; 1798 case UnrollCount: return "unroll_count"; 1799 } 1800 llvm_unreachable("Unhandled LoopHint option."); 1801 } 1802 1803 static StringRef getValueName(int Value) { 1804 if (Value) 1805 return "enable"; 1806 return "disable"; 1807 } 1808 1809 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const { 1810 OS << getOptionName(option) << "("; 1811 if (option == VectorizeWidth || option == InterleaveCount || 1812 option == UnrollCount) 1813 OS << value; 1814 else 1815 OS << getValueName(value); 1816 OS << ")\n"; 1817 } 1818 }]; 1819 1820 let Documentation = [LoopHintDocs]; 1821} 1822