1//==--- Attr.td - attribute definitions -----------------------------------===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8 9// The documentation is organized by category. Attributes can have category- 10// specific documentation that is collated within the larger document. 11class DocumentationCategory<string name> { 12 string Name = name; 13 code Content = [{}]; 14} 15def DocCatFunction : DocumentationCategory<"Function Attributes">; 16def DocCatVariable : DocumentationCategory<"Variable Attributes">; 17def DocCatField : DocumentationCategory<"Field Attributes">; 18def DocCatType : DocumentationCategory<"Type Attributes">; 19def DocCatStmt : DocumentationCategory<"Statement Attributes">; 20def DocCatDecl : DocumentationCategory<"Declaration Attributes">; 21 22// Attributes listed under the Undocumented category do not generate any public 23// documentation. Ideally, this category should be used for internal-only 24// attributes which contain no spellings. 25def DocCatUndocumented : DocumentationCategory<"Undocumented">; 26 27class DocDeprecated<string replacement = ""> { 28 // If the Replacement field is empty, no replacement will be listed with the 29 // documentation. Otherwise, the documentation will specify the attribute has 30 // been superseded by this replacement. 31 string Replacement = replacement; 32} 33 34// Specifies the documentation to be associated with the given category. 35class Documentation { 36 DocumentationCategory Category; 37 code Content; 38 39 // If the heading is empty, one may be picked automatically. If the attribute 40 // only has one spelling, no heading is required as the attribute's sole 41 // spelling is sufficient. If all spellings are semantically common, the 42 // heading will be the semantic spelling. If the spellings are not 43 // semantically common and no heading is provided, an error will be emitted. 44 string Heading = ""; 45 46 // When set, specifies that the attribute is deprecated and can optionally 47 // specify a replacement attribute. 48 DocDeprecated Deprecated; 49} 50 51// Specifies that the attribute is explicitly undocumented. This can be a 52// helpful placeholder for the attribute while working on the implementation, 53// but should not be used once feature work has been completed. 54def Undocumented : Documentation { 55 let Category = DocCatUndocumented; 56} 57 58include "clang/Basic/AttrDocs.td" 59 60// An attribute's subject is whatever it appertains to. In this file, it is 61// more accurately a list of things that an attribute can appertain to. All 62// Decls and Stmts are possibly AttrSubjects (even though the syntax may not 63// allow attributes on a given Decl or Stmt). 64class AttrSubject; 65 66include "clang/Basic/DeclNodes.td" 67include "clang/Basic/StmtNodes.td" 68 69// A subset-subject is an AttrSubject constrained to operate only on some subset 70// of that subject. 71// 72// The code fragment is a boolean expression that will confirm that the subject 73// meets the requirements; the subject will have the name S, and will have the 74// type specified by the base. It should be a simple boolean expression. The 75// diagnostic string should be a comma-separated list of subject names. 76class SubsetSubject<AttrSubject base, code check, string diag> : AttrSubject { 77 AttrSubject Base = base; 78 code CheckCode = check; 79 string DiagSpelling = diag; 80} 81 82def LocalVar : SubsetSubject<Var, 83 [{S->hasLocalStorage() && !isa<ParmVarDecl>(S)}], 84 "local variables">; 85def NonParmVar : SubsetSubject<Var, 86 [{S->getKind() != Decl::ParmVar}], 87 "variables">; 88def NonLocalVar : SubsetSubject<Var, 89 [{!S->hasLocalStorage()}], 90 "variables with non-local storage">; 91def NonBitField : SubsetSubject<Field, 92 [{!S->isBitField()}], 93 "non-bit-field non-static data members">; 94 95def NonStaticCXXMethod : SubsetSubject<CXXMethod, 96 [{!S->isStatic()}], 97 "non-static member functions">; 98 99def NonStaticNonConstCXXMethod 100 : SubsetSubject<CXXMethod, 101 [{!S->isStatic() && !S->isConst()}], 102 "non-static non-const member functions">; 103 104def ObjCInstanceMethod : SubsetSubject<ObjCMethod, 105 [{S->isInstanceMethod()}], 106 "Objective-C instance methods">; 107 108def Struct : SubsetSubject<Record, 109 [{!S->isUnion()}], "structs">; 110 111def TLSVar : SubsetSubject<Var, 112 [{S->getTLSKind() != 0}], "thread-local variables">; 113 114def SharedVar : SubsetSubject<Var, 115 [{S->hasGlobalStorage() && !S->getTLSKind()}], 116 "global variables">; 117 118def GlobalVar : SubsetSubject<Var, 119 [{S->hasGlobalStorage()}], "global variables">; 120 121def InlineFunction : SubsetSubject<Function, 122 [{S->isInlineSpecified()}], "inline functions">; 123 124def FunctionTmpl 125 : SubsetSubject<Function, [{S->getTemplatedKind() == 126 FunctionDecl::TK_FunctionTemplate}], 127 "function templates">; 128 129// FIXME: this hack is needed because DeclNodes.td defines the base Decl node 130// type to be a class, not a definition. This makes it impossible to create an 131// attribute subject which accepts a Decl. Normally, this is not a problem, 132// because the attribute can have no Subjects clause to accomplish this. But in 133// the case of a SubsetSubject, there's no way to express it without this hack. 134def DeclBase : AttrSubject; 135def FunctionLike : SubsetSubject<DeclBase, 136 [{S->getFunctionType(false) != nullptr}], 137 "functions, function pointers">; 138 139def OpenCLKernelFunction 140 : SubsetSubject<Function, [{S->hasAttr<OpenCLKernelAttr>()}], 141 "kernel functions">; 142 143// HasFunctionProto is a more strict version of FunctionLike, so it should 144// never be specified in a Subjects list along with FunctionLike (due to the 145// inclusive nature of subject testing). 146def HasFunctionProto : SubsetSubject<DeclBase, 147 [{(S->getFunctionType(true) != nullptr && 148 isa<FunctionProtoType>(S->getFunctionType())) || 149 isa<ObjCMethodDecl>(S) || 150 isa<BlockDecl>(S)}], 151 "non-K&R-style functions">; 152 153// A subject that matches the implicit object parameter of a non-static member 154// function. Accepted as a function type attribute on the type of such a 155// member function. 156// FIXME: This does not actually ever match currently. 157def ImplicitObjectParameter 158 : SubsetSubject<Function, [{static_cast<void>(S), false}], 159 "implicit object parameters">; 160 161// A single argument to an attribute 162class Argument<string name, bit optional, bit fake = 0> { 163 string Name = name; 164 bit Optional = optional; 165 166 /// A fake argument is used to store and serialize additional information 167 /// in an attribute without actually changing its parsing or pretty-printing. 168 bit Fake = fake; 169} 170 171class BoolArgument<string name, bit opt = 0, bit fake = 0> : Argument<name, opt, 172 fake>; 173class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>; 174class IntArgument<string name, bit opt = 0> : Argument<name, opt>; 175class StringArgument<string name, bit opt = 0> : Argument<name, opt>; 176class ExprArgument<string name, bit opt = 0> : Argument<name, opt>; 177class DeclArgument<DeclNode kind, string name, bit opt = 0, bit fake = 0> 178 : Argument<name, opt, fake> { 179 DeclNode Kind = kind; 180} 181 182// An argument of a OMPDeclareVariantAttr that represents the `match` 183// clause of the declare variant by keeping the information (incl. nesting) in 184// an OMPTraitInfo object. 185// 186// With some exceptions, the `match(<context-selector>)` clause looks roughly 187// as follows: 188// context-selector := list<selector-set> 189// selector-set := <kind>={list<selector>} 190// selector := <kind>([score(<const-expr>):] list<trait>) 191// trait := <kind> 192// 193// The structure of an OMPTraitInfo object is a tree as defined below: 194// 195// OMPTraitInfo := {list<OMPTraitSet>} 196// OMPTraitSet := {Kind, list<OMPTraitSelector>} 197// OMPTraitSelector := {Kind, Expr, list<OMPTraitProperty>} 198// OMPTraitProperty := {Kind} 199// 200class OMPTraitInfoArgument<string name> : Argument<name, 0>; 201 202class TypeArgument<string name, bit opt = 0> : Argument<name, opt>; 203class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>; 204class VariadicUnsignedArgument<string name> : Argument<name, 1>; 205class VariadicExprArgument<string name> : Argument<name, 1>; 206class VariadicStringArgument<string name> : Argument<name, 1>; 207class VariadicIdentifierArgument<string name> : Argument<name, 1>; 208 209// Like VariadicUnsignedArgument except values are ParamIdx. 210class VariadicParamIdxArgument<string name> : Argument<name, 1>; 211 212// A list of identifiers matching parameters or ParamIdx indices. 213class VariadicParamOrParamIdxArgument<string name> : Argument<name, 1>; 214 215// Like VariadicParamIdxArgument but for a single function parameter index. 216class ParamIdxArgument<string name, bit opt = 0> : Argument<name, opt>; 217 218// A version of the form major.minor[.subminor]. 219class VersionArgument<string name, bit opt = 0> : Argument<name, opt>; 220 221// This one's a doozy, so it gets its own special type 222// It can be an unsigned integer, or a type. Either can 223// be dependent. 224class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>; 225 226// A bool argument with a default value 227class DefaultBoolArgument<string name, bit default, bit fake = 0> 228 : BoolArgument<name, 1, fake> { 229 bit Default = default; 230} 231 232// An integer argument with a default value 233class DefaultIntArgument<string name, int default> : IntArgument<name, 1> { 234 int Default = default; 235} 236 237// This argument is more complex, it includes the enumerator type name, 238// a list of strings to accept, and a list of enumerators to map them to. 239class EnumArgument<string name, string type, list<string> values, 240 list<string> enums, bit opt = 0, bit fake = 0> 241 : Argument<name, opt, fake> { 242 string Type = type; 243 list<string> Values = values; 244 list<string> Enums = enums; 245} 246 247// FIXME: There should be a VariadicArgument type that takes any other type 248// of argument and generates the appropriate type. 249class VariadicEnumArgument<string name, string type, list<string> values, 250 list<string> enums> : Argument<name, 1> { 251 string Type = type; 252 list<string> Values = values; 253 list<string> Enums = enums; 254} 255 256// This handles one spelling of an attribute. 257class Spelling<string name, string variety> { 258 string Name = name; 259 string Variety = variety; 260} 261 262class GNU<string name> : Spelling<name, "GNU">; 263class Declspec<string name> : Spelling<name, "Declspec">; 264class Microsoft<string name> : Spelling<name, "Microsoft">; 265class CXX11<string namespace, string name, int version = 1> 266 : Spelling<name, "CXX11"> { 267 string Namespace = namespace; 268 int Version = version; 269} 270class C2x<string namespace, string name> : Spelling<name, "C2x"> { 271 string Namespace = namespace; 272} 273 274class Keyword<string name> : Spelling<name, "Keyword">; 275class Pragma<string namespace, string name> : Spelling<name, "Pragma"> { 276 string Namespace = namespace; 277} 278 279// The GCC spelling implies GNU<name>, CXX11<"gnu", name>, and optionally, 280// C2x<"gnu", name>. This spelling should be used for any GCC-compatible 281// attributes. 282class GCC<string name, bit allowInC = 1> : Spelling<name, "GCC"> { 283 bit AllowInC = allowInC; 284} 285 286// The Clang spelling implies GNU<name>, CXX11<"clang", name>, and optionally, 287// C2x<"clang", name>. This spelling should be used for any Clang-specific 288// attributes. 289class Clang<string name, bit allowInC = 1> : Spelling<name, "Clang"> { 290 bit AllowInC = allowInC; 291} 292 293class Accessor<string name, list<Spelling> spellings> { 294 string Name = name; 295 list<Spelling> Spellings = spellings; 296} 297 298class SubjectDiag<bit warn> { 299 bit Warn = warn; 300} 301def WarnDiag : SubjectDiag<1>; 302def ErrorDiag : SubjectDiag<0>; 303 304class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag, 305 string customDiag = ""> { 306 list<AttrSubject> Subjects = subjects; 307 SubjectDiag Diag = diag; 308 string CustomDiag = customDiag; 309} 310 311class LangOpt<string name, code customCode = [{}]> { 312 // The language option to test; ignored when custom code is supplied. 313 string Name = name; 314 315 // A custom predicate, written as an expression evaluated in a context with 316 // "LangOpts" bound. 317 code CustomCode = customCode; 318} 319def MicrosoftExt : LangOpt<"MicrosoftExt">; 320def Borland : LangOpt<"Borland">; 321def CUDA : LangOpt<"CUDA">; 322def SYCL : LangOpt<"SYCLIsDevice">; 323def COnly : LangOpt<"", "!LangOpts.CPlusPlus">; 324def CPlusPlus : LangOpt<"CPlusPlus">; 325def OpenCL : LangOpt<"OpenCL">; 326def RenderScript : LangOpt<"RenderScript">; 327def ObjC : LangOpt<"ObjC">; 328def BlocksSupported : LangOpt<"Blocks">; 329def ObjCAutoRefCount : LangOpt<"ObjCAutoRefCount">; 330def ObjCNonFragileRuntime 331 : LangOpt<"", "LangOpts.ObjCRuntime.allowsClassStubs()">; 332 333// Language option for CMSE extensions 334def Cmse : LangOpt<"Cmse">; 335 336// Defines targets for target-specific attributes. Empty lists are unchecked. 337class TargetSpec { 338 // Specifies Architectures for which the target applies, based off the 339 // ArchType enumeration in Triple.h. 340 list<string> Arches = []; 341 // Specifies Operating Systems for which the target applies, based off the 342 // OSType enumeration in Triple.h 343 list<string> OSes; 344 // Specifies Object Formats for which the target applies, based off the 345 // ObjectFormatType enumeration in Triple.h 346 list<string> ObjectFormats; 347 // A custom predicate, written as an expression evaluated in a context 348 // with the following declarations in scope: 349 // const clang::TargetInfo &Target; 350 // const llvm::Triple &T = Target.getTriple(); 351 code CustomCode = [{}]; 352} 353 354class TargetArch<list<string> arches> : TargetSpec { 355 let Arches = arches; 356} 357def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>; 358def TargetAArch64 : TargetArch<["aarch64"]>; 359def TargetAnyArm : TargetArch<!listconcat(TargetARM.Arches, TargetAArch64.Arches)>; 360def TargetAVR : TargetArch<["avr"]>; 361def TargetBPF : TargetArch<["bpfel", "bpfeb"]>; 362def TargetMips32 : TargetArch<["mips", "mipsel"]>; 363def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>; 364def TargetMSP430 : TargetArch<["msp430"]>; 365def TargetRISCV : TargetArch<["riscv32", "riscv64"]>; 366def TargetX86 : TargetArch<["x86"]>; 367def TargetAnyX86 : TargetArch<["x86", "x86_64"]>; 368def TargetWebAssembly : TargetArch<["wasm32", "wasm64"]>; 369def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> { 370 let OSes = ["Win32"]; 371} 372def TargetItaniumCXXABI : TargetSpec { 373 let CustomCode = [{ Target.getCXXABI().isItaniumFamily() }]; 374} 375def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> { 376 let CustomCode = [{ Target.getCXXABI().isMicrosoft() }]; 377} 378def TargetELF : TargetSpec { 379 let ObjectFormats = ["ELF"]; 380} 381 382// Attribute subject match rules that are used for #pragma clang attribute. 383// 384// A instance of AttrSubjectMatcherRule represents an individual match rule. 385// An individual match rule can correspond to a number of different attribute 386// subjects, e.g. "record" matching rule corresponds to the Record and 387// CXXRecord attribute subjects. 388// 389// Match rules are used in the subject list of the #pragma clang attribute. 390// Match rules can have sub-match rules that are instances of 391// AttrSubjectMatcherSubRule. A sub-match rule can correspond to a number 392// of different attribute subjects, and it can have a negated spelling as well. 393// For example, "variable(unless(is_parameter))" matching rule corresponds to 394// the NonParmVar attribute subject. 395class AttrSubjectMatcherSubRule<string name, list<AttrSubject> subjects, 396 bit negated = 0> { 397 string Name = name; 398 list<AttrSubject> Subjects = subjects; 399 bit Negated = negated; 400 // Lists language options, one of which is required to be true for the 401 // attribute to be applicable. If empty, the language options are taken 402 // from the parent matcher rule. 403 list<LangOpt> LangOpts = []; 404} 405class AttrSubjectMatcherRule<string name, list<AttrSubject> subjects, 406 list<AttrSubjectMatcherSubRule> subrules = []> { 407 string Name = name; 408 list<AttrSubject> Subjects = subjects; 409 list<AttrSubjectMatcherSubRule> Constraints = subrules; 410 // Lists language options, one of which is required to be true for the 411 // attribute to be applicable. If empty, no language options are required. 412 list<LangOpt> LangOpts = []; 413} 414 415// function(is_member) 416def SubRuleForCXXMethod : AttrSubjectMatcherSubRule<"is_member", [CXXMethod]> { 417 let LangOpts = [CPlusPlus]; 418} 419def SubjectMatcherForFunction : AttrSubjectMatcherRule<"function", [Function], [ 420 SubRuleForCXXMethod 421]>; 422// hasType is abstract, it should be used with one of the sub-rules. 423def SubjectMatcherForType : AttrSubjectMatcherRule<"hasType", [], [ 424 AttrSubjectMatcherSubRule<"functionType", [FunctionLike]> 425 426 // FIXME: There's a matcher ambiguity with objc methods and blocks since 427 // functionType excludes them but functionProtoType includes them. 428 // AttrSubjectMatcherSubRule<"functionProtoType", [HasFunctionProto]> 429]>; 430def SubjectMatcherForTypedef : AttrSubjectMatcherRule<"type_alias", 431 [TypedefName]>; 432def SubjectMatcherForRecord : AttrSubjectMatcherRule<"record", [Record, 433 CXXRecord], [ 434 // unless(is_union) 435 AttrSubjectMatcherSubRule<"is_union", [Struct], 1> 436]>; 437def SubjectMatcherForEnum : AttrSubjectMatcherRule<"enum", [Enum]>; 438def SubjectMatcherForEnumConstant : AttrSubjectMatcherRule<"enum_constant", 439 [EnumConstant]>; 440def SubjectMatcherForVar : AttrSubjectMatcherRule<"variable", [Var], [ 441 AttrSubjectMatcherSubRule<"is_thread_local", [TLSVar]>, 442 AttrSubjectMatcherSubRule<"is_global", [GlobalVar]>, 443 AttrSubjectMatcherSubRule<"is_local", [LocalVar]>, 444 AttrSubjectMatcherSubRule<"is_parameter", [ParmVar]>, 445 // unless(is_parameter) 446 AttrSubjectMatcherSubRule<"is_parameter", [NonParmVar], 1> 447]>; 448def SubjectMatcherForField : AttrSubjectMatcherRule<"field", [Field]>; 449def SubjectMatcherForNamespace : AttrSubjectMatcherRule<"namespace", 450 [Namespace]> { 451 let LangOpts = [CPlusPlus]; 452} 453def SubjectMatcherForObjCInterface : AttrSubjectMatcherRule<"objc_interface", 454 [ObjCInterface]> { 455 let LangOpts = [ObjC]; 456} 457def SubjectMatcherForObjCProtocol : AttrSubjectMatcherRule<"objc_protocol", 458 [ObjCProtocol]> { 459 let LangOpts = [ObjC]; 460} 461def SubjectMatcherForObjCCategory : AttrSubjectMatcherRule<"objc_category", 462 [ObjCCategory]> { 463 let LangOpts = [ObjC]; 464} 465def SubjectMatcherForObjCImplementation : 466 AttrSubjectMatcherRule<"objc_implementation", [ObjCImpl]> { 467 let LangOpts = [ObjC]; 468} 469def SubjectMatcherForObjCMethod : AttrSubjectMatcherRule<"objc_method", 470 [ObjCMethod], [ 471 AttrSubjectMatcherSubRule<"is_instance", [ObjCInstanceMethod]> 472]> { 473 let LangOpts = [ObjC]; 474} 475def SubjectMatcherForObjCProperty : AttrSubjectMatcherRule<"objc_property", 476 [ObjCProperty]> { 477 let LangOpts = [ObjC]; 478} 479def SubjectMatcherForBlock : AttrSubjectMatcherRule<"block", [Block]> { 480 let LangOpts = [BlocksSupported]; 481} 482 483// Aggregate attribute subject match rules are abstract match rules that can't 484// be used directly in #pragma clang attribute. Instead, users have to use 485// subject match rules that correspond to attribute subjects that derive from 486// the specified subject. 487class AttrSubjectMatcherAggregateRule<AttrSubject subject> { 488 AttrSubject Subject = subject; 489} 490 491def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule<Named>; 492 493class Attr { 494 // The various ways in which an attribute can be spelled in source 495 list<Spelling> Spellings; 496 // The things to which an attribute can appertain 497 SubjectList Subjects; 498 // The arguments allowed on an attribute 499 list<Argument> Args = []; 500 // Accessors which should be generated for the attribute. 501 list<Accessor> Accessors = []; 502 // Set to true for attributes with arguments which require delayed parsing. 503 bit LateParsed = 0; 504 // Set to false to prevent an attribute from being propagated from a template 505 // to the instantiation. 506 bit Clone = 1; 507 // Set to true for attributes which must be instantiated within templates 508 bit TemplateDependent = 0; 509 // Set to true for attributes that have a corresponding AST node. 510 bit ASTNode = 1; 511 // Set to true for attributes which have handler in Sema. 512 bit SemaHandler = 1; 513 // Set to true if this attribute doesn't need custom handling in Sema. 514 bit SimpleHandler = 0; 515 // Set to true for attributes that are completely ignored. 516 bit Ignored = 0; 517 // Set to true if the attribute's parsing does not match its semantic 518 // content. Eg) It parses 3 args, but semantically takes 4 args. Opts out of 519 // common attribute error checking. 520 bit HasCustomParsing = 0; 521 // Set to true if all of the attribute's arguments should be parsed in an 522 // unevaluated context. 523 bit ParseArgumentsAsUnevaluated = 0; 524 // Set to true if this attribute meaningful when applied to or inherited 525 // in a class template definition. 526 bit MeaningfulToClassTemplateDefinition = 0; 527 // Set to true if this attribute can be used with '#pragma clang attribute'. 528 // By default, an attribute is supported by the '#pragma clang attribute' 529 // only when: 530 // - It has a subject list whose subjects can be represented using subject 531 // match rules. 532 // - It has GNU/CXX11 spelling and doesn't require delayed parsing. 533 bit PragmaAttributeSupport; 534 // Lists language options, one of which is required to be true for the 535 // attribute to be applicable. If empty, no language options are required. 536 list<LangOpt> LangOpts = []; 537 // Any additional text that should be included verbatim in the class. 538 // Note: Any additional data members will leak and should be constructed 539 // externally on the ASTContext. 540 code AdditionalMembers = [{}]; 541 // Any documentation that should be associated with the attribute. Since an 542 // attribute may be documented under multiple categories, more than one 543 // Documentation entry may be listed. 544 list<Documentation> Documentation; 545} 546 547/// A type attribute is not processed on a declaration or a statement. 548class TypeAttr : Attr; 549 550/// A stmt attribute is not processed on a declaration or a type. 551class StmtAttr : Attr; 552 553/// An inheritable attribute is inherited by later redeclarations. 554class InheritableAttr : Attr { 555 // Set to true if this attribute can be duplicated on a subject when inheriting 556 // attributes from prior declarations. 557 bit InheritEvenIfAlreadyPresent = 0; 558} 559 560/// Some attributes, like calling conventions, can appear in either the 561/// declaration or the type position. These attributes are morally type 562/// attributes, but have historically been written on declarations. 563class DeclOrTypeAttr : InheritableAttr; 564 565/// A target-specific attribute. This class is meant to be used as a mixin 566/// with InheritableAttr or Attr depending on the attribute's needs. 567class TargetSpecificAttr<TargetSpec target> { 568 TargetSpec Target = target; 569 // Attributes are generally required to have unique spellings for their names 570 // so that the parser can determine what kind of attribute it has parsed. 571 // However, target-specific attributes are special in that the attribute only 572 // "exists" for a given target. So two target-specific attributes can share 573 // the same name when they exist in different targets. To support this, a 574 // Kind can be explicitly specified for a target-specific attribute. This 575 // corresponds to the ParsedAttr::AT_* enum that is generated and it 576 // should contain a shared value between the attributes. 577 // 578 // Target-specific attributes which use this feature should ensure that the 579 // spellings match exactly between the attributes, and if the arguments or 580 // subjects differ, should specify HasCustomParsing = 1 and implement their 581 // own parsing and semantic handling requirements as-needed. 582 string ParseKind; 583} 584 585/// An inheritable parameter attribute is inherited by later 586/// redeclarations, even when it's written on a parameter. 587class InheritableParamAttr : InheritableAttr; 588 589/// An attribute which changes the ABI rules for a specific parameter. 590class ParameterABIAttr : InheritableParamAttr { 591 let Subjects = SubjectList<[ParmVar]>; 592} 593 594/// An ignored attribute, which we parse but discard with no checking. 595class IgnoredAttr : Attr { 596 let Ignored = 1; 597 let ASTNode = 0; 598 let SemaHandler = 0; 599 let Documentation = [Undocumented]; 600} 601 602// 603// Attributes begin here 604// 605 606def AbiTag : Attr { 607 let Spellings = [GCC<"abi_tag", /*AllowInC*/0>]; 608 let Args = [VariadicStringArgument<"Tags">]; 609 let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag>; 610 let MeaningfulToClassTemplateDefinition = 1; 611 let Documentation = [AbiTagsDocs]; 612} 613 614def AddressSpace : TypeAttr { 615 let Spellings = [Clang<"address_space">]; 616 let Args = [IntArgument<"AddressSpace">]; 617 let Documentation = [Undocumented]; 618} 619 620def Alias : Attr { 621 let Spellings = [GCC<"alias">]; 622 let Args = [StringArgument<"Aliasee">]; 623 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>; 624 let Documentation = [Undocumented]; 625} 626 627def ArmBuiltinAlias : InheritableAttr, TargetSpecificAttr<TargetAnyArm> { 628 let Spellings = [Clang<"__clang_arm_builtin_alias">]; 629 let Args = [IdentifierArgument<"BuiltinName">]; 630 let Subjects = SubjectList<[Function], ErrorDiag>; 631 let Documentation = [ArmBuiltinAliasDocs]; 632} 633 634def Aligned : InheritableAttr { 635 let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">, 636 Keyword<"_Alignas">]; 637 let Args = [AlignedArgument<"Alignment", 1>]; 638 let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>, 639 Accessor<"isC11", [Keyword<"_Alignas">]>, 640 Accessor<"isAlignas", [Keyword<"alignas">, 641 Keyword<"_Alignas">]>, 642 Accessor<"isDeclspec",[Declspec<"align">]>]; 643 let Documentation = [Undocumented]; 644} 645 646def AlignValue : Attr { 647 let Spellings = [ 648 // Unfortunately, this is semantically an assertion, not a directive 649 // (something else must ensure the alignment), so aligned_value is a 650 // probably a better name. We might want to add an aligned_value spelling in 651 // the future (and a corresponding C++ attribute), but this can be done 652 // later once we decide if we also want them to have slightly-different 653 // semantics than Intel's align_value. 654 // 655 // Does not get a [[]] spelling because the attribute is not exposed as such 656 // by Intel. 657 GNU<"align_value"> 658 // Intel's compiler on Windows also supports: 659 // , Declspec<"align_value"> 660 ]; 661 let Args = [ExprArgument<"Alignment">]; 662 let Subjects = SubjectList<[Var, TypedefName]>; 663 let Documentation = [AlignValueDocs]; 664} 665 666def AlignMac68k : InheritableAttr { 667 // This attribute has no spellings as it is only ever created implicitly. 668 let Spellings = []; 669 let SemaHandler = 0; 670 let Documentation = [Undocumented]; 671} 672 673def AlwaysInline : InheritableAttr { 674 let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">]; 675 let Subjects = SubjectList<[Function]>; 676 let Documentation = [Undocumented]; 677} 678 679def Artificial : InheritableAttr { 680 let Spellings = [GCC<"artificial">]; 681 let Subjects = SubjectList<[InlineFunction]>; 682 let Documentation = [ArtificialDocs]; 683 let SimpleHandler = 1; 684} 685 686def XRayInstrument : InheritableAttr { 687 let Spellings = [Clang<"xray_always_instrument">, 688 Clang<"xray_never_instrument">]; 689 let Subjects = SubjectList<[Function, ObjCMethod]>; 690 let Accessors = [Accessor<"alwaysXRayInstrument", 691 [Clang<"xray_always_instrument">]>, 692 Accessor<"neverXRayInstrument", 693 [Clang<"xray_never_instrument">]>]; 694 let Documentation = [XRayDocs]; 695 let SimpleHandler = 1; 696} 697 698def XRayLogArgs : InheritableAttr { 699 let Spellings = [Clang<"xray_log_args">]; 700 let Subjects = SubjectList<[Function, ObjCMethod]>; 701 // This argument is a count not an index, so it has the same encoding (base 702 // 1 including C++ implicit this parameter) at the source and LLVM levels of 703 // representation, so ParamIdxArgument is inappropriate. It is never used 704 // at the AST level of representation, so it never needs to be adjusted not 705 // to include any C++ implicit this parameter. Thus, we just store it and 706 // use it as an unsigned that never needs adjustment. 707 let Args = [UnsignedArgument<"ArgumentCount">]; 708 let Documentation = [XRayDocs]; 709} 710 711def PatchableFunctionEntry 712 : InheritableAttr, 713 TargetSpecificAttr<TargetArch<["aarch64", "aarch64_be", "x86", "x86_64"]>> { 714 let Spellings = [GCC<"patchable_function_entry">]; 715 let Subjects = SubjectList<[Function, ObjCMethod]>; 716 let Args = [UnsignedArgument<"Count">, DefaultIntArgument<"Offset", 0>]; 717 let Documentation = [PatchableFunctionEntryDocs]; 718} 719 720def TLSModel : InheritableAttr { 721 let Spellings = [GCC<"tls_model">]; 722 let Subjects = SubjectList<[TLSVar], ErrorDiag>; 723 let Args = [StringArgument<"Model">]; 724 let Documentation = [TLSModelDocs]; 725} 726 727def AnalyzerNoReturn : InheritableAttr { 728 // TODO: should this attribute be exposed with a [[]] spelling under the clang 729 // vendor namespace, or should it use a vendor namespace specific to the 730 // analyzer? 731 let Spellings = [GNU<"analyzer_noreturn">]; 732 // TODO: Add subject list. 733 let Documentation = [Undocumented]; 734} 735 736def Annotate : InheritableParamAttr { 737 let Spellings = [Clang<"annotate">]; 738 let Args = [StringArgument<"Annotation">]; 739 // Ensure that the annotate attribute can be used with 740 // '#pragma clang attribute' even though it has no subject list. 741 let PragmaAttributeSupport = 1; 742 let Documentation = [Undocumented]; 743} 744 745def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> { 746 // NOTE: If you add any additional spellings, MSP430Interrupt's, 747 // MipsInterrupt's and AnyX86Interrupt's spellings must match. 748 let Spellings = [GCC<"interrupt">]; 749 let Args = [EnumArgument<"Interrupt", "InterruptType", 750 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""], 751 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"], 752 1>]; 753 let ParseKind = "Interrupt"; 754 let HasCustomParsing = 1; 755 let Documentation = [ARMInterruptDocs]; 756} 757 758def AVRInterrupt : InheritableAttr, TargetSpecificAttr<TargetAVR> { 759 let Spellings = [GCC<"interrupt">]; 760 let Subjects = SubjectList<[Function]>; 761 let ParseKind = "Interrupt"; 762 let Documentation = [AVRInterruptDocs]; 763} 764 765def AVRSignal : InheritableAttr, TargetSpecificAttr<TargetAVR> { 766 let Spellings = [GCC<"signal">]; 767 let Subjects = SubjectList<[Function]>; 768 let Documentation = [AVRSignalDocs]; 769} 770 771def AsmLabel : InheritableAttr { 772 let Spellings = [Keyword<"asm">, Keyword<"__asm__">]; 773 let Args = [ 774 // Label specifies the mangled name for the decl. 775 StringArgument<"Label">, 776 777 // IsLiteralLabel specifies whether the label is literal (i.e. suppresses 778 // the global C symbol prefix) or not. If not, the mangle-suppression prefix 779 // ('\01') is omitted from the decl name at the LLVM IR level. 780 // 781 // Non-literal labels are used by some external AST sources like LLDB. 782 BoolArgument<"IsLiteralLabel", /*optional=*/0, /*fake=*/1> 783 ]; 784 let SemaHandler = 0; 785 let Documentation = [AsmLabelDocs]; 786 let AdditionalMembers = 787[{ 788bool isEquivalent(AsmLabelAttr *Other) const { 789 return getLabel() == Other->getLabel() && getIsLiteralLabel() == Other->getIsLiteralLabel(); 790} 791}]; 792} 793 794def Availability : InheritableAttr { 795 let Spellings = [Clang<"availability">]; 796 let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">, 797 VersionArgument<"deprecated">, VersionArgument<"obsoleted">, 798 BoolArgument<"unavailable">, StringArgument<"message">, 799 BoolArgument<"strict">, StringArgument<"replacement">, 800 IntArgument<"priority">]; 801 let AdditionalMembers = 802[{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) { 803 return llvm::StringSwitch<llvm::StringRef>(Platform) 804 .Case("android", "Android") 805 .Case("ios", "iOS") 806 .Case("macos", "macOS") 807 .Case("tvos", "tvOS") 808 .Case("watchos", "watchOS") 809 .Case("ios_app_extension", "iOS (App Extension)") 810 .Case("macos_app_extension", "macOS (App Extension)") 811 .Case("tvos_app_extension", "tvOS (App Extension)") 812 .Case("watchos_app_extension", "watchOS (App Extension)") 813 .Case("swift", "Swift") 814 .Default(llvm::StringRef()); 815} 816static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) { 817 return llvm::StringSwitch<llvm::StringRef>(Platform) 818 .Case("ios", "iOS") 819 .Case("macos", "macOS") 820 .Case("tvos", "tvOS") 821 .Case("watchos", "watchOS") 822 .Case("ios_app_extension", "iOSApplicationExtension") 823 .Case("macos_app_extension", "macOSApplicationExtension") 824 .Case("tvos_app_extension", "tvOSApplicationExtension") 825 .Case("watchos_app_extension", "watchOSApplicationExtension") 826 .Default(Platform); 827} 828static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) { 829 return llvm::StringSwitch<llvm::StringRef>(Platform) 830 .Case("iOS", "ios") 831 .Case("macOS", "macos") 832 .Case("tvOS", "tvos") 833 .Case("watchOS", "watchos") 834 .Case("iOSApplicationExtension", "ios_app_extension") 835 .Case("macOSApplicationExtension", "macos_app_extension") 836 .Case("tvOSApplicationExtension", "tvos_app_extension") 837 .Case("watchOSApplicationExtension", "watchos_app_extension") 838 .Default(Platform); 839} }]; 840 let HasCustomParsing = 1; 841 let InheritEvenIfAlreadyPresent = 1; 842 let Subjects = SubjectList<[Named]>; 843 let Documentation = [AvailabilityDocs]; 844} 845 846def ExternalSourceSymbol : InheritableAttr { 847 let Spellings = [Clang<"external_source_symbol">]; 848 let Args = [StringArgument<"language", 1>, 849 StringArgument<"definedIn", 1>, 850 BoolArgument<"generatedDeclaration", 1>]; 851 let HasCustomParsing = 1; 852 let Subjects = SubjectList<[Named]>; 853 let Documentation = [ExternalSourceSymbolDocs]; 854} 855 856def Blocks : InheritableAttr { 857 let Spellings = [Clang<"blocks">]; 858 let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>]; 859 let Documentation = [Undocumented]; 860} 861 862def Bounded : IgnoredAttr { 863 // Does not have a [[]] spelling because the attribute is ignored. 864 let Spellings = [GNU<"bounded">]; 865} 866 867def CarriesDependency : InheritableParamAttr { 868 let Spellings = [GNU<"carries_dependency">, 869 CXX11<"","carries_dependency", 200809>]; 870 let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>; 871 let Documentation = [CarriesDependencyDocs]; 872} 873 874def CDecl : DeclOrTypeAttr { 875 let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">]; 876// let Subjects = [Function, ObjCMethod]; 877 let Documentation = [Undocumented]; 878} 879 880// cf_audited_transfer indicates that the given function has been 881// audited and has been marked with the appropriate cf_consumed and 882// cf_returns_retained attributes. It is generally applied by 883// '#pragma clang arc_cf_code_audited' rather than explicitly. 884def CFAuditedTransfer : InheritableAttr { 885 let Spellings = [Clang<"cf_audited_transfer">]; 886 let Subjects = SubjectList<[Function], ErrorDiag>; 887 let Documentation = [Undocumented]; 888} 889 890// cf_unknown_transfer is an explicit opt-out of cf_audited_transfer. 891// It indicates that the function has unknown or unautomatable 892// transfer semantics. 893def CFUnknownTransfer : InheritableAttr { 894 let Spellings = [Clang<"cf_unknown_transfer">]; 895 let Subjects = SubjectList<[Function], ErrorDiag>; 896 let Documentation = [Undocumented]; 897} 898 899def CFReturnsRetained : InheritableAttr { 900 let Spellings = [Clang<"cf_returns_retained">]; 901// let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>; 902 let Documentation = [RetainBehaviorDocs]; 903} 904 905def CFReturnsNotRetained : InheritableAttr { 906 let Spellings = [Clang<"cf_returns_not_retained">]; 907// let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>; 908 let Documentation = [RetainBehaviorDocs]; 909} 910 911def CFConsumed : InheritableParamAttr { 912 let Spellings = [Clang<"cf_consumed">]; 913 let Subjects = SubjectList<[ParmVar]>; 914 let Documentation = [RetainBehaviorDocs]; 915} 916 917// OSObject-based attributes. 918def OSConsumed : InheritableParamAttr { 919 let Spellings = [Clang<"os_consumed">]; 920 let Subjects = SubjectList<[ParmVar]>; 921 let Documentation = [RetainBehaviorDocs]; 922} 923 924def OSReturnsRetained : InheritableAttr { 925 let Spellings = [Clang<"os_returns_retained">]; 926 let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty, ParmVar]>; 927 let Documentation = [RetainBehaviorDocs]; 928} 929 930def OSReturnsNotRetained : InheritableAttr { 931 let Spellings = [Clang<"os_returns_not_retained">]; 932 let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty, ParmVar]>; 933 let Documentation = [RetainBehaviorDocs]; 934} 935 936def OSReturnsRetainedOnZero : InheritableAttr { 937 let Spellings = [Clang<"os_returns_retained_on_zero">]; 938 let Subjects = SubjectList<[ParmVar]>; 939 let Documentation = [RetainBehaviorDocs]; 940} 941 942def OSReturnsRetainedOnNonZero : InheritableAttr { 943 let Spellings = [Clang<"os_returns_retained_on_non_zero">]; 944 let Subjects = SubjectList<[ParmVar]>; 945 let Documentation = [RetainBehaviorDocs]; 946} 947 948def OSConsumesThis : InheritableAttr { 949 let Spellings = [Clang<"os_consumes_this">]; 950 let Subjects = SubjectList<[NonStaticCXXMethod]>; 951 let Documentation = [RetainBehaviorDocs]; 952 let SimpleHandler = 1; 953} 954 955def Cleanup : InheritableAttr { 956 let Spellings = [GCC<"cleanup">]; 957 let Args = [DeclArgument<Function, "FunctionDecl">]; 958 let Subjects = SubjectList<[LocalVar]>; 959 let Documentation = [Undocumented]; 960} 961 962def CmseNSEntry : InheritableAttr, TargetSpecificAttr<TargetARM> { 963 let Spellings = [GNU<"cmse_nonsecure_entry">]; 964 let Subjects = SubjectList<[Function]>; 965 let LangOpts = [Cmse]; 966 let Documentation = [ArmCmseNSEntryDocs]; 967} 968 969def CmseNSCall : TypeAttr, TargetSpecificAttr<TargetARM> { 970 let Spellings = [GNU<"cmse_nonsecure_call">]; 971 let LangOpts = [Cmse]; 972 let Documentation = [ArmCmseNSCallDocs]; 973} 974 975def Cold : InheritableAttr { 976 let Spellings = [GCC<"cold">]; 977 let Subjects = SubjectList<[Function]>; 978 let Documentation = [Undocumented]; 979} 980 981def Common : InheritableAttr { 982 let Spellings = [GCC<"common">]; 983 let Subjects = SubjectList<[Var]>; 984 let Documentation = [Undocumented]; 985} 986 987def Const : InheritableAttr { 988 let Spellings = [GCC<"const">, GCC<"__const">]; 989 let Documentation = [Undocumented]; 990 let SimpleHandler = 1; 991} 992 993def ConstInit : InheritableAttr { 994 // This attribute does not have a C [[]] spelling because it requires the 995 // CPlusPlus language option. 996 let Spellings = [Keyword<"constinit">, 997 Clang<"require_constant_initialization", 0>]; 998 let Subjects = SubjectList<[GlobalVar], ErrorDiag>; 999 let Accessors = [Accessor<"isConstinit", [Keyword<"constinit">]>]; 1000 let Documentation = [ConstInitDocs]; 1001 let LangOpts = [CPlusPlus]; 1002 let SimpleHandler = 1; 1003} 1004 1005def Constructor : InheritableAttr { 1006 let Spellings = [GCC<"constructor">]; 1007 let Args = [DefaultIntArgument<"Priority", 65535>]; 1008 let Subjects = SubjectList<[Function]>; 1009 let Documentation = [Undocumented]; 1010} 1011 1012def CPUSpecific : InheritableAttr { 1013 let Spellings = [Clang<"cpu_specific">, Declspec<"cpu_specific">]; 1014 let Args = [VariadicIdentifierArgument<"Cpus">]; 1015 let Subjects = SubjectList<[Function]>; 1016 let Documentation = [CPUSpecificCPUDispatchDocs]; 1017 let AdditionalMembers = [{ 1018 IdentifierInfo *getCPUName(unsigned Index) const { 1019 return *(cpus_begin() + Index); 1020 } 1021 }]; 1022} 1023 1024def CPUDispatch : InheritableAttr { 1025 let Spellings = [Clang<"cpu_dispatch">, Declspec<"cpu_dispatch">]; 1026 let Args = [VariadicIdentifierArgument<"Cpus">]; 1027 let Subjects = SubjectList<[Function]>; 1028 let Documentation = [CPUSpecificCPUDispatchDocs]; 1029} 1030 1031// CUDA attributes are spelled __attribute__((attr)) or __declspec(__attr__), 1032// and they do not receive a [[]] spelling. 1033def CUDAConstant : InheritableAttr { 1034 let Spellings = [GNU<"constant">, Declspec<"__constant__">]; 1035 let Subjects = SubjectList<[Var]>; 1036 let LangOpts = [CUDA]; 1037 let Documentation = [Undocumented]; 1038} 1039 1040def CUDACudartBuiltin : IgnoredAttr { 1041 let Spellings = [GNU<"cudart_builtin">, Declspec<"__cudart_builtin__">]; 1042 let LangOpts = [CUDA]; 1043} 1044 1045def CUDADevice : InheritableAttr { 1046 let Spellings = [GNU<"device">, Declspec<"__device__">]; 1047 let Subjects = SubjectList<[Function, Var]>; 1048 let LangOpts = [CUDA]; 1049 let Documentation = [Undocumented]; 1050} 1051 1052def CUDADeviceBuiltin : IgnoredAttr { 1053 let Spellings = [GNU<"device_builtin">, Declspec<"__device_builtin__">]; 1054 let LangOpts = [CUDA]; 1055} 1056 1057def CUDADeviceBuiltinSurfaceType : InheritableAttr { 1058 let Spellings = [GNU<"device_builtin_surface_type">, 1059 Declspec<"__device_builtin_surface_type__">]; 1060 let LangOpts = [CUDA]; 1061 let Subjects = SubjectList<[CXXRecord]>; 1062 let Documentation = [CUDADeviceBuiltinSurfaceTypeDocs]; 1063} 1064 1065def CUDADeviceBuiltinTextureType : InheritableAttr { 1066 let Spellings = [GNU<"device_builtin_texture_type">, 1067 Declspec<"__device_builtin_texture_type__">]; 1068 let LangOpts = [CUDA]; 1069 let Subjects = SubjectList<[CXXRecord]>; 1070 let Documentation = [CUDADeviceBuiltinTextureTypeDocs]; 1071} 1072 1073def CUDAGlobal : InheritableAttr { 1074 let Spellings = [GNU<"global">, Declspec<"__global__">]; 1075 let Subjects = SubjectList<[Function]>; 1076 let LangOpts = [CUDA]; 1077 let Documentation = [Undocumented]; 1078} 1079 1080def CUDAHost : InheritableAttr { 1081 let Spellings = [GNU<"host">, Declspec<"__host__">]; 1082 let Subjects = SubjectList<[Function]>; 1083 let LangOpts = [CUDA]; 1084 let Documentation = [Undocumented]; 1085} 1086 1087def CUDAInvalidTarget : InheritableAttr { 1088 let Spellings = []; 1089 let Subjects = SubjectList<[Function]>; 1090 let LangOpts = [CUDA]; 1091 let Documentation = [Undocumented]; 1092} 1093 1094def CUDALaunchBounds : InheritableAttr { 1095 let Spellings = [GNU<"launch_bounds">, Declspec<"__launch_bounds__">]; 1096 let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>]; 1097 let LangOpts = [CUDA]; 1098 let Subjects = SubjectList<[ObjCMethod, FunctionLike]>; 1099 // An AST node is created for this attribute, but is not used by other parts 1100 // of the compiler. However, this node needs to exist in the AST because 1101 // non-LLVM backends may be relying on the attribute's presence. 1102 let Documentation = [Undocumented]; 1103} 1104 1105def CUDAShared : InheritableAttr { 1106 let Spellings = [GNU<"shared">, Declspec<"__shared__">]; 1107 let Subjects = SubjectList<[Var]>; 1108 let LangOpts = [CUDA]; 1109 let Documentation = [Undocumented]; 1110} 1111 1112def SYCLKernel : InheritableAttr { 1113 let Spellings = [Clang<"sycl_kernel">]; 1114 let Subjects = SubjectList<[FunctionTmpl]>; 1115 let LangOpts = [SYCL]; 1116 let Documentation = [SYCLKernelDocs]; 1117} 1118 1119def C11NoReturn : InheritableAttr { 1120 let Spellings = [Keyword<"_Noreturn">]; 1121 let Subjects = SubjectList<[Function], ErrorDiag>; 1122 let SemaHandler = 0; 1123 let Documentation = [C11NoReturnDocs]; 1124} 1125 1126def CXX11NoReturn : InheritableAttr { 1127 let Spellings = [CXX11<"", "noreturn", 200809>]; 1128 let Subjects = SubjectList<[Function], ErrorDiag>; 1129 let Documentation = [CXX11NoReturnDocs]; 1130 let SimpleHandler = 1; 1131} 1132 1133// Similar to CUDA, OpenCL attributes do not receive a [[]] spelling because 1134// the specification does not expose them with one currently. 1135def OpenCLKernel : InheritableAttr { 1136 let Spellings = [Keyword<"__kernel">, Keyword<"kernel">]; 1137 let Subjects = SubjectList<[Function], ErrorDiag>; 1138 let Documentation = [Undocumented]; 1139 let SimpleHandler = 1; 1140} 1141 1142def OpenCLUnrollHint : InheritableAttr { 1143 let Spellings = [GNU<"opencl_unroll_hint">]; 1144 let Args = [UnsignedArgument<"UnrollHint">]; 1145 let Documentation = [OpenCLUnrollHintDocs]; 1146} 1147 1148def OpenCLIntelReqdSubGroupSize: InheritableAttr { 1149 let Spellings = [GNU<"intel_reqd_sub_group_size">]; 1150 let Args = [UnsignedArgument<"SubGroupSize">]; 1151 let Subjects = SubjectList<[Function], ErrorDiag>; 1152 let Documentation = [OpenCLIntelReqdSubGroupSizeDocs]; 1153} 1154 1155// This attribute is both a type attribute, and a declaration attribute (for 1156// parameter variables). 1157def OpenCLAccess : Attr { 1158 let Spellings = [Keyword<"__read_only">, Keyword<"read_only">, 1159 Keyword<"__write_only">, Keyword<"write_only">, 1160 Keyword<"__read_write">, Keyword<"read_write">]; 1161 let Subjects = SubjectList<[ParmVar, TypedefName], ErrorDiag>; 1162 let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">, 1163 Keyword<"read_only">]>, 1164 Accessor<"isReadWrite", [Keyword<"__read_write">, 1165 Keyword<"read_write">]>, 1166 Accessor<"isWriteOnly", [Keyword<"__write_only">, 1167 Keyword<"write_only">]>]; 1168 let Documentation = [OpenCLAccessDocs]; 1169} 1170 1171def OpenCLPrivateAddressSpace : TypeAttr { 1172 let Spellings = [Keyword<"__private">, Keyword<"private">, Clang<"opencl_private">]; 1173 let Documentation = [OpenCLAddressSpacePrivateDocs]; 1174} 1175 1176def OpenCLGlobalAddressSpace : TypeAttr { 1177 let Spellings = [Keyword<"__global">, Keyword<"global">, Clang<"opencl_global">]; 1178 let Documentation = [OpenCLAddressSpaceGlobalDocs]; 1179} 1180 1181def OpenCLLocalAddressSpace : TypeAttr { 1182 let Spellings = [Keyword<"__local">, Keyword<"local">, Clang<"opencl_local">]; 1183 let Documentation = [OpenCLAddressSpaceLocalDocs]; 1184} 1185 1186def OpenCLConstantAddressSpace : TypeAttr { 1187 let Spellings = [Keyword<"__constant">, Keyword<"constant">, Clang<"opencl_constant">]; 1188 let Documentation = [OpenCLAddressSpaceConstantDocs]; 1189} 1190 1191def OpenCLGenericAddressSpace : TypeAttr { 1192 let Spellings = [Keyword<"__generic">, Keyword<"generic">, Clang<"opencl_generic">]; 1193 let Documentation = [OpenCLAddressSpaceGenericDocs]; 1194} 1195 1196def OpenCLNoSVM : Attr { 1197 let Spellings = [GNU<"nosvm">]; 1198 let Subjects = SubjectList<[Var]>; 1199 let Documentation = [OpenCLNoSVMDocs]; 1200 let LangOpts = [OpenCL]; 1201 let ASTNode = 0; 1202} 1203 1204def RenderScriptKernel : Attr { 1205 let Spellings = [GNU<"kernel">]; 1206 let Subjects = SubjectList<[Function]>; 1207 let Documentation = [RenderScriptKernelAttributeDocs]; 1208 let LangOpts = [RenderScript]; 1209 let SimpleHandler = 1; 1210} 1211 1212def Deprecated : InheritableAttr { 1213 let Spellings = [GCC<"deprecated">, Declspec<"deprecated">, 1214 CXX11<"","deprecated", 201309>, C2x<"", "deprecated">]; 1215 let Args = [StringArgument<"Message", 1>, 1216 // An optional string argument that enables us to provide a 1217 // Fix-It. 1218 StringArgument<"Replacement", 1>]; 1219 let MeaningfulToClassTemplateDefinition = 1; 1220 let Documentation = [DeprecatedDocs]; 1221} 1222 1223def Destructor : InheritableAttr { 1224 let Spellings = [GCC<"destructor">]; 1225 let Args = [DefaultIntArgument<"Priority", 65535>]; 1226 let Subjects = SubjectList<[Function]>; 1227 let Documentation = [Undocumented]; 1228} 1229 1230def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> { 1231 let Spellings = [Declspec<"empty_bases">]; 1232 let Subjects = SubjectList<[CXXRecord]>; 1233 let Documentation = [EmptyBasesDocs]; 1234 let SimpleHandler = 1; 1235} 1236 1237def AllocSize : InheritableAttr { 1238 let Spellings = [GCC<"alloc_size">]; 1239 let Subjects = SubjectList<[HasFunctionProto]>; 1240 let Args = [ParamIdxArgument<"ElemSizeParam">, 1241 ParamIdxArgument<"NumElemsParam", /*opt*/ 1>]; 1242 let TemplateDependent = 1; 1243 let Documentation = [AllocSizeDocs]; 1244} 1245 1246def EnableIf : InheritableAttr { 1247 // Does not have a [[]] spelling because this attribute requires the ability 1248 // to parse function arguments but the attribute is not written in the type 1249 // position. 1250 let Spellings = [GNU<"enable_if">]; 1251 let Subjects = SubjectList<[Function]>; 1252 let Args = [ExprArgument<"Cond">, StringArgument<"Message">]; 1253 let TemplateDependent = 1; 1254 let Documentation = [EnableIfDocs]; 1255} 1256 1257def ExtVectorType : Attr { 1258 // This is an OpenCL-related attribute and does not receive a [[]] spelling. 1259 let Spellings = [GNU<"ext_vector_type">]; 1260 // FIXME: This subject list is wrong; this is a type attribute. 1261 let Subjects = SubjectList<[TypedefName], ErrorDiag>; 1262 let Args = [ExprArgument<"NumElements">]; 1263 let ASTNode = 0; 1264 let Documentation = [Undocumented]; 1265 // This is a type attribute with an incorrect subject list, so should not be 1266 // permitted by #pragma clang attribute. 1267 let PragmaAttributeSupport = 0; 1268} 1269 1270def FallThrough : StmtAttr { 1271 let Spellings = [CXX11<"", "fallthrough", 201603>, C2x<"", "fallthrough">, 1272 CXX11<"clang", "fallthrough">, GCC<"fallthrough">]; 1273// let Subjects = [NullStmt]; 1274 let Documentation = [FallthroughDocs]; 1275} 1276 1277def NoMerge : StmtAttr { 1278 let Spellings = [Clang<"nomerge">]; 1279 let Documentation = [NoMergeDocs]; 1280} 1281 1282def FastCall : DeclOrTypeAttr { 1283 let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">, 1284 Keyword<"_fastcall">]; 1285// let Subjects = [Function, ObjCMethod]; 1286 let Documentation = [FastCallDocs]; 1287} 1288 1289def RegCall : DeclOrTypeAttr { 1290 let Spellings = [GCC<"regcall">, Keyword<"__regcall">]; 1291 let Documentation = [RegCallDocs]; 1292} 1293 1294def Final : InheritableAttr { 1295 let Spellings = [Keyword<"final">, Keyword<"sealed">]; 1296 let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>]; 1297 let SemaHandler = 0; 1298 let Documentation = [Undocumented]; 1299} 1300 1301def MinSize : InheritableAttr { 1302 let Spellings = [Clang<"minsize">]; 1303 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>; 1304 let Documentation = [Undocumented]; 1305} 1306 1307def FlagEnum : InheritableAttr { 1308 let Spellings = [Clang<"flag_enum">]; 1309 let Subjects = SubjectList<[Enum]>; 1310 let Documentation = [FlagEnumDocs]; 1311 let SimpleHandler = 1; 1312} 1313 1314def EnumExtensibility : InheritableAttr { 1315 let Spellings = [Clang<"enum_extensibility">]; 1316 let Subjects = SubjectList<[Enum]>; 1317 let Args = [EnumArgument<"Extensibility", "Kind", 1318 ["closed", "open"], ["Closed", "Open"]>]; 1319 let Documentation = [EnumExtensibilityDocs]; 1320} 1321 1322def Flatten : InheritableAttr { 1323 let Spellings = [GCC<"flatten">]; 1324 let Subjects = SubjectList<[Function], ErrorDiag>; 1325 let Documentation = [FlattenDocs]; 1326 let SimpleHandler = 1; 1327} 1328 1329def Format : InheritableAttr { 1330 let Spellings = [GCC<"format">]; 1331 let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">, 1332 IntArgument<"FirstArg">]; 1333 let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto]>; 1334 let Documentation = [FormatDocs]; 1335} 1336 1337def FormatArg : InheritableAttr { 1338 let Spellings = [GCC<"format_arg">]; 1339 let Args = [ParamIdxArgument<"FormatIdx">]; 1340 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto]>; 1341 let Documentation = [Undocumented]; 1342} 1343 1344def Callback : InheritableAttr { 1345 let Spellings = [Clang<"callback">]; 1346 let Args = [VariadicParamOrParamIdxArgument<"Encoding">]; 1347 let Subjects = SubjectList<[Function]>; 1348 let Documentation = [CallbackDocs]; 1349} 1350 1351def GNUInline : InheritableAttr { 1352 let Spellings = [GCC<"gnu_inline">]; 1353 let Subjects = SubjectList<[Function]>; 1354 let Documentation = [GnuInlineDocs]; 1355} 1356 1357def Hot : InheritableAttr { 1358 let Spellings = [GCC<"hot">]; 1359 let Subjects = SubjectList<[Function]>; 1360 // An AST node is created for this attribute, but not actually used beyond 1361 // semantic checking for mutual exclusion with the Cold attribute. 1362 let Documentation = [Undocumented]; 1363} 1364 1365def IBAction : InheritableAttr { 1366 let Spellings = [Clang<"ibaction">]; 1367 let Subjects = SubjectList<[ObjCInstanceMethod]>; 1368 // An AST node is created for this attribute, but is not used by other parts 1369 // of the compiler. However, this node needs to exist in the AST because 1370 // external tools rely on it. 1371 let Documentation = [Undocumented]; 1372 let SimpleHandler = 1; 1373} 1374 1375def IBOutlet : InheritableAttr { 1376 let Spellings = [Clang<"iboutlet">]; 1377// let Subjects = [ObjCIvar, ObjCProperty]; 1378 let Documentation = [Undocumented]; 1379} 1380 1381def IBOutletCollection : InheritableAttr { 1382 let Spellings = [Clang<"iboutletcollection">]; 1383 let Args = [TypeArgument<"Interface", 1>]; 1384// let Subjects = [ObjCIvar, ObjCProperty]; 1385 let Documentation = [Undocumented]; 1386} 1387 1388def IFunc : Attr, TargetSpecificAttr<TargetELF> { 1389 let Spellings = [GCC<"ifunc">]; 1390 let Args = [StringArgument<"Resolver">]; 1391 let Subjects = SubjectList<[Function]>; 1392 let Documentation = [IFuncDocs]; 1393} 1394 1395def Restrict : InheritableAttr { 1396 let Spellings = [Declspec<"restrict">, GCC<"malloc">]; 1397 let Subjects = SubjectList<[Function]>; 1398 let Documentation = [Undocumented]; 1399} 1400 1401def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> { 1402 let Spellings = [Declspec<"layout_version">]; 1403 let Args = [UnsignedArgument<"Version">]; 1404 let Subjects = SubjectList<[CXXRecord]>; 1405 let Documentation = [LayoutVersionDocs]; 1406} 1407 1408def LifetimeBound : DeclOrTypeAttr { 1409 let Spellings = [Clang<"lifetimebound", 0>]; 1410 let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>; 1411 let Documentation = [LifetimeBoundDocs]; 1412 let LangOpts = [CPlusPlus]; 1413 let SimpleHandler = 1; 1414} 1415 1416def TrivialABI : InheritableAttr { 1417 // This attribute does not have a C [[]] spelling because it requires the 1418 // CPlusPlus language option. 1419 let Spellings = [Clang<"trivial_abi", 0>]; 1420 let Subjects = SubjectList<[CXXRecord]>; 1421 let Documentation = [TrivialABIDocs]; 1422 let LangOpts = [CPlusPlus]; 1423 let SimpleHandler = 1; 1424} 1425 1426def MaxFieldAlignment : InheritableAttr { 1427 // This attribute has no spellings as it is only ever created implicitly. 1428 let Spellings = []; 1429 let Args = [UnsignedArgument<"Alignment">]; 1430 let SemaHandler = 0; 1431 let Documentation = [Undocumented]; 1432} 1433 1434def MayAlias : InheritableAttr { 1435 // FIXME: this is a type attribute in GCC, but a declaration attribute here. 1436 let Spellings = [GCC<"may_alias">]; 1437 let Documentation = [Undocumented]; 1438 let SimpleHandler = 1; 1439} 1440 1441def MIGServerRoutine : InheritableAttr { 1442 let Spellings = [Clang<"mig_server_routine">]; 1443 let Subjects = SubjectList<[Function, ObjCMethod, Block]>; 1444 let Documentation = [MIGConventionDocs]; 1445} 1446 1447def MSABI : DeclOrTypeAttr { 1448 let Spellings = [GCC<"ms_abi">]; 1449// let Subjects = [Function, ObjCMethod]; 1450 let Documentation = [MSABIDocs]; 1451} 1452 1453def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> { 1454 // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's 1455 // and AnyX86Interrupt's spellings must match. 1456 let Spellings = [GCC<"interrupt">]; 1457 let Args = [UnsignedArgument<"Number">]; 1458 let ParseKind = "Interrupt"; 1459 let HasCustomParsing = 1; 1460 let Documentation = [Undocumented]; 1461} 1462 1463def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> { 1464 let Spellings = [GCC<"mips16">]; 1465 let Subjects = SubjectList<[Function], ErrorDiag>; 1466 let Documentation = [Undocumented]; 1467} 1468 1469def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips32> { 1470 // NOTE: If you add any additional spellings, ARMInterrupt's, 1471 // MSP430Interrupt's and AnyX86Interrupt's spellings must match. 1472 let Spellings = [GCC<"interrupt">]; 1473 let Subjects = SubjectList<[Function]>; 1474 let Args = [EnumArgument<"Interrupt", "InterruptType", 1475 ["vector=sw0", "vector=sw1", "vector=hw0", 1476 "vector=hw1", "vector=hw2", "vector=hw3", 1477 "vector=hw4", "vector=hw5", "eic", ""], 1478 ["sw0", "sw1", "hw0", "hw1", "hw2", "hw3", 1479 "hw4", "hw5", "eic", "eic"] 1480 >]; 1481 let ParseKind = "Interrupt"; 1482 let Documentation = [MipsInterruptDocs]; 1483} 1484 1485def MicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> { 1486 let Spellings = [GCC<"micromips">]; 1487 let Subjects = SubjectList<[Function], ErrorDiag>; 1488 let Documentation = [MicroMipsDocs]; 1489} 1490 1491def MipsLongCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> { 1492 let Spellings = [GCC<"long_call">, GCC<"far">]; 1493 let Subjects = SubjectList<[Function]>; 1494 let Documentation = [MipsLongCallStyleDocs]; 1495} 1496 1497def MipsShortCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> { 1498 let Spellings = [GCC<"short_call">, GCC<"near">]; 1499 let Subjects = SubjectList<[Function]>; 1500 let Documentation = [MipsShortCallStyleDocs]; 1501} 1502 1503def Mode : Attr { 1504 let Spellings = [GCC<"mode">]; 1505 let Subjects = SubjectList<[Var, Enum, TypedefName, Field], ErrorDiag>; 1506 let Args = [IdentifierArgument<"Mode">]; 1507 let Documentation = [Undocumented]; 1508 // This is notionally a type attribute, which #pragma clang attribute 1509 // generally does not support. 1510 let PragmaAttributeSupport = 0; 1511} 1512 1513def Naked : InheritableAttr { 1514 let Spellings = [GCC<"naked">, Declspec<"naked">]; 1515 let Subjects = SubjectList<[Function]>; 1516 let Documentation = [Undocumented]; 1517} 1518 1519def NeonPolyVectorType : TypeAttr { 1520 let Spellings = [Clang<"neon_polyvector_type">]; 1521 let Args = [IntArgument<"NumElements">]; 1522 let Documentation = [Undocumented]; 1523 // Represented as VectorType instead. 1524 let ASTNode = 0; 1525} 1526 1527def NeonVectorType : TypeAttr { 1528 let Spellings = [Clang<"neon_vector_type">]; 1529 let Args = [IntArgument<"NumElements">]; 1530 let Documentation = [Undocumented]; 1531 // Represented as VectorType instead. 1532 let ASTNode = 0; 1533} 1534 1535def ArmMveStrictPolymorphism : TypeAttr, TargetSpecificAttr<TargetARM> { 1536 let Spellings = [Clang<"__clang_arm_mve_strict_polymorphism">]; 1537 let Documentation = [ArmMveStrictPolymorphismDocs]; 1538} 1539 1540def NoUniqueAddress : InheritableAttr, TargetSpecificAttr<TargetItaniumCXXABI> { 1541 let Spellings = [CXX11<"", "no_unique_address", 201803>]; 1542 let Subjects = SubjectList<[NonBitField], ErrorDiag>; 1543 let Documentation = [NoUniqueAddressDocs]; 1544 let SimpleHandler = 1; 1545} 1546 1547def ReturnsTwice : InheritableAttr { 1548 let Spellings = [GCC<"returns_twice">]; 1549 let Subjects = SubjectList<[Function]>; 1550 let Documentation = [Undocumented]; 1551 let SimpleHandler = 1; 1552} 1553 1554def DisableTailCalls : InheritableAttr { 1555 let Spellings = [Clang<"disable_tail_calls">]; 1556 let Subjects = SubjectList<[Function, ObjCMethod]>; 1557 let Documentation = [DisableTailCallsDocs]; 1558} 1559 1560def NoAlias : InheritableAttr { 1561 let Spellings = [Declspec<"noalias">]; 1562 let Subjects = SubjectList<[Function]>; 1563 let Documentation = [NoAliasDocs]; 1564 let SimpleHandler = 1; 1565} 1566 1567def NoCommon : InheritableAttr { 1568 let Spellings = [GCC<"nocommon">]; 1569 let Subjects = SubjectList<[Var]>; 1570 let Documentation = [Undocumented]; 1571 let SimpleHandler = 1; 1572} 1573 1574def NoDebug : InheritableAttr { 1575 let Spellings = [GCC<"nodebug">]; 1576 let Subjects = SubjectList<[TypedefName, FunctionLike, ObjCMethod, NonParmVar]>; 1577 let Documentation = [NoDebugDocs]; 1578} 1579 1580def NoDuplicate : InheritableAttr { 1581 let Spellings = [Clang<"noduplicate">]; 1582 let Subjects = SubjectList<[Function]>; 1583 let Documentation = [NoDuplicateDocs]; 1584 let SimpleHandler = 1; 1585} 1586 1587def Convergent : InheritableAttr { 1588 let Spellings = [Clang<"convergent">]; 1589 let Subjects = SubjectList<[Function]>; 1590 let Documentation = [ConvergentDocs]; 1591 let SimpleHandler = 1; 1592} 1593 1594def NoInline : InheritableAttr { 1595 let Spellings = [GCC<"noinline">, Declspec<"noinline">]; 1596 let Subjects = SubjectList<[Function]>; 1597 let Documentation = [Undocumented]; 1598 let SimpleHandler = 1; 1599} 1600 1601def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> { 1602 let Spellings = [GCC<"nomips16">]; 1603 let Subjects = SubjectList<[Function], ErrorDiag>; 1604 let Documentation = [Undocumented]; 1605 let SimpleHandler = 1; 1606} 1607 1608def NoMicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> { 1609 let Spellings = [GCC<"nomicromips">]; 1610 let Subjects = SubjectList<[Function], ErrorDiag>; 1611 let Documentation = [MicroMipsDocs]; 1612 let SimpleHandler = 1; 1613} 1614 1615def RISCVInterrupt : InheritableAttr, TargetSpecificAttr<TargetRISCV> { 1616 let Spellings = [GCC<"interrupt">]; 1617 let Subjects = SubjectList<[Function]>; 1618 let Args = [EnumArgument<"Interrupt", "InterruptType", 1619 ["user", "supervisor", "machine"], 1620 ["user", "supervisor", "machine"], 1621 1>]; 1622 let ParseKind = "Interrupt"; 1623 let Documentation = [RISCVInterruptDocs]; 1624} 1625 1626// This is not a TargetSpecificAttr so that is silently accepted and 1627// ignored on other targets as encouraged by the OpenCL spec. 1628// 1629// See OpenCL 1.2 6.11.5: "It is our intention that a particular 1630// implementation of OpenCL be free to ignore all attributes and the 1631// resulting executable binary will produce the same result." 1632// 1633// However, only AMD GPU targets will emit the corresponding IR 1634// attribute. 1635// 1636// FIXME: This provides a sub-optimal error message if you attempt to 1637// use this in CUDA, since CUDA does not use the same terminology. 1638// 1639// FIXME: SubjectList should be for OpenCLKernelFunction, but is not to 1640// workaround needing to see kernel attribute before others to know if 1641// this should be rejected on non-kernels. 1642 1643def AMDGPUFlatWorkGroupSize : InheritableAttr { 1644 let Spellings = [Clang<"amdgpu_flat_work_group_size", 0>]; 1645 let Args = [ExprArgument<"Min">, ExprArgument<"Max">]; 1646 let Documentation = [AMDGPUFlatWorkGroupSizeDocs]; 1647 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">; 1648} 1649 1650def AMDGPUWavesPerEU : InheritableAttr { 1651 let Spellings = [Clang<"amdgpu_waves_per_eu", 0>]; 1652 let Args = [ExprArgument<"Min">, ExprArgument<"Max", 1>]; 1653 let Documentation = [AMDGPUWavesPerEUDocs]; 1654 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">; 1655} 1656 1657def AMDGPUNumSGPR : InheritableAttr { 1658 let Spellings = [Clang<"amdgpu_num_sgpr", 0>]; 1659 let Args = [UnsignedArgument<"NumSGPR">]; 1660 let Documentation = [AMDGPUNumSGPRNumVGPRDocs]; 1661 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">; 1662} 1663 1664def AMDGPUNumVGPR : InheritableAttr { 1665 let Spellings = [Clang<"amdgpu_num_vgpr", 0>]; 1666 let Args = [UnsignedArgument<"NumVGPR">]; 1667 let Documentation = [AMDGPUNumSGPRNumVGPRDocs]; 1668 let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">; 1669} 1670 1671def BPFPreserveAccessIndex : InheritableAttr, 1672 TargetSpecificAttr<TargetBPF> { 1673 let Spellings = [Clang<"preserve_access_index">]; 1674 let Subjects = SubjectList<[Record], ErrorDiag>; 1675 let Documentation = [BPFPreserveAccessIndexDocs]; 1676 let LangOpts = [COnly]; 1677} 1678 1679def WebAssemblyExportName : InheritableAttr, 1680 TargetSpecificAttr<TargetWebAssembly> { 1681 let Spellings = [Clang<"export_name">]; 1682 let Args = [StringArgument<"ExportName">]; 1683 let Documentation = [WebAssemblyExportNameDocs]; 1684 let Subjects = SubjectList<[Function], ErrorDiag>; 1685} 1686 1687def WebAssemblyImportModule : InheritableAttr, 1688 TargetSpecificAttr<TargetWebAssembly> { 1689 let Spellings = [Clang<"import_module">]; 1690 let Args = [StringArgument<"ImportModule">]; 1691 let Documentation = [WebAssemblyImportModuleDocs]; 1692 let Subjects = SubjectList<[Function], ErrorDiag>; 1693} 1694 1695def WebAssemblyImportName : InheritableAttr, 1696 TargetSpecificAttr<TargetWebAssembly> { 1697 let Spellings = [Clang<"import_name">]; 1698 let Args = [StringArgument<"ImportName">]; 1699 let Documentation = [WebAssemblyImportNameDocs]; 1700 let Subjects = SubjectList<[Function], ErrorDiag>; 1701} 1702 1703def NoSplitStack : InheritableAttr { 1704 let Spellings = [GCC<"no_split_stack">]; 1705 let Subjects = SubjectList<[Function], ErrorDiag>; 1706 let Documentation = [NoSplitStackDocs]; 1707 let SimpleHandler = 1; 1708} 1709 1710def NonNull : InheritableParamAttr { 1711 let Spellings = [GCC<"nonnull">]; 1712 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag, 1713 "functions, methods, and parameters">; 1714 let Args = [VariadicParamIdxArgument<"Args">]; 1715 let AdditionalMembers = [{ 1716 bool isNonNull(unsigned IdxAST) const { 1717 if (!args_size()) 1718 return true; 1719 return args_end() != std::find_if( 1720 args_begin(), args_end(), 1721 [=](const ParamIdx &Idx) { return Idx.getASTIndex() == IdxAST; }); 1722 } 1723 }]; 1724 // FIXME: We should merge duplicates into a single nonnull attribute. 1725 let InheritEvenIfAlreadyPresent = 1; 1726 let Documentation = [NonNullDocs]; 1727} 1728 1729def ReturnsNonNull : InheritableAttr { 1730 let Spellings = [GCC<"returns_nonnull">]; 1731 let Subjects = SubjectList<[ObjCMethod, Function]>; 1732 let Documentation = [ReturnsNonNullDocs]; 1733} 1734 1735// pass_object_size(N) indicates that the parameter should have 1736// __builtin_object_size with Type=N evaluated on the parameter at the callsite. 1737def PassObjectSize : InheritableParamAttr { 1738 let Spellings = [Clang<"pass_object_size">, 1739 Clang<"pass_dynamic_object_size">]; 1740 let Accessors = [Accessor<"isDynamic", [Clang<"pass_dynamic_object_size">]>]; 1741 let Args = [IntArgument<"Type">]; 1742 let Subjects = SubjectList<[ParmVar]>; 1743 let Documentation = [PassObjectSizeDocs]; 1744} 1745 1746// Nullability type attributes. 1747def TypeNonNull : TypeAttr { 1748 let Spellings = [Keyword<"_Nonnull">]; 1749 let Documentation = [TypeNonNullDocs]; 1750} 1751 1752def TypeNullable : TypeAttr { 1753 let Spellings = [Keyword<"_Nullable">]; 1754 let Documentation = [TypeNullableDocs]; 1755} 1756 1757def TypeNullUnspecified : TypeAttr { 1758 let Spellings = [Keyword<"_Null_unspecified">]; 1759 let Documentation = [TypeNullUnspecifiedDocs]; 1760} 1761 1762// This is a marker used to indicate that an __unsafe_unretained qualifier was 1763// ignored because ARC is not enabled. The usual representation for this 1764// qualifier is as an ObjCOwnership attribute with Kind == "none". 1765def ObjCInertUnsafeUnretained : TypeAttr { 1766 let Spellings = [Keyword<"__unsafe_unretained">]; 1767 let Documentation = [Undocumented]; 1768} 1769 1770def ObjCKindOf : TypeAttr { 1771 let Spellings = [Keyword<"__kindof">]; 1772 let Documentation = [Undocumented]; 1773} 1774 1775def NoEscape : Attr { 1776 let Spellings = [Clang<"noescape">]; 1777 let Subjects = SubjectList<[ParmVar]>; 1778 let Documentation = [NoEscapeDocs]; 1779} 1780 1781def AssumeAligned : InheritableAttr { 1782 let Spellings = [GCC<"assume_aligned">]; 1783 let Subjects = SubjectList<[ObjCMethod, Function]>; 1784 let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>]; 1785 let Documentation = [AssumeAlignedDocs]; 1786} 1787 1788def AllocAlign : InheritableAttr { 1789 let Spellings = [GCC<"alloc_align">]; 1790 let Subjects = SubjectList<[HasFunctionProto]>; 1791 let Args = [ParamIdxArgument<"ParamIndex">]; 1792 let Documentation = [AllocAlignDocs]; 1793} 1794 1795def NoReturn : InheritableAttr { 1796 let Spellings = [GCC<"noreturn">, Declspec<"noreturn">]; 1797 // FIXME: Does GCC allow this on the function instead? 1798 let Documentation = [Undocumented]; 1799} 1800 1801def NoInstrumentFunction : InheritableAttr { 1802 let Spellings = [GCC<"no_instrument_function">]; 1803 let Subjects = SubjectList<[Function]>; 1804 let Documentation = [Undocumented]; 1805 let SimpleHandler = 1; 1806} 1807 1808def NotTailCalled : InheritableAttr { 1809 let Spellings = [Clang<"not_tail_called">]; 1810 let Subjects = SubjectList<[Function]>; 1811 let Documentation = [NotTailCalledDocs]; 1812} 1813 1814def NoStackProtector : InheritableAttr { 1815 let Spellings = [Clang<"no_stack_protector">]; 1816 let Subjects = SubjectList<[Function]>; 1817 let Documentation = [NoStackProtectorDocs]; 1818 let SimpleHandler = 1; 1819} 1820 1821def NoThrow : InheritableAttr { 1822 let Spellings = [GCC<"nothrow">, Declspec<"nothrow">]; 1823 let Subjects = SubjectList<[FunctionLike]>; 1824 let Documentation = [NoThrowDocs]; 1825} 1826 1827def NvWeak : IgnoredAttr { 1828 // No Declspec spelling of this attribute; the CUDA headers use 1829 // __attribute__((nv_weak)) unconditionally. Does not receive an [[]] 1830 // spelling because it is a CUDA attribute. 1831 let Spellings = [GNU<"nv_weak">]; 1832 let LangOpts = [CUDA]; 1833} 1834 1835def ObjCBridge : InheritableAttr { 1836 let Spellings = [Clang<"objc_bridge">]; 1837 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag>; 1838 let Args = [IdentifierArgument<"BridgedType">]; 1839 let Documentation = [Undocumented]; 1840} 1841 1842def ObjCBridgeMutable : InheritableAttr { 1843 let Spellings = [Clang<"objc_bridge_mutable">]; 1844 let Subjects = SubjectList<[Record], ErrorDiag>; 1845 let Args = [IdentifierArgument<"BridgedType">]; 1846 let Documentation = [Undocumented]; 1847} 1848 1849def ObjCBridgeRelated : InheritableAttr { 1850 let Spellings = [Clang<"objc_bridge_related">]; 1851 let Subjects = SubjectList<[Record], ErrorDiag>; 1852 let Args = [IdentifierArgument<"RelatedClass">, 1853 IdentifierArgument<"ClassMethod">, 1854 IdentifierArgument<"InstanceMethod">]; 1855 let HasCustomParsing = 1; 1856 let Documentation = [Undocumented]; 1857} 1858 1859def NSReturnsRetained : DeclOrTypeAttr { 1860 let Spellings = [Clang<"ns_returns_retained">]; 1861// let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>; 1862 let Documentation = [RetainBehaviorDocs]; 1863} 1864 1865def NSReturnsNotRetained : InheritableAttr { 1866 let Spellings = [Clang<"ns_returns_not_retained">]; 1867// let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>; 1868 let Documentation = [RetainBehaviorDocs]; 1869} 1870 1871def NSReturnsAutoreleased : InheritableAttr { 1872 let Spellings = [Clang<"ns_returns_autoreleased">]; 1873// let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>; 1874 let Documentation = [RetainBehaviorDocs]; 1875} 1876 1877def NSConsumesSelf : InheritableAttr { 1878 let Spellings = [Clang<"ns_consumes_self">]; 1879 let Subjects = SubjectList<[ObjCMethod]>; 1880 let Documentation = [RetainBehaviorDocs]; 1881 let SimpleHandler = 1; 1882} 1883 1884def NSConsumed : InheritableParamAttr { 1885 let Spellings = [Clang<"ns_consumed">]; 1886 let Subjects = SubjectList<[ParmVar]>; 1887 let Documentation = [RetainBehaviorDocs]; 1888} 1889 1890def ObjCException : InheritableAttr { 1891 let Spellings = [Clang<"objc_exception">]; 1892 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; 1893 let Documentation = [Undocumented]; 1894 let SimpleHandler = 1; 1895} 1896 1897def ObjCMethodFamily : InheritableAttr { 1898 let Spellings = [Clang<"objc_method_family">]; 1899 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>; 1900 let Args = [EnumArgument<"Family", "FamilyKind", 1901 ["none", "alloc", "copy", "init", "mutableCopy", "new"], 1902 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init", 1903 "OMF_mutableCopy", "OMF_new"]>]; 1904 let Documentation = [ObjCMethodFamilyDocs]; 1905} 1906 1907def ObjCNSObject : InheritableAttr { 1908 let Spellings = [Clang<"NSObject">]; 1909 let Documentation = [Undocumented]; 1910} 1911 1912def ObjCIndependentClass : InheritableAttr { 1913 let Spellings = [Clang<"objc_independent_class">]; 1914 let Documentation = [Undocumented]; 1915} 1916 1917def ObjCPreciseLifetime : InheritableAttr { 1918 let Spellings = [Clang<"objc_precise_lifetime">]; 1919 let Subjects = SubjectList<[Var], ErrorDiag>; 1920 let Documentation = [Undocumented]; 1921} 1922 1923def ObjCReturnsInnerPointer : InheritableAttr { 1924 let Spellings = [Clang<"objc_returns_inner_pointer">]; 1925 let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>; 1926 let Documentation = [Undocumented]; 1927} 1928 1929def ObjCRequiresSuper : InheritableAttr { 1930 let Spellings = [Clang<"objc_requires_super">]; 1931 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>; 1932 let Documentation = [ObjCRequiresSuperDocs]; 1933} 1934 1935def ObjCRootClass : InheritableAttr { 1936 let Spellings = [Clang<"objc_root_class">]; 1937 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; 1938 let Documentation = [Undocumented]; 1939 let SimpleHandler = 1; 1940} 1941 1942def ObjCNonLazyClass : Attr { 1943 let Spellings = [Clang<"objc_nonlazy_class">]; 1944 let Subjects = SubjectList<[ObjCInterface, ObjCImpl], ErrorDiag>; 1945 let LangOpts = [ObjC]; 1946 let Documentation = [ObjCNonLazyClassDocs]; 1947 let SimpleHandler = 1; 1948} 1949 1950def ObjCSubclassingRestricted : InheritableAttr { 1951 let Spellings = [Clang<"objc_subclassing_restricted">]; 1952 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; 1953 let Documentation = [ObjCSubclassingRestrictedDocs]; 1954 let SimpleHandler = 1; 1955} 1956 1957def ObjCExplicitProtocolImpl : InheritableAttr { 1958 let Spellings = [Clang<"objc_protocol_requires_explicit_implementation">]; 1959 let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>; 1960 let Documentation = [Undocumented]; 1961} 1962 1963def ObjCDesignatedInitializer : Attr { 1964 let Spellings = [Clang<"objc_designated_initializer">]; 1965 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>; 1966 let Documentation = [Undocumented]; 1967} 1968 1969def ObjCDirect : Attr { 1970 let Spellings = [Clang<"objc_direct">]; 1971 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>; 1972 let LangOpts = [ObjC]; 1973 let Documentation = [ObjCDirectDocs]; 1974} 1975 1976def ObjCDirectMembers : Attr { 1977 let Spellings = [Clang<"objc_direct_members">]; 1978 let Subjects = SubjectList<[ObjCImpl, ObjCInterface, ObjCCategory], ErrorDiag>; 1979 let LangOpts = [ObjC]; 1980 let Documentation = [ObjCDirectMembersDocs]; 1981} 1982 1983def ObjCRuntimeName : Attr { 1984 let Spellings = [Clang<"objc_runtime_name">]; 1985 let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>; 1986 let Args = [StringArgument<"MetadataName">]; 1987 let Documentation = [ObjCRuntimeNameDocs]; 1988} 1989 1990def ObjCRuntimeVisible : Attr { 1991 let Spellings = [Clang<"objc_runtime_visible">]; 1992 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; 1993 let Documentation = [ObjCRuntimeVisibleDocs]; 1994 let SimpleHandler = 1; 1995} 1996 1997def ObjCClassStub : Attr { 1998 let Spellings = [Clang<"objc_class_stub">]; 1999 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; 2000 let Documentation = [ObjCClassStubDocs]; 2001 let LangOpts = [ObjCNonFragileRuntime]; 2002 let SimpleHandler = 1; 2003} 2004 2005def ObjCBoxable : Attr { 2006 let Spellings = [Clang<"objc_boxable">]; 2007 let Subjects = SubjectList<[Record], ErrorDiag>; 2008 let Documentation = [ObjCBoxableDocs]; 2009} 2010 2011def OptimizeNone : InheritableAttr { 2012 let Spellings = [Clang<"optnone">]; 2013 let Subjects = SubjectList<[Function, ObjCMethod]>; 2014 let Documentation = [OptnoneDocs]; 2015} 2016 2017def Overloadable : Attr { 2018 let Spellings = [Clang<"overloadable">]; 2019 let Subjects = SubjectList<[Function], ErrorDiag>; 2020 let Documentation = [OverloadableDocs]; 2021 let SimpleHandler = 1; 2022} 2023 2024def Override : InheritableAttr { 2025 let Spellings = [Keyword<"override">]; 2026 let SemaHandler = 0; 2027 let Documentation = [Undocumented]; 2028} 2029 2030def Ownership : InheritableAttr { 2031 let Spellings = [Clang<"ownership_holds">, Clang<"ownership_returns">, 2032 Clang<"ownership_takes">]; 2033 let Accessors = [Accessor<"isHolds", [Clang<"ownership_holds">]>, 2034 Accessor<"isReturns", [Clang<"ownership_returns">]>, 2035 Accessor<"isTakes", [Clang<"ownership_takes">]>]; 2036 let AdditionalMembers = [{ 2037 enum OwnershipKind { Holds, Returns, Takes }; 2038 OwnershipKind getOwnKind() const { 2039 return isHolds() ? Holds : 2040 isTakes() ? Takes : 2041 Returns; 2042 } 2043 }]; 2044 let Args = [IdentifierArgument<"Module">, 2045 VariadicParamIdxArgument<"Args">]; 2046 let Subjects = SubjectList<[HasFunctionProto]>; 2047 let Documentation = [Undocumented]; 2048} 2049 2050def Packed : InheritableAttr { 2051 let Spellings = [GCC<"packed">]; 2052// let Subjects = [Tag, Field]; 2053 let Documentation = [Undocumented]; 2054} 2055 2056// CHERI-related attributes 2057 2058def CHERICapability : TypeAttr { 2059 let Spellings = [GNU<"cheri_capability">]; 2060 let Documentation = [Undocumented]; 2061} 2062def MemoryAddress : TypeAttr { 2063 let Spellings = [GNU<"memory_address">, CXX11<"cheri","memory_address">]; 2064 let Documentation = [Undocumented]; 2065} 2066 2067def PointerInterpretationCaps : DeclOrTypeAttr { // InheritableAttr { 2068 let Spellings = [GNU<"pointer_interpretation_capabilities">]; 2069 let Documentation = [Undocumented]; 2070} 2071 2072def CHERICCall : DeclOrTypeAttr { // InheritableAttr { 2073 let Spellings = [GNU<"cheri_ccall">]; 2074 let Documentation = [Undocumented]; 2075} 2076 2077def CHERICCallee : DeclOrTypeAttr { // InheritableAttr { 2078 let Spellings = [GNU<"cheri_ccallee">]; 2079 let Subjects = SubjectList<[Function], ErrorDiag>; 2080 let Documentation = [Undocumented]; 2081} 2082 2083def CHERICCallback : DeclOrTypeAttr { // InheritableAttr { 2084 let Spellings = [GNU<"cheri_ccallback">]; 2085 let Documentation = [Undocumented]; 2086} 2087 2088def CHERIMethodSuffix : DeclOrTypeAttr { // InheritableAttr { 2089 let Spellings = [GNU<"cheri_method_suffix">]; 2090 let Documentation = [Undocumented]; 2091 let Args = [StringArgument<"Suffix">]; 2092} 2093def CHERIMethodClass : DeclOrTypeAttr { // InheritableAttr { 2094 let Spellings = [GNU<"cheri_method_class">]; 2095 let Documentation = [Undocumented]; 2096 let Args = [IdentifierArgument<"DefaultClass">]; 2097} 2098 2099def CHERINoSubobjectBounds : DeclOrTypeAttr { 2100 let Spellings = [GNU<"cheri_no_subobject_bounds">, 2101 CXX11<"cheri","no_subobject_bounds">, 2102 C2x<"cheri", "no_subobject_bounds">]; 2103 let Documentation = [Undocumented]; 2104} 2105 2106// For pre-C99 variable length arrays or variable legnth arrays that have a 2107// maximum size. 2108def CHERISubobjectBoundsUseRemainingSize : InheritableAttr { 2109 let Spellings = [GNU<"cheri_subobject_bounds_use_remaining_size">, 2110 CXX11<"cheri","subobject_bounds_use_remaining_size">, 2111 C2x<"cheri", "subobject_bounds_use_remaining_size">]; 2112 // TODO: allow this to be a reference to another field in the structure 2113 let Args = [UnsignedArgument<"MaxSize", /*Optional=*/1>]; 2114 let Subjects = SubjectList<[Field, Record /* TODO:, TypedefName*/]>; 2115 let Documentation = [Undocumented]; 2116} 2117 2118// Attributes for __uintcap_t/__intcap_t to indicate whether 2119// they carry provenance or not (to avoid the LHS carries 2120// provenance rule that we were using before). 2121def CHERINoProvenance : TypeAttr { 2122 let Spellings = [GNU<"cheri_no_provenance">, 2123 CXX11<"cheri","no_provenance">, 2124 C2x<"cheri", "no_provenance">]; 2125 let Documentation = [Undocumented]; // FIXME 2126} 2127 2128def IntelOclBicc : DeclOrTypeAttr { 2129 let Spellings = [Clang<"intel_ocl_bicc", 0>]; 2130// let Subjects = [Function, ObjCMethod]; 2131 let Documentation = [Undocumented]; 2132} 2133 2134def Pcs : DeclOrTypeAttr { 2135 let Spellings = [GCC<"pcs">]; 2136 let Args = [EnumArgument<"PCS", "PCSType", 2137 ["aapcs", "aapcs-vfp"], 2138 ["AAPCS", "AAPCS_VFP"]>]; 2139// let Subjects = [Function, ObjCMethod]; 2140 let Documentation = [PcsDocs]; 2141} 2142 2143def AArch64VectorPcs: DeclOrTypeAttr { 2144 let Spellings = [Clang<"aarch64_vector_pcs">]; 2145 let Documentation = [AArch64VectorPcsDocs]; 2146} 2147 2148def Pure : InheritableAttr { 2149 let Spellings = [GCC<"pure">]; 2150 let Documentation = [Undocumented]; 2151 let SimpleHandler = 1; 2152} 2153 2154def Regparm : TypeAttr { 2155 let Spellings = [GCC<"regparm">]; 2156 let Args = [UnsignedArgument<"NumParams">]; 2157 let Documentation = [RegparmDocs]; 2158 // Represented as part of the enclosing function type. 2159 let ASTNode = 0; 2160} 2161 2162def NoDeref : TypeAttr { 2163 let Spellings = [Clang<"noderef">]; 2164 let Documentation = [NoDerefDocs]; 2165} 2166 2167def ReqdWorkGroupSize : InheritableAttr { 2168 // Does not have a [[]] spelling because it is an OpenCL-related attribute. 2169 let Spellings = [GNU<"reqd_work_group_size">]; 2170 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">, 2171 UnsignedArgument<"ZDim">]; 2172 let Subjects = SubjectList<[Function], ErrorDiag>; 2173 let Documentation = [Undocumented]; 2174} 2175 2176def WorkGroupSizeHint : InheritableAttr { 2177 // Does not have a [[]] spelling because it is an OpenCL-related attribute. 2178 let Spellings = [GNU<"work_group_size_hint">]; 2179 let Args = [UnsignedArgument<"XDim">, 2180 UnsignedArgument<"YDim">, 2181 UnsignedArgument<"ZDim">]; 2182 let Subjects = SubjectList<[Function], ErrorDiag>; 2183 let Documentation = [Undocumented]; 2184} 2185 2186def InitPriority : InheritableAttr { 2187 let Spellings = [GCC<"init_priority", /*AllowInC*/0>]; 2188 let Args = [UnsignedArgument<"Priority">]; 2189 let Subjects = SubjectList<[Var], ErrorDiag>; 2190 let Documentation = [Undocumented]; 2191} 2192 2193def Section : InheritableAttr { 2194 let Spellings = [GCC<"section">, Declspec<"allocate">]; 2195 let Args = [StringArgument<"Name">]; 2196 let Subjects = 2197 SubjectList<[ Function, GlobalVar, ObjCMethod, ObjCProperty ], ErrorDiag>; 2198 let Documentation = [SectionDocs]; 2199} 2200 2201// This is used for `__declspec(code_seg("segname"))`, but not for 2202// `#pragma code_seg("segname")`. 2203def CodeSeg : InheritableAttr { 2204 let Spellings = [Declspec<"code_seg">]; 2205 let Args = [StringArgument<"Name">]; 2206 let Subjects = SubjectList<[Function, CXXRecord], ErrorDiag>; 2207 let Documentation = [CodeSegDocs]; 2208} 2209 2210def PragmaClangBSSSection : InheritableAttr { 2211 // This attribute has no spellings as it is only ever created implicitly. 2212 let Spellings = []; 2213 let Args = [StringArgument<"Name">]; 2214 let Subjects = SubjectList<[GlobalVar], ErrorDiag>; 2215 let Documentation = [Undocumented]; 2216} 2217 2218def PragmaClangDataSection : InheritableAttr { 2219 // This attribute has no spellings as it is only ever created implicitly. 2220 let Spellings = []; 2221 let Args = [StringArgument<"Name">]; 2222 let Subjects = SubjectList<[GlobalVar], ErrorDiag>; 2223 let Documentation = [Undocumented]; 2224} 2225 2226def PragmaClangRodataSection : InheritableAttr { 2227 // This attribute has no spellings as it is only ever created implicitly. 2228 let Spellings = []; 2229 let Args = [StringArgument<"Name">]; 2230 let Subjects = SubjectList<[GlobalVar], ErrorDiag>; 2231 let Documentation = [Undocumented]; 2232} 2233 2234def PragmaClangRelroSection : InheritableAttr { 2235 // This attribute has no spellings as it is only ever created implicitly. 2236 let Spellings = []; 2237 let Args = [StringArgument<"Name">]; 2238 let Subjects = SubjectList<[GlobalVar], ErrorDiag>; 2239 let Documentation = [Undocumented]; 2240} 2241 2242def PragmaClangTextSection : InheritableAttr { 2243 // This attribute has no spellings as it is only ever created implicitly. 2244 let Spellings = []; 2245 let Args = [StringArgument<"Name">]; 2246 let Subjects = SubjectList<[Function], ErrorDiag>; 2247 let Documentation = [Undocumented]; 2248} 2249 2250def Sentinel : InheritableAttr { 2251 let Spellings = [GCC<"sentinel">]; 2252 let Args = [DefaultIntArgument<"Sentinel", 0>, 2253 DefaultIntArgument<"NullPos", 0>]; 2254// let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>; 2255 let Documentation = [Undocumented]; 2256} 2257 2258def Sensitive : InheritableAttr { 2259 let Spellings = [GNU<"sensitive">]; 2260 let Documentation = [Undocumented]; 2261} 2262 2263def StdCall : DeclOrTypeAttr { 2264 let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">]; 2265// let Subjects = [Function, ObjCMethod]; 2266 let Documentation = [StdCallDocs]; 2267} 2268 2269def SwiftCall : DeclOrTypeAttr { 2270 let Spellings = [Clang<"swiftcall">]; 2271// let Subjects = SubjectList<[Function]>; 2272 let Documentation = [SwiftCallDocs]; 2273} 2274 2275def SwiftContext : ParameterABIAttr { 2276 let Spellings = [Clang<"swift_context">]; 2277 let Documentation = [SwiftContextDocs]; 2278} 2279 2280def SwiftErrorResult : ParameterABIAttr { 2281 let Spellings = [Clang<"swift_error_result">]; 2282 let Documentation = [SwiftErrorResultDocs]; 2283} 2284 2285def SwiftIndirectResult : ParameterABIAttr { 2286 let Spellings = [Clang<"swift_indirect_result">]; 2287 let Documentation = [SwiftIndirectResultDocs]; 2288} 2289 2290def Suppress : StmtAttr { 2291 let Spellings = [CXX11<"gsl", "suppress">]; 2292 let Args = [VariadicStringArgument<"DiagnosticIdentifiers">]; 2293 let Documentation = [SuppressDocs]; 2294} 2295 2296def SysVABI : DeclOrTypeAttr { 2297 let Spellings = [GCC<"sysv_abi">]; 2298// let Subjects = [Function, ObjCMethod]; 2299 let Documentation = [Undocumented]; 2300} 2301 2302def ThisCall : DeclOrTypeAttr { 2303 let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">, 2304 Keyword<"_thiscall">]; 2305// let Subjects = [Function, ObjCMethod]; 2306 let Documentation = [ThisCallDocs]; 2307} 2308 2309def VectorCall : DeclOrTypeAttr { 2310 let Spellings = [Clang<"vectorcall">, Keyword<"__vectorcall">, 2311 Keyword<"_vectorcall">]; 2312// let Subjects = [Function, ObjCMethod]; 2313 let Documentation = [VectorCallDocs]; 2314} 2315 2316def Pascal : DeclOrTypeAttr { 2317 let Spellings = [Clang<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">]; 2318// let Subjects = [Function, ObjCMethod]; 2319 let Documentation = [Undocumented]; 2320} 2321 2322def PreserveMost : DeclOrTypeAttr { 2323 let Spellings = [Clang<"preserve_most">]; 2324 let Documentation = [PreserveMostDocs]; 2325} 2326 2327def PreserveAll : DeclOrTypeAttr { 2328 let Spellings = [Clang<"preserve_all">]; 2329 let Documentation = [PreserveAllDocs]; 2330} 2331 2332def Target : InheritableAttr { 2333 let Spellings = [GCC<"target">]; 2334 let Args = [StringArgument<"featuresStr">]; 2335 let Subjects = SubjectList<[Function], ErrorDiag>; 2336 let Documentation = [TargetDocs]; 2337 let AdditionalMembers = [{ 2338 ParsedTargetAttr parse() const { 2339 return parse(getFeaturesStr()); 2340 } 2341 2342 StringRef getArchitecture() const { 2343 StringRef Features = getFeaturesStr(); 2344 if (Features == "default") return {}; 2345 2346 SmallVector<StringRef, 1> AttrFeatures; 2347 Features.split(AttrFeatures, ","); 2348 2349 for (auto &Feature : AttrFeatures) { 2350 Feature = Feature.trim(); 2351 if (Feature.startswith("arch=")) 2352 return Feature.drop_front(sizeof("arch=") - 1); 2353 } 2354 return ""; 2355 } 2356 2357 // Gets the list of features as simple string-refs with no +/- or 'no-'. 2358 // Only adds the items to 'Out' that are additions. 2359 void getAddedFeatures(llvm::SmallVectorImpl<StringRef> &Out) const { 2360 StringRef Features = getFeaturesStr(); 2361 if (Features == "default") return; 2362 2363 SmallVector<StringRef, 1> AttrFeatures; 2364 Features.split(AttrFeatures, ","); 2365 2366 for (auto &Feature : AttrFeatures) { 2367 Feature = Feature.trim(); 2368 2369 if (!Feature.startswith("no-") && !Feature.startswith("arch=") && 2370 !Feature.startswith("fpmath=") && !Feature.startswith("tune=")) 2371 Out.push_back(Feature); 2372 } 2373 } 2374 2375 template<class Compare> 2376 ParsedTargetAttr parse(Compare cmp) const { 2377 ParsedTargetAttr Attrs = parse(); 2378 llvm::sort(std::begin(Attrs.Features), std::end(Attrs.Features), cmp); 2379 return Attrs; 2380 } 2381 2382 bool isDefaultVersion() const { return getFeaturesStr() == "default"; } 2383 2384 static ParsedTargetAttr parse(StringRef Features) { 2385 ParsedTargetAttr Ret; 2386 if (Features == "default") return Ret; 2387 SmallVector<StringRef, 1> AttrFeatures; 2388 Features.split(AttrFeatures, ","); 2389 2390 // Grab the various features and prepend a "+" to turn on the feature to 2391 // the backend and add them to our existing set of features. 2392 for (auto &Feature : AttrFeatures) { 2393 // Go ahead and trim whitespace rather than either erroring or 2394 // accepting it weirdly. 2395 Feature = Feature.trim(); 2396 2397 // We don't support cpu tuning this way currently. 2398 // TODO: Support the fpmath option. It will require checking 2399 // overall feature validity for the function with the rest of the 2400 // attributes on the function. 2401 if (Feature.startswith("fpmath=") || Feature.startswith("tune=")) 2402 continue; 2403 2404 if (Feature.startswith("branch-protection=")) { 2405 Ret.BranchProtection = Feature.split('=').second.trim(); 2406 continue; 2407 } 2408 2409 // While we're here iterating check for a different target cpu. 2410 if (Feature.startswith("arch=")) { 2411 if (!Ret.Architecture.empty()) 2412 Ret.DuplicateArchitecture = true; 2413 else 2414 Ret.Architecture = Feature.split("=").second.trim(); 2415 } else if (Feature.startswith("no-")) 2416 Ret.Features.push_back("-" + Feature.split("-").second.str()); 2417 else 2418 Ret.Features.push_back("+" + Feature.str()); 2419 } 2420 return Ret; 2421 } 2422 }]; 2423} 2424 2425def MinVectorWidth : InheritableAttr { 2426 let Spellings = [Clang<"min_vector_width">]; 2427 let Args = [UnsignedArgument<"VectorWidth">]; 2428 let Subjects = SubjectList<[Function], ErrorDiag>; 2429 let Documentation = [MinVectorWidthDocs]; 2430} 2431 2432def TransparentUnion : InheritableAttr { 2433 let Spellings = [GCC<"transparent_union">]; 2434// let Subjects = SubjectList<[Record, TypedefName]>; 2435 let Documentation = [TransparentUnionDocs]; 2436 let LangOpts = [COnly]; 2437} 2438 2439def Unavailable : InheritableAttr { 2440 let Spellings = [Clang<"unavailable">]; 2441 let Args = [StringArgument<"Message", 1>, 2442 EnumArgument<"ImplicitReason", "ImplicitReason", 2443 ["", "", "", ""], 2444 ["IR_None", 2445 "IR_ARCForbiddenType", 2446 "IR_ForbiddenWeak", 2447 "IR_ARCForbiddenConversion", 2448 "IR_ARCInitReturnsUnrelated", 2449 "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>]; 2450 let Documentation = [Undocumented]; 2451} 2452 2453def DiagnoseIf : InheritableAttr { 2454 // Does not have a [[]] spelling because this attribute requires the ability 2455 // to parse function arguments but the attribute is not written in the type 2456 // position. 2457 let Spellings = [GNU<"diagnose_if">]; 2458 let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>; 2459 let Args = [ExprArgument<"Cond">, StringArgument<"Message">, 2460 EnumArgument<"DiagnosticType", 2461 "DiagnosticType", 2462 ["error", "warning"], 2463 ["DT_Error", "DT_Warning"]>, 2464 BoolArgument<"ArgDependent", 0, /*fake*/ 1>, 2465 DeclArgument<Named, "Parent", 0, /*fake*/ 1>]; 2466 let InheritEvenIfAlreadyPresent = 1; 2467 let LateParsed = 1; 2468 let AdditionalMembers = [{ 2469 bool isError() const { return diagnosticType == DT_Error; } 2470 bool isWarning() const { return diagnosticType == DT_Warning; } 2471 }]; 2472 let TemplateDependent = 1; 2473 let Documentation = [DiagnoseIfDocs]; 2474} 2475 2476def ArcWeakrefUnavailable : InheritableAttr { 2477 let Spellings = [Clang<"objc_arc_weak_reference_unavailable">]; 2478 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; 2479 let Documentation = [Undocumented]; 2480 let SimpleHandler = 1; 2481} 2482 2483def ObjCGC : TypeAttr { 2484 let Spellings = [Clang<"objc_gc">]; 2485 let Args = [IdentifierArgument<"Kind">]; 2486 let Documentation = [Undocumented]; 2487} 2488 2489def ObjCOwnership : DeclOrTypeAttr { 2490 let Spellings = [Clang<"objc_ownership">]; 2491 let Args = [IdentifierArgument<"Kind">]; 2492 let Documentation = [Undocumented]; 2493} 2494 2495def ObjCRequiresPropertyDefs : InheritableAttr { 2496 let Spellings = [Clang<"objc_requires_property_definitions">]; 2497 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; 2498 let Documentation = [Undocumented]; 2499 let SimpleHandler = 1; 2500} 2501 2502def Unused : InheritableAttr { 2503 let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">, 2504 C2x<"", "maybe_unused">]; 2505 let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label, 2506 Field, ObjCMethod, FunctionLike]>; 2507 let Documentation = [WarnMaybeUnusedDocs]; 2508} 2509 2510def Used : InheritableAttr { 2511 let Spellings = [GCC<"used">]; 2512 let Subjects = SubjectList<[NonLocalVar, Function, ObjCMethod]>; 2513 let Documentation = [Undocumented]; 2514 let SimpleHandler = 1; 2515} 2516 2517def Uuid : InheritableAttr { 2518 let Spellings = [Declspec<"uuid">, Microsoft<"uuid">]; 2519 let Args = [StringArgument<"Guid">, 2520 DeclArgument<MSGuid, "GuidDecl", 0, /*fake=*/1>]; 2521 let Subjects = SubjectList<[Record, Enum]>; 2522 // FIXME: Allow expressing logical AND for LangOpts. Our condition should be: 2523 // CPlusPlus && (MicrosoftExt || Borland) 2524 let LangOpts = [MicrosoftExt, Borland]; 2525 let Documentation = [Undocumented]; 2526} 2527 2528def VectorSize : TypeAttr { 2529 let Spellings = [GCC<"vector_size">]; 2530 let Args = [ExprArgument<"NumBytes">]; 2531 let Documentation = [Undocumented]; 2532 // Represented as VectorType instead. 2533 let ASTNode = 0; 2534} 2535 2536def VecTypeHint : InheritableAttr { 2537 // Does not have a [[]] spelling because it is an OpenCL-related attribute. 2538 let Spellings = [GNU<"vec_type_hint">]; 2539 let Args = [TypeArgument<"TypeHint">]; 2540 let Subjects = SubjectList<[Function], ErrorDiag>; 2541 let Documentation = [Undocumented]; 2542} 2543 2544def MatrixType : TypeAttr { 2545 let Spellings = [Clang<"matrix_type">]; 2546 let Subjects = SubjectList<[TypedefName], ErrorDiag>; 2547 let Args = [ExprArgument<"NumRows">, ExprArgument<"NumColumns">]; 2548 let Documentation = [Undocumented]; 2549 let ASTNode = 0; 2550 let PragmaAttributeSupport = 0; 2551} 2552 2553def Visibility : InheritableAttr { 2554 let Clone = 0; 2555 let Spellings = [GCC<"visibility">]; 2556 let Args = [EnumArgument<"Visibility", "VisibilityType", 2557 ["default", "hidden", "internal", "protected"], 2558 ["Default", "Hidden", "Hidden", "Protected"]>]; 2559 let MeaningfulToClassTemplateDefinition = 1; 2560 let Documentation = [Undocumented]; 2561} 2562 2563def TypeVisibility : InheritableAttr { 2564 let Clone = 0; 2565 let Spellings = [Clang<"type_visibility">]; 2566 let Args = [EnumArgument<"Visibility", "VisibilityType", 2567 ["default", "hidden", "internal", "protected"], 2568 ["Default", "Hidden", "Hidden", "Protected"]>]; 2569// let Subjects = [Tag, ObjCInterface, Namespace]; 2570 let Documentation = [Undocumented]; 2571} 2572 2573def VecReturn : InheritableAttr { 2574 // This attribute does not have a C [[]] spelling because it only appertains 2575 // to C++ struct/class/union. 2576 // FIXME: should this attribute have a CPlusPlus language option? 2577 let Spellings = [Clang<"vecreturn", 0>]; 2578 let Subjects = SubjectList<[CXXRecord], ErrorDiag>; 2579 let Documentation = [Undocumented]; 2580} 2581 2582def WarnUnused : InheritableAttr { 2583 let Spellings = [GCC<"warn_unused">]; 2584 let Subjects = SubjectList<[Record]>; 2585 let Documentation = [Undocumented]; 2586 let SimpleHandler = 1; 2587} 2588 2589def WarnUnusedResult : InheritableAttr { 2590 let Spellings = [CXX11<"", "nodiscard", 201907>, C2x<"", "nodiscard">, 2591 CXX11<"clang", "warn_unused_result">, 2592 GCC<"warn_unused_result">]; 2593 let Subjects = SubjectList<[ObjCMethod, Enum, Record, FunctionLike]>; 2594 let Args = [StringArgument<"Message", 1>]; 2595 let Documentation = [WarnUnusedResultsDocs]; 2596 let AdditionalMembers = [{ 2597 // Check whether this the C++11 nodiscard version, even in non C++11 2598 // spellings. 2599 bool IsCXX11NoDiscard() const { 2600 return this->getSemanticSpelling() == CXX11_nodiscard; 2601 } 2602 }]; 2603} 2604 2605def Weak : InheritableAttr { 2606 let Spellings = [GCC<"weak">]; 2607 let Subjects = SubjectList<[Var, Function, CXXRecord]>; 2608 let Documentation = [Undocumented]; 2609 let SimpleHandler = 1; 2610} 2611 2612def WeakImport : InheritableAttr { 2613 let Spellings = [Clang<"weak_import">]; 2614 let Documentation = [Undocumented]; 2615} 2616 2617def WeakRef : InheritableAttr { 2618 let Spellings = [GCC<"weakref">]; 2619 // A WeakRef that has an argument is treated as being an AliasAttr 2620 let Args = [StringArgument<"Aliasee", 1>]; 2621 let Subjects = SubjectList<[Var, Function], ErrorDiag>; 2622 let Documentation = [Undocumented]; 2623} 2624 2625def LTOVisibilityPublic : InheritableAttr { 2626 let Spellings = [Clang<"lto_visibility_public">]; 2627 let Subjects = SubjectList<[Record]>; 2628 let Documentation = [LTOVisibilityDocs]; 2629 let SimpleHandler = 1; 2630} 2631 2632def AnyX86Interrupt : InheritableAttr, TargetSpecificAttr<TargetAnyX86> { 2633 // NOTE: If you add any additional spellings, ARMInterrupt's, 2634 // MSP430Interrupt's and MipsInterrupt's spellings must match. 2635 let Spellings = [GCC<"interrupt">]; 2636 let Subjects = SubjectList<[HasFunctionProto]>; 2637 let ParseKind = "Interrupt"; 2638 let HasCustomParsing = 1; 2639 let Documentation = [Undocumented]; 2640} 2641 2642def AnyX86NoCallerSavedRegisters : InheritableAttr, 2643 TargetSpecificAttr<TargetAnyX86> { 2644 let Spellings = [GCC<"no_caller_saved_registers">]; 2645 let Documentation = [AnyX86NoCallerSavedRegistersDocs]; 2646 let SimpleHandler = 1; 2647} 2648 2649def AnyX86NoCfCheck : DeclOrTypeAttr, TargetSpecificAttr<TargetAnyX86>{ 2650 let Spellings = [GCC<"nocf_check">]; 2651 let Subjects = SubjectList<[FunctionLike]>; 2652 let Documentation = [AnyX86NoCfCheckDocs]; 2653} 2654 2655def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetAnyX86> { 2656 let Spellings = [GCC<"force_align_arg_pointer">]; 2657 // Technically, this appertains to a FunctionDecl, but the target-specific 2658 // code silently allows anything function-like (such as typedefs or function 2659 // pointers), but does not apply the attribute to them. 2660 let Documentation = [X86ForceAlignArgPointerDocs]; 2661} 2662 2663def NoSanitize : InheritableAttr { 2664 let Spellings = [Clang<"no_sanitize">]; 2665 let Args = [VariadicStringArgument<"Sanitizers">]; 2666 let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag>; 2667 let Documentation = [NoSanitizeDocs]; 2668 let AdditionalMembers = [{ 2669 SanitizerMask getMask() const { 2670 SanitizerMask Mask; 2671 for (auto SanitizerName : sanitizers()) { 2672 SanitizerMask ParsedMask = 2673 parseSanitizerValue(SanitizerName, /*AllowGroups=*/true); 2674 Mask |= expandSanitizerGroups(ParsedMask); 2675 } 2676 return Mask; 2677 } 2678 }]; 2679} 2680 2681// Attributes to disable a specific sanitizer. No new sanitizers should be added 2682// to this list; the no_sanitize attribute should be extended instead. 2683def NoSanitizeSpecific : InheritableAttr { 2684 let Spellings = [GCC<"no_address_safety_analysis">, 2685 GCC<"no_sanitize_address">, 2686 GCC<"no_sanitize_thread">, 2687 Clang<"no_sanitize_memory">]; 2688 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>; 2689 let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs, 2690 NoSanitizeMemoryDocs]; 2691 let ASTNode = 0; 2692} 2693 2694def CFICanonicalJumpTable : InheritableAttr { 2695 let Spellings = [Clang<"cfi_canonical_jump_table">]; 2696 let Subjects = SubjectList<[Function], ErrorDiag>; 2697 let Documentation = [CFICanonicalJumpTableDocs]; 2698 let SimpleHandler = 1; 2699} 2700 2701// C/C++ Thread safety attributes (e.g. for deadlock, data race checking) 2702// Not all of these attributes will be given a [[]] spelling. The attributes 2703// which require access to function parameter names cannot use the [[]] spelling 2704// because they are not written in the type position. Some attributes are given 2705// an updated captability-based name and the older name will only be supported 2706// under the GNU-style spelling. 2707def GuardedVar : InheritableAttr { 2708 let Spellings = [Clang<"guarded_var", 0>]; 2709 let Subjects = SubjectList<[Field, SharedVar]>; 2710 let Documentation = [Undocumented]; 2711 let SimpleHandler = 1; 2712} 2713 2714def PtGuardedVar : InheritableAttr { 2715 let Spellings = [Clang<"pt_guarded_var", 0>]; 2716 let Subjects = SubjectList<[Field, SharedVar]>; 2717 let Documentation = [Undocumented]; 2718} 2719 2720def Lockable : InheritableAttr { 2721 let Spellings = [GNU<"lockable">]; 2722 let Subjects = SubjectList<[Record]>; 2723 let Documentation = [Undocumented]; 2724 let ASTNode = 0; // Replaced by Capability 2725} 2726 2727def ScopedLockable : InheritableAttr { 2728 let Spellings = [Clang<"scoped_lockable", 0>]; 2729 let Subjects = SubjectList<[Record]>; 2730 let Documentation = [Undocumented]; 2731 let SimpleHandler = 1; 2732} 2733 2734def Capability : InheritableAttr { 2735 let Spellings = [Clang<"capability", 0>, Clang<"shared_capability", 0>]; 2736 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag>; 2737 let Args = [StringArgument<"Name">]; 2738 let Accessors = [Accessor<"isShared", 2739 [Clang<"shared_capability", 0>]>]; 2740 let Documentation = [Undocumented]; 2741} 2742 2743def AssertCapability : InheritableAttr { 2744 let Spellings = [Clang<"assert_capability", 0>, 2745 Clang<"assert_shared_capability", 0>]; 2746 let Subjects = SubjectList<[Function]>; 2747 let LateParsed = 1; 2748 let TemplateDependent = 1; 2749 let ParseArgumentsAsUnevaluated = 1; 2750 let InheritEvenIfAlreadyPresent = 1; 2751 let Args = [VariadicExprArgument<"Args">]; 2752 let Accessors = [Accessor<"isShared", 2753 [Clang<"assert_shared_capability", 0>]>]; 2754 let Documentation = [AssertCapabilityDocs]; 2755} 2756 2757def AcquireCapability : InheritableAttr { 2758 let Spellings = [Clang<"acquire_capability", 0>, 2759 Clang<"acquire_shared_capability", 0>, 2760 GNU<"exclusive_lock_function">, 2761 GNU<"shared_lock_function">]; 2762 let Subjects = SubjectList<[Function]>; 2763 let LateParsed = 1; 2764 let TemplateDependent = 1; 2765 let ParseArgumentsAsUnevaluated = 1; 2766 let InheritEvenIfAlreadyPresent = 1; 2767 let Args = [VariadicExprArgument<"Args">]; 2768 let Accessors = [Accessor<"isShared", 2769 [Clang<"acquire_shared_capability", 0>, 2770 GNU<"shared_lock_function">]>]; 2771 let Documentation = [AcquireCapabilityDocs]; 2772} 2773 2774def TryAcquireCapability : InheritableAttr { 2775 let Spellings = [Clang<"try_acquire_capability", 0>, 2776 Clang<"try_acquire_shared_capability", 0>]; 2777 let Subjects = SubjectList<[Function], 2778 ErrorDiag>; 2779 let LateParsed = 1; 2780 let TemplateDependent = 1; 2781 let ParseArgumentsAsUnevaluated = 1; 2782 let InheritEvenIfAlreadyPresent = 1; 2783 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">]; 2784 let Accessors = [Accessor<"isShared", 2785 [Clang<"try_acquire_shared_capability", 0>]>]; 2786 let Documentation = [TryAcquireCapabilityDocs]; 2787} 2788 2789def ReleaseCapability : InheritableAttr { 2790 let Spellings = [Clang<"release_capability", 0>, 2791 Clang<"release_shared_capability", 0>, 2792 Clang<"release_generic_capability", 0>, 2793 Clang<"unlock_function", 0>]; 2794 let Subjects = SubjectList<[Function]>; 2795 let LateParsed = 1; 2796 let TemplateDependent = 1; 2797 let ParseArgumentsAsUnevaluated = 1; 2798 let InheritEvenIfAlreadyPresent = 1; 2799 let Args = [VariadicExprArgument<"Args">]; 2800 let Accessors = [Accessor<"isShared", 2801 [Clang<"release_shared_capability", 0>]>, 2802 Accessor<"isGeneric", 2803 [Clang<"release_generic_capability", 0>, 2804 Clang<"unlock_function", 0>]>]; 2805 let Documentation = [ReleaseCapabilityDocs]; 2806} 2807 2808def RequiresCapability : InheritableAttr { 2809 let Spellings = [Clang<"requires_capability", 0>, 2810 Clang<"exclusive_locks_required", 0>, 2811 Clang<"requires_shared_capability", 0>, 2812 Clang<"shared_locks_required", 0>]; 2813 let Args = [VariadicExprArgument<"Args">]; 2814 let LateParsed = 1; 2815 let TemplateDependent = 1; 2816 let ParseArgumentsAsUnevaluated = 1; 2817 let InheritEvenIfAlreadyPresent = 1; 2818 let Subjects = SubjectList<[Function]>; 2819 let Accessors = [Accessor<"isShared", [Clang<"requires_shared_capability", 0>, 2820 Clang<"shared_locks_required", 0>]>]; 2821 let Documentation = [Undocumented]; 2822} 2823 2824def NoThreadSafetyAnalysis : InheritableAttr { 2825 let Spellings = [Clang<"no_thread_safety_analysis">]; 2826 let Subjects = SubjectList<[Function]>; 2827 let Documentation = [Undocumented]; 2828 let SimpleHandler = 1; 2829} 2830 2831def GuardedBy : InheritableAttr { 2832 let Spellings = [GNU<"guarded_by">]; 2833 let Args = [ExprArgument<"Arg">]; 2834 let LateParsed = 1; 2835 let TemplateDependent = 1; 2836 let ParseArgumentsAsUnevaluated = 1; 2837 let InheritEvenIfAlreadyPresent = 1; 2838 let Subjects = SubjectList<[Field, SharedVar]>; 2839 let Documentation = [Undocumented]; 2840} 2841 2842def PtGuardedBy : InheritableAttr { 2843 let Spellings = [GNU<"pt_guarded_by">]; 2844 let Args = [ExprArgument<"Arg">]; 2845 let LateParsed = 1; 2846 let TemplateDependent = 1; 2847 let ParseArgumentsAsUnevaluated = 1; 2848 let InheritEvenIfAlreadyPresent = 1; 2849 let Subjects = SubjectList<[Field, SharedVar]>; 2850 let Documentation = [Undocumented]; 2851} 2852 2853def AcquiredAfter : InheritableAttr { 2854 let Spellings = [GNU<"acquired_after">]; 2855 let Args = [VariadicExprArgument<"Args">]; 2856 let LateParsed = 1; 2857 let TemplateDependent = 1; 2858 let ParseArgumentsAsUnevaluated = 1; 2859 let InheritEvenIfAlreadyPresent = 1; 2860 let Subjects = SubjectList<[Field, SharedVar]>; 2861 let Documentation = [Undocumented]; 2862} 2863 2864def AcquiredBefore : InheritableAttr { 2865 let Spellings = [GNU<"acquired_before">]; 2866 let Args = [VariadicExprArgument<"Args">]; 2867 let LateParsed = 1; 2868 let TemplateDependent = 1; 2869 let ParseArgumentsAsUnevaluated = 1; 2870 let InheritEvenIfAlreadyPresent = 1; 2871 let Subjects = SubjectList<[Field, SharedVar]>; 2872 let Documentation = [Undocumented]; 2873} 2874 2875def AssertExclusiveLock : InheritableAttr { 2876 let Spellings = [GNU<"assert_exclusive_lock">]; 2877 let Args = [VariadicExprArgument<"Args">]; 2878 let LateParsed = 1; 2879 let TemplateDependent = 1; 2880 let ParseArgumentsAsUnevaluated = 1; 2881 let InheritEvenIfAlreadyPresent = 1; 2882 let Subjects = SubjectList<[Function]>; 2883 let Documentation = [Undocumented]; 2884} 2885 2886def AssertSharedLock : InheritableAttr { 2887 let Spellings = [GNU<"assert_shared_lock">]; 2888 let Args = [VariadicExprArgument<"Args">]; 2889 let LateParsed = 1; 2890 let TemplateDependent = 1; 2891 let ParseArgumentsAsUnevaluated = 1; 2892 let InheritEvenIfAlreadyPresent = 1; 2893 let Subjects = SubjectList<[Function]>; 2894 let Documentation = [Undocumented]; 2895} 2896 2897// The first argument is an integer or boolean value specifying the return value 2898// of a successful lock acquisition. 2899def ExclusiveTrylockFunction : InheritableAttr { 2900 let Spellings = [GNU<"exclusive_trylock_function">]; 2901 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">]; 2902 let LateParsed = 1; 2903 let TemplateDependent = 1; 2904 let ParseArgumentsAsUnevaluated = 1; 2905 let InheritEvenIfAlreadyPresent = 1; 2906 let Subjects = SubjectList<[Function]>; 2907 let Documentation = [Undocumented]; 2908} 2909 2910// The first argument is an integer or boolean value specifying the return value 2911// of a successful lock acquisition. 2912def SharedTrylockFunction : InheritableAttr { 2913 let Spellings = [GNU<"shared_trylock_function">]; 2914 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">]; 2915 let LateParsed = 1; 2916 let TemplateDependent = 1; 2917 let ParseArgumentsAsUnevaluated = 1; 2918 let InheritEvenIfAlreadyPresent = 1; 2919 let Subjects = SubjectList<[Function]>; 2920 let Documentation = [Undocumented]; 2921} 2922 2923def LockReturned : InheritableAttr { 2924 let Spellings = [GNU<"lock_returned">]; 2925 let Args = [ExprArgument<"Arg">]; 2926 let LateParsed = 1; 2927 let TemplateDependent = 1; 2928 let ParseArgumentsAsUnevaluated = 1; 2929 let Subjects = SubjectList<[Function]>; 2930 let Documentation = [Undocumented]; 2931} 2932 2933def LocksExcluded : InheritableAttr { 2934 let Spellings = [GNU<"locks_excluded">]; 2935 let Args = [VariadicExprArgument<"Args">]; 2936 let LateParsed = 1; 2937 let TemplateDependent = 1; 2938 let ParseArgumentsAsUnevaluated = 1; 2939 let InheritEvenIfAlreadyPresent = 1; 2940 let Subjects = SubjectList<[Function]>; 2941 let Documentation = [Undocumented]; 2942} 2943 2944// C/C++ consumed attributes. 2945 2946def Consumable : InheritableAttr { 2947 // This attribute does not have a C [[]] spelling because it only appertains 2948 // to C++ struct/class/union. 2949 // FIXME: should this attribute have a CPlusPlus language option? 2950 let Spellings = [Clang<"consumable", 0>]; 2951 let Subjects = SubjectList<[CXXRecord]>; 2952 let Args = [EnumArgument<"DefaultState", "ConsumedState", 2953 ["unknown", "consumed", "unconsumed"], 2954 ["Unknown", "Consumed", "Unconsumed"]>]; 2955 let Documentation = [ConsumableDocs]; 2956} 2957 2958def ConsumableAutoCast : InheritableAttr { 2959 // This attribute does not have a C [[]] spelling because it only appertains 2960 // to C++ struct/class/union. 2961 // FIXME: should this attribute have a CPlusPlus language option? 2962 let Spellings = [Clang<"consumable_auto_cast_state", 0>]; 2963 let Subjects = SubjectList<[CXXRecord]>; 2964 let Documentation = [Undocumented]; 2965 let SimpleHandler = 1; 2966} 2967 2968def ConsumableSetOnRead : InheritableAttr { 2969 // This attribute does not have a C [[]] spelling because it only appertains 2970 // to C++ struct/class/union. 2971 // FIXME: should this attribute have a CPlusPlus language option? 2972 let Spellings = [Clang<"consumable_set_state_on_read", 0>]; 2973 let Subjects = SubjectList<[CXXRecord]>; 2974 let Documentation = [Undocumented]; 2975 let SimpleHandler = 1; 2976} 2977 2978def CallableWhen : InheritableAttr { 2979 // This attribute does not have a C [[]] spelling because it only appertains 2980 // to C++ function (but doesn't require it to be a member function). 2981 // FIXME: should this attribute have a CPlusPlus language option? 2982 let Spellings = [Clang<"callable_when", 0>]; 2983 let Subjects = SubjectList<[CXXMethod]>; 2984 let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState", 2985 ["unknown", "consumed", "unconsumed"], 2986 ["Unknown", "Consumed", "Unconsumed"]>]; 2987 let Documentation = [CallableWhenDocs]; 2988} 2989 2990def ParamTypestate : InheritableAttr { 2991 // This attribute does not have a C [[]] spelling because it only appertains 2992 // to a parameter whose type is a consumable C++ class. 2993 // FIXME: should this attribute have a CPlusPlus language option? 2994 let Spellings = [Clang<"param_typestate", 0>]; 2995 let Subjects = SubjectList<[ParmVar]>; 2996 let Args = [EnumArgument<"ParamState", "ConsumedState", 2997 ["unknown", "consumed", "unconsumed"], 2998 ["Unknown", "Consumed", "Unconsumed"]>]; 2999 let Documentation = [ParamTypestateDocs]; 3000} 3001 3002def ReturnTypestate : InheritableAttr { 3003 // This attribute does not have a C [[]] spelling because it only appertains 3004 // to a parameter or function return type that is a consumable C++ class. 3005 // FIXME: should this attribute have a CPlusPlus language option? 3006 let Spellings = [Clang<"return_typestate", 0>]; 3007 let Subjects = SubjectList<[Function, ParmVar]>; 3008 let Args = [EnumArgument<"State", "ConsumedState", 3009 ["unknown", "consumed", "unconsumed"], 3010 ["Unknown", "Consumed", "Unconsumed"]>]; 3011 let Documentation = [ReturnTypestateDocs]; 3012} 3013 3014def SetTypestate : InheritableAttr { 3015 // This attribute does not have a C [[]] spelling because it only appertains 3016 // to C++ function (but doesn't require it to be a member function). 3017 // FIXME: should this attribute have a CPlusPlus language option? 3018 let Spellings = [Clang<"set_typestate", 0>]; 3019 let Subjects = SubjectList<[CXXMethod]>; 3020 let Args = [EnumArgument<"NewState", "ConsumedState", 3021 ["unknown", "consumed", "unconsumed"], 3022 ["Unknown", "Consumed", "Unconsumed"]>]; 3023 let Documentation = [SetTypestateDocs]; 3024} 3025 3026def TestTypestate : InheritableAttr { 3027 // This attribute does not have a C [[]] spelling because it only appertains 3028 // to C++ function (but doesn't require it to be a member function). 3029 // FIXME: should this attribute have a CPlusPlus language option? 3030 let Spellings = [Clang<"test_typestate", 0>]; 3031 let Subjects = SubjectList<[CXXMethod]>; 3032 let Args = [EnumArgument<"TestState", "ConsumedState", 3033 ["consumed", "unconsumed"], 3034 ["Consumed", "Unconsumed"]>]; 3035 let Documentation = [TestTypestateDocs]; 3036} 3037 3038// Type safety attributes for `void *' pointers and type tags. 3039 3040def ArgumentWithTypeTag : InheritableAttr { 3041 let Spellings = [Clang<"argument_with_type_tag">, 3042 Clang<"pointer_with_type_tag">]; 3043 let Subjects = SubjectList<[HasFunctionProto], ErrorDiag>; 3044 let Args = [IdentifierArgument<"ArgumentKind">, 3045 ParamIdxArgument<"ArgumentIdx">, 3046 ParamIdxArgument<"TypeTagIdx">, 3047 BoolArgument<"IsPointer", /*opt*/0, /*fake*/1>]; 3048 let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs]; 3049} 3050 3051def TypeTagForDatatype : InheritableAttr { 3052 let Spellings = [Clang<"type_tag_for_datatype">]; 3053 let Args = [IdentifierArgument<"ArgumentKind">, 3054 TypeArgument<"MatchingCType">, 3055 BoolArgument<"LayoutCompatible">, 3056 BoolArgument<"MustBeNull">]; 3057// let Subjects = SubjectList<[Var], ErrorDiag>; 3058 let HasCustomParsing = 1; 3059 let Documentation = [TypeTagForDatatypeDocs]; 3060} 3061 3062def Owner : InheritableAttr { 3063 let Spellings = [CXX11<"gsl", "Owner">]; 3064 let Subjects = SubjectList<[Struct]>; 3065 let Args = [TypeArgument<"DerefType", /*opt=*/1>]; 3066 let Documentation = [LifetimeOwnerDocs]; 3067} 3068 3069def Pointer : InheritableAttr { 3070 let Spellings = [CXX11<"gsl", "Pointer">]; 3071 let Subjects = SubjectList<[Struct]>; 3072 let Args = [TypeArgument<"DerefType", /*opt=*/1>]; 3073 let Documentation = [LifetimePointerDocs]; 3074} 3075 3076// Microsoft-related attributes 3077 3078def MSNoVTable : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> { 3079 let Spellings = [Declspec<"novtable">]; 3080 let Subjects = SubjectList<[CXXRecord]>; 3081 let Documentation = [MSNoVTableDocs]; 3082 let SimpleHandler = 1; 3083} 3084 3085def : IgnoredAttr { 3086 let Spellings = [Declspec<"property">]; 3087} 3088 3089def MSAllocator : InheritableAttr { 3090 let Spellings = [Declspec<"allocator">]; 3091 let Subjects = SubjectList<[Function]>; 3092 let Documentation = [MSAllocatorDocs]; 3093} 3094 3095def CFGuard : InheritableAttr { 3096 // Currently only the __declspec(guard(nocf)) modifier is supported. In future 3097 // we might also want to support __declspec(guard(suppress)). 3098 let Spellings = [Declspec<"guard">]; 3099 let Subjects = SubjectList<[Function]>; 3100 let Args = [EnumArgument<"Guard", "GuardArg", ["nocf"], ["nocf"]>]; 3101 let Documentation = [CFGuardDocs]; 3102} 3103 3104def MSStruct : InheritableAttr { 3105 let Spellings = [GCC<"ms_struct">]; 3106 let Subjects = SubjectList<[Record]>; 3107 let Documentation = [Undocumented]; 3108 let SimpleHandler = 1; 3109} 3110 3111def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> { 3112 let Spellings = [Declspec<"dllexport">, GCC<"dllexport">]; 3113 let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>; 3114 let Documentation = [DLLExportDocs]; 3115} 3116 3117def DLLExportStaticLocal : InheritableAttr, TargetSpecificAttr<TargetWindows> { 3118 // This attribute is used internally only when -fno-dllexport-inlines is 3119 // passed. This attribute is added to inline function of class having 3120 // dllexport attribute. And if the function has static local variables, this 3121 // attribute is used to whether the variables are exported or not. Also if 3122 // function has local static variables, the function is dllexported too. 3123 let Spellings = []; 3124 let Subjects = SubjectList<[Function]>; 3125 let Documentation = [Undocumented]; 3126} 3127 3128def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> { 3129 let Spellings = [Declspec<"dllimport">, GCC<"dllimport">]; 3130 let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>; 3131 let Documentation = [DLLImportDocs]; 3132 3133 3134 let AdditionalMembers = [{ 3135private: 3136 bool PropagatedToBaseTemplate = false; 3137 3138public: 3139 void setPropagatedToBaseTemplate() { PropagatedToBaseTemplate = true; } 3140 bool wasPropagatedToBaseTemplate() { return PropagatedToBaseTemplate; } 3141 }]; 3142} 3143 3144def DLLImportStaticLocal : InheritableAttr, TargetSpecificAttr<TargetWindows> { 3145 // This attribute is used internally only when -fno-dllexport-inlines is 3146 // passed. This attribute is added to inline function of class having 3147 // dllimport attribute. And if the function has static local variables, this 3148 // attribute is used to whether the variables are imported or not. 3149 let Spellings = []; 3150 let Subjects = SubjectList<[Function]>; 3151 let Documentation = [Undocumented]; 3152} 3153 3154def SelectAny : InheritableAttr { 3155 let Spellings = [Declspec<"selectany">, GCC<"selectany">]; 3156 let Documentation = [SelectAnyDocs]; 3157 let SimpleHandler = 1; 3158} 3159 3160def Thread : Attr { 3161 let Spellings = [Declspec<"thread">]; 3162 let LangOpts = [MicrosoftExt]; 3163 let Documentation = [ThreadDocs]; 3164 let Subjects = SubjectList<[Var]>; 3165} 3166 3167def Win64 : IgnoredAttr { 3168 let Spellings = [Keyword<"__w64">]; 3169 let LangOpts = [MicrosoftExt]; 3170} 3171 3172def Ptr32 : TypeAttr { 3173 let Spellings = [Keyword<"__ptr32">]; 3174 let Documentation = [Ptr32Docs]; 3175} 3176 3177def Ptr64 : TypeAttr { 3178 let Spellings = [Keyword<"__ptr64">]; 3179 let Documentation = [Ptr64Docs]; 3180} 3181 3182def SPtr : TypeAttr { 3183 let Spellings = [Keyword<"__sptr">]; 3184 let Documentation = [SPtrDocs]; 3185} 3186 3187def UPtr : TypeAttr { 3188 let Spellings = [Keyword<"__uptr">]; 3189 let Documentation = [UPtrDocs]; 3190} 3191 3192def MSInheritance : InheritableAttr { 3193 let LangOpts = [MicrosoftExt]; 3194 let Args = [DefaultBoolArgument<"BestCase", /*default*/1, /*fake*/1>]; 3195 let Spellings = [Keyword<"__single_inheritance">, 3196 Keyword<"__multiple_inheritance">, 3197 Keyword<"__virtual_inheritance">, 3198 Keyword<"__unspecified_inheritance">]; 3199 let AdditionalMembers = [{ 3200 MSInheritanceModel getInheritanceModel() const { 3201 // The spelling enum should agree with MSInheritanceModel. 3202 return MSInheritanceModel(getSemanticSpelling()); 3203 } 3204 }]; 3205 let Documentation = [MSInheritanceDocs]; 3206} 3207 3208def MSVtorDisp : InheritableAttr { 3209 // This attribute has no spellings as it is only ever created implicitly. 3210 let Spellings = []; 3211 let Args = [UnsignedArgument<"vdm">]; 3212 let SemaHandler = 0; 3213 3214 let AdditionalMembers = [{ 3215 MSVtorDispMode getVtorDispMode() const { return MSVtorDispMode(vdm); } 3216 }]; 3217 let Documentation = [Undocumented]; 3218} 3219 3220def InitSeg : Attr { 3221 let Spellings = [Pragma<"", "init_seg">]; 3222 let Args = [StringArgument<"Section">]; 3223 let SemaHandler = 0; 3224 let Documentation = [InitSegDocs]; 3225 let AdditionalMembers = [{ 3226 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const { 3227 OS << " (" << getSection() << ')'; 3228 } 3229 }]; 3230} 3231 3232def LoopHint : Attr { 3233 /// #pragma clang loop <option> directive 3234 /// vectorize: vectorizes loop operations if State == Enable. 3235 /// vectorize_width: vectorize loop operations with width 'Value'. 3236 /// interleave: interleave multiple loop iterations if State == Enable. 3237 /// interleave_count: interleaves 'Value' loop iterations. 3238 /// unroll: fully unroll loop if State == Enable. 3239 /// unroll_count: unrolls loop 'Value' times. 3240 /// unroll_and_jam: attempt to unroll and jam loop if State == Enable. 3241 /// unroll_and_jam_count: unroll and jams loop 'Value' times. 3242 /// distribute: attempt to distribute loop if State == Enable. 3243 /// pipeline: disable pipelining loop if State == Disable. 3244 /// pipeline_initiation_interval: create loop schedule with initiation interval equal to 'Value'. 3245 3246 /// #pragma unroll <argument> directive 3247 /// <no arg>: fully unrolls loop. 3248 /// boolean: fully unrolls loop if State == Enable. 3249 /// expression: unrolls loop 'Value' times. 3250 3251 let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">, 3252 Pragma<"", "nounroll">, Pragma<"", "unroll_and_jam">, 3253 Pragma<"", "nounroll_and_jam">]; 3254 3255 /// State of the loop optimization specified by the spelling. 3256 let Args = [EnumArgument<"Option", "OptionType", 3257 ["vectorize", "vectorize_width", "interleave", "interleave_count", 3258 "unroll", "unroll_count", "unroll_and_jam", "unroll_and_jam_count", 3259 "pipeline", "pipeline_initiation_interval", "distribute", 3260 "vectorize_predicate"], 3261 ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount", 3262 "Unroll", "UnrollCount", "UnrollAndJam", "UnrollAndJamCount", 3263 "PipelineDisabled", "PipelineInitiationInterval", "Distribute", 3264 "VectorizePredicate"]>, 3265 EnumArgument<"State", "LoopHintState", 3266 ["enable", "disable", "numeric", "assume_safety", "full"], 3267 ["Enable", "Disable", "Numeric", "AssumeSafety", "Full"]>, 3268 ExprArgument<"Value">]; 3269 3270 let AdditionalMembers = [{ 3271 static const char *getOptionName(int Option) { 3272 switch(Option) { 3273 case Vectorize: return "vectorize"; 3274 case VectorizeWidth: return "vectorize_width"; 3275 case Interleave: return "interleave"; 3276 case InterleaveCount: return "interleave_count"; 3277 case Unroll: return "unroll"; 3278 case UnrollCount: return "unroll_count"; 3279 case UnrollAndJam: return "unroll_and_jam"; 3280 case UnrollAndJamCount: return "unroll_and_jam_count"; 3281 case PipelineDisabled: return "pipeline"; 3282 case PipelineInitiationInterval: return "pipeline_initiation_interval"; 3283 case Distribute: return "distribute"; 3284 case VectorizePredicate: return "vectorize_predicate"; 3285 } 3286 llvm_unreachable("Unhandled LoopHint option."); 3287 } 3288 3289 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const; 3290 3291 // Return a string containing the loop hint argument including the 3292 // enclosing parentheses. 3293 std::string getValueString(const PrintingPolicy &Policy) const; 3294 3295 // Return a string suitable for identifying this attribute in diagnostics. 3296 std::string getDiagnosticName(const PrintingPolicy &Policy) const; 3297 }]; 3298 3299 let Documentation = [LoopHintDocs, UnrollHintDocs]; 3300} 3301 3302def CapturedRecord : InheritableAttr { 3303 // This attribute has no spellings as it is only ever created implicitly. 3304 let Spellings = []; 3305 let SemaHandler = 0; 3306 let Documentation = [Undocumented]; 3307} 3308 3309def OMPThreadPrivateDecl : InheritableAttr { 3310 // This attribute has no spellings as it is only ever created implicitly. 3311 let Spellings = []; 3312 let SemaHandler = 0; 3313 let Documentation = [Undocumented]; 3314} 3315 3316def OMPCaptureNoInit : InheritableAttr { 3317 // This attribute has no spellings as it is only ever created implicitly. 3318 let Spellings = []; 3319 let SemaHandler = 0; 3320 let Documentation = [Undocumented]; 3321} 3322 3323def OMPCaptureKind : Attr { 3324 // This attribute has no spellings as it is only ever created implicitly. 3325 let Spellings = []; 3326 let SemaHandler = 0; 3327 let Args = [UnsignedArgument<"CaptureKindVal">]; 3328 let Documentation = [Undocumented]; 3329 let AdditionalMembers = [{ 3330 llvm::omp::Clause getCaptureKind() const { 3331 return static_cast<llvm::omp::Clause>(getCaptureKindVal()); 3332 } 3333 }]; 3334} 3335 3336def OMPReferencedVar : Attr { 3337 // This attribute has no spellings as it is only ever created implicitly. 3338 let Spellings = []; 3339 let SemaHandler = 0; 3340 let Args = [ExprArgument<"Ref">]; 3341 let Documentation = [Undocumented]; 3342} 3343 3344def OMPDeclareSimdDecl : Attr { 3345 let Spellings = [Pragma<"omp", "declare simd">]; 3346 let Subjects = SubjectList<[Function]>; 3347 let SemaHandler = 0; 3348 let HasCustomParsing = 1; 3349 let Documentation = [OMPDeclareSimdDocs]; 3350 let Args = [ 3351 EnumArgument<"BranchState", "BranchStateTy", 3352 [ "", "inbranch", "notinbranch" ], 3353 [ "BS_Undefined", "BS_Inbranch", "BS_Notinbranch" ]>, 3354 ExprArgument<"Simdlen">, VariadicExprArgument<"Uniforms">, 3355 VariadicExprArgument<"Aligneds">, VariadicExprArgument<"Alignments">, 3356 VariadicExprArgument<"Linears">, VariadicUnsignedArgument<"Modifiers">, 3357 VariadicExprArgument<"Steps"> 3358 ]; 3359 let AdditionalMembers = [{ 3360 void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy) 3361 const; 3362 }]; 3363} 3364 3365def OMPDeclareTargetDecl : InheritableAttr { 3366 let Spellings = [Pragma<"omp", "declare target">]; 3367 let SemaHandler = 0; 3368 let Subjects = SubjectList<[Function, SharedVar]>; 3369 let Documentation = [OMPDeclareTargetDocs]; 3370 let Args = [ 3371 EnumArgument<"MapType", "MapTypeTy", 3372 [ "to", "link" ], 3373 [ "MT_To", "MT_Link" ]>, 3374 EnumArgument<"DevType", "DevTypeTy", 3375 [ "host", "nohost", "any" ], 3376 [ "DT_Host", "DT_NoHost", "DT_Any" ]> 3377 ]; 3378 let AdditionalMembers = [{ 3379 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const; 3380 static llvm::Optional<MapTypeTy> 3381 isDeclareTargetDeclaration(const ValueDecl *VD); 3382 static llvm::Optional<DevTypeTy> getDeviceType(const ValueDecl *VD); 3383 }]; 3384} 3385 3386def OMPAllocateDecl : InheritableAttr { 3387 // This attribute has no spellings as it is only ever created implicitly. 3388 let Spellings = []; 3389 let SemaHandler = 0; 3390 let Args = [ 3391 EnumArgument<"AllocatorType", "AllocatorTypeTy", 3392 [ 3393 "omp_null_allocator", "omp_default_mem_alloc", 3394 "omp_large_cap_mem_alloc", "omp_const_mem_alloc", 3395 "omp_high_bw_mem_alloc", "omp_low_lat_mem_alloc", 3396 "omp_cgroup_mem_alloc", "omp_pteam_mem_alloc", 3397 "omp_thread_mem_alloc", "" 3398 ], 3399 [ 3400 "OMPNullMemAlloc", "OMPDefaultMemAlloc", 3401 "OMPLargeCapMemAlloc", "OMPConstMemAlloc", 3402 "OMPHighBWMemAlloc", "OMPLowLatMemAlloc", 3403 "OMPCGroupMemAlloc", "OMPPTeamMemAlloc", "OMPThreadMemAlloc", 3404 "OMPUserDefinedMemAlloc" 3405 ]>, 3406 ExprArgument<"Allocator"> 3407 ]; 3408 let Documentation = [Undocumented]; 3409} 3410 3411def OMPDeclareVariant : InheritableAttr { 3412 let Spellings = [Pragma<"omp", "declare variant">]; 3413 let Subjects = SubjectList<[Function]>; 3414 let SemaHandler = 0; 3415 let HasCustomParsing = 1; 3416 let InheritEvenIfAlreadyPresent = 1; 3417 let Documentation = [OMPDeclareVariantDocs]; 3418 let Args = [ 3419 ExprArgument<"VariantFuncRef">, 3420 OMPTraitInfoArgument<"TraitInfos">, 3421 ]; 3422 let AdditionalMembers = [{ 3423 OMPTraitInfo &getTraitInfo() { return *traitInfos; } 3424 void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy) 3425 const; 3426 }]; 3427} 3428 3429def InternalLinkage : InheritableAttr { 3430 let Spellings = [Clang<"internal_linkage">]; 3431 let Subjects = SubjectList<[Var, Function, CXXRecord]>; 3432 let Documentation = [InternalLinkageDocs]; 3433} 3434 3435def ExcludeFromExplicitInstantiation : InheritableAttr { 3436 let Spellings = [Clang<"exclude_from_explicit_instantiation">]; 3437 let Subjects = SubjectList<[Var, Function, CXXRecord]>; 3438 let Documentation = [ExcludeFromExplicitInstantiationDocs]; 3439 let MeaningfulToClassTemplateDefinition = 1; 3440 let SimpleHandler = 1; 3441} 3442 3443def Reinitializes : InheritableAttr { 3444 let Spellings = [Clang<"reinitializes", 0>]; 3445 let Subjects = SubjectList<[NonStaticNonConstCXXMethod], ErrorDiag>; 3446 let Documentation = [ReinitializesDocs]; 3447 let SimpleHandler = 1; 3448} 3449 3450def NoDestroy : InheritableAttr { 3451 let Spellings = [Clang<"no_destroy", 0>]; 3452 let Subjects = SubjectList<[Var]>; 3453 let Documentation = [NoDestroyDocs]; 3454} 3455 3456def AlwaysDestroy : InheritableAttr { 3457 let Spellings = [Clang<"always_destroy", 0>]; 3458 let Subjects = SubjectList<[Var]>; 3459 let Documentation = [AlwaysDestroyDocs]; 3460} 3461 3462def SpeculativeLoadHardening : InheritableAttr { 3463 let Spellings = [Clang<"speculative_load_hardening">]; 3464 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>; 3465 let Documentation = [SpeculativeLoadHardeningDocs]; 3466} 3467 3468def NoSpeculativeLoadHardening : InheritableAttr { 3469 let Spellings = [Clang<"no_speculative_load_hardening">]; 3470 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>; 3471 let Documentation = [NoSpeculativeLoadHardeningDocs]; 3472} 3473 3474def Uninitialized : InheritableAttr { 3475 let Spellings = [Clang<"uninitialized", 0>]; 3476 let Subjects = SubjectList<[LocalVar]>; 3477 let PragmaAttributeSupport = 1; 3478 let Documentation = [UninitializedDocs]; 3479} 3480 3481def LoaderUninitialized : Attr { 3482 let Spellings = [Clang<"loader_uninitialized">]; 3483 let Subjects = SubjectList<[GlobalVar]>; 3484 let Documentation = [LoaderUninitializedDocs]; 3485} 3486 3487def ObjCExternallyRetained : InheritableAttr { 3488 let LangOpts = [ObjCAutoRefCount]; 3489 let Spellings = [Clang<"objc_externally_retained">]; 3490 let Subjects = SubjectList<[NonParmVar, Function, Block, ObjCMethod]>; 3491 let Documentation = [ObjCExternallyRetainedDocs]; 3492} 3493 3494def NoBuiltin : Attr { 3495 let Spellings = [Clang<"no_builtin">]; 3496 let Args = [VariadicStringArgument<"BuiltinNames">]; 3497 let Subjects = SubjectList<[Function]>; 3498 let Documentation = [NoBuiltinDocs]; 3499} 3500 3501// FIXME: This attribute is not inheritable, it will not be propagated to 3502// redecls. [[clang::lifetimebound]] has the same problems. This should be 3503// fixed in TableGen (by probably adding a new inheritable flag). 3504def AcquireHandle : DeclOrTypeAttr { 3505 let Spellings = [Clang<"acquire_handle">]; 3506 let Args = [StringArgument<"HandleType">]; 3507 let Subjects = SubjectList<[Function, TypedefName, ParmVar]>; 3508 let Documentation = [AcquireHandleDocs]; 3509} 3510 3511def UseHandle : InheritableParamAttr { 3512 let Spellings = [Clang<"use_handle">]; 3513 let Args = [StringArgument<"HandleType">]; 3514 let Subjects = SubjectList<[ParmVar]>; 3515 let Documentation = [UseHandleDocs]; 3516} 3517 3518def ReleaseHandle : InheritableParamAttr { 3519 let Spellings = [Clang<"release_handle">]; 3520 let Args = [StringArgument<"HandleType">]; 3521 let Subjects = SubjectList<[ParmVar]>; 3522 let Documentation = [ReleaseHandleDocs]; 3523} 3524