aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-10-03 16:00:32 +0000
committerJordan Rose <jordan_rose@apple.com>2012-10-03 16:00:32 +0000
commitff63227817217cd33c587e054d4892285b8e00c6 (patch)
tree438942ac9d1bb2844557ef6dcae1fb450ffbdb3d
parent1215057517e16814ee50c91d4d5d3a174b670ff0 (diff)
Revert "InlineObjCInstanceMethod.m: Remove lines introduced in r165079."
...and fix the run line so that the expected warnings are the same on all platforms. This reverts r165088 / d09074f0ca06626914108f1c0d4e70adeb851e01. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165124 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/Analysis/inlining/InlineObjCInstanceMethod.m27
1 files changed, 26 insertions, 1 deletions
diff --git a/test/Analysis/inlining/InlineObjCInstanceMethod.m b/test/Analysis/inlining/InlineObjCInstanceMethod.m
index 48556dcd49..21ce8576a4 100644
--- a/test/Analysis/inlining/InlineObjCInstanceMethod.m
+++ b/test/Analysis/inlining/InlineObjCInstanceMethod.m
@@ -1,4 +1,4 @@
-// RUN: %clang --analyze -Xanalyzer -analyzer-checker=core -Xclang -verify %s
+// RUN: %clang --analyze -Xanalyzer -analyzer-checker=osx.cocoa.IncompatibleMethodTypes -Xclang -verify %s
#include "InlineObjCInstanceMethod.h"
@@ -84,3 +84,28 @@
void randomlyMessageAnObject(MyClass *arr[], int i) {
(void)[arr[i] getInt];
}
+
+
+@interface EvilChild : MyParent
+- (id)getInt;
+@end
+
+@implementation EvilChild
+- (id)getInt { // expected-warning {{types are incompatible}}
+ return self;
+}
+@end
+
+int testNonCovariantReturnType() {
+ MyParent *obj = [[EvilChild alloc] init];
+
+ // Devirtualization allows us to directly call -[EvilChild getInt], but
+ // that returns an id, not an int. There is an off-by-default warning for
+ // this, -Woverriding-method-mismatch, and an on-by-default analyzer warning,
+ // osx.cocoa.IncompatibleMethodTypes. This code would probably crash at
+ // runtime, but at least the analyzer shouldn't crash.
+ int x = 1 + [obj getInt];
+
+ [obj release];
+ return 5/(x-1); // no-warning
+}