<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>This sounds like a bug in clang.<br></div>
<div> </div>
<div>typedefs are not expanded in the same way that macros are, and should not cause the same misery on SourceLocations as they do. Verify that the source range you're getting is valid.<br></div>
<div> </div>
<div id="sig30782065"><div class="signature">---<br></div>
<div class="signature">Best regards,<br></div>
<div class="signature"> </div>
<div class="signature">Gábor 'ShdNx' Kozár<br></div>
<div class="signature"><a href="http://gaborkozar.me">http://gaborkozar.me</a><br></div>
<div class="signature"> </div>
</div>
<div> </div>
<div> </div>
<div>On Tue, Sep 8, 2015, at 06:54, Yogesh Chobe via cfe-dev wrote:<br></div>
<blockquote type="cite"><div dir="ltr"><div>Hi All, <br></div>
<div> </div>
<div><div>In the ASTVisitor, when I hit VisitDecl(Decl* d) for a function of interest, I am inserting some code above that function using TheRewriter.InsertTextBefore(d->getSourceRange().getBegin(), someString);<br></div>
<div> </div>
<div>This has been working out great for a while, but I hit upon some user code which has a typedef'd return type. In this case, I don't see anything being inserted. My hypothesis is that the typedef is expanded at the point where I am inserting into the AST and when I write the user code back to disk, the expanded type and my changes are all replaced by the typedef'd symbol.<br></div>
<div> </div>
<div>I tried to do a getLocWithOffset(-1) type of thing to the getBegin() but that did not help. Is there a way to say insertAfterPreviousLine() kind of a thing? I am using the 3.5 release version and I could not find an easy way to get a handle to the line above the function declaration.<br></div>
</div>
<div> </div>
<div>Thanks, <br></div>
<div>Yogesh<br></div>
</div>
<div><u>_______________________________________________</u><br></div>
<div>cfe-dev mailing list<br></div>
<div><a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br></div>
<div><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br></div>
</blockquote><div> </div>
</body>
</html>