retdec
api_call_info.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_PATTERN_PATTERN_FINDERS_API_CALL_API_CALL_INFO_H
8 #define RETDEC_LLVMIR2HLL_PATTERN_PATTERN_FINDERS_API_CALL_API_CALL_INFO_H
9 
10 #include <map>
11 #include <string>
12 
14 
15 namespace retdec {
16 namespace llvmir2hll {
17 
23 class APICallInfo {
24 public:
27  using ParamNum = unsigned;
28 
30  using ParamBindMap = std::map<ParamNum, std::string>;
31 
36  using param_bind_iterator = ParamBindMap::const_iterator;
37 
38 public:
39  APICallInfo(std::string funcName);
40 
41  // The compiler-generated destructor, copy constructor and assignment
42  // operator are just fine, so we don't have to create our own ones.
43 
44  bool operator==(const APICallInfo &other) const;
45  bool operator!=(const APICallInfo &other) const;
46 
49  const std::string getFuncName() const;
51 
54  APICallInfo &bindReturnValue(const std::string &bindId);
55  bool hasBoundReturnValue() const;
56  std::string getReturnValueBind() const;
58 
61  APICallInfo &bindParam(ParamNum n, const std::string &bindId);
62  bool hasBoundParam(ParamNum n) const;
63  std::string getParamBind(ParamNum n) const;
64 
68 
69 private:
71  std::string funcName;
72 
74  std::string returnValueBind;
75 
79 };
80 
81 } // namespace llvmir2hll
82 } // namespace retdec
83 
84 #endif
A representation of information about an API call.
Definition: api_call_info.h:23
bool hasBoundParam(ParamNum n) const
Returns true if parameter number n has been bound to some ID, false otherwise.
Definition: api_call_info.cpp:135
std::string getParamBind(ParamNum n) const
Returns the ID of the bind to the given parameter.
Definition: api_call_info.cpp:154
param_bind_iterator param_bind_end() const
Returns an iterator past the last parameter bind.
Definition: api_call_info.cpp:171
APICallInfo & bindReturnValue(const std::string &bindId)
Binds bindId to the return value.
Definition: api_call_info.cpp:69
param_bind_iterator param_bind_begin() const
Returns an iterator to the first parameter bind.
Definition: api_call_info.cpp:164
bool hasBoundReturnValue() const
Returns true if the return value has been bound to some ID, false otherwise.
Definition: api_call_info.cpp:80
std::string funcName
Name of the function.
Definition: api_call_info.h:71
std::map< ParamNum, std::string > ParamBindMap
Mapping of a parameter number into a bind ID.
Definition: api_call_info.h:30
unsigned ParamNum
Definition: api_call_info.h:27
const std::string getFuncName() const
Returns the name of the function that this API call information describes.
Definition: api_call_info.cpp:49
APICallInfo & bindParam(ParamNum n, const std::string &bindId)
Binds bindId to the given parameter.
Definition: api_call_info.cpp:117
std::string getReturnValueBind() const
Returns the ID of the bind to the return value.
Definition: api_call_info.cpp:90
std::string returnValueBind
ID of the bind to the return value. If there is no bind, it is empty.
Definition: api_call_info.h:74
ParamBindMap paramBinds
Definition: api_call_info.h:78
APICallInfo(std::string funcName)
Constructs an API call information for a function named funcName.
Definition: api_call_info.cpp:24
bool operator==(const APICallInfo &other) const
Returns true if this info is equal to other, false otherwise.
Definition: api_call_info.cpp:31
bool operator!=(const APICallInfo &other) const
Returns true if this info is not equal to other, false otherwise.
Definition: api_call_info.cpp:41
ParamBindMap::const_iterator param_bind_iterator
Definition: api_call_info.h:36
A library providing API for working with back-end IR.
Definition: archive_wrapper.h:19
Aliases for several useful types.