[cfe-dev] Getting precise SourceLocation for VarDecl
Himanshu via cfe-dev
cfe-dev at lists.llvm.org
Wed Jul 27 10:57:28 PDT 2016
Actually I found out that getLoc works as desired in this case.
On Wed, Jul 27, 2016 at 10:49 AM, Himanshu <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?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev