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