[PATCH] D55628: Add support for "labels" on push/pop directives in #pragma clang attribute
Erik Pilkington via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 18 23:36:40 PST 2018
erik.pilkington updated this revision to Diff 178837.
erik.pilkington added a comment.
After looking through some users of `#pragma clang attribute`, I don't think that the begin/end solution is what we want here. Some users of this attribute write macros that can expand to different attributes depending on their arguments, for instance:
AVAILABILITY_BEGIN(macos(10.12)) // expands to an availability attribute
// some code...
This code makes sense and is safe, but in this case rewriting AVAILABILITY_BEGIN to use a hypothetical `pragma clang attribute begin`/`end` would be a breaking change, which isn't acceptable. So I think that we want stack semantics, but scoped within the `AVAILABILITY_BEGIN` macro's namespace. That way, we can support multiple `push`es in the same macro, without having having different macros accidentally pop each other.
As for a syntax for this, I chose the following (basically, @dexonsmith's idea with a '.'):
#pragma clang attribute NoReturn.push (__attribute__((noreturn)), apply_to=function)
#pragma clang attribute NoReturn.pop
I think the '.' makes the nested relationship (i.e. the push is contained within the namespace) more clear to C programmers, and hopefully clears up the confusion. @AaronBallman: WDYT?
CHANGES SINCE LAST ACTION
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 12648 bytes
Desc: not available
More information about the cfe-commits