retdec
cg.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_GRAPHS_CG_CG_H
8 #define RETDEC_LLVMIR2HLL_GRAPHS_CG_CG_H
9 
10 #include <map>
11 
15 
16 namespace retdec {
17 namespace llvmir2hll {
18 
19 class Function;
20 class Module;
21 
35 class CG final: private retdec::utils::NonCopyable {
36  friend class CGBuilder;
37 
38 public:
42  class CalledFuncs {
43  public:
45  bool callsOnlyDefinedFuncs = true,
46  bool callsByPointer = false);
47 
48  public:
52 
56 
61 
66  };
67 
69  using CallerCalleeMap = std::map<ShPtr<Function>, ShPtr<CalledFuncs>>;
70 
72  using caller_iterator = CallerCalleeMap::const_iterator;
73 
74 public:
77  bool includeIndirectCalls = false) const;
78 
84 
85 private:
87 
89 
90 private:
93 
96 };
97 
98 } // namespace llvmir2hll
99 } // namespace retdec
100 
101 #endif
A creator of call graphs (CGs) from modules.
Definition: cg_builder.h:26
Information about called functions from a caller.
Definition: cg.h:42
ShPtr< Function > caller
Definition: cg.h:51
FuncSet callees
Definition: cg.h:55
bool callsByPointer
Definition: cg.h:65
CalledFuncs(ShPtr< Function > caller, bool callsOnlyDefinedFuncs=true, bool callsByPointer=false)
Constructs a new information about called functions.
Definition: cg.cpp:26
bool callsOnlyDefinedFuncs
Definition: cg.h:60
A representation of a call graph (CG).
Definition: cg.h:35
ShPtr< Module > getCorrespondingModule() const
Returns the module for which this call graph has been created.
Definition: cg.cpp:41
ShPtr< CalledFuncs > getCalledFuncs(ShPtr< Function > func, bool includeIndirectCalls=false) const
Returns called functions from the given function.
Definition: cg.cpp:60
ShPtr< Module > module
Module for which this call graph has been created.
Definition: cg.h:92
caller_iterator caller_end() const
Returns an iterator past the last caller.
Definition: cg.cpp:133
CG(ShPtr< Module > module)
Constructs a new call graph.
Definition: cg.cpp:36
CallerCalleeMap callerCalleeMap
Mapping of a caller into callees.
Definition: cg.h:95
caller_iterator caller_begin() const
Returns an iterator to the first caller.
Definition: cg.cpp:126
CallerCalleeMap::const_iterator caller_iterator
Callers iterator.
Definition: cg.h:72
ShPtr< CalledFuncs > computeIndirectCalls(ShPtr< CalledFuncs > calledFuncs) const
Computes indirect calls from the given called functions.
Definition: cg.cpp:80
std::map< ShPtr< Function >, ShPtr< CalledFuncs > > CallerCalleeMap
Mapping of a caller into callees.
Definition: cg.h:69
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
std::set< ShPtr< Function > > FuncSet
Set of functions.
Definition: types.h:78
Definition: archive_wrapper.h:19
A mixin to make classes non-copyable.
Declarations, aliases, macros, etc. for the use of smart pointers.
Aliases for several useful types.