[cfe-dev] Using Rewriter to remove a function call argument along with preceding comma?

Stephan Bergmann sbergman at redhat.com
Tue Jun 11 13:34:27 PDT 2013


On 06/07/2013 08:19 PM, Argyrios Kyrtzidis wrote:
> On Jun 7, 2013, at 5:31 AM, Stephan Bergmann <sbergman at redhat.com
> <mailto:sbergman at redhat.com>> wrote:
>> Anyway, what I want to do is a rewriting Clang plugin that removes one
>> argument from specific function calls.  But where I'm lost is how to
>> determine the SourceLocation of the comma preceding the given
>> argument, to do something like
>
> You could remove this range:
>
> [loc-for-end-of-token of end location of preceding argument, end
> location of removed argument]

Yeah, but how do I get that loc-for-end-of-token?  I must confess that 
studying the header files left me clueless.  Continuing with my below 
example, what would replace the /*TODO*/ if I wanted to remove starting 
past the tokens for callExpr->getArg(0)?

Thanks again,
Stephan

>>  Rewriter.RemoveText(
>>    SourceRange(
>>      /*TODO*/,
>>      callExpr->getArg(1)->getLocEnd()));




More information about the cfe-dev mailing list