diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-02-26 19:05:15 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-02-26 19:05:15 +0000 |
commit | 05a2378c708688c8ef498a5cea40ed7f5db15fa5 (patch) | |
tree | 613f7bbb17a613879201efbab2e0981784d3c4d9 /Analysis/ValueState.cpp | |
parent | a5694b8b0096215137bf1c273764ec93ac4898fd (diff) |
Major cleanup of the transfer function logic for '&&', '||', and '?'. We
now store in the state essentially which branch we took. This removes
a bunch of bogus assumptions (and likely bugs), reduces the complexity of
the implementation, and facilitates more optimizations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47613 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Analysis/ValueState.cpp')
-rw-r--r-- | Analysis/ValueState.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/Analysis/ValueState.cpp b/Analysis/ValueState.cpp index 03b2996b65..ab208ff0fe 100644 --- a/Analysis/ValueState.cpp +++ b/Analysis/ValueState.cpp @@ -69,10 +69,14 @@ ValueStateManager::RemoveDeadBindings(ValueState St, Stmt* Loc, MarkedSymbols.insert(*SI); } } - else + else { + RVal X = I.getData(); + + if (X.isUninit() && cast<UninitializedVal>(X).getData()) + continue; + NewSt.BlockExprBindings = Remove(NewSt, BlkExpr); - - continue; + } } // Iterate over the variable bindings. @@ -209,7 +213,7 @@ ValueStateManager::AddEQ(ValueState St, SymbolID sym, const llvm::APSInt& V) { return getPersistentState(NewSt); } -RVal ValueStateManager::GetRVal(ValueState St, Expr* E, bool* hasVal) { +RVal ValueStateManager::GetRVal(ValueState St, Expr* E) { for (;;) { @@ -322,21 +326,15 @@ RVal ValueStateManager::GetRVal(ValueState St, Expr* E, bool* hasVal) { ValueState::ExprBindingsTy::TreeTy* T = St->SubExprBindings.SlimFind(E); - if (T) { - if (hasVal) *hasVal = true; - return T->getValue().second; - } - - T = St->BlockExprBindings.SlimFind(E); + return T ? T->getValue().second : GetBlkExprRVal(St, E); +} + +RVal ValueStateManager::GetBlkExprRVal(ValueState St, Expr* E) { - if (T) { - if (hasVal) *hasVal = true; - return T->getValue().second; - } - else { - if (hasVal) *hasVal = false; - return UnknownVal(); - } + assert (!isa<ParenExpr>(E)); + + ValueState::ExprBindingsTy::TreeTy* T = St->BlockExprBindings.SlimFind(E); + return T ? T->getValue().second : UnknownVal(); } RVal ValueStateManager::GetLVal(ValueState St, Expr* E) { |