aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/LiveVariables.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-12-09 00:14:14 +0000
committerTed Kremenek <kremenek@apple.com>2008-12-09 00:14:14 +0000
commite0dbda136444b2f3550a421f4436d438230c732f (patch)
treea5f969951743ba0a1dddcc50819cc1b116b0b8e7 /lib/Analysis/LiveVariables.cpp
parent447d7aeb9499d7ade42be7d63fa03b37b1d2fc09 (diff)
Fixed LiveVariables bug where we didn't consider block-level expressions that functioned as the size of a VLA to be live.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60730 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/LiveVariables.cpp')
-rw-r--r--lib/Analysis/LiveVariables.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/Analysis/LiveVariables.cpp b/lib/Analysis/LiveVariables.cpp
index 4b181a954c..8105e38b67 100644
--- a/lib/Analysis/LiveVariables.cpp
+++ b/lib/Analysis/LiveVariables.cpp
@@ -13,6 +13,7 @@
#include "clang/Analysis/Analyses/LiveVariables.h"
#include "clang/Basic/SourceManager.h"
+#include "clang/AST/ASTContext.h"
#include "clang/AST/Expr.h"
#include "clang/AST/CFG.h"
#include "clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h"
@@ -95,9 +96,11 @@ public:
} // end anonymous namespace
-LiveVariables::LiveVariables(CFG& cfg) {
+LiveVariables::LiveVariables(ASTContext& Ctx, CFG& cfg) {
// Register all referenced VarDecls.
- getAnalysisData().setCFG(&cfg);
+ getAnalysisData().setCFG(cfg);
+ getAnalysisData().setContext(Ctx);
+
RegisterDecls R(getAnalysisData());
cfg.VisitBlockStmts(R);
}
@@ -270,6 +273,13 @@ void TransferFuncs::VisitDeclStmt(DeclStmt* DS) {
if (Expr* Init = VD->getInit())
Visit(Init);
+ if (const VariableArrayType* VT =
+ AD.getContext().getAsVariableArrayType(VD->getType())) {
+ StmtIterator I(const_cast<VariableArrayType*>(VT));
+ StmtIterator E;
+ for (; I != E; ++I) Visit(*I);
+ }
+
// Update liveness information by killing the VarDecl.
unsigned bit = AD.getIdx(VD);
LiveState.getDeclBit(bit) = Dead | AD.AlwaysLive.getDeclBit(bit);