Teach DeadStoresChecker about attribute objc_precise_lifetime.

llvm-svn: 199277
This commit is contained in:
Ted Kremenek 2014-01-15 00:59:23 +00:00
parent 1ad8457570
commit 0f83390540
2 changed files with 14 additions and 3 deletions

View File

@ -214,7 +214,8 @@ public:
return;
if (!isLive(Live, VD) &&
!(VD->hasAttr<UnusedAttr>() || VD->hasAttr<BlocksAttr>())) {
!(VD->hasAttr<UnusedAttr>() || VD->hasAttr<BlocksAttr>() ||
VD->hasAttr<ObjCPreciseLifetimeAttr>())) {
PathDiagnosticLocation ExLoc =
PathDiagnosticLocation::createBegin(Ex, BR.getSourceManager(), AC);
@ -339,8 +340,10 @@ public:
// A dead initialization is a variable that is dead after it
// is initialized. We don't flag warnings for those variables
// marked 'unused'.
if (!isLive(Live, V) && !V->hasAttr<UnusedAttr>()) {
// marked 'unused' or 'objc_precise_lifetime'.
if (!isLive(Live, V) &&
!V->hasAttr<UnusedAttr>() &&
!V->hasAttr<ObjCPreciseLifetimeAttr>()) {
// Special case: check for initializations with constants.
//
// e.g. : int x = 0;

View File

@ -109,3 +109,11 @@ Radar11059352_1 *_Path;
return wp;
}
@end
id test_objc_precise_lifetime_foo();
void test_objc_precise_lifetime() {
__attribute__((objc_precise_lifetime)) id dead = test_objc_precise_lifetime_foo(); // no-warning
dead = 0;
dead = test_objc_precise_lifetime_foo(); // no-warning
dead = 0;
}