forked from OSchip/llvm-project
Enhance the unused ivar checker to not consider an ivar to be accidentally unused
when it is explicitly marked as unused via __attribute__((unused)). llvm-svn: 97104
This commit is contained in:
parent
6bf658abef
commit
d98d22b9af
|
@ -18,7 +18,6 @@ add_clang_library(clangChecker
|
||||||
CheckDeadStores.cpp
|
CheckDeadStores.cpp
|
||||||
CheckObjCDealloc.cpp
|
CheckObjCDealloc.cpp
|
||||||
CheckObjCInstMethSignature.cpp
|
CheckObjCInstMethSignature.cpp
|
||||||
CheckObjCUnusedIVars.cpp
|
|
||||||
CheckSecuritySyntaxOnly.cpp
|
CheckSecuritySyntaxOnly.cpp
|
||||||
CheckSizeofPointer.cpp
|
CheckSizeofPointer.cpp
|
||||||
Checker.cpp
|
Checker.cpp
|
||||||
|
@ -42,6 +41,7 @@ add_clang_library(clangChecker
|
||||||
NSErrorChecker.cpp
|
NSErrorChecker.cpp
|
||||||
NoReturnFunctionChecker.cpp
|
NoReturnFunctionChecker.cpp
|
||||||
OSAtomicChecker.cpp
|
OSAtomicChecker.cpp
|
||||||
|
ObjCUnusedIVarsChecker.cpp
|
||||||
PathDiagnostic.cpp
|
PathDiagnostic.cpp
|
||||||
PointerArithChecker.cpp
|
PointerArithChecker.cpp
|
||||||
PointerSubChecker.cpp
|
PointerSubChecker.cpp
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//==- CheckObjCUnusedIVars.cpp - Check for unused ivars ----------*- C++ -*-==//
|
//==- ObjCUnusedIVarsChecker.cpp - Check for unused ivars --------*- C++ -*-==//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -109,12 +109,12 @@ void clang::CheckObjCUnusedIvar(const ObjCImplementationDecl *D,
|
||||||
|
|
||||||
const ObjCIvarDecl* ID = *I;
|
const ObjCIvarDecl* ID = *I;
|
||||||
|
|
||||||
// Ignore ivars that aren't private.
|
// Ignore ivars that...
|
||||||
if (ID->getAccessControl() != ObjCIvarDecl::Private)
|
// (a) aren't private
|
||||||
continue;
|
// (b) explicitly marked unused
|
||||||
|
// (c) are iboutlets
|
||||||
// Skip IB Outlets.
|
if (ID->getAccessControl() != ObjCIvarDecl::Private ||
|
||||||
if (ID->getAttr<IBOutletAttr>())
|
ID->getAttr<UnusedAttr>() || ID->getAttr<IBOutletAttr>())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
M[ID] = Unused;
|
M[ID] = Unused;
|
||||||
|
@ -126,7 +126,6 @@ void clang::CheckObjCUnusedIvar(const ObjCImplementationDecl *D,
|
||||||
// Now scan the implementation declaration.
|
// Now scan the implementation declaration.
|
||||||
Scan(M, D);
|
Scan(M, D);
|
||||||
|
|
||||||
|
|
||||||
// Any potentially unused ivars?
|
// Any potentially unused ivars?
|
||||||
bool hasUnused = false;
|
bool hasUnused = false;
|
||||||
for (IvarUsageMap::iterator I = M.begin(), E = M.end(); I!=E; ++I)
|
for (IvarUsageMap::iterator I = M.begin(), E = M.end(); I!=E; ++I)
|
|
@ -81,3 +81,18 @@ int radar_7254495(RDar7254495 *a) {
|
||||||
return a->x;
|
return a->x;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
// <rdar://problem/7353683> - consult attribute((unused)) to silence warnings
|
||||||
|
// about unused instance variables
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
@interface RDar7353683 {
|
||||||
|
@private
|
||||||
|
id x __attribute__((unused));
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation RDar7353683
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue