retdec
Static Public Member Functions | Protected Member Functions | List of all members
retdec::llvmir2hll::LibcSemantics Class Reference

Semantics for the standard C library. More...

#include <libc_semantics.h>

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

Public Member Functions

Semantics Interface
virtual std::string getId () const override
 Returns the ID of the semantics. More...
 
virtual std::optional< std::string > getMainFuncName () const override
 Returns the name of the main function. More...
 
virtual std::optional< std::string > getCHeaderFileForFunc (const std::string &funcName) const override
 Returns the C header file for the given function. More...
 
virtual std::optional< bool > funcNeverReturns (const std::string &funcName) const override
 Gets the information whether the given function never returns. More...
 
virtual std::optional< std::string > getNameOfVarStoringResult (const std::string &funcName) const override
 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 override
 Returns an appropriate name of the given function's parameter. More...
 
virtual std::optional< IntStringMapgetSymbolicNamesForParam (const std::string &funcName, unsigned paramPos) const override
 Returns a mapping of integers into their symbolic names for the given parameter of the given function. More...
 
Semantics Interface
- Public Member Functions inherited from retdec::llvmir2hll::Semantics
virtual ~Semantics ()=default
 

Static Public Member Functions

static ShPtr< Semanticscreate ()
 Creates a new semantics. More...
 
- Static Public Member Functions inherited from retdec::llvmir2hll::DefaultSemantics
static ShPtr< Semanticscreate ()
 Creates a new semantics. More...
 

Protected Member Functions

 LibcSemantics ()
 Constructs the semantics. More...
 
- Protected Member Functions inherited from retdec::llvmir2hll::DefaultSemantics
 DefaultSemantics ()
 Constructs the semantics. More...
 
- Protected Member Functions inherited from retdec::llvmir2hll::Semantics
 Semantics ()=default
 

Detailed Description

Semantics for the standard C library.

This class provides the semantics for the standard C library.

Instances of this class have reference object semantics.

Constructor & Destructor Documentation

◆ LibcSemantics()

retdec::llvmir2hll::LibcSemantics::LibcSemantics ( )
protected

Constructs the semantics.

Member Function Documentation

◆ create()

ShPtr< Semantics > retdec::llvmir2hll::LibcSemantics::create ( )
static

Creates a new semantics.

◆ funcNeverReturns()

std::optional< bool > retdec::llvmir2hll::LibcSemantics::funcNeverReturns ( const std::string &  funcName) const
overridevirtual

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".

Reimplemented from retdec::llvmir2hll::DefaultSemantics.

◆ getCHeaderFileForFunc()

std::optional< std::string > retdec::llvmir2hll::LibcSemantics::getCHeaderFileForFunc ( const std::string &  funcName) const
overridevirtual

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".

Reimplemented from retdec::llvmir2hll::DefaultSemantics.

◆ getId()

std::string retdec::llvmir2hll::LibcSemantics::getId ( ) const
overridevirtual

Returns the ID of the semantics.

Reimplemented from retdec::llvmir2hll::DefaultSemantics.

◆ getMainFuncName()

std::optional< std::string > retdec::llvmir2hll::LibcSemantics::getMainFuncName ( ) const
overridevirtual

Returns the name of the main function.

Reimplemented from retdec::llvmir2hll::DefaultSemantics.

◆ getNameOfParam()

std::optional< std::string > retdec::llvmir2hll::LibcSemantics::getNameOfParam ( const std::string &  funcName,
unsigned  paramPos 
) const
overridevirtual

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".

Reimplemented from retdec::llvmir2hll::DefaultSemantics.

◆ getNameOfVarStoringResult()

std::optional< std::string > retdec::llvmir2hll::LibcSemantics::getNameOfVarStoringResult ( const std::string &  funcName) const
overridevirtual

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".

Reimplemented from retdec::llvmir2hll::DefaultSemantics.

◆ getSymbolicNamesForParam()

std::optional< IntStringMap > retdec::llvmir2hll::LibcSemantics::getSymbolicNamesForParam ( const std::string &  funcName,
unsigned  paramPos 
) const
overridevirtual

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.

Reimplemented from retdec::llvmir2hll::DefaultSemantics.


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