retdec
return_stmt.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_IR_RETURN_STMT_H
8 #define RETDEC_LLVMIR2HLL_IR_RETURN_STMT_H
9 
12 
13 namespace retdec {
14 namespace llvmir2hll {
15 
16 class Expression;
17 class Visitor;
18 
25 class ReturnStmt final: public Statement {
26 public:
29 
30  virtual ShPtr<Value> clone() override;
31  virtual bool isEqualTo(ShPtr<Value> otherValue) const override;
32  virtual bool isCompound() override { return false; }
33  virtual void replace(ShPtr<Expression> oldExpr, ShPtr<Expression> newExpr) override;
34  virtual ShPtr<Expression> asExpression() const override;
35 
37  void setRetVal(ShPtr<Expression> newRetVal);
38  bool hasRetVal() const;
39 
42  virtual void update(ShPtr<Value> subject, ShPtr<Value> arg = nullptr) override;
44 
47  virtual void accept(Visitor *v) override;
49 
50 private:
51  // Since instances are created by calling the static function create(), the
52  // constructor can be private.
53  explicit ReturnStmt(ShPtr<Expression> retVal = nullptr,
55 
56 private:
59 };
60 
61 } // namespace llvmir2hll
62 } // namespace retdec
63 
64 #endif
Definition: address.h:21
static const uint64_t Undefined
Definition: address.h:47
A return statement.
Definition: return_stmt.h:25
virtual bool isEqualTo(ShPtr< Value > otherValue) const override
Returns true if this value is equal to otherValue, false otherwise.
Definition: return_stmt.cpp:34
virtual void accept(Visitor *v) override
Visitor pattern implementation.
Definition: return_stmt.cpp:140
virtual void update(ShPtr< Value > subject, ShPtr< Value > arg=nullptr) override
Updates the statement according to the changes of subject.
Definition: return_stmt.cpp:131
ReturnStmt(ShPtr< Expression > retVal=nullptr, Address a=Address::Undefined)
Constructs a new return statement.
Definition: return_stmt.cpp:21
void setRetVal(ShPtr< Expression > newRetVal)
Sets a new return value.
Definition: return_stmt.cpp:75
virtual ShPtr< Expression > asExpression() const override
Returns the statement as an expression.
Definition: return_stmt.cpp:55
virtual bool isCompound() override
Returns true if the statement is a compound statement, false otherwise.
Definition: return_stmt.h:32
virtual ShPtr< Value > clone() override
Returns a clone of the value.
Definition: return_stmt.cpp:24
static ShPtr< ReturnStmt > create(ShPtr< Expression > retVal=nullptr, ShPtr< Statement > succ=nullptr, Address a=Address::Undefined)
Creates a new return statement.
Definition: return_stmt.cpp:100
ShPtr< Expression > retVal
Return value.
Definition: return_stmt.h:58
virtual void replace(ShPtr< Expression > oldExpr, ShPtr< Expression > newExpr) override
Replaces all occurrences of oldExpr with newExpr in the current statement.
Definition: return_stmt.cpp:47
bool hasRetVal() const
Returns true if the return statement has return value, false otherwise.
Definition: return_stmt.cpp:89
ShPtr< Expression > getRetVal() const
Returns the return value.
Definition: return_stmt.cpp:63
A representation of a program statement.
Definition: statement.h:39
ShPtr< Statement > succ
Successor statement.
Definition: statement.h:141
A base class of all visitors.
Definition: visitor.h:95
A library providing API for working with back-end IR.
std::shared_ptr< T > ShPtr
An alias for a shared pointer.
Definition: smart_ptr.h:18
Definition: archive_wrapper.h:19
Declarations, aliases, macros, etc. for the use of smart pointers.
A representation of a program statement.