diff options
author | Devin Coughlin <dcoughlin@apple.com> | 2016-01-26 23:58:48 +0000 |
---|---|---|
committer | Devin Coughlin <dcoughlin@apple.com> | 2016-01-26 23:58:48 +0000 |
commit | 609444fdf26450fc530f2fcc72b2c1a743e03bfd (patch) | |
tree | a25a1134a85e407ac9b7b5adbad27a376a7bff61 /test | |
parent | 8379dbf80c66539b0fbd09752b38348d17065b2f (diff) | |
download | clang-609444fdf26450fc530f2fcc72b2c1a743e03bfd.tar.gz |
[analyzer] Body farm: Look for property ivar in shadowing readwrite property.
After r251874, readonly properties that are shadowed by a readwrite property
in a class extension no longer have an instance variable, which caused the body
farm to not synthesize getters. Now, if a readonly property does not have an
instance variable look for a shadowing property and try to get the instance
variable from there.
rdar://problem/24060091
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258886 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Analysis/properties.m | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/Analysis/properties.m b/test/Analysis/properties.m index bf9424c8c2..4fdbb69d87 100644 --- a/test/Analysis/properties.m +++ b/test/Analysis/properties.m @@ -211,6 +211,33 @@ void testConsistencyAssign(Person *p) { clang_analyzer_eval(p.friend == origFriend); // expected-warning{{UNKNOWN}} } +@interface ClassWithShadowedReadWriteProperty { + int _f; +} +@property (readonly) int someProp; +@end + +@interface ClassWithShadowedReadWriteProperty () +@property (readwrite) int someProp; +@end + +@implementation ClassWithShadowedReadWriteProperty +- (void)testSynthesisForShadowedReadWriteProperties; { + clang_analyzer_eval(self.someProp == self.someProp); // expected-warning{{TRUE}} + + _f = 1; + + // Read of shadowed property should not invalidate receiver. + (void)self.someProp; + clang_analyzer_eval(_f == 1); // expected-warning{{TRUE}} + + _f = 2; + // Call to getter of shadowed property should not invalidate receiver. + (void)[self someProp]; + clang_analyzer_eval(_f == 2); // expected-warning{{TRUE}} +} +@end + #if !__has_feature(objc_arc) void testOverrelease(Person *p, int coin) { switch (coin) { |