Static Value-Flow Analysis
Loading...
Searching...
No Matches
AbstractStateManager.h
Go to the documentation of this file.
1//===- AbstractStateManager.h -- State management for abstract execution --//
2//
3// SVF: Static Value-Flow Analysis
4//
5// Copyright (C) <2013-> <Yulei Sui>
6//
7
8// This program is free software: you can redistribute it and/or modify
9// it under the terms of the GNU Affero General Public License as published by
10// the Free Software Foundation, either version 3 of the License, or
11// (at your option) any later version.
12
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU Affero General Public License for more details.
17
18// You should have received a copy of the GNU Affero General Public License
19// along with this program. If not, see <http://www.gnu.org/licenses/>.
20//
21//===----------------------------------------------------------------------===//
22//
23// Created on: Mar 2026
24// Author: Jiawei Wang
25//
26#pragma once
28#include "SVFIR/SVFIR.h"
29
30namespace SVF
31{
32
33class GepStmt;
34class AddrStmt;
35class SVFG;
36class AndersenWaveDiff;
37
49{
50public:
53
54 // ===----------------------------------------------------------------------===//
55 // Abstract Value Access API
56 // ===----------------------------------------------------------------------===//
57
61 const AbstractValue& getAbstractValue(const ValVar* var, const ICFGNode* node);
62
64 const AbstractValue& getAbstractValue(const ObjVar* var, const ICFGNode* node);
65
67 const AbstractValue& getAbstractValue(const SVFVar* var, const ICFGNode* node);
68
74 bool hasAbstractValue(const ValVar* var, const ICFGNode* node) const;
75
77 bool hasAbstractValue(const ObjVar* var, const ICFGNode* node) const;
78
80 bool hasAbstractValue(const SVFVar* var, const ICFGNode* node) const;
81
83 void updateAbstractValue(const ValVar* var, const AbstractValue& val, const ICFGNode* node);
84
86 void updateAbstractValue(const ObjVar* var, const AbstractValue& val, const ICFGNode* node);
87
89 void updateAbstractValue(const SVFVar* var, const AbstractValue& val, const ICFGNode* node);
90
91 // ===----------------------------------------------------------------------===//
92 // State Access
93 // ===----------------------------------------------------------------------===//
94
97 void updateAbstractState(const ICFGNode* node, const AbstractState& state);
98
100 bool hasAbstractState(const ICFGNode* node);
101
106
107 // ===----------------------------------------------------------------------===//
108 // GEP Helpers
109 //
110 // Lifted from AbstractState to use getAbstractValue for index variable lookup.
111 // ===----------------------------------------------------------------------===//
112
115
118
121
122 // ===----------------------------------------------------------------------===//
123 // Load / Store through pointer (combines ValVar lookup + ObjVar access)
124 // ===----------------------------------------------------------------------===//
125
131 AbstractValue loadValue(const ValVar* pointer, const ICFGNode* node);
132
138 void storeValue(const ValVar* pointer, const AbstractValue& val, const ICFGNode* node);
139
140 // ===----------------------------------------------------------------------===//
141 // Type / Size Helpers
142 // ===----------------------------------------------------------------------===//
143
145 const SVFType* getPointeeElement(const ObjVar* var, const ICFGNode* node);
146
149
150 // ===----------------------------------------------------------------------===//
151 // Direct Trace Access (for merge, fixpoint, etc.)
152 // ===----------------------------------------------------------------------===//
153
159 {
160 return abstractTrace[node];
161 }
162
163 // ===----------------------------------------------------------------------===//
164 // Def/Use site queries (sparsity-aware)
165 // ===----------------------------------------------------------------------===//
166
169
172
174 const ICFGNode* getDefSiteOfValVar(const ValVar* var) const;
175
177 const ICFGNode* getDefSiteOfObjVar(const ObjVar* obj, const ICFGNode* node) const;
178
179private:
183};
184
185} // namespace SVF
buffer offset
Definition cJSON.cpp:1113
void storeValue(const ValVar *pointer, const AbstractValue &val, const ICFGNode *node)
void updateAbstractValue(const ValVar *var, const AbstractValue &val, const ICFGNode *node)
Write a top-level variable's abstract value into abstractTrace[node].
Map< const ICFGNode *, AbstractState > & getTrace()
IntervalValue getGepByteOffset(const GepStmt *gep)
Compute the byte offset for a GepStmt.
AbstractState & getAbstractState(const ICFGNode *node)
Retrieve the abstract state for a given ICFG node. Asserts if absent.
u32_t getAllocaInstByteSize(const AddrStmt *addr)
Get the byte size of a stack allocation.
bool hasAbstractState(const ICFGNode *node)
Check if an abstract state exists for a given ICFG node.
bool hasAbstractValue(const ValVar *var, const ICFGNode *node) const
const AbstractValue & getAbstractValue(const ValVar *var, const ICFGNode *node)
AbstractState & operator[](const ICFGNode *node)
IntervalValue getGepElementIndex(const GepStmt *gep)
Compute the flattened element index for a GepStmt.
const ICFGNode * getDefSiteOfValVar(const ValVar *var) const
Given a ValVar, find its definition-site ICFGNode.
Set< const ICFGNode * > getUseSitesOfObjVar(const ObjVar *obj, const ICFGNode *node) const
Given an ObjVar and its use-site ICFGNode, find all downstream use-site ICFGNodes.
const ICFGNode * getDefSiteOfObjVar(const ObjVar *obj, const ICFGNode *node) const
Given an ObjVar and its use-site ICFGNode, find the definition-site ICFGNode.
AddressValue getGepObjAddrs(const ValVar *pointer, IntervalValue offset)
Compute GEP object addresses for a pointer at a given element offset.
AbstractValue loadValue(const ValVar *pointer, const ICFGNode *node)
const SVFType * getPointeeElement(const ObjVar *var, const ICFGNode *node)
Get the pointee type for a pointer variable.
Map< const ICFGNode *, AbstractState > abstractTrace
Set< const ICFGNode * > getUseSitesOfValVar(const ValVar *var) const
Given a ValVar, find all use-site ICFGNodes.
void updateAbstractState(const ICFGNode *node, const AbstractState &state)
for isBitcode
Definition BasicTypes.h:70
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76
unsigned u32_t
Definition GeneralType.h:47