<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Mar 15, 2013, at 7:27 , Sebastian Hagedorn <<a href="mailto:hagi.dd@web.de">hagi.dd@web.de</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">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:<div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(195, 89, 0); "><span style="">decl-></span><span style="color: #587ea8">getAttr</span><span style=""><</span>AvailabilityAttr<span style="">>()</span><span style="">-></span><span style="color: rgb(88, 126, 168); ">getIntroduced</span><span style="">()</span><span style="">;</span></div></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(195, 89, 0); "><span style=""><br></span></div><div style="margin: 0px; ">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 <span style="font-family: Menlo; font-size: 11px; ">PKPassKitErrorCode</span> enum that was introduced in iOS 6. The framework header declares the following:</div><div style="margin: 0px; "><br></div><div style="margin: 0px; "><div style="margin: 0px; font-size: 11px; font-family: Menlo; "><span style="color: #35568a">typedef</span> <span style="color: #777997">NS_ENUM</span>(NSInteger, PKPassKitErrorCode) {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">    PKUnknownError = -<span style="color: #35568a">1</span>,</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">    PKInvalidDataError = <span style="color: #35568a">1</span>,</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">    PKUnsupportedVersionError,</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">    PKInvalidSignature,</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(119, 121, 151); "><span style="">} </span>NS_ENUM_AVAILABLE_IOS<span style="">(</span><span style="color: #35568a">6</span><span style="">_0);</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(119, 121, 151); "><span style=""><br></span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(119, 121, 151); "><span style="font-family: Helvetica; font-size: medium; ">Obviously, availability information is provided using the usual macros. This is what the preprocessor generates:</span></div></div><div style="margin: 0px; "><br></div><div style="margin: 0px; "><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">typedef enum PKPassKitErrorCode : NSInteger PKPassKitErrorCode; enum PKPassKitErrorCode : NSInteger {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">    PKUnknownError = -<span style="color: #35568a">1</span>,</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">    PKInvalidDataError = <span style="color: #35568a">1</span>,</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">    PKUnsupportedVersionError,</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">    PKInvalidSignature,</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">} __attribute__((availability(ios,introduced=<span style="color: #35568a">6.0</span>)));</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "><br></div><div style="margin: 0px; ">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 <span style="font-family: Menlo; font-size: 11px; color: rgb(195, 89, 0); ">Sema</span><span style="font-family: Menlo; font-size: 11px; ">::DiagnoseUseOfDecl()</span> in SemaExpr.cpp), there is none – <span style="font-family: Menlo; font-size: 11px; color: rgb(88, 126, 168); ">getAttr</span><span style="font-family: Menlo; font-size: 11px; "><</span><span style="color: rgb(195, 89, 0); font-family: Menlo; font-size: 11px; ">AvailabilityAttr</span><span style="font-family: Menlo; font-size: 11px; ">>()</span> returns NULL for EnumConstantDecls.</div><div style="margin: 0px; "><br></div><div style="margin: 0px; ">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?</div></div></div></blockquote><br></div><div>The attribute here isn't <i>on</i> the EnumConstantDecls; it's on the EnumDecl as a whole. You'll also have to be careful about redeclarations; in this case I would guess that the first EnumDecl (inside the typedef) doesn't have the attribute, but the second one (where the enumerators are actually defined) does.</div><div><br></div><div>Jordan</div><br></body></html>