[cfe-dev] [clang-tidy] Some possible contributions

Firat Kasmis via cfe-dev cfe-dev at lists.llvm.org
Tue Dec 15 16:29:02 PST 2015


I just uploaded the code to pastebin:

DeclarationTransformer: http://pastebin.com/GpzpJGiz
VariableDeclaration: http://pastebin.com/SPMNJvkY

DeclarationTransformer is a Matcher/MatcherCallback and VariableDeclaration
a helper struct.

    DeclarationTransformer declarationTransformer(context, rewriter);
    declarationTransformer.doTransformation();

I am using this in a bigger clang-tool that I am writing right now and thus
there are still TODOs and work to do. But I think this should help for now.
Furthermore, it is only used for C-code. So auto and co. won't work (I
think) since it is not been tested for C++ at all.

Here an example before (http://pastebin.com/M6Qkwbgi) and after (
http://pastebin.com/9jAQGd5Q) transformation. And of course, I will
appreciate any improvements.

Best,
Firat

2015-12-16 0:00 GMT+01:00 Piotr Dziwinski via cfe-dev <
cfe-dev at lists.llvm.org>:

> On 15/12/15 21:10, Richard via cfe-dev wrote:
>
>> [Please reply *only* to the list and do not include my email directly
>> in the To: or Cc: of your reply; otherwise I will not see your reply.
>> Thanks.]
>>
>> In article <56708712.6050402 at gmail.com>,
>>      Piotr Dziwinski via cfe-dev <cfe-dev at lists.llvm.org> writes:
>>
>> Thanks, I could use your code. My checker only handles local variables
>>> declared in functions so that parser or transformer doesn't have to work
>>> for globals necessarily.
>>>
>> I remember now that I was looking into this for a check that would
>> split a multiple variable declaration into multiple single variable
>> declarations.
>>
>> This would simplify your job of localizing variable declarations if
>> you could depend on each variable declaration being a single variable
>> declaration instead of a multiple variable declaration.
>>
>> With the suggestion made by Firat Kasmis, I should be able to write
>> this check now, which would handle globals and struct/class fields.
>>
>> Thoughts?
>>
>
> Well, taking the assumption that all variable declarations are single
> declarations would simplify my localizing variables checker a great deal
> and make issue #1 obsolete.
>
> On the other hand, I worry about the decreased usability from the user's
> point of view.
> He would have to first run the checker that splits multiple declarations,
> applying its fixes everywhere.
> Only then, as a second step, he would be able to run the localizing
> variables checker, and use its fixes.
>
> I'm not sure if we want to go in that direction. As far as I know, so far
> there aren't any checkers that make such assumptions, generating such
> implicit dependencies.
>
> Best regards,
> Piotr Dziwinski
>
> _______________________________________________
> 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/20151216/5c6e6fc0/attachment.html>


More information about the cfe-dev mailing list