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