[cfe-commits] r165124 - /cfe/trunk/test/Analysis/inlining/InlineObjCInstanceMethod.m
Jordan Rose
jordan_rose at apple.com
Wed Oct 3 09:00:32 PDT 2012
Author: jrose
Date: Wed Oct 3 11:00:32 2012
New Revision: 165124
URL: http://llvm.org/viewvc/llvm-project?rev=165124&view=rev
Log:
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.
Modified:
cfe/trunk/test/Analysis/inlining/InlineObjCInstanceMethod.m
Modified: cfe/trunk/test/Analysis/inlining/InlineObjCInstanceMethod.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inlining/InlineObjCInstanceMethod.m?rev=165124&r1=165123&r2=165124&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/inlining/InlineObjCInstanceMethod.m (original)
+++ cfe/trunk/test/Analysis/inlining/InlineObjCInstanceMethod.m Wed Oct 3 11:00:32 2012
@@ -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];
}
+
+
+ at interface EvilChild : MyParent
+- (id)getInt;
+ at end
+
+ at implementation EvilChild
+- (id)getInt { // expected-warning {{types are incompatible}}
+ return self;
+}
+ at 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
+}
More information about the cfe-commits
mailing list