]> granicus.if.org Git - clang/commitdiff
Remove CheckerContext's dependence on setting
authorTed Kremenek <kremenek@apple.com>
Thu, 13 Jan 2011 04:36:36 +0000 (04:36 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 13 Jan 2011 04:36:36 +0000 (04:36 +0000)
the node builder's "tag" ivar (which we would
like to remove).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123361 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/ProgramPoint.h
include/clang/StaticAnalyzer/PathSensitive/Checker.h
include/clang/StaticAnalyzer/PathSensitive/CoreEngine.h
lib/StaticAnalyzer/Checker.cpp

index 9656803b635cf21ffbeac2661389e975f7e46bba..36949c1c6c54f81cd6035d0218651b59380d2e65 100644 (file)
@@ -181,14 +181,15 @@ public:
 
 class PostStmt : public StmtPoint {
 protected:
-  PostStmt(const Stmt* S, Kind k, const LocationContext *L, const void *tag = 0)
-    : StmtPoint(S, NULL, k, L, tag) {}
-
   PostStmt(const Stmt* S, const void* data, Kind k, const LocationContext *L,
            const void *tag =0)
     : StmtPoint(S, data, k, L, tag) {}
 
 public:
+  explicit PostStmt(const Stmt* S, Kind k, 
+                    const LocationContext *L, const void *tag = 0)
+    : StmtPoint(S, NULL, k, L, tag) {}
+
   explicit PostStmt(const Stmt* S, const LocationContext *L,const void *tag = 0)
     : StmtPoint(S, NULL, PostStmtKind, L, tag) {}
 
index 82205dcd136980fa168f2aeed5dfc859ba1e0bb1..3b3952c20b9d6f99f969dccb83fa62472d44899b 100644 (file)
@@ -32,7 +32,7 @@ class CheckerContext {
   ExprEngine &Eng;
   ExplodedNode *Pred;
   SaveAndRestore<bool> OldSink;
-  SaveAndRestore<const void*> OldTag;
+  const void *checkerTag;
   SaveAndRestore<ProgramPoint::Kind> OldPointKind;
   SaveOr OldHasGen;
   const GRState *ST;
@@ -48,7 +48,7 @@ public:
                  const Stmt *stmt = 0, const GRState *st = 0)
     : Dst(dst), B(builder), Eng(eng), Pred(pred),
       OldSink(B.BuildSinks),
-      OldTag(B.Tag, tag),
+      checkerTag(tag),
       OldPointKind(B.PointKind, K),
       OldHasGen(B.HasGeneratedNode),
       ST(st), statement(stmt), size(Dst.size()),
@@ -95,16 +95,18 @@ public:
 
   ExplodedNode *generateNode(bool autoTransition = true) {
     assert(statement && "Only transitions with statements currently supported");
-    ExplodedNode *N = generateNodeImpl(statement, getState(), false);
+    ExplodedNode *N = generateNodeImpl(statement, getState(), false,
+                                       checkerTag);
     if (N && autoTransition)
       Dst.Add(N);
     return N;
   }
   
   ExplodedNode *generateNode(const Stmt *stmt, const GRState *state,
-                             bool autoTransition = true) {
+                             bool autoTransition = true, const void *tag = 0) {
     assert(state);
-    ExplodedNode *N = generateNodeImpl(stmt, state, false);
+    ExplodedNode *N = generateNodeImpl(stmt, state, false,
+                                       tag ? tag : checkerTag);
     if (N && autoTransition)
       addTransition(N);
     return N;
@@ -119,46 +121,42 @@ public:
     return N;
   }
 
-  ExplodedNode *generateNode(const GRState *state, bool autoTransition = true) {
+  ExplodedNode *generateNode(const GRState *state, bool autoTransition = true,
+                             const void *tag = 0) {
     assert(statement && "Only transitions with statements currently supported");
-    ExplodedNode *N = generateNodeImpl(statement, state, false);
+    ExplodedNode *N = generateNodeImpl(statement, state, false,
+                                       tag ? tag : checkerTag);
     if (N && autoTransition)
       addTransition(N);
     return N;
   }
 
   ExplodedNode *generateSink(const Stmt *stmt, const GRState *state = 0) {
-    return generateNodeImpl(stmt, state ? state : getState(), true);
+    return generateNodeImpl(stmt, state ? state : getState(), true,
+                            checkerTag);
   }
   
   ExplodedNode *generateSink(const GRState *state = 0) {
     assert(statement && "Only transitions with statements currently supported");
-    return generateNodeImpl(statement, state ? state : getState(), true);
+    return generateNodeImpl(statement, state ? state : getState(), true,
+                            checkerTag);
   }
 
   void addTransition(ExplodedNode *node) {
     Dst.Add(node);
   }
   
-  void addTransition(const GRState *state) {
+  void addTransition(const GRState *state, const void *tag = 0) {
     assert(state);
     // If the 'state' is not new, we need to check if the cached state 'ST'
     // is new.
     if (state != getState() || (ST && ST != B.GetState(Pred)))
       // state is new or equals to ST.
-      generateNode(state, true);
+      generateNode(state, true, tag);
     else
       Dst.Add(Pred);
   }
 
-  // Generate a node with a new program point different from the one that will
-  // be created by the StmtNodeBuilder.
-  void addTransition(const GRState *state, ProgramPoint Loc) {
-    ExplodedNode *N = B.generateNode(Loc, state, Pred);
-    if (N)
-      addTransition(N);
-  }
-
   void EmitReport(BugReport *R) {
     Eng.getBugReporter().EmitReport(R);
   }
@@ -169,8 +167,8 @@ public:
 
 private:
   ExplodedNode *generateNodeImpl(const Stmt* stmt, const GRState *state,
-                             bool markAsSink) {
-    ExplodedNode *node = B.generateNode(stmt, state, Pred);
+                             bool markAsSink, const void *tag) {
+    ExplodedNode *node = B.generateNode(stmt, state, Pred, tag);
     if (markAsSink && node)
       node->markAsSink();
     return node;
@@ -178,7 +176,7 @@ private:
 
   ExplodedNode *generateNodeImpl(const Stmt* stmt, const GRState *state,
                                  ExplodedNode *pred, bool markAsSink) {
-   ExplodedNode *node = B.generateNode(stmt, state, pred);
+   ExplodedNode *node = B.generateNode(stmt, state, pred, checkerTag);
     if (markAsSink && node)
       node->markAsSink();
     return node;
index bc920d5cb1aaaf819ecb4354a96bd6d20d9edaf3..a59b7a23698867a8a66234d5640157fe46b425ed 100644 (file)
@@ -186,18 +186,19 @@ public:
   }
 
   ExplodedNode* generateNode(const Stmt *S, const GRState *St,
-                             ExplodedNode *Pred, ProgramPoint::Kind K) {
+                             ExplodedNode *Pred, ProgramPoint::Kind K,
+                             const void *tag = 0) {
     HasGeneratedNode = true;
 
     if (PurgingDeadSymbols)
       K = ProgramPoint::PostPurgeDeadSymbolsKind;
 
-    return generateNodeInternal(S, St, Pred, K, Tag);
+    return generateNodeInternal(S, St, Pred, K, tag ? tag : Tag);
   }
 
   ExplodedNode* generateNode(const Stmt *S, const GRState *St,
-                             ExplodedNode *Pred) {
-    return generateNode(S, St, Pred, PointKind);
+                             ExplodedNode *Pred, const void *tag = 0) {
+    return generateNode(S, St, Pred, PointKind, tag);
   }
 
   ExplodedNode *generateNode(const ProgramPoint &PP, const GRState* State,
index 6867ff5b645ddbc99c689b4062c8423ca819ecf1..2ee910f8dffbe04ef45c63fb93a5dc5b434db7d7 100644 (file)
@@ -27,8 +27,7 @@ CheckerContext::~CheckerContext() {
   if (Dst.size() == size && !B.BuildSinks && !B.HasGeneratedNode) {
     if (ST && ST != B.GetState(Pred)) {
       static int autoTransitionTag = 0;
-      B.Tag = &autoTransitionTag;
-      addTransition(ST);
+      addTransition(ST, &autoTransitionTag);
     }
     else
       Dst.Add(Pred);