From: Anna Zaks Date: Wed, 5 Oct 2011 23:44:11 +0000 (+0000) Subject: [analyzer] Remove the last dependency on CheckerContext::getNodeBuilder() as well... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4eff823b8e015e003d05953c386d685ee6bb6235;p=clang [analyzer] Remove the last dependency on CheckerContext::getNodeBuilder() as well as the method itself. Checkers should not directly access NodeBuilder, nodes can be created by calling the CheckerContext's generateNode() methods. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141249 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h b/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h index 417bea997e..19daaa537f 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h @@ -78,7 +78,6 @@ public: } ExplodedNodeSet &getNodeSet() { return Dst; } - StmtNodeBuilder &getNodeBuilder() { return B; } ExplodedNode *&getPredecessor() { return Pred; } const ProgramState *getState() { return ST ? ST : Pred->getState(); } const Stmt *getStmt() const { return statement; } diff --git a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp index b31c4a732d..58bd7ecf30 100644 --- a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -43,22 +43,20 @@ namespace { /// Wrapper around different kinds of node builder, so that helper functions /// can have a common interface. class GenericNodeBuilderRefCount { - StmtNodeBuilder *SNB; - const Stmt *S; + CheckerContext *C; const ProgramPointTag *tag; EndOfFunctionNodeBuilder *ENB; public: - GenericNodeBuilderRefCount(StmtNodeBuilder &snb, const Stmt *s, - const ProgramPointTag *t) - : SNB(&snb), S(s), tag(t), ENB(0) {} + GenericNodeBuilderRefCount(CheckerContext &c, + const ProgramPointTag *t) + : C(&c), tag(t), ENB(0) {} GenericNodeBuilderRefCount(EndOfFunctionNodeBuilder &enb) - : SNB(0), S(0), tag(0), ENB(&enb) {} + : C(0), tag(0), ENB(&enb) {} ExplodedNode *MakeNode(const ProgramState *state, ExplodedNode *Pred) { - if (SNB) - return SNB->generateNode(PostStmt(S, Pred->getLocationContext(), tag), - state, Pred); + if (C) + return C->generateNode(state, Pred, tag, false); assert(ENB); return ENB->generateNode(state, Pred); @@ -3110,7 +3108,7 @@ void RetainCountChecker::checkPreStmt(const ReturnStmt *S, // Update the autorelease counts. static SimpleProgramPointTag AutoreleaseTag("RetainCountChecker : Autorelease"); - GenericNodeBuilderRefCount Bd(C.getNodeBuilder(), S, &AutoreleaseTag); + GenericNodeBuilderRefCount Bd(C, &AutoreleaseTag); llvm::tie(Pred, state) = handleAutoreleaseCounts(state, Bd, Pred, C.getEngine(), Sym, X); @@ -3463,9 +3461,7 @@ RetainCountChecker::getDeadSymbolTag(SymbolRef sym) const { void RetainCountChecker::checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const { - StmtNodeBuilder &Builder = C.getNodeBuilder(); ExprEngine &Eng = C.getEngine(); - const Stmt *S = C.getStmt(); ExplodedNode *Pred = C.getPredecessor(); const ProgramState *state = C.getState(); @@ -3478,7 +3474,7 @@ void RetainCountChecker::checkDeadSymbols(SymbolReaper &SymReaper, if (const RefVal *T = B.lookup(Sym)){ // Use the symbol as the tag. // FIXME: This might not be as unique as we would like. - GenericNodeBuilderRefCount Bd(Builder, S, getDeadSymbolTag(Sym)); + GenericNodeBuilderRefCount Bd(C, getDeadSymbolTag(Sym)); llvm::tie(Pred, state) = handleAutoreleaseCounts(state, Bd, Pred, Eng, Sym, *T); if (!state) @@ -3496,7 +3492,7 @@ void RetainCountChecker::checkDeadSymbols(SymbolReaper &SymReaper, } { - GenericNodeBuilderRefCount Bd(Builder, S, this); + GenericNodeBuilderRefCount Bd(C, this); Pred = processLeaks(state, Leaked, Bd, Eng, Pred); }