[cfe-dev] improvements to scan-build

Anton Yartsev anton.yartsev at gmail.com
Wed Nov 5 14:19:04 PST 2014

Jordan, Anna, Ted, I'd love to hear your opinion. Do you think it make 
sense to move forward with it?

> Hi all,
> I'm thinking of the following improvements to scan-build and want to 
> discuss them with the community and to hear your thoughts and opinions:
> First of all, refactoring: keep all scan-build arguments in the hash 
> rather then in scattered variables.
> This will make the scan-build code easier to understand and make it 
> easier to re-engineer the code in the future.
> Then I intend to add a possibility for scan-build to read options from 
> a simple INI-like (http://en.wikipedia.org/wiki/INI_file) 
> configuration file.
> Values (if any) from this file will override default hardcoded values 
> but do not override those obtained from the command line.
> The file may have separate sections for scan-build, ccc/c++-analyzer 
> and environment variables (if needed).
> This will concentrate all the analyzer settings in the single place 
> and will allow users to easily observe the default values all-together 
> and to customize scan-build invocations of their own will.
> I also intend to add several additional options to scan-build:
> 1) Set of additional flags for ccc/c++-analyzer (e.g. additional 
> include paths, defines, optimization options, e.t.c).
> Often after 'configure' analysys with Clang ended up with different 
> errors and I had to manually patch makefiles to transfer additional 
> flags to Clang to make it work. It was a real headache.
> Here is random example of how this additional flags looked like: '-g0 
> -Os -fpermissive -D__STRICT_ANSI__ -I 
> "F:/---OGRE/ogre_src_v1-8-1/include" -I 
> "F:/---OGRE/ogre_src_v1-8-1/OgreMain/include"'...
> So many times I wished to put extra flags somewhere so that 
> ccc/c++-analyzer could take them and pass to Clang!
> In configuration file it might look like the following:
> CLANG_EXTRA_CXXFLAGS = -g0 -Os -fpermissive -D__STRICT_ANSI__ -I 
> "F:/---OGRE/ogre_src_v1-8-1/include" -I 
> "F:/---OGRE/ogre_src_v1-8-1/OgreMain/include"
> 2) If it happens so that both gcc and Clang are used after 
> configuration then they share the same set of flags and the problem 
> increases - Clang do not recognize some of gcc flags.
> So I wish to add another option to scan-build, (e.g. 
> CLANG_EXCLUDE_CXXFLAGS in config file) that will hold flags to be 
> excluded from Clang invocation.
> 3) The third option is to add a possibility to completely bypass 
> compilation step by gcc(g++, etc.) - this partially solves problems 
> with options and, what is more important, may significantly reduce 
> overall analisys time.
> May I move forward with this?
> Any thoughts and suggestions are welcome!

More information about the cfe-dev mailing list