r264025 - [Objective-c] Do not set IsExact to true when the receiver is a class.

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 21 22:00:21 PDT 2016


Author: ahatanak
Date: Tue Mar 22 00:00:21 2016
New Revision: 264025

URL: http://llvm.org/viewvc/llvm-project?rev=264025&view=rev
Log:
[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

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

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=264025&r1=264024&r2=264025&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Tue Mar 22 00:00:21 2016
@@ -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)
   ///

Modified: cfe/trunk/lib/Sema/ScopeInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ScopeInfo.cpp?rev=264025&r1=264024&r2=264025&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/ScopeInfo.cpp (original)
+++ cfe/trunk/lib/Sema/ScopeInfo.cpp Tue Mar 22 00:00:21 2016
@@ -86,9 +86,7 @@ FunctionScopeInfo::WeakObjectProfileTy::
     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();

Modified: cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-repeated-weak.mm?rev=264025&r1=264024&r2=264025&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/arc-repeated-weak.mm (original)
+++ cfe/trunk/test/SemaObjC/arc-repeated-weak.mm Tue Mar 22 00:00:21 2016
@@ -445,9 +445,20 @@ void doubleLevelAccessIvar(Test *a, Test
 @class NSString;
 @interface NSBundle
 +(NSBundle *)foo;
+ at property (class) NSBundle *foo2;
 @property NSString *prop;
+ at property(weak) NSString *weakProp;
+ at end
+
+ at 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}}
 }




More information about the cfe-commits mailing list