]> granicus.if.org Git - clang/commitdiff
Silence null dereference warnings by documenting context-specific
authorTed Kremenek <kremenek@apple.com>
Fri, 12 Oct 2012 22:56:40 +0000 (22:56 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 12 Oct 2012 22:56:40 +0000 (22:56 +0000)
invariants using assertions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165840 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp

index 3338c479be2c743afe7240ec285c0c9f70deafb2..c84365e4a9ee655e8e8b4d0b1a60ecd342bdb9dd 100644 (file)
@@ -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)