[cfe-commits] r53957 - in /cfe/trunk: lib/Analysis/CheckObjCUnusedIVars.cpp test/Analysis/unused-ivars.m

Ted Kremenek kremenek at apple.com
Wed Jul 23 11:21:36 PDT 2008


Author: kremenek
Date: Wed Jul 23 13:21:36 2008
New Revision: 53957

URL: http://llvm.org/viewvc/llvm-project?rev=53957&view=rev
Log:
Properly skip IBOutlets when checking for unused ivars.
Refine the error message of unused ivars.
Added test case.

Added:
    cfe/trunk/test/Analysis/unused-ivars.m
Modified:
    cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp

Modified: cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp?rev=53957&r1=53956&r2=53957&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp (original)
+++ cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp Wed Jul 23 13:21:36 2008
@@ -57,8 +57,9 @@
     // Ignore ivars that aren't private.
     if (ID->getAccessControl() != ObjCIvarDecl::Private)
       continue;
-    
-    if (ID->getAttr<IBOutletAttr>() == 0)
+
+    // Skip IB Outlets.
+    if (ID->getAttr<IBOutletAttr>())
       continue;
     
     M[ID] = Unused;
@@ -77,8 +78,9 @@
     if (I->second == Unused) {
       
       std::ostringstream os;
-      os << "Private ivar '" << I->first->getName() << "' is never used.";
-      
+      os << "Instance variable '" << I->first->getName()
+         << "' in class '" << ID->getName() << "' is never used.";
+
       BR.EmitBasicReport("unused ivar",
                          os.str().c_str(), I->first->getLocation());
     }

Added: cfe/trunk/test/Analysis/unused-ivars.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/unused-ivars.m?rev=53957&view=auto

==============================================================================
--- cfe/trunk/test/Analysis/unused-ivars.m (added)
+++ cfe/trunk/test/Analysis/unused-ivars.m Wed Jul 23 13:21:36 2008
@@ -0,0 +1,10 @@
+// RUN: clang -warn-objc-unused-ivars %s -verify
+
+ at interface A
+{
+  @private int x; // expected-warning {{Instance variable 'x' in class 'A' is never used.}}
+}
+ at end
+
+ at implementation A @end
+





More information about the cfe-commits mailing list