Files
swift-mirror/test/Interop/Cxx/enum/Inputs/CFAvailability.h
Nuri Amari 709321b69f Fix ASTMangler mangling NS_OPTION differently in C++ mode
CF_OPTIONS is defined differently in the SDK based on
a __cplusplus preprocessor branch. As a result, declarations
referencing CF_OPTIONS are mangled differently depending
on if C++ interop is enabled.

This meant a module compiled with cxx interop on could
not be linked with a module compiled without and vice versa.
This patch modifies the mangler such that the mangled names
are consistent. This is achieved by feeding the mangler a modified
AST node that looks like the Objective-C definition of CF_OPTIONS,
even when we have cxx interop enabled.
2023-03-09 09:30:05 -08:00

28 lines
1001 B
C

#if __has_attribute(enum_extensibility)
#define __CF_ENUM_ATTRIBUTES __attribute__((enum_extensibility(open)))
#define __CF_CLOSED_ENUM_ATTRIBUTES __attribute__((enum_extensibility(closed)))
#define __CF_OPTIONS_ATTRIBUTES \
__attribute__((flag_enum, enum_extensibility(open)))
#else
#define __CF_ENUM_ATTRIBUTES
#define __CF_CLOSED_ENUM_ATTRIBUTES
#define __CF_OPTIONS_ATTRIBUTES
#endif
#if (__cplusplus)
#define CF_OPTIONS(_type, _name) \
_type __attribute__((availability(swift, unavailable))) _name; \
enum __CF_OPTIONS_ATTRIBUTES : _name
#else
#define CF_OPTIONS(_type, _name) \
enum __CF_OPTIONS_ATTRIBUTES _name : _type _name; \
enum _name : _type
#endif
#define NS_OPTIONS(_type, _name) CF_OPTIONS(_type, _name)
typedef NS_OPTIONS(int, StandardNSOption) {
StandardNSOption1,
StandardNSOption2
};