[PATCH] D56892: Add a priority field to availability attributes to prioritize explicit attributes from declaration over attributes from '#pragma clang attribute'
Alex Lorenz via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 17 18:40:06 PST 2019
arphaman created this revision.
arphaman added reviewers: erik.pilkington, aaron.ballman.
Herald added subscribers: dexonsmith, jkorous.
We have an issue when using `#pragma clang attribute` with availability attributes:
- The explicit attribute that's specified next to the declaration is not guaranteed to be preferred over the attribute specified in the pragma.
This patch fixes this by introducing a `priority` field to the availability attribute to control how they're merged. Attributes with higher priority are applied over attributes with lower priority for the same platform. The implicitly inferred attributes are given the lower priority. This ensures that:
1. explicit attributes are preferred over all other attributes.
2. implicitly inferred attributes that are inferred from an explicit attribute are discarded if there's an explicit attribute or an attribute specified using a `#pragma` for the same platform.
3. implicitly inferred attributes that are inferred from an attribute in the `#pragma` are not used if there's an explicit, explicit `#pragma`, or an implicit attribute inferred from an explicit attribute for the declaration.
This is the resulting ranking:
`platform availability > platform availability from pragma > inferred availability > inferred availability from pragma`
rdar://46390243
Repository:
rC Clang
https://reviews.llvm.org/D56892
Files:
include/clang/Basic/Attr.td
include/clang/Sema/ParsedAttr.h
include/clang/Sema/Sema.h
lib/Sema/SemaAttr.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclAttr.cpp
test/SemaObjC/attr-availability-priority.m
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56892.182429.patch
Type: text/x-patch
Size: 20369 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190118/016709b1/attachment-0001.bin>
More information about the cfe-commits
mailing list