<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; "><div>I think my long-term suggestion would be to have one "initializeSelectors" method that runs in advance and fills up a map of class names -> selector sets. Then you iterate through the superclasses until you find one that's in the map, and then check the selectors as before. (If you wanted to be a little more lazy about it, you could put function pointers in the map, where each function returned the set of selectors appropriate for that class.)</div><div><br></div><div>As for multi-keyword selectors, what you have to do is make an <i>array</i> of IdentifierInfo objects appropriate for that selector. You could either do this explicitly (with an array of strings and then an array of IdentifierInfo), or cheat using variadic functions. Take a look at <span style="font-family: Menlo; font-size: 11px; ">isMultiArgSelector</span> in NoReturnFunctionChecker.cpp and <span style="font-family: Menlo; font-size: 11px; ">generateSelector</span> in RetainCountChecker.cpp to see what I mean.</div><div><br></div><div>For bonus points, change <span style="color: rgb(79, 129, 135); font-family: Menlo; font-size: 11px; ">SelectorTable</span><span style="font-family: Menlo; font-size: 11px; ">::getSelector</span> to take an ArrayRef<IdentifierInfo *> instead of a size and pointer-to-first-element. (In a separate patch, please, since this will cause changes throughout the entire compiler! Benign changes, though.)</div><div><br></div><div>Would love to see more work from you to improve this checker (and others). Thanks for thinking about this.</div><div>Jordan</div><div><br></div><br><div><div>On Nov 2, 2012, at 5:05 , Julian Mayer <<a href="mailto:julian@corecode.at">julian@corecode.at</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">On 30.10.2012, at 02:22, wrote Jordan Rose:<br><blockquote type="cite"><br> Committed, with a few slight tweaks, as r166993. Thanks!<br><br><a href="http://llvm-reviews.chandlerc.com/D78">http://llvm-reviews.chandlerc.com/D78</a><br></blockquote><br><br><br>hi jordan,<br><br>thanks, thats great ;)<br><br>while the topic is still hot, do you have any ideas for the future of the checker?<br><br>the first things i'd like to address are :<br>1.) checking other classes like UIResponder and NSResponder. should we extend our simple C const array based approach that we are using now for the selector names to multiple classes like this?<br><br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>const char *UIVC_SelectorNames[] = {"addChildViewController", "viewDidAppear", "viewDidDisappear"};<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>const unsigned UIVC_SelectorArgumentCounts[] = {1, 1, 1};<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>const size_t UIVC_SelectorCount = llvm::array_lengthof(UIVC_SelectorNames);<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>const char *UIR_SelectorNames[] = {"resignFirstResponder"};<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>const unsigned UIR_SelectorArgumentCounts[] = {0};<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>const size_t UIR_SelectorCount = llvm::array_lengthof(UIR_SelectorNames);<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>const void *Classes[] = {"UIViewController", UIVC_SelectorNames, UIVC_SelectorArgumentCounts, &UIVC_SelectorCount,<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span> "UIResponder", UIR_SelectorNames, UIR_SelectorArgumentCounts, &UIR_SelectorCount};<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><br><br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>for (int i = 0; i < llvm::array_lengthof(Classes); i += 4)<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>{<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>const char *className = (const char *)Classes[i+0];<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>const char **selectorNames = (const char **)Classes[i+1];<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>const unsigned *selectorArgumentCounts = (const unsigned *)Classes[i+2];<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>const size_t *selectorCount = (const size_t *)Classes[i+3];<br><br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>for (size_t v = 0; v < *selectorCount; v++)<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>{<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span> /* do checks as previously */<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>}<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>}<br><br><br>2.) checking multi-argument methods. as i understand it we currently can't check selectors with more than one argument because the call to Ctx.Selectors.getSelector(ArgumentCount, &II) doesn't work in these cases. i have searched the llvm internals documentation but couldn't find a simple solution to this problem...any ideas?<br><br>bye, julian<br><br><br>--<br>A. Julian Mayer <<a href="mailto:julian@corecode.at">julian@corecode.at</a>><br>CoreCode | Founder | Lead Developer<br><a href="http://www.corecode.at">http://www.corecode.at</a><br><br></blockquote></div><br></body></html>