retdec
api_call_seq_data.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_PATTERN_PATTERN_FINDERS_API_CALL_API_CALL_SEQ_DATA_H
8 #define RETDEC_LLVMIR2HLL_PATTERN_PATTERN_FINDERS_API_CALL_API_CALL_SEQ_DATA_H
9 
12 
13 namespace retdec {
14 namespace llvmir2hll {
15 
16 class Pattern;
17 class Statement;
18 class StmtsPattern;
19 
24 public:
25  APICallSeqData(const APICallInfoSeq &info);
26 
27  // The compiler-generated destructor is just fine, so we don't have to
28  // create our own one.
29 
30  APICallSeqData(const APICallSeqData &data);
32 
33  bool operator==(const APICallSeqData &other) const;
34  bool operator!=(const APICallSeqData &other) const;
35 
36  bool matches(ShPtr<CallExpr> call) const;
37  void apply(ShPtr<Statement> stmt, ShPtr<CallExpr> call);
38  bool patternIsComplete() const;
39  ShPtr<Pattern> getPattern() const;
40  bool atEnd() const;
41 
42 private:
44  using BindIdValueMap = std::map<std::string, ShPtr<Expression>>;
45 
46 private:
47  bool funcNameMatches(ShPtr<Expression> calledExpr) const;
48  bool argsMatch(ShPtr<CallExpr> call) const;
49  bool valuesMatch(ShPtr<Value> value1, ShPtr<Value> value2) const;
51  void advanceToNextInfo();
55 
56 private:
59 
62 
65 
68 
71 };
72 
73 } // namespace llvmir2hll
74 } // namespace retdec
75 
76 #endif
A representation of information about an API call.
A sequence of information about API calls.
A sequence of information about API calls.
Definition: api_call_info_seq.h:21
APICallInfos::const_iterator iterator
Iterator over API call information.
Definition: api_call_info_seq.h:27
A representation of information about an API call.
Definition: api_call_info.h:23
A storage of intermediate data when finding sequences of API calls.
Definition: api_call_seq_data.h:23
void bindValues(ShPtr< Statement > stmt, ShPtr< CallExpr > call)
Binds values from call that appear in stmt.
Definition: api_call_seq_data.cpp:215
APICallSeqData & operator=(const APICallSeqData &data)
Assigns data into the current data.
Definition: api_call_seq_data.cpp:68
void bindValuesFromArgs(ShPtr< CallExpr > call)
Binds the values from the arguments of call.
Definition: api_call_seq_data.cpp:248
bool atEnd() const
Returns true if all the API call information passed to the constructor have been matched,...
Definition: api_call_seq_data.cpp:140
void advanceToNextInfo()
Advances to the next information in allInfos.
Definition: api_call_seq_data.cpp:204
bool argsMatch(ShPtr< CallExpr > call) const
Checks that all the bound parameters from the API call info match the values in call.
Definition: api_call_seq_data.cpp:156
BindIdValueMap boundValues
Mapping of a bind ID into the bound value.
Definition: api_call_seq_data.h:67
bool funcNameMatches(ShPtr< Expression > calledExpr) const
Checks that the function called in calledExpr is the one we expect.
Definition: api_call_seq_data.cpp:147
APICallInfoSeq::iterator currInfoIter
Iterator to the current information in allInfos.
Definition: api_call_seq_data.h:64
bool valuesMatch(ShPtr< Value > value1, ShPtr< Value > value2) const
Checks whether value1 is structurally equal to value2.
Definition: api_call_seq_data.cpp:190
APICallSeqData(const APICallInfoSeq &info)
Constructs data from the given information.
Definition: api_call_seq_data.cpp:50
bool operator!=(const APICallSeqData &other) const
Returns true if this data differ from the other data, false otherwise.
Definition: api_call_seq_data.cpp:90
std::map< std::string, ShPtr< Expression > > BindIdValueMap
Mapping of a bind ID into the bound value.
Definition: api_call_seq_data.h:44
ShPtr< Pattern > getPattern() const
Returns the current version of the built pattern.
Definition: api_call_seq_data.cpp:132
bool matches(ShPtr< CallExpr > call) const
Returns true if call matches the currently set API call information, false otherwise.
Definition: api_call_seq_data.cpp:98
const APICallInfoSeq & allInfos
Sequence of API call information that we are looking for.
Definition: api_call_seq_data.h:58
void bindValueFromReturnValue(ShPtr< Statement > stmt, ShPtr< CallExpr > call)
Binds the value returned from call (if any).
Definition: api_call_seq_data.cpp:225
bool patternIsComplete() const
Returns true if the pattern is complete, false otherwise.
Definition: api_call_seq_data.cpp:122
void apply(ShPtr< Statement > stmt, ShPtr< CallExpr > call)
Applies call that occur in stmt.
Definition: api_call_seq_data.cpp:111
void addToPattern(ShPtr< Statement > stmt, ShPtr< CallExpr > call)
Adds a new piece of information into the currently built pattern.
Definition: api_call_seq_data.cpp:197
bool operator==(const APICallSeqData &other) const
Returns true if this data equal the other data, false otherwise.
Definition: api_call_seq_data.cpp:78
ShPtr< StmtsPattern > pattern
Pattern that is being built.
Definition: api_call_seq_data.h:70
const APICallInfo * currInfo
Pointer to the current information from allInfos.
Definition: api_call_seq_data.h:61
A library providing API for working with back-end IR.
std::shared_ptr< T > ShPtr
An alias for a shared pointer.
Definition: smart_ptr.h:18
Definition: archive_wrapper.h:19