[cfe-dev] Missing Availability Information for Enums

Sebastian Hagedorn hagi.dd at web.de
Fri Mar 15 07:27:18 PDT 2013

I'm currently working on a Clang modification that analyses the (iOS SDK) version in which certain symbols were introduced. Most of it is based on code that looks similar to this:


So far, this works fine for ObjC methods, properties, classes, and C functions. One missing piece are enumerations, but I've found that they seem to lack availability information alltogether. Let's pick an example, I'm trying to use the PKPassKitErrorCode enum that was introduced in iOS 6. The framework header declares the following:

typedef NS_ENUM(NSInteger, PKPassKitErrorCode) {
    PKUnknownError = -1,
    PKInvalidDataError = 1,

Obviously, availability information is provided using the usual macros. This is what the preprocessor generates:

typedef enum PKPassKitErrorCode : NSInteger PKPassKitErrorCode; enum PKPassKitErrorCode : NSInteger {
    PKUnknownError = -1,
    PKInvalidDataError = 1,
} __attribute__((availability(ios,introduced=6.0)));

Still looks ok to me, all the information I'm looking for is included. However, when I try to get the availability information during the compilation process (I'm modifying Sema::DiagnoseUseOfDecl() in SemaExpr.cpp), there is none – getAttr<AvailabilityAttr>() returns NULL for EnumConstantDecls.

I have not started examining the parsing of the declaration, but wanted to ask first whether there's an obvious reason why the information is missing, or there's an obvious mistake/misassumption I'm making?

Any help is greatly appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130315/a9a6619d/attachment.html>

More information about the cfe-dev mailing list