<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>Le 27 juil. 09 à 17:09, Chris Lattner a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br>On Jul 27, 2009, at 6:14 AM, Erik Verbruggen wrote:<br><br><blockquote type="cite"><br></blockquote><blockquote type="cite">On Monday, 27 July, 2009, at 01:16PM, "Sebastian Redl" <<a href="mailto:sebastian.redl@getdesigned.at">sebastian.redl@getdesigned.at</a> <br></blockquote><blockquote type="cite"><blockquote type="cite">wrote:<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite">I believe, from previous reviews I've seen, that an operator < <br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">should only<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">be defined if there is a natural ordering. If you simply need an <br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">ordering<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">for a std::map (which you may want to replace by one of LLVM's own <br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">ADTs, by<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">the way - another point that comes up often, though it depends on <br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">what you<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">do with the map), it is, I believe, generally preferred to write a <br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">custom<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">ordering predicate and supply it as a template parameter.<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">A new patch is attached, which:<br></blockquote><blockquote type="cite">- has a custom ordering predecate for QualType<br></blockquote><blockquote type="cite">- fixes a range bug (where the last handler wasn't checked)<br></blockquote><blockquote type="cite">- fixes a crash when the caught exception type is null (i.e. for <br></blockquote><blockquote type="cite">catch(...))<br></blockquote><blockquote type="cite">- adds a testcase<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">On the map type: I checked <a href="http://llvm.org/docs/ProgrammersManual.html#ds_map">http://llvm.org/docs/ProgrammersManual.html#ds_map</a> <br></blockquote><blockquote type="cite"> and none of the other datatypes seem applicable.<br></blockquote><br>Instead of using std::map, please use a SmallVector<pair<>, 8> and <br>then use array_pod_sort (from llvm/ADT/STLExtras.h) to sort it after <br>it is populated. A simple linear scan can then detect dupes.<br><br>It looks like some tabs are sneaking in:<br><br>+ // Detect handlers for the same type as an earlier one.<br>+ const QualType QT = Handler->getCaughtType();<br>+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>if (QT.isNull())<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>continue;<br><br><br>You shouldn't use getCanonicalTypeInternal here, you should use <br>ASTContext::getCanonicalType:<br><br>+ const QualType CQT = QT.getTypePtr()->getCanonicalTypeInternal();<br><br>How does objc treat CV qualifiers on catch types? I don't think that <br>this makes sense, does it?<br><br>@catch (NSString *const X) ..<br>@catch (NSString *volatile X) ..<br><br></div></blockquote><div><br></div><div>Just a side note, even @catch(NSString *) does not really make sense in fact, at least in 64-bit, as the frameworks require that you do not throw something that does not inherits NSException.</div></div><div><br></div><div>From <a href="http://developer.apple.com/releasenotes/Cocoa/RN-ObjectiveC/">http://developer.apple.com/releasenotes/Cocoa/RN-ObjectiveC/</a> </div><div><br></div><div><span class="Apple-style-span" style="font-family: 'Lucida Grande', Geneva, Helvetica, Arial, sans-serif; font-size: 12px; ">The Cocoa frameworks require that all exceptions be instances of <code style="font-size: 11px; font-family: Monaco, Courier, Consolas, monospace; ">NSException</code> or its subclasses. Do not throw objects of other types.</span></div><div><br></div><div><br></div></body></html>