diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-11-05 00:26:53 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-11-05 00:26:53 +0000 |
commit | ddaec0dba69f2318d96f949b2f273b2befd1a5c2 (patch) | |
tree | 62f4eea81926228df94d86f69ade1b5650ba1f87 /lib/Analysis/LiveVariables.cpp | |
parent | 6a9065a39ab15383082b914af28759da1652db18 (diff) |
Teach LiveVariables to look through OpaqueValueExprs for extending Stmt liveness.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143767 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/LiveVariables.cpp')
-rw-r--r-- | lib/Analysis/LiveVariables.cpp | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/lib/Analysis/LiveVariables.cpp b/lib/Analysis/LiveVariables.cpp index 194c03cd0a..0b5a236bed 100644 --- a/lib/Analysis/LiveVariables.cpp +++ b/lib/Analysis/LiveVariables.cpp @@ -231,6 +231,30 @@ static const VariableArrayType *FindVA(QualType Ty) { return 0; } +static const Stmt *LookThroughStmt(const Stmt *S) { + while (S) { + switch (S->getStmtClass()) { + case Stmt::ParenExprClass: { + S = cast<ParenExpr>(S)->getSubExpr(); + continue; + } + case Stmt::OpaqueValueExprClass: { + S = cast<OpaqueValueExpr>(S)->getSourceExpr(); + continue; + } + default: + break; + } + } + return S; +} + +static void AddLiveStmt(llvm::ImmutableSet<const Stmt *> &Set, + llvm::ImmutableSet<const Stmt *>::Factory &F, + const Stmt *S) { + Set = F.add(Set, LookThroughStmt(S)); +} + void TransferFunctions::Visit(Stmt *S) { if (observer) observer->observeStmt(S, currentBlock, val); @@ -255,8 +279,7 @@ void TransferFunctions::Visit(Stmt *S) { // Include the implicit "this" pointer as being live. CXXMemberCallExpr *CE = cast<CXXMemberCallExpr>(S); if (Expr *ImplicitObj = CE->getImplicitObjectArgument()) { - ImplicitObj = ImplicitObj->IgnoreParens(); - val.liveStmts = LV.SSetFact.add(val.liveStmts, ImplicitObj); + AddLiveStmt(val.liveStmts, LV.SSetFact, ImplicitObj); } break; } @@ -265,8 +288,7 @@ void TransferFunctions::Visit(Stmt *S) { if (const VarDecl *VD = dyn_cast<VarDecl>(DS->getSingleDecl())) { for (const VariableArrayType* VA = FindVA(VD->getType()); VA != 0; VA = FindVA(VA->getElementType())) { - val.liveStmts = LV.SSetFact.add(val.liveStmts, - VA->getSizeExpr()->IgnoreParens()); + AddLiveStmt(val.liveStmts, LV.SSetFact, VA->getSizeExpr()); } } break; @@ -288,12 +310,8 @@ void TransferFunctions::Visit(Stmt *S) { for (Stmt::child_iterator it = S->child_begin(), ei = S->child_end(); it != ei; ++it) { - if (Stmt *child = *it) { - if (Expr *Ex = dyn_cast<Expr>(child)) - child = Ex->IgnoreParens(); - - val.liveStmts = LV.SSetFact.add(val.liveStmts, child); - } + if (Stmt *child = *it) + AddLiveStmt(val.liveStmts, LV.SSetFact, child); } } |