<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 2, 2014 at 2:19 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Wed, Oct 1, 2014 at 3:12 PM, Alexander Kornienko <span dir="ltr"><<a href="mailto:alexfh@google.com" target="_blank">alexfh@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>>>! In D5528#5, @doug.gregor wrote:<br>
> In non-macro cases, one can extract the locations of the parentheses using the lexer. Personally, I don't think the benefits of being able to extract the locations of the parentheses efficiently or in the macro cases outweigh the disadvantages of bloating the AST further.<br>
<br>
</span>For the context: this patch resulted from the discussion on D5395.<br>
<br>
I understand your concerns about bloating the AST. Some locations can be relatively easy found by re-lexing small parts of the input. One problem with this approach is that everyone who needs these locations spends time looking for a way to get them and then writing their own implementation. Is there a document or a comment describing the high-level approach to what is considered worthy storing in the AST?<br>
<br>
Also, it may be reasonable to add utility methods in the AST classes (or free-standing functions in clang/AST headers) for retrieving some less frequently used locations of syntactic constructs in non-macro cases (e.g. WhileStmt::findRParenLoc() which would find the first non-comment token after getCond()->getLocEnd()). What do you think?<br></blockquote><div><br></div></span><div>At the least, we should provide a version of Lexer::findLocationAfterToken that finds the location *of* the token, rather than skipping past it.</div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
And while you're here, one more question related to D5395:<br>
what is the reason why the statements ending with a semicolon do not include the semicolon in their source range (with exception of the NullStmt)? Is it feasible to extend the source range to include it? (and what would you expect to break in this case?)<br></blockquote><div><br></div></span><div>Perhaps it's time to add an ExprStmt to represent an expression-statement, along with the location of its semicolon.</div></div></div></div></blockquote><div><br></div><div>Well, what about ContinueStmt and BreakStmt which also don't include the location of the semicolon?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<a href="http://reviews.llvm.org/D5528" target="_blank">http://reviews.llvm.org/D5528</a><br>
<br>
<br>
</blockquote></div></div></div></blockquote></div><br>
</div></div>