diff --git a/.gitignore b/.gitignore index 51650bf5612..bea63f4c816 100644 --- a/.gitignore +++ b/.gitignore @@ -170,6 +170,9 @@ dataflow/tests/busy-expression/Out.txt dataflow/tests/busy-expression/*.class dataflow/tests/busyexpr/Out.txt dataflow/tests/busyexpr/*.class +dataflow/tests/busyexpr/Test-test-int.dot +dataflow/tests/busyexpr/Test-test-int.dot.pdf +dataflow/tests/busyexpr/methods.txt dataflow/tests/cfgconstruction/*.class dataflow/tests/constant-propagation/Out.txt dataflow/tests/constant-propagation/*.class diff --git a/dataflow/src/test/java/busyexpr/BusyExpression.java b/dataflow/src/test/java/busyexpr/BusyExpression.java index 619ec2dd1ad..7fffece8ffd 100644 --- a/dataflow/src/test/java/busyexpr/BusyExpression.java +++ b/dataflow/src/test/java/busyexpr/BusyExpression.java @@ -5,18 +5,23 @@ import org.checkerframework.dataflow.analysis.UnusedAbstractValue; import org.checkerframework.dataflow.busyexpr.BusyExprStore; import org.checkerframework.dataflow.busyexpr.BusyExprTransfer; +import org.checkerframework.dataflow.cfg.ControlFlowGraph; import org.checkerframework.dataflow.cfg.visualize.CFGVisualizeLauncher; -/** Used in busyExpressionTest Gradle task to test the BusyExpression analysis. */ +/** + * Run busy expression analysis create a text file of the CFG. + * + *

Used in busyExpressionTest Gradle task to test the BusyExpression analysis. + */ public class BusyExpression { /** - * The main method expects to be run in dataflow/tests/busy-expression directory. + * The main method expects to be run in the {@code dataflow/tests/busy-expression/} directory. * - * @param args not used + * @param args command-line arguments, not used */ public static void main(String[] args) { - String inputFile = "Test.java"; // input file name; + String inputFile = "Test.java"; String method = "test"; String clazz = "Test"; String outputFile = "Out.txt"; @@ -24,6 +29,10 @@ public static void main(String[] args) { BusyExprTransfer transfer = new BusyExprTransfer(); BackwardAnalysis backwardAnalysis = new BackwardAnalysisImpl<>(transfer); - CFGVisualizeLauncher.writeStringOfCFG(inputFile, method, clazz, outputFile, backwardAnalysis); + ControlFlowGraph cfg = + CFGVisualizeLauncher.generateMethodCFG(inputFile, method, clazz, backwardAnalysis); + CFGVisualizeLauncher.writeStringOfCFG(cfg, outputFile, backwardAnalysis); + // The .dot and .pdf files are not tested, only created for debugging convenience. + CFGVisualizeLauncher.generateDOTofCFG(cfg, ".", true, true, backwardAnalysis); } }