[cfe-commits] r48234 - /cfe/trunk/Analysis/CFRefCount.cpp
Ted Kremenek
kremenek at apple.com
Tue Mar 11 11:14:11 PDT 2008
Author: kremenek
Date: Tue Mar 11 13:14:09 2008
New Revision: 48234
URL: http://llvm.org/viewvc/llvm-project?rev=48234&view=rev
Log:
Added bookkeeping of error nodes.
Modified:
cfe/trunk/Analysis/CFRefCount.cpp
Modified: cfe/trunk/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/CFRefCount.cpp?rev=48234&r1=48233&r2=48234&view=diff
==============================================================================
--- cfe/trunk/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/Analysis/CFRefCount.cpp Tue Mar 11 13:14:09 2008
@@ -182,6 +182,8 @@
return Data >> 3;
}
+ static bool isError(Kind k) { return k >= ErrorUseAfterRelease; }
+
static RefVal makeOwned(unsigned Count) { return RefVal(Owned, Count); }
static RefVal makeAcqOwned(unsigned Count) { return RefVal(AcqOwned, Count); }
static RefVal makeNotOwned() { return RefVal(NotOwned); }
@@ -197,9 +199,16 @@
class CFRefCount : public GRSimpleVals {
typedef llvm::ImmutableMap<SymbolID, RefVal> RefBindings;
typedef RefBindings::Factory RefBFactoryTy;
-
+
+ typedef llvm::SmallPtrSet<GRExprEngine::NodeTy*,2> UseAfterReleasesTy;
+ typedef llvm::SmallPtrSet<GRExprEngine::NodeTy*,2> ReleasesNotOwnedTy;
+
CFRefSummaryManager Summaries;
RefBFactoryTy RefBFactory;
+
+ UseAfterReleasesTy UseAfterReleases;
+ ReleasesNotOwnedTy ReleasesNotOwned;
+
static RefBindings GetRefBindings(ValueState& StImpl) {
return RefBindings((RefBindings::TreeTy*) StImpl.CheckerState);
@@ -214,7 +223,7 @@
}
RefBindings Update(RefBindings B, SymbolID sym, RefVal V, ArgEffect E,
- bool& hasError);
+ RefVal::Kind& hasError);
public:
CFRefCount() {}
@@ -258,7 +267,7 @@
// Evaluate the effects of the call.
ValueState StVals = *St;
- bool hasError = false;
+ RefVal::Kind hasError = (RefVal::Kind) 0;
if (!Summ) {
@@ -310,16 +319,31 @@
St = StateMgr.getPersistentState(StVals);
if (hasError) {
-
+ GRExprEngine::NodeTy* N = Builder.generateNode(CE, St, Pred);
+
+ if (N) {
+ N->markAsSink();
+
+ switch (hasError) {
+ default: assert(false);
+ case RefVal::ErrorUseAfterRelease:
+ UseAfterReleases.insert(N);
+ break;
+
+ case RefVal::ErrorReleaseNotOwned:
+ ReleasesNotOwned.insert(N);
+ break;
+ }
+ }
}
-
- Builder.Nodify(Dst, CE, Pred, St);
+ else
+ Builder.Nodify(Dst, CE, Pred, St);
}
CFRefCount::RefBindings CFRefCount::Update(RefBindings B, SymbolID sym,
RefVal V, ArgEffect E,
- bool& hasError) {
+ RefVal::Kind& hasError) {
// FIXME: This dispatch can potentially be sped up by unifiying it into
// a single switch statement. Opt for simplicity for now.
@@ -348,8 +372,8 @@
break;
case RefVal::Released:
- hasError = true;
V = RefVal::makeUseAfterRelease();
+ hasError = V.getKind();
break;
}
@@ -371,13 +395,13 @@
}
case RefVal::NotOwned:
- hasError = true;
V = RefVal::makeReleaseNotOwned();
+ hasError = V.getKind();
break;
case RefVal::Released:
- hasError = true;
V = RefVal::makeUseAfterRelease();
+ hasError = V.getKind();
break;
}
}
More information about the cfe-commits
mailing list