summaryrefslogtreecommitdiffstats
path: root/clang/Analysis/LiveVariables.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-01-17 20:48:37 +0000
committerTed Kremenek <kremenek@apple.com>2008-01-17 20:48:37 +0000
commit85be7cf8ca5c403cc04bd359f6ecd2f10f69bbbd (patch)
tree0352f8b8de3ba9bdc8326538768c566dd5de6d1e /clang/Analysis/LiveVariables.cpp
parente4d3e3c0e7e122b5c14c0146d6a27a73884176ad (diff)
downloadbcm5719-llvm-85be7cf8ca5c403cc04bd359f6ecd2f10f69bbbd.tar.gz
bcm5719-llvm-85be7cf8ca5c403cc04bd359f6ecd2f10f69bbbd.zip
Modified the notion of "Block-level expressions" in CFGs to include Stmt*. This
is because GNU-style Statement-expressions cause the last statement in the statement-expression to act like an expression. We now have two notions: block-level statements and block-level expressions. The former are all Stmt* that appear in the list of statements in CFGBlocks. The latter is the subset of the former; these block-level statements are used as subexpressions somewhere in the AST. CFG::isBlockExpr() returns true for the latter, not the former (previously isBlockExpr() always returned true for non-Expr Stmt*). Modified the LiveVariables analysis to also track liveness state for block-level expressions (using the updated definition of block-level expressions). Modified the dataflow solver so that when it records values for block-level statements, it records the dataflow value *before* the transfer function for a Stmt* is evaluated (not after). This is more in sync in what clients will want. Modified CFGStmtVisitor to record the current block-level statement. llvm-svn: 46143
Diffstat (limited to 'clang/Analysis/LiveVariables.cpp')
-rw-r--r--clang/Analysis/LiveVariables.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/Analysis/LiveVariables.cpp b/clang/Analysis/LiveVariables.cpp
index ff4224a06fa..5bd72b42af4 100644
--- a/clang/Analysis/LiveVariables.cpp
+++ b/clang/Analysis/LiveVariables.cpp
@@ -77,7 +77,16 @@ void TransferFuncs::Visit(Stmt *S) {
if (AD.Observer)
AD.Observer->ObserveStmt(S,AD,LiveState);
- static_cast<CFGStmtVisitor<TransferFuncs>*>(this)->Visit(S);
+
+ if (S == getCurrentBlkStmt()) {
+ StmtVisitor<TransferFuncs,void>::Visit(S);
+ if (getCFG().isBlkExpr(S)) LiveState(S,AD) = Dead;
+ }
+ else if (!getCFG().isBlkExpr(S))
+ StmtVisitor<TransferFuncs,void>::Visit(S);
+ else
+ // For block-level expressions, mark that they are live.
+ LiveState(S,AD) = Alive;
}
void TransferFuncs::VisitDeclRefExpr(DeclRefExpr* DR) {
@@ -186,6 +195,10 @@ bool LiveVariables::isLive(const ValTy& Live, const VarDecl* D) const {
return Live(D,getAnalysisData());
}
+bool LiveVariables::isLive(const Stmt* Loc, const Stmt* StmtVal) const {
+ return getStmtData(Loc)(StmtVal,getAnalysisData());
+}
+
//===----------------------------------------------------------------------===//
// printing liveness state for debugging
//
OpenPOWER on IntegriCloud