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