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