summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/CFRefCount.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-04-11 22:25:11 +0000
committerTed Kremenek <kremenek@apple.com>2008-04-11 22:25:11 +0000
commit8784a7c006b9b2bad02aef54f64ee2875daeb145 (patch)
treeacfcd103c51a96310bee67cdef3a7e337fadb3b4 /clang/lib/Analysis/CFRefCount.cpp
parentbc888b47b98fcc91c600060d05031d2bd2edd7c1 (diff)
downloadbcm5719-llvm-8784a7c006b9b2bad02aef54f64ee2875daeb145.tar.gz
bcm5719-llvm-8784a7c006b9b2bad02aef54f64ee2875daeb145.zip
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). llvm-svn: 49564
Diffstat (limited to 'clang/lib/Analysis/CFRefCount.cpp')
-rw-r--r--clang/lib/Analysis/CFRefCount.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/clang/lib/Analysis/CFRefCount.cpp b/clang/lib/Analysis/CFRefCount.cpp
index 27812f5a74d..ff78fd749ec 100644
--- a/clang/lib/Analysis/CFRefCount.cpp
+++ b/clang/lib/Analysis/CFRefCount.cpp
@@ -63,7 +63,7 @@ public:
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 @@ public:
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 @@ public:
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 @@ void CFRefCount::EvalCall(ExplodedNodeSet<ValueState>& Dst,
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,
OpenPOWER on IntegriCloud