diff options
author | Anna Zaks <ganna@apple.com> | 2012-08-06 23:25:45 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-08-06 23:25:45 +0000 |
commit | 05253782a48d82cbcefba4ff1744fbf5eb6923bf (patch) | |
tree | 30e8da2c016cfe8bb0bac8745dd31554f6c67d8c /clang/test | |
parent | 472dbcf15673dc67d03b463845635784f41847a2 (diff) | |
download | bcm5719-llvm-05253782a48d82cbcefba4ff1744fbf5eb6923bf.tar.gz bcm5719-llvm-05253782a48d82cbcefba4ff1744fbf5eb6923bf.zip |
[analyzer] Dynamic type info - propagate through implicit casts.
I currently have a bit of redundancy with the cast kind switch statement
inside the ImplicitCast callback, but I might be adding more casts going
forward.
llvm-svn: 161358
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/Analysis/inlining/ObjCDynTypePopagation.m | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/clang/test/Analysis/inlining/ObjCDynTypePopagation.m b/clang/test/Analysis/inlining/ObjCDynTypePopagation.m index 89c05c9c567..425903242dc 100644 --- a/clang/test/Analysis/inlining/ObjCDynTypePopagation.m +++ b/clang/test/Analysis/inlining/ObjCDynTypePopagation.m @@ -41,8 +41,8 @@ MyClass *getObj(); /* Test that we get the right type from call to alloc. */ + (void) testAllocSelf { - id a = [self alloc]; - clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}} + id a = [self alloc]; + clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}} } @@ -68,8 +68,26 @@ MyClass *getObj(); } + (void) testNewSelf { - id a = [self new]; - clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}} + id a = [self new]; + clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}} +} + +// Casting to parent should not pessimize the dynamic type. ++ (void) testCastToParent { + id a = [[self alloc] init]; + MyParent *p = a; + clang_analyzer_eval([p getZeroOverridden] == 0); // expected-warning{{TRUE}} +} + +// The type of parameter gets used. ++ (void)testTypeFromParam:(MyParent*) p { + clang_analyzer_eval([p getZero] == 0); // expected-warning{{TRUE}} +} + +// Test implisit cast. ++ (void) testCastFromId:(id) a { + MyParent *p = a; + clang_analyzer_eval([p getZero] == 0); // expected-warning{{TRUE}} } @end
\ No newline at end of file |