The C++ static analysis tools are accessed through the ct
increment,
which is entered with the CLI command >ct
. The commands available
in that increment are described here,
starting after the line ct>help full
.
The contents of the code library must be defined before any of the tools
can be used. This can be done with >read buildlib
, which imports the
entire code base using the buildlib script (which,
in turn, uses the lib.create script). You can
modify these scripts to import your own code.
As the library is built, #include
relationships are noted. This allows
#include
dependencies to be analyzed using the operators ub
, us
,
ab
, as
, and ca
.
The command >parse - win64 $files
parses all of the files in the library
(for 64-bit Windows). After a set of files has been parsed, the following
commands can be used on those files:
>check
, to look for violations of C++ design guidelines (a file that has not been parsed is automatically parsed before it is checked, with a prompt to also parse files that are affected by that file)>fix
, to interactively modify the files to eliminate warnings found by>check
(currently, about half of the warning types can be fixed this way)>export
, to generate any of the following:- a .lib file that displays the parsed code in a standard format
- a .trim file that lists the symbols that each file uses from other
files, along with the recommendations for which
#include
directives,using
statements, and forward declarations the file should add or remove - an .xref file that contains a global cross-reference
The operators im
, nb
, ns
, db
, df
, ds
, rb
, and rs
can also
be used once the code has been parsed. A summary of all operators appears
in the CLI help documentation.
The output directory is regularly updated with the files
generated by the >check
and >export
commands for the current
release of the entire code base:
- the .check file from
>check
- the .lib file from
>export
- the .trim file from
>export
- the .xref file from
>export
Documentation for each warning that >check
can emit can be seen
here. (This file is formatted for use by the
>explain
command but is easily readable.)
The parser currently supports everything used within RSC. Because this is
not everything in C++, there are limitations. A detailed description of
exclusions is available here. Some things
are not fully supported and can result in false positives from >check
. But
if code uses something that is not supported at all, it will fail to compile,
which will limit the usefulness of the tools. If you run into this, you are
welcome to request that the missing language feature(s) be supported.
This article on CodeProject discusses the static analysis tools in a bit more detail.