libclang: Merge multiple platform availability declarations

Hi,

I’m working on a tool to list all deprecated APIs on macOS and using libclang's `clang_getCursorPlatformAvailability`. On macOS 10.12, the APIs are marked (to best of my knowledge) deprecated using the following macro __OSX_DEPRECATED(_start, _dep, _msg)

Which is defined as

__OSX_AVAILABLE(_start) __OS_AVAILABILITY_MSG(macosx,deprecated=_dep,_msg)

These macros expand to something like

__attribute__((availability(macosx,introduced=_start))) __attribute__((availability(macosx,deprecated=_dep,message=_msg)))

This appears to cause `clang_getCursorPlatformAvailability` to populate the array with two separate CXPlatformAvailability instances. Would it not be desirable to merge these two declarations as if it was defined as just __attribute__((availability(macosx,introduced=_start,deprecated=_dep,message=_msg)))?

Thank you,

Ron

Hi,

I’m working on a tool to list all deprecated APIs on macOS and using
libclang's `clang_getCursorPlatformAvailability`. On macOS 10.12, the
APIs are marked (to best of my knowledge) deprecated using the following
macro __OSX_DEPRECATED(_start, _dep, _msg)

Which is defined as

__OSX_AVAILABLE(_start) __OS_AVAILABILITY_MSG(macosx,deprecated=_dep,_msg)

These macros expand to something like

__attribute__((availability(macosx,introduced=_start)))
__attribute__((availability(macosx,deprecated=_dep,message=_msg)))

This appears to cause `clang_getCursorPlatformAvailability` to populate
the array with two separate CXPlatformAvailability instances. Would it not
be desirable to merge these two declarations as if it was defined as just
__attribute__((availability(macosx,introduced=_start,
deprecated=_dep,message=_msg)))?

Yes, right now the API populates the CXPlatformAvailability array based on
the exact attributes specified in the source. IMHO, it makes sense to keep
things simple in libclang and to map directly to the AST representation if
possible, which we kind of end up doing here. But your argument makes sense
too, at least from the perspective of a libclang user. I would encourage
you to create a patch that merges these availability instances in libclang
and send it to the list for review if you are interested in seeing this
fixed.

Alex

Hi,

I’m working on a tool to list all deprecated APIs on macOS and using libclang's `clang_getCursorPlatformAvailability`. On macOS 10.12, the APIs are marked (to best of my knowledge) deprecated using the following macro __OSX_DEPRECATED(_start, _dep, _msg)

Which is defined as

__OSX_AVAILABLE(_start) __OS_AVAILABILITY_MSG(macosx,deprecated=_dep,_msg)

These macros expand to something like

__attribute__((availability(macosx,introduced=_start))) __attribute__((availability(macosx,deprecated=_dep,message=_msg)))

This appears to cause `clang_getCursorPlatformAvailability` to populate the array with two separate CXPlatformAvailability instances. Would it not be desirable to merge these two declarations as if it was defined as just __attribute__((availability(macosx,introduced=_start,deprecated=_dep,message=_msg)))?

Yes, right now the API populates the CXPlatformAvailability array based on the exact attributes specified in the source. IMHO, it makes sense to keep things simple in libclang and to map directly to the AST representation if possible, which we kind of end up doing here. But your argument makes sense too, at least from the perspective of a libclang user. I would encourage you to create a patch that merges these availability instances in libclang and send it to the list for review if you are interested in seeing this fixed.

Thanks. I'll try to get a patch together shortly and see how it turns out.

Ron