To check existing codebases with PC-lint (plus) one has to:
- (according to manual) prepare a local PC-lint setup
- creating a
lin.batorlin.shthat invokes PC-lint (plus) - create a
std.lntthat includesco.lntandoptions.lnt - create a
co.lntthat sets up the compiler being used - create an
options.lntthat sets up the output format and - create a
suppressions.lntfor project-specific suppressions
- creating a
- invoke
lintwith all include paths and defines per compilation-unit.
In order to integrate with existing build chains this tool can be used to execute PC-lint using the build job's JSON compilation database.
Invoke lint4jsondb.py
W:\> lint4jsondb.py --compilation-db commands.json --lint-path D:\pclp --lint-binary pclp64.exe --jobs 6 -- std.lnt
where
--compilation-dbpoints to your build system's JSON compilation database--lint-pathpoints to you PC-lint root path (that contains the binaries and thelntdirectory)--lint-binarynames the PC-lint binary you want to execute (eitherpclp32,pclp64orlint-nt)--jobsis the number of parallel PC-lint jobs to spawn (defaults to number of CPU core)--and everything after it will be passed to the PC-lint binary; use it to point to yourstd.lnt
Optionally you can control which files of the overall JSON compilation database SHALL be processed using
--include-only <regexp>will include only those files whose full file-path matches<regexp>--exclude-all <regexp>will additionally exclude all those files whose full file-path matches<regexp>
Also, you can control if a file is to be treated as -library by PC-lint using
--treat-as-library <regexp>and e.g. pass thebuilddirectory where Qtmocgenerated files are stored
Additionally, you can control how PC-lint is invoked via --exec-mode
- either once per file using
each - or once per JSON compilation database using
all
It is recommended to use all (the default) as this allows PC-lint to further track member usage inter-dependencies.
- might work with FlexeLint as well (I don't have one to test with)
- Python >= 2.7
- Package
ijson(for parsing JSON compilation databases on the fly) - Package
mock(mocking calls, since Python 3.3 shipped with it)
The format specification for JSON compilation databases is available from LLVM.
Set CMAKE_EXPORT_COMPILE_COMMANDS to ON - or just pass -DCMAKE_EXPORT_COMPILE_COMMANDS=ON when invoking cmake.
For more information refer to the CMake manual.
Use Bear, see Bear on github.
Run qbs in generate mode and use the clangdb generator
$ > qbs generate -g clangdb
Refer to qbs manual on generators