mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-10 19:56:06 +00:00

attributes from declaration over attributes from '#pragma clang attribute' Before this commit users had 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 commit 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 Differential Revision: https://reviews.llvm.org/D56892 llvm-svn: 352084
54 lines
2.8 KiB
Objective-C
54 lines
2.8 KiB
Objective-C
// RUN: %clang_cc1 -triple arm64-apple-tvos12.0 -fsyntax-only -verify %s
|
|
|
|
void explicit() __attribute__((availability(tvos, introduced=11.0, deprecated=12.0))); // expected-note {{marked deprecated here}}
|
|
void inferred() __attribute__((availability(ios, introduced=11.0, deprecated=12.0))); // expected-note {{marked deprecated here}}
|
|
void explicitOverInferred()
|
|
__attribute__((availability(ios, introduced=11.0, deprecated=12.0)))
|
|
__attribute__((availability(tvos, introduced=11.0)));
|
|
void explicitOverInferred2()
|
|
__attribute__((availability(tvos, introduced=11.0)))
|
|
__attribute__((availability(ios, introduced=11.0, deprecated=12.0)));
|
|
|
|
void simpleUsage() {
|
|
explicit(); // expected-warning{{'explicit' is deprecated: first deprecated in tvOS 12.0}}
|
|
inferred(); // expected-warning{{'inferred' is deprecated: first deprecated in tvOS 12.0}}
|
|
// ok, not deprecated for tvOS.
|
|
explicitOverInferred();
|
|
explicitOverInferred2();
|
|
}
|
|
|
|
#pragma clang attribute push (__attribute__((availability(tvos, introduced=11.0, deprecated=12.0))), apply_to=function)
|
|
|
|
void explicitFromPragma(); // expected-note {{marked deprecated here}}
|
|
void explicitWinsOverExplicitFromPragma() __attribute__((availability(tvos, introduced=11.0)));
|
|
void implicitLosesOverExplicitFromPragma() __attribute__((availability(ios, introduced=11.0))); // expected-note {{marked deprecated here}}
|
|
|
|
#pragma clang attribute pop
|
|
|
|
#pragma clang attribute push (__attribute__((availability(ios, introduced=11.0, deprecated=12.0))), apply_to=function)
|
|
|
|
void implicitFromPragma(); // expected-note {{marked deprecated here}}
|
|
void explicitWinsOverImplicitFromPragma() __attribute__((availability(tvos, introduced=11.0)));
|
|
void implicitWinsOverImplicitFromPragma() __attribute__((availability(ios, introduced=11.0)));
|
|
|
|
#pragma clang attribute pop
|
|
|
|
#pragma clang attribute push (__attribute__((availability(tvos, introduced=11.0, deprecated=12.0))), apply_to=function)
|
|
#pragma clang attribute push (__attribute__((availability(ios, introduced=11.0, deprecated=11.3))), apply_to=function)
|
|
|
|
void pragmaExplicitWinsOverPragmaImplicit(); // expected-note {{marked deprecated here}}
|
|
|
|
#pragma clang attribute pop
|
|
#pragma clang attribute pop
|
|
|
|
void pragmaUsage() {
|
|
explicitFromPragma(); // expected-warning {{'explicitFromPragma' is deprecated: first deprecated in tvOS 12.0}}
|
|
explicitWinsOverExplicitFromPragma(); // ok
|
|
implicitLosesOverExplicitFromPragma(); // expected-warning {{'implicitLosesOverExplicitFromPragma' is deprecated: first deprecated in tvOS 12.0}}
|
|
|
|
implicitFromPragma(); // expected-warning {{'implicitFromPragma' is deprecated: first deprecated in tvOS 12.0}}
|
|
explicitWinsOverImplicitFromPragma(); // ok
|
|
implicitWinsOverImplicitFromPragma(); // ok
|
|
pragmaExplicitWinsOverPragmaImplicit(); // expected-warning {{'pragmaExplicitWinsOverPragmaImplicit' is deprecated: first deprecated in tvOS 12.0}}
|
|
}
|