<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On 29 Oct 2013, at 17:11, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> wrote:<br><div><br><blockquote type="cite"><div style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">The logic all seems correct here, but I think we can still do better on the message. The class and protocol cases seem a little underinformative to me, especially since the analyzer doesn't have a note where the availability shows up. So instead of a version kind, how about just passing the decl that has the availability attribute? That way we can say "method", "function", "class 'Foo'", or "protocol 'Foo'".</div><div style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br></div><div style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Also, it would be nice to include the platform name with the version. This code is stolen from DeclBase.cpp, but I don't have a better place for it right now.</div><div style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br></div><div style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  <span style="color: rgb(79, 129, 135);">StringRef</span><span class="Apple-converted-space"> </span>TargetPlatform = Context.<span style="color: rgb(49, 89, 93);">getTargetInfo</span>().<span style="color: rgb(49, 89, 93);">getPlatformName</span>();</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"> <span class="Apple-converted-space"> </span><span style="color: rgb(79, 129, 135);">StringRef</span><span class="Apple-converted-space"> </span>PrettyPlatformName</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">    =<span class="Apple-converted-space"> </span><span style="color: rgb(79, 129, 135);">AvailabilityAttr</span>::<span style="color: rgb(49, 89, 93);">getPrettyPlatformName</span>(TargetPlatform);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"> <span class="Apple-converted-space"> </span><span style="color: rgb(187, 44, 162);">if</span><span class="Apple-converted-space"> </span>(PrettyPlatformName.<span style="color: rgb(49, 89, 93);">empty</span>())</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">    PrettyPlatformName = TargetPlatform;</div><div><br></div><div>"Calling method introduced in OS X 10.9 (deployment target is 10.8)"</div><div><br></div><div>But other than this polish this is looking very good. Have you tried running it on existing projects?</div><div>Jordan</div></div></blockquote></div><br><div>OK, I have changed the message as suggested, works for you?</div><div><br></div><div>I have been running this on some small projects, but today gave it a test on all the large old projects I have here. Mostly it is working well (and caught many unsafe calls I was not aware of), but there were some issues which I have addressed in the latest patch:</div><div><br></div><div>* id types cause false positives</div><div>When calling methods on id types (in block enumerations and so on) the method decl match is often incorrect, and so the version check information often causes false positives. I fixed this by not checking any ObjCMethodCall without a receiver interface.</div><div><br></div><div>* Array and Dictionary subscripting</div><div>When using subscripting in a project with a deployment target less than iOS6 (or 10.8?), every subscript will cause a version warning. However, as stated here:</div><div><br></div><div><a href="https://developer.apple.com/library/ios/releasenotes/ObjectiveC/ObjCAvailabilityIndex/index.html">https://developer.apple.com/library/ios/releasenotes/ObjectiveC/ObjCAvailabilityIndex/index.html</a></div><div><br></div><div>subscripting is handled back to iOS5 and 10.6. I am not sure of the best way to handle this, the current workaround was just to match the selectors by name and not version check when we have a subscript selector. Ideally the checker would make sure that the deployment target was high enough for the runtime to support subscripting, is there a way to get this information from some API?</div><div><br></div><div>* Methods that call [super sameMethod]</div><div>I had a few false positives where implementing eg</div><div><br></div><div><div style="margin: 0px; font-family: Monaco;">- (<span style="color: #bb2ca2">void</span>)encodeRestorableStateWithCoder:(<span style="color: #703daa">NSCoder</span> *)coder</div><div style="margin: 0px; font-family: Monaco;">{</div><div style="margin: 0px; font-family: Monaco; color: rgb(61, 29, 129);"><span style="color: #000000">    [</span><span style="color: #bb2ca2">super</span><span style="color: #000000"> </span>encodeRestorableStateWithCoder<span style="color: #000000">:coder];</span></div><p style="margin: 0px; font-family: Monaco; min-height: 19px;">}</p></div><div><br></div><div>Currently I have left these as false positives, but perhaps there should be special casing to handle this situation too. What do you think about this, is it safe to ignore methods called on super that have been implemented on self, regardless of deployment target? </div><div><br></div><div>Richard</div><div><br></div><div></div></body></html>