Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions clang/include/clang/CConv/AVarBoundsInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ class AvarBoundsInference {

// Infer bounds for the given key from the set of given ARR atoms.
// The flag FromPB requests the inference to use potential length variables.
bool inferBounds(BoundsKey K, bool FromPB = false);
bool inferBounds(BoundsKey K, AVarGraph &BKGraph, bool FromPB = false);
private:
bool inferPossibleBounds(BoundsKey K, ABounds *SB,
AVarGraph &BKGraph,
std::set<ABounds *> &EB);

bool intersectBounds(std::set<ProgramVar *> &ProgVars,
Expand All @@ -110,6 +111,7 @@ class AvarBoundsInference {
std::set<ABounds *> &ResBounds);

bool predictBounds(BoundsKey K, std::set<BoundsKey> &Neighbours,
AVarGraph &BKGraph,
ABounds **KB);


Expand All @@ -120,7 +122,7 @@ class AvarBoundsInference {

class AVarBoundsInfo {
public:
AVarBoundsInfo() : ProgVarGraph(this) {
AVarBoundsInfo() : ProgVarGraph(this), CtxSensProgVarGraph(this) {
BCount = 1;
PVarInfo.clear();
InProgramArrPtrBoundsKeys.clear();
Expand Down Expand Up @@ -208,7 +210,8 @@ class AVarBoundsInfo {
// Create context sensitive BoundsKey variables for the given set of
// ConstraintVariables.
bool contextualizeCVar(CallExpr *CE,
const std::set<ConstraintVariable *> &CV);
const std::set<ConstraintVariable *> &CV,
ASTContext *C);
// Get the context sensitive BoundsKey for the given key.
// If there exists no context-sensitive bounds key, we just return
// the provided key.
Expand Down Expand Up @@ -269,6 +272,9 @@ class AVarBoundsInfo {

// Graph of all program variables.
AVarGraph ProgVarGraph;
// Graph that contains only edges between context-sensitive
// BoundsKey and corresponding original BoundsKey.
AVarGraph CtxSensProgVarGraph;
// Stats on techniques used to find length for various variables.
AVarBoundsStats BoundsInferStats;
// This is the map of pointer variable bounds key and set of bounds key
Expand All @@ -293,6 +299,9 @@ class AVarBoundsInfo {

void insertProgramVar(BoundsKey NK, ProgramVar *PV);

void insertCtxSensBoundsKey(ProgramVar *OldPV, BoundsKey NK,
const CtxFunctionArgScope *CFAS);

// Check if the provided bounds key corresponds to function return.
bool isFunctionReturn(BoundsKey BK);

Expand All @@ -303,9 +312,11 @@ class AVarBoundsInfo {
// returns true if any thing changed, else false.
bool keepHighestPriorityBounds(std::set<BoundsKey> &ArrPtrs);

// Perform worklist based inference on the requested array variables.
// Perform worklist based inference on the requested array variables using
// the provided graph.
// The flag FromPB requests the algorithm to use potential length variables.
bool performWorkListInference(std::set<BoundsKey> &ArrNeededBounds,
AVarGraph &BKGraph,
bool FromPB = false);

void insertParamKey(ParamDeclType ParamDecl, BoundsKey NK);
Expand Down
15 changes: 11 additions & 4 deletions clang/include/clang/CConv/ConstraintVariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,20 @@ enum ConsAction {
void constrainConsVarGeq(const std::set<ConstraintVariable *> &LHS,
const std::set<ConstraintVariable *> &RHS,
Constraints &CS, PersistentSourceLoc *PL,
ConsAction CA, bool doEqType, ProgramInfo *Info);
ConsAction CA, bool doEqType,
ProgramInfo *Info,
bool HandleBoundsKey = true);
void constrainConsVarGeq(ConstraintVariable *LHS, const CVarSet &RHS,
Constraints &CS, PersistentSourceLoc *PL,
ConsAction CA, bool doEqType, ProgramInfo *Info);
void constrainConsVarGeq(ConstraintVariable *LHS, ConstraintVariable *RHS,
ConsAction CA, bool doEqType,
ProgramInfo *Info,
bool HandleBoundsKey = true);
void constrainConsVarGeq(ConstraintVariable *LHS,
ConstraintVariable *RHS,
Constraints &CS, PersistentSourceLoc *PL,
ConsAction CA, bool doEqType, ProgramInfo *Info);
ConsAction CA, bool doEqType,
ProgramInfo *Info,
bool HandleBoundsKey = true);

// True if [C] is a PVConstraint that contains at least one Atom (i.e.,
// it represents a C pointer)
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/CConv/PersistentSourceLoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class PersistentSourceLoc {
static
PersistentSourceLoc mkPSL(const clang::Stmt *S, clang::ASTContext &Context);

static
PersistentSourceLoc mkPSL(const clang::Expr *E, clang::ASTContext &Context);

private:
// Create a PersistentSourceLoc based on absolute file path
// from the given SourceRange and SourceLocation.
Expand Down
Loading