diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-01-30 21:40:37 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-01-30 21:40:37 +0000 |
commit | f2bda69cd26be3a63f2537a3c5965274d8b61356 (patch) | |
tree | 6602f7ca8c3b2d254e13aec5bdbfd40c11556939 /clang/test/CodeGenObjC/arc.m | |
parent | cf2c65aa8ee41e42fb77d35d3d2f81c79d79cf45 (diff) | |
download | bcm5719-llvm-f2bda69cd26be3a63f2537a3c5965274d8b61356.tar.gz bcm5719-llvm-f2bda69cd26be3a63f2537a3c5965274d8b61356.zip |
objc-arc: Perform null check on receiver before sending methods which
consume one or more of their arguments. If not done, this will cause a leak
as method will not consume the argument when receiver is null.
In this patch, the null path releases consumed argument.
// rdar://10444474
llvm-svn: 149279
Diffstat (limited to 'clang/test/CodeGenObjC/arc.m')
-rw-r--r-- | clang/test/CodeGenObjC/arc.m | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/test/CodeGenObjC/arc.m b/clang/test/CodeGenObjC/arc.m index c5ffb187312..97abb472437 100644 --- a/clang/test/CodeGenObjC/arc.m +++ b/clang/test/CodeGenObjC/arc.m @@ -1489,8 +1489,13 @@ void test66(void) { // CHECK-NEXT: [[T5:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T4]]) // CHECK-NEXT: [[T6:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES // CHECK-NEXT: [[T7:%.*]] = bitcast [[TEST66]]* [[T3]] to i8* -// CHECK-NEXT: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*)*)(i8* [[T7]], i8* [[T6]], i8* [[T5]]) -// CHECK-NEXT: [[T8:%.*]] = bitcast [[TEST66]]* [[T3]] to i8* +// CHECK-NEXT: [[SIX:%.*]] = icmp eq i8* [[T7]], null +// CHECK-NEXT: br i1 [[SIX]], label [[NULINIT:%.*]], label [[CALL:%.*]] +// CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*)*)(i8* [[T7]], i8* [[T6]], i8* [[T5]]) +// CHECK-NEXT: br label [[CONT:%.*]] +// CHECK: call void @objc_release(i8* [[T5]]) nounwind +// CHECK-NEXT: br label [[CONT:%.*]] +// CHECK: [[T8:%.*]] = bitcast [[TEST66]]* [[T3]] to i8* // CHECK-NEXT: call void @objc_release(i8* [[T8]]) // CHECK-NEXT: ret void |