@@ -97,9 +97,10 @@ class AvarBoundsInference {
9797
9898 // Infer bounds for the given key from the set of given ARR atoms.
9999 // The flag FromPB requests the inference to use potential length variables.
100- bool inferBounds (BoundsKey K, bool FromPB = false );
100+ bool inferBounds (BoundsKey K, AVarGraph &BKGraph, bool FromPB = false );
101101private:
102102 bool inferPossibleBounds (BoundsKey K, ABounds *SB ,
103+ AVarGraph &BKGraph,
103104 std::set<ABounds *> &EB );
104105
105106 bool intersectBounds (std::set<ProgramVar *> &ProgVars,
@@ -110,6 +111,7 @@ class AvarBoundsInference {
110111 std::set<ABounds *> &ResBounds);
111112
112113 bool predictBounds (BoundsKey K, std::set<BoundsKey> &Neighbours,
114+ AVarGraph &BKGraph,
113115 ABounds **KB );
114116
115117
@@ -120,7 +122,7 @@ class AvarBoundsInference {
120122
121123class AVarBoundsInfo {
122124public:
123- AVarBoundsInfo () : ProgVarGraph(this ) {
125+ AVarBoundsInfo () : ProgVarGraph(this ), CtxSensProgVarGraph( this ) {
124126 BCount = 1 ;
125127 PVarInfo.clear ();
126128 InProgramArrPtrBoundsKeys.clear ();
@@ -208,7 +210,8 @@ class AVarBoundsInfo {
208210 // Create context sensitive BoundsKey variables for the given set of
209211 // ConstraintVariables.
210212 bool contextualizeCVar (CallExpr *CE ,
211- const std::set<ConstraintVariable *> &CV );
213+ const std::set<ConstraintVariable *> &CV ,
214+ ASTContext *C);
212215 // Get the context sensitive BoundsKey for the given key.
213216 // If there exists no context-sensitive bounds key, we just return
214217 // the provided key.
@@ -269,6 +272,9 @@ class AVarBoundsInfo {
269272
270273 // Graph of all program variables.
271274 AVarGraph ProgVarGraph;
275+ // Graph that contains only edges between context-sensitive
276+ // BoundsKey and corresponding original BoundsKey.
277+ AVarGraph CtxSensProgVarGraph;
272278 // Stats on techniques used to find length for various variables.
273279 AVarBoundsStats BoundsInferStats;
274280 // This is the map of pointer variable bounds key and set of bounds key
@@ -293,6 +299,9 @@ class AVarBoundsInfo {
293299
294300 void insertProgramVar (BoundsKey NK , ProgramVar *PV );
295301
302+ void insertCtxSensBoundsKey (ProgramVar *OldPV, BoundsKey NK ,
303+ const CtxFunctionArgScope *CFAS );
304+
296305 // Check if the provided bounds key corresponds to function return.
297306 bool isFunctionReturn (BoundsKey BK );
298307
@@ -303,9 +312,11 @@ class AVarBoundsInfo {
303312 // returns true if any thing changed, else false.
304313 bool keepHighestPriorityBounds (std::set<BoundsKey> &ArrPtrs);
305314
306- // Perform worklist based inference on the requested array variables.
315+ // Perform worklist based inference on the requested array variables using
316+ // the provided graph.
307317 // The flag FromPB requests the algorithm to use potential length variables.
308318 bool performWorkListInference (std::set<BoundsKey> &ArrNeededBounds,
319+ AVarGraph &BKGraph,
309320 bool FromPB = false );
310321
311322 void insertParamKey (ParamDeclType ParamDecl, BoundsKey NK );
0 commit comments