From: Ted Kremenek Date: Tue, 9 Dec 2008 00:14:14 +0000 (+0000) Subject: Fixed LiveVariables bug where we didn't consider block-level expressions that functio... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e0dbda136444b2f3550a421f4436d438230c732f;p=clang 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 --- diff --git a/include/clang/Analysis/Analyses/LiveVariables.h b/include/clang/Analysis/Analyses/LiveVariables.h index 451e202dd2..b41cd684e9 100644 --- a/include/clang/Analysis/Analyses/LiveVariables.h +++ b/include/clang/Analysis/Analyses/LiveVariables.h @@ -66,7 +66,7 @@ class LiveVariables : public DataflowValuesisBlkExpr(S); } 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(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);