klee
ExprVisitor.h
Go to the documentation of this file.
1//===-- ExprVisitor.h -------------------------------------------*- C++ -*-===//
2//
3// The KLEE Symbolic Virtual Machine
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef KLEE_EXPRVISITOR_H
11#define KLEE_EXPRVISITOR_H
12
13#include "ExprHashMap.h"
14
15namespace klee {
17 protected:
18 // typed variant, but non-virtual for efficiency
19 class Action {
20 public:
22
23 private:
24 // Action() {}
25 Action(Kind _kind)
26 : kind(_kind), argument(nullptr) {}
27 Action(Kind _kind, const ref<Expr> &_argument)
28 : kind(_kind), argument(_argument) {}
29
30 friend class ExprVisitor;
31
32 public:
35
36 static Action changeTo(const ref<Expr> &expr) {
37 return Action(ChangeTo,expr);
38 }
39 static Action doChildren() { return Action(DoChildren); }
40 static Action skipChildren() { return Action(SkipChildren); }
41 };
42
43 protected:
44 explicit
45 ExprVisitor(bool _recursive=false) : recursive(_recursive) {}
46 virtual ~ExprVisitor() {}
47
48 virtual Action visitExpr(const Expr&);
49 virtual Action visitExprPost(const Expr&);
50
51 virtual Action visitNotOptimized(const NotOptimizedExpr&);
52 virtual Action visitRead(const ReadExpr&);
53 virtual Action visitSelect(const SelectExpr&);
54 virtual Action visitConcat(const ConcatExpr&);
55 virtual Action visitExtract(const ExtractExpr&);
56 virtual Action visitZExt(const ZExtExpr&);
57 virtual Action visitSExt(const SExtExpr&);
58 virtual Action visitAdd(const AddExpr&);
59 virtual Action visitSub(const SubExpr&);
60 virtual Action visitMul(const MulExpr&);
61 virtual Action visitUDiv(const UDivExpr&);
62 virtual Action visitSDiv(const SDivExpr&);
63 virtual Action visitURem(const URemExpr&);
64 virtual Action visitSRem(const SRemExpr&);
65 virtual Action visitNot(const NotExpr&);
66 virtual Action visitAnd(const AndExpr&);
67 virtual Action visitOr(const OrExpr&);
68 virtual Action visitXor(const XorExpr&);
69 virtual Action visitShl(const ShlExpr&);
70 virtual Action visitLShr(const LShrExpr&);
71 virtual Action visitAShr(const AShrExpr&);
72 virtual Action visitEq(const EqExpr&);
73 virtual Action visitNe(const NeExpr&);
74 virtual Action visitUlt(const UltExpr&);
75 virtual Action visitUle(const UleExpr&);
76 virtual Action visitUgt(const UgtExpr&);
77 virtual Action visitUge(const UgeExpr&);
78 virtual Action visitSlt(const SltExpr&);
79 virtual Action visitSle(const SleExpr&);
80 virtual Action visitSgt(const SgtExpr&);
81 virtual Action visitSge(const SgeExpr&);
82
83 private:
87
89
90 public:
91 // apply the visitor to the expression and return a possibly
92 // modified new expression.
93 ref<Expr> visit(const ref<Expr> &e);
94 };
95
96}
97
98#endif /* KLEE_EXPRVISITOR_H */
static Action changeTo(const ref< Expr > &expr)
Definition: ExprVisitor.h:36
Action(Kind _kind, const ref< Expr > &_argument)
Definition: ExprVisitor.h:27
static Action doChildren()
Definition: ExprVisitor.h:39
static Action skipChildren()
Definition: ExprVisitor.h:40
virtual Action visitUle(const UleExpr &)
virtual Action visitUge(const UgeExpr &)
virtual Action visitZExt(const ZExtExpr &)
ref< Expr > visit(const ref< Expr > &e)
Definition: ExprVisitor.cpp:26
virtual Action visitOr(const OrExpr &)
virtual Action visitSge(const SgeExpr &)
virtual Action visitNotOptimized(const NotOptimizedExpr &)
virtual Action visitSRem(const SRemExpr &)
virtual Action visitRead(const ReadExpr &)
virtual Action visitMul(const MulExpr &)
ref< Expr > visitActual(const ref< Expr > &e)
Definition: ExprVisitor.cpp:42
virtual Action visitSub(const SubExpr &)
virtual Action visitSExt(const SExtExpr &)
visited_ty visited
Definition: ExprVisitor.h:85
virtual Action visitURem(const URemExpr &)
virtual Action visitSlt(const SltExpr &)
virtual Action visitEq(const EqExpr &)
virtual Action visitSDiv(const SDivExpr &)
virtual Action visitAShr(const AShrExpr &)
virtual Action visitSgt(const SgtExpr &)
ExprVisitor(bool _recursive=false)
Definition: ExprVisitor.h:45
virtual Action visitAdd(const AddExpr &)
virtual Action visitXor(const XorExpr &)
virtual Action visitAnd(const AndExpr &)
virtual Action visitExprPost(const Expr &)
ExprHashMap< ref< Expr > > visited_ty
Definition: ExprVisitor.h:84
virtual Action visitExpr(const Expr &)
virtual Action visitExtract(const ExtractExpr &)
virtual Action visitLShr(const LShrExpr &)
virtual Action visitShl(const ShlExpr &)
virtual Action visitUlt(const UltExpr &)
virtual Action visitSle(const SleExpr &)
virtual Action visitConcat(const ConcatExpr &)
virtual Action visitNot(const NotExpr &)
virtual ~ExprVisitor()
Definition: ExprVisitor.h:46
virtual Action visitNe(const NeExpr &)
virtual Action visitUgt(const UgtExpr &)
virtual Action visitSelect(const SelectExpr &)
virtual Action visitUDiv(const UDivExpr &)
Class representing symbolic expressions.
Definition: Expr.h:91
Class representing a one byte read from an array.
Definition: Expr.h:565
Class representing an if-then-else expression.
Definition: Expr.h:610
Definition: main.cpp:291