retdec
unreachable_code_in_cfg_remover.h
Go to the documentation of this file.
1 /*
2 * @file include/retdec/llvmir2hll/support/unreachable_code_in_cfg_remover.h
3 * @brief Removes code that is unreachable in a CFG.
4 * @copyright (c) 2017 Avast Software, licensed under the MIT license
5 */
6 
7 #ifndef RETDEC_LLVMIR2HLL_SUPPORT_UNREACHABLE_CODE_IN_CFG_REMOVER_H
8 #define RETDEC_LLVMIR2HLL_SUPPORT_UNREACHABLE_CODE_IN_CFG_REMOVER_H
9 
13 
14 namespace retdec {
15 namespace llvmir2hll {
16 
17 class CFG;
18 class CFGBuilder;
19 class Module;
20 
31 public:
32  static void removeCode(ShPtr<Module> module);
33 
34 private:
36 
37  void performRemoval();
39 
43  virtual void visitStmt(ShPtr<Statement> stmt, bool visitSuccessors = true,
44  bool visitNestedStmts = true) override;
46 
47 private:
50 
53 
56 };
57 
58 } // namespace llvmir2hll
59 } // namespace retdec
60 
61 #endif
A visitor that visits everything in an ordered way.
Definition: ordered_all_visitor.h:44
bool visitSuccessors
Should statements' successor be accessed?
Definition: ordered_all_visitor.h:144
virtual void visit(ShPtr< GlobalVarDef > varDef) override
Definition: ordered_all_visitor.cpp:95
bool visitNestedStmts
Should nested statements be accessed?
Definition: ordered_all_visitor.h:147
Removes code that is unreachable in a CFG.
Definition: unreachable_code_in_cfg_remover.h:30
static void removeCode(ShPtr< Module > module)
Removes code from all the functions in module that is unreachable in the CFG.
Definition: unreachable_code_in_cfg_remover.cpp:56
virtual void visitStmt(ShPtr< Statement > stmt, bool visitSuccessors=true, bool visitNestedStmts=true) override
Visits the given statement, and possibly its successors or nested statements.
Definition: unreachable_code_in_cfg_remover.cpp:90
void performRemovalInFunc(ShPtr< Function > func)
Performs the removal of code in the given function.
Definition: unreachable_code_in_cfg_remover.cpp:79
ShPtr< CFG > cfg
The CFG of the current function.
Definition: unreachable_code_in_cfg_remover.h:52
void performRemoval()
Performs the removal of code.
Definition: unreachable_code_in_cfg_remover.cpp:69
UnreachableCodeInCFGRemover(ShPtr< Module > module)
Constructs a new remover.
Definition: unreachable_code_in_cfg_remover.cpp:29
ShPtr< Module > module
Module in which the code is removed.
Definition: unreachable_code_in_cfg_remover.h:49
ShPtr< CFGBuilder > cfgBuilder
The used builder of CFGs.
Definition: unreachable_code_in_cfg_remover.h:55
A mixin to make classes non-copyable.
Definition: non_copyable.h:27
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
A mixin to make classes non-copyable.
A visitor that visits everything in an ordered way.
Declarations, aliases, macros, etc. for the use of smart pointers.