[cfe-commits] r141133 - /cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h

Anna Zaks ganna at apple.com
Tue Oct 4 16:12:04 PDT 2011


Author: zaks
Date: Tue Oct  4 18:12:04 2011
New Revision: 141133

URL: http://llvm.org/viewvc/llvm-project?rev=141133&view=rev
Log:
[analyzer] Refactor node generation to use less code.

Modified:
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h?rev=141133&r1=141132&r2=141133&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h Tue Oct  4 18:12:04 2011
@@ -114,12 +114,7 @@
   /// \brief Generate a default checker node (containing checker tag but no
   /// checker state changes).
   ExplodedNode *generateNode(bool autoTransition = true) {
-    assert(statement && "Only transitions with statements currently supported");
-    ExplodedNode *N = generateNodeImpl(statement, getState(), false,
-                                       checkerTag);
-    if (N && autoTransition)
-      Dst.Add(N);
-    return N;
+    return generateNode(getState(), autoTransition);
   }
   
   /// \brief Generate a new checker node with the given predecessor.
@@ -127,8 +122,7 @@
   ExplodedNode *generateNode(const ProgramState *state,
                              ExplodedNode *pred,
                              bool autoTransition = true) {
-   assert(statement && "Only transitions with statements currently supported");
-    ExplodedNode *N = generateNodeImpl(statement, state, pred, false);
+    ExplodedNode *N = generateNodeImpl(state, false, pred);
     if (N && autoTransition)
       addTransition(N);
     return N;
@@ -138,9 +132,7 @@
   ExplodedNode *generateNode(const ProgramState *state,
                              bool autoTransition = true,
                              const ProgramPointTag *tag = 0) {
-    assert(statement && "Only transitions with statements currently supported");
-    ExplodedNode *N = generateNodeImpl(statement, state, false,
-                                       tag ? tag : checkerTag);
+    ExplodedNode *N = generateNodeImpl(state, false, 0, tag);
     if (N && autoTransition)
       addTransition(N);
     return N;
@@ -149,9 +141,7 @@
   /// \brief Generate a sink node. Generating sink stops exploration of the
   /// given path.
   ExplodedNode *generateSink(const ProgramState *state = 0) {
-    assert(statement && "Only transitions with statements currently supported");
-    return generateNodeImpl(statement, state ? state : getState(), true,
-                            checkerTag);
+    return generateNodeImpl(state ? state : getState(), true);
   }
 
   void addTransition(ExplodedNode *node) {
@@ -179,21 +169,14 @@
   }
 
 private:
-  ExplodedNode *generateNodeImpl(const Stmt *stmt,
-                                 const ProgramState *state,
+  ExplodedNode *generateNodeImpl(const ProgramState *state,
                                  bool markAsSink,
-                                 const ProgramPointTag *tag) {
-    ExplodedNode *node = B.generateNode(stmt, state, Pred, tag);
-    if (markAsSink && node)
-      node->markAsSink();
-    return node;
-  }
-
-  ExplodedNode *generateNodeImpl(const Stmt *stmt,
-                                 const ProgramState *state,
-                                 ExplodedNode *pred,
-                                 bool markAsSink) {
-   ExplodedNode *node = B.generateNode(stmt, state, pred, checkerTag);
+                                 ExplodedNode *pred = 0,
+                                 const ProgramPointTag *tag = 0) {
+    assert(statement && "Only transitions with statements currently supported");
+    ExplodedNode *node = B.generateNode(statement, state,
+                                        pred ? pred : Pred,
+                                        tag  ? tag  : checkerTag);
     if (markAsSink && node)
       node->markAsSink();
     return node;





More information about the cfe-commits mailing list