[cfe-commits] r49564 - /cfe/trunk/lib/Analysis/CFRefCount.cpp
Ted Kremenek
kremenek at apple.com
Fri Apr 11 15:25:11 PDT 2008
Author: kremenek
Date: Fri Apr 11 17:25:11 2008
New Revision: 49564
URL: http://llvm.org/viewvc/llvm-project?rev=49564&view=rev
Log:
Add some boilerplate to report memory leaks at the end of an analyzed function.
Still need some boilerplate in BugReporter to report bugs at the end
of a function (not associated with a particular statement).
Modified:
cfe/trunk/lib/Analysis/CFRefCount.cpp
Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=49564&r1=49563&r2=49564&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Fri Apr 11 17:25:11 2008
@@ -63,7 +63,7 @@
assert(getKind() == Alias);
return Data >> 2;
}
-
+
static RetEffect MakeAlias(unsigned Idx) { return RetEffect(Alias, Idx); }
static RetEffect MakeOwned() { return RetEffect(OwnedSymbol, 0); }
@@ -485,6 +485,10 @@
static bool isError(Kind k) { return k >= ErrorUseAfterRelease; }
+ bool isOwned() const {
+ return getKind() == Owned;
+ }
+
static RefVal makeOwned(unsigned Count = 0) {
return RefVal(Owned, Count);
}
@@ -596,6 +600,11 @@
CallExpr* CE, LVal L,
ExplodedNode<ValueState>* Pred);
+ // End-of-path.
+
+ virtual void EvalEndPath(GRExprEngine& Engine,
+ GREndPathNodeBuilder<ValueState>& Builder);
+
// Error iterators.
typedef UseAfterReleasesTy::iterator use_after_iterator;
@@ -795,6 +804,25 @@
Builder.MakeNode(Dst, CE, Pred, St);
}
+// End-of-path.
+
+void CFRefCount::EvalEndPath(GRExprEngine& Engine,
+ GREndPathNodeBuilder<ValueState>& Builder) {
+
+ RefBindings B = GetRefBindings(*Builder.getState());
+
+ // Scan the set of bindings for symbols that are in the Owned state.
+
+ for (RefBindings::iterator I = B.begin(), E = B.end(); I != E; ++I)
+ if ((*I).second.isOwned()) {
+
+ // FIXME: Register an error with the diagnostic engine. Since we
+ // don't have a Stmt* here, we need some extra machinery to get
+ // a sourcelocation.
+
+ }
+}
+
CFRefCount::RefBindings CFRefCount::Update(RefBindings B, SymbolID sym,
RefVal V, ArgEffect E,
More information about the cfe-commits
mailing list