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

Piotr Dziwinski via cfe-dev cfe-dev at lists.llvm.org
Tue Oct 20 15:38:39 PDT 2015


On 2015-10-20 08:24, Richard via cfe-dev wrote:
>> [localizing variables]
>>
>> I'm working on it now and I think I see how to approach this. I decided
>> on writing something like a context-sensitive RecursiveASTVisitor, where
>> I can keep track of variable declarations and their uses in different
>> scopes. At the end, I just go over the collected data, and propose
>> replacements as necessary. Sound complicated but it should do the job.
> Yeah, I was thinking that it would need to be it's own visitor as well.
> I was thinking of how I could do it in the clang-tidy tooling framework
> and it just wasn't coming together in my head.  I think the approach
> you've outlined is a good one.

Yes, and it's coming along nicely. I already have a sort-of working 
version on my github fork:
https://github.com/piotrdz/clang-tools-extra/blob/master/clang-tidy/readability/LocalizingVariablesCheck.cpp

It still needs work on corner cases and some hard cases like switch 
statements, which I've left out for now. And of course more tests. I 
will try to cover as much as possible in unit tests, but it's just 
impossible to test everything. The real verification will be running it 
on some production code. I will look at the project you gave as example, 
too.

Best regards,
Piotr Dziwinski



More information about the cfe-dev mailing list