Skip to content

Commit

Permalink
Merge pull request #1440 from bjjwwang/master
Browse files Browse the repository at this point in the history
add const to some funcs in SVFIR2AbsState
  • Loading branch information
yuleisui authored Apr 19, 2024
2 parents 67cbb9c + 5169c4c commit 3f9ff09
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
28 changes: 14 additions & 14 deletions svf/include/AE/Svfexe/SVFIR2AbsState.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,24 @@ class SVFIR2AbsState
/// Return the value range of Integer SVF Type, e.g. unsigned i8 Type->[0, 255], signed i8 Type->[-128, 127]
AbstractValue getRangeLimitFromType(const SVFType* type);

AbstractValue getZExtValue(AbstractState& es, const SVFVar* var);
AbstractValue getSExtValue(AbstractState& es, const SVFVar* var);
AbstractValue getFPToSIntValue(AbstractState& es, const SVFVar* var);
AbstractValue getFPToUIntValue(AbstractState& es, const SVFVar* var);
AbstractValue getSIntToFPValue(AbstractState& es, const SVFVar* var);
AbstractValue getUIntToFPValue(AbstractState& es, const SVFVar* var);
AbstractValue getTruncValue(AbstractState& es, const SVFVar* var, const SVFType* dstType);
AbstractValue getFPTruncValue(AbstractState& es, const SVFVar* var, const SVFType* dstType);
AbstractValue getZExtValue(const AbstractState& es, const SVFVar* var);
AbstractValue getSExtValue(const AbstractState& es, const SVFVar* var);
AbstractValue getFPToSIntValue(const AbstractState& es, const SVFVar* var);
AbstractValue getFPToUIntValue(const AbstractState& es, const SVFVar* var);
AbstractValue getSIntToFPValue(const AbstractState& es, const SVFVar* var);
AbstractValue getUIntToFPValue(const AbstractState& es, const SVFVar* var);
AbstractValue getTruncValue(const AbstractState& es, const SVFVar* var, const SVFType* dstType);
AbstractValue getFPTruncValue(const AbstractState& es, const SVFVar* var, const SVFType* dstType);

/// Return the byte offset expression of a GepStmt
/// elemBytesize is the element byte size of an static alloc or heap alloc array
/// e.g. GepStmt* gep = [i32*10], x, and x is [0,3]
/// std::pair<s32_t, s32_t> byteOffset = getByteOffset(gep);
/// byteOffset should be [0, 12] since i32 is 4 bytes.
AbstractValue getByteOffset(AbstractState& es, const GepStmt *gep);
AbstractValue getByteOffset(const AbstractState& es, const GepStmt *gep);

/// Return the offset expression of a GepStmt
AbstractValue getItvOfFlattenedElemIndex(AbstractState& es, const GepStmt *gep);
AbstractValue getItvOfFlattenedElemIndex(const AbstractState& es, const GepStmt *gep);


static z3::context &getContext()
Expand All @@ -111,26 +111,26 @@ class SVFIR2AbsState


/// whether the variable is in varToVal table
inline bool inVarToValTable(AbstractState& es, u32_t id) const
inline bool inVarToValTable(const AbstractState& es, u32_t id) const
{
return es.inVarToValTable(id);
}

/// whether the variable is in varToAddrs table
inline bool inVarToAddrsTable(AbstractState& es, u32_t id) const
inline bool inVarToAddrsTable(const AbstractState& es, u32_t id) const
{
return es.inVarToAddrsTable(id);
}


/// whether the memory address stores a interval value
inline bool inLocToValTable(AbstractState& es, u32_t id) const
inline bool inLocToValTable(const AbstractState& es, u32_t id) const
{
return es.inLocToValTable(id);
}

/// whether the memory address stores memory addresses
inline bool inLocToAddrsTable(AbstractState& es, u32_t id) const
inline bool inLocToAddrsTable(const AbstractState& es, u32_t id) const
{
return es.inLocToAddrsTable(id);
}
Expand Down
20 changes: 10 additions & 10 deletions svf/lib/AE/Svfexe/SVFIR2AbsState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ AbstractValue SVFIR2AbsState::getRangeLimitFromType(const SVFType* type)
}
}

AbstractValue SVFIR2AbsState::getZExtValue(AbstractState& es, const SVFVar* var)
AbstractValue SVFIR2AbsState::getZExtValue(const AbstractState& es, const SVFVar* var)
{
const SVFType* type = var->getType();
if (SVFUtil::isa<SVFIntegerType>(type))
Expand Down Expand Up @@ -153,12 +153,12 @@ AbstractValue SVFIR2AbsState::getZExtValue(AbstractState& es, const SVFVar* var)
assert(false && "cannot support non-integer type");
}

AbstractValue SVFIR2AbsState::getSExtValue(AbstractState& es, const SVFVar* var)
AbstractValue SVFIR2AbsState::getSExtValue(const AbstractState& es, const SVFVar* var)
{
return es[var->getId()].getInterval();
}

AbstractValue SVFIR2AbsState::getFPToSIntValue(AbstractState& es, const SVF::SVFVar* var)
AbstractValue SVFIR2AbsState::getFPToSIntValue(const AbstractState& es, const SVF::SVFVar* var)
{
if (es[var->getId()].getInterval().is_real())
{
Expand All @@ -176,7 +176,7 @@ AbstractValue SVFIR2AbsState::getFPToSIntValue(AbstractState& es, const SVF::SVF
}
}

AbstractValue SVFIR2AbsState::getFPToUIntValue(AbstractState& es, const SVF::SVFVar* var)
AbstractValue SVFIR2AbsState::getFPToUIntValue(const AbstractState& es, const SVF::SVFVar* var)
{
if (es[var->getId()].getInterval().is_real())
{
Expand All @@ -194,7 +194,7 @@ AbstractValue SVFIR2AbsState::getFPToUIntValue(AbstractState& es, const SVF::SVF
}
}

AbstractValue SVFIR2AbsState::getSIntToFPValue(AbstractState& es, const SVF::SVFVar* var)
AbstractValue SVFIR2AbsState::getSIntToFPValue(const AbstractState& es, const SVF::SVFVar* var)
{
// get the sint value of ub and lb
s64_t sint_lb = es[var->getId()].getInterval().lb().getIntNumeral();
Expand All @@ -205,7 +205,7 @@ AbstractValue SVFIR2AbsState::getSIntToFPValue(AbstractState& es, const SVF::SVF
return IntervalValue(float_lb, float_ub);
}

AbstractValue SVFIR2AbsState::getUIntToFPValue(AbstractState& es, const SVF::SVFVar* var)
AbstractValue SVFIR2AbsState::getUIntToFPValue(const AbstractState& es, const SVF::SVFVar* var)
{
// get the uint value of ub and lb
u64_t uint_lb = es[var->getId()].getInterval().lb().getIntNumeral();
Expand All @@ -216,7 +216,7 @@ AbstractValue SVFIR2AbsState::getUIntToFPValue(AbstractState& es, const SVF::SVF
return IntervalValue(float_lb, float_ub);
}

AbstractValue SVFIR2AbsState::getTruncValue(AbstractState& es, const SVF::SVFVar* var, const SVFType* dstType)
AbstractValue SVFIR2AbsState::getTruncValue(const AbstractState& es, const SVF::SVFVar* var, const SVFType* dstType)
{
// get the value of ub and lb
s64_t int_lb = es[var->getId()].getInterval().lb().getIntNumeral();
Expand Down Expand Up @@ -265,7 +265,7 @@ AbstractValue SVFIR2AbsState::getTruncValue(AbstractState& es, const SVF::SVFVar
}
}

AbstractValue SVFIR2AbsState::getFPTruncValue(AbstractState& es, const SVF::SVFVar* var, const SVFType* dstType)
AbstractValue SVFIR2AbsState::getFPTruncValue(const AbstractState& es, const SVF::SVFVar* var, const SVFType* dstType)
{
// TODO: now we do not really handle fptrunc
return es[var->getId()].getInterval();
Expand Down Expand Up @@ -400,7 +400,7 @@ AbstractValue SVFIR2AbsState::getGepObjAddress(AbstractState& es, u32_t pointer,
* Therefore the final byteoffset is [8+4*var1.lb(), 8+4*var1.ub()]
*
*/
AbstractValue SVFIR2AbsState::getByteOffset(AbstractState& es, const GepStmt *gep)
AbstractValue SVFIR2AbsState::getByteOffset(const AbstractState& es, const GepStmt *gep)
{
if (gep->isConstantOffset())
return IntervalValue((s64_t)gep->accumulateConstantByteOffset());
Expand Down Expand Up @@ -470,7 +470,7 @@ AbstractValue SVFIR2AbsState::getByteOffset(AbstractState& es, const GepStmt *ge
*
* @return A pair of APOffset values representing the offset range.
*/
AbstractValue SVFIR2AbsState::getItvOfFlattenedElemIndex(AbstractState& es, const GepStmt *gep)
AbstractValue SVFIR2AbsState::getItvOfFlattenedElemIndex(const AbstractState& es, const GepStmt *gep)
{
if (gep->isConstantOffset())
return IntervalValue((s64_t)gep->accumulateConstantOffset());
Expand Down

0 comments on commit 3f9ff09

Please sign in to comment.