diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2016-03-22 05:00:21 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2016-03-22 05:00:21 +0000 |
commit | 7e2c82da90e9a47de674f0dc518af8deac4946d6 (patch) | |
tree | 471897475e2682633ce04dbee18165acdcb32a04 | |
parent | 5ac1a47cadd81fc80a8c166567058ccab009ceef (diff) | |
download | bcm5719-llvm-7e2c82da90e9a47de674f0dc518af8deac4946d6.tar.gz bcm5719-llvm-7e2c82da90e9a47de674f0dc518af8deac4946d6.zip |
[Objective-c] Do not set IsExact to true when the receiver is a class.
IsExact shouldn't be set to true in WeakObjectProfileTy::getBaseInfo
when the receiver is a class because having a class as the receiver
doesn't guarantee that the Base is exact.
This is a follow-up to r263818.
rdar://problem/25208167
llvm-svn: 264025
-rw-r--r-- | clang/include/clang/Sema/ScopeInfo.h | 1 | ||||
-rw-r--r-- | clang/lib/Sema/ScopeInfo.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaObjC/arc-repeated-weak.mm | 11 |
3 files changed, 13 insertions, 3 deletions
diff --git a/clang/include/clang/Sema/ScopeInfo.h b/clang/include/clang/Sema/ScopeInfo.h index 0ec59cd3806..c57a59db8ec 100644 --- a/clang/include/clang/Sema/ScopeInfo.h +++ b/clang/include/clang/Sema/ScopeInfo.h @@ -189,6 +189,7 @@ public: /// [self foo].prop | 0 (unknown) | prop (ObjCPropertyDecl) /// self.prop1.prop2 | prop1 (ObjCPropertyDecl) | prop2 (ObjCPropertyDecl) /// MyClass.prop | MyClass (ObjCInterfaceDecl) | -prop (ObjCMethodDecl) + /// MyClass.foo.prop | +foo (ObjCMethodDecl) | -prop (ObjCPropertyDecl) /// weakVar | 0 (known) | weakVar (VarDecl) /// self->weakIvar | self (VarDecl) | weakIvar (ObjCIvarDecl) /// diff --git a/clang/lib/Sema/ScopeInfo.cpp b/clang/lib/Sema/ScopeInfo.cpp index d18328878c7..037ffd843bb 100644 --- a/clang/lib/Sema/ScopeInfo.cpp +++ b/clang/lib/Sema/ScopeInfo.cpp @@ -86,9 +86,7 @@ FunctionScopeInfo::WeakObjectProfileTy::getBaseInfo(const Expr *E) { if (BaseProp) { D = getBestPropertyDecl(BaseProp); - if (BaseProp->isClassReceiver()) - IsExact = true; - else { + if (BaseProp->isObjectReceiver()) { const Expr *DoubleBase = BaseProp->getBase(); if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(DoubleBase)) DoubleBase = OVE->getSourceExpr(); diff --git a/clang/test/SemaObjC/arc-repeated-weak.mm b/clang/test/SemaObjC/arc-repeated-weak.mm index 7ac2313fa31..11161a0bf7f 100644 --- a/clang/test/SemaObjC/arc-repeated-weak.mm +++ b/clang/test/SemaObjC/arc-repeated-weak.mm @@ -445,9 +445,20 @@ void doubleLevelAccessIvar(Test *a, Test *b) { @class NSString; @interface NSBundle +(NSBundle *)foo; +@property (class) NSBundle *foo2; @property NSString *prop; +@property(weak) NSString *weakProp; +@end + +@interface NSBundle2 : NSBundle @end void foo() { NSString * t = NSBundle.foo.prop; + use(NSBundle.foo.weakProp); // expected-warning{{weak property 'weakProp' may be accessed multiple times}} + use(NSBundle2.foo.weakProp); // expected-note{{also accessed here}} + + NSString * t2 = NSBundle.foo2.prop; + use(NSBundle.foo2.weakProp); // expected-warning{{weak property 'weakProp' may be accessed multiple times}} + use(NSBundle2.foo2.weakProp); // expected-note{{also accessed here}} } |