From b045b01840455aad8781c6ec82b073c432e3fc06 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 12 Oct 2012 22:56:40 +0000 Subject: [PATCH] Silence null dereference warnings by documenting context-specific invariants using assertions. llvm-svn: 165840 --- clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp index 3338c47..c84365e 100644 --- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ b/clang/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) -- 2.7.4