r247739 - [Static Analyzer] Added an XFAIL test for inlining when the type inference involves generic types.
Gabor Horvath via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 15 16:14:01 PDT 2015
Author: xazax
Date: Tue Sep 15 18:14:01 2015
New Revision: 247739
URL: http://llvm.org/viewvc/llvm-project?rev=247739&view=rev
Log:
[Static Analyzer] Added an XFAIL test for inlining when the type inference involves generic types.
Added:
cfe/trunk/test/Analysis/DynamicTypePropagation.m
Added: cfe/trunk/test/Analysis/DynamicTypePropagation.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/DynamicTypePropagation.m?rev=247739&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/DynamicTypePropagation.m (added)
+++ cfe/trunk/test/Analysis/DynamicTypePropagation.m Tue Sep 15 18:14:01 2015
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.osx.cocoa.ObjCGenerics -verify %s
+// XFAIL: *
+
+#if !__has_feature(objc_generics)
+# error Compiler does not support Objective-C generics?
+#endif
+
+#define nil 0
+typedef unsigned long NSUInteger;
+typedef int BOOL;
+
+ at protocol NSCopying
+ at end
+
+__attribute__((objc_root_class))
+ at interface NSObject
+- (void) myFunction:(int*)p myParam:(int) n;
+ at end
+
+ at interface MyType : NSObject <NSCopying>
+- (void) myFunction:(int*)p myParam:(int) n;
+ at end
+
+ at interface NSArray<ObjectType> : NSObject
+- (BOOL)contains:(ObjectType)obj;
+- (ObjectType)getObjAtIndex:(NSUInteger)idx;
+- (ObjectType)objectAtIndexedSubscript:(NSUInteger)idx;
+ at property(readonly) ObjectType firstObject;
+ at end
+
+ at implementation NSObject
+- (void) myFunction:(int*)p myParam:(int) n {
+ (void)*p;// no warning
+}
+ at end
+
+ at implementation MyType
+- (void) myFunction:(int*)p myParam:(int) n {
+ int i = 5/n; // expected-warning {{}}
+ (void)i;
+}
+ at end
+
+void testReturnType(NSArray<MyType *> *arr) {
+ NSArray *erased = arr;
+ NSObject *element = [erased firstObject];
+ // TODO: myFunction currently dispatches to NSObject. Make it dispatch to
+ // MyType instead!
+ [element myFunction:0 myParam:0 ];
+}
+
+void testArgument(NSArray<MyType *> *arr, id element) {
+ NSArray *erased = arr;
+ [erased contains: element];
+ // TODO: myFunction currently is not dispatched to MyType. Make it dispatch to
+ // MyType!
+ [element myFunction:0 myParam:0 ];
+}
More information about the cfe-commits
mailing list