summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-02-06 00:30:00 +0000
committerTed Kremenek <kremenek@apple.com>2010-02-06 00:30:00 +0000
commit5abd69d946374a8a40fe4fd47f95b49c24d9643a (patch)
tree2006e6e02941f9f104781e33075d33ed571526b7 /clang/lib/Analysis
parentca972cd1f1e016cc144a47eb34bcca51e59a6fab (diff)
downloadbcm5719-llvm-5abd69d946374a8a40fe4fd47f95b49c24d9643a.tar.gz
bcm5719-llvm-5abd69d946374a8a40fe4fd47f95b49c24d9643a.zip
Teach RegionStore::InvalidateRegions() to also invalidate static variables referenced by blocks.
llvm-svn: 95459
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r--clang/lib/Analysis/AnalysisContext.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/clang/lib/Analysis/AnalysisContext.cpp b/clang/lib/Analysis/AnalysisContext.cpp
index 0c64610bea4..ccd5088f2ec 100644
--- a/clang/lib/Analysis/AnalysisContext.cpp
+++ b/clang/lib/Analysis/AnalysisContext.cpp
@@ -194,6 +194,7 @@ namespace {
class FindBlockDeclRefExprsVals : public StmtVisitor<FindBlockDeclRefExprsVals>{
BumpVector<const VarDecl*> &BEVals;
BumpVectorContext &BC;
+ llvm::DenseMap<const VarDecl*, unsigned> Visited;
public:
FindBlockDeclRefExprsVals(BumpVector<const VarDecl*> &bevals,
BumpVectorContext &bc)
@@ -204,10 +205,27 @@ public:
if (Stmt *child = *I)
Visit(child);
}
+
+ void VisitDeclRefExpr(const DeclRefExpr *DR) {
+ // Non-local variables are also directly modified.
+ if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl()))
+ if (!VD->hasLocalStorage()) {
+ unsigned &flag = Visited[VD];
+ if (!flag) {
+ flag = 1;
+ BEVals.push_back(VD, BC);
+ }
+ }
+ }
void VisitBlockDeclRefExpr(BlockDeclRefExpr *DR) {
- if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl()))
- BEVals.push_back(VD, BC);
+ if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) {
+ unsigned &flag = Visited[VD];
+ if (!flag) {
+ flag = 1;
+ BEVals.push_back(VD, BC);
+ }
+ }
}
};
} // end anonymous namespace
OpenPOWER on IntegriCloud