From: Ted Kremenek Date: Fri, 12 Oct 2012 22:56:40 +0000 (+0000) Subject: Silence null dereference warnings by documenting context-specific X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5a8fc88b18793f25d4423805d7e4ac5d0325b9a6;p=clang Silence null dereference warnings by documenting context-specific invariants using assertions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165840 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp index 3338c479be..c84365e4a9 100644 --- a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -2203,6 +2203,7 @@ GetAllocationSite(ProgramStateManager& StateMgr, const ExplodedNode *N, // If allocation happened in a function different from the leak node context, // do not report the binding. + assert(N && "Could not find allocation node"); if (N->getLocationContext() != LeakContext) { FirstBinding = 0; } @@ -2258,6 +2259,7 @@ CFRefLeakReportVisitor::getEndPath(BugReporterContext &BRC, // Get the retain count. const RefVal* RV = getRefBinding(EndN->getState(), Sym); + assert(RV); if (RV->getKind() == RefVal::ErrorLeakReturned) { // FIXME: Per comments in rdar://6320065, "create" only applies to CF @@ -2855,6 +2857,7 @@ void RetainCountChecker::checkSummary(const RetainSummary &Summ, // Consult the summary for the return value. RetEffect RE = Summ.getRetEffect(); + assert(CallOrMsg.getOriginExpr()); if (RE.getKind() == RetEffect::OwnedWhenTrackedReceiver) { if (ReceiverIsTracked)