From e8d9177a1533411eb53593c7a16cfa6c188952c9 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Thu, 4 Jun 2009 05:36:36 +0000 Subject: Use dyn_cast<> instead of dyn_ref_cast. git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@72847 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/klee/util/Ref.h | 18 ------------------ lib/Expr/Constraints.cpp | 2 +- lib/Expr/Expr.cpp | 2 +- lib/Expr/ExprPPrinter.cpp | 15 +++++++-------- lib/Expr/ExprUtil.cpp | 2 +- unittests/Expr/ExprTest.cpp | 2 +- 6 files changed, 11 insertions(+), 30 deletions(-) diff --git a/include/klee/util/Ref.h b/include/klee/util/Ref.h index d1c2e56b..61e91f3c 100644 --- a/include/klee/util/Ref.h +++ b/include/klee/util/Ref.h @@ -44,8 +44,6 @@ private: public: template friend class ref; - template friend U* dyn_ref_cast(ref &src); - template friend const U* dyn_ref_cast(const ref &src); // constructor from pointer ref(T *p) : ptr(p) { @@ -65,10 +63,6 @@ public: } // pointer operations - T *get () { - return ptr; - } - T *get () const { return ptr; } @@ -119,18 +113,6 @@ inline std::ostream &operator<<(std::ostream &os, const ref &e) { return os; } -class Expr; - -template -U* dyn_ref_cast(ref &src) { - return dyn_cast(src.ptr); -} - -template -const U* dyn_ref_cast(const ref &src) { - return dyn_cast(src.ptr); -} - } // end namespace klee namespace llvm { diff --git a/lib/Expr/Constraints.cpp b/lib/Expr/Constraints.cpp index 3fa58ffd..9103c7c3 100644 --- a/lib/Expr/Constraints.cpp +++ b/lib/Expr/Constraints.cpp @@ -94,7 +94,7 @@ ref ConstraintManager::simplifyExpr(ref e) const { for (ConstraintManager::constraints_ty::const_iterator it = constraints.begin(), ie = constraints.end(); it != ie; ++it) { - if (const EqExpr *ee = dyn_ref_cast(*it)) { + if (const EqExpr *ee = dyn_cast(*it)) { if (ee->left->isConstant()) { equalities.insert(std::make_pair(ee->right, ee->left)); diff --git a/lib/Expr/Expr.cpp b/lib/Expr/Expr.cpp index 3d3b6dd7..6cd15be7 100644 --- a/lib/Expr/Expr.cpp +++ b/lib/Expr/Expr.cpp @@ -490,7 +490,7 @@ ref ExtractExpr::create(ref expr, unsigned off, Width w) { } else // Extract(Concat) - if (ConcatExpr *ce = dyn_ref_cast(expr)) { + if (ConcatExpr *ce = dyn_cast(expr)) { // if the extract skips the right side of the concat if (off >= ce->getRight()->getWidth()) return ExtractExpr::create(ce->getLeft(), off - ce->getRight()->getWidth(), w); diff --git a/lib/Expr/ExprPPrinter.cpp b/lib/Expr/ExprPPrinter.cpp index 6be93c38..e26568d9 100644 --- a/lib/Expr/ExprPPrinter.cpp +++ b/lib/Expr/ExprPPrinter.cpp @@ -112,7 +112,7 @@ class PPrinter : public ExprPPrinter { bool isSimple(const ref &e) { if (isVerySimple(e)) { return true; - } else if (const ReadExpr *re = dyn_ref_cast(e)) { + } else if (const ReadExpr *re = dyn_cast(e)) { return isVerySimple(re->index) && isVerySimpleUpdate(re->updates.head); } else { Expr *ep = e.get(); @@ -148,7 +148,7 @@ class PPrinter : public ExprPPrinter { Expr *ep = e.get(); for (unsigned i=0; igetNumKids(); i++) scan1(ep->getKid(i)); - if (const ReadExpr *re = dyn_ref_cast(e)) + if (const ReadExpr *re = dyn_cast(e)) scanUpdate(re->updates.head); } else { shouldPrint.insert(e); @@ -233,8 +233,7 @@ class PPrinter : public ExprPPrinter { bool isReadExprAtOffset(ref e, const ReadExpr *base, ref offset) { - - const ReadExpr *re = dyn_ref_cast(e.get()); + const ReadExpr *re = dyn_cast(e.get()); // right now, all Reads are byte reads but some // transformations might change this @@ -262,7 +261,7 @@ class PPrinter : public ExprPPrinter { assert(e->getKind() == Expr::Concat); assert(stride == 1 || stride == -1); - const ReadExpr *base = dyn_ref_cast(e->getKid(0)); + const ReadExpr *base = dyn_cast(e->getKid(0)); // right now, all Reads are byte reads but some // transformations might change this @@ -402,7 +401,7 @@ public: // Detect Not. // FIXME: This should be in common code. - if (const EqExpr *ee = dyn_ref_cast(e)) { + if (const EqExpr *ee = dyn_cast(e)) { if (ee->left == ConstantExpr::alloc(false, Expr::Bool)) { PC << "(Not"; printWidth(PC, e); @@ -443,9 +442,9 @@ public: // Indent at first argument and dispatch to appropriate print // routine for exprs which require special handling. unsigned indent = PC.pos; - if (const ReadExpr *re = dyn_ref_cast(e)) { + if (const ReadExpr *re = dyn_cast(e)) { printRead(re, PC, indent); - } else if (const ExtractExpr *ee = dyn_ref_cast(e)) { + } else if (const ExtractExpr *ee = dyn_cast(e)) { printExtract(ee, PC, indent); } else if (e->getKind() == Expr::Concat || e->getKind() == Expr::SExt) printExpr(e.get(), PC, indent, true); diff --git a/lib/Expr/ExprUtil.cpp b/lib/Expr/ExprUtil.cpp index 192c18a5..780398f0 100644 --- a/lib/Expr/ExprUtil.cpp +++ b/lib/Expr/ExprUtil.cpp @@ -35,7 +35,7 @@ void klee::findReads(ref e, ref top = stack.back(); stack.pop_back(); - if (ReadExpr *re = dyn_ref_cast(top)) { + if (ReadExpr *re = dyn_cast(top)) { // We memoized so can just add to list without worrying about // repeats. results.push_back(re); diff --git a/unittests/Expr/ExprTest.cpp b/unittests/Expr/ExprTest.cpp index 84179661..a5e5d5d7 100644 --- a/unittests/Expr/ExprTest.cpp +++ b/unittests/Expr/ExprTest.cpp @@ -58,7 +58,7 @@ TEST(ExprTest, ConcatExtract) { ref extract4 = ExtractExpr::create(concat1, 27, 2); EXPECT_EQ(Expr::Extract, extract4->getKind()); - const ExtractExpr* tmp = dyn_ref_cast(extract4); + const ExtractExpr* tmp = cast(extract4); EXPECT_EQ(3U, tmp->offset); EXPECT_EQ(2U, tmp->getWidth()); -- cgit 1.4.1