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