Simple CFG module for ExtendJ
This is a Control Flow Graph (CFG) module for the ExtendJ compiler for building simplified CFGs. This module builds CFGs for Java methods where only branches and method calls have are included. These simple CFGs provide enough information to perform intraprocedural static analyses on Java code.
This repository also includes two sample Java static analyzers based on the this
CFG module. One analyzer checks for additional calls to a
close() was called on the same instance.
The other analyzer checks for potential
null dereferences on paramters
annotated with javax.annotation.Nullable.
This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.
The demo analyzers can be plugged into the Shipshape pipeline. The Shipshape integration is currently experimental.
To build the Simplified CFG generator you need the following dependencies:
- Gradle 2.4
This repository has a submodule for the ExtendJ compiler. If you did not clone
this repository with the
--recursive flag you will have to run
git submodule init followed by
git submodule update, this will clone a specific commit from
the ExtendJ repository into the
Note that you must have the Git submodule
order to build SimpleCFG. To download the submodule, use the following commands:
git submodule init git submodule update
Build the Simplified CFG generator Jar file by running the following Gradle command:
The tests may be run by issuing the following command:
Most tests check that a well-formed SimpleCFG is built for each Java file in the testdata directory. The tests are structured so that they test the successors of each node in the resulting CFG for the single block/method in each of the Java files.
You can generate images for the CFGs in each test file by running the