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