From: Gabor Horvath Date: Tue, 15 Sep 2015 23:14:01 +0000 (+0000) Subject: [Static Analyzer] Added an XFAIL test for inlining when the type inference involves... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=456f4accdf36f689b7faed5c7a1c40f8d4931037;p=clang [Static Analyzer] Added an XFAIL test for inlining when the type inference involves generic types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247739 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Analysis/DynamicTypePropagation.m b/test/Analysis/DynamicTypePropagation.m new file mode 100644 index 0000000000..7db866044e --- /dev/null +++ b/test/Analysis/DynamicTypePropagation.m @@ -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; + +@protocol NSCopying +@end + +__attribute__((objc_root_class)) +@interface NSObject +- (void) myFunction:(int*)p myParam:(int) n; +@end + +@interface MyType : NSObject +- (void) myFunction:(int*)p myParam:(int) n; +@end + +@interface NSArray : NSObject +- (BOOL)contains:(ObjectType)obj; +- (ObjectType)getObjAtIndex:(NSUInteger)idx; +- (ObjectType)objectAtIndexedSubscript:(NSUInteger)idx; +@property(readonly) ObjectType firstObject; +@end + +@implementation NSObject +- (void) myFunction:(int*)p myParam:(int) n { + (void)*p;// no warning +} +@end + +@implementation MyType +- (void) myFunction:(int*)p myParam:(int) n { + int i = 5/n; // expected-warning {{}} + (void)i; +} +@end + +void testReturnType(NSArray *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 *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 ]; +}