]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Basic/Attr.td
Merge ^/head r279893 through r279984.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / Basic / Attr.td
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 NonBitField : SubsetSubject<Field,
86                                 [{!S->isBitField()}]>;
87
88 def ObjCInstanceMethod : SubsetSubject<ObjCMethod,
89                                        [{S->isInstanceMethod()}]>;
90
91 def ObjCInterfaceDeclInitMethod : SubsetSubject<ObjCMethod,
92                                [{S->getMethodFamily() == OMF_init &&
93                                  (isa<ObjCInterfaceDecl>(S->getDeclContext()) ||
94                                   (isa<ObjCCategoryDecl>(S->getDeclContext()) &&
95             cast<ObjCCategoryDecl>(S->getDeclContext())->IsClassExtension()))}]>;
96
97 def Struct : SubsetSubject<Record,
98                            [{!S->isUnion()}]>;
99
100 def TLSVar : SubsetSubject<Var,
101                            [{S->getTLSKind() != 0}]>;
102
103 def SharedVar : SubsetSubject<Var,
104                               [{S->hasGlobalStorage() && !S->getTLSKind()}]>;
105
106 def GlobalVar : SubsetSubject<Var,
107                              [{S->hasGlobalStorage()}]>;
108
109 // FIXME: this hack is needed because DeclNodes.td defines the base Decl node
110 // type to be a class, not a definition. This makes it impossible to create an
111 // attribute subject which accepts a Decl. Normally, this is not a problem,
112 // because the attribute can have no Subjects clause to accomplish this. But in
113 // the case of a SubsetSubject, there's no way to express it without this hack.
114 def DeclBase : AttrSubject;
115 def FunctionLike : SubsetSubject<DeclBase,
116                                   [{S->getFunctionType(false) != NULL}]>;
117
118 def OpenCLKernelFunction : SubsetSubject<Function, [{
119   S->hasAttr<OpenCLKernelAttr>()
120 }]>;
121
122 // HasFunctionProto is a more strict version of FunctionLike, so it should
123 // never be specified in a Subjects list along with FunctionLike (due to the
124 // inclusive nature of subject testing).
125 def HasFunctionProto : SubsetSubject<DeclBase,
126                                      [{(S->getFunctionType(true) != NULL &&
127                               isa<FunctionProtoType>(S->getFunctionType())) ||
128                                        isa<ObjCMethodDecl>(S) ||
129                                        isa<BlockDecl>(S)}]>;
130
131 // A single argument to an attribute
132 class Argument<string name, bit optional> {
133   string Name = name;
134   bit Optional = optional;
135 }
136
137 class BoolArgument<string name, bit opt = 0> : Argument<name, opt>;
138 class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>;
139 class IntArgument<string name, bit opt = 0> : Argument<name, opt>;
140 class StringArgument<string name, bit opt = 0> : Argument<name, opt>;
141 class ExprArgument<string name, bit opt = 0> : Argument<name, opt>;
142 class FunctionArgument<string name, bit opt = 0> : Argument<name, opt>;
143 class TypeArgument<string name, bit opt = 0> : Argument<name, opt>;
144 class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>;
145 class VariadicUnsignedArgument<string name> : Argument<name, 1>;
146 class VariadicExprArgument<string name> : Argument<name, 1>;
147
148 // A version of the form major.minor[.subminor].
149 class VersionArgument<string name, bit opt = 0> : Argument<name, opt>;
150
151 // This one's a doozy, so it gets its own special type
152 // It can be an unsigned integer, or a type. Either can
153 // be dependent.
154 class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>;
155
156 // A bool argument with a default value
157 class DefaultBoolArgument<string name, bit default> : BoolArgument<name, 1> {
158   bit Default = default;
159 }
160
161 // An integer argument with a default value
162 class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
163   int Default = default;
164 }
165
166 // This argument is more complex, it includes the enumerator type name,
167 // a list of strings to accept, and a list of enumerators to map them to.
168 class EnumArgument<string name, string type, list<string> values,
169                    list<string> enums, bit opt = 0> : Argument<name, opt> {
170   string Type = type;
171   list<string> Values = values;
172   list<string> Enums = enums;
173 }
174
175 // FIXME: There should be a VariadicArgument type that takes any other type
176 //        of argument and generates the appropriate type.
177 class VariadicEnumArgument<string name, string type, list<string> values,
178                            list<string> enums> : Argument<name, 1>  {
179   string Type = type;
180   list<string> Values = values;
181   list<string> Enums = enums;
182 }
183
184 // This handles one spelling of an attribute.
185 class Spelling<string name, string variety> {
186   string Name = name;
187   string Variety = variety;
188   bit KnownToGCC;
189 }
190
191 class GNU<string name> : Spelling<name, "GNU">;
192 class Declspec<string name> : Spelling<name, "Declspec">;
193 class CXX11<string namespace, string name, int version = 1>
194     : Spelling<name, "CXX11"> {
195   string Namespace = namespace;
196   int Version = version;
197 } class Keyword<string name> : Spelling<name, "Keyword">;
198 class Pragma<string namespace, string name> : Spelling<name, "Pragma"> {
199   string Namespace = namespace;
200 }
201
202 // The GCC spelling implies GNU<name, "GNU"> and CXX11<"gnu", name> and also
203 // sets KnownToGCC to 1. This spelling should be used for any GCC-compatible
204 // attributes.
205 class GCC<string name> : Spelling<name, "GCC"> {
206   let KnownToGCC = 1;
207 }
208
209 class Accessor<string name, list<Spelling> spellings> {
210   string Name = name;
211   list<Spelling> Spellings = spellings;
212 }
213
214 class SubjectDiag<bit warn> {
215   bit Warn = warn;
216 }
217 def WarnDiag : SubjectDiag<1>;
218 def ErrorDiag : SubjectDiag<0>;
219
220 class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag,
221                   string customDiag = ""> {
222   list<AttrSubject> Subjects = subjects;
223   SubjectDiag Diag = diag;
224   string CustomDiag = customDiag;
225 }
226
227 class LangOpt<string name> {
228   string Name = name;
229 }
230 def MicrosoftExt : LangOpt<"MicrosoftExt">;
231 def Borland : LangOpt<"Borland">;
232 def CUDA : LangOpt<"CUDA">;
233
234 // Defines targets for target-specific attributes. The list of strings should
235 // specify architectures for which the target applies, based off the ArchType
236 // enumeration in Triple.h.
237 class TargetArch<list<string> arches> {
238   list<string> Arches = arches;
239   list<string> OSes;
240 }
241 def TargetARM : TargetArch<["arm", "thumb"]>;
242 def TargetMSP430 : TargetArch<["msp430"]>;
243 def TargetX86 : TargetArch<["x86"]>;
244 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
245   let OSes = ["Win32"];
246 }
247 def TargetMips : TargetArch<["mips", "mipsel"]>;
248
249 class Attr {
250   // The various ways in which an attribute can be spelled in source
251   list<Spelling> Spellings;
252   // The things to which an attribute can appertain
253   SubjectList Subjects;
254   // The arguments allowed on an attribute
255   list<Argument> Args = [];
256   // Accessors which should be generated for the attribute.
257   list<Accessor> Accessors = [];
258   // Set to true for attributes with arguments which require delayed parsing.
259   bit LateParsed = 0;
260   // Set to false to prevent an attribute from being propagated from a template
261   // to the instantiation.
262   bit Clone = 1;
263   // Set to true for attributes which must be instantiated within templates
264   bit TemplateDependent = 0;
265   // Set to true for attributes that have a corresponding AST node.
266   bit ASTNode = 1;
267   // Set to true for attributes which have handler in Sema.
268   bit SemaHandler = 1;
269   // Set to true for attributes that are completely ignored.
270   bit Ignored = 0;
271   // Set to true if the attribute's parsing does not match its semantic
272   // content. Eg) It parses 3 args, but semantically takes 4 args.  Opts out of
273   // common attribute error checking.
274   bit HasCustomParsing = 0;
275   // Set to true if all of the attribute's arguments should be parsed in an
276   // unevaluated context.
277   bit ParseArgumentsAsUnevaluated = 0;
278   // Set to true if this attribute can be duplicated on a subject when merging
279   // attributes. By default, attributes are not merged.
280   bit DuplicatesAllowedWhileMerging = 0;
281   // Lists language options, one of which is required to be true for the
282   // attribute to be applicable. If empty, no language options are required.
283   list<LangOpt> LangOpts = [];
284   // Any additional text that should be included verbatim in the class.
285   code AdditionalMembers = [{}];
286   // Any documentation that should be associated with the attribute. Since an
287   // attribute may be documented under multiple categories, more than one
288   // Documentation entry may be listed.
289   list<Documentation> Documentation;
290 }
291
292 /// A type attribute is not processed on a declaration or a statement.
293 class TypeAttr : Attr {
294   // By default, type attributes do not get an AST node.
295   let ASTNode = 0;
296 }
297
298 /// An inheritable attribute is inherited by later redeclarations.
299 class InheritableAttr : Attr;
300
301 /// A target-specific attribute.  This class is meant to be used as a mixin
302 /// with InheritableAttr or Attr depending on the attribute's needs.
303 class TargetSpecificAttr<TargetArch target> {
304   TargetArch Target = target;
305   // Attributes are generally required to have unique spellings for their names
306   // so that the parser can determine what kind of attribute it has parsed.
307   // However, target-specific attributes are special in that the attribute only
308   // "exists" for a given target. So two target-specific attributes can share
309   // the same name when they exist in different targets. To support this, a
310   // Kind can be explicitly specified for a target-specific attribute. This
311   // corresponds to the AttributeList::AT_* enum that is generated and it
312   // should contain a shared value between the attributes.
313   //
314   // Target-specific attributes which use this feature should ensure that the
315   // spellings match exactly betweeen the attributes, and if the arguments or
316   // subjects differ, should specify HasCustomParsing = 1 and implement their
317   // own parsing and semantic handling requirements as-needed.
318   string ParseKind;
319 }
320
321 /// An inheritable parameter attribute is inherited by later
322 /// redeclarations, even when it's written on a parameter.
323 class InheritableParamAttr : InheritableAttr;
324
325 /// An ignored attribute, which we parse but discard with no checking.
326 class IgnoredAttr : Attr {
327   let Ignored = 1;
328   let ASTNode = 0;
329   let SemaHandler = 0;
330   let Documentation = [Undocumented];
331 }
332
333 //
334 // Attributes begin here
335 //
336
337 def AddressSpace : TypeAttr {
338   let Spellings = [GNU<"address_space">];
339   let Args = [IntArgument<"AddressSpace">];
340   let Documentation = [Undocumented];
341 }
342
343 def Alias : Attr {
344   let Spellings = [GCC<"alias">];
345   let Args = [StringArgument<"Aliasee">];
346   let Documentation = [Undocumented];
347 }
348
349 def Aligned : InheritableAttr {
350   let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">,
351                    Keyword<"_Alignas">];
352 //  let Subjects = SubjectList<[NonBitField, NormalVar, Tag]>;
353   let Args = [AlignedArgument<"Alignment", 1>];
354   let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
355                    Accessor<"isC11", [Keyword<"_Alignas">]>,
356                    Accessor<"isAlignas", [Keyword<"alignas">,
357                                           Keyword<"_Alignas">]>,
358                    Accessor<"isDeclspec",[Declspec<"align">]>];
359   let Documentation = [Undocumented];
360 }
361
362 def AlignValue : Attr {
363   let Spellings = [
364     // Unfortunately, this is semantically an assertion, not a directive
365     // (something else must ensure the alignment), so aligned_value is a
366     // probably a better name. We might want to add an aligned_value spelling in
367     // the future (and a corresponding C++ attribute), but this can be done
368     // later once we decide if we also want them to have slightly-different
369     // semantics than Intel's align_value.
370     GNU<"align_value">
371     // Intel's compiler on Windows also supports:
372     // , Declspec<"align_value">
373   ];
374   let Args = [ExprArgument<"Alignment">];
375   let Subjects = SubjectList<[Var, TypedefName], WarnDiag,
376                              "ExpectedVariableOrTypedef">;
377   let Documentation = [AlignValueDocs];
378 }
379
380 def AlignMac68k : InheritableAttr {
381   // This attribute has no spellings as it is only ever created implicitly.
382   let Spellings = [];
383   let SemaHandler = 0;
384   let Documentation = [Undocumented];
385 }
386
387 def AlwaysInline : InheritableAttr {
388   let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
389   let Subjects = SubjectList<[Function]>;
390   let Documentation = [Undocumented];
391 }
392
393 def TLSModel : InheritableAttr {
394   let Spellings = [GCC<"tls_model">];
395   let Subjects = SubjectList<[TLSVar], ErrorDiag, "ExpectedTLSVar">;
396   let Args = [StringArgument<"Model">];
397   let Documentation = [TLSModelDocs];
398 }
399
400 def AnalyzerNoReturn : InheritableAttr {
401   let Spellings = [GNU<"analyzer_noreturn">];
402   let Documentation = [Undocumented];
403 }
404
405 def Annotate : InheritableParamAttr {
406   let Spellings = [GNU<"annotate">];
407   let Args = [StringArgument<"Annotation">];
408   let Documentation = [Undocumented];
409 }
410
411 def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> {
412   // NOTE: If you add any additional spellings, MSP430Interrupt's spellings
413   // must match.
414   let Spellings = [GNU<"interrupt">];
415   let Args = [EnumArgument<"Interrupt", "InterruptType",
416                            ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
417                            ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
418                            1>];
419   let ParseKind = "Interrupt";
420   let HasCustomParsing = 1;
421   let Documentation = [ARMInterruptDocs];
422 }
423
424 def AsmLabel : InheritableAttr {
425   let Spellings = [Keyword<"asm">, Keyword<"__asm__">];
426   let Args = [StringArgument<"Label">];
427   let SemaHandler = 0;
428   let Documentation = [Undocumented];
429 }
430
431 def Availability : InheritableAttr {
432   let Spellings = [GNU<"availability">];
433   let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
434               VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
435               BoolArgument<"unavailable">, StringArgument<"message">];
436   let AdditionalMembers =
437 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
438     return llvm::StringSwitch<llvm::StringRef>(Platform)
439              .Case("ios", "iOS")
440              .Case("macosx", "OS X")
441              .Default(llvm::StringRef());
442 } }];
443   let HasCustomParsing = 1;
444   let DuplicatesAllowedWhileMerging = 1;
445 //  let Subjects = SubjectList<[Named]>;
446   let Documentation = [AvailabilityDocs];
447 }
448
449 def Blocks : InheritableAttr {
450   let Spellings = [GNU<"blocks">];
451   let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
452   let Documentation = [Undocumented];
453 }
454
455 def Bounded : IgnoredAttr {
456   let Spellings = [GNU<"bounded">];
457 }
458
459 def CarriesDependency : InheritableParamAttr {
460   let Spellings = [GNU<"carries_dependency">,
461                    CXX11<"","carries_dependency", 200809>];
462   let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>;
463   let Documentation = [CarriesDependencyDocs];
464 }
465
466 def CDecl : InheritableAttr {
467   let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">];
468 //  let Subjects = [Function, ObjCMethod];
469   let Documentation = [Undocumented];
470 }
471
472 // cf_audited_transfer indicates that the given function has been
473 // audited and has been marked with the appropriate cf_consumed and
474 // cf_returns_retained attributes.  It is generally applied by
475 // '#pragma clang arc_cf_code_audited' rather than explicitly.
476 def CFAuditedTransfer : InheritableAttr {
477   let Spellings = [GNU<"cf_audited_transfer">];
478   let Subjects = SubjectList<[Function], ErrorDiag>;
479   let Documentation = [Undocumented];
480 }
481
482 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
483 // It indicates that the function has unknown or unautomatable
484 // transfer semantics.
485 def CFUnknownTransfer : InheritableAttr {
486   let Spellings = [GNU<"cf_unknown_transfer">];
487   let Subjects = SubjectList<[Function], ErrorDiag>;
488   let Documentation = [Undocumented];
489 }
490
491 def CFReturnsRetained : InheritableAttr {
492   let Spellings = [GNU<"cf_returns_retained">];
493 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
494   let Documentation = [Undocumented];
495 }
496
497 def CFReturnsNotRetained : InheritableAttr {
498   let Spellings = [GNU<"cf_returns_not_retained">];
499 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
500   let Documentation = [Undocumented];
501 }
502
503 def CFConsumed : InheritableParamAttr {
504   let Spellings = [GNU<"cf_consumed">];
505   let Subjects = SubjectList<[ParmVar]>;
506   let Documentation = [Undocumented];
507 }
508
509 def Cleanup : InheritableAttr {
510   let Spellings = [GCC<"cleanup">];
511   let Args = [FunctionArgument<"FunctionDecl">];
512   let Subjects = SubjectList<[Var]>;
513   let Documentation = [Undocumented];
514 }
515
516 def Cold : InheritableAttr {
517   let Spellings = [GCC<"cold">];
518   let Subjects = SubjectList<[Function]>;
519   let Documentation = [Undocumented];
520 }
521
522 def Common : InheritableAttr {
523   let Spellings = [GCC<"common">];
524   let Subjects = SubjectList<[Var]>;
525   let Documentation = [Undocumented];
526 }
527
528 def Const : InheritableAttr {
529   let Spellings = [GCC<"const">, GCC<"__const">];
530   let Documentation = [Undocumented];
531 }
532
533 def Constructor : InheritableAttr {
534   let Spellings = [GCC<"constructor">];
535   let Args = [DefaultIntArgument<"Priority", 65535>];
536   let Subjects = SubjectList<[Function]>;
537   let Documentation = [Undocumented];
538 }
539
540 def CUDAConstant : InheritableAttr {
541   let Spellings = [GNU<"constant">];
542   let Subjects = SubjectList<[Var]>;
543   let LangOpts = [CUDA];
544   let Documentation = [Undocumented];
545 }
546
547 def CUDADevice : InheritableAttr {
548   let Spellings = [GNU<"device">];
549   let Subjects = SubjectList<[Function, Var]>;
550   let LangOpts = [CUDA];
551   let Documentation = [Undocumented];
552 }
553
554 def CUDAGlobal : InheritableAttr {
555   let Spellings = [GNU<"global">];
556   let Subjects = SubjectList<[Function]>;
557   let LangOpts = [CUDA];
558   let Documentation = [Undocumented];
559 }
560
561 def CUDAHost : InheritableAttr {
562   let Spellings = [GNU<"host">];
563   let Subjects = SubjectList<[Function]>;
564   let LangOpts = [CUDA];
565   let Documentation = [Undocumented];
566 }
567
568 def CUDAInvalidTarget : InheritableAttr {
569   let Spellings = [];
570   let Subjects = SubjectList<[Function]>;
571   let LangOpts = [CUDA];
572   let Documentation = [Undocumented];
573 }
574
575 def CUDALaunchBounds : InheritableAttr {
576   let Spellings = [GNU<"launch_bounds">];
577   let Args = [IntArgument<"MaxThreads">, DefaultIntArgument<"MinBlocks", 0>];
578   let LangOpts = [CUDA];
579   let Subjects = SubjectList<[ObjCMethod, FunctionLike], WarnDiag,
580                              "ExpectedFunctionOrMethod">;
581   // An AST node is created for this attribute, but is not used by other parts
582   // of the compiler. However, this node needs to exist in the AST because
583   // non-LLVM backends may be relying on the attribute's presence.
584   let Documentation = [Undocumented];
585 }
586
587 def CUDAShared : InheritableAttr {
588   let Spellings = [GNU<"shared">];
589   let Subjects = SubjectList<[Var]>;
590   let LangOpts = [CUDA];
591   let Documentation = [Undocumented];
592 }
593
594 def C11NoReturn : InheritableAttr {
595   let Spellings = [Keyword<"_Noreturn">];
596   let Subjects = SubjectList<[Function], ErrorDiag>;
597   let SemaHandler = 0;
598   let Documentation = [C11NoReturnDocs];
599 }
600
601 def CXX11NoReturn : InheritableAttr {
602   let Spellings = [CXX11<"","noreturn", 200809>];
603   let Subjects = SubjectList<[Function], ErrorDiag>;
604   let Documentation = [CXX11NoReturnDocs];
605 }
606
607 def OpenCLKernel : InheritableAttr {
608   let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
609   let Subjects = SubjectList<[Function], ErrorDiag>;
610   let Documentation = [Undocumented];
611 }
612
613 // This attribute is both a type attribute, and a declaration attribute (for
614 // parameter variables).
615 def OpenCLImageAccess : Attr {
616   let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
617                    Keyword<"__write_only">, Keyword<"write_only">,
618                    Keyword<"__read_write">, Keyword<"read_write">];
619   let Subjects = SubjectList<[ParmVar], ErrorDiag>;
620   let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
621                                            Keyword<"read_only">]>,
622                    Accessor<"isReadWrite", [Keyword<"__read_write">,
623                                             Keyword<"read_write">]>,
624                    Accessor<"isWriteOnly", [Keyword<"__write_only">,
625                                             Keyword<"write_only">]>];
626   let Documentation = [Undocumented];
627 }
628
629 def OpenCLPrivateAddressSpace : TypeAttr {
630   let Spellings = [Keyword<"__private">, Keyword<"private">];
631   let Documentation = [OpenCLAddressSpacePrivateDocs];
632 }
633
634 def OpenCLGlobalAddressSpace : TypeAttr {
635   let Spellings = [Keyword<"__global">, Keyword<"global">];
636   let Documentation = [OpenCLAddressSpaceGlobalDocs];
637 }
638
639 def OpenCLLocalAddressSpace : TypeAttr {
640   let Spellings = [Keyword<"__local">, Keyword<"local">];
641   let Documentation = [OpenCLAddressSpaceLocalDocs];
642 }
643
644 def OpenCLConstantAddressSpace : TypeAttr {
645   let Spellings = [Keyword<"__constant">, Keyword<"constant">];
646   let Documentation = [OpenCLAddressSpaceConstantDocs];
647 }
648
649 def OpenCLGenericAddressSpace : TypeAttr {
650   let Spellings = [Keyword<"__generic">, Keyword<"generic">];
651   let Documentation = [OpenCLAddressSpaceGenericDocs];
652 }
653
654 def Deprecated : InheritableAttr {
655   let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
656                    CXX11<"","deprecated", 201309>];
657   let Args = [StringArgument<"Message", 1>];
658   let Documentation = [Undocumented];
659 }
660
661 def Destructor : InheritableAttr {
662   let Spellings = [GCC<"destructor">];
663   let Args = [DefaultIntArgument<"Priority", 65535>];
664   let Subjects = SubjectList<[Function]>;
665   let Documentation = [Undocumented];
666 }
667
668 def EnableIf : InheritableAttr {
669   let Spellings = [GNU<"enable_if">];
670   let Subjects = SubjectList<[Function]>;
671   let Args = [ExprArgument<"Cond">, StringArgument<"Message">];
672   let TemplateDependent = 1;
673   let Documentation = [EnableIfDocs];
674 }
675
676 def ExtVectorType : Attr {
677   let Spellings = [GNU<"ext_vector_type">];
678   let Subjects = SubjectList<[TypedefName], ErrorDiag>;
679   let Args = [ExprArgument<"NumElements">];
680   let ASTNode = 0;
681   let Documentation = [Undocumented];
682 }
683
684 def FallThrough : Attr {
685   let Spellings = [CXX11<"clang", "fallthrough">];
686 //  let Subjects = [NullStmt];
687   let Documentation = [FallthroughDocs];
688 }
689
690 def FastCall : InheritableAttr {
691   let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
692                    Keyword<"_fastcall">];
693 //  let Subjects = [Function, ObjCMethod];
694   let Documentation = [FastCallDocs];
695 }
696
697 def Final : InheritableAttr {
698   let Spellings = [Keyword<"final">, Keyword<"sealed">];
699   let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
700   let SemaHandler = 0;
701   let Documentation = [Undocumented];
702 }
703
704 def MinSize : InheritableAttr {
705   let Spellings = [GNU<"minsize">];
706   let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
707   let Documentation = [Undocumented];
708 }
709
710 def Flatten : InheritableAttr {
711   let Spellings = [GCC<"flatten">];
712   let Subjects = SubjectList<[Function], ErrorDiag>;
713   let Documentation = [FlattenDocs];
714 }
715
716 def Format : InheritableAttr {
717   let Spellings = [GCC<"format">];
718   let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
719               IntArgument<"FirstArg">];
720   let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto], WarnDiag,
721                              "ExpectedFunction">;
722   let Documentation = [FormatDocs];
723 }
724
725 def FormatArg : InheritableAttr {
726   let Spellings = [GCC<"format_arg">];
727   let Args = [IntArgument<"FormatIdx">];
728   let Subjects = SubjectList<[ObjCMethod, HasFunctionProto], WarnDiag,
729                              "ExpectedFunction">;
730   let Documentation = [Undocumented];
731 }
732
733 def GNUInline : InheritableAttr {
734   let Spellings = [GCC<"gnu_inline">];
735   let Subjects = SubjectList<[Function]>;
736   let Documentation = [Undocumented];
737 }
738
739 def Hot : InheritableAttr {
740   let Spellings = [GCC<"hot">];
741   let Subjects = SubjectList<[Function]>;
742   // An AST node is created for this attribute, but not actually used beyond
743   // semantic checking for mutual exclusion with the Cold attribute.
744   let Documentation = [Undocumented];
745 }
746
747 def IBAction : InheritableAttr {
748   let Spellings = [GNU<"ibaction">];
749   let Subjects = SubjectList<[ObjCInstanceMethod], WarnDiag,
750                              "ExpectedObjCInstanceMethod">;
751   // An AST node is created for this attribute, but is not used by other parts
752   // of the compiler. However, this node needs to exist in the AST because
753   // external tools rely on it.
754   let Documentation = [Undocumented];
755 }
756
757 def IBOutlet : InheritableAttr {
758   let Spellings = [GNU<"iboutlet">];
759 //  let Subjects = [ObjCIvar, ObjCProperty];
760   let Documentation = [Undocumented];
761 }
762
763 def IBOutletCollection : InheritableAttr {
764   let Spellings = [GNU<"iboutletcollection">];
765   let Args = [TypeArgument<"Interface", 1>];
766 //  let Subjects = [ObjCIvar, ObjCProperty];
767   let Documentation = [Undocumented];
768 }
769
770 def Malloc : InheritableAttr {
771   let Spellings = [GCC<"malloc">];
772 //  let Subjects = [Function];
773   let Documentation = [Undocumented];
774 }
775
776 def MaxFieldAlignment : InheritableAttr {
777   // This attribute has no spellings as it is only ever created implicitly.
778   let Spellings = [];
779   let Args = [UnsignedArgument<"Alignment">];
780   let SemaHandler = 0;
781   let Documentation = [Undocumented];
782 }
783
784 def MayAlias : InheritableAttr {
785   // FIXME: this is a type attribute in GCC, but a declaration attribute here.
786   let Spellings = [GCC<"may_alias">];
787   let Documentation = [Undocumented];
788 }
789
790 def MSABI : InheritableAttr {
791   let Spellings = [GCC<"ms_abi">];
792 //  let Subjects = [Function, ObjCMethod];
793   let Documentation = [MSABIDocs];
794 }
795
796 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
797   // NOTE: If you add any additional spellings, ARMInterrupt's spellings must
798   // match.
799   let Spellings = [GNU<"interrupt">];
800   let Args = [UnsignedArgument<"Number">];
801   let ParseKind = "Interrupt";
802   let HasCustomParsing = 1;
803   let Documentation = [Undocumented];
804 }
805
806 def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
807   let Spellings = [GCC<"mips16">];
808   let Subjects = SubjectList<[Function], ErrorDiag>;
809   let Documentation = [Undocumented];
810 }
811
812 def Mode : Attr {
813   let Spellings = [GCC<"mode">];
814   let Args = [IdentifierArgument<"Mode">];
815   let Documentation = [Undocumented];
816 }
817
818 def Naked : InheritableAttr {
819   let Spellings = [GCC<"naked">, Declspec<"naked">];
820   let Subjects = SubjectList<[Function]>;
821   let Documentation = [Undocumented];
822 }
823
824 def NeonPolyVectorType : TypeAttr {
825   let Spellings = [GNU<"neon_polyvector_type">];
826   let Args = [IntArgument<"NumElements">];
827   let Documentation = [Undocumented];
828 }
829
830 def NeonVectorType : TypeAttr {
831   let Spellings = [GNU<"neon_vector_type">];
832   let Args = [IntArgument<"NumElements">];
833   let Documentation = [Undocumented];
834 }
835
836 def ReturnsTwice : InheritableAttr {
837   let Spellings = [GCC<"returns_twice">];
838   let Subjects = SubjectList<[Function]>;
839   let Documentation = [Undocumented];
840 }
841
842 def NoCommon : InheritableAttr {
843   let Spellings = [GCC<"nocommon">];
844   let Subjects = SubjectList<[Var]>;
845   let Documentation = [Undocumented];
846 }
847
848 def NoDebug : InheritableAttr {
849   let Spellings = [GCC<"nodebug">];
850   let Documentation = [Undocumented];
851 }
852
853 def NoDuplicate : InheritableAttr {
854   let Spellings = [GNU<"noduplicate">, CXX11<"clang", "noduplicate">];
855   let Subjects = SubjectList<[Function]>;
856   let Documentation = [NoDuplicateDocs];
857 }
858
859 def NoInline : InheritableAttr {
860   let Spellings = [GCC<"noinline">, Declspec<"noinline">];
861   let Subjects = SubjectList<[Function]>;
862   let Documentation = [Undocumented];
863 }
864
865 def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips> {
866   let Spellings = [GCC<"nomips16">];
867   let Subjects = SubjectList<[Function], ErrorDiag>;
868   let Documentation = [Undocumented];
869 }
870
871 // This is not a TargetSpecificAttr so that is silently accepted and
872 // ignored on other targets as encouraged by the OpenCL spec.
873 //
874 // See OpenCL 1.2 6.11.5: "It is our intention that a particular
875 // implementation of OpenCL be free to ignore all attributes and the
876 // resulting executable binary will produce the same result."
877 //
878 // However, only AMD GPU targets will emit the corresponding IR
879 // attribute.
880 //
881 // FIXME: This provides a sub-optimal error message if you attempt to
882 // use this in CUDA, since CUDA does not use the same terminology.
883 def AMDGPUNumVGPR : InheritableAttr {
884   let Spellings = [GNU<"amdgpu_num_vgpr">];
885   let Args = [UnsignedArgument<"NumVGPR">];
886   let Documentation = [AMDGPUNumVGPRDocs];
887
888 // FIXME: This should be for OpenCLKernelFunction, but is not to
889 // workaround needing to see kernel attribute before others to know if
890 // this should be rejected on non-kernels.
891   let Subjects = SubjectList<[Function], ErrorDiag,
892                              "ExpectedKernelFunction">;
893 }
894
895 def AMDGPUNumSGPR : InheritableAttr {
896   let Spellings = [GNU<"amdgpu_num_sgpr">];
897   let Args = [UnsignedArgument<"NumSGPR">];
898   let Documentation = [AMDGPUNumSGPRDocs];
899   let Subjects = SubjectList<[Function], ErrorDiag,
900                               "ExpectedKernelFunction">;
901 }
902
903 def NoSplitStack : InheritableAttr {
904   let Spellings = [GCC<"no_split_stack">];
905   let Subjects = SubjectList<[Function], ErrorDiag>;
906   let Documentation = [NoSplitStackDocs];
907 }
908
909 def NonNull : InheritableAttr {
910   let Spellings = [GCC<"nonnull">];
911   let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
912                              "ExpectedFunctionMethodOrParameter">;
913   let Args = [VariadicUnsignedArgument<"Args">];
914   let AdditionalMembers =
915 [{bool isNonNull(unsigned idx) const {
916     if (!args_size())
917       return true;
918     for (const auto &V : args())
919       if (V == idx)
920         return true;
921     return false;
922   } }];
923   // FIXME: We should merge duplicates into a single nonnull attribute.
924   let DuplicatesAllowedWhileMerging = 1;
925   let Documentation = [Undocumented];
926 }
927
928 def ReturnsNonNull : InheritableAttr {
929   let Spellings = [GCC<"returns_nonnull">];
930   let Subjects = SubjectList<[ObjCMethod, Function], WarnDiag,
931                              "ExpectedFunctionOrMethod">;
932   let Documentation = [Undocumented];
933 }
934
935 def AssumeAligned : InheritableAttr {
936   let Spellings = [GCC<"assume_aligned">];
937   let Subjects = SubjectList<[ObjCMethod, Function]>;
938   let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>];
939   let Documentation = [AssumeAlignedDocs];
940 }
941
942 def NoReturn : InheritableAttr {
943   let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
944   // FIXME: Does GCC allow this on the function instead?
945   let Documentation = [Undocumented];
946 }
947
948 def NoInstrumentFunction : InheritableAttr {
949   let Spellings = [GCC<"no_instrument_function">];
950   let Subjects = SubjectList<[Function]>;
951   let Documentation = [Undocumented];
952 }
953
954 def NoThrow : InheritableAttr {
955   let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
956   let Documentation = [Undocumented];
957 }
958
959 def ObjCBridge : InheritableAttr {
960   let Spellings = [GNU<"objc_bridge">];
961   let Subjects = SubjectList<[Record], ErrorDiag>;
962   let Args = [IdentifierArgument<"BridgedType">];
963   let Documentation = [Undocumented];
964 }
965
966 def ObjCBridgeMutable : InheritableAttr {
967   let Spellings = [GNU<"objc_bridge_mutable">];
968   let Subjects = SubjectList<[Record], ErrorDiag>;
969   let Args = [IdentifierArgument<"BridgedType">];
970   let Documentation = [Undocumented];
971 }
972
973 def ObjCBridgeRelated : InheritableAttr {
974   let Spellings = [GNU<"objc_bridge_related">];
975   let Subjects = SubjectList<[Record], ErrorDiag>;
976   let Args = [IdentifierArgument<"RelatedClass">,
977           IdentifierArgument<"ClassMethod">,
978           IdentifierArgument<"InstanceMethod">];
979   let HasCustomParsing = 1;
980   let Documentation = [Undocumented];
981 }
982
983 def NSReturnsRetained : InheritableAttr {
984   let Spellings = [GNU<"ns_returns_retained">];
985 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
986   let Documentation = [Undocumented];
987 }
988
989 def NSReturnsNotRetained : InheritableAttr {
990   let Spellings = [GNU<"ns_returns_not_retained">];
991 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
992   let Documentation = [Undocumented];
993 }
994
995 def NSReturnsAutoreleased : InheritableAttr {
996   let Spellings = [GNU<"ns_returns_autoreleased">];
997 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
998   let Documentation = [Undocumented];
999 }
1000
1001 def NSConsumesSelf : InheritableAttr {
1002   let Spellings = [GNU<"ns_consumes_self">];
1003   let Subjects = SubjectList<[ObjCMethod]>;
1004   let Documentation = [Undocumented];
1005 }
1006
1007 def NSConsumed : InheritableParamAttr {
1008   let Spellings = [GNU<"ns_consumed">];
1009   let Subjects = SubjectList<[ParmVar]>;
1010   let Documentation = [Undocumented];
1011 }
1012
1013 def ObjCException : InheritableAttr {
1014   let Spellings = [GNU<"objc_exception">];
1015   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1016   let Documentation = [Undocumented];
1017 }
1018
1019 def ObjCMethodFamily : InheritableAttr {
1020   let Spellings = [GNU<"objc_method_family">];
1021   let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1022   let Args = [EnumArgument<"Family", "FamilyKind",
1023                ["none", "alloc", "copy", "init", "mutableCopy", "new"],
1024                ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
1025                 "OMF_mutableCopy", "OMF_new"]>];
1026   let Documentation = [ObjCMethodFamilyDocs];
1027 }
1028
1029 def ObjCNSObject : InheritableAttr {
1030   let Spellings = [GNU<"NSObject">];
1031   let Documentation = [Undocumented];
1032 }
1033
1034 def ObjCPreciseLifetime : InheritableAttr {
1035   let Spellings = [GNU<"objc_precise_lifetime">];
1036   let Subjects = SubjectList<[Var], ErrorDiag>;
1037   let Documentation = [Undocumented];
1038 }
1039
1040 def ObjCReturnsInnerPointer : InheritableAttr {
1041   let Spellings = [GNU<"objc_returns_inner_pointer">];
1042   let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
1043   let Documentation = [Undocumented];
1044 }
1045
1046 def ObjCRequiresSuper : InheritableAttr {
1047   let Spellings = [GNU<"objc_requires_super">];
1048   let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
1049   let Documentation = [ObjCRequiresSuperDocs];
1050 }
1051
1052 def ObjCRootClass : InheritableAttr {
1053   let Spellings = [GNU<"objc_root_class">];
1054   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1055   let Documentation = [Undocumented];
1056 }
1057
1058 def ObjCExplicitProtocolImpl : InheritableAttr {
1059   let Spellings = [GNU<"objc_protocol_requires_explicit_implementation">];
1060   let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
1061   let Documentation = [Undocumented];
1062 }
1063
1064 def ObjCDesignatedInitializer : Attr {
1065   let Spellings = [GNU<"objc_designated_initializer">];
1066   let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag,
1067                              "ExpectedObjCInterfaceDeclInitMethod">;
1068   let Documentation = [Undocumented];
1069 }
1070
1071 def ObjCRuntimeName : Attr {
1072   let Spellings = [GNU<"objc_runtime_name">];
1073   let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
1074   let Args = [StringArgument<"MetadataName">];
1075   let Documentation = [ObjCRuntimeNameDocs];
1076 }
1077
1078 def OptimizeNone : InheritableAttr {
1079   let Spellings = [GNU<"optnone">, CXX11<"clang", "optnone">];
1080   let Subjects = SubjectList<[Function, ObjCMethod]>;
1081   let Documentation = [OptnoneDocs];
1082 }
1083
1084 def Overloadable : Attr {
1085   let Spellings = [GNU<"overloadable">];
1086   let Subjects = SubjectList<[Function], ErrorDiag>;
1087   let Documentation = [OverloadableDocs];
1088 }
1089
1090 def Override : InheritableAttr { 
1091   let Spellings = [Keyword<"override">];
1092   let SemaHandler = 0;
1093   let Documentation = [Undocumented];
1094 }
1095
1096 def Ownership : InheritableAttr {
1097   let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">,
1098                    GNU<"ownership_takes">];
1099   let Accessors = [Accessor<"isHolds", [GNU<"ownership_holds">]>,
1100                    Accessor<"isReturns", [GNU<"ownership_returns">]>,
1101                    Accessor<"isTakes", [GNU<"ownership_takes">]>];
1102   let AdditionalMembers = [{
1103     enum OwnershipKind { Holds, Returns, Takes };
1104     OwnershipKind getOwnKind() const {
1105       return isHolds() ? Holds :
1106              isTakes() ? Takes :
1107              Returns;
1108     }
1109   }];
1110   let Args = [IdentifierArgument<"Module">, VariadicUnsignedArgument<"Args">];
1111   let Subjects = SubjectList<[HasFunctionProto], WarnDiag, "ExpectedFunction">;
1112   let Documentation = [Undocumented];
1113 }
1114
1115 def Packed : InheritableAttr {
1116   let Spellings = [GCC<"packed">];
1117 //  let Subjects = [Tag, Field];
1118   let Documentation = [Undocumented];
1119 }
1120
1121 def PnaclCall : InheritableAttr {
1122   let Spellings = [GNU<"pnaclcall">];
1123 //  let Subjects = [Function, ObjCMethod];
1124   let Documentation = [Undocumented];
1125 }
1126
1127 def IntelOclBicc : InheritableAttr {
1128   let Spellings = [GNU<"intel_ocl_bicc">];
1129 //  let Subjects = [Function, ObjCMethod];
1130   let Documentation = [Undocumented];
1131 }
1132
1133 def Pcs : InheritableAttr {
1134   let Spellings = [GCC<"pcs">];
1135   let Args = [EnumArgument<"PCS", "PCSType",
1136                            ["aapcs", "aapcs-vfp"],
1137                            ["AAPCS", "AAPCS_VFP"]>];
1138 //  let Subjects = [Function, ObjCMethod];
1139   let Documentation = [PcsDocs];
1140 }
1141
1142 def Pure : InheritableAttr {
1143   let Spellings = [GCC<"pure">];
1144   let Documentation = [Undocumented];
1145 }
1146
1147 def Regparm : TypeAttr {
1148   let Spellings = [GCC<"regparm">];
1149   let Args = [UnsignedArgument<"NumParams">];
1150   let Documentation = [RegparmDocs];
1151 }
1152
1153 def ReqdWorkGroupSize : InheritableAttr {
1154   let Spellings = [GNU<"reqd_work_group_size">];
1155   let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
1156               UnsignedArgument<"ZDim">];
1157   let Subjects = SubjectList<[Function], ErrorDiag>;
1158   let Documentation = [Undocumented];
1159 }
1160
1161 def WorkGroupSizeHint :  InheritableAttr {
1162   let Spellings = [GNU<"work_group_size_hint">];
1163   let Args = [UnsignedArgument<"XDim">, 
1164               UnsignedArgument<"YDim">,
1165               UnsignedArgument<"ZDim">];
1166   let Subjects = SubjectList<[Function], ErrorDiag>;
1167   let Documentation = [Undocumented];
1168 }
1169
1170 def InitPriority : InheritableAttr {
1171   let Spellings = [GNU<"init_priority">];
1172   let Args = [UnsignedArgument<"Priority">];
1173   let Subjects = SubjectList<[Var], ErrorDiag>;
1174   let Documentation = [Undocumented];
1175 }
1176
1177 def Section : InheritableAttr {
1178   let Spellings = [GCC<"section">, Declspec<"allocate">];
1179   let Args = [StringArgument<"Name">];
1180   let Subjects = SubjectList<[Function, GlobalVar,
1181                               ObjCMethod, ObjCProperty], ErrorDiag,
1182                              "ExpectedFunctionGlobalVarMethodOrProperty">;
1183   let Documentation = [SectionDocs];
1184 }
1185
1186 def Sentinel : InheritableAttr {
1187   let Spellings = [GCC<"sentinel">];
1188   let Args = [DefaultIntArgument<"Sentinel", 0>,
1189               DefaultIntArgument<"NullPos", 0>];
1190 //  let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
1191   let Documentation = [Undocumented];
1192 }
1193
1194 def StdCall : InheritableAttr {
1195   let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
1196 //  let Subjects = [Function, ObjCMethod];
1197   let Documentation = [StdCallDocs];
1198 }
1199
1200 def SysVABI : InheritableAttr {
1201   let Spellings = [GCC<"sysv_abi">];
1202 //  let Subjects = [Function, ObjCMethod];
1203   let Documentation = [Undocumented];
1204 }
1205
1206 def ThisCall : InheritableAttr {
1207   let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
1208                    Keyword<"_thiscall">];
1209 //  let Subjects = [Function, ObjCMethod];
1210   let Documentation = [ThisCallDocs];
1211 }
1212
1213 def VectorCall : InheritableAttr {
1214   let Spellings = [GNU<"vectorcall">, Keyword<"__vectorcall">,
1215                    Keyword<"_vectorcall">];
1216 //  let Subjects = [Function, ObjCMethod];
1217   let Documentation = [VectorCallDocs];
1218 }
1219
1220 def Pascal : InheritableAttr {
1221   let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
1222 //  let Subjects = [Function, ObjCMethod];
1223   let Documentation = [Undocumented];
1224 }
1225
1226 def TransparentUnion : InheritableAttr {
1227   let Spellings = [GCC<"transparent_union">];
1228 //  let Subjects = SubjectList<[Record, TypedefName]>;
1229   let Documentation = [Undocumented];
1230 }
1231
1232 def Unavailable : InheritableAttr {
1233   let Spellings = [GNU<"unavailable">];
1234   let Args = [StringArgument<"Message", 1>];
1235   let Documentation = [Undocumented];
1236 }
1237
1238 def ArcWeakrefUnavailable : InheritableAttr {
1239   let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
1240   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1241   let Documentation = [Undocumented];
1242 }
1243
1244 def ObjCGC : TypeAttr {
1245   let Spellings = [GNU<"objc_gc">];
1246   let Args = [IdentifierArgument<"Kind">];
1247   let Documentation = [Undocumented];
1248 }
1249
1250 def ObjCOwnership : InheritableAttr {
1251   let Spellings = [GNU<"objc_ownership">];
1252   let Args = [IdentifierArgument<"Kind">];
1253   let ASTNode = 0;
1254   let Documentation = [Undocumented];
1255 }
1256
1257 def ObjCRequiresPropertyDefs : InheritableAttr {
1258   let Spellings = [GNU<"objc_requires_property_definitions">];
1259   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
1260   let Documentation = [Undocumented];
1261 }
1262
1263 def Unused : InheritableAttr {
1264   let Spellings = [GCC<"unused">];
1265   let Subjects = SubjectList<[Var, ObjCIvar, Type, Label, Field, ObjCMethod,
1266                               FunctionLike], WarnDiag,
1267                              "ExpectedVariableFunctionOrLabel">;
1268   let Documentation = [Undocumented];
1269 }
1270
1271 def Used : InheritableAttr {
1272   let Spellings = [GCC<"used">];
1273   let Documentation = [Undocumented];
1274 }
1275
1276 def Uuid : InheritableAttr {
1277   let Spellings = [Declspec<"uuid">];
1278   let Args = [StringArgument<"Guid">];
1279 //  let Subjects = SubjectList<[CXXRecord]>;
1280   let LangOpts = [MicrosoftExt, Borland];
1281   let Documentation = [Undocumented];
1282 }
1283
1284 def VectorSize : TypeAttr {
1285   let Spellings = [GCC<"vector_size">];
1286   let Args = [ExprArgument<"NumBytes">];
1287   let Documentation = [Undocumented];
1288 }
1289
1290 def VecTypeHint : InheritableAttr {
1291   let Spellings = [GNU<"vec_type_hint">];
1292   let Args = [TypeArgument<"TypeHint">];
1293   let Subjects = SubjectList<[Function], ErrorDiag>;
1294   let Documentation = [Undocumented];
1295 }
1296
1297 def Visibility : InheritableAttr {
1298   let Clone = 0;
1299   let Spellings = [GCC<"visibility">];
1300   let Args = [EnumArgument<"Visibility", "VisibilityType",
1301                            ["default", "hidden", "internal", "protected"],
1302                            ["Default", "Hidden", "Hidden", "Protected"]>];
1303   let Documentation = [Undocumented];
1304 }
1305
1306 def TypeVisibility : InheritableAttr {
1307   let Clone = 0;
1308   let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">];
1309   let Args = [EnumArgument<"Visibility", "VisibilityType",
1310                            ["default", "hidden", "internal", "protected"],
1311                            ["Default", "Hidden", "Hidden", "Protected"]>];
1312 //  let Subjects = [Tag, ObjCInterface, Namespace];
1313   let Documentation = [Undocumented];
1314 }
1315
1316 def VecReturn : InheritableAttr {
1317   let Spellings = [GNU<"vecreturn">];
1318   let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
1319   let Documentation = [Undocumented];
1320 }
1321
1322 def WarnUnused : InheritableAttr {
1323   let Spellings = [GNU<"warn_unused">];
1324   let Subjects = SubjectList<[Record]>;
1325   let Documentation = [Undocumented];
1326 }
1327
1328 def WarnUnusedResult : InheritableAttr {
1329   let Spellings = [GCC<"warn_unused_result">,
1330                    CXX11<"clang", "warn_unused_result">];
1331   let Subjects = SubjectList<[ObjCMethod, CXXRecord, FunctionLike], WarnDiag,
1332                              "ExpectedFunctionMethodOrClass">;
1333   let Documentation = [Undocumented];
1334 }
1335
1336 def Weak : InheritableAttr {
1337   let Spellings = [GCC<"weak">];
1338   let Subjects = SubjectList<[Var, Function, CXXRecord]>;
1339   let Documentation = [Undocumented];
1340 }
1341
1342 def WeakImport : InheritableAttr {
1343   let Spellings = [GNU<"weak_import">];
1344   let Documentation = [Undocumented];
1345 }
1346
1347 def WeakRef : InheritableAttr {
1348   let Spellings = [GCC<"weakref">];
1349   // A WeakRef that has an argument is treated as being an AliasAttr
1350   let Args = [StringArgument<"Aliasee", 1>];
1351   let Subjects = SubjectList<[Var, Function], ErrorDiag>;
1352   let Documentation = [Undocumented];
1353 }
1354
1355 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetX86> {
1356   let Spellings = [GNU<"force_align_arg_pointer">];
1357   // Technically, this appertains to a FunctionDecl, but the target-specific
1358   // code silently allows anything function-like (such as typedefs or function
1359   // pointers), but does not apply the attribute to them.
1360   let Documentation = [Undocumented];
1361 }
1362
1363 // Attribute to disable AddressSanitizer (or equivalent) checks.
1364 def NoSanitizeAddress : InheritableAttr {
1365   let Spellings = [GCC<"no_address_safety_analysis">,
1366                    GCC<"no_sanitize_address">];
1367   let Subjects = SubjectList<[Function], ErrorDiag>;
1368   let Documentation = [NoSanitizeAddressDocs];
1369 }
1370
1371 // Attribute to disable ThreadSanitizer checks.
1372 def NoSanitizeThread : InheritableAttr {
1373   let Spellings = [GNU<"no_sanitize_thread">];
1374   let Subjects = SubjectList<[Function], ErrorDiag>;
1375   let Documentation = [NoSanitizeThreadDocs];
1376 }
1377
1378 // Attribute to disable MemorySanitizer checks.
1379 def NoSanitizeMemory : InheritableAttr {
1380   let Spellings = [GNU<"no_sanitize_memory">];
1381   let Subjects = SubjectList<[Function], ErrorDiag>;
1382   let Documentation = [NoSanitizeMemoryDocs];
1383 }
1384
1385 // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
1386
1387 def GuardedVar : InheritableAttr {
1388   let Spellings = [GNU<"guarded_var">];
1389   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1390                              "ExpectedFieldOrGlobalVar">;
1391   let Documentation = [Undocumented];
1392 }
1393
1394 def PtGuardedVar : InheritableAttr {
1395   let Spellings = [GNU<"pt_guarded_var">];
1396   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1397                              "ExpectedFieldOrGlobalVar">;
1398   let Documentation = [Undocumented];
1399 }
1400
1401 def Lockable : InheritableAttr {
1402   let Spellings = [GNU<"lockable">];
1403   let Subjects = SubjectList<[Record]>;
1404   let Documentation = [Undocumented];
1405   let ASTNode = 0;  // Replaced by Capability
1406 }
1407
1408 def ScopedLockable : InheritableAttr {
1409   let Spellings = [GNU<"scoped_lockable">];
1410   let Subjects = SubjectList<[Record]>;
1411   let Documentation = [Undocumented];
1412 }
1413
1414 def Capability : InheritableAttr {
1415   let Spellings = [GNU<"capability">, CXX11<"clang", "capability">,
1416                    GNU<"shared_capability">,
1417                    CXX11<"clang", "shared_capability">];
1418   let Subjects = SubjectList<[Struct, TypedefName], ErrorDiag,
1419                              "ExpectedStructOrTypedef">;
1420   let Args = [StringArgument<"Name">];
1421   let Accessors = [Accessor<"isShared",
1422                     [GNU<"shared_capability">,
1423                      CXX11<"clang","shared_capability">]>];
1424   let Documentation = [Undocumented];
1425   let AdditionalMembers = [{
1426     bool isMutex() const { return getName().equals_lower("mutex"); }
1427     bool isRole() const { return getName().equals_lower("role"); }
1428   }];
1429 }
1430
1431 def AssertCapability : InheritableAttr {
1432   let Spellings = [GNU<"assert_capability">,
1433                    CXX11<"clang", "assert_capability">,
1434                    GNU<"assert_shared_capability">,
1435                    CXX11<"clang", "assert_shared_capability">];
1436   let Subjects = SubjectList<[Function]>;
1437   let LateParsed = 1;
1438   let TemplateDependent = 1;
1439   let ParseArgumentsAsUnevaluated = 1;
1440   let DuplicatesAllowedWhileMerging = 1;
1441   let Args = [ExprArgument<"Expr">];
1442   let Accessors = [Accessor<"isShared",
1443                     [GNU<"assert_shared_capability">,
1444                      CXX11<"clang", "assert_shared_capability">]>];
1445   let Documentation = [AssertCapabilityDocs];
1446 }
1447
1448 def AcquireCapability : InheritableAttr {
1449   let Spellings = [GNU<"acquire_capability">,
1450                    CXX11<"clang", "acquire_capability">,
1451                    GNU<"acquire_shared_capability">,
1452                    CXX11<"clang", "acquire_shared_capability">,
1453                    GNU<"exclusive_lock_function">,
1454                    GNU<"shared_lock_function">];
1455   let Subjects = SubjectList<[Function]>;
1456   let LateParsed = 1;
1457   let TemplateDependent = 1;
1458   let ParseArgumentsAsUnevaluated = 1;
1459   let DuplicatesAllowedWhileMerging = 1;
1460   let Args = [VariadicExprArgument<"Args">];
1461   let Accessors = [Accessor<"isShared",
1462                     [GNU<"acquire_shared_capability">,
1463                      CXX11<"clang", "acquire_shared_capability">,
1464                      GNU<"shared_lock_function">]>];
1465   let Documentation = [AcquireCapabilityDocs];
1466 }
1467
1468 def TryAcquireCapability : InheritableAttr {
1469   let Spellings = [GNU<"try_acquire_capability">,
1470                    CXX11<"clang", "try_acquire_capability">,
1471                    GNU<"try_acquire_shared_capability">,
1472                    CXX11<"clang", "try_acquire_shared_capability">];
1473   let Subjects = SubjectList<[Function],
1474                              ErrorDiag>;
1475   let LateParsed = 1;
1476   let TemplateDependent = 1;
1477   let ParseArgumentsAsUnevaluated = 1;
1478   let DuplicatesAllowedWhileMerging = 1;
1479   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1480   let Accessors = [Accessor<"isShared",
1481                     [GNU<"try_acquire_shared_capability">,
1482                      CXX11<"clang", "try_acquire_shared_capability">]>];
1483   let Documentation = [TryAcquireCapabilityDocs];
1484 }
1485
1486 def ReleaseCapability : InheritableAttr {
1487   let Spellings = [GNU<"release_capability">,
1488                    CXX11<"clang", "release_capability">,
1489                    GNU<"release_shared_capability">,
1490                    CXX11<"clang", "release_shared_capability">,
1491                    GNU<"release_generic_capability">,
1492                    CXX11<"clang", "release_generic_capability">,
1493                    GNU<"unlock_function">];
1494   let Subjects = SubjectList<[Function]>;
1495   let LateParsed = 1;
1496   let TemplateDependent = 1;
1497   let ParseArgumentsAsUnevaluated = 1;
1498   let DuplicatesAllowedWhileMerging = 1;
1499   let Args = [VariadicExprArgument<"Args">];
1500   let Accessors = [Accessor<"isShared",
1501                     [GNU<"release_shared_capability">,
1502                      CXX11<"clang", "release_shared_capability">]>,
1503                    Accessor<"isGeneric",
1504                      [GNU<"release_generic_capability">,
1505                       CXX11<"clang", "release_generic_capability">,
1506                       GNU<"unlock_function">]>];
1507   let Documentation = [ReleaseCapabilityDocs];
1508 }
1509
1510 def RequiresCapability : InheritableAttr {
1511   let Spellings = [GNU<"requires_capability">,
1512                    CXX11<"clang", "requires_capability">,
1513                    GNU<"exclusive_locks_required">,
1514                    GNU<"requires_shared_capability">,
1515                    CXX11<"clang", "requires_shared_capability">,
1516                    GNU<"shared_locks_required">];
1517   let Args = [VariadicExprArgument<"Args">];
1518   let LateParsed = 1;
1519   let TemplateDependent = 1;
1520   let ParseArgumentsAsUnevaluated = 1;
1521   let DuplicatesAllowedWhileMerging = 1;
1522   let Subjects = SubjectList<[Function]>;
1523   let Accessors = [Accessor<"isShared", [GNU<"requires_shared_capability">,
1524                                          GNU<"shared_locks_required">,
1525                                 CXX11<"clang","requires_shared_capability">]>];
1526   let Documentation = [Undocumented];
1527 }
1528
1529 def NoThreadSafetyAnalysis : InheritableAttr {
1530   let Spellings = [GNU<"no_thread_safety_analysis">];
1531   let Subjects = SubjectList<[Function]>;
1532   let Documentation = [Undocumented];
1533 }
1534
1535 def GuardedBy : InheritableAttr {
1536   let Spellings = [GNU<"guarded_by">];
1537   let Args = [ExprArgument<"Arg">];
1538   let LateParsed = 1;
1539   let TemplateDependent = 1;
1540   let ParseArgumentsAsUnevaluated = 1;
1541   let DuplicatesAllowedWhileMerging = 1;
1542   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1543                              "ExpectedFieldOrGlobalVar">;
1544   let Documentation = [Undocumented];
1545 }
1546
1547 def PtGuardedBy : InheritableAttr {
1548   let Spellings = [GNU<"pt_guarded_by">];
1549   let Args = [ExprArgument<"Arg">];
1550   let LateParsed = 1;
1551   let TemplateDependent = 1;
1552   let ParseArgumentsAsUnevaluated = 1;
1553   let DuplicatesAllowedWhileMerging = 1;
1554   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1555                              "ExpectedFieldOrGlobalVar">;
1556   let Documentation = [Undocumented];
1557 }
1558
1559 def AcquiredAfter : InheritableAttr {
1560   let Spellings = [GNU<"acquired_after">];
1561   let Args = [VariadicExprArgument<"Args">];
1562   let LateParsed = 1;
1563   let TemplateDependent = 1;
1564   let ParseArgumentsAsUnevaluated = 1;
1565   let DuplicatesAllowedWhileMerging = 1;
1566   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1567                              "ExpectedFieldOrGlobalVar">;
1568   let Documentation = [Undocumented];
1569 }
1570
1571 def AcquiredBefore : InheritableAttr {
1572   let Spellings = [GNU<"acquired_before">];
1573   let Args = [VariadicExprArgument<"Args">];
1574   let LateParsed = 1;
1575   let TemplateDependent = 1;
1576   let ParseArgumentsAsUnevaluated = 1;
1577   let DuplicatesAllowedWhileMerging = 1;
1578   let Subjects = SubjectList<[Field, SharedVar], WarnDiag,
1579                              "ExpectedFieldOrGlobalVar">;
1580   let Documentation = [Undocumented];
1581 }
1582
1583 def AssertExclusiveLock : InheritableAttr {
1584   let Spellings = [GNU<"assert_exclusive_lock">];
1585   let Args = [VariadicExprArgument<"Args">];
1586   let LateParsed = 1;
1587   let TemplateDependent = 1;
1588   let ParseArgumentsAsUnevaluated = 1;
1589   let DuplicatesAllowedWhileMerging = 1;
1590   let Subjects = SubjectList<[Function]>;
1591   let Documentation = [Undocumented];
1592 }
1593
1594 def AssertSharedLock : InheritableAttr {
1595   let Spellings = [GNU<"assert_shared_lock">];
1596   let Args = [VariadicExprArgument<"Args">];
1597   let LateParsed = 1;
1598   let TemplateDependent = 1;
1599   let ParseArgumentsAsUnevaluated = 1;
1600   let DuplicatesAllowedWhileMerging = 1;
1601   let Subjects = SubjectList<[Function]>;
1602   let Documentation = [Undocumented];
1603 }
1604
1605 // The first argument is an integer or boolean value specifying the return value
1606 // of a successful lock acquisition.
1607 def ExclusiveTrylockFunction : InheritableAttr {
1608   let Spellings = [GNU<"exclusive_trylock_function">];
1609   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1610   let LateParsed = 1;
1611   let TemplateDependent = 1;
1612   let ParseArgumentsAsUnevaluated = 1;
1613   let DuplicatesAllowedWhileMerging = 1;
1614   let Subjects = SubjectList<[Function]>;
1615   let Documentation = [Undocumented];
1616 }
1617
1618 // The first argument is an integer or boolean value specifying the return value
1619 // of a successful lock acquisition.
1620 def SharedTrylockFunction : InheritableAttr {
1621   let Spellings = [GNU<"shared_trylock_function">];
1622   let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
1623   let LateParsed = 1;
1624   let TemplateDependent = 1;
1625   let ParseArgumentsAsUnevaluated = 1;
1626   let DuplicatesAllowedWhileMerging = 1;
1627   let Subjects = SubjectList<[Function]>;
1628   let Documentation = [Undocumented];
1629 }
1630
1631 def LockReturned : InheritableAttr {
1632   let Spellings = [GNU<"lock_returned">];
1633   let Args = [ExprArgument<"Arg">];
1634   let LateParsed = 1;
1635   let TemplateDependent = 1;
1636   let ParseArgumentsAsUnevaluated = 1;
1637   let Subjects = SubjectList<[Function]>;
1638   let Documentation = [Undocumented];
1639 }
1640
1641 def LocksExcluded : InheritableAttr {
1642   let Spellings = [GNU<"locks_excluded">];
1643   let Args = [VariadicExprArgument<"Args">];
1644   let LateParsed = 1;
1645   let TemplateDependent = 1;
1646   let ParseArgumentsAsUnevaluated = 1;
1647   let DuplicatesAllowedWhileMerging = 1;
1648   let Subjects = SubjectList<[Function]>;
1649   let Documentation = [Undocumented];
1650 }
1651
1652 // C/C++ consumed attributes.
1653
1654 def Consumable : InheritableAttr {
1655   let Spellings = [GNU<"consumable">];
1656   let Subjects = SubjectList<[CXXRecord]>;
1657   let Args = [EnumArgument<"DefaultState", "ConsumedState",
1658                            ["unknown", "consumed", "unconsumed"],
1659                            ["Unknown", "Consumed", "Unconsumed"]>];
1660   let Documentation = [ConsumableDocs];
1661 }
1662
1663 def ConsumableAutoCast : InheritableAttr {
1664   let Spellings = [GNU<"consumable_auto_cast_state">];
1665   let Subjects = SubjectList<[CXXRecord]>;
1666   let Documentation = [Undocumented];
1667 }
1668
1669 def ConsumableSetOnRead : InheritableAttr {
1670   let Spellings = [GNU<"consumable_set_state_on_read">];
1671   let Subjects = SubjectList<[CXXRecord]>;
1672   let Documentation = [Undocumented];
1673 }
1674
1675 def CallableWhen : InheritableAttr {
1676   let Spellings = [GNU<"callable_when">];
1677   let Subjects = SubjectList<[CXXMethod]>;
1678   let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
1679                                    ["unknown", "consumed", "unconsumed"],
1680                                    ["Unknown", "Consumed", "Unconsumed"]>];
1681   let Documentation = [CallableWhenDocs];
1682 }
1683
1684 def ParamTypestate : InheritableAttr {
1685   let Spellings = [GNU<"param_typestate">];
1686   let Subjects = SubjectList<[ParmVar]>;
1687   let Args = [EnumArgument<"ParamState", "ConsumedState",
1688                            ["unknown", "consumed", "unconsumed"],
1689                            ["Unknown", "Consumed", "Unconsumed"]>];
1690   let Documentation = [ParamTypestateDocs];
1691 }
1692
1693 def ReturnTypestate : InheritableAttr {
1694   let Spellings = [GNU<"return_typestate">];
1695   let Subjects = SubjectList<[Function, ParmVar]>;
1696   let Args = [EnumArgument<"State", "ConsumedState",
1697                            ["unknown", "consumed", "unconsumed"],
1698                            ["Unknown", "Consumed", "Unconsumed"]>];
1699   let Documentation = [ReturnTypestateDocs];
1700 }
1701
1702 def SetTypestate : InheritableAttr {
1703   let Spellings = [GNU<"set_typestate">];
1704   let Subjects = SubjectList<[CXXMethod]>;
1705   let Args = [EnumArgument<"NewState", "ConsumedState",
1706                            ["unknown", "consumed", "unconsumed"],
1707                            ["Unknown", "Consumed", "Unconsumed"]>];
1708   let Documentation = [SetTypestateDocs];
1709 }
1710
1711 def TestTypestate : InheritableAttr {
1712   let Spellings = [GNU<"test_typestate">];
1713   let Subjects = SubjectList<[CXXMethod]>;
1714   let Args = [EnumArgument<"TestState", "ConsumedState",
1715                            ["consumed", "unconsumed"],
1716                            ["Consumed", "Unconsumed"]>];
1717   let Documentation = [TestTypestateDocs];
1718 }
1719
1720 // Type safety attributes for `void *' pointers and type tags.
1721
1722 def ArgumentWithTypeTag : InheritableAttr {
1723   let Spellings = [GNU<"argument_with_type_tag">,
1724                    GNU<"pointer_with_type_tag">];
1725   let Args = [IdentifierArgument<"ArgumentKind">,
1726               UnsignedArgument<"ArgumentIdx">,
1727               UnsignedArgument<"TypeTagIdx">,
1728               BoolArgument<"IsPointer">];
1729   let HasCustomParsing = 1;
1730   let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
1731 }
1732
1733 def TypeTagForDatatype : InheritableAttr {
1734   let Spellings = [GNU<"type_tag_for_datatype">];
1735   let Args = [IdentifierArgument<"ArgumentKind">,
1736               TypeArgument<"MatchingCType">,
1737               BoolArgument<"LayoutCompatible">,
1738               BoolArgument<"MustBeNull">];
1739 //  let Subjects = SubjectList<[Var], ErrorDiag>;
1740   let HasCustomParsing = 1;
1741   let Documentation = [TypeTagForDatatypeDocs];
1742 }
1743
1744 // Microsoft-related attributes
1745
1746 def MsProperty : IgnoredAttr {
1747   let Spellings = [Declspec<"property">];
1748 }
1749
1750 def MsStruct : InheritableAttr {
1751   let Spellings = [GCC<"ms_struct">];
1752   let Subjects = SubjectList<[Record]>;
1753   let Documentation = [Undocumented];
1754 }
1755
1756 def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
1757   let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
1758   let Subjects = SubjectList<[Function, Var, CXXRecord]>;
1759   let Documentation = [Undocumented];
1760 }
1761
1762 def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
1763   let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
1764   let Subjects = SubjectList<[Function, Var, CXXRecord]>;
1765   let Documentation = [Undocumented];
1766 }
1767
1768 def SelectAny : InheritableAttr {
1769   let Spellings = [Declspec<"selectany">];
1770   let LangOpts = [MicrosoftExt];
1771   let Documentation = [Undocumented];
1772 }
1773
1774 def Thread : Attr {
1775   let Spellings = [Declspec<"thread">];
1776   let LangOpts = [MicrosoftExt];
1777   let Documentation = [ThreadDocs];
1778   let Subjects = SubjectList<[Var]>;
1779 }
1780
1781 def Win64 : IgnoredAttr {
1782   let Spellings = [Keyword<"__w64">];
1783   let LangOpts = [MicrosoftExt];
1784 }
1785
1786 def Ptr32 : TypeAttr {
1787   let Spellings = [Keyword<"__ptr32">];
1788   let Documentation = [Undocumented];
1789 }
1790
1791 def Ptr64 : TypeAttr {
1792   let Spellings = [Keyword<"__ptr64">];
1793   let Documentation = [Undocumented];
1794 }
1795
1796 def SPtr : TypeAttr {
1797   let Spellings = [Keyword<"__sptr">];
1798   let Documentation = [Undocumented];
1799 }
1800
1801 def UPtr : TypeAttr {
1802   let Spellings = [Keyword<"__uptr">];
1803   let Documentation = [Undocumented];
1804 }
1805
1806 def MSInheritance : InheritableAttr {
1807   let LangOpts = [MicrosoftExt];
1808   let Args = [DefaultBoolArgument<"BestCase", 1>];
1809   let Spellings = [Keyword<"__single_inheritance">,
1810                    Keyword<"__multiple_inheritance">,
1811                    Keyword<"__virtual_inheritance">,
1812                    Keyword<"__unspecified_inheritance">];
1813   let AdditionalMembers = [{
1814   static bool hasVBPtrOffsetField(Spelling Inheritance) {
1815     return Inheritance == Keyword_unspecified_inheritance;
1816   }
1817
1818   // Only member pointers to functions need a this adjustment, since it can be
1819   // combined with the field offset for data pointers.
1820   static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
1821     return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
1822   }
1823
1824   static bool hasVBTableOffsetField(Spelling Inheritance) {
1825     return Inheritance >= Keyword_virtual_inheritance;
1826   }
1827
1828   static bool hasOnlyOneField(bool IsMemberFunction,
1829                               Spelling Inheritance) {
1830     if (IsMemberFunction)
1831       return Inheritance <= Keyword_single_inheritance;
1832     return Inheritance <= Keyword_multiple_inheritance;
1833   }
1834   }];
1835   let Documentation = [MSInheritanceDocs];
1836 }
1837
1838 def MSVtorDisp : InheritableAttr {
1839   // This attribute has no spellings as it is only ever created implicitly.
1840   let Spellings = [];
1841   let Args = [UnsignedArgument<"vdm">];
1842   let SemaHandler = 0;
1843
1844   let AdditionalMembers = [{
1845   enum Mode {
1846     Never,
1847     ForVBaseOverride,
1848     ForVFTable
1849   };
1850
1851   Mode getVtorDispMode() const { return Mode(vdm); }
1852   }];
1853   let Documentation = [Undocumented];
1854 }
1855
1856 def InitSeg : Attr {
1857   let Spellings = [Pragma<"", "init_seg">];
1858   let Args = [StringArgument<"Section">];
1859   let SemaHandler = 0;
1860   let Documentation = [InitSegDocs];
1861   let AdditionalMembers = [{
1862   void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
1863     OS << '(' << getSection() << ')';
1864   }
1865   }];
1866 }
1867
1868 def Unaligned : IgnoredAttr {
1869   let Spellings = [Keyword<"__unaligned">];
1870 }
1871
1872 def LoopHint : Attr {
1873   /// #pragma clang loop <option> directive
1874   /// vectorize: vectorizes loop operations if State == Enable.
1875   /// vectorize_width: vectorize loop operations with width 'Value'.
1876   /// interleave: interleave multiple loop iterations if State == Enable.
1877   /// interleave_count: interleaves 'Value' loop interations.
1878   /// unroll: fully unroll loop if State == Enable.
1879   /// unroll_count: unrolls loop 'Value' times.
1880
1881   /// #pragma unroll <argument> directive
1882   /// <no arg>: fully unrolls loop.
1883   /// boolean: fully unrolls loop if State == Enable.
1884   /// expression: unrolls loop 'Value' times.
1885
1886   let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">,
1887                    Pragma<"", "nounroll">];
1888
1889   /// State of the loop optimization specified by the spelling.
1890   let Args = [EnumArgument<"Option", "OptionType",
1891                           ["vectorize", "vectorize_width", "interleave", "interleave_count",
1892                            "unroll", "unroll_count"],
1893                           ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
1894                            "Unroll", "UnrollCount"]>,
1895               EnumArgument<"State", "LoopHintState",
1896                            ["default", "enable", "disable"],
1897                            ["Default", "Enable", "Disable"]>,
1898               ExprArgument<"Value">];
1899
1900   let AdditionalMembers = [{
1901   static const char *getOptionName(int Option) {
1902     switch(Option) {
1903     case Vectorize: return "vectorize";
1904     case VectorizeWidth: return "vectorize_width";
1905     case Interleave: return "interleave";
1906     case InterleaveCount: return "interleave_count";
1907     case Unroll: return "unroll";
1908     case UnrollCount: return "unroll_count";
1909     }
1910     llvm_unreachable("Unhandled LoopHint option.");
1911   }
1912
1913   void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
1914     unsigned SpellingIndex = getSpellingListIndex();
1915     // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
1916     // "nounroll" is already emitted as the pragma name.
1917     if (SpellingIndex == Pragma_nounroll) {
1918       OS << "\n";
1919       return;
1920     }
1921     else if (SpellingIndex == Pragma_unroll) {
1922       OS << getValueString(Policy) << "\n";
1923       return;
1924     }
1925
1926     assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
1927     OS << getOptionName(option) << getValueString(Policy) << "\n";
1928   }
1929
1930   // Return a string containing the loop hint argument including the
1931   // enclosing parentheses.
1932   std::string getValueString(const PrintingPolicy &Policy) const {
1933     std::string ValueName;
1934     llvm::raw_string_ostream OS(ValueName);
1935     OS << "(";
1936     if (option == VectorizeWidth || option == InterleaveCount ||
1937         option == UnrollCount)
1938       value->printPretty(OS, nullptr, Policy);
1939     else if (state == Default)
1940       return "";
1941     else if (state == Enable)
1942       OS << (option == Unroll ? "full" : "enable");
1943     else
1944       OS << "disable";
1945     OS << ")";
1946     return OS.str();
1947   }
1948
1949   // Return a string suitable for identifying this attribute in diagnostics.
1950   std::string getDiagnosticName(const PrintingPolicy &Policy) const {
1951     unsigned SpellingIndex = getSpellingListIndex();
1952     if (SpellingIndex == Pragma_nounroll)
1953       return "#pragma nounroll";
1954     else if (SpellingIndex == Pragma_unroll)
1955       return "#pragma unroll" + getValueString(Policy);
1956
1957     assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
1958     return getOptionName(option) + getValueString(Policy);
1959   }
1960   }];
1961
1962   let Documentation = [LoopHintDocs, UnrollHintDocs];
1963 }
1964
1965 def CapturedRecord : InheritableAttr {
1966   // This attribute has no spellings as it is only ever created implicitly.
1967   let Spellings = [];
1968   let SemaHandler = 0;
1969   let Documentation = [Undocumented];
1970 }
1971
1972 def OMPThreadPrivateDecl : InheritableAttr {
1973   // This attribute has no spellings as it is only ever created implicitly.
1974   let Spellings = [];
1975   let SemaHandler = 0;
1976   let Documentation = [Undocumented];
1977 }