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:
- explicit attributes are preferred over all other attributes.
- 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.
- 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