To check existing codebases with PC-lint (plus) one has to:
- (according to manual) prepare a local PC-lint setup
- creating a
lin.bat
orlin.sh
that invokes PC-lint (plus) - create a
std.lnt
that includesco.lnt
andoptions.lnt
- create a
co.lnt
that sets up the compiler being used - create an
options.lnt
that sets up the output format and - create a
suppressions.lnt
for project-specific suppressions
- creating a
- invoke
lint
with 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-db
points to your build system's JSON compilation database--lint-path
points to you PC-lint root path (that contains the binaries and thelnt
directory)--lint-binary
names the PC-lint binary you want to execute (eitherpclp32
,pclp64
orlint-nt
)--jobs
is 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>
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