[cfe-dev] Retrieving assignment operator from AST
George Burgess IV via cfe-dev
cfe-dev at lists.llvm.org
Sun Apr 24 21:28:53 PDT 2016
Readding cfe-dev.
I'm not at all familiar with the Rewriter APIs, so I could be wrong, but
ISTM that `Rewriter::InsertTextAfter(Loc, Str)` will insert text *at* Loc
(after any other text that was previously inserted at Loc). It also looks
like `bo->getLocEnd()` will not return the location of ";" in "foo = bar;".
So, it makes sense that things end up a bit off.
Have you tried using `InsertTextAfterToken` instead? It looks like that may
do what you want.
On Sun, Apr 24, 2016 at 12:13 PM, Awanish <avanis1994 at gmail.com> wrote:
> Thank you so much. It was really so helpful.
> Can you please help me in. I am getting something very weired
> If I a=b+c+d I have to convert this in fun(a,b+c+d)
> For this I am doing
> rewriter.InsertTextAfter(bo->getLocEnd(),")"); // bo is pointer to
> this statement.
> My output is
> fun(a,b+c+)d
> "*) just before last identifier*".
> Can you please tell me where I am doing wrong.
>
>
> On Tuesday 19 April 2016 01:48 AM, George Burgess IV wrote:
>
> Hi!
>
> ASTMatchers ( http://clang.llvm.org/docs/LibASTMatchersReference.html )
> are probably what you're looking for. If you'd like examples,
> clang-tidy's SimplifyBooleanExprCheck seems to create ASTMatchers for
> assignment operations.
>
> On Mon, Apr 18, 2016 at 2:27 AM, Awanish via cfe-dev <
> <cfe-dev at lists.llvm.org>cfe-dev at lists.llvm.org> wrote:
>
>> Dear All,
>>
>> I want to retrieve all assignment operator from a given C program. Can
>> anyone please inform me how to do it?Thanks in advance:-) .
>>
>> --
>> Thanks and Regards
>> Awanish Pandey
>> PhD, CSE
>> IIT Kanpur
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>
>
> --
> Thanks and Regards
> Awanish Pandey
> PhD, CSE
> IIT Kanpur
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160424/51828196/attachment.html>
More information about the cfe-dev
mailing list