[cfe-dev] Making clang::Rewriter friendlier for subclassing

Manuel Klimek klimek at google.com
Sun May 17 12:28:32 PDT 2015


I'd personally say that making the rewriter more complex by making the
methods virtual is not worth it. My design vote would go for decoupling
through a facade in the client code.

On Fri, May 15, 2015 at 5:01 AM Eli Bendersky <eliben at google.com> wrote:

> On Thu, May 14, 2015 at 7:13 PM, Manasij Mukherjee <manasij7479 at gmail.com>
> wrote:
>
>> If you mean to call the base methods anyway, wouldn't it be better to
>> have a Rewriter object as a member of your class ?
>>
>
> It is certainly possible to wrap Rewriter in another class. But this would
> mean the code needs to:
>
> 1. Replace Rewriter* everywhere with the new class
> 2. Implement all of Rewriter's methods to call base methods + additional
> operations
>
> This is quite cumbersome. Making some methods of Rewriter virtual,
> however, would mean (1) is not needed and in (2) we only need to override
> methods we instrument/modify.
>
> Eli
>
>
>>
>>
>> On Thu, May 14, 2015 at 12:20 PM, Eli Bendersky <eliben at google.com>
>> wrote:
>>
>>> Hi,
>>>
>>> Would there be objections to make clang::Rewriter a bit friendlier for
>>> subclassing by marking some of its methods virtual? In particular
>>> InsertText, ReplaceText, RemoveText and their variations.
>>>
>>> The reason for this is to be able to subclass Rewriter for the purposes
>>> of logging, debugging and other custom capabilities.
>>>
>>> If this sounds reasonable, I'll be happy to implement this.
>>>
>>> Thanks in advance,
>>>
>>> Eli
>>>
>>> _______________________________________________
>>> cfe-dev mailing list
>>> cfe-dev at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>>
>>>
>>  _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150517/faf0b937/attachment.html>


More information about the cfe-dev mailing list