diff options
-rw-r--r-- | lib/Analysis/CheckObjCUnusedIVars.cpp | 10 | ||||
-rw-r--r-- | test/Analysis/unused-ivars.m | 10 |
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/Analysis/CheckObjCUnusedIVars.cpp b/lib/Analysis/CheckObjCUnusedIVars.cpp index d074dde8a3..d536ea4bdb 100644 --- a/lib/Analysis/CheckObjCUnusedIVars.cpp +++ b/lib/Analysis/CheckObjCUnusedIVars.cpp @@ -57,8 +57,9 @@ void clang::CheckObjCUnusedIvar(ObjCImplementationDecl* D, BugReporter& BR) { // 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 @@ void clang::CheckObjCUnusedIvar(ObjCImplementationDecl* D, BugReporter& BR) { 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()); } diff --git a/test/Analysis/unused-ivars.m b/test/Analysis/unused-ivars.m new file mode 100644 index 0000000000..c29e243fc3 --- /dev/null +++ b/test/Analysis/unused-ivars.m @@ -0,0 +1,10 @@ +// RUN: clang -warn-objc-unused-ivars %s -verify + +@interface A +{ + @private int x; // expected-warning {{Instance variable 'x' in class 'A' is never used.}} +} +@end + +@implementation A @end + |