retdec
Public Member Functions | Protected Member Functions | List of all members
retdec::llvmir2hll::Semantics Class Referenceabstract

A base class for all descriptions of function semantics. More...

#include <semantics.h>

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

Public Member Functions

virtual ~Semantics ()=default
 
virtual std::string getId () const =0
 Returns the ID of the semantics. More...
 
virtual std::optional< std::string > getMainFuncName () const =0
 Returns the name of the main function. More...
 
virtual std::optional< std::string > getCHeaderFileForFunc (const std::string &funcName) const =0
 Returns the C header file for the given function. More...
 
virtual std::optional< bool > funcNeverReturns (const std::string &funcName) const =0
 Gets the information whether the given function never returns. More...
 
virtual std::optional< std::string > getNameOfVarStoringResult (const std::string &funcName) const =0
 Returns an appropriate name of the variable that stores the result of calls to the given function. More...
 
virtual std::optional< std::string > getNameOfParam (const std::string &funcName, unsigned paramPos) const =0
 Returns an appropriate name of the given function's parameter. More...
 
virtual std::optional< IntStringMapgetSymbolicNamesForParam (const std::string &funcName, unsigned paramPos) const =0
 Returns a mapping of integers into their symbolic names for the given parameter of the given function. More...
 

Protected Member Functions

 Semantics ()=default
 

Additional Inherited Members

- 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 for all descriptions of function semantics.

This class should be used as a base class for all semantics.

To implement a new semantics, you should:

Instances of this class have reference object semantics.

Constructor & Destructor Documentation

◆ ~Semantics()

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

◆ Semantics()

retdec::llvmir2hll::Semantics::Semantics ( )
protecteddefault

Member Function Documentation

◆ funcNeverReturns()

virtual std::optional<bool> retdec::llvmir2hll::Semantics::funcNeverReturns ( const std::string &  funcName) const
pure virtual

Gets the information whether the given function never returns.

Returns
true if the given function never returns, false if the function may return, and std::nullopt otherwise.
Parameters
[in]funcNameName of the function.

For example, semantics describing the standard C library may return true for "exit".

Implemented in retdec::llvmir2hll::WinAPISemantics, retdec::llvmir2hll::LibcSemantics, retdec::llvmir2hll::DefaultSemantics, and retdec::llvmir2hll::CompoundSemantics.

◆ getCHeaderFileForFunc()

virtual std::optional<std::string> retdec::llvmir2hll::Semantics::getCHeaderFileForFunc ( const std::string &  funcName) const
pure virtual

Returns the C header file for the given function.

Returns
"file" if the header file is known, std::nullopt otherwise.
Parameters
[in]funcNameName of the function.

For example, semantics describing the standard C library may return "stdio.h" for "printf".

Implemented in retdec::llvmir2hll::WinAPISemantics, retdec::llvmir2hll::LibcSemantics, retdec::llvmir2hll::GCCGeneralSemantics, retdec::llvmir2hll::DefaultSemantics, and retdec::llvmir2hll::CompoundSemantics.

◆ getId()

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

◆ getMainFuncName()

virtual std::optional<std::string> retdec::llvmir2hll::Semantics::getMainFuncName ( ) const
pure virtual

◆ getNameOfParam()

virtual std::optional<std::string> retdec::llvmir2hll::Semantics::getNameOfParam ( const std::string &  funcName,
unsigned  paramPos 
) const
pure virtual

Returns an appropriate name of the given function's parameter.

Returns
"name" if the name is known, std::nullopt otherwise.
Parameters
[in]funcNameName of the function.
[in]paramPosPosition of the parameter.

For example, semantics describing the standard C library may return "file_path" for the first parameter of "fopen".

Implemented in retdec::llvmir2hll::WinAPISemantics, retdec::llvmir2hll::LibcSemantics, retdec::llvmir2hll::GCCGeneralSemantics, retdec::llvmir2hll::DefaultSemantics, and retdec::llvmir2hll::CompoundSemantics.

◆ getNameOfVarStoringResult()

virtual std::optional<std::string> retdec::llvmir2hll::Semantics::getNameOfVarStoringResult ( const std::string &  funcName) const
pure virtual

Returns an appropriate name of the variable that stores the result of calls to the given function.

Returns
"name" if the name is known, std::nullopt otherwise.
Parameters
[in]funcNameName of the function.

For example, semantics describing the standard C library may return "c" for "getchar".

Implemented in retdec::llvmir2hll::WinAPISemantics, retdec::llvmir2hll::LibcSemantics, retdec::llvmir2hll::GCCGeneralSemantics, retdec::llvmir2hll::DefaultSemantics, and retdec::llvmir2hll::CompoundSemantics.

◆ getSymbolicNamesForParam()

virtual std::optional<IntStringMap> retdec::llvmir2hll::Semantics::getSymbolicNamesForParam ( const std::string &  funcName,
unsigned  paramPos 
) const
pure virtual

Returns a mapping of integers into their symbolic names for the given parameter of the given function.

Returns
map if the mapping is known, std::nullopt otherwise.
Parameters
[in]funcNameName of the function.
[in]paramPosPosition of the parameter.

For example, a semantics may return

1 -> LOCK_SH
2 -> LOCK_EX
4 -> LOCK_NB
8 -> LOCK_UN

for "flock" and 2.

Implemented in retdec::llvmir2hll::WinAPISemantics, retdec::llvmir2hll::LibcSemantics, retdec::llvmir2hll::GCCGeneralSemantics, retdec::llvmir2hll::DefaultSemantics, and retdec::llvmir2hll::CompoundSemantics.


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