Author: fjahanian
Date: Tue Dec 10 18:53:48 2013
New Revision: 196989

URL: http://llvm.org/viewvc/llvm-project?rev=196989&view=rev
Log:
ObjectiveC. Fixes a bug where  an 'unused property ivar'
warning is coming out incorrectly too early
becuase of unrelated scope pop. // rdar://15630719

Modified:
    cfe/trunk/include/clang/Sema/Scope.h
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/SemaObjC/unsued-backing-ivar-warning.m

Modified: cfe/trunk/include/clang/Sema/Scope.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Scope.h?rev=196989&r1=196988&r2=196989&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Scope.h (original)
+++ cfe/trunk/include/clang/Sema/Scope.h Tue Dec 10 18:53:48 2013
@@ -273,6 +273,18 @@ public:
     return false;
   }
 
+  /// isInObjcMethodOuterScope - Return true if this scope is an
+  /// Objective-C method outer most body.
+  bool isInObjcMethodOuterScope() const {
+    if (const Scope *S = this) {
+      // If this scope is an objc method scope, then we succeed.
+      if (S->getFlags() & ObjCMethodScope)
+        return true;
+    }
+    return false;
+  }
+
+  
   /// isTemplateParamScope - Return true if this scope is a C++
   /// template parameter scope.
   bool isTemplateParamScope() const {

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=196989&r1=196988&r2=196989&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Dec 10 18:53:48 2013
@@ -3498,7 +3498,7 @@ Sema::GetIvarBackingPropertyAccessor(con
 }
 
 void Sema::DiagnoseUnusedBackingIvarInAccessor(Scope *S) {
-  if (S->hasUnrecoverableErrorOccurred() || !S->isInObjcMethodScope())
+  if (S->hasUnrecoverableErrorOccurred() || !S->isInObjcMethodOuterScope())
     return;
   
   const ObjCMethodDecl *CurMethod = getCurMethodDecl();

Modified: cfe/trunk/test/SemaObjC/unsued-backing-ivar-warning.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/unsued-backing-ivar-warning.m?rev=196989&r1=196988&r2=196989&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/unsued-backing-ivar-warning.m (original)
+++ cfe/trunk/test/SemaObjC/unsued-backing-ivar-warning.m Tue Dec 10 18:53:48 
2013
@@ -74,3 +74,20 @@ typedef char BOOL;
   return 0;
 }
 @end
+
+// rdar://15630719
+@interface CDBModifyRecordsOperation : NSObject
+@property (nonatomic, assign) BOOL atomic;
+@end
+
+@class NSString;
+
+@implementation CDBModifyRecordsOperation
+- (void)setAtomic:(BOOL)atomic {
+  if (atomic == __objc_yes) {
+    NSString *recordZoneID = 0;
+  }
+  _atomic = atomic;
+}
+@end
+


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to