[cfe-dev] Getting precise SourceLocation for VarDecl
Kirill Bobyrev via cfe-dev
cfe-dev at lists.llvm.org
Wed Jul 27 11:04:03 PDT 2016
For such things you might also want to take a look at clang-rename tool in clang/tools/extra.
—
Kirill
> On 27 Jul 2016, at 19:57, Himanshu via cfe-dev <cfe-dev at lists.llvm.org> wrote:
>
> Actually I found out that getLoc works as desired in this case.
> thanks!
>
> --
> Himanshu
>
> On Wed, Jul 27, 2016 at 10:49 AM, Himanshu <himanshu at utexas.edu <mailto:himanshu at utexas.edu>> wrote:
> Hi All,
>
> I am working on a rewriter that needs to replace certain variable declarations. Let me create a simplified example here. Consider the following DeclStmt:
>
> size_t v, *u = NULL, w = 10;
>
> In my RecursiveASTVisitor I implement VisitVarDecl, and use the rewriter.replace(SourceRange, ...) API. I create the SourceRange using VarDecl::getLocStart and getLocEnd. But this leads to the whole DeclStmt being replaced even if only want to replace u or w. I tried using the getInnerLocStart, but it leads to the same issue. How should I get the correct start and end locations for each individual VarDecl?
>
>
> Thanks!
> -
> Himanshu
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160727/cf4ad9ca/attachment.html>
More information about the cfe-dev
mailing list