r184768 - [analyzer] Add a debug checker that prints Exploded Graph

Anna Zaks ganna at apple.com
Mon Jun 24 11:12:12 PDT 2013


Author: zaks
Date: Mon Jun 24 13:12:12 2013
New Revision: 184768

URL: http://llvm.org/viewvc/llvm-project?rev=184768&view=rev
Log:
[analyzer] Add a debug checker that prints Exploded Graph
Add a debug checker that is useful to understand how the ExplodedGraph is
built; it can be triggered using the following command:

 clang -cc1 -analyze -analyzer-checker=debug.ViewExplodedGraph my_program.c

A patch by BĂ©atrice Creusillet!

Modified:
    cfe/trunk/docs/analyzer/DebugChecks.rst
    cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
    cfe/trunk/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp

Modified: cfe/trunk/docs/analyzer/DebugChecks.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/analyzer/DebugChecks.rst?rev=184768&r1=184767&r2=184768&view=diff
==============================================================================
--- cfe/trunk/docs/analyzer/DebugChecks.rst (original)
+++ cfe/trunk/docs/analyzer/DebugChecks.rst Mon Jun 24 13:12:12 2013
@@ -30,6 +30,10 @@ using a 'dot' format viewer (such as Gra
 - debug.DumpLiveVars: Show the results of live variable analysis for each
   top-level function being analyzed.
 
+- debug.ViewExplodedGraph: Show the Exploded Graphs generated for the
+  analysis of different functions in the input translation unit. When there
+  are several functions analyzed, display one graph per function. Beware 
+  that these graphs may grow very large, even for small functions.
 
 Path Tracking
 =============

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td?rev=184768&r1=184767&r2=184768&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td Mon Jun 24 13:12:12 2013
@@ -538,4 +538,8 @@ def ExprInspectionChecker : Checker<"Exp
   HelpText<"Check the analyzer's understanding of expressions">,
   DescFile<"ExprInspectionChecker.cpp">;
 
+def ExplodedGraphViewer : Checker<"ViewExplodedGraph">,
+  HelpText<"View Exploded Graphs using GraphViz">,
+  DescFile<"DebugCheckers.cpp">;
+
 } // end "debug"

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp?rev=184768&r1=184767&r2=184768&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp Mon Jun 24 13:12:12 2013
@@ -17,6 +17,8 @@
 #include "clang/Analysis/CallGraph.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "llvm/Support/Process.h"
 
 using namespace clang;
@@ -179,3 +181,22 @@ public:
 void ento::registerConfigDumper(CheckerManager &mgr) {
   mgr.registerChecker<ConfigDumper>();
 }
+
+//===----------------------------------------------------------------------===//
+// ExplodedGraph Viewer
+//===----------------------------------------------------------------------===//
+
+namespace {
+class ExplodedGraphViewer : public Checker< check::EndAnalysis > {
+public:
+  ExplodedGraphViewer() {}
+  void checkEndAnalysis(ExplodedGraph &G, BugReporter &B,ExprEngine &Eng) const {
+    Eng.ViewGraph(0);
+  }
+};
+
+}
+
+void ento::registerExplodedGraphViewer(CheckerManager &mgr) {
+  mgr.registerChecker<ExplodedGraphViewer>();
+}





More information about the cfe-commits mailing list