From: Ted Kremenek Date: Thu, 13 Jan 2011 04:36:36 +0000 (+0000) Subject: Remove CheckerContext's dependence on setting X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4bac726dadb09ee38bab8147f1e706380368b362;p=clang Remove CheckerContext's dependence on setting 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 --- diff --git a/include/clang/Analysis/ProgramPoint.h b/include/clang/Analysis/ProgramPoint.h index 9656803b63..36949c1c6c 100644 --- a/include/clang/Analysis/ProgramPoint.h +++ b/include/clang/Analysis/ProgramPoint.h @@ -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) {} diff --git a/include/clang/StaticAnalyzer/PathSensitive/Checker.h b/include/clang/StaticAnalyzer/PathSensitive/Checker.h index 82205dcd13..3b3952c20b 100644 --- a/include/clang/StaticAnalyzer/PathSensitive/Checker.h +++ b/include/clang/StaticAnalyzer/PathSensitive/Checker.h @@ -32,7 +32,7 @@ class CheckerContext { ExprEngine &Eng; ExplodedNode *Pred; SaveAndRestore OldSink; - SaveAndRestore OldTag; + const void *checkerTag; SaveAndRestore 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; diff --git a/include/clang/StaticAnalyzer/PathSensitive/CoreEngine.h b/include/clang/StaticAnalyzer/PathSensitive/CoreEngine.h index bc920d5cb1..a59b7a2369 100644 --- a/include/clang/StaticAnalyzer/PathSensitive/CoreEngine.h +++ b/include/clang/StaticAnalyzer/PathSensitive/CoreEngine.h @@ -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, diff --git a/lib/StaticAnalyzer/Checker.cpp b/lib/StaticAnalyzer/Checker.cpp index 6867ff5b64..2ee910f8df 100644 --- a/lib/StaticAnalyzer/Checker.cpp +++ b/lib/StaticAnalyzer/Checker.cpp @@ -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);