diff options
author | Lukáš Zaoral <lzaoral@redhat.com> | 2022-04-17 12:35:47 +0200 |
---|---|---|
committer | MartinNowack <2443641+MartinNowack@users.noreply.github.com> | 2023-03-20 16:05:38 +0000 |
commit | d9da9eadbc0aacf61b336231560abb67bcba91ad (patch) | |
tree | db9bf8f3a6ead078f8eaa32a308f8134230663fd | |
parent | d79d048bfa21b432e1e9e97db9fca9924118b678 (diff) | |
download | klee-d9da9eadbc0aacf61b336231560abb67bcba91ad.tar.gz |
ConstantArrayExprVisitor: Deduplicate `visitConcat` and `visitRead`
-rw-r--r-- | lib/Expr/ArrayExprVisitor.cpp | 36 |
1 files changed, 2 insertions, 34 deletions
diff --git a/lib/Expr/ArrayExprVisitor.cpp b/lib/Expr/ArrayExprVisitor.cpp index c12689b3..0965308a 100644 --- a/lib/Expr/ArrayExprVisitor.cpp +++ b/lib/Expr/ArrayExprVisitor.cpp @@ -58,41 +58,9 @@ ReadExpr *ArrayExprHelper::hasOrderedReads(const ConcatExpr &ce) { ExprVisitor::Action ConstantArrayExprVisitor::visitConcat(const ConcatExpr &ce) { ReadExpr *base = ArrayExprHelper::hasOrderedReads(ce); - if (base) { - // It is an interesting ReadExpr if it contains a concrete array - // that is read at a symbolic index - if (base->updates.root->isConstantArray() && - !isa<ConstantExpr>(base->index)) { - for (const auto *un = base->updates.head.get(); un; un = un->next.get()) { - if (!isa<ConstantExpr>(un->index) || !isa<ConstantExpr>(un->value)) { - incompatible = true; - return Action::skipChildren(); - } - } - IndexCompatibilityExprVisitor compatible; - compatible.visit(base->index); - if (compatible.isCompatible() && - addedIndexes.find(base->index.get()->hash()) == addedIndexes.end()) { - if (arrays.find(base->updates.root) == arrays.end()) { - arrays.insert( - std::make_pair(base->updates.root, std::vector<ref<Expr> >())); - } else { - // Another possible index to resolve, currently unsupported - incompatible = true; - return Action::skipChildren(); - } - arrays.find(base->updates.root)->second.push_back(base->index); - addedIndexes.insert(base->index.get()->hash()); - } else if (compatible.hasInnerReads()) { - // This Read has an inner Read, we want to optimize the inner one - // to create a cascading effect during assignment evaluation - return Action::doChildren(); - } - return Action::skipChildren(); - } - } - return Action::doChildren(); + return base ? visitRead(*base) : Action::doChildren(); } + ExprVisitor::Action ConstantArrayExprVisitor::visitRead(const ReadExpr &re) { // It is an interesting ReadExpr if it contains a concrete array // that is read at a symbolic index |