As part of work funded by OpenSFS, a plugin for Clang has been developed. This plugin can be used to identify code in the Lustre source tree that is never called. In addition, structures that are read and never written, and unused variables can also be identified. The purpose of this document is to enable a developer to begin working with these tools.
llvm-devel-3.0-5.el6.elrepo.x86_64
clang-doc-3.0-5.el6.elrepo.noarch
Once elrepo is available as a repo, only the main channel is available by default. To install llvm and clang you need the elrepo-extras repo. This can be enabled by including
in your yum command. |
git clone http://git.whamcloud.com/tools/lustre-static-analysis.git
Build Lustre software using a script included in lustre-static-analysis for assistance:
# cd lustre-release # git clean -fxd # sh autogen.sh && ./configure # ~/lustre-static-analysis/DeclUse/decl_use_make |
For each .c
to .o
compilation performed by GCC, decl_use_make
will also run Clang with the lustre-static-analysis plugin. When compiling file.c
the output file.o
is produced by GCC and should be identical to a normal Lustre build. Simultaneously decl_use_make
instructs Clang to read file.c and produce corresponding file.o._Ref
and file.o._Err
. Note: Clang does not compile file.c to an object file. Clang parses file.c and produces an AST in memory. The file.o._Err
file records the errors Clang discovered during processing file.c
.
In practice, |
For the purposes of static analysis provided by the Clang plugin, the file.o._Ref
are intermediate file and not of general interest. The files of interest are contained in the directory DeclUse-2.5.60-40-g*/
. Useful file include:
File name | Description |
---|---|
Err | Errors reported by the Clang compiler. |
GetOnly | Structure members that are read somewhere but never set. |
MacroUnused | Macros that are never used. |
SetOnly | Structure members that are set somewhere but never read. |
Undefined | Variables that are never defined. |