[cfe-commits] r169481 - in /cfe/trunk: lib/Analysis/AnalysisDeclContext.cpp test/Analysis/blocks.m
Ted Kremenek
kremenek at apple.com
Wed Dec 5 23:17:26 PST 2012
Author: kremenek
Date: Thu Dec 6 01:17:26 2012
New Revision: 169481
URL: http://llvm.org/viewvc/llvm-project?rev=169481&view=rev
Log:
Use the BlockDecl captures list to infer the direct captures for a BlockDataRegion. Fixes <rdar://problem/12415065>.
We still need to do a recursive walk to determine all static/global variables
referenced by a block, which is needed for region invalidation.
Modified:
cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
cfe/trunk/test/Analysis/blocks.m
Modified: cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp?rev=169481&r1=169480&r2=169481&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp (original)
+++ cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp Thu Dec 6 01:17:26 2012
@@ -402,9 +402,6 @@
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 @@
DeclVec *BV = (DeclVec*) A.Allocate<DeclVec>();
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());
Modified: cfe/trunk/test/Analysis/blocks.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/blocks.m?rev=169481&r1=169480&r2=169481&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/blocks.m (original)
+++ cfe/trunk/test/Analysis/blocks.m Thu Dec 6 01:17:26 2012
@@ -97,7 +97,6 @@
}
-// FALSE POSITIVE <rdar://problem/12415065>
@interface rdar12415065 : NSObject
@end
@@ -112,8 +111,9 @@
if (!queue)
return;
- // FALSE POSITIVE
- // expected-warning at +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) {
More information about the cfe-commits
mailing list