From: Ted Kremenek Date: Thu, 6 Dec 2012 07:17:26 +0000 (+0000) Subject: Use the BlockDecl captures list to infer the direct captures for a BlockDataRegion... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3e871d8cf686b911e2a66655a77252555b946c99;p=platform%2Fupstream%2Fllvm.git Use the BlockDecl captures list to infer the direct captures for a BlockDataRegion. Fixes . We still need to do a recursive walk to determine all static/global variables referenced by a block, which is needed for region invalidation. llvm-svn: 169481 --- diff --git a/clang/lib/Analysis/AnalysisDeclContext.cpp b/clang/lib/Analysis/AnalysisDeclContext.cpp index 83d441e..bcaad9b 100644 --- a/clang/lib/Analysis/AnalysisDeclContext.cpp +++ b/clang/lib/Analysis/AnalysisDeclContext.cpp @@ -402,9 +402,6 @@ public: if (!VD->hasLocalStorage()) { if (Visited.insert(VD)) BEVals.push_back(VD, BC); - } else if (DR->refersToEnclosingLocal()) { - if (Visited.insert(VD) && IsTrackedDecl(VD)) - BEVals.push_back(VD, BC); } } } @@ -439,7 +436,13 @@ static DeclVec* LazyInitializeReferencedDecls(const BlockDecl *BD, DeclVec *BV = (DeclVec*) A.Allocate(); new (BV) DeclVec(BC, 10); - // Find the referenced variables. + // Go through the capture list. + for (BlockDecl::capture_const_iterator CI = BD->capture_begin(), + CE = BD->capture_end(); CI != CE; ++CI) { + BV->push_back(CI->getVariable(), BC); + } + + // Find the referenced global/static variables. FindBlockDeclRefExprsVals F(*BV, BC); F.Visit(BD->getBody()); diff --git a/clang/test/Analysis/blocks.m b/clang/test/Analysis/blocks.m index 8aa65a3..2fa5a8e 100644 --- a/clang/test/Analysis/blocks.m +++ b/clang/test/Analysis/blocks.m @@ -97,7 +97,6 @@ void testMessaging() { } -// FALSE POSITIVE @interface rdar12415065 : NSObject @end @@ -112,8 +111,9 @@ void testMessaging() { if (!queue) return; - // FALSE POSITIVE - // expected-warning@+1 {{Variable 'x' is uninitialized when captured by block}} + // This previously was a false positive with 'x' being flagged as being + // uninitialized when captured by the exterior block (when it is only + // captured by the interior block). dispatch_async(queue, ^{ double x = 0.0; if (24.0f < x) {