8 #ifndef INCLUDE_IR_SEG_SEGTRACE_H_
9 #define INCLUDE_IR_SEG_SEGTRACE_H_
11 #include "rapidjson/document.h"
13 #include "IR/LLVMValueTrace.h"
14 #include "IR/SEG/SymbolicExprGraphBuilder.h"
21 class SEGTrace :
public Trace<const SEGObject *> {
22 friend class TraceSerializer;
31 virtual TraceKind getKind()
const {
return TK_ValueFlow; }
34 typedef uint64_t StepType;
35 const static StepType STY_VALUE = 0x1;
36 const static StepType STY_USE_SITE = 0x2;
38 const StepType DEFAULT_STEP_TYPE = STY_VALUE | STY_USE_SITE;
45 kvec<SEGRegionNode *> AdditionalConds;
57 int guessLEVFSrcIdx(
bool IsConsiderLoad)
const;
64 SEGTrace(
const kvec<const SEGObject *> &Trace);
77 virtual void resetWithLLVMValueTrace(
const LLVMValueTrace *ValueTrace,
86 virtual int getValidStartIdx()
const;
91 virtual int getKeyIdx()
const;
115 virtual int getLEVFSrcIdx(
bool isConsiderLoad =
false)
const;
118 StepType getStepType(
int StepIdx)
const;
121 void setStepType(
int StepIdx, StepType STy);
124 int getNumAdditionalConds()
const;
134 void clearAdditionalCond();
139 template <
typename Predicate>
140 std::pair<const SEGObject *, int>
find(
int StartIndex, Predicate P)
const {
141 for (
int I = StartIndex, E = get_length(); I < E; ++I) {
144 return std::move(std::make_pair(O, I));
148 return std::move(std::make_pair(
nullptr, get_length()));
151 template <
typename Predicate>
152 std::pair<const SEGObject *, size_t> rfind(
size_t StartIndex,
154 size_t Size = get_length();
155 if (StartIndex >= Size)
156 return std::move(std::make_pair(
nullptr, Size));
158 for (
size_t I = StartIndex;; --I) {
161 return std::move(std::make_pair(O, I));
168 return std::move(std::make_pair(
nullptr, Size));
171 virtual void print(raw_ostream &O);