From: Ted Kremenek Date: Sat, 9 May 2009 00:44:07 +0000 (+0000) Subject: More hacking on autorelease errors. We now can emit basic errors (disabled for X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=80c24182549f45b9b3aa1cec1e547e8c4c09179b;p=clang More hacking on autorelease errors. We now can emit basic errors (disabled for now until ready). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71303 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp index e45b3b37f8..c8d0bf78ae 100644 --- a/lib/Analysis/CFRefCount.cpp +++ b/lib/Analysis/CFRefCount.cpp @@ -179,7 +179,7 @@ public: Pred); assert(ENB); - return ENB->MakeNode(state, Pred); + return ENB->generateNode(state, Pred); } }; } // end anonymous namespace @@ -1552,6 +1552,10 @@ void RefVal::print(std::ostream& Out) const { case ErrorReleaseNotOwned: Out << "Release of Not-Owned [ERROR]"; break; + + case RefVal::ErrorOverAutorelease: + Out << "Over autoreleased"; + break; } if (ACnt) { @@ -3185,8 +3189,14 @@ CFRefCount::HandleAutoreleaseCounts(GRStateRef state, GenericNodeBuilder Bd, unsigned Cnt = V.getCount(); if (ACnt <= Cnt) { - V.setCount(Cnt - ACnt); - V.setAutoreleaseCount(0); + if (ACnt == Cnt) { + V.clearCounts(); + V = V ^ RefVal::NotOwned; + } + else { + V.setCount(Cnt - ACnt); + V.setAutoreleaseCount(0); + } state = state.set(Sym, V); ExplodedNode *N = Bd.MakeNode(state, Pred); stop = (N == 0); @@ -3200,6 +3210,7 @@ CFRefCount::HandleAutoreleaseCounts(GRStateRef state, GenericNodeBuilder Bd, state = state.set(Sym, V); if (ExplodedNode *N = Bd.MakeNode(state, Pred)) { + N->markAsSink(); CFRefReport *report = new CFRefReport(*static_cast(overAutorelease), *this, N, Sym); diff --git a/lib/Analysis/GRCoreEngine.cpp b/lib/Analysis/GRCoreEngine.cpp index c75fd9ace1..ff7b548bc0 100644 --- a/lib/Analysis/GRCoreEngine.cpp +++ b/lib/Analysis/GRCoreEngine.cpp @@ -568,7 +568,6 @@ GREndPathNodeBuilderImpl::generateNodeImpl(const void* State, Node->addPredecessor(P ? P : Pred); if (IsNew) { - Node->markAsSink(); Eng.G->addEndOfPath(Node); return Node; }