retdec
Namespaces | Macros | Typedefs | Functions
get_symbolic_names_for_param.h File Reference

Support for implementing the getSymbolicNamesForParam semantics. More...

#include <map>
#include <optional>
#include <unordered_map>
#include "retdec/llvmir2hll/support/types.h"

Go to the source code of this file.

Namespaces

 retdec
 
 retdec::llvmir2hll
 
 retdec::llvmir2hll::semantics
 Implementation of semantics.
 

Macros

#define DEFINE_GET_SYMBOLIC_NAMES_FUNC_BEGIN(funcName)
 Starts a definition of a getSymbolicNamesFor() function. More...
 
#define DEFINE_GET_SYMBOLIC_NAMES_FUNC_END()
 The ending part of DEFINE_GET_SYMBOLIC_NAMES_FUNC_BEGIN. More...
 

Typedefs

using retdec::llvmir2hll::semantics::ParamSymbolsMap = std::map< unsigned, IntStringMap >
 Mapping of a parameter position into symbolic names of its possible values. More...
 
using retdec::llvmir2hll::semantics::FuncParamsMap = std::unordered_map< std::string, ParamSymbolsMap >
 Mapping of a function name into ParamSymbolsMap. More...
 

Functions

std::optional< IntStringMap > retdec::llvmir2hll::semantics::getSymbolicNamesForParamFromMap (const std::string &funcName, unsigned paramPos, const FuncParamsMap &map)
 Returns symbolic names for the given parameter from the given map. More...
 

Detailed Description

Support for implementing the getSymbolicNamesForParam semantics.

Macro Definition Documentation

◆ DEFINE_GET_SYMBOLIC_NAMES_FUNC_BEGIN

#define DEFINE_GET_SYMBOLIC_NAMES_FUNC_BEGIN (   funcName)
Value:
const IntStringMap &funcName() { \
static IntStringMap symbolicNamesMap; \
if (!symbolicNamesMap.empty()) { \
return symbolicNamesMap; \
}
std::map< std::int64_t, std::string > IntStringMap
Mapping of a 64b int into a string.
Definition: types.h:135

Starts a definition of a getSymbolicNamesFor() function.

Such a function can be used to provide the creation of symbolicNamesMap for a specific set of names, like signal numbers or error numbers. In this way, the names can be aggregated on a single place and not copy&pasted to every place they are needed (error(), error_at_line(), etc).

The created function ensures that the map is filled at most once (upon the first call). Therefore, when you call the function for the second time, the already filled map is returned without filling the map again with the same data.

Important Note

Every use of this macro has to be ended with DEFINE_GET_SYMBOLIC_NAMES_FUNC_END.

Usage Example
DEFINE_GET_SYMBOLIC_NAMES_FUNC_BEGIN(getSymbolicNamesForSignalHandlers)
// Info from: <sys/signal.h>
symbolicNamesMap[0] = "SIG_DFL";
symbolicNamesMap[1] = "SIG_IGN";
// ...
paramSymbolsMap[2] = getSymbolicNamesForSignalHandlers();
#define DEFINE_GET_SYMBOLIC_NAMES_FUNC_END()
The ending part of DEFINE_GET_SYMBOLIC_NAMES_FUNC_BEGIN.
Definition: get_symbolic_names_for_param.h:59
#define DEFINE_GET_SYMBOLIC_NAMES_FUNC_BEGIN(funcName)
Starts a definition of a getSymbolicNamesFor() function.
Definition: get_symbolic_names_for_param.h:47

◆ DEFINE_GET_SYMBOLIC_NAMES_FUNC_END

#define DEFINE_GET_SYMBOLIC_NAMES_FUNC_END ( )
Value:
return symbolicNamesMap; \
}

The ending part of DEFINE_GET_SYMBOLIC_NAMES_FUNC_BEGIN.

See also
DEFINE_GET_SYMBOLIC_NAMES_FUNC_BEGIN