<div dir="ltr">Thanks. Both worked. Also, aren't macros already expanded at this point?</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 18, 2014 at 4:56 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, Sep 17, 2014 at 3:55 PM, Mihai Draghicioiu <span dir="ltr"><<a href="mailto:mihai.draghicioiu@gmail.com" target="_blank">mihai.draghicioiu@gmail.com</a>></span> wrote:<br></span><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi guys. I'm trying to get a SourceLocation for a couple of points in the source. So for:<div><br></div><div><font face="courier new, monospace">class Foo<b><HERE></b>:</font></div></div></blockquote><div><br></div></span><div>Lexer::getLocForEndOfToken(RD->getLocation(), 0, /*...*/)<br></div><div> <br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><font face="courier new, monospace">public Bar <b><AND HERE></b>{</font></div></blockquote></div><div> </div><div>Do you want the location of the open brace, or the location after each base specifier? For the base specifiers, iterate over RD->bases() and grab the source range. (Use getLocForEndOfToken on the end of the range.) We don't directly store the location of the left brace, but you can get an approximation of the right thing by scanning forwards through the input buffer looking for it (you can be defeated by macros, but that's hard to avoid without re-lexing).</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class=""><div dir="ltr">Starting from a CXXRecordDecl (which I get from RecursiveASTVisitor::VisitCXXRecordDecl()), currently I am only able to get the location before the <i>class</i> keyword (with TagDecl::getInnerLocStart()) and after it (TagDecl::getOuterLocStart()).<div><br></div><div>I've been struggling with this for a while now, and the documentation really isn't helping. There are many missing enums and member functions in the docs. Am I supposed to use the lexer somehow? How? Am I supposed to use VisitTypeLoc()? I dunno, help!</div><div><br></div><div>This is for a source translation tool that translates a small subset of C++ to JS. So:</div><div><br></div><div><font face="courier new, monospace">class Foo: public Bar {</font></div><div><font face="courier new, monospace">    Foo(int x, float y) {</font></div><div><br></div><div>Becomes:</div><div><br></div><div><font face="courier new, monospace">function Foo(x, y) {</font></div><div><font face="courier new, monospace">...</font></div><div><font face="courier new, monospace">}</font></div><div><font face="courier new, monospace">// Do some inheritance stuff for Bar</font></div><div><br></div></div>
<br></span>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div><br></div>