]> granicus.if.org Git - clang/commitdiff
ObjectiveC. Fixes a bug where an 'unused property ivar'
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 11 Dec 2013 00:53:48 +0000 (00:53 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 11 Dec 2013 00:53:48 +0000 (00:53 +0000)
warning is coming out incorrectly too early
becuase of unrelated scope pop. // rdar://15630719

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

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

index 249a4c74311bbcb95a4a147f8a8fb6315bfefe52..238e0d28184ee7eb3520d4684d83967de4784e96 100644 (file)
@@ -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 {
index babfafe656d3614813175ccff69c8e55b8f4d76f..a2d5fc00ac32ceda1c172610b6294c632d23383c 100644 (file)
@@ -3498,7 +3498,7 @@ Sema::GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method,
 }
 
 void Sema::DiagnoseUnusedBackingIvarInAccessor(Scope *S) {
-  if (S->hasUnrecoverableErrorOccurred() || !S->isInObjcMethodScope())
+  if (S->hasUnrecoverableErrorOccurred() || !S->isInObjcMethodOuterScope())
     return;
   
   const ObjCMethodDecl *CurMethod = getCurMethodDecl();
index c07dea71a7e180e4b45db2a3ab02a8b944528088..df3ede75afa8f1f1d70ccb625456ab5e29e89980 100644 (file)
@@ -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
+