summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorDevin Coughlin <dcoughlin@apple.com>2016-04-08 19:59:16 +0000
committerDevin Coughlin <dcoughlin@apple.com>2016-04-08 19:59:16 +0000
commitebaa56bb263b56ee47d3492d7e32fe1db639b155 (patch)
treec50ac14344c5bb258b41c689d30ede262390ebf3 /clang/test
parentfe1bc708b53016d0800b54342b268c09b8c52a6f (diff)
downloadbcm5719-llvm-ebaa56bb263b56ee47d3492d7e32fe1db639b155.tar.gz
bcm5719-llvm-ebaa56bb263b56ee47d3492d7e32fe1db639b155.zip
[analyzer] Teach trackNullOrUndefValue about calls to property accessors.
Teach trackNullOrUndefValue() how to look through PseudoObjectExprs to find the underlying method call for property getters. This makes over-suppression of 'return nil' in getters consistent with the similar over-suppression for method and function calls. rdar://problem/24437252 llvm-svn: 265839
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Analysis/inlining/false-positive-suppression.m36
1 files changed, 36 insertions, 0 deletions
diff --git a/clang/test/Analysis/inlining/false-positive-suppression.m b/clang/test/Analysis/inlining/false-positive-suppression.m
index 53ec138367e..7be1cb8472f 100644
--- a/clang/test/Analysis/inlining/false-positive-suppression.m
+++ b/clang/test/Analysis/inlining/false-positive-suppression.m
@@ -36,3 +36,39 @@ void testNilReceiver(int coin) {
else
testNilReceiverHelperB([[x getObject] getPtr]);
}
+
+// FALSE NEGATIVES (over-suppression)
+
+__attribute__((objc_root_class))
+@interface SomeClass
+-(int *)methodReturningNull;
+
+@property(readonly) int *propertyReturningNull;
+
+@end
+
+@implementation SomeClass
+-(int *)methodReturningNull {
+ return 0;
+}
+
+-(int *)propertyReturningNull {
+ return 0;
+}
+@end
+
+void testMethodReturningNull(SomeClass *sc) {
+ int *result = [sc methodReturningNull];
+ *result = 1;
+#ifndef SUPPRESSED
+ // expected-warning@-2 {{Dereference of null pointer}}
+#endif
+}
+
+void testPropertyReturningNull(SomeClass *sc) {
+ int *result = sc.propertyReturningNull;
+ *result = 1;
+#ifndef SUPPRESSED
+ // expected-warning@-2 {{Dereference of null pointer}}
+#endif
+}
OpenPOWER on IntegriCloud