8 #ifndef IR_SEG_CBAccessPath_H
9 #define IR_SEG_CBAccessPath_H
11 #include <llvm/IR/Value.h>
13 #include "Platform/Arch/CBTypes.h"
14 #include "Utils/ADT/kvec.h"
23 friend class SEGSerializer;
27 kvec<pp_offset_t> offsets;
30 bool is_base_ptr_from_return;
35 is_base_ptr_from_return =
false;
41 void add_level(Value *base_ptr, pp_offset_t offset,
42 bool is_from_return =
false) {
43 this->base_ptr = base_ptr;
44 offsets.push_back(offset);
45 this->is_base_ptr_from_return = is_from_return;
50 void reset_cur_level(Value *base_ptr, pp_offset_t offset,
51 bool is_from_return =
false) {
52 if (!offsets.empty()) {
53 this->base_ptr = base_ptr;
54 offsets.back() -= offset;
55 this->is_base_ptr_from_return = is_from_return;
60 void reset(Value *base_ptr,
bool is_from_return =
false) {
62 this->base_ptr = base_ptr;
63 this->is_base_ptr_from_return = is_from_return;
69 offsets.push_back(ap.offsets);
70 this->base_ptr = ap.base_ptr;
71 this->is_base_ptr_from_return = ap.is_base_ptr_from_return;
74 int get_depth()
const {
return offsets.size(); }
76 pp_offset_t get_offset(
int idx)
const {
79 return offsets[get_depth() - idx - 1];
82 Value *get_base_ptr()
const {
return base_ptr; }
85 bool is_from_return()
const {
return is_base_ptr_from_return; }