[cfe-dev] libclang: Merge multiple platform availability declarations

Ronald Wampler via cfe-dev cfe-dev at lists.llvm.org
Thu May 18 18:55:16 PDT 2017


> On May 17, 2017, at 7:21 AM, Alex L <arphaman at gmail.com> wrote:
> 
> 
> 
> On 16 May 2017 at 19:16, Ronald Wampler via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> 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

> 
> Alex
>  
> Thank you,
> 
> Ron
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list