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