<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Jun 22, 2009, at 9:37 AM, Douglas Gregor wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br><blockquote type="cite"><font class="Apple-style-span" color="#144FAE"><br></font></blockquote><blockquote type="cite">+void FunctionDecl::setBody(Stmt *B) {<br></blockquote><blockquote type="cite">+ Body = B;<br></blockquote><blockquote type="cite">+ if (B && EndRangeLoc < B->getLocEnd())<br></blockquote><blockquote type="cite">+ EndRangeLoc = B->getLocEnd();<br></blockquote><blockquote type="cite">+}<br></blockquote><br>Why do we need this < check? The body of the function definition will <br>always have an end location later in the file than the last function <br>parameter.<br></div></blockquote><div><br></div>Yep, this is redundant, no matter what value EndRangeLoc had before, it should be updated here. I removed the check.</div><div><br><blockquote type="cite"><div><br>I was about to point out that EndRangeLoc is unnecessary, because we <br>could compute the full range in getSourceRange(). However, when we're <br>dealing with a function definition deserialized from a PCH/AST file, <br>we can only compute the full range once the function body has been de- <br>serialized... so it's far better to have the (sometimes-redundant) </div></blockquote><blockquote type="cite"><div>EndRangeLoc. Please add a comment to that effect.<br></div></blockquote><div><br></div>Done.</div><div><br><blockquote type="cite"><div><br><blockquote type="cite">bool FunctionDecl::isMain() const {<br></blockquote><blockquote type="cite"> return getDeclContext()->getLookupContext()->isTranslationUnit() &&<br></blockquote><blockquote type="cite"> getIdentifier() && getIdentifier()->isStr("main");<br></blockquote><blockquote type="cite">@@ -481,6 +493,10 @@<br></blockquote><blockquote type="cite"> void *Mem = C.Allocate(sizeof(ParmVarDecl*)*NumParams);<br></blockquote><blockquote type="cite"> ParamInfo = new (Mem) ParmVarDecl*[NumParams];<br></blockquote><blockquote type="cite"> memcpy(ParamInfo, NewParamInfo, sizeof(ParmVarDecl*)*NumParams);<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+ // Update source range.<br></blockquote><blockquote type="cite">+ if (EndRangeLoc < NewParamInfo[NumParams-1]->getLocEnd())<br></blockquote><blockquote type="cite">+ EndRangeLoc = NewParamInfo[NumParams-1]->getLocEnd();<br></blockquote><blockquote type="cite"> }<br></blockquote><blockquote type="cite">}<br></blockquote><br><br>I don't think we need to use the < here.<br></div></blockquote><div><br></div><div>This is to allow the flexibility to set EndRangeLoc before setting the parameters.</div><div>i.e. at <span class="Apple-style-span" style="font-family: Monaco; font-size: 11px; ">PCHDeclReader::VisitFunctionDecl, EndRangeLoc is set before the setParams() call. If the check was missing we would have to be careful about the exact order of the calls to "reconstruct" the FunctionDecl.</span></div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 11px;"><br></span></font></div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 11px;"><br></span></font></div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 11px;">-Argiris</span></font></div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 11px;"><br></span></font></div></div></body></html>