retdec
stmts_pattern.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_PATTERN_PATTERNS_STMTS_PATTERN_H
8 #define RETDEC_LLVMIR2HLL_PATTERN_PATTERNS_STMTS_PATTERN_H
9 
13 
14 namespace retdec {
15 namespace llvmir2hll {
16 
17 class Function;
18 
24 class StmtsPattern: public Pattern {
25 public:
27  using stmt_iterator = StmtVector::const_iterator;
28 
29 public:
30  virtual void print(llvm::raw_ostream &os,
31  const std::string &indentation = "") const override;
32 
35  bool isEmpty() const;
36  void addStmt(ShPtr<Statement> stmt);
37  StmtVector::size_type getNumOfStmts() const;
38  stmt_iterator stmt_begin() const;
39  stmt_iterator stmt_end() const;
41 
42  static ShPtr<StmtsPattern> create();
44 
45 protected:
46  StmtsPattern();
47  explicit StmtsPattern(ShPtr<Statement> stmt);
48 
49 protected:
52 };
53 
54 } // namespace llvmir2hll
55 } // namespace retdec
56 
57 #endif
A base class for representing code patterns.
Definition: pattern.h:25
A pattern that is composed of zero or more statements.
Definition: stmts_pattern.h:24
stmt_iterator stmt_end() const
Returns an iterator past the last statement in the pattern.
Definition: stmts_pattern.cpp:76
static ShPtr< StmtsPattern > create()
Creates an empty pattern.
Definition: stmts_pattern.cpp:83
StmtsPattern()
Constructs an empty pattern.
Definition: stmts_pattern.cpp:16
stmt_iterator stmt_begin() const
Returns an iterator to the first statement in the pattern.
Definition: stmts_pattern.cpp:66
StmtVector stmts
Statements that form the pattern.
Definition: stmts_pattern.h:51
bool isEmpty() const
Returns true if the pattern is empty, false otherwise.
Definition: stmts_pattern.cpp:39
virtual void print(llvm::raw_ostream &os, const std::string &indentation="") const override
Prints the pattern to stream os, each line indented with indentation.
Definition: stmts_pattern.cpp:25
void addStmt(ShPtr< Statement > stmt)
Adds a new statement into the pattern.
Definition: stmts_pattern.cpp:49
StmtVector::const_iterator stmt_iterator
Iterator over statements.
Definition: stmts_pattern.h:27
StmtVector::size_type getNumOfStmts() const
Returns the number of statements in the pattern.
Definition: stmts_pattern.cpp:56
A base class for representing code patterns.
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
std::vector< ShPtr< Statement > > StmtVector
Vector of statements.
Definition: types.h:96
Definition: archive_wrapper.h:19
Declarations, aliases, macros, etc. for the use of smart pointers.
Aliases for several useful types.