[cfe-dev] null pointer literals, warnings, and fixups

David Blaikie dblaikie at gmail.com
Sun Aug 21 21:13:51 PDT 2011


On Fri, Aug 19, 2011 at 2:32 PM, Manuel Klimek <klimek at google.com> wrote:
> On Fri, Aug 19, 2011 at 2:05 PM, David Blaikie <dblaikie at gmail.com> wrote:
> <snip>
>> Side question: what tools currently exist that can actually apply
>> fixit instructions to code? Is there any existing simple program (that
>> would probably work like scan-build, or similar) that could be
>> instructed to actually apply all instances of a particular warning
>> fixup?
>
> We've been working on infrastructure to do exactly that, but it didn't
> get included in mainline (see
> http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-June/015434.html,
> which includes a patch that should still apply somewhat clean). We're
> currently working on different options to get it open sourced.

Ah, yes, I remember that thread. That's a bit of a bigger/more general
tool than I was thinking of in this context - in this case I was just
wondering if there was a simple tool to apply Clang's suggested
FixIts. In this case if I added a warning that suggested NULL over 0
in pointer contexts (or 0 over NULL, if that was the desired coding
convention) & nullptr over both in C++0x, I would like to be able to
say "apply all fixups from this warning" & then I could easily
transform a codebase over to nullptr (or maintain 0/NULL usage in
C++98).

> The architectural idea is that you have a clang-fixit tool that uses
> cmake's ability to output compile commands to apply all possible fixes
> that clang suggests on a file.

So you'd take all of cmake's output then filter it through some tool
to grab the compile commands, replace the compiler name with your tool
& then your program uses clang as a lib to produce fixits & act on
them? Neat. Though I wonder if it'd be possible/better/worse to use
the clang static analyzer's scan-build approach of injecting itself
into the compilation process & splitting - running both the analyzer
(fixer) & compiler at the same time. Relying on cmake would only work
for people using that build system, scan-build seems to be a little
more versatile.

- David



More information about the cfe-dev mailing list