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