]> granicus.if.org Git - clang/commitdiff
[Objective-c] Do not set IsExact to true when the receiver is a class.
authorAkira Hatanaka <ahatanaka@apple.com>
Tue, 22 Mar 2016 05:00:21 +0000 (05:00 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Tue, 22 Mar 2016 05:00:21 +0000 (05:00 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@264025 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/ScopeInfo.h
lib/Sema/ScopeInfo.cpp
test/SemaObjC/arc-repeated-weak.mm

index 0ec59cd38066adee610193fdca02aaae65b37871..c57a59db8ec9389b32fbae9408aa62593e0203a4 100644 (file)
@@ -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)
   ///
index d18328878c73314a6a47db7401f07953a6875811..037ffd843bb716aca0460252a630d1bdf0246e99 100644 (file)
@@ -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();
index 7ac2313fa318a3caf770e43cb2373cacbe629219..11161a0bf7fc0cf0bcbaaf64df33a48d85e26d94 100644 (file)
@@ -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}}
 }