retdec
Classes | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
retdec::llvmir2hll::CallInfoObtainer Class Referenceabstract

A base class of all obtainers of information about functions and function calls. More...

#include <call_info_obtainer.h>

Inheritance diagram for retdec::llvmir2hll::CallInfoObtainer:
Inheritance graph
[legend]
Collaboration diagram for retdec::llvmir2hll::CallInfoObtainer:
Collaboration graph
[legend]

Classes

class  FuncInfoCompOrder
 Represents an order in which FuncInfos should be computed. More...
 
class  SCCComputer
 A computation of strongly connected components (SCCs) from a call graph. More...
 
struct  SCCWithRepresent
 An SCC with a represent. More...
 

Public Member Functions

virtual ~CallInfoObtainer ()=default
 
ShPtr< CGgetCG () const
 Returns the call graph with which the obtainer has been initialized. More...
 
ShPtr< CFGgetCFGForFunc (ShPtr< Function > func) const
 Returns the CFG for func after the obtainer has been initialized. More...
 
virtual void init (ShPtr< CG > cg, ShPtr< ValueAnalysis > va)
 Initializes the obtainer. More...
 
virtual bool isInitialized () const
 Returns true if the obtainer has been initialized, false otherwise. More...
 
virtual std::string getId () const =0
 Returns the ID of the obtainer. More...
 
virtual ShPtr< CallInfogetCallInfo (ShPtr< CallExpr > call, ShPtr< Function > caller)=0
 Computes and returns information about the given function call which occurs in caller. More...
 
virtual ShPtr< FuncInfogetFuncInfo (ShPtr< Function > func)=0
 Computes and returns information about the given function. More...
 

Protected Types

using FuncVectorSet = std::vector< FuncSet >
 Vector of sets of functions. More...
 
using FuncCFGMap = std::map< ShPtr< Function >, ShPtr< CFG > >
 Mapping of a function into its CFG. More...
 

Protected Member Functions

 CallInfoObtainer ()
 Constructs a new obtainer. More...
 
ShPtr< FuncInfoCompOrdergetFuncInfoCompOrder (ShPtr< CG > cg)
 Computes an order in which FuncInfos should be computed. More...
 

Protected Attributes

ShPtr< Modulemodule
 The current module. More...
 
ShPtr< CGcg
 Call graph of the current module. More...
 
ShPtr< ValueAnalysisva
 Analysis of values. More...
 
FuncCFGMap funcCFGMap
 Mapping of a function into its CFG. More...
 
ShPtr< CFGBuildercfgBuilder
 The used builder of CFGs. More...
 

Private Member Functions

FuncVectorSet computeSCCs ()
 Computes all SCCs in the current call graph and returns them. More...
 
bool callsJustComputedFuncs (ShPtr< Function > func, const FuncSet &computedFuncs) const
 Returns true if func calls just functions from computedFuncs, false otherwise. More...
 
SCCWithRepresent findNextSCC (const FuncVectorSet &sccs, const FuncSet &computedFuncs, const FuncSet &remainingFuncs) const
 Finds a next SCC and its represent and returns them. More...
 
- Private Member Functions inherited from retdec::utils::NonCopyable
 NonCopyable (const NonCopyable &)=delete
 
NonCopyableoperator= (const NonCopyable &)=delete
 
 NonCopyable ()=default
 
 ~NonCopyable ()=default
 

Detailed Description

A base class of all obtainers of information about functions and function calls.

Every function call information obtainer should subclass this class and override getCallInfo() and getFuncInfo(). Furthermore, also CallInfo should be subclassed and this subclass should have the concrete obtainer as a friend so it can set its values (remember that in C++, friendship is not inherited). If the obtainer overrides init(), then it has to call CallInfoObtainer::init().

Every time an instance of this class (or its subclass) is created or the underlying module is changed in a way that affects the call graph, the init() member function has to be called.

Instances of this class have reference object semantics.

Member Typedef Documentation

◆ FuncCFGMap

Mapping of a function into its CFG.

◆ FuncVectorSet

Vector of sets of functions.

Constructor & Destructor Documentation

◆ ~CallInfoObtainer()

virtual retdec::llvmir2hll::CallInfoObtainer::~CallInfoObtainer ( )
virtualdefault

◆ CallInfoObtainer()

retdec::llvmir2hll::CallInfoObtainer::CallInfoObtainer ( )
protected

Constructs a new obtainer.

Member Function Documentation

◆ callsJustComputedFuncs()

bool retdec::llvmir2hll::CallInfoObtainer::callsJustComputedFuncs ( ShPtr< Function func,
const FuncSet computedFuncs 
) const
private

Returns true if func calls just functions from computedFuncs, false otherwise.

◆ computeSCCs()

CallInfoObtainer::FuncVectorSet retdec::llvmir2hll::CallInfoObtainer::computeSCCs ( )
private

Computes all SCCs in the current call graph and returns them.

A single function is not considered to be an SCC unless it contains a call to itself (see the description of FuncInfoCompOrder).

◆ findNextSCC()

CallInfoObtainer::SCCWithRepresent retdec::llvmir2hll::CallInfoObtainer::findNextSCC ( const FuncVectorSet sccs,
const FuncSet computedFuncs,
const FuncSet remainingFuncs 
) const
private

Finds a next SCC and its represent and returns them.

Parameters
[in]sccsAll SCCs in the call graph.
[in]computedFuncsFunctions that already have been included in FuncInfoCompOrder::order.
[in]remainingFuncsFunctions that haven't been included in FuncInfoCompOrder::order.
Preconditions
  • remainingFuncs is non-empty
  • remainingFuncs doesn't contain a function which calls just functions from computedFuncs.

◆ getCallInfo()

virtual ShPtr<CallInfo> retdec::llvmir2hll::CallInfoObtainer::getCallInfo ( ShPtr< CallExpr call,
ShPtr< Function caller 
)
pure virtual

Computes and returns information about the given function call which occurs in caller.

Preconditions
  • the call obtainer has been initialized using init()
  • the given call and caller exist in the module

Implemented in retdec::llvmir2hll::PessimCallInfoObtainer, and retdec::llvmir2hll::OptimCallInfoObtainer.

◆ getCFGForFunc()

ShPtr< CFG > retdec::llvmir2hll::CallInfoObtainer::getCFGForFunc ( ShPtr< Function func) const

Returns the CFG for func after the obtainer has been initialized.

If the obtainer hasn't been initialized or there is no CFG for func, it returns the null pointer.

◆ getCG()

ShPtr< CG > retdec::llvmir2hll::CallInfoObtainer::getCG ( ) const

Returns the call graph with which the obtainer has been initialized.

If the obtainer hasn't been initialized, this function returns the null pointer.

◆ getFuncInfo()

virtual ShPtr<FuncInfo> retdec::llvmir2hll::CallInfoObtainer::getFuncInfo ( ShPtr< Function func)
pure virtual

Computes and returns information about the given function.

Preconditions
  • the call obtainer has been initialized using init()
  • the given function exists in the module

Implemented in retdec::llvmir2hll::PessimCallInfoObtainer, and retdec::llvmir2hll::OptimCallInfoObtainer.

◆ getFuncInfoCompOrder()

ShPtr< CallInfoObtainer::FuncInfoCompOrder > retdec::llvmir2hll::CallInfoObtainer::getFuncInfoCompOrder ( ShPtr< CG cg)
protected

Computes an order in which FuncInfos should be computed.

See the description of FuncInfoCompOrder for some more information.

◆ getId()

virtual std::string retdec::llvmir2hll::CallInfoObtainer::getId ( ) const
pure virtual

Returns the ID of the obtainer.

Implemented in retdec::llvmir2hll::PessimCallInfoObtainer, and retdec::llvmir2hll::OptimCallInfoObtainer.

◆ init()

void retdec::llvmir2hll::CallInfoObtainer::init ( ShPtr< CG cg,
ShPtr< ValueAnalysis va 
)
virtual

Initializes the obtainer.

Parameters
[in]cgThe obtainer will be initialized with this call graph.
[in]vaThe used analysis of values.

This member function has to be called (1) when an instance of this class (or its subclass) is created and (2) whenever the current module is changed in a way that changes the call graph of the module and/or the variables which are read/modified in a function.

Preconditions
  • both va and cg are non-null
  • va is in a valid state

This function leaves va in a valid state.

Reimplemented in retdec::llvmir2hll::OptimCallInfoObtainer.

◆ isInitialized()

bool retdec::llvmir2hll::CallInfoObtainer::isInitialized ( ) const
virtual

Returns true if the obtainer has been initialized, false otherwise.

Member Data Documentation

◆ cfgBuilder

ShPtr<CFGBuilder> retdec::llvmir2hll::CallInfoObtainer::cfgBuilder
protected

The used builder of CFGs.

◆ cg

ShPtr<CG> retdec::llvmir2hll::CallInfoObtainer::cg
protected

Call graph of the current module.

◆ funcCFGMap

FuncCFGMap retdec::llvmir2hll::CallInfoObtainer::funcCFGMap
protected

Mapping of a function into its CFG.

◆ module

ShPtr<Module> retdec::llvmir2hll::CallInfoObtainer::module
protected

The current module.

◆ va

ShPtr<ValueAnalysis> retdec::llvmir2hll::CallInfoObtainer::va
protected

Analysis of values.


The documentation for this class was generated from the following files: