From fc0189aadc380b8727f874e942a7d3db798c3a72 Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Tue, 18 Oct 2011 23:05:58 +0000 Subject: [analyzer] Node Builder refactoring: Introduce a simple Node Builder responsible for generating the node frontier. Currently we have a bunch of different node builders which provide some common functionality but are difficult to refactor. Each builder generates nodes of different kinds and calculates the frontier nodes, which should be propagated to the next step (after the builder dies). Introduce a new NodeBuilder which provides very basic node generation facilities but takes care of the second problem. The idea is that all the other builders will eventually use it. Use this builder in CheckerContext instead of StmtNodeBuilder (the way the frontier is propagated to the StmtBuilder is a hack and will be removed later on). llvm-svn: 142443 --- .../lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp') diff --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp index 93e0fe5b4f9..be7ce384e7e 100644 --- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -54,12 +54,18 @@ public: GenericNodeBuilderRefCount(EndOfFunctionNodeBuilder &enb) : C(0), tag(0), ENB(&enb) {} - ExplodedNode *MakeNode(const ProgramState *state, ExplodedNode *Pred) { - if (C) - return C->generateNode(state, Pred, tag, false); + ExplodedNode *MakeNode(const ProgramState *state, ExplodedNode *Pred, + bool MarkAsSink = false) { + if (C) { + return C->generateNode(state, Pred, tag, false, MarkAsSink); + } assert(ENB); - return ENB->generateNode(state, Pred); + ExplodedNode *N = ENB->generateNode(state, Pred); + if (MarkAsSink) + N->markAsSink(); + + return N; } }; } // end anonymous namespace @@ -3366,9 +3372,7 @@ RetainCountChecker::handleAutoreleaseCounts(const ProgramState *state, V = V ^ RefVal::ErrorOverAutorelease; state = state->set(Sym, V); - if (ExplodedNode *N = Bd.MakeNode(state, Pred)) { - N->markAsSink(); - + if (ExplodedNode *N = Bd.MakeNode(state, Pred, true)) { llvm::SmallString<128> sbuf; llvm::raw_svector_ostream os(sbuf); os << "Object over-autoreleased: object was sent -autorelease "; -- cgit v1.2.3