diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-12-09 00:14:14 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-12-09 00:14:14 +0000 |
commit | 6ee0a118146ce01d852b529156ceaaadb0e2d11a (patch) | |
tree | 9664326b5952eabc5643b70ec4f5630319f62946 /clang/lib/Analysis/LiveVariables.cpp | |
parent | 8e0079c7876a23fb54032da3ee3cf3b57fa196a7 (diff) | |
download | bcm5719-llvm-6ee0a118146ce01d852b529156ceaaadb0e2d11a.tar.gz bcm5719-llvm-6ee0a118146ce01d852b529156ceaaadb0e2d11a.zip |
Fixed LiveVariables bug where we didn't consider block-level expressions that functioned as the size of a VLA to be live.
llvm-svn: 60730
Diffstat (limited to 'clang/lib/Analysis/LiveVariables.cpp')
-rw-r--r-- | clang/lib/Analysis/LiveVariables.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/Analysis/LiveVariables.cpp b/clang/lib/Analysis/LiveVariables.cpp index 4b181a954c0..8105e38b674 100644 --- a/clang/lib/Analysis/LiveVariables.cpp +++ b/clang/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); |