summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Analysis/CFRefCount.cpp9
-rw-r--r--clang/test/Analysis/retain-release.m24
2 files changed, 28 insertions, 5 deletions
diff --git a/clang/lib/Analysis/CFRefCount.cpp b/clang/lib/Analysis/CFRefCount.cpp
index 0e4d660f35a..a9ef5cf3fcf 100644
--- a/clang/lib/Analysis/CFRefCount.cpp
+++ b/clang/lib/Analysis/CFRefCount.cpp
@@ -175,8 +175,7 @@ public:
ExplodedNode<GRState> *MakeNode(const GRState *state,
ExplodedNode<GRState> *Pred) {
if (SNB)
- return SNB->generateNode(PostStmt(S, tag), state,
- Pred);
+ return SNB->generateNode(PostStmt(S, tag), state, Pred);
assert(ENB);
return ENB->generateNode(state, Pred);
@@ -3111,6 +3110,7 @@ GRStateRef CFRefCount::Update(GRStateRef state, SymbolRef sym,
// Update the autorelease counts.
state = SendAutorelease(state, ARCountFactory, sym);
V = V.autorelease();
+ break;
case StopTracking:
return state.remove<RefBindings>(sym);
@@ -3245,7 +3245,7 @@ CFRefCount::ProcessLeaks(GRStateRef state,
return Pred;
// Generate an intermediate node representing the leak point.
- ExplodedNode<GRState> *N = Builder.MakeNode(state, Pred);
+ ExplodedNode<GRState> *N = Builder.MakeNode(state, Pred);
if (N) {
for (llvm::SmallVectorImpl<SymbolRef>::iterator
@@ -3354,7 +3354,8 @@ void CFRefCount::ProcessNonLeakError(ExplodedNodeSet<GRState>& Dst,
Builder.BuildSinks = true;
GRExprEngine::NodeTy* N = Builder.MakeNode(Dst, NodeExpr, Pred, St);
- if (!N) return;
+ if (!N)
+ return;
CFRefBug *BT = 0;
diff --git a/clang/test/Analysis/retain-release.m b/clang/test/Analysis/retain-release.m
index de86dbc2898..49fd98b3b7e 100644
--- a/clang/test/Analysis/retain-release.m
+++ b/clang/test/Analysis/retain-release.m
@@ -284,10 +284,32 @@ void f12() {
}
void f13_autorelease() {
- CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
[(id) A autorelease]; // no-warning
}
+void f13_autorelease_b() {
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
+ [(id) A autorelease];
+ [(id) A autorelease]; // expected-warning{{Object will be sent more -release messages from its containing autorelease pools than it has retain counts}}
+}
+
+CFMutableArrayRef f13_autorelease_c() {
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
+ [(id) A autorelease];
+ [(id) A autorelease];
+ return A; // expected-warning{{Object will be sent more -release messages from its containing autorelease pools than it has retain counts}}
+}
+
+CFMutableArrayRef f13_autorelease_d() {
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
+ [(id) A autorelease];
+ [(id) A autorelease];
+ CFMutableArrayRef B = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{Object will be sent more -release messages}}
+ CFRelease(B); // no-warning
+}
+
+
// This case exercises the logic where the leak site is the same as the allocation site.
void f14_leakimmediately() {
CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{leak}}
OpenPOWER on IntegriCloud