[LLVMdev] sample of running google c++ lint script

Sebastian Redl sebastian.redl at getdesigned.at
Tue Jun 5 04:50:57 PDT 2012


On 05.06.2012 02:56, reed kotler wrote:
> Just as an example, I picked totally at random, one c++ program to run
> the google code style checker.
>
> There are clearly some valid points it found. I think it would good to
> start to adapt this tool
> or write a new tool to do style checking and to start to better
> formalize the llvm rules.
>
> I ran it against Target/Target.cpp
>
> Target.cpp:10:  Line ends in whitespace.  Consider deleting these extra
> spaces.  [whitespace/end_of_line] [4]
We have an incredible amount of those, and fixing them would create far 
too much churn. I generally fix them on the code I touch.
> Target.cpp:22:  Found C++ system header after other header. Should be:
> Target.h, c system, c++ system, other.  [build/include_order] [4]
The LLVM convention is to reverse the "usual" order. The first file any 
.cpp includes should be its own .h. Then other project headers. Then, in 
the case of Clang, the LLVM headers. And finally system and standard 
headers.
> Target.cpp:24:  Do not use namespace using-directives.  Use
> using-declarations instead.  [build/namespaces] [5]
LLVM convention is to use a using directive for the project namespace.
> Target.cpp:26:  Is this a non-const reference? If so, make const or use
> a pointer.  [runtime/references] [2]
What? Why?

Sebastian



More information about the llvm-dev mailing list