Skip to content

Commit ef77a87

Browse files
committed
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. llvm-svn: 165124
1 parent 35fcb54 commit ef77a87

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

clang/test/Analysis/inlining/InlineObjCInstanceMethod.m

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang --analyze -Xanalyzer -analyzer-checker=core -Xclang -verify %s
1+
// RUN: %clang --analyze -Xanalyzer -analyzer-checker=osx.cocoa.IncompatibleMethodTypes -Xclang -verify %s
22

33
#include "InlineObjCInstanceMethod.h"
44

@@ -84,3 +84,28 @@ - (int) method2 {
8484
void randomlyMessageAnObject(MyClass *arr[], int i) {
8585
(void)[arr[i] getInt];
8686
}
87+
88+
89+
@interface EvilChild : MyParent
90+
- (id)getInt;
91+
@end
92+
93+
@implementation EvilChild
94+
- (id)getInt { // expected-warning {{types are incompatible}}
95+
return self;
96+
}
97+
@end
98+
99+
int testNonCovariantReturnType() {
100+
MyParent *obj = [[EvilChild alloc] init];
101+
102+
// Devirtualization allows us to directly call -[EvilChild getInt], but
103+
// that returns an id, not an int. There is an off-by-default warning for
104+
// this, -Woverriding-method-mismatch, and an on-by-default analyzer warning,
105+
// osx.cocoa.IncompatibleMethodTypes. This code would probably crash at
106+
// runtime, but at least the analyzer shouldn't crash.
107+
int x = 1 + [obj getInt];
108+
109+
[obj release];
110+
return 5/(x-1); // no-warning
111+
}

0 commit comments

Comments
 (0)