Properly skip IBOutlets when checking for unused ivars.
Refine the error message of unused ivars. Added test case. llvm-svn: 53957
This commit is contained in:
parent
0cdba6b43e
commit
46abc7db6b
|
@ -58,7 +58,8 @@ void clang::CheckObjCUnusedIvar(ObjCImplementationDecl* D, BugReporter& BR) {
|
|||
if (ID->getAccessControl() != ObjCIvarDecl::Private)
|
||||
continue;
|
||||
|
||||
if (ID->getAttr<IBOutletAttr>() == 0)
|
||||
// Skip IB Outlets.
|
||||
if (ID->getAttr<IBOutletAttr>())
|
||||
continue;
|
||||
|
||||
M[ID] = Unused;
|
||||
|
@ -77,7 +78,8 @@ 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());
|
||||
|
|
|
@ -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
|
||||
|
Loading…
Reference in New Issue