diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-03-29 01:40:00 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-03-29 01:40:00 +0000 |
commit | 03325c4be988ccfbf1cad214b3895627b8d6c910 (patch) | |
tree | 127978eb13b464a844df286eb9071e400fb1dca6 /clang/lib/Analysis | |
parent | 6454e15f496c118cf0332e53ee9896dabdc66dcc (diff) | |
download | bcm5719-llvm-03325c4be988ccfbf1cad214b3895627b8d6c910.tar.gz bcm5719-llvm-03325c4be988ccfbf1cad214b3895627b8d6c910.zip |
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.
llvm-svn: 128443
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r-- | clang/lib/Analysis/UninitializedValues.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/clang/lib/Analysis/UninitializedValues.cpp b/clang/lib/Analysis/UninitializedValues.cpp index 6e7e915c474..f3cf905af27 100644 --- a/clang/lib/Analysis/UninitializedValues.cpp +++ b/clang/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); |