From: Jordan Rose Date: Thu, 15 Nov 2012 19:11:38 +0000 (+0000) Subject: [analyzer] StreamChecker: Remove now-unnecessary check::EndPath callback. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f34a5791c5c9df0348714e275adb09b8cf858460;p=clang [analyzer] StreamChecker: Remove now-unnecessary check::EndPath callback. Also, don't bother to stop tracking symbols in the return value, either. They are now properly considered live during checkDeadSymbols. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168069 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Checkers/StreamChecker.cpp b/lib/StaticAnalyzer/Checkers/StreamChecker.cpp index c06ba7c304..39723c04b3 100644 --- a/lib/StaticAnalyzer/Checkers/StreamChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/StreamChecker.cpp @@ -57,9 +57,7 @@ struct StreamState { }; class StreamChecker : public Checker > { + check::DeadSymbols > { mutable IdentifierInfo *II_fopen, *II_tmpfile, *II_fclose, *II_fread, *II_fwrite, *II_fseek, *II_ftell, *II_rewind, *II_fgetpos, *II_fsetpos, @@ -75,8 +73,6 @@ public: bool evalCall(const CallExpr *CE, CheckerContext &C) const; void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const; - void checkEndPath(CheckerContext &Ctx) const; - void checkPreStmt(const ReturnStmt *S, CheckerContext &C) const; private: void Fopen(CheckerContext &C, const CallExpr *CE) const; @@ -423,47 +419,6 @@ void StreamChecker::checkDeadSymbols(SymbolReaper &SymReaper, } } -void StreamChecker::checkEndPath(CheckerContext &Ctx) const { - ProgramStateRef state = Ctx.getState(); - StreamMapTy M = state->get(); - - for (StreamMapTy::iterator I = M.begin(), E = M.end(); I != E; ++I) { - StreamState SS = I->second; - if (SS.isOpened()) { - ExplodedNode *N = Ctx.addTransition(state); - if (N) { - if (!BT_ResourceLeak) - BT_ResourceLeak.reset(new BuiltinBug("Resource Leak", - "Opened File never closed. Potential Resource leak.")); - BugReport *R = new BugReport(*BT_ResourceLeak, - BT_ResourceLeak->getDescription(), N); - Ctx.emitReport(R); - } - } - } -} - -void StreamChecker::checkPreStmt(const ReturnStmt *S, CheckerContext &C) const { - const Expr *RetE = S->getRetValue(); - if (!RetE) - return; - - ProgramStateRef state = C.getState(); - SymbolRef Sym = state->getSVal(RetE, C.getLocationContext()).getAsSymbol(); - - if (!Sym) - return; - - const StreamState *SS = state->get(Sym); - if(!SS) - return; - - if (SS->isOpened()) - state = state->set(Sym, StreamState::getEscaped(S)); - - C.addTransition(state); -} - void ento::registerStreamChecker(CheckerManager &mgr) { mgr.registerChecker(); }