diff options
author | Erik Pilkington <erik.pilkington@gmail.com> | 2018-10-29 02:29:21 +0000 |
---|---|---|
committer | Erik Pilkington <erik.pilkington@gmail.com> | 2018-10-29 02:29:21 +0000 |
commit | a7cc6b360fe976c9105968d73f60e26172dc7b77 (patch) | |
tree | e02f473cba9c5e5fc4eed3653a5aaec219c1f908 /clang/docs | |
parent | 36d9746630fd4fb71fef627057fdd5b899cfd221 (diff) |
Support for groups of attributes in #pragma clang attribute
This commit enables pushing an empty #pragma clang attribute push, then adding
multiple attributes to it, then popping them all with #pragma clang attribute
pop, just like #pragma clang diagnostic. We still support the current way of
adding these, #pragma clang attribute push(__attribute__((...))), by treating it
like a combined push/attribute. This is needed to create macros like:
DO_SOMETHING_BEGIN(attr1, attr2, attr3)
// ...
DO_SOMETHING_END
rdar://45496947
Differential revision: https://reviews.llvm.org/D53621
llvm-svn: 345486
Diffstat (limited to 'clang/docs')
-rw-r--r-- | clang/docs/LanguageExtensions.rst | 16 | ||||
-rw-r--r-- | clang/docs/ReleaseNotes.rst | 4 |
2 files changed, 11 insertions, 9 deletions
diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index 894b7504fd2c..506d2736891f 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -2651,17 +2651,19 @@ Specifying an attribute for multiple declarations (#pragma clang attribute) The ``#pragma clang attribute`` directive can be used to apply an attribute to multiple declarations. The ``#pragma clang attribute push`` variation of the -directive pushes a new attribute to the attribute stack. The declarations that -follow the pragma receive the attributes that are on the attribute stack, until -the stack is cleared using a ``#pragma clang attribute pop`` directive. Multiple -push directives can be nested inside each other. +directive pushes a new "scope" of ``#pragma clang attribute`` that attributes +can be added to. The ``#pragma clang attribute (...)`` variation adds an +attribute to that scope, and the ``#pragma clang attribute pop`` variation pops +the scope. You can also use ``#pragma clang attribute push (...)``, which is a +shorthand for when you want to add one attribute to a new scope. Multiple push +directives can be nested inside each other. The attributes that are used in the ``#pragma clang attribute`` directives can be written using the GNU-style syntax: .. code-block:: c++ - #pragma clang attribute push(__attribute__((annotate("custom"))), apply_to = function) + #pragma clang attribute push (__attribute__((annotate("custom"))), apply_to = function) void function(); // The function now has the annotate("custom") attribute @@ -2671,7 +2673,7 @@ The attributes can also be written using the C++11 style syntax: .. code-block:: c++ - #pragma clang attribute push([[noreturn]], apply_to = function) + #pragma clang attribute push ([[noreturn]], apply_to = function) void function(); // The function now has the [[noreturn]] attribute @@ -2681,7 +2683,7 @@ The ``__declspec`` style syntax is also supported: .. code-block:: c++ - #pragma clang attribute push(__declspec(dllexport), apply_to = function) + #pragma clang attribute push (__declspec(dllexport), apply_to = function) void function(); // The function now has the __declspec(dllexport) attribute diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index c6ddbfd8eaf2..69343eab84b1 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -86,8 +86,8 @@ Modified Compiler Flags New Pragmas in Clang -------------------- -Clang now supports the ... - +- Clang now supports adding multiple ``#pragma clang attribute`` attributes into + a "scope" of ``push``ed attributes. Attribute Changes in Clang -------------------------- |