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