<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;"><br><div><div>On May 24, 2013, at 16:35 , Argyrios Kyrtzidis <<a href="mailto:akyrtzi@gmail.com">akyrtzi@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: 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; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On May 24, 2013, at 3:40 PM, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> wrote:<br><div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: 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; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">I see that we're fixing crashes, but why isn't it just part of the precondition for this function that it is never called with an invalid FileID?</div></blockquote><div><br></div><div>It's not checking the parameters, the source locations it received may be fine, but then getDecomposedLoc() may return an invalid FileID because, for example, the location was in a PCH and the file it referred to was removed from the file system *after* we fully loaded the PCH.</div><br><blockquote type="cite"><div style="letter-spacing: 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; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><br></div><div>Also, you can't change isBeforeInTranslationUnit that way; the sort's not consistent. Invalid locs should be always before or always after valid locs, or you should assert that this doesn't happen.</div></div></blockquote><div><br></div><div>You are right that the return value becomes meaningless; maybe add an optional "bool *Invalid" parameter and allow callers to check that ?</div></div></div></blockquote><br></div><div dir="auto">This function is used as a comparator for std::sort and such. I think you can just make an ordering by fiat and it won't hurt anyone.</div><br></body></html>