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

Richard via cfe-dev cfe-dev at lists.llvm.org
Mon Oct 19 23:24:11 PDT 2015


[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 <562004D4.20009 at gmail.com>,
    Piotr Dziwinski via cfe-dev <cfe-dev at lists.llvm.org> writes:

> On 2015-10-13 22:33, 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.]
> As you wish.

Sorry about that, but ever since they changed the mailing list software,
I've been losing replies to my posts if they aren't sent to me through
the mailing list.  I try to set the Reply-To, but the mailing list
software keeps deciding it knows better and changes it.

> Yes, I was thinking along the same lines. It seems that these are the 
> most common cases, where people rely on evaluating pointer as boolean. 

Those are so idiomatic and prevalent throughout the community that I
think warning on those would be more irksome than helpful.  However,
for all those cases where my int was implicitly converted to bool and
vice-versa, I think that would be really useful because in my experience
those most often represent coding mistakes.

> [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.

> Thanks, it's nice to hear that my work is being appreciated. I think I 
> will be able to make that check reliable enough for production use. Once 
> I finish it, I'll test it myself by running it on Colobot codebase 
> (100k+ LOC). This should prove to be a suitable field test for it.

Oh, it is very much appreciated!  Not only your contributions but
everyone who contributes to clang and associated tools is very much
appreciated.

If you want a real torture case for localizing variables you can
try iterated dynamics, my fork of the open source fractint fractal
renderer.  It has a CMake based build and unfortunately too many
long functions with all the variables declared at the top C style.
<https://github.com/LegalizeAdulthood/iterated-dynamics>
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
     The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
         The Terminals Wiki <http://terminals.classiccmp.org>
  Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>



More information about the cfe-dev mailing list