]> granicus.if.org Git - clang/commitdiff
More hacking on autorelease errors. We now can emit basic errors (disabled for
authorTed Kremenek <kremenek@apple.com>
Sat, 9 May 2009 00:44:07 +0000 (00:44 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 9 May 2009 00:44:07 +0000 (00:44 +0000)
now until ready).

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

lib/Analysis/CFRefCount.cpp
lib/Analysis/GRCoreEngine.cpp

index e45b3b37f8a916e042947dc6a64de908597eaf10..c8d0bf78ae3cccc2d39469398140e916f4cb9f12 100644 (file)
@@ -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<RefBindings>(Sym, V);
     ExplodedNode<GRState> *N = Bd.MakeNode(state, Pred);
     stop = (N == 0);
@@ -3200,6 +3210,7 @@ CFRefCount::HandleAutoreleaseCounts(GRStateRef state, GenericNodeBuilder Bd,
   state = state.set<RefBindings>(Sym, V);
 
   if (ExplodedNode<GRState> *N = Bd.MakeNode(state, Pred)) {
+    N->markAsSink();
     CFRefReport *report =
       new CFRefReport(*static_cast<CFRefBug*>(overAutorelease),
                       *this, N, Sym);
index c75fd9ace1b7ffba7743411ac7a10508425e9133..ff7b548bc054f0703a425c726510abd2a4b39704 100644 (file)
@@ -568,7 +568,6 @@ GREndPathNodeBuilderImpl::generateNodeImpl(const void* State,
   Node->addPredecessor(P ? P : Pred);
   
   if (IsNew) {
-    Node->markAsSink();
     Eng.G->addEndOfPath(Node);
     return Node;
   }