aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/UninitializedValues.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-03-29 01:40:00 +0000
committerTed Kremenek <kremenek@apple.com>2011-03-29 01:40:00 +0000
commitb831c673621c5587642343cace9def134916a17b (patch)
tree75b481fd7ceedcdb0fe1a59fabfb41d082bf1666 /lib/Analysis/UninitializedValues.cpp
parent170a6a229b6cb0c411be5edaa587a1b1436bd147 (diff)
Add workaround for Sema issue found in <rdar://problem/9188004>, which leads to an assertion failure in the uninitialized variables analysis. The problem is that Sema isn't properly registering a variable in a DeclContext (which -Wuninitialized relies on), but
my expertise on the template instantiation logic isn't good enough to fix this problem for real. This patch worksaround the problem in -Wuninitialized, but we should fix it for real later. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128443 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/UninitializedValues.cpp')
-rw-r--r--lib/Analysis/UninitializedValues.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Analysis/UninitializedValues.cpp b/lib/Analysis/UninitializedValues.cpp
index 6e7e915c47..f3cf905af2 100644
--- a/lib/Analysis/UninitializedValues.cpp
+++ b/lib/Analysis/UninitializedValues.cpp
@@ -51,7 +51,7 @@ public:
unsigned size() const { return map.size(); }
/// Returns the bit vector index for a given declaration.
- llvm::Optional<unsigned> getValueIndex(const VarDecl *d);
+ llvm::Optional<unsigned> getValueIndex(const VarDecl *d) const;
};
}
@@ -66,8 +66,8 @@ void DeclToIndex::computeMap(const DeclContext &dc) {
}
}
-llvm::Optional<unsigned> DeclToIndex::getValueIndex(const VarDecl *d) {
- llvm::DenseMap<const VarDecl *, unsigned>::iterator I = map.find(d);
+llvm::Optional<unsigned> DeclToIndex::getValueIndex(const VarDecl *d) const {
+ llvm::DenseMap<const VarDecl *, unsigned>::const_iterator I = map.find(d);
if (I == map.end())
return llvm::Optional<unsigned>();
return I->second;
@@ -152,6 +152,10 @@ public:
return declToIndex.size() == 0;
}
+ bool hasEntry(const VarDecl *vd) const {
+ return declToIndex.getValueIndex(vd).hasValue();
+ }
+
void resetScratch();
ValueVector &getScratch() { return scratch; }
@@ -379,7 +383,13 @@ public:
void BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt *fs);
bool isTrackedVar(const VarDecl *vd) {
+#if 1
+ // FIXME: This is a temporary workaround to deal with the fact
+ // that DeclContext's do not always contain all of their variables!
+ return vals.hasEntry(vd);
+#else
return ::isTrackedVar(vd, cast<DeclContext>(ac.getDecl()));
+#endif
}
FindVarResult findBlockVarDecl(Expr *ex);