summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/CFRefCount.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-05-10 16:52:15 +0000
committerTed Kremenek <kremenek@apple.com>2009-05-10 16:52:15 +0000
commit1f8e4346fac477398c2443cbe7c0289b038db2d0 (patch)
treec8ca280a3bd1f05b43e13a50b86c26b8e0260a2f /clang/lib/Analysis/CFRefCount.cpp
parent004192bde38e58e2fa08ae610b24667b5bf52c8e (diff)
downloadbcm5719-llvm-1f8e4346fac477398c2443cbe7c0289b038db2d0.tar.gz
bcm5719-llvm-1f8e4346fac477398c2443cbe7c0289b038db2d0.zip
Add special warning about returning a retained object where a GC'ed object is expected.
llvm-svn: 71397
Diffstat (limited to 'clang/lib/Analysis/CFRefCount.cpp')
-rw-r--r--clang/lib/Analysis/CFRefCount.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/Analysis/CFRefCount.cpp b/clang/lib/Analysis/CFRefCount.cpp
index 2715a9633f2..4b254e07d59 100644
--- a/clang/lib/Analysis/CFRefCount.cpp
+++ b/clang/lib/Analysis/CFRefCount.cpp
@@ -2517,9 +2517,10 @@ CFRefLeakReport::getEndPath(BugReporterContext& BRC,
else if (RV->getKind() == RefVal::ErrorGCLeakReturned) {
ObjCMethodDecl& MD = cast<ObjCMethodDecl>(BRC.getCodeDecl());
os << " and returned from method '" << MD.getSelector().getAsString()
- << "' is potentially leaked when using garbage collection. Callers"
- " of this method do not expect a +1 retain count since the return"
- " type is an Objective-C object reference";
+ << "' is potentially leaked when using garbage collection. Callers "
+ "of this method do not expect a returned object with a +1 retain "
+ "count since they expect the object to be managed by the garbage "
+ "collector";
}
else
os << " is no longer referenced after this point and has a retain count of"
@@ -3073,11 +3074,12 @@ void CFRefCount::EvalReturn(ExplodedNodeSet<GRState>& Dst,
if (isGCEnabled() && RE.getObjKind() == RetEffect::ObjC) {
// Things are more complicated with garbage collection. If the
// returned object is suppose to be an Objective-C object, we have
- // a leak (as the caller expects a GC'ed object).
+ // a leak (as the caller expects a GC'ed object) because no
+ // method should return ownership unless it returns a CF object.
X = X ^ RefVal::ErrorGCLeakReturned;
// Keep this false until this is properly tested.
- hasError = false;
+ hasError = true;
}
else if (!RE.isOwned()) {
// Either we are using GC and the returned object is a CF type
OpenPOWER on IntegriCloud