1//==--- Attr.td - attribute definitions -----------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// The documentation is organized by category. Attributes can have category- 11// specific documentation that is collated within the larger document. 12class DocumentationCategory<string name> { 13 string Name = name; 14 code Content = [{}]; 15} 16def DocCatFunction : DocumentationCategory<"Function Attributes">; 17def DocCatVariable : DocumentationCategory<"Variable Attributes">; 18def DocCatType : DocumentationCategory<"Type Attributes">; 19def DocCatStmt : DocumentationCategory<"Statement Attributes">; 20// Attributes listed under the Undocumented category do not generate any public 21// documentation. Ideally, this category should be used for internal-only 22// attributes which contain no spellings. 23def DocCatUndocumented : DocumentationCategory<"Undocumented">; 24 25class DocDeprecated<string replacement = ""> { 26 // If the Replacement field is empty, no replacement will be listed with the 27 // documentation. Otherwise, the documentation will specify the attribute has 28 // been superseded by this replacement. 29 string Replacement = replacement; 30} 31 32// Specifies the documentation to be associated with the given category. 33class Documentation { 34 DocumentationCategory Category; 35 code Content; 36 37 // If the heading is empty, one may be picked automatically. If the attribute 38 // only has one spelling, no heading is required as the attribute's sole 39 // spelling is sufficient. If all spellings are semantically common, the 40 // heading will be the semantic spelling. If the spellings are not 41 // semantically common and no heading is provided, an error will be emitted. 42 string Heading = ""; 43 44 // When set, specifies that the attribute is deprecated and can optionally 45 // specify a replacement attribute. 46 DocDeprecated Deprecated; 47} 48 49// Specifies that the attribute is explicitly undocumented. This can be a 50// helpful placeholder for the attribute while working on the implementation, 51// but should not be used once feature work has been completed. 52def Undocumented : Documentation { 53 let Category = DocCatUndocumented; 54} 55 56include "clang/Basic/AttrDocs.td" 57 58// An attribute's subject is whatever it appertains to. In this file, it is 59// more accurately a list of things that an attribute can appertain to. All 60// Decls and Stmts are possibly AttrSubjects (even though the syntax may not 61// allow attributes on a given Decl or Stmt). 62class AttrSubject; 63 64include "clang/Basic/DeclNodes.td" 65include "clang/Basic/StmtNodes.td" 66 67// A subset-subject is an AttrSubject constrained to operate only on some subset 68// of that subject. 69// 70// The code fragment is a boolean expression that will confirm that the subject 71// meets the requirements; the subject will have the name S, and will have the 72// type specified by the base. It should be a simple boolean expression. 73class SubsetSubject<AttrSubject base, code check> : AttrSubject { 74 AttrSubject Base = base; 75 code CheckCode = check; 76} 77 78// This is the type of a variable which C++11 allows alignas(...) to appertain 79// to. 80def NormalVar : SubsetSubject<Var, 81 [{S->getStorageClass() != VarDecl::Register && 82 S->getKind() != Decl::ImplicitParam && 83 S->getKind() != Decl::ParmVar && 84 S->getKind() != Decl::NonTypeTemplateParm}]>; 85def NonParmVar : SubsetSubject<Var, 86 [{S->getKind() != Decl::ParmVar}]>; 87def NonBitField : SubsetSubject<Field, 88 [{!S->isBitField()}]>; 89 90def ObjCInstanceMethod : SubsetSubject<ObjCMethod, 91 [{S->isInstanceMethod()}]>; 92 93def ObjCInterfaceDeclInitMethod : SubsetSubject<ObjCMethod, 94 [{S->getMethodFamily() == OMF_init && 95 (isa<ObjCInterfaceDecl>(S->getDeclContext()) || 96 (isa<ObjCCategoryDecl>(S->getDeclContext()) && 97 cast<ObjCCategoryDecl>(S->getDeclContext())->IsClassExtension()))}]>; 98 99def Struct : SubsetSubject<Record, 100 [{!S->isUnion()}]>; 101 102def TLSVar : SubsetSubject<Var, 103 [{S->getTLSKind() != 0}]>; 104 105def SharedVar : SubsetSubject<Var, 106 [{S->hasGlobalStorage() && !S->getTLSKind()}]>; 107 108def GlobalVar : SubsetSubject<Var, 109 [{S->hasGlobalStorage()}]>; 110 111// FIXME: this hack is needed because DeclNodes.td defines the base Decl node 112// type to be a class, not a definition. This makes it impossible to create an 113// attribute subject which accepts a Decl. Normally, this is not a problem, 114// because the attribute can have no Subjects clause to accomplish this. But in 115// the case of a SubsetSubject, there's no way to express it without this hack. 116def DeclBase : AttrSubject; 117def FunctionLike : SubsetSubject<DeclBase, 118 [{S->getFunctionType(false) != nullptr}]>; 119 120def OpenCLKernelFunction : SubsetSubject<Function, [{ 121 S->hasAttr<OpenCLKernelAttr>() 122}]>; 123 124// HasFunctionProto is a more strict version of FunctionLike, so it should 125// never be specified in a Subjects list along with FunctionLike (due to the 126// inclusive nature of subject testing). 127def HasFunctionProto : SubsetSubject<DeclBase, 128 [{(S->getFunctionType(true) != nullptr && 129 isa<FunctionProtoType>(S->getFunctionType())) || 130 isa<ObjCMethodDecl>(S) || 131 isa<BlockDecl>(S)}]>; 132 133// A single argument to an attribute 134class Argument<string name, bit optional, bit fake = 0> { 135 string Name = name; 136 bit Optional = optional; 137 138 /// A fake argument is used to store and serialize additional information 139 /// in an attribute without actually changing its parsing or pretty-printing. 140 bit Fake = fake; 141} 142 143class BoolArgument<string name, bit opt = 0> : Argument<name, opt>; 144class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>; 145class IntArgument<string name, bit opt = 0> : Argument<name, opt>; 146class StringArgument<string name, bit opt = 0> : Argument<name, opt>; 147class ExprArgument<string name, bit opt = 0> : Argument<name, opt>; 148class FunctionArgument<string name, bit opt = 0> : Argument<name, opt>; 149class TypeArgument<string name, bit opt = 0> : Argument<name, opt>; 150class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>; 151class VariadicUnsignedArgument<string name> : Argument<name, 1>; 152class VariadicExprArgument<string name> : Argument<name, 1>; 153class VariadicStringArgument<string name> : Argument<name, 1>; 154 155// A version of the form major.minor[.subminor]. 156class VersionArgument<string name, bit opt = 0> : Argument<name, opt>; 157 158// This one's a doozy, so it gets its own special type 159// It can be an unsigned integer, or a type. Either can 160// be dependent. 161class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>; 162 163// A bool argument with a default value 164class DefaultBoolArgument<string name, bit default> : BoolArgument<name, 1> { 165 bit Default = default; 166} 167 168// An integer argument with a default value 169class DefaultIntArgument<string name, int default> : IntArgument<name, 1> { 170 int Default = default; 171} 172 173// This argument is more complex, it includes the enumerator type name, 174// a list of strings to accept, and a list of enumerators to map them to. 175class EnumArgument<string name, string type, list<string> values, 176 list<string> enums, bit opt = 0, bit fake = 0> 177 : Argument<name, opt, fake> { 178 string Type = type; 179 list<string> Values = values; 180 list<string> Enums = enums; 181} 182 183// FIXME: There should be a VariadicArgument type that takes any other type 184// of argument and generates the appropriate type. 185class VariadicEnumArgument<string name, string type, list<string> values, 186 list<string> enums> : Argument<name, 1> { 187 string Type = type; 188 list<string> Values = values; 189 list<string> Enums = enums; 190} 191 192// This handles one spelling of an attribute. 193class Spelling<string name, string variety> { 194 string Name = name; 195 string Variety = variety; 196 bit KnownToGCC; 197} 198 199class GNU<string name> : Spelling<name, "GNU">; 200class Declspec<string name> : Spelling<name, "Declspec">; 201class CXX11<string namespace, string name, int version = 1> 202 : Spelling<name, "CXX11"> { 203 string Namespace = namespace; 204 int Version = version; 205} 206class Keyword<string name> : Spelling<name, "Keyword">; 207class Pragma<string namespace, string name> : Spelling<name, "Pragma"> { 208 string Namespace = namespace; 209} 210 211// The GCC spelling implies GNU<name, "GNU"> and CXX11<"gnu", name> and also 212// sets KnownToGCC to 1. This spelling should be used for any GCC-compatible 213// attributes. 214class GCC<string name> : Spelling<name, "GCC"> { 215 let KnownToGCC = 1; 216} 217 218class Accessor<string name, list<Spelling> spellings> { 219 string Name = name; 220 list<Spelling> Spellings = spellings; 221} 222 223class SubjectDiag<bit warn> { 224 bit Warn = warn; 225} 226def WarnDiag : SubjectDiag<1>; 227def ErrorDiag : SubjectDiag<0>; 228 229class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag, 230 string customDiag = ""> { 231 list<AttrSubject> Subjects = subjects; 232 SubjectDiag Diag = diag; 233 string CustomDiag = customDiag; 234} 235 236class LangOpt<string name, bit negated = 0> { 237 string Name = name; 238 bit Negated = negated; 239} 240def MicrosoftExt : LangOpt<"MicrosoftExt">; 241def Borland : LangOpt<"Borland">; 242def CUDA : LangOpt<"CUDA">; 243def COnly : LangOpt<"CPlusPlus", 1>; 244def OpenCL : LangOpt<"OpenCL">; 245def RenderScript : LangOpt<"RenderScript">; 246 247// Defines targets for target-specific attributes. The list of strings should 248// specify architectures for which the target applies, based off the ArchType 249// enumeration in Triple.h. 250class TargetArch<list<string> arches> { 251 list<string> Arches = arches; 252 list<string> OSes; 253 list<string> CXXABIs; 254} 255def TargetARM : TargetArch<["arm", "thumb"]>; 256def TargetMips : TargetArch<["mips", "mipsel"]>; 257def TargetMSP430 : TargetArch<["msp430"]>; 258def TargetX86 : TargetArch<["x86"]>; 259def TargetAnyX86 : TargetArch<["x86", "x86_64"]>; 260def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> { 261 let OSes = ["Win32"]; 262} 263def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb"]> { 264 let CXXABIs = ["Microsoft"]; 265} 266 267class Attr { 268 // The various ways in which an attribute can be spelled in source 269 list<Spelling> Spellings; 270 // The things to which an attribute can appertain 271 SubjectList Subjects; 272 // The arguments allowed on an attribute 273 list<Argument> Args = []; 274 // Accessors which should be generated for the attribute. 275 list<Accessor> Accessors = []; 276 // Set to true for attributes with arguments which require delayed parsing. 277 bit LateParsed = 0; 278 // Set to false to prevent an attribute from being propagated from a template 279 // to the instantiation. 280 bit Clone = 1; 281 // Set to true for attributes which must be instantiated within templates 282 bit TemplateDependent = 0; 283 // Set to true for attributes that have a corresponding AST node. 284 bit ASTNode = 1; 285 // Set to true for attributes which have handler in Sema. 286 bit SemaHandler = 1; 287 // Set to true for attributes that are completely ignored. 288 bit Ignored = 0; 289 // Set to true if the attribute's parsing does not match its semantic 290 // content. Eg) It parses 3 args, but semantically takes 4 args. Opts out of 291 // common attribute error checking. 292 bit HasCustomParsing = 0; 293 // Set to true if all of the attribute's arguments should be parsed in an 294 // unevaluated context. 295 bit ParseArgumentsAsUnevaluated = 0; 296 // Set to true if this attribute can be duplicated on a subject when merging 297 // attributes. By default, attributes are not merged. 298 bit DuplicatesAllowedWhileMerging = 0; 299 // Lists language options, one of which is required to be true for the 300 // attribute to be applicable. If empty, no language options are required. 301 list<LangOpt> LangOpts = []; 302 // Any additional text that should be included verbatim in the class. 303 // Note: Any additional data members will leak and should be constructed 304 // externally on the ASTContext. 305 code AdditionalMembers = [{}]; 306 // Any documentation that should be associated with the attribute. Since an 307 // attribute may be documented under multiple categories, more than one 308 // Documentation entry may be listed. 309 list<Documentation> Documentation; 310} 311 312/// A type attribute is not processed on a declaration or a statement. 313class TypeAttr : Attr { 314 // By default, type attributes do not get an AST node. 315 let ASTNode = 0; 316} 317 318/// A stmt attribute is not processed on a declaration or a type. 319class StmtAttr : Attr; 320 321/// An inheritable attribute is inherited by later redeclarations. 322class InheritableAttr : Attr; 323 324/// A target-specific attribute. This class is meant to be used as a mixin 325/// with InheritableAttr or Attr depending on the attribute's needs. 326class TargetSpecificAttr<TargetArch target> { 327 TargetArch Target = target; 328 // Attributes are generally required to have unique spellings for their names 329 // so that the parser can determine what kind of attribute it has parsed. 330 // However, target-specific attributes are special in that the attribute only 331 // "exists" for a given target. So two target-specific attributes can share 332 // the same name when they exist in different targets. To support this, a 333 // Kind can be explicitly specified for a target-specific attribute. This 334 // corresponds to the AttributeList::AT_* enum that is generated and it 335 // should contain a shared value between the attributes. 336 // 337 // Target-specific attributes which use this feature should ensure that the 338 // spellings match exactly betweeen the attributes, and if the arguments or 339 // subjects differ, should specify HasCustomParsing = 1 and implement their 340 // own parsing and semantic handling requirements as-needed. 341 string ParseKind; 342} 343 344/// An inheritable parameter attribute is inherited by later 345/// redeclarations, even when it's written on a parameter. 346class InheritableParamAttr : InheritableAttr; 347 348/// An attribute which changes the ABI rules for a specific parameter. 349class ParameterABIAttr : InheritableParamAttr { 350 let Subjects = SubjectList<[ParmVar]>; 351} 352 353/// An ignored attribute, which we parse but discard with no checking. 354class IgnoredAttr : Attr { 355 let Ignored = 1; 356 let ASTNode = 0; 357 let SemaHandler = 0; 358 let Documentation = [Undocumented]; 359} 360 361// 362// Attributes begin here 363// 364 365def AbiTag : Attr { 366 let Spellings = [GCC<"abi_tag">]; 367 let Args = [VariadicStringArgument<"Tags">]; 368 let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag, 369 "ExpectedStructClassVariableFunctionOrInlineNamespace">; 370 let Documentation = [AbiTagsDocs]; 371} 372 373def AddressSpace : TypeAttr { 374 let Spellings = [GNU<"address_space">]; 375 let Args = [IntArgument<"AddressSpace">]; 376 let Documentation = [Undocumented]; 377} 378 379def Alias : Attr { 380 let Spellings = [GCC<"alias">]; 381 let Args = [StringArgument<"Aliasee">]; 382 let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag, 383 "ExpectedFunctionGlobalVarMethodOrProperty">; 384 let Documentation = [Undocumented]; 385} 386 387def Aligned : InheritableAttr { 388 let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">, 389 Keyword<"_Alignas">]; 390// let Subjects = SubjectList<[NonBitField, NormalVar, Tag]>; 391 let Args = [AlignedArgument<"Alignment", 1>]; 392 let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>, 393 Accessor<"isC11", [Keyword<"_Alignas">]>, 394 Accessor<"isAlignas", [Keyword<"alignas">, 395 Keyword<"_Alignas">]>, 396 Accessor<"isDeclspec",[Declspec<"align">]>]; 397 let Documentation = [Undocumented]; 398} 399 400def AlignValue : Attr { 401 let Spellings = [ 402 // Unfortunately, this is semantically an assertion, not a directive 403 // (something else must ensure the alignment), so aligned_value is a 404 // probably a better name. We might want to add an aligned_value spelling in 405 // the future (and a corresponding C++ attribute), but this can be done 406 // later once we decide if we also want them to have slightly-different 407 // semantics than Intel's align_value. 408 GNU<"align_value"> 409 // Intel's compiler on Windows also supports: 410 // , Declspec<"align_value"> 411 ]; 412 let Args = [ExprArgument<"Alignment">]; 413 let Subjects = SubjectList<[Var, TypedefName], WarnDiag, 414 "ExpectedVariableOrTypedef">; 415 let Documentation = [AlignValueDocs]; 416} 417 418def AlignMac68k : InheritableAttr { 419 // This attribute has no spellings as it is only ever created implicitly. 420 let Spellings = []; 421 let SemaHandler = 0; 422 let Documentation = [Undocumented]; 423} 424 425def AlwaysInline : InheritableAttr { 426 let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">]; 427 let Subjects = SubjectList<[Function]>; 428 let Documentation = [Undocumented]; 429} 430 431def XRayInstrument : InheritableAttr { 432 let Spellings = [GNU<"xray_always_instrument">, 433 CXX11<"clang", "xray_always_instrument">, 434 GNU<"xray_never_instrument">, 435 CXX11<"clang", "xray_never_instrument">]; 436 let Subjects = SubjectList<[CXXMethod, ObjCMethod, Function], WarnDiag, 437 "ExpectedFunctionOrMethod">; 438 let Accessors = [Accessor<"alwaysXRayInstrument", 439 [GNU<"xray_always_instrument">, 440 CXX11<"clang", "xray_always_instrument">]>, 441 Accessor<"neverXRayInstrument", 442 [GNU<"xray_never_instrument">, 443 CXX11<"clang", "xray_never_instrument">]>]; 444 let Documentation = [XRayDocs]; 445} 446 447def TLSModel : InheritableAttr { 448 let Spellings = [GCC<"tls_model">]; 449 let Subjects = SubjectList<[TLSVar], ErrorDiag, "ExpectedTLSVar">; 450 let Args = [StringArgument<"Model">]; 451 let Documentation = [TLSModelDocs]; 452} 453 454def AnalyzerNoReturn : InheritableAttr { 455 let Spellings = [GNU<"analyzer_noreturn">]; 456 let Documentation = [Undocumented]; 457} 458 459def Annotate : InheritableParamAttr { 460 let Spellings = [GNU<"annotate">]; 461 let Args = [StringArgument<"Annotation">]; 462 let Documentation = [Undocumented]; 463} 464 465def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> { 466 // NOTE: If you add any additional spellings, MSP430Interrupt's, 467 // MipsInterrupt's and AnyX86Interrupt's spellings must match. 468 let Spellings = [GNU<"interrupt">]; 469 let Args = [EnumArgument<"Interrupt", "InterruptType", 470 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""], 471 ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"], 472 1>]; 473 let ParseKind = "Interrupt"; 474 let HasCustomParsing = 1; 475 let Documentation = [ARMInterruptDocs]; 476} 477 478def AsmLabel : InheritableAttr { 479 let Spellings = [Keyword<"asm">, Keyword<"__asm__">]; 480 let Args = [StringArgument<"Label">]; 481 let SemaHandler = 0; 482 let Documentation = [Undocumented]; 483} 484 485def Availability : InheritableAttr { 486 let Spellings = [GNU<"availability">]; 487 let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">, 488 VersionArgument<"deprecated">, VersionArgument<"obsoleted">, 489 BoolArgument<"unavailable">, StringArgument<"message">, 490 BoolArgument<"strict">, StringArgument<"replacement">]; 491 let AdditionalMembers = 492[{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) { 493 return llvm::StringSwitch<llvm::StringRef>(Platform) 494 .Case("android", "Android") 495 .Case("ios", "iOS") 496 .Case("macos", "macOS") 497 .Case("tvos", "tvOS") 498 .Case("watchos", "watchOS") 499 .Case("ios_app_extension", "iOS (App Extension)") 500 .Case("macos_app_extension", "macOS (App Extension)") 501 .Case("tvos_app_extension", "tvOS (App Extension)") 502 .Case("watchos_app_extension", "watchOS (App Extension)") 503 .Default(llvm::StringRef()); 504} }]; 505 let HasCustomParsing = 1; 506 let DuplicatesAllowedWhileMerging = 1; 507// let Subjects = SubjectList<[Named]>; 508 let Documentation = [AvailabilityDocs]; 509} 510 511def Blocks : InheritableAttr { 512 let Spellings = [GNU<"blocks">]; 513 let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>]; 514 let Documentation = [Undocumented]; 515} 516 517def Bounded : IgnoredAttr { 518 let Spellings = [GNU<"bounded">]; 519} 520 521def CarriesDependency : InheritableParamAttr { 522 let Spellings = [GNU<"carries_dependency">, 523 CXX11<"","carries_dependency", 200809>]; 524 let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>; 525 let Documentation = [CarriesDependencyDocs]; 526} 527 528def CDecl : InheritableAttr { 529 let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">]; 530// let Subjects = [Function, ObjCMethod]; 531 let Documentation = [Undocumented]; 532} 533 534// cf_audited_transfer indicates that the given function has been 535// audited and has been marked with the appropriate cf_consumed and 536// cf_returns_retained attributes. It is generally applied by 537// '#pragma clang arc_cf_code_audited' rather than explicitly. 538def CFAuditedTransfer : InheritableAttr { 539 let Spellings = [GNU<"cf_audited_transfer">]; 540 let Subjects = SubjectList<[Function], ErrorDiag>; 541 let Documentation = [Undocumented]; 542} 543 544// cf_unknown_transfer is an explicit opt-out of cf_audited_transfer. 545// It indicates that the function has unknown or unautomatable 546// transfer semantics. 547def CFUnknownTransfer : InheritableAttr { 548 let Spellings = [GNU<"cf_unknown_transfer">]; 549 let Subjects = SubjectList<[Function], ErrorDiag>; 550 let Documentation = [Undocumented]; 551} 552 553def CFReturnsRetained : InheritableAttr { 554 let Spellings = [GNU<"cf_returns_retained">]; 555// let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>; 556 let Documentation = [Undocumented]; 557} 558 559def CFReturnsNotRetained : InheritableAttr { 560 let Spellings = [GNU<"cf_returns_not_retained">]; 561// let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>; 562 let Documentation = [Undocumented]; 563} 564 565def CFConsumed : InheritableParamAttr { 566 let Spellings = [GNU<"cf_consumed">]; 567 let Subjects = SubjectList<[ParmVar]>; 568 let Documentation = [Undocumented]; 569} 570 571def Cleanup : InheritableAttr { 572 let Spellings = [GCC<"cleanup">]; 573 let Args = [FunctionArgument<"FunctionDecl">]; 574 let Subjects = SubjectList<[Var]>; 575 let Documentation = [Undocumented]; 576} 577 578def Cold : InheritableAttr { 579 let Spellings = [GCC<"cold">]; 580 let Subjects = SubjectList<[Function]>; 581 let Documentation = [Undocumented]; 582} 583 584def Common : InheritableAttr { 585 let Spellings = [GCC<"common">]; 586 let Subjects = SubjectList<[Var]>; 587 let Documentation = [Undocumented]; 588} 589 590def Const : InheritableAttr { 591 let Spellings = [GCC<"const">, GCC<"__const">]; 592 let Documentation = [Undocumented]; 593} 594 595def Constructor : InheritableAttr { 596 let Spellings = [GCC<"constructor">]; 597 let Args = [DefaultIntArgument<"Priority", 65535>]; 598 let Subjects = SubjectList<[Function]>; 599 let Documentation = [Undocumented]; 600} 601 602def CUDAConstant : InheritableAttr { 603 let Spellings = [GNU<"constant">]; 604 let Subjects = SubjectList<[Var]>; 605 let LangOpts = [CUDA]; 606 let Documentation = [Undocumented]; 607} 608 609def CUDACudartBuiltin : IgnoredAttr { 610 let Spellings = [GNU<"cudart_builtin">]; 611 let LangOpts = [CUDA]; 612} 613 614def CUDADevice : InheritableAttr { 615 let Spellings = [GNU<"device">]; 616 let Subjects = SubjectList<[Function, Var]>; 617 let LangOpts = [CUDA]; 618 let Documentation = [Undocumented]; 619} 620 621def CUDADeviceBuiltin : IgnoredAttr { 622 let Spellings = [GNU<"device_builtin">]; 623 let LangOpts = [CUDA]; 624} 625 626def CUDADeviceBuiltinSurfaceType : IgnoredAttr { 627 let Spellings = [GNU<"device_builtin_surface_type">]; 628 let LangOpts = [CUDA]; 629} 630 631def CUDADeviceBuiltinTextureType : IgnoredAttr { 632 let Spellings = [GNU<"device_builtin_texture_type">]; 633 let LangOpts = [CUDA]; 634} 635 636def CUDAGlobal : InheritableAttr { 637 let Spellings = [GNU<"global">]; 638 let Subjects = SubjectList<[Function]>; 639 let LangOpts = [CUDA]; 640 let Documentation = [Undocumented]; 641} 642 643def CUDAHost : InheritableAttr { 644 let Spellings = [GNU<"host">]; 645 let Subjects = SubjectList<[Function]>; 646 let LangOpts = [CUDA]; 647 let Documentation = [Undocumented]; 648} 649 650def CUDAInvalidTarget : InheritableAttr { 651 let Spellings = []; 652 let Subjects = SubjectList<[Function]>; 653 let LangOpts = [CUDA]; 654 let Documentation = [Undocumented]; 655} 656 657def CUDALaunchBounds : InheritableAttr { 658 let Spellings = [GNU<"launch_bounds">]; 659 let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>]; 660 let LangOpts = [CUDA]; 661 let Subjects = SubjectList<[ObjCMethod, FunctionLike], WarnDiag, 662 "ExpectedFunctionOrMethod">; 663 // An AST node is created for this attribute, but is not used by other parts 664 // of the compiler. However, this node needs to exist in the AST because 665 // non-LLVM backends may be relying on the attribute's presence. 666 let Documentation = [Undocumented]; 667} 668 669def CUDAShared : InheritableAttr { 670 let Spellings = [GNU<"shared">]; 671 let Subjects = SubjectList<[Var]>; 672 let LangOpts = [CUDA]; 673 let Documentation = [Undocumented]; 674} 675 676def C11NoReturn : InheritableAttr { 677 let Spellings = [Keyword<"_Noreturn">]; 678 let Subjects = SubjectList<[Function], ErrorDiag>; 679 let SemaHandler = 0; 680 let Documentation = [C11NoReturnDocs]; 681} 682 683def CXX11NoReturn : InheritableAttr { 684 let Spellings = [CXX11<"","noreturn", 200809>]; 685 let Subjects = SubjectList<[Function], ErrorDiag>; 686 let Documentation = [CXX11NoReturnDocs]; 687} 688 689def OpenCLKernel : InheritableAttr { 690 let Spellings = [Keyword<"__kernel">, Keyword<"kernel">]; 691 let Subjects = SubjectList<[Function], ErrorDiag>; 692 let Documentation = [Undocumented]; 693} 694 695def OpenCLUnrollHint : InheritableAttr { 696 let Spellings = [GNU<"opencl_unroll_hint">]; 697 let Args = [UnsignedArgument<"UnrollHint">]; 698 let Documentation = [OpenCLUnrollHintDocs]; 699} 700 701// This attribute is both a type attribute, and a declaration attribute (for 702// parameter variables). 703def OpenCLAccess : Attr { 704 let Spellings = [Keyword<"__read_only">, Keyword<"read_only">, 705 Keyword<"__write_only">, Keyword<"write_only">, 706 Keyword<"__read_write">, Keyword<"read_write">]; 707 let Subjects = SubjectList<[ParmVar, TypedefName], ErrorDiag, 708 "ExpectedParameterOrTypedef">; 709 let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">, 710 Keyword<"read_only">]>, 711 Accessor<"isReadWrite", [Keyword<"__read_write">, 712 Keyword<"read_write">]>, 713 Accessor<"isWriteOnly", [Keyword<"__write_only">, 714 Keyword<"write_only">]>]; 715 let Documentation = [OpenCLAccessDocs]; 716} 717 718def OpenCLPrivateAddressSpace : TypeAttr { 719 let Spellings = [Keyword<"__private">, Keyword<"private">]; 720 let Documentation = [OpenCLAddressSpacePrivateDocs]; 721} 722 723def OpenCLGlobalAddressSpace : TypeAttr { 724 let Spellings = [Keyword<"__global">, Keyword<"global">]; 725 let Documentation = [OpenCLAddressSpaceGlobalDocs]; 726} 727 728def OpenCLLocalAddressSpace : TypeAttr { 729 let Spellings = [Keyword<"__local">, Keyword<"local">]; 730 let Documentation = [OpenCLAddressSpaceLocalDocs]; 731} 732 733def OpenCLConstantAddressSpace : TypeAttr { 734 let Spellings = [Keyword<"__constant">, Keyword<"constant">]; 735 let Documentation = [OpenCLAddressSpaceConstantDocs]; 736} 737 738def OpenCLGenericAddressSpace : TypeAttr { 739 let Spellings = [Keyword<"__generic">, Keyword<"generic">]; 740 let Documentation = [OpenCLAddressSpaceGenericDocs]; 741} 742 743def OpenCLNoSVM : Attr { 744 let Spellings = [GNU<"nosvm">]; 745 let Subjects = SubjectList<[Var]>; 746 let Documentation = [OpenCLNoSVMDocs]; 747 let LangOpts = [OpenCL]; 748 let ASTNode = 0; 749} 750 751def RenderScriptKernel : Attr { 752 let Spellings = [GNU<"kernel">]; 753 let Subjects = SubjectList<[Function]>; 754 let Documentation = [RenderScriptKernelAttributeDocs]; 755 let LangOpts = [RenderScript]; 756} 757 758def Deprecated : InheritableAttr { 759 let Spellings = [GCC<"deprecated">, Declspec<"deprecated">, 760 CXX11<"","deprecated", 201309>]; 761 let Args = [StringArgument<"Message", 1>, 762 // An optional string argument that enables us to provide a 763 // Fix-It. 764 StringArgument<"Replacement", 1>]; 765 let Documentation = [DeprecatedDocs]; 766} 767 768def Destructor : InheritableAttr { 769 let Spellings = [GCC<"destructor">]; 770 let Args = [DefaultIntArgument<"Priority", 65535>]; 771 let Subjects = SubjectList<[Function]>; 772 let Documentation = [Undocumented]; 773} 774 775def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> { 776 let Spellings = [Declspec<"empty_bases">]; 777 let Subjects = SubjectList<[CXXRecord]>; 778 let Documentation = [EmptyBasesDocs]; 779} 780 781def EnableIf : InheritableAttr { 782 let Spellings = [GNU<"enable_if">]; 783 let Subjects = SubjectList<[Function]>; 784 let Args = [ExprArgument<"Cond">, StringArgument<"Message">]; 785 let TemplateDependent = 1; 786 let Documentation = [EnableIfDocs]; 787} 788 789def ExtVectorType : Attr { 790 let Spellings = [GNU<"ext_vector_type">]; 791 let Subjects = SubjectList<[TypedefName], ErrorDiag>; 792 let Args = [ExprArgument<"NumElements">]; 793 let ASTNode = 0; 794 let Documentation = [Undocumented]; 795} 796 797def FallThrough : StmtAttr { 798 let Spellings = [CXX11<"", "fallthrough", 201603>, 799 CXX11<"clang", "fallthrough">]; 800// let Subjects = [NullStmt]; 801 let Documentation = [FallthroughDocs]; 802} 803 804def FastCall : InheritableAttr { 805 let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">, 806 Keyword<"_fastcall">]; 807// let Subjects = [Function, ObjCMethod]; 808 let Documentation = [FastCallDocs]; 809} 810 811def Final : InheritableAttr { 812 let Spellings = [Keyword<"final">, Keyword<"sealed">]; 813 let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>]; 814 let SemaHandler = 0; 815 let Documentation = [Undocumented]; 816} 817 818def MinSize : InheritableAttr { 819 let Spellings = [GNU<"minsize">]; 820 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>; 821 let Documentation = [Undocumented]; 822} 823 824def FlagEnum : InheritableAttr { 825 let Spellings = [GNU<"flag_enum">]; 826 let Subjects = SubjectList<[Enum]>; 827 let Documentation = [FlagEnumDocs]; 828 let LangOpts = [COnly]; 829} 830 831def Flatten : InheritableAttr { 832 let Spellings = [GCC<"flatten">]; 833 let Subjects = SubjectList<[Function], ErrorDiag>; 834 let Documentation = [FlattenDocs]; 835} 836 837def Format : InheritableAttr { 838 let Spellings = [GCC<"format">]; 839 let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">, 840 IntArgument<"FirstArg">]; 841 let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto], WarnDiag, 842 "ExpectedFunctionWithProtoType">; 843 let Documentation = [FormatDocs]; 844} 845 846def FormatArg : InheritableAttr { 847 let Spellings = [GCC<"format_arg">]; 848 let Args = [IntArgument<"FormatIdx">]; 849 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto], WarnDiag, 850 "ExpectedFunctionWithProtoType">; 851 let Documentation = [Undocumented]; 852} 853 854def GNUInline : InheritableAttr { 855 let Spellings = [GCC<"gnu_inline">]; 856 let Subjects = SubjectList<[Function]>; 857 let Documentation = [Undocumented]; 858} 859 860def Hot : InheritableAttr { 861 let Spellings = [GCC<"hot">]; 862 let Subjects = SubjectList<[Function]>; 863 // An AST node is created for this attribute, but not actually used beyond 864 // semantic checking for mutual exclusion with the Cold attribute. 865 let Documentation = [Undocumented]; 866} 867 868def IBAction : InheritableAttr { 869 let Spellings = [GNU<"ibaction">]; 870 let Subjects = SubjectList<[ObjCInstanceMethod], WarnDiag, 871 "ExpectedObjCInstanceMethod">; 872 // An AST node is created for this attribute, but is not used by other parts 873 // of the compiler. However, this node needs to exist in the AST because 874 // external tools rely on it. 875 let Documentation = [Undocumented]; 876} 877 878def IBOutlet : InheritableAttr { 879 let Spellings = [GNU<"iboutlet">]; 880// let Subjects = [ObjCIvar, ObjCProperty]; 881 let Documentation = [Undocumented]; 882} 883 884def IBOutletCollection : InheritableAttr { 885 let Spellings = [GNU<"iboutletcollection">]; 886 let Args = [TypeArgument<"Interface", 1>]; 887// let Subjects = [ObjCIvar, ObjCProperty]; 888 let Documentation = [Undocumented]; 889} 890 891def IFunc : Attr { 892 let Spellings = [GCC<"ifunc">]; 893 let Args = [StringArgument<"Resolver">]; 894 let Subjects = SubjectList<[Function]>; 895 let Documentation = [IFuncDocs]; 896} 897 898def Restrict : InheritableAttr { 899 let Spellings = [Declspec<"restrict">, GCC<"malloc">]; 900 let Subjects = SubjectList<[Function]>; 901 let Documentation = [Undocumented]; 902} 903 904def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> { 905 let Spellings = [Declspec<"layout_version">]; 906 let Args = [UnsignedArgument<"Version">]; 907 let Subjects = SubjectList<[CXXRecord]>; 908 let Documentation = [LayoutVersionDocs]; 909} 910 911def MaxFieldAlignment : InheritableAttr { 912 // This attribute has no spellings as it is only ever created implicitly. 913 let Spellings = []; 914 let Args = [UnsignedArgument<"Alignment">]; 915 let SemaHandler = 0; 916 let Documentation = [Undocumented]; 917} 918 919def MayAlias : InheritableAttr { 920 // FIXME: this is a type attribute in GCC, but a declaration attribute here. 921 let Spellings = [GCC<"may_alias">]; 922 let Documentation = [Undocumented]; 923} 924 925def MSABI : InheritableAttr { 926 let Spellings = [GCC<"ms_abi">]; 927// let Subjects = [Function, ObjCMethod]; 928 let Documentation = [MSABIDocs]; 929} 930 931def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> { 932 // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's 933 // and AnyX86Interrupt's spellings must match. 934 let Spellings = [GNU<"interrupt">]; 935 let Args = [UnsignedArgument<"Number">]; 936 let ParseKind = "Interrupt"; 937 let HasCustomParsing = 1; 938 let Documentation = [Undocumented]; 939} 940 941def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips> { 942 let Spellings = [GCC<"mips16">]; 943 let Subjects = SubjectList<[Function], ErrorDiag>; 944 let Documentation = [Undocumented]; 945} 946 947def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips> { 948 // NOTE: If you add any additional spellings, ARMInterrupt's, 949 // MSP430Interrupt's and AnyX86Interrupt's spellings must match. 950 let Spellings = [GNU<"interrupt">]; 951 let Subjects = SubjectList<[Function]>; 952 let Args = [EnumArgument<"Interrupt", "InterruptType", 953 ["vector=sw0", "vector=sw1", "vector=hw0", 954 "vector=hw1", "vector=hw2", "vector=hw3", 955 "vector=hw4", "vector=hw5", "eic", ""], 956 ["sw0", "sw1", "hw0", "hw1", "hw2", "hw3", 957 "hw4", "hw5", "eic", "eic"] 958 >]; 959 let ParseKind = "Interrupt"; 960 let Documentation = [MipsInterruptDocs]; 961} 962 963def Mode : Attr { 964 let Spellings = [GCC<"mode">]; 965 let Subjects = SubjectList<[Var, Enum, TypedefName, Field], ErrorDiag, 966 "ExpectedVariableEnumFieldOrTypedef">; 967 let Args = [IdentifierArgument<"Mode">]; 968 let Documentation = [Undocumented]; 969} 970 971def Naked : InheritableAttr { 972 let Spellings = [GCC<"naked">, Declspec<"naked">]; 973 let Subjects = SubjectList<[Function]>; 974 let Documentation = [Undocumented]; 975} 976 977def NeonPolyVectorType : TypeAttr { 978 let Spellings = [GNU<"neon_polyvector_type">]; 979 let Args = [IntArgument<"NumElements">]; 980 let Documentation = [Undocumented]; 981} 982 983def NeonVectorType : TypeAttr { 984 let Spellings = [GNU<"neon_vector_type">]; 985 let Args = [IntArgument<"NumElements">]; 986 let Documentation = [Undocumented]; 987} 988 989def ReturnsTwice : InheritableAttr { 990 let Spellings = [GCC<"returns_twice">]; 991 let Subjects = SubjectList<[Function]>; 992 let Documentation = [Undocumented]; 993} 994 995def DisableTailCalls : InheritableAttr { 996 let Spellings = [GNU<"disable_tail_calls">, 997 CXX11<"clang", "disable_tail_calls">]; 998 let Subjects = SubjectList<[Function, ObjCMethod]>; 999 let Documentation = [DisableTailCallsDocs]; 1000} 1001 1002def NoAlias : InheritableAttr { 1003 let Spellings = [Declspec<"noalias">]; 1004 let Subjects = SubjectList<[Function]>; 1005 let Documentation = [NoAliasDocs]; 1006} 1007 1008def NoCommon : InheritableAttr { 1009 let Spellings = [GCC<"nocommon">]; 1010 let Subjects = SubjectList<[Var]>; 1011 let Documentation = [Undocumented]; 1012} 1013 1014def NoDebug : InheritableAttr { 1015 let Spellings = [GCC<"nodebug">]; 1016 let Subjects = SubjectList<[FunctionLike, ObjCMethod, NonParmVar], WarnDiag, 1017 "ExpectedVariableOrFunction">; 1018 let Documentation = [NoDebugDocs]; 1019} 1020 1021def NoDuplicate : InheritableAttr { 1022 let Spellings = [GNU<"noduplicate">, CXX11<"clang", "noduplicate">]; 1023 let Subjects = SubjectList<[Function]>; 1024 let Documentation = [NoDuplicateDocs]; 1025} 1026 1027def NoInline : InheritableAttr { 1028 let Spellings = [GCC<"noinline">, Declspec<"noinline">]; 1029 let Subjects = SubjectList<[Function]>; 1030 let Documentation = [Undocumented]; 1031} 1032 1033def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips> { 1034 let Spellings = [GCC<"nomips16">]; 1035 let Subjects = SubjectList<[Function], ErrorDiag>; 1036 let Documentation = [Undocumented]; 1037} 1038 1039// This is not a TargetSpecificAttr so that is silently accepted and 1040// ignored on other targets as encouraged by the OpenCL spec. 1041// 1042// See OpenCL 1.2 6.11.5: "It is our intention that a particular 1043// implementation of OpenCL be free to ignore all attributes and the 1044// resulting executable binary will produce the same result." 1045// 1046// However, only AMD GPU targets will emit the corresponding IR 1047// attribute. 1048// 1049// FIXME: This provides a sub-optimal error message if you attempt to 1050// use this in CUDA, since CUDA does not use the same terminology. 1051def AMDGPUNumVGPR : InheritableAttr { 1052 let Spellings = [GNU<"amdgpu_num_vgpr">]; 1053 let Args = [UnsignedArgument<"NumVGPR">]; 1054 let Documentation = [AMDGPUNumVGPRDocs]; 1055 1056// FIXME: This should be for OpenCLKernelFunction, but is not to 1057// workaround needing to see kernel attribute before others to know if 1058// this should be rejected on non-kernels. 1059 let Subjects = SubjectList<[Function], ErrorDiag, 1060 "ExpectedKernelFunction">; 1061} 1062 1063def AMDGPUNumSGPR : InheritableAttr { 1064 let Spellings = [GNU<"amdgpu_num_sgpr">]; 1065 let Args = [UnsignedArgument<"NumSGPR">]; 1066 let Documentation = [AMDGPUNumSGPRDocs]; 1067 let Subjects = SubjectList<[Function], ErrorDiag, 1068 "ExpectedKernelFunction">; 1069} 1070 1071def NoSplitStack : InheritableAttr { 1072 let Spellings = [GCC<"no_split_stack">]; 1073 let Subjects = SubjectList<[Function], ErrorDiag>; 1074 let Documentation = [NoSplitStackDocs]; 1075} 1076 1077def NonNull : InheritableAttr { 1078 let Spellings = [GCC<"nonnull">]; 1079 let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag, 1080 "ExpectedFunctionMethodOrParameter">; 1081 let Args = [VariadicUnsignedArgument<"Args">]; 1082 let AdditionalMembers = 1083[{bool isNonNull(unsigned idx) const { 1084 if (!args_size()) 1085 return true; 1086 for (const auto &V : args()) 1087 if (V == idx) 1088 return true; 1089 return false; 1090 } }]; 1091 // FIXME: We should merge duplicates into a single nonnull attribute. 1092 let DuplicatesAllowedWhileMerging = 1; 1093 let Documentation = [NonNullDocs]; 1094} 1095 1096def ReturnsNonNull : InheritableAttr { 1097 let Spellings = [GCC<"returns_nonnull">]; 1098 let Subjects = SubjectList<[ObjCMethod, Function], WarnDiag, 1099 "ExpectedFunctionOrMethod">; 1100 let Documentation = [ReturnsNonNullDocs]; 1101} 1102 1103// pass_object_size(N) indicates that the parameter should have 1104// __builtin_object_size with Type=N evaluated on the parameter at the callsite. 1105def PassObjectSize : InheritableParamAttr { 1106 let Spellings = [GNU<"pass_object_size">]; 1107 let Args = [IntArgument<"Type">]; 1108 let Subjects = SubjectList<[ParmVar]>; 1109 let Documentation = [PassObjectSizeDocs]; 1110} 1111 1112// Nullability type attributes. 1113def TypeNonNull : TypeAttr { 1114 let Spellings = [Keyword<"_Nonnull">]; 1115 let Documentation = [TypeNonNullDocs]; 1116} 1117 1118def TypeNullable : TypeAttr { 1119 let Spellings = [Keyword<"_Nullable">]; 1120 let Documentation = [TypeNullableDocs]; 1121} 1122 1123def TypeNullUnspecified : TypeAttr { 1124 let Spellings = [Keyword<"_Null_unspecified">]; 1125 let Documentation = [TypeNullUnspecifiedDocs]; 1126} 1127 1128def ObjCKindOf : TypeAttr { 1129 let Spellings = [Keyword<"__kindof">]; 1130 let Documentation = [Undocumented]; 1131} 1132 1133def AssumeAligned : InheritableAttr { 1134 let Spellings = [GCC<"assume_aligned">]; 1135 let Subjects = SubjectList<[ObjCMethod, Function]>; 1136 let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>]; 1137 let Documentation = [AssumeAlignedDocs]; 1138} 1139 1140def NoReturn : InheritableAttr { 1141 let Spellings = [GCC<"noreturn">, Declspec<"noreturn">]; 1142 // FIXME: Does GCC allow this on the function instead? 1143 let Documentation = [Undocumented]; 1144} 1145 1146def NoInstrumentFunction : InheritableAttr { 1147 let Spellings = [GCC<"no_instrument_function">]; 1148 let Subjects = SubjectList<[Function]>; 1149 let Documentation = [Undocumented]; 1150} 1151 1152def NotTailCalled : InheritableAttr { 1153 let Spellings = [GNU<"not_tail_called">, CXX11<"clang", "not_tail_called">]; 1154 let Subjects = SubjectList<[Function]>; 1155 let Documentation = [NotTailCalledDocs]; 1156} 1157 1158def NoThrow : InheritableAttr { 1159 let Spellings = [GCC<"nothrow">, Declspec<"nothrow">]; 1160 let Documentation = [Undocumented]; 1161} 1162 1163def NvWeak : IgnoredAttr { 1164 let Spellings = [GNU<"nv_weak">]; 1165 let LangOpts = [CUDA]; 1166} 1167 1168def ObjCBridge : InheritableAttr { 1169 let Spellings = [GNU<"objc_bridge">]; 1170 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag, 1171 "ExpectedStructOrUnionOrTypedef">; 1172 let Args = [IdentifierArgument<"BridgedType">]; 1173 let Documentation = [Undocumented]; 1174} 1175 1176def ObjCBridgeMutable : InheritableAttr { 1177 let Spellings = [GNU<"objc_bridge_mutable">]; 1178 let Subjects = SubjectList<[Record], ErrorDiag>; 1179 let Args = [IdentifierArgument<"BridgedType">]; 1180 let Documentation = [Undocumented]; 1181} 1182 1183def ObjCBridgeRelated : InheritableAttr { 1184 let Spellings = [GNU<"objc_bridge_related">]; 1185 let Subjects = SubjectList<[Record], ErrorDiag>; 1186 let Args = [IdentifierArgument<"RelatedClass">, 1187 IdentifierArgument<"ClassMethod", 1>, 1188 IdentifierArgument<"InstanceMethod", 1>]; 1189 let HasCustomParsing = 1; 1190 let Documentation = [Undocumented]; 1191} 1192 1193def NSReturnsRetained : InheritableAttr { 1194 let Spellings = [GNU<"ns_returns_retained">]; 1195// let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>; 1196 let Documentation = [Undocumented]; 1197} 1198 1199def NSReturnsNotRetained : InheritableAttr { 1200 let Spellings = [GNU<"ns_returns_not_retained">]; 1201// let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>; 1202 let Documentation = [Undocumented]; 1203} 1204 1205def NSReturnsAutoreleased : InheritableAttr { 1206 let Spellings = [GNU<"ns_returns_autoreleased">]; 1207// let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>; 1208 let Documentation = [Undocumented]; 1209} 1210 1211def NSConsumesSelf : InheritableAttr { 1212 let Spellings = [GNU<"ns_consumes_self">]; 1213 let Subjects = SubjectList<[ObjCMethod]>; 1214 let Documentation = [Undocumented]; 1215} 1216 1217def NSConsumed : InheritableParamAttr { 1218 let Spellings = [GNU<"ns_consumed">]; 1219 let Subjects = SubjectList<[ParmVar]>; 1220 let Documentation = [Undocumented]; 1221} 1222 1223def ObjCException : InheritableAttr { 1224 let Spellings = [GNU<"objc_exception">]; 1225 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; 1226 let Documentation = [Undocumented]; 1227} 1228 1229def ObjCMethodFamily : InheritableAttr { 1230 let Spellings = [GNU<"objc_method_family">]; 1231 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>; 1232 let Args = [EnumArgument<"Family", "FamilyKind", 1233 ["none", "alloc", "copy", "init", "mutableCopy", "new"], 1234 ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init", 1235 "OMF_mutableCopy", "OMF_new"]>]; 1236 let Documentation = [ObjCMethodFamilyDocs]; 1237} 1238 1239def ObjCNSObject : InheritableAttr { 1240 let Spellings = [GNU<"NSObject">]; 1241 let Documentation = [Undocumented]; 1242} 1243 1244def ObjCIndependentClass : InheritableAttr { 1245 let Spellings = [GNU<"objc_independent_class">]; 1246 let Documentation = [Undocumented]; 1247} 1248 1249def ObjCPreciseLifetime : InheritableAttr { 1250 let Spellings = [GNU<"objc_precise_lifetime">]; 1251 let Subjects = SubjectList<[Var], ErrorDiag>; 1252 let Documentation = [Undocumented]; 1253} 1254 1255def ObjCReturnsInnerPointer : InheritableAttr { 1256 let Spellings = [GNU<"objc_returns_inner_pointer">]; 1257 let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>; 1258 let Documentation = [Undocumented]; 1259} 1260 1261def ObjCRequiresSuper : InheritableAttr { 1262 let Spellings = [GNU<"objc_requires_super">]; 1263 let Subjects = SubjectList<[ObjCMethod], ErrorDiag>; 1264 let Documentation = [ObjCRequiresSuperDocs]; 1265} 1266 1267def ObjCRootClass : InheritableAttr { 1268 let Spellings = [GNU<"objc_root_class">]; 1269 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; 1270 let Documentation = [Undocumented]; 1271} 1272 1273def ObjCExplicitProtocolImpl : InheritableAttr { 1274 let Spellings = [GNU<"objc_protocol_requires_explicit_implementation">]; 1275 let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>; 1276 let Documentation = [Undocumented]; 1277} 1278 1279def ObjCDesignatedInitializer : Attr { 1280 let Spellings = [GNU<"objc_designated_initializer">]; 1281 let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag, 1282 "ExpectedObjCInterfaceDeclInitMethod">; 1283 let Documentation = [Undocumented]; 1284} 1285 1286def ObjCRuntimeName : Attr { 1287 let Spellings = [GNU<"objc_runtime_name">]; 1288 let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>; 1289 let Args = [StringArgument<"MetadataName">]; 1290 let Documentation = [ObjCRuntimeNameDocs]; 1291} 1292 1293def ObjCRuntimeVisible : Attr { 1294 let Spellings = [GNU<"objc_runtime_visible">]; 1295 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; 1296 let Documentation = [ObjCRuntimeVisibleDocs]; 1297} 1298 1299def ObjCBoxable : Attr { 1300 let Spellings = [GNU<"objc_boxable">]; 1301 let Subjects = SubjectList<[Record], ErrorDiag, "ExpectedStructOrUnion">; 1302 let Documentation = [ObjCBoxableDocs]; 1303} 1304 1305def OptimizeNone : InheritableAttr { 1306 let Spellings = [GNU<"optnone">, CXX11<"clang", "optnone">]; 1307 let Subjects = SubjectList<[Function, ObjCMethod]>; 1308 let Documentation = [OptnoneDocs]; 1309} 1310 1311def Overloadable : Attr { 1312 let Spellings = [GNU<"overloadable">]; 1313 let Subjects = SubjectList<[Function], ErrorDiag>; 1314 let Documentation = [OverloadableDocs]; 1315} 1316 1317def Override : InheritableAttr { 1318 let Spellings = [Keyword<"override">]; 1319 let SemaHandler = 0; 1320 let Documentation = [Undocumented]; 1321} 1322 1323def Ownership : InheritableAttr { 1324 let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">, 1325 GNU<"ownership_takes">]; 1326 let Accessors = [Accessor<"isHolds", [GNU<"ownership_holds">]>, 1327 Accessor<"isReturns", [GNU<"ownership_returns">]>, 1328 Accessor<"isTakes", [GNU<"ownership_takes">]>]; 1329 let AdditionalMembers = [{ 1330 enum OwnershipKind { Holds, Returns, Takes }; 1331 OwnershipKind getOwnKind() const { 1332 return isHolds() ? Holds : 1333 isTakes() ? Takes : 1334 Returns; 1335 } 1336 }]; 1337 let Args = [IdentifierArgument<"Module">, VariadicUnsignedArgument<"Args">]; 1338 let Subjects = SubjectList<[HasFunctionProto], WarnDiag, 1339 "ExpectedFunctionWithProtoType">; 1340 let Documentation = [Undocumented]; 1341} 1342 1343def Packed : InheritableAttr { 1344 let Spellings = [GCC<"packed">]; 1345// let Subjects = [Tag, Field]; 1346 let Documentation = [Undocumented]; 1347} 1348 1349def IntelOclBicc : InheritableAttr { 1350 let Spellings = [GNU<"intel_ocl_bicc">]; 1351// let Subjects = [Function, ObjCMethod]; 1352 let Documentation = [Undocumented]; 1353} 1354 1355def Pcs : InheritableAttr { 1356 let Spellings = [GCC<"pcs">]; 1357 let Args = [EnumArgument<"PCS", "PCSType", 1358 ["aapcs", "aapcs-vfp"], 1359 ["AAPCS", "AAPCS_VFP"]>]; 1360// let Subjects = [Function, ObjCMethod]; 1361 let Documentation = [PcsDocs]; 1362} 1363 1364def Pure : InheritableAttr { 1365 let Spellings = [GCC<"pure">]; 1366 let Documentation = [Undocumented]; 1367} 1368 1369def Regparm : TypeAttr { 1370 let Spellings = [GCC<"regparm">]; 1371 let Args = [UnsignedArgument<"NumParams">]; 1372 let Documentation = [RegparmDocs]; 1373} 1374 1375def ReqdWorkGroupSize : InheritableAttr { 1376 let Spellings = [GNU<"reqd_work_group_size">]; 1377 let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">, 1378 UnsignedArgument<"ZDim">]; 1379 let Subjects = SubjectList<[Function], ErrorDiag>; 1380 let Documentation = [Undocumented]; 1381} 1382 1383def WorkGroupSizeHint : InheritableAttr { 1384 let Spellings = [GNU<"work_group_size_hint">]; 1385 let Args = [UnsignedArgument<"XDim">, 1386 UnsignedArgument<"YDim">, 1387 UnsignedArgument<"ZDim">]; 1388 let Subjects = SubjectList<[Function], ErrorDiag>; 1389 let Documentation = [Undocumented]; 1390} 1391 1392def InitPriority : InheritableAttr { 1393 let Spellings = [GNU<"init_priority">]; 1394 let Args = [UnsignedArgument<"Priority">]; 1395 let Subjects = SubjectList<[Var], ErrorDiag>; 1396 let Documentation = [Undocumented]; 1397} 1398 1399def Section : InheritableAttr { 1400 let Spellings = [GCC<"section">, Declspec<"allocate">]; 1401 let Args = [StringArgument<"Name">]; 1402 let Subjects = SubjectList<[Function, GlobalVar, 1403 ObjCMethod, ObjCProperty], ErrorDiag, 1404 "ExpectedFunctionGlobalVarMethodOrProperty">; 1405 let Documentation = [SectionDocs]; 1406} 1407 1408def Sentinel : InheritableAttr { 1409 let Spellings = [GCC<"sentinel">]; 1410 let Args = [DefaultIntArgument<"Sentinel", 0>, 1411 DefaultIntArgument<"NullPos", 0>]; 1412// let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>; 1413 let Documentation = [Undocumented]; 1414} 1415 1416def StdCall : InheritableAttr { 1417 let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">]; 1418// let Subjects = [Function, ObjCMethod]; 1419 let Documentation = [StdCallDocs]; 1420} 1421 1422def SwiftCall : InheritableAttr { 1423 let Spellings = [GCC<"swiftcall">]; 1424// let Subjects = SubjectList<[Function]>; 1425 let Documentation = [SwiftCallDocs]; 1426} 1427 1428def SwiftContext : ParameterABIAttr { 1429 let Spellings = [GCC<"swift_context">]; 1430 let Documentation = [SwiftContextDocs]; 1431} 1432 1433def SwiftErrorResult : ParameterABIAttr { 1434 let Spellings = [GCC<"swift_error_result">]; 1435 let Documentation = [SwiftErrorResultDocs]; 1436} 1437 1438def SwiftIndirectResult : ParameterABIAttr { 1439 let Spellings = [GCC<"swift_indirect_result">]; 1440 let Documentation = [SwiftIndirectResultDocs]; 1441} 1442 1443def SysVABI : InheritableAttr { 1444 let Spellings = [GCC<"sysv_abi">]; 1445// let Subjects = [Function, ObjCMethod]; 1446 let Documentation = [Undocumented]; 1447} 1448 1449def ThisCall : InheritableAttr { 1450 let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">, 1451 Keyword<"_thiscall">]; 1452// let Subjects = [Function, ObjCMethod]; 1453 let Documentation = [ThisCallDocs]; 1454} 1455 1456def VectorCall : InheritableAttr { 1457 let Spellings = [GNU<"vectorcall">, Keyword<"__vectorcall">, 1458 Keyword<"_vectorcall">]; 1459// let Subjects = [Function, ObjCMethod]; 1460 let Documentation = [VectorCallDocs]; 1461} 1462 1463def Pascal : InheritableAttr { 1464 let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">]; 1465// let Subjects = [Function, ObjCMethod]; 1466 let Documentation = [Undocumented]; 1467} 1468 1469def PreserveMost : InheritableAttr { 1470 let Spellings = [GNU<"preserve_most">]; 1471 let Documentation = [PreserveMostDocs]; 1472} 1473 1474def PreserveAll : InheritableAttr { 1475 let Spellings = [GNU<"preserve_all">]; 1476 let Documentation = [PreserveAllDocs]; 1477} 1478 1479def Target : InheritableAttr { 1480 let Spellings = [GCC<"target">]; 1481 let Args = [StringArgument<"featuresStr">]; 1482 let Subjects = SubjectList<[Function], ErrorDiag>; 1483 let Documentation = [TargetDocs]; 1484 let AdditionalMembers = [{ 1485 typedef std::pair<std::vector<std::string>, StringRef> ParsedTargetAttr; 1486 ParsedTargetAttr parse() const { 1487 ParsedTargetAttr Ret; 1488 SmallVector<StringRef, 1> AttrFeatures; 1489 getFeaturesStr().split(AttrFeatures, ","); 1490 1491 // Grab the various features and prepend a "+" to turn on the feature to 1492 // the backend and add them to our existing set of features. 1493 for (auto &Feature : AttrFeatures) { 1494 // Go ahead and trim whitespace rather than either erroring or 1495 // accepting it weirdly. 1496 Feature = Feature.trim(); 1497 1498 // We don't support cpu tuning this way currently. 1499 // TODO: Support the fpmath option. It will require checking 1500 // overall feature validity for the function with the rest of the 1501 // attributes on the function. 1502 if (Feature.startswith("fpmath=") || Feature.startswith("tune=")) 1503 continue; 1504 1505 // While we're here iterating check for a different target cpu. 1506 if (Feature.startswith("arch=")) 1507 Ret.second = Feature.split("=").second.trim(); 1508 else if (Feature.startswith("no-")) 1509 Ret.first.push_back("-" + Feature.split("-").second.str()); 1510 else 1511 Ret.first.push_back("+" + Feature.str()); 1512 } 1513 return Ret; 1514 } 1515 }]; 1516} 1517 1518def TransparentUnion : InheritableAttr { 1519 let Spellings = [GCC<"transparent_union">]; 1520// let Subjects = SubjectList<[Record, TypedefName]>; 1521 let Documentation = [Undocumented]; 1522} 1523 1524def Unavailable : InheritableAttr { 1525 let Spellings = [GNU<"unavailable">]; 1526 let Args = [StringArgument<"Message", 1>, 1527 EnumArgument<"ImplicitReason", "ImplicitReason", 1528 ["", "", "", ""], 1529 ["IR_None", 1530 "IR_ARCForbiddenType", 1531 "IR_ForbiddenWeak", 1532 "IR_ARCForbiddenConversion", 1533 "IR_ARCInitReturnsUnrelated", 1534 "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>]; 1535 let Documentation = [Undocumented]; 1536} 1537 1538def ArcWeakrefUnavailable : InheritableAttr { 1539 let Spellings = [GNU<"objc_arc_weak_reference_unavailable">]; 1540 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; 1541 let Documentation = [Undocumented]; 1542} 1543 1544def ObjCGC : TypeAttr { 1545 let Spellings = [GNU<"objc_gc">]; 1546 let Args = [IdentifierArgument<"Kind">]; 1547 let Documentation = [Undocumented]; 1548} 1549 1550def ObjCOwnership : InheritableAttr { 1551 let Spellings = [GNU<"objc_ownership">]; 1552 let Args = [IdentifierArgument<"Kind">]; 1553 let ASTNode = 0; 1554 let Documentation = [Undocumented]; 1555} 1556 1557def ObjCRequiresPropertyDefs : InheritableAttr { 1558 let Spellings = [GNU<"objc_requires_property_definitions">]; 1559 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; 1560 let Documentation = [Undocumented]; 1561} 1562 1563def Unused : InheritableAttr { 1564 let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">]; 1565 let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label, 1566 Field, ObjCMethod, FunctionLike], WarnDiag, 1567 "ExpectedForMaybeUnused">; 1568 let Documentation = [WarnMaybeUnusedDocs]; 1569} 1570 1571def Used : InheritableAttr { 1572 let Spellings = [GCC<"used">]; 1573 let Documentation = [Undocumented]; 1574} 1575 1576def Uuid : InheritableAttr { 1577 let Spellings = [Declspec<"uuid">]; 1578 let Args = [StringArgument<"Guid">]; 1579// let Subjects = SubjectList<[CXXRecord]>; 1580 let LangOpts = [MicrosoftExt, Borland]; 1581 let Documentation = [Undocumented]; 1582} 1583 1584def VectorSize : TypeAttr { 1585 let Spellings = [GCC<"vector_size">]; 1586 let Args = [ExprArgument<"NumBytes">]; 1587 let Documentation = [Undocumented]; 1588} 1589 1590def VecTypeHint : InheritableAttr { 1591 let Spellings = [GNU<"vec_type_hint">]; 1592 let Args = [TypeArgument<"TypeHint">]; 1593 let Subjects = SubjectList<[Function], ErrorDiag>; 1594 let Documentation = [Undocumented]; 1595} 1596 1597def Visibility : InheritableAttr { 1598 let Clone = 0; 1599 let Spellings = [GCC<"visibility">]; 1600 let Args = [EnumArgument<"Visibility", "VisibilityType", 1601 ["default", "hidden", "internal", "protected"], 1602 ["Default", "Hidden", "Hidden", "Protected"]>]; 1603 let Documentation = [Undocumented]; 1604} 1605 1606def TypeVisibility : InheritableAttr { 1607 let Clone = 0; 1608 let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">]; 1609 let Args = [EnumArgument<"Visibility", "VisibilityType", 1610 ["default", "hidden", "internal", "protected"], 1611 ["Default", "Hidden", "Hidden", "Protected"]>]; 1612// let Subjects = [Tag, ObjCInterface, Namespace]; 1613 let Documentation = [Undocumented]; 1614} 1615 1616def VecReturn : InheritableAttr { 1617 let Spellings = [GNU<"vecreturn">]; 1618 let Subjects = SubjectList<[CXXRecord], ErrorDiag>; 1619 let Documentation = [Undocumented]; 1620} 1621 1622def WarnUnused : InheritableAttr { 1623 let Spellings = [GNU<"warn_unused">]; 1624 let Subjects = SubjectList<[Record]>; 1625 let Documentation = [Undocumented]; 1626} 1627 1628def WarnUnusedResult : InheritableAttr { 1629 let Spellings = [CXX11<"", "nodiscard", 201603>, 1630 CXX11<"clang", "warn_unused_result">, 1631 GCC<"warn_unused_result">]; 1632 let Subjects = SubjectList<[ObjCMethod, Enum, CXXRecord, FunctionLike], 1633 WarnDiag, "ExpectedFunctionMethodEnumOrClass">; 1634 let Documentation = [WarnUnusedResultsDocs]; 1635} 1636 1637def Weak : InheritableAttr { 1638 let Spellings = [GCC<"weak">]; 1639 let Subjects = SubjectList<[Var, Function, CXXRecord]>; 1640 let Documentation = [Undocumented]; 1641} 1642 1643def WeakImport : InheritableAttr { 1644 let Spellings = [GNU<"weak_import">]; 1645 let Documentation = [Undocumented]; 1646} 1647 1648def WeakRef : InheritableAttr { 1649 let Spellings = [GCC<"weakref">]; 1650 // A WeakRef that has an argument is treated as being an AliasAttr 1651 let Args = [StringArgument<"Aliasee", 1>]; 1652 let Subjects = SubjectList<[Var, Function], ErrorDiag>; 1653 let Documentation = [Undocumented]; 1654} 1655 1656def LTOVisibilityPublic : InheritableAttr { 1657 let Spellings = [CXX11<"clang", "lto_visibility_public">]; 1658 let Subjects = SubjectList<[Record]>; 1659 let Documentation = [LTOVisibilityDocs]; 1660} 1661 1662def AnyX86Interrupt : InheritableAttr, TargetSpecificAttr<TargetAnyX86> { 1663 // NOTE: If you add any additional spellings, ARMInterrupt's, 1664 // MSP430Interrupt's and MipsInterrupt's spellings must match. 1665 let Spellings = [GNU<"interrupt">]; 1666 let Subjects = SubjectList<[HasFunctionProto]>; 1667 let ParseKind = "Interrupt"; 1668 let HasCustomParsing = 1; 1669 let Documentation = [AnyX86InterruptDocs]; 1670} 1671 1672def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetX86> { 1673 let Spellings = [GNU<"force_align_arg_pointer">]; 1674 // Technically, this appertains to a FunctionDecl, but the target-specific 1675 // code silently allows anything function-like (such as typedefs or function 1676 // pointers), but does not apply the attribute to them. 1677 let Documentation = [Undocumented]; 1678} 1679 1680def NoSanitize : InheritableAttr { 1681 let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">]; 1682 let Args = [VariadicStringArgument<"Sanitizers">]; 1683 let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>; 1684 let Documentation = [NoSanitizeDocs]; 1685 let AdditionalMembers = [{ 1686 SanitizerMask getMask() const { 1687 SanitizerMask Mask = 0; 1688 for (auto SanitizerName : sanitizers()) { 1689 SanitizerMask ParsedMask = 1690 parseSanitizerValue(SanitizerName, /*AllowGroups=*/true); 1691 Mask |= expandSanitizerGroups(ParsedMask); 1692 } 1693 return Mask; 1694 } 1695 }]; 1696} 1697 1698// Attributes to disable a specific sanitizer. No new sanitizers should be added 1699// to this list; the no_sanitize attribute should be extended instead. 1700def NoSanitizeSpecific : InheritableAttr { 1701 let Spellings = [GCC<"no_address_safety_analysis">, 1702 GCC<"no_sanitize_address">, 1703 GCC<"no_sanitize_thread">, 1704 GNU<"no_sanitize_memory">]; 1705 let Subjects = SubjectList<[Function], ErrorDiag>; 1706 let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs, 1707 NoSanitizeMemoryDocs]; 1708 let ASTNode = 0; 1709} 1710 1711// C/C++ Thread safety attributes (e.g. for deadlock, data race checking) 1712 1713def GuardedVar : InheritableAttr { 1714 let Spellings = [GNU<"guarded_var">]; 1715 let Subjects = SubjectList<[Field, SharedVar], WarnDiag, 1716 "ExpectedFieldOrGlobalVar">; 1717 let Documentation = [Undocumented]; 1718} 1719 1720def PtGuardedVar : InheritableAttr { 1721 let Spellings = [GNU<"pt_guarded_var">]; 1722 let Subjects = SubjectList<[Field, SharedVar], WarnDiag, 1723 "ExpectedFieldOrGlobalVar">; 1724 let Documentation = [Undocumented]; 1725} 1726 1727def Lockable : InheritableAttr { 1728 let Spellings = [GNU<"lockable">]; 1729 let Subjects = SubjectList<[Record]>; 1730 let Documentation = [Undocumented]; 1731 let ASTNode = 0; // Replaced by Capability 1732} 1733 1734def ScopedLockable : InheritableAttr { 1735 let Spellings = [GNU<"scoped_lockable">]; 1736 let Subjects = SubjectList<[Record]>; 1737 let Documentation = [Undocumented]; 1738} 1739 1740def Capability : InheritableAttr { 1741 let Spellings = [GNU<"capability">, CXX11<"clang", "capability">, 1742 GNU<"shared_capability">, 1743 CXX11<"clang", "shared_capability">]; 1744 let Subjects = SubjectList<[Record, TypedefName], ErrorDiag, 1745 "ExpectedStructOrUnionOrTypedef">; 1746 let Args = [StringArgument<"Name">]; 1747 let Accessors = [Accessor<"isShared", 1748 [GNU<"shared_capability">, 1749 CXX11<"clang","shared_capability">]>]; 1750 let Documentation = [Undocumented]; 1751 let AdditionalMembers = [{ 1752 bool isMutex() const { return getName().equals_lower("mutex"); } 1753 bool isRole() const { return getName().equals_lower("role"); } 1754 }]; 1755} 1756 1757def AssertCapability : InheritableAttr { 1758 let Spellings = [GNU<"assert_capability">, 1759 CXX11<"clang", "assert_capability">, 1760 GNU<"assert_shared_capability">, 1761 CXX11<"clang", "assert_shared_capability">]; 1762 let Subjects = SubjectList<[Function]>; 1763 let LateParsed = 1; 1764 let TemplateDependent = 1; 1765 let ParseArgumentsAsUnevaluated = 1; 1766 let DuplicatesAllowedWhileMerging = 1; 1767 let Args = [ExprArgument<"Expr">]; 1768 let Accessors = [Accessor<"isShared", 1769 [GNU<"assert_shared_capability">, 1770 CXX11<"clang", "assert_shared_capability">]>]; 1771 let Documentation = [AssertCapabilityDocs]; 1772} 1773 1774def AcquireCapability : InheritableAttr { 1775 let Spellings = [GNU<"acquire_capability">, 1776 CXX11<"clang", "acquire_capability">, 1777 GNU<"acquire_shared_capability">, 1778 CXX11<"clang", "acquire_shared_capability">, 1779 GNU<"exclusive_lock_function">, 1780 GNU<"shared_lock_function">]; 1781 let Subjects = SubjectList<[Function]>; 1782 let LateParsed = 1; 1783 let TemplateDependent = 1; 1784 let ParseArgumentsAsUnevaluated = 1; 1785 let DuplicatesAllowedWhileMerging = 1; 1786 let Args = [VariadicExprArgument<"Args">]; 1787 let Accessors = [Accessor<"isShared", 1788 [GNU<"acquire_shared_capability">, 1789 CXX11<"clang", "acquire_shared_capability">, 1790 GNU<"shared_lock_function">]>]; 1791 let Documentation = [AcquireCapabilityDocs]; 1792} 1793 1794def TryAcquireCapability : InheritableAttr { 1795 let Spellings = [GNU<"try_acquire_capability">, 1796 CXX11<"clang", "try_acquire_capability">, 1797 GNU<"try_acquire_shared_capability">, 1798 CXX11<"clang", "try_acquire_shared_capability">]; 1799 let Subjects = SubjectList<[Function], 1800 ErrorDiag>; 1801 let LateParsed = 1; 1802 let TemplateDependent = 1; 1803 let ParseArgumentsAsUnevaluated = 1; 1804 let DuplicatesAllowedWhileMerging = 1; 1805 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">]; 1806 let Accessors = [Accessor<"isShared", 1807 [GNU<"try_acquire_shared_capability">, 1808 CXX11<"clang", "try_acquire_shared_capability">]>]; 1809 let Documentation = [TryAcquireCapabilityDocs]; 1810} 1811 1812def ReleaseCapability : InheritableAttr { 1813 let Spellings = [GNU<"release_capability">, 1814 CXX11<"clang", "release_capability">, 1815 GNU<"release_shared_capability">, 1816 CXX11<"clang", "release_shared_capability">, 1817 GNU<"release_generic_capability">, 1818 CXX11<"clang", "release_generic_capability">, 1819 GNU<"unlock_function">]; 1820 let Subjects = SubjectList<[Function]>; 1821 let LateParsed = 1; 1822 let TemplateDependent = 1; 1823 let ParseArgumentsAsUnevaluated = 1; 1824 let DuplicatesAllowedWhileMerging = 1; 1825 let Args = [VariadicExprArgument<"Args">]; 1826 let Accessors = [Accessor<"isShared", 1827 [GNU<"release_shared_capability">, 1828 CXX11<"clang", "release_shared_capability">]>, 1829 Accessor<"isGeneric", 1830 [GNU<"release_generic_capability">, 1831 CXX11<"clang", "release_generic_capability">, 1832 GNU<"unlock_function">]>]; 1833 let Documentation = [ReleaseCapabilityDocs]; 1834} 1835 1836def RequiresCapability : InheritableAttr { 1837 let Spellings = [GNU<"requires_capability">, 1838 CXX11<"clang", "requires_capability">, 1839 GNU<"exclusive_locks_required">, 1840 GNU<"requires_shared_capability">, 1841 CXX11<"clang", "requires_shared_capability">, 1842 GNU<"shared_locks_required">]; 1843 let Args = [VariadicExprArgument<"Args">]; 1844 let LateParsed = 1; 1845 let TemplateDependent = 1; 1846 let ParseArgumentsAsUnevaluated = 1; 1847 let DuplicatesAllowedWhileMerging = 1; 1848 let Subjects = SubjectList<[Function]>; 1849 let Accessors = [Accessor<"isShared", [GNU<"requires_shared_capability">, 1850 GNU<"shared_locks_required">, 1851 CXX11<"clang","requires_shared_capability">]>]; 1852 let Documentation = [Undocumented]; 1853} 1854 1855def NoThreadSafetyAnalysis : InheritableAttr { 1856 let Spellings = [GNU<"no_thread_safety_analysis">]; 1857 let Subjects = SubjectList<[Function]>; 1858 let Documentation = [Undocumented]; 1859} 1860 1861def GuardedBy : InheritableAttr { 1862 let Spellings = [GNU<"guarded_by">]; 1863 let Args = [ExprArgument<"Arg">]; 1864 let LateParsed = 1; 1865 let TemplateDependent = 1; 1866 let ParseArgumentsAsUnevaluated = 1; 1867 let DuplicatesAllowedWhileMerging = 1; 1868 let Subjects = SubjectList<[Field, SharedVar], WarnDiag, 1869 "ExpectedFieldOrGlobalVar">; 1870 let Documentation = [Undocumented]; 1871} 1872 1873def PtGuardedBy : InheritableAttr { 1874 let Spellings = [GNU<"pt_guarded_by">]; 1875 let Args = [ExprArgument<"Arg">]; 1876 let LateParsed = 1; 1877 let TemplateDependent = 1; 1878 let ParseArgumentsAsUnevaluated = 1; 1879 let DuplicatesAllowedWhileMerging = 1; 1880 let Subjects = SubjectList<[Field, SharedVar], WarnDiag, 1881 "ExpectedFieldOrGlobalVar">; 1882 let Documentation = [Undocumented]; 1883} 1884 1885def AcquiredAfter : InheritableAttr { 1886 let Spellings = [GNU<"acquired_after">]; 1887 let Args = [VariadicExprArgument<"Args">]; 1888 let LateParsed = 1; 1889 let TemplateDependent = 1; 1890 let ParseArgumentsAsUnevaluated = 1; 1891 let DuplicatesAllowedWhileMerging = 1; 1892 let Subjects = SubjectList<[Field, SharedVar], WarnDiag, 1893 "ExpectedFieldOrGlobalVar">; 1894 let Documentation = [Undocumented]; 1895} 1896 1897def AcquiredBefore : InheritableAttr { 1898 let Spellings = [GNU<"acquired_before">]; 1899 let Args = [VariadicExprArgument<"Args">]; 1900 let LateParsed = 1; 1901 let TemplateDependent = 1; 1902 let ParseArgumentsAsUnevaluated = 1; 1903 let DuplicatesAllowedWhileMerging = 1; 1904 let Subjects = SubjectList<[Field, SharedVar], WarnDiag, 1905 "ExpectedFieldOrGlobalVar">; 1906 let Documentation = [Undocumented]; 1907} 1908 1909def AssertExclusiveLock : InheritableAttr { 1910 let Spellings = [GNU<"assert_exclusive_lock">]; 1911 let Args = [VariadicExprArgument<"Args">]; 1912 let LateParsed = 1; 1913 let TemplateDependent = 1; 1914 let ParseArgumentsAsUnevaluated = 1; 1915 let DuplicatesAllowedWhileMerging = 1; 1916 let Subjects = SubjectList<[Function]>; 1917 let Documentation = [Undocumented]; 1918} 1919 1920def AssertSharedLock : InheritableAttr { 1921 let Spellings = [GNU<"assert_shared_lock">]; 1922 let Args = [VariadicExprArgument<"Args">]; 1923 let LateParsed = 1; 1924 let TemplateDependent = 1; 1925 let ParseArgumentsAsUnevaluated = 1; 1926 let DuplicatesAllowedWhileMerging = 1; 1927 let Subjects = SubjectList<[Function]>; 1928 let Documentation = [Undocumented]; 1929} 1930 1931// The first argument is an integer or boolean value specifying the return value 1932// of a successful lock acquisition. 1933def ExclusiveTrylockFunction : InheritableAttr { 1934 let Spellings = [GNU<"exclusive_trylock_function">]; 1935 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">]; 1936 let LateParsed = 1; 1937 let TemplateDependent = 1; 1938 let ParseArgumentsAsUnevaluated = 1; 1939 let DuplicatesAllowedWhileMerging = 1; 1940 let Subjects = SubjectList<[Function]>; 1941 let Documentation = [Undocumented]; 1942} 1943 1944// The first argument is an integer or boolean value specifying the return value 1945// of a successful lock acquisition. 1946def SharedTrylockFunction : InheritableAttr { 1947 let Spellings = [GNU<"shared_trylock_function">]; 1948 let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">]; 1949 let LateParsed = 1; 1950 let TemplateDependent = 1; 1951 let ParseArgumentsAsUnevaluated = 1; 1952 let DuplicatesAllowedWhileMerging = 1; 1953 let Subjects = SubjectList<[Function]>; 1954 let Documentation = [Undocumented]; 1955} 1956 1957def LockReturned : InheritableAttr { 1958 let Spellings = [GNU<"lock_returned">]; 1959 let Args = [ExprArgument<"Arg">]; 1960 let LateParsed = 1; 1961 let TemplateDependent = 1; 1962 let ParseArgumentsAsUnevaluated = 1; 1963 let Subjects = SubjectList<[Function]>; 1964 let Documentation = [Undocumented]; 1965} 1966 1967def LocksExcluded : InheritableAttr { 1968 let Spellings = [GNU<"locks_excluded">]; 1969 let Args = [VariadicExprArgument<"Args">]; 1970 let LateParsed = 1; 1971 let TemplateDependent = 1; 1972 let ParseArgumentsAsUnevaluated = 1; 1973 let DuplicatesAllowedWhileMerging = 1; 1974 let Subjects = SubjectList<[Function]>; 1975 let Documentation = [Undocumented]; 1976} 1977 1978// C/C++ consumed attributes. 1979 1980def Consumable : InheritableAttr { 1981 let Spellings = [GNU<"consumable">]; 1982 let Subjects = SubjectList<[CXXRecord]>; 1983 let Args = [EnumArgument<"DefaultState", "ConsumedState", 1984 ["unknown", "consumed", "unconsumed"], 1985 ["Unknown", "Consumed", "Unconsumed"]>]; 1986 let Documentation = [ConsumableDocs]; 1987} 1988 1989def ConsumableAutoCast : InheritableAttr { 1990 let Spellings = [GNU<"consumable_auto_cast_state">]; 1991 let Subjects = SubjectList<[CXXRecord]>; 1992 let Documentation = [Undocumented]; 1993} 1994 1995def ConsumableSetOnRead : InheritableAttr { 1996 let Spellings = [GNU<"consumable_set_state_on_read">]; 1997 let Subjects = SubjectList<[CXXRecord]>; 1998 let Documentation = [Undocumented]; 1999} 2000 2001def CallableWhen : InheritableAttr { 2002 let Spellings = [GNU<"callable_when">]; 2003 let Subjects = SubjectList<[CXXMethod]>; 2004 let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState", 2005 ["unknown", "consumed", "unconsumed"], 2006 ["Unknown", "Consumed", "Unconsumed"]>]; 2007 let Documentation = [CallableWhenDocs]; 2008} 2009 2010def ParamTypestate : InheritableAttr { 2011 let Spellings = [GNU<"param_typestate">]; 2012 let Subjects = SubjectList<[ParmVar]>; 2013 let Args = [EnumArgument<"ParamState", "ConsumedState", 2014 ["unknown", "consumed", "unconsumed"], 2015 ["Unknown", "Consumed", "Unconsumed"]>]; 2016 let Documentation = [ParamTypestateDocs]; 2017} 2018 2019def ReturnTypestate : InheritableAttr { 2020 let Spellings = [GNU<"return_typestate">]; 2021 let Subjects = SubjectList<[Function, ParmVar]>; 2022 let Args = [EnumArgument<"State", "ConsumedState", 2023 ["unknown", "consumed", "unconsumed"], 2024 ["Unknown", "Consumed", "Unconsumed"]>]; 2025 let Documentation = [ReturnTypestateDocs]; 2026} 2027 2028def SetTypestate : InheritableAttr { 2029 let Spellings = [GNU<"set_typestate">]; 2030 let Subjects = SubjectList<[CXXMethod]>; 2031 let Args = [EnumArgument<"NewState", "ConsumedState", 2032 ["unknown", "consumed", "unconsumed"], 2033 ["Unknown", "Consumed", "Unconsumed"]>]; 2034 let Documentation = [SetTypestateDocs]; 2035} 2036 2037def TestTypestate : InheritableAttr { 2038 let Spellings = [GNU<"test_typestate">]; 2039 let Subjects = SubjectList<[CXXMethod]>; 2040 let Args = [EnumArgument<"TestState", "ConsumedState", 2041 ["consumed", "unconsumed"], 2042 ["Consumed", "Unconsumed"]>]; 2043 let Documentation = [TestTypestateDocs]; 2044} 2045 2046// Type safety attributes for `void *' pointers and type tags. 2047 2048def ArgumentWithTypeTag : InheritableAttr { 2049 let Spellings = [GNU<"argument_with_type_tag">, 2050 GNU<"pointer_with_type_tag">]; 2051 let Args = [IdentifierArgument<"ArgumentKind">, 2052 UnsignedArgument<"ArgumentIdx">, 2053 UnsignedArgument<"TypeTagIdx">, 2054 BoolArgument<"IsPointer">]; 2055 let HasCustomParsing = 1; 2056 let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs]; 2057} 2058 2059def TypeTagForDatatype : InheritableAttr { 2060 let Spellings = [GNU<"type_tag_for_datatype">]; 2061 let Args = [IdentifierArgument<"ArgumentKind">, 2062 TypeArgument<"MatchingCType">, 2063 BoolArgument<"LayoutCompatible">, 2064 BoolArgument<"MustBeNull">]; 2065// let Subjects = SubjectList<[Var], ErrorDiag>; 2066 let HasCustomParsing = 1; 2067 let Documentation = [TypeTagForDatatypeDocs]; 2068} 2069 2070// Microsoft-related attributes 2071 2072def MSNoVTable : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> { 2073 let Spellings = [Declspec<"novtable">]; 2074 let Subjects = SubjectList<[CXXRecord]>; 2075 let Documentation = [MSNoVTableDocs]; 2076} 2077 2078def : IgnoredAttr { 2079 let Spellings = [Declspec<"property">]; 2080} 2081 2082def MSStruct : InheritableAttr { 2083 let Spellings = [GCC<"ms_struct">]; 2084 let Subjects = SubjectList<[Record]>; 2085 let Documentation = [Undocumented]; 2086} 2087 2088def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> { 2089 let Spellings = [Declspec<"dllexport">, GCC<"dllexport">]; 2090 let Subjects = SubjectList<[Function, Var, CXXRecord]>; 2091 let Documentation = [Undocumented]; 2092} 2093 2094def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> { 2095 let Spellings = [Declspec<"dllimport">, GCC<"dllimport">]; 2096 let Subjects = SubjectList<[Function, Var, CXXRecord]>; 2097 let Documentation = [Undocumented]; 2098} 2099 2100def SelectAny : InheritableAttr { 2101 let Spellings = [Declspec<"selectany">]; 2102 let LangOpts = [MicrosoftExt]; 2103 let Documentation = [Undocumented]; 2104} 2105 2106def Thread : Attr { 2107 let Spellings = [Declspec<"thread">]; 2108 let LangOpts = [MicrosoftExt]; 2109 let Documentation = [ThreadDocs]; 2110 let Subjects = SubjectList<[Var]>; 2111} 2112 2113def Win64 : IgnoredAttr { 2114 let Spellings = [Keyword<"__w64">]; 2115 let LangOpts = [MicrosoftExt]; 2116} 2117 2118def Ptr32 : TypeAttr { 2119 let Spellings = [Keyword<"__ptr32">]; 2120 let Documentation = [Undocumented]; 2121} 2122 2123def Ptr64 : TypeAttr { 2124 let Spellings = [Keyword<"__ptr64">]; 2125 let Documentation = [Undocumented]; 2126} 2127 2128def SPtr : TypeAttr { 2129 let Spellings = [Keyword<"__sptr">]; 2130 let Documentation = [Undocumented]; 2131} 2132 2133def UPtr : TypeAttr { 2134 let Spellings = [Keyword<"__uptr">]; 2135 let Documentation = [Undocumented]; 2136} 2137 2138def MSInheritance : InheritableAttr { 2139 let LangOpts = [MicrosoftExt]; 2140 let Args = [DefaultBoolArgument<"BestCase", 1>]; 2141 let Spellings = [Keyword<"__single_inheritance">, 2142 Keyword<"__multiple_inheritance">, 2143 Keyword<"__virtual_inheritance">, 2144 Keyword<"__unspecified_inheritance">]; 2145 let AdditionalMembers = [{ 2146 static bool hasVBPtrOffsetField(Spelling Inheritance) { 2147 return Inheritance == Keyword_unspecified_inheritance; 2148 } 2149 2150 // Only member pointers to functions need a this adjustment, since it can be 2151 // combined with the field offset for data pointers. 2152 static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) { 2153 return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance; 2154 } 2155 2156 static bool hasVBTableOffsetField(Spelling Inheritance) { 2157 return Inheritance >= Keyword_virtual_inheritance; 2158 } 2159 2160 static bool hasOnlyOneField(bool IsMemberFunction, 2161 Spelling Inheritance) { 2162 if (IsMemberFunction) 2163 return Inheritance <= Keyword_single_inheritance; 2164 return Inheritance <= Keyword_multiple_inheritance; 2165 } 2166 }]; 2167 let Documentation = [MSInheritanceDocs]; 2168} 2169 2170def MSVtorDisp : InheritableAttr { 2171 // This attribute has no spellings as it is only ever created implicitly. 2172 let Spellings = []; 2173 let Args = [UnsignedArgument<"vdm">]; 2174 let SemaHandler = 0; 2175 2176 let AdditionalMembers = [{ 2177 enum Mode { 2178 Never, 2179 ForVBaseOverride, 2180 ForVFTable 2181 }; 2182 2183 Mode getVtorDispMode() const { return Mode(vdm); } 2184 }]; 2185 let Documentation = [Undocumented]; 2186} 2187 2188def InitSeg : Attr { 2189 let Spellings = [Pragma<"", "init_seg">]; 2190 let Args = [StringArgument<"Section">]; 2191 let SemaHandler = 0; 2192 let Documentation = [InitSegDocs]; 2193 let AdditionalMembers = [{ 2194 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const { 2195 OS << '(' << getSection() << ')'; 2196 } 2197 }]; 2198} 2199 2200def LoopHint : Attr { 2201 /// #pragma clang loop <option> directive 2202 /// vectorize: vectorizes loop operations if State == Enable. 2203 /// vectorize_width: vectorize loop operations with width 'Value'. 2204 /// interleave: interleave multiple loop iterations if State == Enable. 2205 /// interleave_count: interleaves 'Value' loop interations. 2206 /// unroll: fully unroll loop if State == Enable. 2207 /// unroll_count: unrolls loop 'Value' times. 2208 /// distribute: attempt to distribute loop if State == Enable 2209 2210 /// #pragma unroll <argument> directive 2211 /// <no arg>: fully unrolls loop. 2212 /// boolean: fully unrolls loop if State == Enable. 2213 /// expression: unrolls loop 'Value' times. 2214 2215 let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">, 2216 Pragma<"", "nounroll">]; 2217 2218 /// State of the loop optimization specified by the spelling. 2219 let Args = [EnumArgument<"Option", "OptionType", 2220 ["vectorize", "vectorize_width", "interleave", "interleave_count", 2221 "unroll", "unroll_count", "distribute"], 2222 ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount", 2223 "Unroll", "UnrollCount", "Distribute"]>, 2224 EnumArgument<"State", "LoopHintState", 2225 ["enable", "disable", "numeric", "assume_safety", "full"], 2226 ["Enable", "Disable", "Numeric", "AssumeSafety", "Full"]>, 2227 ExprArgument<"Value">]; 2228 2229 let AdditionalMembers = [{ 2230 static const char *getOptionName(int Option) { 2231 switch(Option) { 2232 case Vectorize: return "vectorize"; 2233 case VectorizeWidth: return "vectorize_width"; 2234 case Interleave: return "interleave"; 2235 case InterleaveCount: return "interleave_count"; 2236 case Unroll: return "unroll"; 2237 case UnrollCount: return "unroll_count"; 2238 case Distribute: return "distribute"; 2239 } 2240 llvm_unreachable("Unhandled LoopHint option."); 2241 } 2242 2243 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const { 2244 unsigned SpellingIndex = getSpellingListIndex(); 2245 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or 2246 // "nounroll" is already emitted as the pragma name. 2247 if (SpellingIndex == Pragma_nounroll) 2248 return; 2249 else if (SpellingIndex == Pragma_unroll) { 2250 OS << getValueString(Policy); 2251 return; 2252 } 2253 2254 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling"); 2255 OS << getOptionName(option) << getValueString(Policy); 2256 } 2257 2258 // Return a string containing the loop hint argument including the 2259 // enclosing parentheses. 2260 std::string getValueString(const PrintingPolicy &Policy) const { 2261 std::string ValueName; 2262 llvm::raw_string_ostream OS(ValueName); 2263 OS << "("; 2264 if (state == Numeric) 2265 value->printPretty(OS, nullptr, Policy); 2266 else if (state == Enable) 2267 OS << "enable"; 2268 else if (state == Full) 2269 OS << "full"; 2270 else if (state == AssumeSafety) 2271 OS << "assume_safety"; 2272 else 2273 OS << "disable"; 2274 OS << ")"; 2275 return OS.str(); 2276 } 2277 2278 // Return a string suitable for identifying this attribute in diagnostics. 2279 std::string getDiagnosticName(const PrintingPolicy &Policy) const { 2280 unsigned SpellingIndex = getSpellingListIndex(); 2281 if (SpellingIndex == Pragma_nounroll) 2282 return "#pragma nounroll"; 2283 else if (SpellingIndex == Pragma_unroll) 2284 return "#pragma unroll" + (option == UnrollCount ? getValueString(Policy) : ""); 2285 2286 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling"); 2287 return getOptionName(option) + getValueString(Policy); 2288 } 2289 }]; 2290 2291 let Documentation = [LoopHintDocs, UnrollHintDocs]; 2292} 2293 2294def CapturedRecord : InheritableAttr { 2295 // This attribute has no spellings as it is only ever created implicitly. 2296 let Spellings = []; 2297 let SemaHandler = 0; 2298 let Documentation = [Undocumented]; 2299} 2300 2301def OMPThreadPrivateDecl : InheritableAttr { 2302 // This attribute has no spellings as it is only ever created implicitly. 2303 let Spellings = []; 2304 let SemaHandler = 0; 2305 let Documentation = [Undocumented]; 2306} 2307 2308def OMPCaptureNoInit : InheritableAttr { 2309 // This attribute has no spellings as it is only ever created implicitly. 2310 let Spellings = []; 2311 let SemaHandler = 0; 2312 let Documentation = [Undocumented]; 2313} 2314 2315def OMPDeclareSimdDecl : Attr { 2316 let Spellings = [Pragma<"omp", "declare simd">]; 2317 let Subjects = SubjectList<[Function]>; 2318 let SemaHandler = 0; 2319 let HasCustomParsing = 1; 2320 let Documentation = [OMPDeclareSimdDocs]; 2321 let Args = [ 2322 EnumArgument<"BranchState", "BranchStateTy", 2323 [ "", "inbranch", "notinbranch" ], 2324 [ "BS_Undefined", "BS_Inbranch", "BS_Notinbranch" ]>, 2325 ExprArgument<"Simdlen">, VariadicExprArgument<"Uniforms">, 2326 VariadicExprArgument<"Aligneds">, VariadicExprArgument<"Alignments">, 2327 VariadicExprArgument<"Linears">, VariadicUnsignedArgument<"Modifiers">, 2328 VariadicExprArgument<"Steps"> 2329 ]; 2330 let AdditionalMembers = [{ 2331 void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy) 2332 const { 2333 if (getBranchState() != BS_Undefined) 2334 OS << ConvertBranchStateTyToStr(getBranchState()) << " "; 2335 if (auto *E = getSimdlen()) { 2336 OS << "simdlen("; 2337 E->printPretty(OS, nullptr, Policy); 2338 OS << ") "; 2339 } 2340 if (uniforms_size() > 0) { 2341 OS << "uniform"; 2342 StringRef Sep = "("; 2343 for (auto *E : uniforms()) { 2344 OS << Sep; 2345 E->printPretty(OS, nullptr, Policy); 2346 Sep = ", "; 2347 } 2348 OS << ") "; 2349 } 2350 alignments_iterator NI = alignments_begin(); 2351 for (auto *E : aligneds()) { 2352 OS << "aligned("; 2353 E->printPretty(OS, nullptr, Policy); 2354 if (*NI) { 2355 OS << ": "; 2356 (*NI)->printPretty(OS, nullptr, Policy); 2357 } 2358 OS << ") "; 2359 ++NI; 2360 } 2361 steps_iterator I = steps_begin(); 2362 modifiers_iterator MI = modifiers_begin(); 2363 for (auto *E : linears()) { 2364 OS << "linear("; 2365 if (*MI != OMPC_LINEAR_unknown) 2366 OS << getOpenMPSimpleClauseTypeName(OMPC_linear, *MI) << "("; 2367 E->printPretty(OS, nullptr, Policy); 2368 if (*MI != OMPC_LINEAR_unknown) 2369 OS << ")"; 2370 if (*I) { 2371 OS << ": "; 2372 (*I)->printPretty(OS, nullptr, Policy); 2373 } 2374 OS << ") "; 2375 ++I; 2376 ++MI; 2377 } 2378 } 2379 }]; 2380} 2381 2382def OMPDeclareTargetDecl : Attr { 2383 let Spellings = [Pragma<"omp", "declare target">]; 2384 let SemaHandler = 0; 2385 let Documentation = [OMPDeclareTargetDocs]; 2386 let Args = [ 2387 EnumArgument<"MapType", "MapTypeTy", 2388 [ "to", "link" ], 2389 [ "MT_To", "MT_Link" ]> 2390 ]; 2391 let AdditionalMembers = [{ 2392 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const { 2393 // Use fake syntax because it is for testing and debugging purpose only. 2394 if (getMapType() != MT_To) 2395 OS << ConvertMapTypeTyToStr(getMapType()) << " "; 2396 } 2397 }]; 2398} 2399 2400def InternalLinkage : InheritableAttr { 2401 let Spellings = [GNU<"internal_linkage">, CXX11<"clang", "internal_linkage">]; 2402 let Subjects = SubjectList<[Var, Function, CXXRecord]>; 2403 let Documentation = [InternalLinkageDocs]; 2404} 2405