Added initial support into the flow-sensitive dataflow solver to visit the Block-level expression
in a block's terminator. This expression is visited within a block, but it is accessed by the
terminator. This is important to observe because for live-variables analysis the block-level
expression is live between the terminator and where the expression occurs in the block. So far
this hasn't been an issue to not observe this because the block-level expression used in the
terminator is always the last one in the block, and we have never queried the liveness information
about this point (but before the terminator).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49709 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/LiveVariables.cpp b/lib/Analysis/LiveVariables.cpp
index b704b2d..4cef30c 100644
--- a/lib/Analysis/LiveVariables.cpp
+++ b/lib/Analysis/LiveVariables.cpp
@@ -73,7 +73,8 @@
void VisitAssign(BinaryOperator* B);
void VisitDeclStmt(DeclStmt* DS);
void VisitUnaryOperator(UnaryOperator* U);
- void Visit(Stmt *S);
+ void Visit(Stmt *S);
+ void VisitTerminator(Stmt* S);
};
void TransferFuncs::Visit(Stmt *S) {
@@ -90,6 +91,23 @@
// For block-level expressions, mark that they are live.
LiveState(S,AD) = Alive;
}
+
+void TransferFuncs::VisitTerminator(Stmt* S) {
+ return;
+
+ for (Stmt::child_iterator I = S->child_begin(), E = S->child_end();
+ I != E; ++I) {
+
+ Stmt* Child = *I;
+ if (!Child) continue;
+
+ if (getCFG().isBlkExpr(Child)) {
+ LiveState(Child, AD) = Alive;
+ return; // Only one "condition" expression.
+ }
+ }
+}
+
void TransferFuncs::VisitDeclRefExpr(DeclRefExpr* DR) {
if (VarDecl* V = dyn_cast<VarDecl>(DR->getDecl()))
diff --git a/lib/Analysis/UninitializedValues.cpp b/lib/Analysis/UninitializedValues.cpp
index 3edf04d..d5c697a 100644
--- a/lib/Analysis/UninitializedValues.cpp
+++ b/lib/Analysis/UninitializedValues.cpp
@@ -75,6 +75,8 @@
bool Visit(Stmt *S);
bool BlockStmt_VisitExpr(Expr* E);
+
+ void VisitTerminator(Stmt* T) { Visit(T); }
BlockVarDecl* FindBlockVarDecl(Stmt* S);
};