mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Define __SWIFT_ATTR_SUPPORTS_MACROS when the MacrosOnImports features is available
This commit is contained in:
@@ -622,6 +622,11 @@ void importer::getNormalInvocationArguments(
|
||||
if (clangSupportsPragmaAttributeWithSwiftAttr())
|
||||
invocationArgStrs.push_back("-D__SWIFT_ATTR_SUPPORTS_SENDABLE_DECLS=1");
|
||||
|
||||
// Indicate that the compiler will respect macros applied to imported
|
||||
// declarations via '__attribute__((swift_attr("@...")))'.
|
||||
if (LangOpts.hasFeature(Feature::MacrosOnImports))
|
||||
invocationArgStrs.push_back("-D__SWIFT_ATTR_SUPPORTS_MACROS=1");
|
||||
|
||||
if (triple.isXROS()) {
|
||||
// FIXME: This is a gnarly hack until some macros get adjusted in the SDK.
|
||||
invocationArgStrs.insert(invocationArgStrs.end(), {
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
void async_divide(double x, double y, void (* _Nonnull completionHandler)(double x))
|
||||
__attribute__((swift_attr("@macro_library.AddAsync")));
|
||||
#if __SWIFT_ATTR_SUPPORTS_MACROS
|
||||
#define ADD_ASYNC __attribute__((swift_attr("@macro_library.AddAsync")))
|
||||
#else
|
||||
#define ADD_ASYNC
|
||||
#endif
|
||||
|
||||
void async_divide(double x, double y, void (* _Nonnull completionHandler)(double x)) ADD_ASYNC;
|
||||
|
||||
typedef struct SlowComputer {
|
||||
} SlowComputer;
|
||||
|
||||
void computer_divide(const SlowComputer *computer, double x, double y, void (* _Nonnull completionHandler)(double x))
|
||||
__attribute__((swift_attr("@macro_library.AddAsync")))
|
||||
ADD_ASYNC
|
||||
__attribute__((swift_name("SlowComputer.divide(self:_:_:completionHandler:)")));
|
||||
|
||||
|
||||
@@ -14,7 +19,7 @@ void computer_divide(const SlowComputer *computer, double x, double y, void (* _
|
||||
|
||||
@interface Computer: NSObject
|
||||
-(void)multiply:(double)x by:(double)y afterDone:(void (^ _Nonnull)(double x))afterDone
|
||||
__attribute__((swift_attr("@macro_library.AddAsync")))
|
||||
ADD_ASYNC
|
||||
__attribute__((swift_async(none)));
|
||||
@end
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user