]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Basic/AttrDocs.td
Copy ^/vendor/NetBSD/tests/dist to contrib/netbsd-tests
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / Basic / AttrDocs.td
1 //==--- AttrDocs.td - Attribute documentation ----------------------------===//
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 def GlobalDocumentation {
11   code Intro =[{..
12   -------------------------------------------------------------------
13   NOTE: This file is automatically generated by running clang-tblgen
14   -gen-attr-docs. Do not edit this file by hand!!
15   -------------------------------------------------------------------
16
17 ===================
18 Attributes in Clang
19 ===================
20 .. contents::
21    :local:
22
23 Introduction
24 ============
25
26 This page lists the attributes currently supported by Clang.
27 }];
28 }
29
30 def SectionDocs : Documentation {
31   let Category = DocCatVariable;
32   let Content = [{
33 The ``section`` attribute allows you to specify a specific section a
34 global variable or function should be in after translation.
35   }];
36   let Heading = "section (gnu::section, __declspec(allocate))";
37 }
38
39 def InitSegDocs : Documentation {
40   let Category = DocCatVariable;
41   let Content = [{
42 The attribute applied by ``pragma init_seg()`` controls the section into
43 which global initialization function pointers are emitted.  It is only
44 available with ``-fms-extensions``.  Typically, this function pointer is
45 emitted into ``.CRT$XCU`` on Windows.  The user can change the order of
46 initialization by using a different section name with the same
47 ``.CRT$XC`` prefix and a suffix that sorts lexicographically before or
48 after the standard ``.CRT$XCU`` sections.  See the init_seg_
49 documentation on MSDN for more information.
50
51 .. _init_seg: http://msdn.microsoft.com/en-us/library/7977wcck(v=vs.110).aspx
52   }];
53 }
54
55 def TLSModelDocs : Documentation {
56   let Category = DocCatVariable;
57   let Content = [{
58 The ``tls_model`` attribute allows you to specify which thread-local storage
59 model to use. It accepts the following strings:
60
61 * global-dynamic
62 * local-dynamic
63 * initial-exec
64 * local-exec
65
66 TLS models are mutually exclusive.
67   }];
68 }
69
70 def DLLExportDocs : Documentation {
71   let Category = DocCatVariable;
72   let Content = [{
73 The ``__declspec(dllexport)`` attribute declares a variable, function, or
74 Objective-C interface to be exported from the module.  It is available under the
75 ``-fdeclspec`` flag for compatibility with various compilers.  The primary use
76 is for COFF object files which explicitly specify what interfaces are available
77 for external use.  See the dllexport_ documentation on MSDN for more
78 information.
79
80 .. _dllexport: https://msdn.microsoft.com/en-us/library/3y1sfaz2.aspx
81   }];
82 }
83
84 def DLLImportDocs : Documentation {
85   let Category = DocCatVariable;
86   let Content = [{
87 The ``__declspec(dllimport)`` attribute declares a variable, function, or
88 Objective-C interface to be imported from an external module.  It is available
89 under the ``-fdeclspec`` flag for compatibility with various compilers.  The
90 primary use is for COFF object files which explicitly specify what interfaces
91 are imported from external modules.  See the dllimport_ documentation on MSDN
92 for more information.
93
94 .. _dllimport: https://msdn.microsoft.com/en-us/library/3y1sfaz2.aspx
95   }];
96 }
97
98 def ThreadDocs : Documentation {
99   let Category = DocCatVariable;
100   let Content = [{
101 The ``__declspec(thread)`` attribute declares a variable with thread local
102 storage.  It is available under the ``-fms-extensions`` flag for MSVC
103 compatibility.  See the documentation for `__declspec(thread)`_ on MSDN.
104
105 .. _`__declspec(thread)`: http://msdn.microsoft.com/en-us/library/9w1sdazb.aspx
106
107 In Clang, ``__declspec(thread)`` is generally equivalent in functionality to the
108 GNU ``__thread`` keyword.  The variable must not have a destructor and must have
109 a constant initializer, if any.  The attribute only applies to variables
110 declared with static storage duration, such as globals, class static data
111 members, and static locals.
112   }];
113 }
114
115 def CarriesDependencyDocs : Documentation {
116   let Category = DocCatFunction;
117   let Content = [{
118 The ``carries_dependency`` attribute specifies dependency propagation into and
119 out of functions.
120
121 When specified on a function or Objective-C method, the ``carries_dependency``
122 attribute means that the return value carries a dependency out of the function, 
123 so that the implementation need not constrain ordering upon return from that
124 function. Implementations of the function and its caller may choose to preserve
125 dependencies instead of emitting memory ordering instructions such as fences.
126
127 Note, this attribute does not change the meaning of the program, but may result
128 in generation of more efficient code.
129   }];
130 }
131
132 def C11NoReturnDocs : Documentation {
133   let Category = DocCatFunction;
134   let Content = [{
135 A function declared as ``_Noreturn`` shall not return to its caller. The
136 compiler will generate a diagnostic for a function declared as ``_Noreturn``
137 that appears to be capable of returning to its caller.
138   }];
139 }
140
141 def CXX11NoReturnDocs : Documentation {
142   let Category = DocCatFunction;
143   let Content = [{
144 A function declared as ``[[noreturn]]`` shall not return to its caller. The
145 compiler will generate a diagnostic for a function declared as ``[[noreturn]]``
146 that appears to be capable of returning to its caller.
147   }];
148 }
149
150 def AssertCapabilityDocs : Documentation {
151   let Category = DocCatFunction;
152   let Heading = "assert_capability (assert_shared_capability, clang::assert_capability, clang::assert_shared_capability)";
153   let Content = [{
154 Marks a function that dynamically tests whether a capability is held, and halts
155 the program if it is not held.
156   }];
157 }
158
159 def AcquireCapabilityDocs : Documentation {
160   let Category = DocCatFunction;
161   let Heading = "acquire_capability (acquire_shared_capability, clang::acquire_capability, clang::acquire_shared_capability)";
162   let Content = [{
163 Marks a function as acquiring a capability.
164   }];
165 }
166
167 def TryAcquireCapabilityDocs : Documentation {
168   let Category = DocCatFunction;
169   let Heading = "try_acquire_capability (try_acquire_shared_capability, clang::try_acquire_capability, clang::try_acquire_shared_capability)";
170   let Content = [{
171 Marks a function that attempts to acquire a capability. This function may fail to
172 actually acquire the capability; they accept a Boolean value determining
173 whether acquiring the capability means success (true), or failing to acquire
174 the capability means success (false).
175   }];
176 }
177
178 def ReleaseCapabilityDocs : Documentation {
179   let Category = DocCatFunction;
180   let Heading = "release_capability (release_shared_capability, clang::release_capability, clang::release_shared_capability)";
181   let Content = [{
182 Marks a function as releasing a capability.
183   }];
184 }
185
186 def AssumeAlignedDocs : Documentation {
187   let Category = DocCatFunction;
188   let Content = [{
189 Use ``__attribute__((assume_aligned(<alignment>[,<offset>]))`` on a function
190 declaration to specify that the return value of the function (which must be a
191 pointer type) has the specified offset, in bytes, from an address with the
192 specified alignment. The offset is taken to be zero if omitted.
193
194 .. code-block:: c++
195
196   // The returned pointer value has 32-byte alignment.
197   void *a() __attribute__((assume_aligned (32)));
198
199   // The returned pointer value is 4 bytes greater than an address having
200   // 32-byte alignment.
201   void *b() __attribute__((assume_aligned (32, 4)));
202
203 Note that this attribute provides information to the compiler regarding a
204 condition that the code already ensures is true. It does not cause the compiler
205 to enforce the provided alignment assumption.
206   }];
207 }
208
209 def EnableIfDocs : Documentation {
210   let Category = DocCatFunction;
211   let Content = [{
212 .. Note:: Some features of this attribute are experimental. The meaning of
213   multiple enable_if attributes on a single declaration is subject to change in
214   a future version of clang. Also, the ABI is not standardized and the name
215   mangling may change in future versions. To avoid that, use asm labels.
216
217 The ``enable_if`` attribute can be placed on function declarations to control
218 which overload is selected based on the values of the function's arguments.
219 When combined with the ``overloadable`` attribute, this feature is also
220 available in C.
221
222 .. code-block:: c++
223
224   int isdigit(int c);
225   int isdigit(int c) __attribute__((enable_if(c <= -1 || c > 255, "chosen when 'c' is out of range"))) __attribute__((unavailable("'c' must have the value of an unsigned char or EOF")));
226   
227   void foo(char c) {
228     isdigit(c);
229     isdigit(10);
230     isdigit(-10);  // results in a compile-time error.
231   }
232
233 The enable_if attribute takes two arguments, the first is an expression written
234 in terms of the function parameters, the second is a string explaining why this
235 overload candidate could not be selected to be displayed in diagnostics. The
236 expression is part of the function signature for the purposes of determining
237 whether it is a redeclaration (following the rules used when determining
238 whether a C++ template specialization is ODR-equivalent), but is not part of
239 the type.
240
241 The enable_if expression is evaluated as if it were the body of a
242 bool-returning constexpr function declared with the arguments of the function
243 it is being applied to, then called with the parameters at the call site. If the
244 result is false or could not be determined through constant expression
245 evaluation, then this overload will not be chosen and the provided string may
246 be used in a diagnostic if the compile fails as a result.
247
248 Because the enable_if expression is an unevaluated context, there are no global
249 state changes, nor the ability to pass information from the enable_if
250 expression to the function body. For example, suppose we want calls to
251 strnlen(strbuf, maxlen) to resolve to strnlen_chk(strbuf, maxlen, size of
252 strbuf) only if the size of strbuf can be determined:
253
254 .. code-block:: c++
255
256   __attribute__((always_inline))
257   static inline size_t strnlen(const char *s, size_t maxlen)
258     __attribute__((overloadable))
259     __attribute__((enable_if(__builtin_object_size(s, 0) != -1))),
260                              "chosen when the buffer size is known but 'maxlen' is not")))
261   {
262     return strnlen_chk(s, maxlen, __builtin_object_size(s, 0));
263   }
264
265 Multiple enable_if attributes may be applied to a single declaration. In this
266 case, the enable_if expressions are evaluated from left to right in the
267 following manner. First, the candidates whose enable_if expressions evaluate to
268 false or cannot be evaluated are discarded. If the remaining candidates do not
269 share ODR-equivalent enable_if expressions, the overload resolution is
270 ambiguous. Otherwise, enable_if overload resolution continues with the next
271 enable_if attribute on the candidates that have not been discarded and have
272 remaining enable_if attributes. In this way, we pick the most specific
273 overload out of a number of viable overloads using enable_if.
274
275 .. code-block:: c++
276
277   void f() __attribute__((enable_if(true, "")));  // #1
278   void f() __attribute__((enable_if(true, ""))) __attribute__((enable_if(true, "")));  // #2
279   
280   void g(int i, int j) __attribute__((enable_if(i, "")));  // #1
281   void g(int i, int j) __attribute__((enable_if(j, ""))) __attribute__((enable_if(true)));  // #2
282
283 In this example, a call to f() is always resolved to #2, as the first enable_if
284 expression is ODR-equivalent for both declarations, but #1 does not have another
285 enable_if expression to continue evaluating, so the next round of evaluation has
286 only a single candidate. In a call to g(1, 1), the call is ambiguous even though
287 #2 has more enable_if attributes, because the first enable_if expressions are
288 not ODR-equivalent.
289
290 Query for this feature with ``__has_attribute(enable_if)``.
291
292 Note that functions with one or more ``enable_if`` attributes may not have
293 their address taken, unless all of the conditions specified by said
294 ``enable_if`` are constants that evaluate to ``true``. For example:
295
296 .. code-block:: c
297
298   const int TrueConstant = 1;
299   const int FalseConstant = 0;
300   int f(int a) __attribute__((enable_if(a > 0, "")));
301   int g(int a) __attribute__((enable_if(a == 0 || a != 0, "")));
302   int h(int a) __attribute__((enable_if(1, "")));
303   int i(int a) __attribute__((enable_if(TrueConstant, "")));
304   int j(int a) __attribute__((enable_if(FalseConstant, "")));
305
306   void fn() {
307     int (*ptr)(int);
308     ptr = &f; // error: 'a > 0' is not always true
309     ptr = &g; // error: 'a == 0 || a != 0' is not a truthy constant
310     ptr = &h; // OK: 1 is a truthy constant
311     ptr = &i; // OK: 'TrueConstant' is a truthy constant
312     ptr = &j; // error: 'FalseConstant' is a constant, but not truthy
313   }
314
315 Because ``enable_if`` evaluation happens during overload resolution,
316 ``enable_if`` may give unintuitive results when used with templates, depending
317 on when overloads are resolved. In the example below, clang will emit a
318 diagnostic about no viable overloads for ``foo`` in ``bar``, but not in ``baz``:
319
320 .. code-block:: c++
321
322   double foo(int i) __attribute__((enable_if(i > 0, "")));
323   void *foo(int i) __attribute__((enable_if(i <= 0, "")));
324   template <int I>
325   auto bar() { return foo(I); }
326
327   template <typename T>
328   auto baz() { return foo(T::number); }
329
330   struct WithNumber { constexpr static int number = 1; };
331   void callThem() {
332     bar<sizeof(WithNumber)>();
333     baz<WithNumber>();
334   }
335
336 This is because, in ``bar``, ``foo`` is resolved prior to template
337 instantiation, so the value for ``I`` isn't known (thus, both ``enable_if``
338 conditions for ``foo`` fail). However, in ``baz``, ``foo`` is resolved during
339 template instantiation, so the value for ``T::number`` is known.
340   }];
341 }
342
343 def PassObjectSizeDocs : Documentation {
344   let Category = DocCatVariable; // Technically it's a parameter doc, but eh.
345   let Content = [{
346 .. Note:: The mangling of functions with parameters that are annotated with
347   ``pass_object_size`` is subject to change. You can get around this by
348   using ``__asm__("foo")`` to explicitly name your functions, thus preserving
349   your ABI; also, non-overloadable C functions with ``pass_object_size`` are
350   not mangled.
351
352 The ``pass_object_size(Type)`` attribute can be placed on function parameters to
353 instruct clang to call ``__builtin_object_size(param, Type)`` at each callsite
354 of said function, and implicitly pass the result of this call in as an invisible
355 argument of type ``size_t`` directly after the parameter annotated with
356 ``pass_object_size``. Clang will also replace any calls to
357 ``__builtin_object_size(param, Type)`` in the function by said implicit
358 parameter.
359
360 Example usage:
361
362 .. code-block:: c
363
364   int bzero1(char *const p __attribute__((pass_object_size(0))))
365       __attribute__((noinline)) {
366     int i = 0;
367     for (/**/; i < (int)__builtin_object_size(p, 0); ++i) {
368       p[i] = 0;
369     }
370     return i;
371   }
372
373   int main() {
374     char chars[100];
375     int n = bzero1(&chars[0]);
376     assert(n == sizeof(chars));
377     return 0;
378   }
379
380 If successfully evaluating ``__builtin_object_size(param, Type)`` at the
381 callsite is not possible, then the "failed" value is passed in. So, using the
382 definition of ``bzero1`` from above, the following code would exit cleanly:
383
384 .. code-block:: c
385
386   int main2(int argc, char *argv[]) {
387     int n = bzero1(argv);
388     assert(n == -1);
389     return 0;
390   }
391
392 ``pass_object_size`` plays a part in overload resolution. If two overload
393 candidates are otherwise equally good, then the overload with one or more
394 parameters with ``pass_object_size`` is preferred. This implies that the choice
395 between two identical overloads both with ``pass_object_size`` on one or more
396 parameters will always be ambiguous; for this reason, having two such overloads
397 is illegal. For example:
398
399 .. code-block:: c++
400
401   #define PS(N) __attribute__((pass_object_size(N)))
402   // OK
403   void Foo(char *a, char *b); // Overload A
404   // OK -- overload A has no parameters with pass_object_size.
405   void Foo(char *a PS(0), char *b PS(0)); // Overload B
406   // Error -- Same signature (sans pass_object_size) as overload B, and both
407   // overloads have one or more parameters with the pass_object_size attribute.
408   void Foo(void *a PS(0), void *b);
409
410   // OK
411   void Bar(void *a PS(0)); // Overload C
412   // OK
413   void Bar(char *c PS(1)); // Overload D
414
415   void main() {
416     char known[10], *unknown;
417     Foo(unknown, unknown); // Calls overload B
418     Foo(known, unknown); // Calls overload B
419     Foo(unknown, known); // Calls overload B
420     Foo(known, known); // Calls overload B
421
422     Bar(known); // Calls overload D
423     Bar(unknown); // Calls overload D
424   }
425
426 Currently, ``pass_object_size`` is a bit restricted in terms of its usage:
427
428 * Only one use of ``pass_object_size`` is allowed per parameter.
429
430 * It is an error to take the address of a function with ``pass_object_size`` on
431   any of its parameters. If you wish to do this, you can create an overload
432   without ``pass_object_size`` on any parameters.
433
434 * It is an error to apply the ``pass_object_size`` attribute to parameters that
435   are not pointers. Additionally, any parameter that ``pass_object_size`` is
436   applied to must be marked ``const`` at its function's definition.
437   }];
438 }
439
440 def OverloadableDocs : Documentation {
441   let Category = DocCatFunction;
442   let Content = [{
443 Clang provides support for C++ function overloading in C.  Function overloading
444 in C is introduced using the ``overloadable`` attribute.  For example, one
445 might provide several overloaded versions of a ``tgsin`` function that invokes
446 the appropriate standard function computing the sine of a value with ``float``,
447 ``double``, or ``long double`` precision:
448
449 .. code-block:: c
450
451   #include <math.h>
452   float __attribute__((overloadable)) tgsin(float x) { return sinf(x); }
453   double __attribute__((overloadable)) tgsin(double x) { return sin(x); }
454   long double __attribute__((overloadable)) tgsin(long double x) { return sinl(x); }
455
456 Given these declarations, one can call ``tgsin`` with a ``float`` value to
457 receive a ``float`` result, with a ``double`` to receive a ``double`` result,
458 etc.  Function overloading in C follows the rules of C++ function overloading
459 to pick the best overload given the call arguments, with a few C-specific
460 semantics:
461
462 * Conversion from ``float`` or ``double`` to ``long double`` is ranked as a
463   floating-point promotion (per C99) rather than as a floating-point conversion
464   (as in C++).
465
466 * A conversion from a pointer of type ``T*`` to a pointer of type ``U*`` is
467   considered a pointer conversion (with conversion rank) if ``T`` and ``U`` are
468   compatible types.
469
470 * A conversion from type ``T`` to a value of type ``U`` is permitted if ``T``
471   and ``U`` are compatible types.  This conversion is given "conversion" rank.
472
473 The declaration of ``overloadable`` functions is restricted to function
474 declarations and definitions.  Most importantly, if any function with a given
475 name is given the ``overloadable`` attribute, then all function declarations
476 and definitions with that name (and in that scope) must have the
477 ``overloadable`` attribute.  This rule even applies to redeclarations of
478 functions whose original declaration had the ``overloadable`` attribute, e.g.,
479
480 .. code-block:: c
481
482   int f(int) __attribute__((overloadable));
483   float f(float); // error: declaration of "f" must have the "overloadable" attribute
484
485   int g(int) __attribute__((overloadable));
486   int g(int) { } // error: redeclaration of "g" must also have the "overloadable" attribute
487
488 Functions marked ``overloadable`` must have prototypes.  Therefore, the
489 following code is ill-formed:
490
491 .. code-block:: c
492
493   int h() __attribute__((overloadable)); // error: h does not have a prototype
494
495 However, ``overloadable`` functions are allowed to use a ellipsis even if there
496 are no named parameters (as is permitted in C++).  This feature is particularly
497 useful when combined with the ``unavailable`` attribute:
498
499 .. code-block:: c++
500
501   void honeypot(...) __attribute__((overloadable, unavailable)); // calling me is an error
502
503 Functions declared with the ``overloadable`` attribute have their names mangled
504 according to the same rules as C++ function names.  For example, the three
505 ``tgsin`` functions in our motivating example get the mangled names
506 ``_Z5tgsinf``, ``_Z5tgsind``, and ``_Z5tgsine``, respectively.  There are two
507 caveats to this use of name mangling:
508
509 * Future versions of Clang may change the name mangling of functions overloaded
510   in C, so you should not depend on an specific mangling.  To be completely
511   safe, we strongly urge the use of ``static inline`` with ``overloadable``
512   functions.
513
514 * The ``overloadable`` attribute has almost no meaning when used in C++,
515   because names will already be mangled and functions are already overloadable.
516   However, when an ``overloadable`` function occurs within an ``extern "C"``
517   linkage specification, it's name *will* be mangled in the same way as it
518   would in C.
519
520 Query for this feature with ``__has_extension(attribute_overloadable)``.
521   }];
522 }
523
524 def ObjCMethodFamilyDocs : Documentation {
525   let Category = DocCatFunction;
526   let Content = [{
527 Many methods in Objective-C have conventional meanings determined by their
528 selectors. It is sometimes useful to be able to mark a method as having a
529 particular conventional meaning despite not having the right selector, or as
530 not having the conventional meaning that its selector would suggest. For these
531 use cases, we provide an attribute to specifically describe the "method family"
532 that a method belongs to.
533
534 **Usage**: ``__attribute__((objc_method_family(X)))``, where ``X`` is one of
535 ``none``, ``alloc``, ``copy``, ``init``, ``mutableCopy``, or ``new``.  This
536 attribute can only be placed at the end of a method declaration:
537
538 .. code-block:: objc
539
540   - (NSString *)initMyStringValue __attribute__((objc_method_family(none)));
541
542 Users who do not wish to change the conventional meaning of a method, and who
543 merely want to document its non-standard retain and release semantics, should
544 use the retaining behavior attributes (``ns_returns_retained``,
545 ``ns_returns_not_retained``, etc).
546
547 Query for this feature with ``__has_attribute(objc_method_family)``.
548   }];
549 }
550
551 def NoDebugDocs : Documentation {
552   let Category = DocCatVariable;
553   let Content = [{
554 The ``nodebug`` attribute allows you to suppress debugging information for a
555 function or method, or for a variable that is not a parameter or a non-static
556 data member.
557   }];
558 }
559
560 def NoDuplicateDocs : Documentation {
561   let Category = DocCatFunction;
562   let Content = [{
563 The ``noduplicate`` attribute can be placed on function declarations to control
564 whether function calls to this function can be duplicated or not as a result of
565 optimizations. This is required for the implementation of functions with
566 certain special requirements, like the OpenCL "barrier" function, that might
567 need to be run concurrently by all the threads that are executing in lockstep
568 on the hardware. For example this attribute applied on the function
569 "nodupfunc" in the code below avoids that:
570
571 .. code-block:: c
572
573   void nodupfunc() __attribute__((noduplicate));
574   // Setting it as a C++11 attribute is also valid
575   // void nodupfunc() [[clang::noduplicate]];
576   void foo();
577   void bar();
578
579   nodupfunc();
580   if (a > n) {
581     foo();
582   } else {
583     bar();
584   }
585
586 gets possibly modified by some optimizations into code similar to this:
587
588 .. code-block:: c
589
590   if (a > n) {
591     nodupfunc();
592     foo();
593   } else {
594     nodupfunc();
595     bar();
596   }
597
598 where the call to "nodupfunc" is duplicated and sunk into the two branches
599 of the condition.
600   }];
601 }
602
603 def NoSplitStackDocs : Documentation {
604   let Category = DocCatFunction;
605   let Content = [{
606 The ``no_split_stack`` attribute disables the emission of the split stack
607 preamble for a particular function. It has no effect if ``-fsplit-stack``
608 is not specified.
609   }];
610 }
611
612 def ObjCRequiresSuperDocs : Documentation {
613   let Category = DocCatFunction;
614   let Content = [{
615 Some Objective-C classes allow a subclass to override a particular method in a
616 parent class but expect that the overriding method also calls the overridden
617 method in the parent class. For these cases, we provide an attribute to
618 designate that a method requires a "call to ``super``" in the overriding
619 method in the subclass.
620
621 **Usage**: ``__attribute__((objc_requires_super))``.  This attribute can only
622 be placed at the end of a method declaration:
623
624 .. code-block:: objc
625
626   - (void)foo __attribute__((objc_requires_super));
627
628 This attribute can only be applied the method declarations within a class, and
629 not a protocol.  Currently this attribute does not enforce any placement of
630 where the call occurs in the overriding method (such as in the case of
631 ``-dealloc`` where the call must appear at the end).  It checks only that it
632 exists.
633
634 Note that on both OS X and iOS that the Foundation framework provides a
635 convenience macro ``NS_REQUIRES_SUPER`` that provides syntactic sugar for this
636 attribute:
637
638 .. code-block:: objc
639
640   - (void)foo NS_REQUIRES_SUPER;
641
642 This macro is conditionally defined depending on the compiler's support for
643 this attribute.  If the compiler does not support the attribute the macro
644 expands to nothing.
645
646 Operationally, when a method has this annotation the compiler will warn if the
647 implementation of an override in a subclass does not call super.  For example:
648
649 .. code-block:: objc
650
651    warning: method possibly missing a [super AnnotMeth] call
652    - (void) AnnotMeth{};
653                       ^
654   }];
655 }
656
657 def ObjCRuntimeNameDocs : Documentation {
658     let Category = DocCatFunction;
659     let Content = [{
660 By default, the Objective-C interface or protocol identifier is used
661 in the metadata name for that object. The `objc_runtime_name`
662 attribute allows annotated interfaces or protocols to use the
663 specified string argument in the object's metadata name instead of the
664 default name.
665         
666 **Usage**: ``__attribute__((objc_runtime_name("MyLocalName")))``.  This attribute
667 can only be placed before an @protocol or @interface declaration:
668         
669 .. code-block:: objc
670         
671   __attribute__((objc_runtime_name("MyLocalName")))
672   @interface Message
673   @end
674         
675     }];
676 }
677
678 def ObjCRuntimeVisibleDocs : Documentation {
679     let Category = DocCatFunction;
680     let Content = [{
681 This attribute specifies that the Objective-C class to which it applies is visible to the Objective-C runtime but not to the linker. Classes annotated with this attribute cannot be subclassed and cannot have categories defined for them.
682     }];
683 }
684
685 def ObjCBoxableDocs : Documentation {
686     let Category = DocCatFunction;
687     let Content = [{
688 Structs and unions marked with the ``objc_boxable`` attribute can be used 
689 with the Objective-C boxed expression syntax, ``@(...)``.
690
691 **Usage**: ``__attribute__((objc_boxable))``. This attribute 
692 can only be placed on a declaration of a trivially-copyable struct or union:
693
694 .. code-block:: objc
695
696   struct __attribute__((objc_boxable)) some_struct {
697     int i;
698   };
699   union __attribute__((objc_boxable)) some_union {
700     int i;
701     float f;
702   };
703   typedef struct __attribute__((objc_boxable)) _some_struct some_struct;
704
705   // ...
706
707   some_struct ss;
708   NSValue *boxed = @(ss);
709
710     }];
711 }
712
713 def AvailabilityDocs : Documentation {
714   let Category = DocCatFunction;
715   let Content = [{
716 The ``availability`` attribute can be placed on declarations to describe the
717 lifecycle of that declaration relative to operating system versions.  Consider
718 the function declaration for a hypothetical function ``f``:
719
720 .. code-block:: c++
721
722   void f(void) __attribute__((availability(macos,introduced=10.4,deprecated=10.6,obsoleted=10.7)));
723
724 The availability attribute states that ``f`` was introduced in Mac OS X 10.4,
725 deprecated in Mac OS X 10.6, and obsoleted in Mac OS X 10.7.  This information
726 is used by Clang to determine when it is safe to use ``f``: for example, if
727 Clang is instructed to compile code for Mac OS X 10.5, a call to ``f()``
728 succeeds.  If Clang is instructed to compile code for Mac OS X 10.6, the call
729 succeeds but Clang emits a warning specifying that the function is deprecated.
730 Finally, if Clang is instructed to compile code for Mac OS X 10.7, the call
731 fails because ``f()`` is no longer available.
732
733 The availability attribute is a comma-separated list starting with the
734 platform name and then including clauses specifying important milestones in the
735 declaration's lifetime (in any order) along with additional information.  Those
736 clauses can be:
737
738 introduced=\ *version*
739   The first version in which this declaration was introduced.
740
741 deprecated=\ *version*
742   The first version in which this declaration was deprecated, meaning that
743   users should migrate away from this API.
744
745 obsoleted=\ *version*
746   The first version in which this declaration was obsoleted, meaning that it
747   was removed completely and can no longer be used.
748
749 unavailable
750   This declaration is never available on this platform.
751
752 message=\ *string-literal*
753   Additional message text that Clang will provide when emitting a warning or
754   error about use of a deprecated or obsoleted declaration.  Useful to direct
755   users to replacement APIs.
756
757 replacement=\ *string-literal*
758   Additional message text that Clang will use to provide Fix-It when emitting
759   a warning about use of a deprecated declaration. The Fix-It will replace
760   the deprecated declaration with the new declaration specified.
761
762 Multiple availability attributes can be placed on a declaration, which may
763 correspond to different platforms.  Only the availability attribute with the
764 platform corresponding to the target platform will be used; any others will be
765 ignored.  If no availability attribute specifies availability for the current
766 target platform, the availability attributes are ignored.  Supported platforms
767 are:
768
769 ``ios``
770   Apple's iOS operating system.  The minimum deployment target is specified by
771   the ``-mios-version-min=*version*`` or ``-miphoneos-version-min=*version*``
772   command-line arguments.
773
774 ``macos``
775   Apple's Mac OS X operating system.  The minimum deployment target is
776   specified by the ``-mmacosx-version-min=*version*`` command-line argument.
777   ``macosx`` is supported for backward-compatibility reasons, but it is
778   deprecated.
779
780 ``tvos``
781   Apple's tvOS operating system.  The minimum deployment target is specified by
782   the ``-mtvos-version-min=*version*`` command-line argument.
783
784 ``watchos``
785   Apple's watchOS operating system.  The minimum deployment target is specified by
786   the ``-mwatchos-version-min=*version*`` command-line argument.
787
788 A declaration can typically be used even when deploying back to a platform
789 version prior to when the declaration was introduced.  When this happens, the
790 declaration is `weakly linked
791 <https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html>`_,
792 as if the ``weak_import`` attribute were added to the declaration.  A
793 weakly-linked declaration may or may not be present a run-time, and a program
794 can determine whether the declaration is present by checking whether the
795 address of that declaration is non-NULL.
796
797 The flag ``strict`` disallows using API when deploying back to a
798 platform version prior to when the declaration was introduced.  An
799 attempt to use such API before its introduction causes a hard error.
800 Weakly-linking is almost always a better API choice, since it allows
801 users to query availability at runtime.
802
803 If there are multiple declarations of the same entity, the availability
804 attributes must either match on a per-platform basis or later
805 declarations must not have availability attributes for that
806 platform. For example:
807
808 .. code-block:: c
809
810   void g(void) __attribute__((availability(macos,introduced=10.4)));
811   void g(void) __attribute__((availability(macos,introduced=10.4))); // okay, matches
812   void g(void) __attribute__((availability(ios,introduced=4.0))); // okay, adds a new platform
813   void g(void); // okay, inherits both macos and ios availability from above.
814   void g(void) __attribute__((availability(macos,introduced=10.5))); // error: mismatch
815
816 When one method overrides another, the overriding method can be more widely available than the overridden method, e.g.,:
817
818 .. code-block:: objc
819
820   @interface A
821   - (id)method __attribute__((availability(macos,introduced=10.4)));
822   - (id)method2 __attribute__((availability(macos,introduced=10.4)));
823   @end
824
825   @interface B : A
826   - (id)method __attribute__((availability(macos,introduced=10.3))); // okay: method moved into base class later
827   - (id)method __attribute__((availability(macos,introduced=10.5))); // error: this method was available via the base class in 10.4
828   @end
829   }];
830 }
831
832 def WarnMaybeUnusedDocs : Documentation {
833   let Category = DocCatVariable;
834   let Heading = "maybe_unused, unused, gnu::unused";
835   let Content = [{
836 When passing the ``-Wunused`` flag to Clang, entities that are unused by the
837 program may be diagnosed. The ``[[maybe_unused]]`` (or
838 ``__attribute__((unused))``) attribute can be used to silence such diagnostics
839 when the entity cannot be removed. For instance, a local variable may exist
840 solely for use in an ``assert()`` statement, which makes the local variable
841 unused when ``NDEBUG`` is defined.
842
843 The attribute may be applied to the declaration of a class, a typedef, a
844 variable, a function or method, a function parameter, an enumeration, an
845 enumerator, a non-static data member, or a label.
846
847 .. code-block: c++
848   #include <cassert>\r
849 \r
850   [[maybe_unused]] void f([[maybe_unused]] bool thing1,\r
851                           [[maybe_unused]] bool thing2) {\r
852     [[maybe_unused]] bool b = thing1 && thing2;\r
853     assert(b);\r
854   }
855   }];
856 }
857
858 def WarnUnusedResultsDocs : Documentation {
859   let Category = DocCatFunction;
860   let Heading = "nodiscard, warn_unused_result, clang::warn_unused_result, gnu::warn_unused_result";
861   let Content  = [{
862 Clang supports the ability to diagnose when the results of a function call
863 expression are discarded under suspicious circumstances. A diagnostic is
864 generated when a function or its return type is marked with ``[[nodiscard]]``
865 (or ``__attribute__((warn_unused_result))``) and the function call appears as a
866 potentially-evaluated discarded-value expression that is not explicitly cast to
867 `void`.
868
869 .. code-block: c++
870   struct [[nodiscard]] error_info { /*...*/ };\r
871   error_info enable_missile_safety_mode();\r
872   \r
873   void launch_missiles();\r
874   void test_missiles() {\r
875     enable_missile_safety_mode(); // diagnoses\r
876     launch_missiles();\r
877   }\r
878   error_info &foo();\r
879   void f() { foo(); } // Does not diagnose, error_info is a reference.  
880   }];
881 }
882
883 def FallthroughDocs : Documentation {
884   let Category = DocCatStmt;
885   let Heading = "fallthrough, clang::fallthrough";
886   let Content = [{
887 The ``fallthrough`` (or ``clang::fallthrough``) attribute is used
888 to annotate intentional fall-through
889 between switch labels.  It can only be applied to a null statement placed at a
890 point of execution between any statement and the next switch label.  It is
891 common to mark these places with a specific comment, but this attribute is
892 meant to replace comments with a more strict annotation, which can be checked
893 by the compiler.  This attribute doesn't change semantics of the code and can
894 be used wherever an intended fall-through occurs.  It is designed to mimic
895 control-flow statements like ``break;``, so it can be placed in most places
896 where ``break;`` can, but only if there are no statements on the execution path
897 between it and the next switch label.
898
899 By default, Clang does not warn on unannotated fallthrough from one ``switch``
900 case to another. Diagnostics on fallthrough without a corresponding annotation
901 can be enabled with the ``-Wimplicit-fallthrough`` argument.
902
903 Here is an example:
904
905 .. code-block:: c++
906
907   // compile with -Wimplicit-fallthrough
908   switch (n) {
909   case 22:
910   case 33:  // no warning: no statements between case labels
911     f();
912   case 44:  // warning: unannotated fall-through
913     g();
914     [[clang::fallthrough]];
915   case 55:  // no warning
916     if (x) {
917       h();
918       break;
919     }
920     else {
921       i();
922       [[clang::fallthrough]];
923     }
924   case 66:  // no warning
925     p();
926     [[clang::fallthrough]]; // warning: fallthrough annotation does not
927                             //          directly precede case label
928     q();
929   case 77:  // warning: unannotated fall-through
930     r();
931   }
932   }];
933 }
934
935 def ARMInterruptDocs : Documentation {
936   let Category = DocCatFunction;
937   let Content = [{
938 Clang supports the GNU style ``__attribute__((interrupt("TYPE")))`` attribute on
939 ARM targets. This attribute may be attached to a function definition and
940 instructs the backend to generate appropriate function entry/exit code so that
941 it can be used directly as an interrupt service routine.
942
943 The parameter passed to the interrupt attribute is optional, but if
944 provided it must be a string literal with one of the following values: "IRQ",
945 "FIQ", "SWI", "ABORT", "UNDEF".
946
947 The semantics are as follows:
948
949 - If the function is AAPCS, Clang instructs the backend to realign the stack to
950   8 bytes on entry. This is a general requirement of the AAPCS at public
951   interfaces, but may not hold when an exception is taken. Doing this allows
952   other AAPCS functions to be called.
953 - If the CPU is M-class this is all that needs to be done since the architecture
954   itself is designed in such a way that functions obeying the normal AAPCS ABI
955   constraints are valid exception handlers.
956 - If the CPU is not M-class, the prologue and epilogue are modified to save all
957   non-banked registers that are used, so that upon return the user-mode state
958   will not be corrupted. Note that to avoid unnecessary overhead, only
959   general-purpose (integer) registers are saved in this way. If VFP operations
960   are needed, that state must be saved manually.
961
962   Specifically, interrupt kinds other than "FIQ" will save all core registers
963   except "lr" and "sp". "FIQ" interrupts will save r0-r7.
964 - If the CPU is not M-class, the return instruction is changed to one of the
965   canonical sequences permitted by the architecture for exception return. Where
966   possible the function itself will make the necessary "lr" adjustments so that
967   the "preferred return address" is selected.
968
969   Unfortunately the compiler is unable to make this guarantee for an "UNDEF"
970   handler, where the offset from "lr" to the preferred return address depends on
971   the execution state of the code which generated the exception. In this case
972   a sequence equivalent to "movs pc, lr" will be used.
973   }];
974 }
975
976 def MipsInterruptDocs : Documentation {
977   let Category = DocCatFunction;
978   let Content = [{
979 Clang supports the GNU style ``__attribute__((interrupt("ARGUMENT")))`` attribute on
980 MIPS targets. This attribute may be attached to a function definition and instructs
981 the backend to generate appropriate function entry/exit code so that it can be used
982 directly as an interrupt service routine.
983
984 By default, the compiler will produce a function prologue and epilogue suitable for
985 an interrupt service routine that handles an External Interrupt Controller (eic)
986 generated interrupt. This behaviour can be explicitly requested with the "eic"
987 argument.
988
989 Otherwise, for use with vectored interrupt mode, the argument passed should be
990 of the form "vector=LEVEL" where LEVEL is one of the following values:
991 "sw0", "sw1", "hw0", "hw1", "hw2", "hw3", "hw4", "hw5". The compiler will
992 then set the interrupt mask to the corresponding level which will mask all
993 interrupts up to and including the argument.
994
995 The semantics are as follows:
996
997 - The prologue is modified so that the Exception Program Counter (EPC) and
998   Status coprocessor registers are saved to the stack. The interrupt mask is
999   set so that the function can only be interrupted by a higher priority
1000   interrupt. The epilogue will restore the previous values of EPC and Status.
1001
1002 - The prologue and epilogue are modified to save and restore all non-kernel
1003   registers as necessary.
1004
1005 - The FPU is disabled in the prologue, as the floating pointer registers are not
1006   spilled to the stack.
1007
1008 - The function return sequence is changed to use an exception return instruction.
1009
1010 - The parameter sets the interrupt mask for the function corresponding to the
1011   interrupt level specified. If no mask is specified the interrupt mask
1012   defaults to "eic".
1013   }];
1014 }
1015
1016 def TargetDocs : Documentation {
1017   let Category = DocCatFunction;
1018   let Content = [{
1019 Clang supports the GNU style ``__attribute__((target("OPTIONS")))`` attribute.
1020 This attribute may be attached to a function definition and instructs
1021 the backend to use different code generation options than were passed on the
1022 command line.
1023
1024 The current set of options correspond to the existing "subtarget features" for
1025 the target with or without a "-mno-" in front corresponding to the absence
1026 of the feature, as well as ``arch="CPU"`` which will change the default "CPU"
1027 for the function.
1028
1029 Example "subtarget features" from the x86 backend include: "mmx", "sse", "sse4.2",
1030 "avx", "xop" and largely correspond to the machine specific options handled by
1031 the front end.
1032 }];
1033 }
1034
1035 def DocCatAMDGPURegisterAttributes :
1036   DocumentationCategory<"AMD GPU Register Attributes"> {
1037   let Content = [{
1038 Clang supports attributes for controlling register usage on AMD GPU
1039 targets. These attributes may be attached to a kernel function
1040 definition and is an optimization hint to the backend for the maximum
1041 number of registers to use. This is useful in cases where register
1042 limited occupancy is known to be an important factor for the
1043 performance for the kernel.
1044
1045 The semantics are as follows:
1046
1047 - The backend will attempt to limit the number of used registers to
1048   the specified value, but the exact number used is not
1049   guaranteed. The number used may be rounded up to satisfy the
1050   allocation requirements or ABI constraints of the subtarget. For
1051   example, on Southern Islands VGPRs may only be allocated in
1052   increments of 4, so requesting a limit of 39 VGPRs will really
1053   attempt to use up to 40. Requesting more registers than the
1054   subtarget supports will truncate to the maximum allowed. The backend
1055   may also use fewer registers than requested whenever possible.
1056
1057 - 0 implies the default no limit on register usage.
1058
1059 - Ignored on older VLIW subtargets which did not have separate scalar
1060   and vector registers, R600 through Northern Islands.
1061
1062 }];
1063 }
1064
1065
1066 def AMDGPUNumVGPRDocs : Documentation {
1067   let Category = DocCatAMDGPURegisterAttributes;
1068   let Content = [{
1069 Clang supports the
1070 ``__attribute__((amdgpu_num_vgpr(<num_registers>)))`` attribute on AMD
1071 Southern Islands GPUs and later for controlling the number of vector
1072 registers. A typical value would be between 4 and 256 in increments
1073 of 4.
1074 }];
1075 }
1076
1077 def AMDGPUNumSGPRDocs : Documentation {
1078   let Category = DocCatAMDGPURegisterAttributes;
1079   let Content = [{
1080
1081 Clang supports the
1082 ``__attribute__((amdgpu_num_sgpr(<num_registers>)))`` attribute on AMD
1083 Southern Islands GPUs and later for controlling the number of scalar
1084 registers. A typical value would be between 8 and 104 in increments of
1085 8.
1086
1087 Due to common instruction constraints, an additional 2-4 SGPRs are
1088 typically required for internal use depending on features used. This
1089 value is a hint for the total number of SGPRs to use, and not the
1090 number of user SGPRs, so no special consideration needs to be given
1091 for these.
1092 }];
1093 }
1094
1095 def DocCatCallingConvs : DocumentationCategory<"Calling Conventions"> {
1096   let Content = [{
1097 Clang supports several different calling conventions, depending on the target
1098 platform and architecture. The calling convention used for a function determines
1099 how parameters are passed, how results are returned to the caller, and other
1100 low-level details of calling a function.
1101   }];
1102 }
1103
1104 def PcsDocs : Documentation {
1105   let Category = DocCatCallingConvs;
1106   let Content = [{
1107 On ARM targets, this attribute can be used to select calling conventions
1108 similar to ``stdcall`` on x86. Valid parameter values are "aapcs" and
1109 "aapcs-vfp".
1110   }];
1111 }
1112
1113 def RegparmDocs : Documentation {
1114   let Category = DocCatCallingConvs;
1115   let Content = [{
1116 On 32-bit x86 targets, the regparm attribute causes the compiler to pass
1117 the first three integer parameters in EAX, EDX, and ECX instead of on the
1118 stack. This attribute has no effect on variadic functions, and all parameters
1119 are passed via the stack as normal.
1120   }];
1121 }
1122
1123 def SysVABIDocs : Documentation {
1124   let Category = DocCatCallingConvs;
1125   let Content = [{
1126 On Windows x86_64 targets, this attribute changes the calling convention of a
1127 function to match the default convention used on Sys V targets such as Linux,
1128 Mac, and BSD. This attribute has no effect on other targets.
1129   }];
1130 }
1131
1132 def MSABIDocs : Documentation {
1133   let Category = DocCatCallingConvs;
1134   let Content = [{
1135 On non-Windows x86_64 targets, this attribute changes the calling convention of
1136 a function to match the default convention used on Windows x86_64. This
1137 attribute has no effect on Windows targets or non-x86_64 targets.
1138   }];
1139 }
1140
1141 def StdCallDocs : Documentation {
1142   let Category = DocCatCallingConvs;
1143   let Content = [{
1144 On 32-bit x86 targets, this attribute changes the calling convention of a
1145 function to clear parameters off of the stack on return. This convention does
1146 not support variadic calls or unprototyped functions in C, and has no effect on
1147 x86_64 targets. This calling convention is used widely by the Windows API and
1148 COM applications.  See the documentation for `__stdcall`_ on MSDN.
1149
1150 .. _`__stdcall`: http://msdn.microsoft.com/en-us/library/zxk0tw93.aspx
1151   }];
1152 }
1153
1154 def FastCallDocs : Documentation {
1155   let Category = DocCatCallingConvs;
1156   let Content = [{
1157 On 32-bit x86 targets, this attribute changes the calling convention of a
1158 function to use ECX and EDX as register parameters and clear parameters off of
1159 the stack on return. This convention does not support variadic calls or
1160 unprototyped functions in C, and has no effect on x86_64 targets. This calling
1161 convention is supported primarily for compatibility with existing code. Users
1162 seeking register parameters should use the ``regparm`` attribute, which does
1163 not require callee-cleanup.  See the documentation for `__fastcall`_ on MSDN.
1164
1165 .. _`__fastcall`: http://msdn.microsoft.com/en-us/library/6xa169sk.aspx
1166   }];
1167 }
1168
1169 def ThisCallDocs : Documentation {
1170   let Category = DocCatCallingConvs;
1171   let Content = [{
1172 On 32-bit x86 targets, this attribute changes the calling convention of a
1173 function to use ECX for the first parameter (typically the implicit ``this``
1174 parameter of C++ methods) and clear parameters off of the stack on return. This
1175 convention does not support variadic calls or unprototyped functions in C, and
1176 has no effect on x86_64 targets. See the documentation for `__thiscall`_ on
1177 MSDN.
1178
1179 .. _`__thiscall`: http://msdn.microsoft.com/en-us/library/ek8tkfbw.aspx
1180   }];
1181 }
1182
1183 def VectorCallDocs : Documentation {
1184   let Category = DocCatCallingConvs;
1185   let Content = [{
1186 On 32-bit x86 *and* x86_64 targets, this attribute changes the calling
1187 convention of a function to pass vector parameters in SSE registers.
1188
1189 On 32-bit x86 targets, this calling convention is similar to ``__fastcall``.
1190 The first two integer parameters are passed in ECX and EDX. Subsequent integer
1191 parameters are passed in memory, and callee clears the stack.  On x86_64
1192 targets, the callee does *not* clear the stack, and integer parameters are
1193 passed in RCX, RDX, R8, and R9 as is done for the default Windows x64 calling
1194 convention.
1195
1196 On both 32-bit x86 and x86_64 targets, vector and floating point arguments are
1197 passed in XMM0-XMM5. Homogenous vector aggregates of up to four elements are
1198 passed in sequential SSE registers if enough are available. If AVX is enabled,
1199 256 bit vectors are passed in YMM0-YMM5. Any vector or aggregate type that
1200 cannot be passed in registers for any reason is passed by reference, which
1201 allows the caller to align the parameter memory.
1202
1203 See the documentation for `__vectorcall`_ on MSDN for more details.
1204
1205 .. _`__vectorcall`: http://msdn.microsoft.com/en-us/library/dn375768.aspx
1206   }];
1207 }
1208
1209 def DocCatConsumed : DocumentationCategory<"Consumed Annotation Checking"> {
1210   let Content = [{
1211 Clang supports additional attributes for checking basic resource management
1212 properties, specifically for unique objects that have a single owning reference.
1213 The following attributes are currently supported, although **the implementation
1214 for these annotations is currently in development and are subject to change.**
1215   }];
1216 }
1217
1218 def SetTypestateDocs : Documentation {
1219   let Category = DocCatConsumed;
1220   let Content = [{
1221 Annotate methods that transition an object into a new state with
1222 ``__attribute__((set_typestate(new_state)))``.  The new state must be
1223 unconsumed, consumed, or unknown.
1224   }];
1225 }
1226
1227 def CallableWhenDocs : Documentation {
1228   let Category = DocCatConsumed;
1229   let Content = [{
1230 Use ``__attribute__((callable_when(...)))`` to indicate what states a method
1231 may be called in.  Valid states are unconsumed, consumed, or unknown.  Each
1232 argument to this attribute must be a quoted string.  E.g.:
1233
1234 ``__attribute__((callable_when("unconsumed", "unknown")))``
1235   }];
1236 }
1237
1238 def TestTypestateDocs : Documentation {
1239   let Category = DocCatConsumed;
1240   let Content = [{
1241 Use ``__attribute__((test_typestate(tested_state)))`` to indicate that a method
1242 returns true if the object is in the specified state..
1243   }];
1244 }
1245
1246 def ParamTypestateDocs : Documentation {
1247   let Category = DocCatConsumed;
1248   let Content = [{
1249 This attribute specifies expectations about function parameters.  Calls to an
1250 function with annotated parameters will issue a warning if the corresponding
1251 argument isn't in the expected state.  The attribute is also used to set the
1252 initial state of the parameter when analyzing the function's body.
1253   }];
1254 }
1255
1256 def ReturnTypestateDocs : Documentation {
1257   let Category = DocCatConsumed;
1258   let Content = [{
1259 The ``return_typestate`` attribute can be applied to functions or parameters.
1260 When applied to a function the attribute specifies the state of the returned
1261 value.  The function's body is checked to ensure that it always returns a value
1262 in the specified state.  On the caller side, values returned by the annotated
1263 function are initialized to the given state.
1264
1265 When applied to a function parameter it modifies the state of an argument after
1266 a call to the function returns.  The function's body is checked to ensure that
1267 the parameter is in the expected state before returning.
1268   }];
1269 }
1270
1271 def ConsumableDocs : Documentation {
1272   let Category = DocCatConsumed;
1273   let Content = [{
1274 Each ``class`` that uses any of the typestate annotations must first be marked
1275 using the ``consumable`` attribute.  Failure to do so will result in a warning.
1276
1277 This attribute accepts a single parameter that must be one of the following:
1278 ``unknown``, ``consumed``, or ``unconsumed``.
1279   }];
1280 }
1281
1282 def NoSanitizeDocs : Documentation {
1283   let Category = DocCatFunction;
1284   let Content = [{
1285 Use the ``no_sanitize`` attribute on a function declaration to specify
1286 that a particular instrumentation or set of instrumentations should not be
1287 applied to that function. The attribute takes a list of string literals,
1288 which have the same meaning as values accepted by the ``-fno-sanitize=``
1289 flag. For example, ``__attribute__((no_sanitize("address", "thread")))``
1290 specifies that AddressSanitizer and ThreadSanitizer should not be applied
1291 to the function.
1292
1293 See :ref:`Controlling Code Generation <controlling-code-generation>` for a
1294 full list of supported sanitizer flags.
1295   }];
1296 }
1297
1298 def NoSanitizeAddressDocs : Documentation {
1299   let Category = DocCatFunction;
1300   // This function has multiple distinct spellings, and so it requires a custom
1301   // heading to be specified. The most common spelling is sufficient.
1302   let Heading = "no_sanitize_address (no_address_safety_analysis, gnu::no_address_safety_analysis, gnu::no_sanitize_address)";
1303   let Content = [{
1304 .. _langext-address_sanitizer:
1305
1306 Use ``__attribute__((no_sanitize_address))`` on a function declaration to
1307 specify that address safety instrumentation (e.g. AddressSanitizer) should
1308 not be applied to that function.
1309   }];
1310 }
1311
1312 def NoSanitizeThreadDocs : Documentation {
1313   let Category = DocCatFunction;
1314   let Heading = "no_sanitize_thread";
1315   let Content = [{
1316 .. _langext-thread_sanitizer:
1317
1318 Use ``__attribute__((no_sanitize_thread))`` on a function declaration to
1319 specify that checks for data races on plain (non-atomic) memory accesses should
1320 not be inserted by ThreadSanitizer. The function is still instrumented by the
1321 tool to avoid false positives and provide meaningful stack traces.
1322   }];
1323 }
1324
1325 def NoSanitizeMemoryDocs : Documentation {
1326   let Category = DocCatFunction;
1327   let Heading = "no_sanitize_memory";
1328   let Content = [{
1329 .. _langext-memory_sanitizer:
1330
1331 Use ``__attribute__((no_sanitize_memory))`` on a function declaration to
1332 specify that checks for uninitialized memory should not be inserted 
1333 (e.g. by MemorySanitizer). The function may still be instrumented by the tool
1334 to avoid false positives in other places.
1335   }];
1336 }
1337
1338 def DocCatTypeSafety : DocumentationCategory<"Type Safety Checking"> {
1339   let Content = [{
1340 Clang supports additional attributes to enable checking type safety properties
1341 that can't be enforced by the C type system.  Use cases include:
1342
1343 * MPI library implementations, where these attributes enable checking that
1344   the buffer type matches the passed ``MPI_Datatype``;
1345 * for HDF5 library there is a similar use case to MPI;
1346 * checking types of variadic functions' arguments for functions like
1347   ``fcntl()`` and ``ioctl()``.
1348
1349 You can detect support for these attributes with ``__has_attribute()``.  For
1350 example:
1351
1352 .. code-block:: c++
1353
1354   #if defined(__has_attribute)
1355   #  if __has_attribute(argument_with_type_tag) && \
1356         __has_attribute(pointer_with_type_tag) && \
1357         __has_attribute(type_tag_for_datatype)
1358   #    define ATTR_MPI_PWT(buffer_idx, type_idx) __attribute__((pointer_with_type_tag(mpi,buffer_idx,type_idx)))
1359   /* ... other macros ...  */
1360   #  endif
1361   #endif
1362
1363   #if !defined(ATTR_MPI_PWT)
1364   # define ATTR_MPI_PWT(buffer_idx, type_idx)
1365   #endif
1366
1367   int MPI_Send(void *buf, int count, MPI_Datatype datatype /*, other args omitted */)
1368       ATTR_MPI_PWT(1,3);
1369   }];
1370 }
1371
1372 def ArgumentWithTypeTagDocs : Documentation {
1373   let Category = DocCatTypeSafety;
1374   let Heading = "argument_with_type_tag";
1375   let Content = [{
1376 Use ``__attribute__((argument_with_type_tag(arg_kind, arg_idx,
1377 type_tag_idx)))`` on a function declaration to specify that the function
1378 accepts a type tag that determines the type of some other argument.
1379 ``arg_kind`` is an identifier that should be used when annotating all
1380 applicable type tags.
1381
1382 This attribute is primarily useful for checking arguments of variadic functions
1383 (``pointer_with_type_tag`` can be used in most non-variadic cases).
1384
1385 For example:
1386
1387 .. code-block:: c++
1388
1389   int fcntl(int fd, int cmd, ...)
1390       __attribute__(( argument_with_type_tag(fcntl,3,2) ));
1391   }];
1392 }
1393
1394 def PointerWithTypeTagDocs : Documentation {
1395   let Category = DocCatTypeSafety;
1396   let Heading = "pointer_with_type_tag";
1397   let Content = [{
1398 Use ``__attribute__((pointer_with_type_tag(ptr_kind, ptr_idx, type_tag_idx)))``
1399 on a function declaration to specify that the function accepts a type tag that
1400 determines the pointee type of some other pointer argument.
1401
1402 For example:
1403
1404 .. code-block:: c++
1405
1406   int MPI_Send(void *buf, int count, MPI_Datatype datatype /*, other args omitted */)
1407       __attribute__(( pointer_with_type_tag(mpi,1,3) ));
1408   }];
1409 }
1410
1411 def TypeTagForDatatypeDocs : Documentation {
1412   let Category = DocCatTypeSafety;
1413   let Content = [{
1414 Clang supports annotating type tags of two forms.
1415
1416 * **Type tag that is an expression containing a reference to some declared
1417   identifier.** Use ``__attribute__((type_tag_for_datatype(kind, type)))`` on a
1418   declaration with that identifier:
1419
1420   .. code-block:: c++
1421
1422     extern struct mpi_datatype mpi_datatype_int
1423         __attribute__(( type_tag_for_datatype(mpi,int) ));
1424     #define MPI_INT ((MPI_Datatype) &mpi_datatype_int)
1425
1426 * **Type tag that is an integral literal.** Introduce a ``static const``
1427   variable with a corresponding initializer value and attach
1428   ``__attribute__((type_tag_for_datatype(kind, type)))`` on that declaration,
1429   for example:
1430
1431   .. code-block:: c++
1432
1433     #define MPI_INT ((MPI_Datatype) 42)
1434     static const MPI_Datatype mpi_datatype_int
1435         __attribute__(( type_tag_for_datatype(mpi,int) )) = 42
1436
1437 The attribute also accepts an optional third argument that determines how the
1438 expression is compared to the type tag.  There are two supported flags:
1439
1440 * ``layout_compatible`` will cause types to be compared according to
1441   layout-compatibility rules (C++11 [class.mem] p 17, 18).  This is
1442   implemented to support annotating types like ``MPI_DOUBLE_INT``.
1443
1444   For example:
1445
1446   .. code-block:: c++
1447
1448     /* In mpi.h */
1449     struct internal_mpi_double_int { double d; int i; };
1450     extern struct mpi_datatype mpi_datatype_double_int
1451         __attribute__(( type_tag_for_datatype(mpi, struct internal_mpi_double_int, layout_compatible) ));
1452
1453     #define MPI_DOUBLE_INT ((MPI_Datatype) &mpi_datatype_double_int)
1454
1455     /* In user code */
1456     struct my_pair { double a; int b; };
1457     struct my_pair *buffer;
1458     MPI_Send(buffer, 1, MPI_DOUBLE_INT /*, ...  */); // no warning
1459
1460     struct my_int_pair { int a; int b; }
1461     struct my_int_pair *buffer2;
1462     MPI_Send(buffer2, 1, MPI_DOUBLE_INT /*, ...  */); // warning: actual buffer element
1463                                                       // type 'struct my_int_pair'
1464                                                       // doesn't match specified MPI_Datatype
1465
1466 * ``must_be_null`` specifies that the expression should be a null pointer
1467   constant, for example:
1468
1469   .. code-block:: c++
1470
1471     /* In mpi.h */
1472     extern struct mpi_datatype mpi_datatype_null
1473         __attribute__(( type_tag_for_datatype(mpi, void, must_be_null) ));
1474
1475     #define MPI_DATATYPE_NULL ((MPI_Datatype) &mpi_datatype_null)
1476
1477     /* In user code */
1478     MPI_Send(buffer, 1, MPI_DATATYPE_NULL /*, ...  */); // warning: MPI_DATATYPE_NULL
1479                                                         // was specified but buffer
1480                                                         // is not a null pointer
1481   }];
1482 }
1483
1484 def FlattenDocs : Documentation {
1485   let Category = DocCatFunction;
1486   let Content = [{
1487 The ``flatten`` attribute causes calls within the attributed function to
1488 be inlined unless it is impossible to do so, for example if the body of the
1489 callee is unavailable or if the callee has the ``noinline`` attribute.
1490   }];
1491 }
1492
1493 def FormatDocs : Documentation {
1494   let Category = DocCatFunction;
1495   let Content = [{
1496
1497 Clang supports the ``format`` attribute, which indicates that the function
1498 accepts a ``printf`` or ``scanf``-like format string and corresponding
1499 arguments or a ``va_list`` that contains these arguments.
1500
1501 Please see `GCC documentation about format attribute
1502 <http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html>`_ to find details
1503 about attribute syntax.
1504
1505 Clang implements two kinds of checks with this attribute.
1506
1507 #. Clang checks that the function with the ``format`` attribute is called with
1508    a format string that uses format specifiers that are allowed, and that
1509    arguments match the format string.  This is the ``-Wformat`` warning, it is
1510    on by default.
1511
1512 #. Clang checks that the format string argument is a literal string.  This is
1513    the ``-Wformat-nonliteral`` warning, it is off by default.
1514
1515    Clang implements this mostly the same way as GCC, but there is a difference
1516    for functions that accept a ``va_list`` argument (for example, ``vprintf``).
1517    GCC does not emit ``-Wformat-nonliteral`` warning for calls to such
1518    functions.  Clang does not warn if the format string comes from a function
1519    parameter, where the function is annotated with a compatible attribute,
1520    otherwise it warns.  For example:
1521
1522    .. code-block:: c
1523
1524      __attribute__((__format__ (__scanf__, 1, 3)))
1525      void foo(const char* s, char *buf, ...) {
1526        va_list ap;
1527        va_start(ap, buf);
1528
1529        vprintf(s, ap); // warning: format string is not a string literal
1530      }
1531
1532    In this case we warn because ``s`` contains a format string for a
1533    ``scanf``-like function, but it is passed to a ``printf``-like function.
1534
1535    If the attribute is removed, clang still warns, because the format string is
1536    not a string literal.
1537
1538    Another example:
1539
1540    .. code-block:: c
1541
1542      __attribute__((__format__ (__printf__, 1, 3)))
1543      void foo(const char* s, char *buf, ...) {
1544        va_list ap;
1545        va_start(ap, buf);
1546
1547        vprintf(s, ap); // warning
1548      }
1549
1550    In this case Clang does not warn because the format string ``s`` and
1551    the corresponding arguments are annotated.  If the arguments are
1552    incorrect, the caller of ``foo`` will receive a warning.
1553   }];
1554 }
1555
1556 def AlignValueDocs : Documentation {
1557   let Category = DocCatType;
1558   let Content = [{
1559 The align_value attribute can be added to the typedef of a pointer type or the
1560 declaration of a variable of pointer or reference type. It specifies that the
1561 pointer will point to, or the reference will bind to, only objects with at
1562 least the provided alignment. This alignment value must be some positive power
1563 of 2.
1564
1565    .. code-block:: c
1566
1567      typedef double * aligned_double_ptr __attribute__((align_value(64)));
1568      void foo(double & x  __attribute__((align_value(128)),
1569               aligned_double_ptr y) { ... }
1570
1571 If the pointer value does not have the specified alignment at runtime, the
1572 behavior of the program is undefined.
1573   }];
1574 }
1575
1576 def FlagEnumDocs : Documentation {
1577   let Category = DocCatType;
1578   let Content = [{
1579 This attribute can be added to an enumerator to signal to the compiler that it
1580 is intended to be used as a flag type. This will cause the compiler to assume
1581 that the range of the type includes all of the values that you can get by
1582 manipulating bits of the enumerator when issuing warnings.
1583   }];
1584 }
1585
1586 def EmptyBasesDocs : Documentation {
1587   let Category = DocCatType;
1588   let Content = [{
1589 The empty_bases attribute permits the compiler to utilize the
1590 empty-base-optimization more frequently.
1591 This attribute only applies to struct, class, and union types.
1592 It is only supported when using the Microsoft C++ ABI.
1593   }];
1594 }
1595
1596 def LayoutVersionDocs : Documentation {
1597   let Category = DocCatType;
1598   let Content = [{
1599 The layout_version attribute requests that the compiler utilize the class
1600 layout rules of a particular compiler version.
1601 This attribute only applies to struct, class, and union types.
1602 It is only supported when using the Microsoft C++ ABI.
1603   }];
1604 }
1605
1606 def MSInheritanceDocs : Documentation {
1607   let Category = DocCatType;
1608   let Heading = "__single_inhertiance, __multiple_inheritance, __virtual_inheritance";
1609   let Content = [{
1610 This collection of keywords is enabled under ``-fms-extensions`` and controls
1611 the pointer-to-member representation used on ``*-*-win32`` targets.
1612
1613 The ``*-*-win32`` targets utilize a pointer-to-member representation which
1614 varies in size and alignment depending on the definition of the underlying
1615 class.
1616
1617 However, this is problematic when a forward declaration is only available and
1618 no definition has been made yet.  In such cases, Clang is forced to utilize the
1619 most general representation that is available to it.
1620
1621 These keywords make it possible to use a pointer-to-member representation other
1622 than the most general one regardless of whether or not the definition will ever
1623 be present in the current translation unit.
1624
1625 This family of keywords belong between the ``class-key`` and ``class-name``:
1626
1627 .. code-block:: c++
1628
1629   struct __single_inheritance S;
1630   int S::*i;
1631   struct S {};
1632
1633 This keyword can be applied to class templates but only has an effect when used
1634 on full specializations:
1635
1636 .. code-block:: c++
1637
1638   template <typename T, typename U> struct __single_inheritance A; // warning: inheritance model ignored on primary template
1639   template <typename T> struct __multiple_inheritance A<T, T>; // warning: inheritance model ignored on partial specialization
1640   template <> struct __single_inheritance A<int, float>;
1641
1642 Note that choosing an inheritance model less general than strictly necessary is
1643 an error:
1644
1645 .. code-block:: c++
1646
1647   struct __multiple_inheritance S; // error: inheritance model does not match definition
1648   int S::*i;
1649   struct S {};
1650 }];
1651 }
1652
1653 def MSNoVTableDocs : Documentation {
1654   let Category = DocCatType;
1655   let Content = [{
1656 This attribute can be added to a class declaration or definition to signal to
1657 the compiler that constructors and destructors will not reference the virtual
1658 function table. It is only supported when using the Microsoft C++ ABI.
1659   }];
1660 }
1661
1662 def OptnoneDocs : Documentation {
1663   let Category = DocCatFunction;
1664   let Content = [{
1665 The ``optnone`` attribute suppresses essentially all optimizations
1666 on a function or method, regardless of the optimization level applied to
1667 the compilation unit as a whole.  This is particularly useful when you
1668 need to debug a particular function, but it is infeasible to build the
1669 entire application without optimization.  Avoiding optimization on the
1670 specified function can improve the quality of the debugging information
1671 for that function.
1672
1673 This attribute is incompatible with the ``always_inline`` and ``minsize``
1674 attributes.
1675   }];
1676 }
1677
1678 def LoopHintDocs : Documentation {
1679   let Category = DocCatStmt;
1680   let Heading = "#pragma clang loop";
1681   let Content = [{
1682 The ``#pragma clang loop`` directive allows loop optimization hints to be
1683 specified for the subsequent loop. The directive allows vectorization,
1684 interleaving, and unrolling to be enabled or disabled. Vector width as well
1685 as interleave and unrolling count can be manually specified. See
1686 `language extensions
1687 <http://clang.llvm.org/docs/LanguageExtensions.html#extensions-for-loop-hint-optimizations>`_
1688 for details.
1689   }];
1690 }
1691
1692 def UnrollHintDocs : Documentation {
1693   let Category = DocCatStmt;
1694   let Heading = "#pragma unroll, #pragma nounroll";
1695   let Content = [{
1696 Loop unrolling optimization hints can be specified with ``#pragma unroll`` and
1697 ``#pragma nounroll``. The pragma is placed immediately before a for, while,
1698 do-while, or c++11 range-based for loop.
1699
1700 Specifying ``#pragma unroll`` without a parameter directs the loop unroller to
1701 attempt to fully unroll the loop if the trip count is known at compile time and
1702 attempt to partially unroll the loop if the trip count is not known at compile
1703 time:
1704
1705 .. code-block:: c++
1706
1707   #pragma unroll
1708   for (...) {
1709     ...
1710   }
1711
1712 Specifying the optional parameter, ``#pragma unroll _value_``, directs the
1713 unroller to unroll the loop ``_value_`` times.  The parameter may optionally be
1714 enclosed in parentheses:
1715
1716 .. code-block:: c++
1717
1718   #pragma unroll 16
1719   for (...) {
1720     ...
1721   }
1722
1723   #pragma unroll(16)
1724   for (...) {
1725     ...
1726   }
1727
1728 Specifying ``#pragma nounroll`` indicates that the loop should not be unrolled:
1729
1730 .. code-block:: c++
1731
1732   #pragma nounroll
1733   for (...) {
1734     ...
1735   }
1736
1737 ``#pragma unroll`` and ``#pragma unroll _value_`` have identical semantics to
1738 ``#pragma clang loop unroll(full)`` and
1739 ``#pragma clang loop unroll_count(_value_)`` respectively. ``#pragma nounroll``
1740 is equivalent to ``#pragma clang loop unroll(disable)``.  See
1741 `language extensions
1742 <http://clang.llvm.org/docs/LanguageExtensions.html#extensions-for-loop-hint-optimizations>`_
1743 for further details including limitations of the unroll hints.
1744   }];
1745 }
1746
1747 def OpenCLUnrollHintDocs : Documentation {
1748   let Category = DocCatStmt;
1749   let Heading = "__attribute__((opencl_unroll_hint))";
1750   let Content = [{
1751 The opencl_unroll_hint attribute qualifier can be used to specify that a loop
1752 (for, while and do loops) can be unrolled. This attribute qualifier can be
1753 used to specify full unrolling or partial unrolling by a specified amount.
1754 This is a compiler hint and the compiler may ignore this directive. See
1755 `OpenCL v2.0 <https://www.khronos.org/registry/cl/specs/opencl-2.0.pdf>`_
1756 s6.11.5 for details.
1757   }];
1758 }
1759
1760 def OpenCLAccessDocs : Documentation {
1761   let Category = DocCatStmt;
1762   let Heading = "__read_only, __write_only, __read_write (read_only, write_only, read_write)";
1763   let Content = [{
1764 The access qualifiers must be used with image object arguments or pipe arguments
1765 to declare if they are being read or written by a kernel or function.
1766
1767 The read_only/__read_only, write_only/__write_only and read_write/__read_write
1768 names are reserved for use as access qualifiers and shall not be used otherwise.
1769
1770 .. code-block:: c
1771
1772   kernel void
1773   foo (read_only image2d_t imageA,
1774        write_only image2d_t imageB) {
1775     ...
1776   }
1777
1778 In the above example imageA is a read-only 2D image object, and imageB is a
1779 write-only 2D image object.
1780
1781 The read_write (or __read_write) qualifier can not be used with pipe.
1782
1783 More details can be found in the OpenCL C language Spec v2.0, Section 6.6.
1784     }];
1785 }
1786
1787 def DocOpenCLAddressSpaces : DocumentationCategory<"OpenCL Address Spaces"> {
1788   let Content = [{
1789 The address space qualifier may be used to specify the region of memory that is
1790 used to allocate the object. OpenCL supports the following address spaces:
1791 __generic(generic), __global(global), __local(local), __private(private),
1792 __constant(constant).
1793
1794   .. code-block:: c
1795
1796     __constant int c = ...;
1797
1798     __generic int* foo(global int* g) {
1799       __local int* l;
1800       private int p;
1801       ...
1802       return l;
1803     }
1804
1805 More details can be found in the OpenCL C language Spec v2.0, Section 6.5.
1806   }];
1807 }
1808
1809 def OpenCLAddressSpaceGenericDocs : Documentation {
1810   let Category = DocOpenCLAddressSpaces;
1811   let Content = [{
1812 The generic address space attribute is only available with OpenCL v2.0 and later.
1813 It can be used with pointer types. Variables in global and local scope and
1814 function parameters in non-kernel functions can have the generic address space
1815 type attribute. It is intended to be a placeholder for any other address space
1816 except for '__constant' in OpenCL code which can be used with multiple address
1817 spaces.
1818   }];
1819 }
1820
1821 def OpenCLAddressSpaceConstantDocs : Documentation {
1822   let Category = DocOpenCLAddressSpaces;
1823   let Content = [{
1824 The constant address space attribute signals that an object is located in
1825 a constant (non-modifiable) memory region. It is available to all work items.
1826 Any type can be annotated with the constant address space attribute. Objects
1827 with the constant address space qualifier can be declared in any scope and must
1828 have an initializer.
1829   }];
1830 }
1831
1832 def OpenCLAddressSpaceGlobalDocs : Documentation {
1833   let Category = DocOpenCLAddressSpaces;
1834   let Content = [{
1835 The global address space attribute specifies that an object is allocated in
1836 global memory, which is accessible by all work items. The content stored in this
1837 memory area persists between kernel executions. Pointer types to the global
1838 address space are allowed as function parameters or local variables. Starting
1839 with OpenCL v2.0, the global address space can be used with global (program
1840 scope) variables and static local variable as well.
1841   }];
1842 }
1843
1844 def OpenCLAddressSpaceLocalDocs : Documentation {
1845   let Category = DocOpenCLAddressSpaces;
1846   let Content = [{
1847 The local address space specifies that an object is allocated in the local (work
1848 group) memory area, which is accessible to all work items in the same work
1849 group. The content stored in this memory region is not accessible after
1850 the kernel execution ends. In a kernel function scope, any variable can be in
1851 the local address space. In other scopes, only pointer types to the local address
1852 space are allowed. Local address space variables cannot have an initializer.
1853   }];
1854 }
1855
1856 def OpenCLAddressSpacePrivateDocs : Documentation {
1857   let Category = DocOpenCLAddressSpaces;
1858   let Content = [{
1859 The private address space specifies that an object is allocated in the private
1860 (work item) memory. Other work items cannot access the same memory area and its
1861 content is destroyed after work item execution ends. Local variables can be
1862 declared in the private address space. Function arguments are always in the
1863 private address space. Kernel function arguments of a pointer or an array type
1864 cannot point to the private address space.
1865   }];
1866 }
1867
1868 def OpenCLNoSVMDocs : Documentation {
1869   let Category = DocCatVariable;
1870   let Content = [{
1871 OpenCL 2.0 supports the optional ``__attribute__((nosvm))`` qualifier for
1872 pointer variable. It informs the compiler that the pointer does not refer
1873 to a shared virtual memory region. See OpenCL v2.0 s6.7.2 for details.
1874
1875 Since it is not widely used and has been removed from OpenCL 2.1, it is ignored
1876 by Clang.
1877   }];
1878 }
1879 def NullabilityDocs : DocumentationCategory<"Nullability Attributes"> {
1880   let Content = [{
1881 Whether a particular pointer may be "null" is an important concern when working with pointers in the C family of languages. The various nullability attributes indicate whether a particular pointer can be null or not, which makes APIs more expressive and can help static analysis tools identify bugs involving null pointers. Clang supports several kinds of nullability attributes: the ``nonnull`` and ``returns_nonnull`` attributes indicate which function or method parameters and result types can never be null, while nullability type qualifiers indicate which pointer types can be null (``_Nullable``) or cannot be null (``_Nonnull``). 
1882
1883 The nullability (type) qualifiers express whether a value of a given pointer type can be null (the ``_Nullable`` qualifier), doesn't have a defined meaning for null (the ``_Nonnull`` qualifier), or for which the purpose of null is unclear (the ``_Null_unspecified`` qualifier). Because nullability qualifiers are expressed within the type system, they are more general than the ``nonnull`` and ``returns_nonnull`` attributes, allowing one to express (for example) a nullable pointer to an array of nonnull pointers. Nullability qualifiers are written to the right of the pointer to which they apply. For example:
1884
1885   .. code-block:: c
1886
1887     // No meaningful result when 'ptr' is null (here, it happens to be undefined behavior).
1888     int fetch(int * _Nonnull ptr) { return *ptr; }
1889
1890     // 'ptr' may be null.
1891     int fetch_or_zero(int * _Nullable ptr) {
1892       return ptr ? *ptr : 0;
1893     }
1894
1895     // A nullable pointer to non-null pointers to const characters.
1896     const char *join_strings(const char * _Nonnull * _Nullable strings, unsigned n);
1897
1898 In Objective-C, there is an alternate spelling for the nullability qualifiers that can be used in Objective-C methods and properties using context-sensitive, non-underscored keywords. For example:
1899
1900   .. code-block:: objective-c
1901
1902     @interface NSView : NSResponder
1903       - (nullable NSView *)ancestorSharedWithView:(nonnull NSView *)aView;
1904       @property (assign, nullable) NSView *superview;
1905       @property (readonly, nonnull) NSArray *subviews;
1906     @end
1907   }];
1908 }
1909
1910 def TypeNonNullDocs : Documentation {
1911   let Category = NullabilityDocs;
1912   let Content = [{
1913 The ``_Nonnull`` nullability qualifier indicates that null is not a meaningful value for a value of the ``_Nonnull`` pointer type. For example, given a declaration such as:
1914
1915   .. code-block:: c
1916
1917     int fetch(int * _Nonnull ptr);
1918
1919 a caller of ``fetch`` should not provide a null value, and the compiler will produce a warning if it sees a literal null value passed to ``fetch``. Note that, unlike the declaration attribute ``nonnull``, the presence of ``_Nonnull`` does not imply that passing null is undefined behavior: ``fetch`` is free to consider null undefined behavior or (perhaps for backward-compatibility reasons) defensively handle null.
1920   }];
1921 }
1922
1923 def TypeNullableDocs : Documentation {
1924   let Category = NullabilityDocs;
1925   let Content = [{
1926 The ``_Nullable`` nullability qualifier indicates that a value of the ``_Nullable`` pointer type can be null. For example, given:
1927
1928   .. code-block:: c
1929
1930     int fetch_or_zero(int * _Nullable ptr);
1931
1932 a caller of ``fetch_or_zero`` can provide null. 
1933   }];
1934 }
1935
1936 def TypeNullUnspecifiedDocs : Documentation {
1937   let Category = NullabilityDocs;
1938   let Content = [{
1939 The ``_Null_unspecified`` nullability qualifier indicates that neither the ``_Nonnull`` nor ``_Nullable`` qualifiers make sense for a particular pointer type. It is used primarily to indicate that the role of null with specific pointers in a nullability-annotated header is unclear, e.g., due to overly-complex implementations or historical factors with a long-lived API.
1940   }];
1941 }
1942
1943 def NonNullDocs : Documentation {
1944   let Category = NullabilityDocs;
1945   let Content = [{
1946 The ``nonnull`` attribute indicates that some function parameters must not be null, and can be used in several different ways. It's original usage (`from GCC <https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes>`_) is as a function (or Objective-C method) attribute that specifies which parameters of the function are nonnull in a comma-separated list. For example:
1947
1948   .. code-block:: c
1949
1950     extern void * my_memcpy (void *dest, const void *src, size_t len)
1951                     __attribute__((nonnull (1, 2)));
1952
1953 Here, the ``nonnull`` attribute indicates that parameters 1 and 2
1954 cannot have a null value. Omitting the parenthesized list of parameter indices means that all parameters of pointer type cannot be null:
1955
1956   .. code-block:: c
1957
1958     extern void * my_memcpy (void *dest, const void *src, size_t len)
1959                     __attribute__((nonnull));
1960
1961 Clang also allows the ``nonnull`` attribute to be placed directly on a function (or Objective-C method) parameter, eliminating the need to specify the parameter index ahead of type. For example:
1962
1963   .. code-block:: c
1964
1965     extern void * my_memcpy (void *dest __attribute__((nonnull)),
1966                              const void *src __attribute__((nonnull)), size_t len);
1967
1968 Note that the ``nonnull`` attribute indicates that passing null to a non-null parameter is undefined behavior, which the optimizer may take advantage of to, e.g., remove null checks. The ``_Nonnull`` type qualifier indicates that a pointer cannot be null in a more general manner (because it is part of the type system) and does not imply undefined behavior, making it more widely applicable.
1969   }];
1970 }
1971
1972 def ReturnsNonNullDocs : Documentation {
1973   let Category = NullabilityDocs;
1974   let Content = [{
1975 The ``returns_nonnull`` attribute indicates that a particular function (or Objective-C method) always returns a non-null pointer. For example, a particular system ``malloc`` might be defined to terminate a process when memory is not available rather than returning a null pointer:
1976
1977   .. code-block:: c
1978
1979     extern void * malloc (size_t size) __attribute__((returns_nonnull));
1980
1981 The ``returns_nonnull`` attribute implies that returning a null pointer is undefined behavior, which the optimizer may take advantage of. The ``_Nonnull`` type qualifier indicates that a pointer cannot be null in a more general manner (because it is part of the type system) and does not imply undefined behavior, making it more widely applicable
1982 }];
1983 }
1984
1985 def NoAliasDocs : Documentation {
1986   let Category = DocCatFunction;
1987   let Content = [{
1988 The ``noalias`` attribute indicates that the only memory accesses inside
1989 function are loads and stores from objects pointed to by its pointer-typed
1990 arguments, with arbitrary offsets.
1991   }];
1992 }
1993
1994 def OMPDeclareSimdDocs : Documentation {
1995   let Category = DocCatFunction;
1996   let Heading = "#pragma omp declare simd";
1997   let Content = [{
1998 The `declare simd` construct can be applied to a function to enable the creation
1999 of one or more versions that can process multiple arguments using SIMD
2000 instructions from a single invocation in a SIMD loop. The `declare simd`
2001 directive is a declarative directive. There may be multiple `declare simd`
2002 directives for a function. The use of a `declare simd` construct on a function
2003 enables the creation of SIMD versions of the associated function that can be
2004 used to process multiple arguments from a single invocation from a SIMD loop
2005 concurrently.
2006 The syntax of the `declare simd` construct is as follows:
2007
2008   .. code-block:: c
2009
2010   #pragma omp declare simd [clause[[,] clause] ...] new-line
2011   [#pragma omp declare simd [clause[[,] clause] ...] new-line]
2012   [...]
2013   function definition or declaration
2014
2015 where clause is one of the following:
2016
2017   .. code-block:: c
2018
2019   simdlen(length)
2020   linear(argument-list[:constant-linear-step])
2021   aligned(argument-list[:alignment])
2022   uniform(argument-list)
2023   inbranch
2024   notinbranch
2025
2026   }];
2027 }
2028
2029 def OMPDeclareTargetDocs : Documentation {
2030   let Category = DocCatFunction;
2031   let Heading = "#pragma omp declare target";
2032   let Content = [{
2033 The `declare target` directive specifies that variables and functions are mapped
2034 to a device for OpenMP offload mechanism.
2035
2036 The syntax of the declare target directive is as follows:
2037
2038   .. code-block:: c
2039
2040   #pragma omp declare target new-line
2041   declarations-definition-seq
2042   #pragma omp end declare target new-line
2043   }];
2044 }
2045
2046 def NotTailCalledDocs : Documentation {
2047   let Category = DocCatFunction;
2048   let Content = [{
2049 The ``not_tail_called`` attribute prevents tail-call optimization on statically bound calls. It has no effect on indirect calls. Virtual functions, objective-c methods, and functions marked as ``always_inline`` cannot be marked as ``not_tail_called``.
2050
2051 For example, it prevents tail-call optimization in the following case:
2052
2053   .. code-block:: c
2054
2055     int __attribute__((not_tail_called)) foo1(int);
2056
2057     int foo2(int a) {
2058       return foo1(a); // No tail-call optimization on direct calls.
2059     }
2060
2061 However, it doesn't prevent tail-call optimization in this case:
2062
2063   .. code-block:: c
2064
2065     int __attribute__((not_tail_called)) foo1(int);
2066
2067     int foo2(int a) {
2068       int (*fn)(int) = &foo1;
2069
2070       // not_tail_called has no effect on an indirect call even if the call can be
2071       // resolved at compile time.
2072       return (*fn)(a);
2073     }
2074
2075 Marking virtual functions as ``not_tail_called`` is an error:
2076
2077   .. code-block:: c++
2078
2079     class Base {
2080     public:
2081       // not_tail_called on a virtual function is an error.
2082       [[clang::not_tail_called]] virtual int foo1();
2083
2084       virtual int foo2();
2085
2086       // Non-virtual functions can be marked ``not_tail_called``.
2087       [[clang::not_tail_called]] int foo3();
2088     };
2089
2090     class Derived1 : public Base {
2091     public:
2092       int foo1() override;
2093
2094       // not_tail_called on a virtual function is an error.
2095       [[clang::not_tail_called]] int foo2() override;
2096     };
2097   }];
2098 }
2099
2100 def InternalLinkageDocs : Documentation {
2101   let Category = DocCatFunction;
2102   let Content = [{
2103 The ``internal_linkage`` attribute changes the linkage type of the declaration to internal.
2104 This is similar to C-style ``static``, but can be used on classes and class methods. When applied to a class definition,
2105 this attribute affects all methods and static data members of that class.
2106 This can be used to contain the ABI of a C++ library by excluding unwanted class methods from the export tables.
2107   }];
2108 }
2109
2110 def DisableTailCallsDocs : Documentation {
2111   let Category = DocCatFunction;
2112   let Content = [{
2113 The ``disable_tail_calls`` attribute instructs the backend to not perform tail call optimization inside the marked function.
2114
2115 For example:
2116
2117   .. code-block:: c
2118
2119     int callee(int);
2120
2121     int foo(int a) __attribute__((disable_tail_calls)) {
2122       return callee(a); // This call is not tail-call optimized.
2123     }
2124
2125 Marking virtual functions as ``disable_tail_calls`` is legal.
2126
2127   .. code-block:: c++
2128
2129     int callee(int);
2130
2131     class Base {
2132     public:
2133       [[clang::disable_tail_calls]] virtual int foo1() {
2134         return callee(); // This call is not tail-call optimized.
2135       }
2136     };
2137
2138     class Derived1 : public Base {
2139     public:
2140       int foo1() override {
2141         return callee(); // This call is tail-call optimized.
2142       }
2143     };
2144
2145   }];
2146 }
2147
2148 def AnyX86InterruptDocs : Documentation {
2149   let Category = DocCatFunction;
2150   let Content = [{
2151 Clang supports the GNU style ``__attribute__((interrupt))`` attribute on
2152 x86/x86-64 targets.The compiler generates function entry and exit sequences
2153 suitable for use in an interrupt handler when this attribute is present.
2154 The 'IRET' instruction, instead of the 'RET' instruction, is used to return
2155 from interrupt or exception handlers.  All registers, except for the EFLAGS
2156 register which is restored by the 'IRET' instruction, are preserved by the
2157 compiler.
2158
2159 Any interruptible-without-stack-switch code must be compiled with
2160 -mno-red-zone since interrupt handlers can and will, because of the
2161 hardware design, touch the red zone.
2162
2163 1. interrupt handler must be declared with a mandatory pointer argument:
2164
2165   .. code-block:: c
2166
2167     struct interrupt_frame
2168     {
2169       uword_t ip;
2170       uword_t cs;
2171       uword_t flags;
2172       uword_t sp;
2173       uword_t ss;
2174     };
2175
2176     __attribute__ ((interrupt))
2177     void f (struct interrupt_frame *frame) {
2178       ...
2179     }
2180
2181 2. exception handler:
2182
2183   The exception handler is very similar to the interrupt handler with
2184   a different mandatory function signature:
2185
2186   .. code-block:: c
2187
2188     __attribute__ ((interrupt))
2189     void f (struct interrupt_frame *frame, uword_t error_code) {
2190       ...
2191     }
2192
2193   and compiler pops 'ERROR_CODE' off stack before the 'IRET' instruction.
2194
2195   The exception handler should only be used for exceptions which push an
2196   error code and all other exceptions must use the interrupt handler.
2197   The system will crash if the wrong handler is used.
2198   }];
2199 }
2200
2201 def SwiftCallDocs : Documentation {
2202   let Category = DocCatVariable;
2203   let Content = [{
2204 The ``swiftcall`` attribute indicates that a function should be called
2205 using the Swift calling convention for a function or function pointer.
2206
2207 The lowering for the Swift calling convention, as described by the Swift
2208 ABI documentation, occurs in multiple phases.  The first, "high-level"
2209 phase breaks down the formal parameters and results into innately direct
2210 and indirect components, adds implicit paraameters for the generic
2211 signature, and assigns the context and error ABI treatments to parameters
2212 where applicable.  The second phase breaks down the direct parameters
2213 and results from the first phase and assigns them to registers or the
2214 stack.  The ``swiftcall`` convention only handles this second phase of
2215 lowering; the C function type must accurately reflect the results
2216 of the first phase, as follows:
2217
2218 - Results classified as indirect by high-level lowering should be
2219   represented as parameters with the ``swift_indirect_result`` attribute.
2220
2221 - Results classified as direct by high-level lowering should be represented
2222   as follows:
2223
2224   - First, remove any empty direct results.
2225
2226   - If there are no direct results, the C result type should be ``void``.
2227
2228   - If there is one direct result, the C result type should be a type with
2229     the exact layout of that result type.
2230
2231   - If there are a multiple direct results, the C result type should be
2232     a struct type with the exact layout of a tuple of those results.
2233
2234 - Parameters classified as indirect by high-level lowering should be
2235   represented as parameters of pointer type.
2236
2237 - Parameters classified as direct by high-level lowering should be
2238   omitted if they are empty types; otherwise, they should be represented
2239   as a parameter type with a layout exactly matching the layout of the
2240   Swift parameter type.
2241
2242 - The context parameter, if present, should be represented as a trailing
2243   parameter with the ``swift_context`` attribute.
2244
2245 - The error result parameter, if present, should be represented as a
2246   trailing parameter (always following a context parameter) with the
2247   ``swift_error_result`` attribute.
2248
2249 ``swiftcall`` does not support variadic arguments or unprototyped functions.
2250
2251 The parameter ABI treatment attributes are aspects of the function type.
2252 A function type which which applies an ABI treatment attribute to a
2253 parameter is a different type from an otherwise-identical function type
2254 that does not.  A single parameter may not have multiple ABI treatment
2255 attributes.
2256
2257 Support for this feature is target-dependent, although it should be
2258 supported on every target that Swift supports.  Query for this support
2259 with ``__has_attribute(swiftcall)``.  This implies support for the
2260 ``swift_context``, ``swift_error_result``, and ``swift_indirect_result``
2261 attributes.
2262   }];
2263 }
2264
2265 def SwiftContextDocs : Documentation {
2266   let Category = DocCatVariable;
2267   let Content = [{
2268 The ``swift_context`` attribute marks a parameter of a ``swiftcall``
2269 function as having the special context-parameter ABI treatment.
2270
2271 This treatment generally passes the context value in a special register
2272 which is normally callee-preserved.
2273
2274 A ``swift_context`` parameter must either be the last parameter or must be
2275 followed by a ``swift_error_result`` parameter (which itself must always be
2276 the last parameter).
2277
2278 A context parameter must have pointer or reference type.
2279   }];
2280 }
2281
2282 def SwiftErrorResultDocs : Documentation {
2283   let Category = DocCatVariable;
2284   let Content = [{
2285 The ``swift_error_result`` attribute marks a parameter of a ``swiftcall``
2286 function as having the special error-result ABI treatment.
2287
2288 This treatment generally passes the underlying error value in and out of
2289 the function through a special register which is normally callee-preserved.
2290 This is modeled in C by pretending that the register is addressable memory:
2291
2292 - The caller appears to pass the address of a variable of pointer type.
2293   The current value of this variable is copied into the register before
2294   the call; if the call returns normally, the value is copied back into the
2295   variable.
2296
2297 - The callee appears to receive the address of a variable.  This address
2298   is actually a hidden location in its own stack, initialized with the
2299   value of the register upon entry.  When the function returns normally,
2300   the value in that hidden location is written back to the register.
2301
2302 A ``swift_error_result`` parameter must be the last parameter, and it must be
2303 preceded by a ``swift_context`` parameter.
2304
2305 A ``swift_error_result`` parameter must have type ``T**`` or ``T*&`` for some
2306 type T.  Note that no qualifiers are permitted on the intermediate level.
2307
2308 It is undefined behavior if the caller does not pass a pointer or
2309 reference to a valid object.
2310
2311 The standard convention is that the error value itself (that is, the
2312 value stored in the apparent argument) will be null upon function entry,
2313 but this is not enforced by the ABI.
2314   }];
2315 }
2316
2317 def SwiftIndirectResultDocs : Documentation {
2318   let Category = DocCatVariable;
2319   let Content = [{
2320 The ``swift_indirect_result`` attribute marks a parameter of a ``swiftcall``
2321 function as having the special indirect-result ABI treatmenet.
2322
2323 This treatment gives the parameter the target's normal indirect-result
2324 ABI treatment, which may involve passing it differently from an ordinary
2325 parameter.  However, only the first indirect result will receive this
2326 treatment.  Furthermore, low-level lowering may decide that a direct result
2327 must be returned indirectly; if so, this will take priority over the
2328 ``swift_indirect_result`` parameters.
2329
2330 A ``swift_indirect_result`` parameter must either be the first parameter or
2331 follow another ``swift_indirect_result`` parameter.
2332
2333 A ``swift_indirect_result`` parameter must have type ``T*`` or ``T&`` for
2334 some object type ``T``.  If ``T`` is a complete type at the point of
2335 definition of a function, it is undefined behavior if the argument
2336 value does not point to storage of adequate size and alignment for a
2337 value of type ``T``.
2338
2339 Making indirect results explicit in the signature allows C functions to
2340 directly construct objects into them without relying on language
2341 optimizations like C++'s named return value optimization (NRVO).
2342   }];
2343 }
2344
2345 def AbiTagsDocs : Documentation {
2346   let Category = DocCatFunction;
2347   let Content = [{
2348 The ``abi_tag`` attribute can be applied to a function, variable, class or
2349 inline namespace declaration to modify the mangled name of the entity. It gives
2350 the ability to distinguish between different versions of the same entity but
2351 with different ABI versions supported. For example, a newer version of a class
2352 could have a different set of data members and thus have a different size. Using
2353 the ``abi_tag`` attribute, it is possible to have different mangled names for
2354 a global variable of the class type. Therefor, the old code could keep using
2355 the old manged name and the new code will use the new mangled name with tags.
2356   }];
2357 }
2358
2359 def PreserveMostDocs : Documentation {
2360   let Category = DocCatCallingConvs;
2361   let Content = [{
2362 On X86-64 and AArch64 targets, this attribute changes the calling convention of
2363 a function. The ``preserve_most`` calling convention attempts to make the code
2364 in the caller as unintrusive as possible. This convention behaves identically
2365 to the ``C`` calling convention on how arguments and return values are passed,
2366 but it uses a different set of caller/callee-saved registers. This alleviates
2367 the burden of saving and recovering a large register set before and after the
2368 call in the caller. If the arguments are passed in callee-saved registers,
2369 then they will be preserved by the callee across the call. This doesn't
2370 apply for values returned in callee-saved registers.
2371
2372 - On X86-64 the callee preserves all general purpose registers, except for
2373   R11. R11 can be used as a scratch register. Floating-point registers
2374   (XMMs/YMMs) are not preserved and need to be saved by the caller.
2375
2376 The idea behind this convention is to support calls to runtime functions
2377 that have a hot path and a cold path. The hot path is usually a small piece
2378 of code that doesn't use many registers. The cold path might need to call out to
2379 another function and therefore only needs to preserve the caller-saved
2380 registers, which haven't already been saved by the caller. The
2381 `preserve_most` calling convention is very similar to the ``cold`` calling
2382 convention in terms of caller/callee-saved registers, but they are used for
2383 different types of function calls. ``coldcc`` is for function calls that are
2384 rarely executed, whereas `preserve_most` function calls are intended to be
2385 on the hot path and definitely executed a lot. Furthermore ``preserve_most``
2386 doesn't prevent the inliner from inlining the function call.
2387
2388 This calling convention will be used by a future version of the Objective-C
2389 runtime and should therefore still be considered experimental at this time.
2390 Although this convention was created to optimize certain runtime calls to
2391 the Objective-C runtime, it is not limited to this runtime and might be used
2392 by other runtimes in the future too. The current implementation only
2393 supports X86-64 and AArch64, but the intention is to support more architectures
2394 in the future.
2395   }];
2396 }
2397
2398 def PreserveAllDocs : Documentation {
2399   let Category = DocCatCallingConvs;
2400   let Content = [{
2401 On X86-64 and AArch64 targets, this attribute changes the calling convention of
2402 a function. The ``preserve_all`` calling convention attempts to make the code
2403 in the caller even less intrusive than the ``preserve_most`` calling convention.
2404 This calling convention also behaves identical to the ``C`` calling convention
2405 on how arguments and return values are passed, but it uses a different set of
2406 caller/callee-saved registers. This removes the burden of saving and
2407 recovering a large register set before and after the call in the caller. If
2408 the arguments are passed in callee-saved registers, then they will be
2409 preserved by the callee across the call. This doesn't apply for values
2410 returned in callee-saved registers.
2411
2412 - On X86-64 the callee preserves all general purpose registers, except for
2413   R11. R11 can be used as a scratch register. Furthermore it also preserves
2414   all floating-point registers (XMMs/YMMs).
2415
2416 The idea behind this convention is to support calls to runtime functions
2417 that don't need to call out to any other functions.
2418
2419 This calling convention, like the ``preserve_most`` calling convention, will be
2420 used by a future version of the Objective-C runtime and should be considered
2421 experimental at this time.
2422   }];
2423 }
2424
2425 def DeprecatedDocs : Documentation {
2426   let Category = DocCatFunction;
2427   let Content = [{
2428 The ``deprecated`` attribute can be applied to a function, a variable, or a
2429 type. This is useful when identifying functions, variables, or types that are
2430 expected to be removed in a future version of a program.
2431
2432 Consider the function declaration for a hypothetical function ``f``:
2433
2434 .. code-block:: c++
2435
2436   void f(void) __attribute__((deprecated("message", "replacement")));
2437
2438 When spelled as `__attribute__((deprecated))`, the deprecated attribute can have
2439 two optional string arguments. The first one is the message to display when
2440 emitting the warning; the second one enables the compiler to provide a Fix-It
2441 to replace the deprecated name with a new name. Otherwise, when spelled as
2442 `[[gnu::deprecated]] or [[deprecated]]`, the attribute can have one optional
2443 string argument which is the message to display when emitting the warning.
2444   }];
2445 }
2446
2447 def IFuncDocs : Documentation {
2448   let Category = DocCatFunction;
2449   let Content = [{
2450 ``__attribute__((ifunc("resolver")))`` is used to mark that the address of a declaration should be resolved at runtime by calling a resolver function.
2451
2452 The symbol name of the resolver function is given in quotes.  A function with this name (after mangling) must be defined in the current translation unit; it may be ``static``.  The resolver function should take no arguments and return a pointer.
2453
2454 The ``ifunc`` attribute may only be used on a function declaration.  A function declaration with an ``ifunc`` attribute is considered to be a definition of the declared entity.  The entity must not have weak linkage; for example, in C++, it cannot be applied to a declaration if a definition at that location would be considered inline.
2455
2456 Not all targets support this attribute.  ELF targets support this attribute when using binutils v2.20.1 or higher and glibc v2.11.1 or higher.  Non-ELF targets currently do not support this attribute.
2457   }];
2458 }
2459
2460 def LTOVisibilityDocs : Documentation {
2461   let Category = DocCatType;
2462   let Content = [{
2463 See :doc:`LTOVisibility`.
2464   }];
2465 }
2466
2467 def RenderScriptKernelAttributeDocs : Documentation {
2468   let Category = DocCatFunction;
2469   let Content = [{
2470 ``__attribute__((kernel))`` is used to mark a ``kernel`` function in
2471 RenderScript.
2472
2473 In RenderScript, ``kernel`` functions are used to express data-parallel
2474 computations.  The RenderScript runtime efficiently parallelizes ``kernel``
2475 functions to run on computational resources such as multi-core CPUs and GPUs.
2476 See the RenderScript_ documentation for more information.
2477
2478 .. _RenderScript: https://developer.android.com/guide/topics/renderscript/compute.html
2479   }];
2480 }
2481
2482 def XRayDocs : Documentation {
2483   let Category = DocCatFunction;
2484   let Heading = "xray_always_instrument (clang::xray_always_instrument), xray_never_instrument (clang::xray_never_instrument)";
2485   let Content = [{
2486 ``__attribute__((xray_always_instrument))`` or ``[[clang::xray_always_instrument]]`` is used to mark member functions (in C++), methods (in Objective C), and free functions (in C, C++, and Objective C) to be instrumented with XRay. This will cause the function to always have space at the beginning and exit points to allow for runtime patching.
2487
2488 Conversely, ``__attribute__((xray_never_instrument))`` or ``[[clang::xray_never_instrument]]`` will inhibit the insertion of these instrumentation points.
2489
2490 If a function has neither of these attributes, they become subject to the XRay heuristics used to determine whether a function should be instrumented or otherwise.
2491   }];
2492 }