Rename SymbolID to SymbolRef. This is a precursor to some overhauling of the representation of symbolic values.

llvm-svn: 60575
This commit is contained in:
Ted Kremenek 2008-12-05 02:27:51 +00:00
parent fbcf1e2623
commit d8242f19f7
19 changed files with 149 additions and 149 deletions

View File

@ -84,7 +84,7 @@ public:
return getValue(b ? 1 : 0, Ctx.getTypeSize(Ctx.IntTy), false); return getValue(b ? 1 : 0, Ctx.getTypeSize(Ctx.IntTy), false);
} }
const SymIntConstraint& getConstraint(SymbolID sym, BinaryOperator::Opcode Op, const SymIntConstraint& getConstraint(SymbolRef sym, BinaryOperator::Opcode Op,
const llvm::APSInt& V); const llvm::APSInt& V);
const CompoundValData* getCompoundValData(QualType T, const CompoundValData* getCompoundValData(QualType T,

View File

@ -236,7 +236,7 @@ public:
class GRBugReporter : public BugReporter { class GRBugReporter : public BugReporter {
GRExprEngine& Eng; GRExprEngine& Eng;
llvm::SmallSet<SymbolID, 10> NotableSymbols; llvm::SmallSet<SymbolRef, 10> NotableSymbols;
public: public:
GRBugReporter(BugReporterData& d, GRExprEngine& eng) GRBugReporter(BugReporterData& d, GRExprEngine& eng)
@ -260,11 +260,11 @@ public:
virtual void GeneratePathDiagnostic(PathDiagnostic& PD, BugReport& R); virtual void GeneratePathDiagnostic(PathDiagnostic& PD, BugReport& R);
void addNotableSymbol(SymbolID Sym) { void addNotableSymbol(SymbolRef Sym) {
NotableSymbols.insert(Sym); NotableSymbols.insert(Sym);
} }
bool isNotable(SymbolID Sym) const { bool isNotable(SymbolRef Sym) const {
return (bool) NotableSymbols.count(Sym); return (bool) NotableSymbols.count(Sym);
} }

View File

@ -26,7 +26,7 @@ namespace clang {
class GRState; class GRState;
class GRStateManager; class GRStateManager;
class SVal; class SVal;
class SymbolID; class SymbolRef;
class ConstraintManager { class ConstraintManager {
public: public:
@ -38,11 +38,11 @@ public:
SVal UpperBound, bool Assumption, SVal UpperBound, bool Assumption,
bool& isFeasible) = 0; bool& isFeasible) = 0;
virtual const GRState* AddNE(const GRState* St, SymbolID sym, virtual const GRState* AddNE(const GRState* St, SymbolRef sym,
const llvm::APSInt& V) = 0; const llvm::APSInt& V) = 0;
virtual const llvm::APSInt* getSymVal(const GRState* St, SymbolID sym) = 0; virtual const llvm::APSInt* getSymVal(const GRState* St, SymbolRef sym) = 0;
virtual bool isEqual(const GRState* St, SymbolID sym, virtual bool isEqual(const GRState* St, SymbolRef sym,
const llvm::APSInt& V) const = 0; const llvm::APSInt& V) const = 0;
virtual const GRState* RemoveDeadBindings(const GRState* St, virtual const GRState* RemoveDeadBindings(const GRState* St,

View File

@ -7,7 +7,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file defines SymbolID, ExprBindKey, and GRState* // This file defines SymbolRef, ExprBindKey, and GRState*
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -535,11 +535,11 @@ public:
isFeasible); isFeasible);
} }
const GRState* AddNE(const GRState* St, SymbolID sym, const llvm::APSInt& V) { const GRState* AddNE(const GRState* St, SymbolRef sym, const llvm::APSInt& V) {
return ConstraintMgr->AddNE(St, sym, V); return ConstraintMgr->AddNE(St, sym, V);
} }
const llvm::APSInt* getSymVal(const GRState* St, SymbolID sym) { const llvm::APSInt* getSymVal(const GRState* St, SymbolRef sym) {
return ConstraintMgr->getSymVal(St, sym); return ConstraintMgr->getSymVal(St, sym);
} }
@ -605,7 +605,7 @@ public:
return GRStateRef(Mgr->Unbind(St, LV), *Mgr); return GRStateRef(Mgr->Unbind(St, LV), *Mgr);
} }
GRStateRef AddNE(SymbolID sym, const llvm::APSInt& V) { GRStateRef AddNE(SymbolRef sym, const llvm::APSInt& V) {
return GRStateRef(Mgr->AddNE(St, sym, V), *Mgr); return GRStateRef(Mgr->AddNE(St, sym, V), *Mgr);
} }

View File

@ -140,17 +140,17 @@ public:
/// regions do not need to be typed. /// regions do not need to be typed.
class SymbolicRegion : public MemRegion { class SymbolicRegion : public MemRegion {
protected: protected:
const SymbolID sym; const SymbolRef sym;
public: public:
SymbolicRegion(const SymbolID s) : MemRegion(SymbolicRegionKind), sym(s) {} SymbolicRegion(const SymbolRef s) : MemRegion(SymbolicRegionKind), sym(s) {}
SymbolID getSymbol() const { SymbolRef getSymbol() const {
return sym; return sym;
} }
void Profile(llvm::FoldingSetNodeID& ID) const; void Profile(llvm::FoldingSetNodeID& ID) const;
static void ProfileRegion(llvm::FoldingSetNodeID& ID, SymbolID sym); static void ProfileRegion(llvm::FoldingSetNodeID& ID, SymbolRef sym);
void print(llvm::raw_ostream& os) const; void print(llvm::raw_ostream& os) const;
@ -507,9 +507,9 @@ public:
/// the sizes of dynamically allocated chunks of memory with variable size. /// the sizes of dynamically allocated chunks of memory with variable size.
class SymbolicExtent : public RegionExtent { class SymbolicExtent : public RegionExtent {
public: public:
SymbolicExtent(SymbolID S) : RegionExtent(S.getNumber() << 1, Sym) {} SymbolicExtent(SymbolRef S) : RegionExtent(S.getNumber() << 1, Sym) {}
SymbolID getSymbol() const { return SymbolID(getData() >> 1); } SymbolRef getSymbol() const { return SymbolRef(getData() >> 1); }
// Implement isa<T> support. // Implement isa<T> support.
static inline bool classof(const RegionExtent* E) { static inline bool classof(const RegionExtent* E) {
@ -567,7 +567,7 @@ public:
getCompoundLiteralRegion(const CompoundLiteralExpr* CL); getCompoundLiteralRegion(const CompoundLiteralExpr* CL);
/// getSymbolicRegion - Retrieve or create a "symbolic" memory region. /// getSymbolicRegion - Retrieve or create a "symbolic" memory region.
SymbolicRegion* getSymbolicRegion(const SymbolID sym); SymbolicRegion* getSymbolicRegion(const SymbolRef sym);
StringRegion* getStringRegion(const StringLiteral* Str); StringRegion* getStringRegion(const StringLiteral* Str);

View File

@ -102,7 +102,7 @@ public:
class symbol_iterator { class symbol_iterator {
const enum { One, Many } HowMany; const enum { One, Many } HowMany;
union { uintptr_t sym; const SymbolID* sptr; }; union { uintptr_t sym; const SymbolRef* sptr; };
public: public:
bool operator==(const symbol_iterator& X) { bool operator==(const symbol_iterator& X) {
@ -122,16 +122,16 @@ public:
return *this; return *this;
} }
SymbolID operator*() const { SymbolRef operator*() const {
if (HowMany) if (HowMany)
return *sptr; return *sptr;
return SymbolID(sym); return SymbolRef(sym);
} }
symbol_iterator(SymbolID x) : HowMany(One), sym(x.getNumber()) {} symbol_iterator(SymbolRef x) : HowMany(One), sym(x.getNumber()) {}
symbol_iterator() : HowMany(One), sym(~0x0) {} symbol_iterator() : HowMany(One), sym(~0x0) {}
symbol_iterator(const SymbolID* x) : HowMany(Many), sptr(x) {} symbol_iterator(const SymbolRef* x) : HowMany(Many), sptr(x) {}
}; };
symbol_iterator symbol_begin() const; symbol_iterator symbol_begin() const;
@ -238,8 +238,8 @@ public:
SymbolVal(unsigned SymID) SymbolVal(unsigned SymID)
: NonLoc(SymbolValKind, reinterpret_cast<void*>((uintptr_t) SymID)) {} : NonLoc(SymbolValKind, reinterpret_cast<void*>((uintptr_t) SymID)) {}
SymbolID getSymbol() const { SymbolRef getSymbol() const {
return (SymbolID) reinterpret_cast<uintptr_t>(Data); return (SymbolRef) reinterpret_cast<uintptr_t>(Data);
} }
static inline bool classof(const SVal* V) { static inline bool classof(const SVal* V) {
@ -371,8 +371,8 @@ public:
SymbolVal(unsigned SymID) SymbolVal(unsigned SymID)
: Loc(SymbolValKind, reinterpret_cast<void*>((uintptr_t) SymID)) {} : Loc(SymbolValKind, reinterpret_cast<void*>((uintptr_t) SymID)) {}
SymbolID getSymbol() const { SymbolRef getSymbol() const {
return (SymbolID) reinterpret_cast<uintptr_t>(Data); return (SymbolRef) reinterpret_cast<uintptr_t>(Data);
} }
static inline bool classof(const SVal* V) { static inline bool classof(const SVal* V) {

View File

@ -35,8 +35,8 @@ class ObjCIvarDecl;
class StoreManager { class StoreManager {
public: public:
typedef llvm::SmallSet<SymbolID, 20> LiveSymbolsTy; typedef llvm::SmallSet<SymbolRef, 20> LiveSymbolsTy;
typedef llvm::DenseSet<SymbolID> DeadSymbolsTy; typedef llvm::DenseSet<SymbolRef> DeadSymbolsTy;
virtual ~StoreManager() {} virtual ~StoreManager() {}

View File

@ -27,11 +27,11 @@ namespace clang {
class MemRegion; class MemRegion;
class SymbolManager; class SymbolManager;
class SymbolID { class SymbolRef {
unsigned Data; unsigned Data;
public: public:
SymbolID() : Data(~0U - 2) {} SymbolRef() : Data(~0U - 2) {}
SymbolID(unsigned x) : Data(x) {} SymbolRef(unsigned x) : Data(x) {}
bool isInitialized() const { return Data != (unsigned) (~0U - 2); } bool isInitialized() const { return Data != (unsigned) (~0U - 2); }
operator unsigned() const { return getNumber(); } operator unsigned() const { return getNumber(); }
@ -46,17 +46,17 @@ public:
} // end clang namespace } // end clang namespace
namespace llvm { namespace llvm {
template <> struct DenseMapInfo<clang::SymbolID> { template <> struct DenseMapInfo<clang::SymbolRef> {
static inline clang::SymbolID getEmptyKey() { static inline clang::SymbolRef getEmptyKey() {
return clang::SymbolID(~0U); return clang::SymbolRef(~0U);
} }
static inline clang::SymbolID getTombstoneKey() { static inline clang::SymbolRef getTombstoneKey() {
return clang::SymbolID(~0U - 1); return clang::SymbolRef(~0U - 1);
} }
static unsigned getHashValue(clang::SymbolID X) { static unsigned getHashValue(clang::SymbolRef X) {
return X.getNumber(); return X.getNumber();
} }
static bool isEqual(clang::SymbolID X, clang::SymbolID Y) { static bool isEqual(clang::SymbolRef X, clang::SymbolRef Y) {
return X.getNumber() == Y.getNumber(); return X.getNumber() == Y.getNumber();
} }
static bool isPod() { return true; } static bool isPod() { return true; }
@ -74,17 +74,17 @@ public:
private: private:
Kind K; Kind K;
SymbolID Sym; SymbolRef Sym;
protected: protected:
SymbolData(Kind k, SymbolID sym) : K(k), Sym(sym) {} SymbolData(Kind k, SymbolRef sym) : K(k), Sym(sym) {}
public: public:
virtual ~SymbolData() {} virtual ~SymbolData() {}
Kind getKind() const { return K; } Kind getKind() const { return K; }
SymbolID getSymbol() const { return Sym; } SymbolRef getSymbol() const { return Sym; }
QualType getType(const SymbolManager& SymMgr) const; QualType getType(const SymbolManager& SymMgr) const;
@ -98,7 +98,7 @@ class SymbolDataParmVar : public SymbolData {
ParmVarDecl *VD; ParmVarDecl *VD;
public: public:
SymbolDataParmVar(SymbolID MySym, ParmVarDecl* vd) SymbolDataParmVar(SymbolRef MySym, ParmVarDecl* vd)
: SymbolData(ParmKind, MySym), VD(vd) {} : SymbolData(ParmKind, MySym), VD(vd) {}
ParmVarDecl* getDecl() const { return VD; } ParmVarDecl* getDecl() const { return VD; }
@ -122,7 +122,7 @@ class SymbolDataGlobalVar : public SymbolData {
VarDecl *VD; VarDecl *VD;
public: public:
SymbolDataGlobalVar(SymbolID MySym, VarDecl* vd) : SymbolDataGlobalVar(SymbolRef MySym, VarDecl* vd) :
SymbolData(GlobalKind, MySym), VD(vd) {} SymbolData(GlobalKind, MySym), VD(vd) {}
VarDecl* getDecl() const { return VD; } VarDecl* getDecl() const { return VD; }
@ -147,7 +147,7 @@ class SymbolDataElement : public SymbolData {
const llvm::APSInt* Idx; const llvm::APSInt* Idx;
public: public:
SymbolDataElement(SymbolID MySym, const MemRegion* r, const llvm::APSInt* idx) SymbolDataElement(SymbolRef MySym, const MemRegion* r, const llvm::APSInt* idx)
: SymbolData(ElementKind, MySym), R(r), Idx(idx) {} : SymbolData(ElementKind, MySym), R(r), Idx(idx) {}
static void Profile(llvm::FoldingSetNodeID& profile, const MemRegion* R, static void Profile(llvm::FoldingSetNodeID& profile, const MemRegion* R,
@ -170,7 +170,7 @@ class SymbolDataField : public SymbolData {
const FieldDecl* D; const FieldDecl* D;
public: public:
SymbolDataField(SymbolID MySym, const MemRegion* r, const FieldDecl* d) SymbolDataField(SymbolRef MySym, const MemRegion* r, const FieldDecl* d)
: SymbolData(FieldKind, MySym), R(r), D(d) {} : SymbolData(FieldKind, MySym), R(r), D(d) {}
static void Profile(llvm::FoldingSetNodeID& profile, const MemRegion* R, static void Profile(llvm::FoldingSetNodeID& profile, const MemRegion* R,
@ -194,7 +194,7 @@ class SymbolConjured : public SymbolData {
unsigned Count; unsigned Count;
public: public:
SymbolConjured(SymbolID Sym, Stmt* s, QualType t, unsigned count) SymbolConjured(SymbolRef Sym, Stmt* s, QualType t, unsigned count)
: SymbolData(ConjuredKind, Sym), S(s), T(t), Count(count) {} : SymbolData(ConjuredKind, Sym), S(s), T(t), Count(count) {}
Stmt* getStmt() const { return S; } Stmt* getStmt() const { return S; }
@ -223,21 +223,21 @@ public:
// Constraints on symbols. Usually wrapped by SValues. // Constraints on symbols. Usually wrapped by SValues.
class SymIntConstraint : public llvm::FoldingSetNode { class SymIntConstraint : public llvm::FoldingSetNode {
SymbolID Symbol; SymbolRef Symbol;
BinaryOperator::Opcode Op; BinaryOperator::Opcode Op;
const llvm::APSInt& Val; const llvm::APSInt& Val;
public: public:
SymIntConstraint(SymbolID sym, BinaryOperator::Opcode op, SymIntConstraint(SymbolRef sym, BinaryOperator::Opcode op,
const llvm::APSInt& V) const llvm::APSInt& V)
: Symbol(sym), : Symbol(sym),
Op(op), Val(V) {} Op(op), Val(V) {}
BinaryOperator::Opcode getOpcode() const { return Op; } BinaryOperator::Opcode getOpcode() const { return Op; }
const SymbolID& getSymbol() const { return Symbol; } const SymbolRef& getSymbol() const { return Symbol; }
const llvm::APSInt& getInt() const { return Val; } const llvm::APSInt& getInt() const { return Val; }
static inline void Profile(llvm::FoldingSetNodeID& ID, static inline void Profile(llvm::FoldingSetNodeID& ID,
SymbolID Symbol, SymbolRef Symbol,
BinaryOperator::Opcode Op, BinaryOperator::Opcode Op,
const llvm::APSInt& Val) { const llvm::APSInt& Val) {
Symbol.Profile(ID); Symbol.Profile(ID);
@ -253,7 +253,7 @@ public:
class SymbolManager { class SymbolManager {
typedef llvm::FoldingSet<SymbolData> DataSetTy; typedef llvm::FoldingSet<SymbolData> DataSetTy;
typedef llvm::DenseMap<SymbolID, SymbolData*> DataMapTy; typedef llvm::DenseMap<SymbolRef, SymbolData*> DataMapTy;
DataSetTy DataSet; DataSetTy DataSet;
DataMapTy DataMap; DataMapTy DataMap;
@ -267,17 +267,17 @@ public:
~SymbolManager(); ~SymbolManager();
SymbolID getSymbol(VarDecl* D); SymbolRef getSymbol(VarDecl* D);
SymbolID getElementSymbol(const MemRegion* R, const llvm::APSInt* Idx); SymbolRef getElementSymbol(const MemRegion* R, const llvm::APSInt* Idx);
SymbolID getFieldSymbol(const MemRegion* R, const FieldDecl* D); SymbolRef getFieldSymbol(const MemRegion* R, const FieldDecl* D);
SymbolID getConjuredSymbol(Stmt* E, QualType T, unsigned VisitCount); SymbolRef getConjuredSymbol(Stmt* E, QualType T, unsigned VisitCount);
SymbolID getConjuredSymbol(Expr* E, unsigned VisitCount) { SymbolRef getConjuredSymbol(Expr* E, unsigned VisitCount) {
return getConjuredSymbol(E, E->getType(), VisitCount); return getConjuredSymbol(E, E->getType(), VisitCount);
} }
const SymbolData& getSymbolData(SymbolID ID) const; const SymbolData& getSymbolData(SymbolRef ID) const;
QualType getType(SymbolID ID) const { QualType getType(SymbolRef ID) const {
return getSymbolData(ID).getType(*this); return getSymbolData(ID).getType(*this);
} }
}; };

View File

@ -22,8 +22,8 @@ using namespace clang;
namespace { namespace {
typedef llvm::ImmutableMap<SymbolID,GRState::IntSetTy> ConstNotEqTy; typedef llvm::ImmutableMap<SymbolRef,GRState::IntSetTy> ConstNotEqTy;
typedef llvm::ImmutableMap<SymbolID,const llvm::APSInt*> ConstEqTy; typedef llvm::ImmutableMap<SymbolRef,const llvm::APSInt*> ConstEqTy;
// BasicConstraintManager only tracks equality and inequality constraints of // BasicConstraintManager only tracks equality and inequality constraints of
// constants and integer variables. // constants and integer variables.
@ -52,34 +52,34 @@ public:
const GRState* AssumeSymInt(const GRState* St, bool Assumption, const GRState* AssumeSymInt(const GRState* St, bool Assumption,
const SymIntConstraint& C, bool& isFeasible); const SymIntConstraint& C, bool& isFeasible);
const GRState* AssumeSymNE(const GRState* St, SymbolID sym, const GRState* AssumeSymNE(const GRState* St, SymbolRef sym,
const llvm::APSInt& V, bool& isFeasible); const llvm::APSInt& V, bool& isFeasible);
const GRState* AssumeSymEQ(const GRState* St, SymbolID sym, const GRState* AssumeSymEQ(const GRState* St, SymbolRef sym,
const llvm::APSInt& V, bool& isFeasible); const llvm::APSInt& V, bool& isFeasible);
const GRState* AssumeSymLT(const GRState* St, SymbolID sym, const GRState* AssumeSymLT(const GRState* St, SymbolRef sym,
const llvm::APSInt& V, bool& isFeasible); const llvm::APSInt& V, bool& isFeasible);
const GRState* AssumeSymGT(const GRState* St, SymbolID sym, const GRState* AssumeSymGT(const GRState* St, SymbolRef sym,
const llvm::APSInt& V, bool& isFeasible); const llvm::APSInt& V, bool& isFeasible);
const GRState* AssumeSymGE(const GRState* St, SymbolID sym, const GRState* AssumeSymGE(const GRState* St, SymbolRef sym,
const llvm::APSInt& V, bool& isFeasible); const llvm::APSInt& V, bool& isFeasible);
const GRState* AssumeSymLE(const GRState* St, SymbolID sym, const GRState* AssumeSymLE(const GRState* St, SymbolRef sym,
const llvm::APSInt& V, bool& isFeasible); const llvm::APSInt& V, bool& isFeasible);
const GRState* AssumeInBound(const GRState* St, SVal Idx, SVal UpperBound, const GRState* AssumeInBound(const GRState* St, SVal Idx, SVal UpperBound,
bool Assumption, bool& isFeasible); bool Assumption, bool& isFeasible);
const GRState* AddEQ(const GRState* St, SymbolID sym, const llvm::APSInt& V); const GRState* AddEQ(const GRState* St, SymbolRef sym, const llvm::APSInt& V);
const GRState* AddNE(const GRState* St, SymbolID sym, const llvm::APSInt& V); const GRState* AddNE(const GRState* St, SymbolRef sym, const llvm::APSInt& V);
const llvm::APSInt* getSymVal(const GRState* St, SymbolID sym); const llvm::APSInt* getSymVal(const GRState* St, SymbolRef sym);
bool isNotEqual(const GRState* St, SymbolID sym, const llvm::APSInt& V) const; bool isNotEqual(const GRState* St, SymbolRef sym, const llvm::APSInt& V) const;
bool isEqual(const GRState* St, SymbolID sym, const llvm::APSInt& V) const; bool isEqual(const GRState* St, SymbolRef sym, const llvm::APSInt& V) const;
const GRState* RemoveDeadBindings(const GRState* St, const GRState* RemoveDeadBindings(const GRState* St,
StoreManager::LiveSymbolsTy& LSymbols, StoreManager::LiveSymbolsTy& LSymbols,
@ -189,7 +189,7 @@ BasicConstraintManager::AssumeAux(const GRState* St,NonLoc Cond,
case nonloc::SymbolValKind: { case nonloc::SymbolValKind: {
nonloc::SymbolVal& SV = cast<nonloc::SymbolVal>(Cond); nonloc::SymbolVal& SV = cast<nonloc::SymbolVal>(Cond);
SymbolID sym = SV.getSymbol(); SymbolRef sym = SV.getSymbol();
if (Assumption) if (Assumption)
return AssumeSymNE(St, sym, BasicVals.getValue(0, SymMgr.getType(sym)), return AssumeSymNE(St, sym, BasicVals.getValue(0, SymMgr.getType(sym)),
@ -266,7 +266,7 @@ BasicConstraintManager::AssumeSymInt(const GRState* St, bool Assumption,
} }
const GRState* const GRState*
BasicConstraintManager::AssumeSymNE(const GRState* St, SymbolID sym, BasicConstraintManager::AssumeSymNE(const GRState* St, SymbolRef sym,
const llvm::APSInt& V, bool& isFeasible) { const llvm::APSInt& V, bool& isFeasible) {
// First, determine if sym == X, where X != V. // First, determine if sym == X, where X != V.
if (const llvm::APSInt* X = getSymVal(St, sym)) { if (const llvm::APSInt* X = getSymVal(St, sym)) {
@ -287,7 +287,7 @@ BasicConstraintManager::AssumeSymNE(const GRState* St, SymbolID sym,
} }
const GRState* const GRState*
BasicConstraintManager::AssumeSymEQ(const GRState* St, SymbolID sym, BasicConstraintManager::AssumeSymEQ(const GRState* St, SymbolRef sym,
const llvm::APSInt& V, bool& isFeasible) { const llvm::APSInt& V, bool& isFeasible) {
// First, determine if sym == X, where X != V. // First, determine if sym == X, where X != V.
if (const llvm::APSInt* X = getSymVal(St, sym)) { if (const llvm::APSInt* X = getSymVal(St, sym)) {
@ -310,7 +310,7 @@ BasicConstraintManager::AssumeSymEQ(const GRState* St, SymbolID sym,
// These logic will be handled in another ConstraintManager. // These logic will be handled in another ConstraintManager.
const GRState* const GRState*
BasicConstraintManager::AssumeSymLT(const GRState* St, SymbolID sym, BasicConstraintManager::AssumeSymLT(const GRState* St, SymbolRef sym,
const llvm::APSInt& V, bool& isFeasible) { const llvm::APSInt& V, bool& isFeasible) {
// Is 'V' the smallest possible value? // Is 'V' the smallest possible value?
@ -325,7 +325,7 @@ BasicConstraintManager::AssumeSymLT(const GRState* St, SymbolID sym,
} }
const GRState* const GRState*
BasicConstraintManager::AssumeSymGT(const GRState* St, SymbolID sym, BasicConstraintManager::AssumeSymGT(const GRState* St, SymbolRef sym,
const llvm::APSInt& V, bool& isFeasible) { const llvm::APSInt& V, bool& isFeasible) {
// Is 'V' the largest possible value? // Is 'V' the largest possible value?
@ -340,7 +340,7 @@ BasicConstraintManager::AssumeSymGT(const GRState* St, SymbolID sym,
} }
const GRState* const GRState*
BasicConstraintManager::AssumeSymGE(const GRState* St, SymbolID sym, BasicConstraintManager::AssumeSymGE(const GRState* St, SymbolRef sym,
const llvm::APSInt& V, bool& isFeasible) { const llvm::APSInt& V, bool& isFeasible) {
// Reject a path if the value of sym is a constant X and !(X >= V). // Reject a path if the value of sym is a constant X and !(X >= V).
@ -369,7 +369,7 @@ BasicConstraintManager::AssumeSymGE(const GRState* St, SymbolID sym,
} }
const GRState* const GRState*
BasicConstraintManager::AssumeSymLE(const GRState* St, SymbolID sym, BasicConstraintManager::AssumeSymLE(const GRState* St, SymbolRef sym,
const llvm::APSInt& V, bool& isFeasible) { const llvm::APSInt& V, bool& isFeasible) {
// Reject a path if the value of sym is a constant X and !(X <= V). // Reject a path if the value of sym is a constant X and !(X <= V).
@ -439,14 +439,14 @@ namespace clang {
}; };
} }
const GRState* BasicConstraintManager::AddEQ(const GRState* St, SymbolID sym, const GRState* BasicConstraintManager::AddEQ(const GRState* St, SymbolRef sym,
const llvm::APSInt& V) { const llvm::APSInt& V) {
// Create a new state with the old binding replaced. // Create a new state with the old binding replaced.
GRStateRef state(St, StateMgr); GRStateRef state(St, StateMgr);
return state.set<ConstEqTy>(sym, &V); return state.set<ConstEqTy>(sym, &V);
} }
const GRState* BasicConstraintManager::AddNE(const GRState* St, SymbolID sym, const GRState* BasicConstraintManager::AddNE(const GRState* St, SymbolRef sym,
const llvm::APSInt& V) { const llvm::APSInt& V) {
GRStateRef state(St, StateMgr); GRStateRef state(St, StateMgr);
@ -464,12 +464,12 @@ const GRState* BasicConstraintManager::AddNE(const GRState* St, SymbolID sym,
} }
const llvm::APSInt* BasicConstraintManager::getSymVal(const GRState* St, const llvm::APSInt* BasicConstraintManager::getSymVal(const GRState* St,
SymbolID sym) { SymbolRef sym) {
const ConstEqTy::data_type* T = St->get<ConstEqTy>(sym); const ConstEqTy::data_type* T = St->get<ConstEqTy>(sym);
return T ? *T : NULL; return T ? *T : NULL;
} }
bool BasicConstraintManager::isNotEqual(const GRState* St, SymbolID sym, bool BasicConstraintManager::isNotEqual(const GRState* St, SymbolRef sym,
const llvm::APSInt& V) const { const llvm::APSInt& V) const {
// Retrieve the NE-set associated with the given symbol. // Retrieve the NE-set associated with the given symbol.
@ -479,7 +479,7 @@ bool BasicConstraintManager::isNotEqual(const GRState* St, SymbolID sym,
return T ? T->contains(&V) : false; return T ? T->contains(&V) : false;
} }
bool BasicConstraintManager::isEqual(const GRState* St, SymbolID sym, bool BasicConstraintManager::isEqual(const GRState* St, SymbolRef sym,
const llvm::APSInt& V) const { const llvm::APSInt& V) const {
// Retrieve the EQ-set associated with the given symbol. // Retrieve the EQ-set associated with the given symbol.
const ConstEqTy::data_type* T = St->get<ConstEqTy>(sym); const ConstEqTy::data_type* T = St->get<ConstEqTy>(sym);
@ -497,7 +497,7 @@ const GRState* BasicConstraintManager::RemoveDeadBindings(const GRState* St,
ConstEqTy::Factory& CEFactory = state.get_context<ConstEqTy>(); ConstEqTy::Factory& CEFactory = state.get_context<ConstEqTy>();
for (ConstEqTy::iterator I = CE.begin(), E = CE.end(); I!=E; ++I) { for (ConstEqTy::iterator I = CE.begin(), E = CE.end(); I!=E; ++I) {
SymbolID sym = I.getKey(); SymbolRef sym = I.getKey();
if (!LSymbols.count(sym)) { if (!LSymbols.count(sym)) {
DSymbols.insert(sym); DSymbols.insert(sym);
CE = CEFactory.Remove(CE, sym); CE = CEFactory.Remove(CE, sym);
@ -509,7 +509,7 @@ const GRState* BasicConstraintManager::RemoveDeadBindings(const GRState* St,
ConstNotEqTy::Factory& CNEFactory = state.get_context<ConstNotEqTy>(); ConstNotEqTy::Factory& CNEFactory = state.get_context<ConstNotEqTy>();
for (ConstNotEqTy::iterator I = CNE.begin(), E = CNE.end(); I != E; ++I) { for (ConstNotEqTy::iterator I = CNE.begin(), E = CNE.end(); I != E; ++I) {
SymbolID sym = I.getKey(); SymbolRef sym = I.getKey();
if (!LSymbols.count(sym)) { if (!LSymbols.count(sym)) {
DSymbols.insert(sym); DSymbols.insert(sym);
CNE = CNEFactory.Remove(CNE, sym); CNE = CNEFactory.Remove(CNE, sym);

View File

@ -98,7 +98,7 @@ const llvm::APSInt& BasicValueFactory::getValue(uint64_t X, QualType T) {
} }
const SymIntConstraint& const SymIntConstraint&
BasicValueFactory::getConstraint(SymbolID sym, BinaryOperator::Opcode Op, BasicValueFactory::getConstraint(SymbolRef sym, BinaryOperator::Opcode Op,
const llvm::APSInt& V) { const llvm::APSInt& V) {
llvm::FoldingSetNodeID ID; llvm::FoldingSetNodeID ID;

View File

@ -326,7 +326,7 @@ namespace {
class VISIBILITY_HIDDEN NotableSymbolHandler class VISIBILITY_HIDDEN NotableSymbolHandler
: public StoreManager::BindingsHandler { : public StoreManager::BindingsHandler {
SymbolID Sym; SymbolRef Sym;
const GRState* PrevSt; const GRState* PrevSt;
Stmt* S; Stmt* S;
GRStateManager& VMgr; GRStateManager& VMgr;
@ -336,14 +336,14 @@ class VISIBILITY_HIDDEN NotableSymbolHandler
public: public:
NotableSymbolHandler(SymbolID sym, const GRState* prevst, Stmt* s, NotableSymbolHandler(SymbolRef sym, const GRState* prevst, Stmt* s,
GRStateManager& vmgr, ExplodedNode<GRState>* pred, GRStateManager& vmgr, ExplodedNode<GRState>* pred,
PathDiagnostic& pd, BugReporter& br) PathDiagnostic& pd, BugReporter& br)
: Sym(sym), PrevSt(prevst), S(s), VMgr(vmgr), Pred(pred), PD(pd), BR(br) {} : Sym(sym), PrevSt(prevst), S(s), VMgr(vmgr), Pred(pred), PD(pd), BR(br) {}
bool HandleBinding(StoreManager& SMgr, Store store, MemRegion* R, SVal V) { bool HandleBinding(StoreManager& SMgr, Store store, MemRegion* R, SVal V) {
SymbolID ScanSym; SymbolRef ScanSym;
if (loc::SymbolVal* SV = dyn_cast<loc::SymbolVal>(&V)) if (loc::SymbolVal* SV = dyn_cast<loc::SymbolVal>(&V))
ScanSym = SV->getSymbol(); ScanSym = SV->getSymbol();
@ -412,7 +412,7 @@ public:
} }
static void HandleNotableSymbol(ExplodedNode<GRState>* N, Stmt* S, static void HandleNotableSymbol(ExplodedNode<GRState>* N, Stmt* S,
SymbolID Sym, BugReporter& BR, SymbolRef Sym, BugReporter& BR,
PathDiagnostic& PD) { PathDiagnostic& PD) {
ExplodedNode<GRState>* Pred = N->pred_empty() ? 0 : *N->pred_begin(); ExplodedNode<GRState>* Pred = N->pred_empty() ? 0 : *N->pred_begin();
@ -432,7 +432,7 @@ namespace {
class VISIBILITY_HIDDEN ScanNotableSymbols class VISIBILITY_HIDDEN ScanNotableSymbols
: public StoreManager::BindingsHandler { : public StoreManager::BindingsHandler {
llvm::SmallSet<SymbolID, 10> AlreadyProcessed; llvm::SmallSet<SymbolRef, 10> AlreadyProcessed;
ExplodedNode<GRState>* N; ExplodedNode<GRState>* N;
Stmt* S; Stmt* S;
GRBugReporter& BR; GRBugReporter& BR;
@ -444,7 +444,7 @@ public:
: N(n), S(s), BR(br), PD(pd) {} : N(n), S(s), BR(br), PD(pd) {}
bool HandleBinding(StoreManager& SMgr, Store store, MemRegion* R, SVal V) { bool HandleBinding(StoreManager& SMgr, Store store, MemRegion* R, SVal V) {
SymbolID ScanSym; SymbolRef ScanSym;
if (loc::SymbolVal* SV = dyn_cast<loc::SymbolVal>(&V)) if (loc::SymbolVal* SV = dyn_cast<loc::SymbolVal>(&V))
ScanSym = SV->getSymbol(); ScanSym = SV->getSymbol();

View File

@ -1267,7 +1267,7 @@ void RefVal::print(std::ostream& Out) const {
// RefBindings - State used to track object reference counts. // RefBindings - State used to track object reference counts.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
typedef llvm::ImmutableMap<SymbolID, RefVal> RefBindings; typedef llvm::ImmutableMap<SymbolRef, RefVal> RefBindings;
static int RefBIndex = 0; static int RefBIndex = 0;
namespace clang { namespace clang {
@ -1281,8 +1281,8 @@ namespace clang {
// ARBindings - State used to track objects in autorelease pools. // ARBindings - State used to track objects in autorelease pools.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
typedef llvm::ImmutableSet<SymbolID> ARPoolContents; typedef llvm::ImmutableSet<SymbolRef> ARPoolContents;
typedef llvm::ImmutableList< std::pair<SymbolID, ARPoolContents*> > ARBindings; typedef llvm::ImmutableList< std::pair<SymbolRef, ARPoolContents*> > ARBindings;
static int AutoRBIndex = 0; static int AutoRBIndex = 0;
namespace clang { namespace clang {
@ -1301,13 +1301,13 @@ namespace {
class VISIBILITY_HIDDEN CFRefCount : public GRSimpleVals { class VISIBILITY_HIDDEN CFRefCount : public GRSimpleVals {
public: public:
// Type definitions. // Type definitions.
typedef llvm::DenseMap<GRExprEngine::NodeTy*,std::pair<Expr*, SymbolID> > typedef llvm::DenseMap<GRExprEngine::NodeTy*,std::pair<Expr*, SymbolRef> >
ReleasesNotOwnedTy; ReleasesNotOwnedTy;
typedef ReleasesNotOwnedTy UseAfterReleasesTy; typedef ReleasesNotOwnedTy UseAfterReleasesTy;
typedef llvm::DenseMap<GRExprEngine::NodeTy*, typedef llvm::DenseMap<GRExprEngine::NodeTy*,
std::vector<std::pair<SymbolID,bool> >*> std::vector<std::pair<SymbolRef,bool> >*>
LeaksTy; LeaksTy;
class BindingsPrinter : public GRState::Printer { class BindingsPrinter : public GRState::Printer {
@ -1324,10 +1324,10 @@ private:
ReleasesNotOwnedTy ReleasesNotOwned; ReleasesNotOwnedTy ReleasesNotOwned;
LeaksTy Leaks; LeaksTy Leaks;
RefBindings Update(RefBindings B, SymbolID sym, RefVal V, ArgEffect E, RefBindings Update(RefBindings B, SymbolRef sym, RefVal V, ArgEffect E,
RefVal::Kind& hasErr, RefBindings::Factory& RefBFactory); RefVal::Kind& hasErr, RefBindings::Factory& RefBFactory);
RefVal::Kind& Update(GRStateRef& state, SymbolID sym, RefVal V, RefVal::Kind& Update(GRStateRef& state, SymbolRef sym, RefVal V,
ArgEffect E, RefVal::Kind& hasErr) { ArgEffect E, RefVal::Kind& hasErr) {
state = state.set<RefBindings>(Update(state.get<RefBindings>(), sym, V, state = state.set<RefBindings>(Update(state.get<RefBindings>(), sym, V,
@ -1341,11 +1341,11 @@ private:
Expr* NodeExpr, Expr* ErrorExpr, Expr* NodeExpr, Expr* ErrorExpr,
ExplodedNode<GRState>* Pred, ExplodedNode<GRState>* Pred,
const GRState* St, const GRState* St,
RefVal::Kind hasErr, SymbolID Sym); RefVal::Kind hasErr, SymbolRef Sym);
std::pair<GRStateRef, bool> std::pair<GRStateRef, bool>
HandleSymbolDeath(GRStateManager& VMgr, const GRState* St, HandleSymbolDeath(GRStateManager& VMgr, const GRState* St,
const Decl* CD, SymbolID sid, RefVal V, bool& hasLeak); const Decl* CD, SymbolRef sid, RefVal V, bool& hasLeak);
public: public:
@ -1487,7 +1487,7 @@ void CFRefCount::ProcessNonLeakError(ExplodedNodeSet<GRState>& Dst,
Expr* NodeExpr, Expr* ErrorExpr, Expr* NodeExpr, Expr* ErrorExpr,
ExplodedNode<GRState>* Pred, ExplodedNode<GRState>* Pred,
const GRState* St, const GRState* St,
RefVal::Kind hasErr, SymbolID Sym) { RefVal::Kind hasErr, SymbolRef Sym) {
Builder.BuildSinks = true; Builder.BuildSinks = true;
GRExprEngine::NodeTy* N = Builder.MakeNode(Dst, NodeExpr, Pred, St); GRExprEngine::NodeTy* N = Builder.MakeNode(Dst, NodeExpr, Pred, St);
@ -1555,13 +1555,13 @@ void CFRefCount::EvalSummary(ExplodedNodeSet<GRState>& Dst,
RefVal::Kind hasErr = (RefVal::Kind) 0; RefVal::Kind hasErr = (RefVal::Kind) 0;
unsigned idx = 0; unsigned idx = 0;
Expr* ErrorExpr = NULL; Expr* ErrorExpr = NULL;
SymbolID ErrorSym = 0; SymbolRef ErrorSym = 0;
for (ExprIterator I = arg_beg; I != arg_end; ++I, ++idx) { for (ExprIterator I = arg_beg; I != arg_end; ++I, ++idx) {
SVal V = state.GetSVal(*I); SVal V = state.GetSVal(*I);
if (isa<loc::SymbolVal>(V)) { if (isa<loc::SymbolVal>(V)) {
SymbolID Sym = cast<loc::SymbolVal>(V).getSymbol(); SymbolRef Sym = cast<loc::SymbolVal>(V).getSymbol();
if (RefBindings::data_type* T = state.get<RefBindings>(Sym)) if (RefBindings::data_type* T = state.get<RefBindings>(Sym))
if (Update(state, Sym, *T, GetArgE(Summ, idx), hasErr)) { if (Update(state, Sym, *T, GetArgE(Summ, idx), hasErr)) {
ErrorExpr = *I; ErrorExpr = *I;
@ -1594,7 +1594,7 @@ void CFRefCount::EvalSummary(ExplodedNodeSet<GRState>& Dst,
SVal X = state.GetSVal(*MR); SVal X = state.GetSVal(*MR);
if (isa<loc::SymbolVal>(X)) { if (isa<loc::SymbolVal>(X)) {
SymbolID Sym = cast<loc::SymbolVal>(X).getSymbol(); SymbolRef Sym = cast<loc::SymbolVal>(X).getSymbol();
state = state.remove<RefBindings>(Sym); state = state.remove<RefBindings>(Sym);
} }
@ -1606,7 +1606,7 @@ void CFRefCount::EvalSummary(ExplodedNodeSet<GRState>& Dst,
// FIXME: handle structs. // FIXME: handle structs.
if (Loc::IsLocType(T) || (T->isIntegerType() && T->isScalarType())) { if (Loc::IsLocType(T) || (T->isIntegerType() && T->isScalarType())) {
SymbolID NewSym = SymbolRef NewSym =
Eng.getSymbolManager().getConjuredSymbol(*I, T, Count); Eng.getSymbolManager().getConjuredSymbol(*I, T, Count);
state = state.BindLoc(*MR, state = state.BindLoc(*MR,
@ -1635,7 +1635,7 @@ void CFRefCount::EvalSummary(ExplodedNodeSet<GRState>& Dst,
if (!ErrorExpr && Receiver) { if (!ErrorExpr && Receiver) {
SVal V = state.GetSVal(Receiver); SVal V = state.GetSVal(Receiver);
if (isa<loc::SymbolVal>(V)) { if (isa<loc::SymbolVal>(V)) {
SymbolID Sym = cast<loc::SymbolVal>(V).getSymbol(); SymbolRef Sym = cast<loc::SymbolVal>(V).getSymbol();
if (const RefVal* T = state.get<RefBindings>(Sym)) if (const RefVal* T = state.get<RefBindings>(Sym))
if (Update(state, Sym, *T, GetReceiverE(Summ), hasErr)) { if (Update(state, Sym, *T, GetReceiverE(Summ), hasErr)) {
ErrorExpr = Receiver; ErrorExpr = Receiver;
@ -1671,7 +1671,7 @@ void CFRefCount::EvalSummary(ExplodedNodeSet<GRState>& Dst,
if (Loc::IsLocType(T) || (T->isIntegerType() && T->isScalarType())) { if (Loc::IsLocType(T) || (T->isIntegerType() && T->isScalarType())) {
unsigned Count = Builder.getCurrentBlockCount(); unsigned Count = Builder.getCurrentBlockCount();
SymbolID Sym = Eng.getSymbolManager().getConjuredSymbol(Ex, Count); SymbolRef Sym = Eng.getSymbolManager().getConjuredSymbol(Ex, Count);
SVal X = Loc::IsLocType(Ex->getType()) SVal X = Loc::IsLocType(Ex->getType())
? cast<SVal>(loc::SymbolVal(Sym)) ? cast<SVal>(loc::SymbolVal(Sym))
@ -1702,7 +1702,7 @@ void CFRefCount::EvalSummary(ExplodedNodeSet<GRState>& Dst,
case RetEffect::OwnedAllocatedSymbol: case RetEffect::OwnedAllocatedSymbol:
case RetEffect::OwnedSymbol: { case RetEffect::OwnedSymbol: {
unsigned Count = Builder.getCurrentBlockCount(); unsigned Count = Builder.getCurrentBlockCount();
SymbolID Sym = Eng.getSymbolManager().getConjuredSymbol(Ex, Count); SymbolRef Sym = Eng.getSymbolManager().getConjuredSymbol(Ex, Count);
QualType RetT = GetReturnType(Ex, Eng.getContext()); QualType RetT = GetReturnType(Ex, Eng.getContext());
state = state.set<RefBindings>(Sym, RefVal::makeOwned(RetT)); state = state.set<RefBindings>(Sym, RefVal::makeOwned(RetT));
@ -1722,7 +1722,7 @@ void CFRefCount::EvalSummary(ExplodedNodeSet<GRState>& Dst,
case RetEffect::NotOwnedSymbol: { case RetEffect::NotOwnedSymbol: {
unsigned Count = Builder.getCurrentBlockCount(); unsigned Count = Builder.getCurrentBlockCount();
SymbolID Sym = Eng.getSymbolManager().getConjuredSymbol(Ex, Count); SymbolRef Sym = Eng.getSymbolManager().getConjuredSymbol(Ex, Count);
QualType RetT = GetReturnType(Ex, Eng.getContext()); QualType RetT = GetReturnType(Ex, Eng.getContext());
state = state.set<RefBindings>(Sym, RefVal::makeNotOwned(RetT)); state = state.set<RefBindings>(Sym, RefVal::makeNotOwned(RetT));
@ -1770,7 +1770,7 @@ void CFRefCount::EvalObjCMessageExpr(ExplodedNodeSet<GRState>& Dst,
SVal V = Eng.getStateManager().GetSVal(St, Receiver ); SVal V = Eng.getStateManager().GetSVal(St, Receiver );
if (isa<loc::SymbolVal>(V)) { if (isa<loc::SymbolVal>(V)) {
SymbolID Sym = cast<loc::SymbolVal>(V).getSymbol(); SymbolRef Sym = cast<loc::SymbolVal>(V).getSymbol();
if (const RefVal* T = St->get<RefBindings>(Sym)) { if (const RefVal* T = St->get<RefBindings>(Sym)) {
QualType Ty = T->getType(); QualType Ty = T->getType();
@ -1839,7 +1839,7 @@ void CFRefCount::EvalStore(ExplodedNodeSet<GRState>& Dst,
// (3) we are binding to a memregion with stack storage that the store // (3) we are binding to a memregion with stack storage that the store
// does not understand. // does not understand.
SymbolID Sym = cast<loc::SymbolVal>(Val).getSymbol(); SymbolRef Sym = cast<loc::SymbolVal>(Val).getSymbol();
GRStateRef state(St, Eng.getStateManager()); GRStateRef state(St, Eng.getStateManager());
if (!isa<loc::MemRegionVal>(TargetLV)) if (!isa<loc::MemRegionVal>(TargetLV))
@ -1878,7 +1878,7 @@ void CFRefCount::EvalStore(ExplodedNodeSet<GRState>& Dst,
std::pair<GRStateRef,bool> std::pair<GRStateRef,bool>
CFRefCount::HandleSymbolDeath(GRStateManager& VMgr, CFRefCount::HandleSymbolDeath(GRStateManager& VMgr,
const GRState* St, const Decl* CD, const GRState* St, const Decl* CD,
SymbolID sid, SymbolRef sid,
RefVal V, bool& hasLeak) { RefVal V, bool& hasLeak) {
GRStateRef state(St, VMgr); GRStateRef state(St, VMgr);
@ -1913,7 +1913,7 @@ void CFRefCount::EvalEndPath(GRExprEngine& Eng,
const GRState* St = Builder.getState(); const GRState* St = Builder.getState();
RefBindings B = St->get<RefBindings>(); RefBindings B = St->get<RefBindings>();
llvm::SmallVector<std::pair<SymbolID, bool>, 10> Leaked; llvm::SmallVector<std::pair<SymbolRef, bool>, 10> Leaked;
const Decl* CodeDecl = &Eng.getGraph().getCodeDecl(); const Decl* CodeDecl = &Eng.getGraph().getCodeDecl();
for (RefBindings::iterator I = B.begin(), E = B.end(); I != E; ++I) { for (RefBindings::iterator I = B.begin(), E = B.end(); I != E; ++I) {
@ -1935,11 +1935,11 @@ void CFRefCount::EvalEndPath(GRExprEngine& Eng,
if (!N) if (!N)
return; return;
std::vector<std::pair<SymbolID,bool> >*& LeaksAtNode = Leaks[N]; std::vector<std::pair<SymbolRef,bool> >*& LeaksAtNode = Leaks[N];
assert (!LeaksAtNode); assert (!LeaksAtNode);
LeaksAtNode = new std::vector<std::pair<SymbolID,bool> >(); LeaksAtNode = new std::vector<std::pair<SymbolRef,bool> >();
for (llvm::SmallVector<std::pair<SymbolID,bool>, 10>::iterator for (llvm::SmallVector<std::pair<SymbolRef,bool>, 10>::iterator
I = Leaked.begin(), E = Leaked.end(); I != E; ++I) I = Leaked.begin(), E = Leaked.end(); I != E; ++I)
(*LeaksAtNode).push_back(*I); (*LeaksAtNode).push_back(*I);
} }
@ -1957,7 +1957,7 @@ void CFRefCount::EvalDeadSymbols(ExplodedNodeSet<GRState>& Dst,
// FIXME: a lot of copy-and-paste from EvalEndPath. Refactor. // FIXME: a lot of copy-and-paste from EvalEndPath. Refactor.
RefBindings B = St->get<RefBindings>(); RefBindings B = St->get<RefBindings>();
llvm::SmallVector<std::pair<SymbolID,bool>, 10> Leaked; llvm::SmallVector<std::pair<SymbolRef,bool>, 10> Leaked;
for (GRStateManager::DeadSymbolsTy::const_iterator for (GRStateManager::DeadSymbolsTy::const_iterator
I=Dead.begin(), E=Dead.end(); I!=E; ++I) { I=Dead.begin(), E=Dead.end(); I!=E; ++I) {
@ -1986,11 +1986,11 @@ void CFRefCount::EvalDeadSymbols(ExplodedNodeSet<GRState>& Dst,
if (!N) if (!N)
return; return;
std::vector<std::pair<SymbolID,bool> >*& LeaksAtNode = Leaks[N]; std::vector<std::pair<SymbolRef,bool> >*& LeaksAtNode = Leaks[N];
assert (!LeaksAtNode); assert (!LeaksAtNode);
LeaksAtNode = new std::vector<std::pair<SymbolID,bool> >(); LeaksAtNode = new std::vector<std::pair<SymbolRef,bool> >();
for (llvm::SmallVector<std::pair<SymbolID,bool>, 10>::iterator for (llvm::SmallVector<std::pair<SymbolRef,bool>, 10>::iterator
I = Leaked.begin(), E = Leaked.end(); I != E; ++I) I = Leaked.begin(), E = Leaked.end(); I != E; ++I)
(*LeaksAtNode).push_back(*I); (*LeaksAtNode).push_back(*I);
} }
@ -2013,7 +2013,7 @@ void CFRefCount::EvalReturn(ExplodedNodeSet<GRState>& Dst,
return; return;
// Get the reference count binding (if any). // Get the reference count binding (if any).
SymbolID Sym = cast<loc::SymbolVal>(V).getSymbol(); SymbolRef Sym = cast<loc::SymbolVal>(V).getSymbol();
const RefVal* T = state.get<RefBindings>(Sym); const RefVal* T = state.get<RefBindings>(Sym);
if (!T) if (!T)
@ -2084,7 +2084,7 @@ const GRState* CFRefCount::EvalAssume(GRStateManager& VMgr,
return state; return state;
} }
RefBindings CFRefCount::Update(RefBindings B, SymbolID sym, RefBindings CFRefCount::Update(RefBindings B, SymbolRef sym,
RefVal V, ArgEffect E, RefVal V, ArgEffect E,
RefVal::Kind& hasErr, RefVal::Kind& hasErr,
RefBindings::Factory& RefBFactory) { RefBindings::Factory& RefBFactory) {
@ -2270,9 +2270,9 @@ namespace {
//===---------===// //===---------===//
class VISIBILITY_HIDDEN CFRefReport : public RangedBugReport { class VISIBILITY_HIDDEN CFRefReport : public RangedBugReport {
SymbolID Sym; SymbolRef Sym;
public: public:
CFRefReport(CFRefBug& D, ExplodedNode<GRState> *n, SymbolID sym) CFRefReport(CFRefBug& D, ExplodedNode<GRState> *n, SymbolRef sym)
: RangedBugReport(D, n), Sym(sym) {} : RangedBugReport(D, n), Sym(sym) {}
virtual ~CFRefReport() {} virtual ~CFRefReport() {}
@ -2293,7 +2293,7 @@ namespace {
beg = end = 0; beg = end = 0;
} }
SymbolID getSymbol() const { return Sym; } SymbolRef getSymbol() const { return Sym; }
virtual PathDiagnosticPiece* getEndPath(BugReporter& BR, virtual PathDiagnosticPiece* getEndPath(BugReporter& BR,
ExplodedNode<GRState>* N); ExplodedNode<GRState>* N);
@ -2491,12 +2491,12 @@ PathDiagnosticPiece* CFRefReport::VisitNode(ExplodedNode<GRState>* N,
namespace { namespace {
class VISIBILITY_HIDDEN FindUniqueBinding : class VISIBILITY_HIDDEN FindUniqueBinding :
public StoreManager::BindingsHandler { public StoreManager::BindingsHandler {
SymbolID Sym; SymbolRef Sym;
MemRegion* Binding; MemRegion* Binding;
bool First; bool First;
public: public:
FindUniqueBinding(SymbolID sym) : Sym(sym), Binding(0), First(true) {} FindUniqueBinding(SymbolRef sym) : Sym(sym), Binding(0), First(true) {}
bool HandleBinding(StoreManager& SMgr, Store store, MemRegion* R, SVal val) { bool HandleBinding(StoreManager& SMgr, Store store, MemRegion* R, SVal val) {
if (const loc::SymbolVal* SV = dyn_cast<loc::SymbolVal>(&val)) { if (const loc::SymbolVal* SV = dyn_cast<loc::SymbolVal>(&val)) {
@ -2527,7 +2527,7 @@ class VISIBILITY_HIDDEN FindUniqueBinding :
static std::pair<ExplodedNode<GRState>*,MemRegion*> static std::pair<ExplodedNode<GRState>*,MemRegion*>
GetAllocationSite(GRStateManager* StateMgr, ExplodedNode<GRState>* N, GetAllocationSite(GRStateManager* StateMgr, ExplodedNode<GRState>* N,
SymbolID Sym) { SymbolRef Sym) {
// Find both first node that referred to the tracked symbol and the // Find both first node that referred to the tracked symbol and the
// memory location that value was store to. // memory location that value was store to.
@ -2678,7 +2678,7 @@ void Leak::EmitWarnings(BugReporter& BR) {
for (CFRefCount::leaks_iterator I = TF.leaks_begin(), for (CFRefCount::leaks_iterator I = TF.leaks_begin(),
E = TF.leaks_end(); I != E; ++I) { E = TF.leaks_end(); I != E; ++I) {
std::vector<std::pair<SymbolID, bool> >& SymV = *(I->second); std::vector<std::pair<SymbolRef, bool> >& SymV = *(I->second);
unsigned n = SymV.size(); unsigned n = SymV.size();
for (unsigned i = 0; i < n; ++i) { for (unsigned i = 0; i < n; ++i) {
@ -2701,7 +2701,7 @@ bool Leak::isCached(BugReport& R) {
// With leaks, we want to unique them by the location where they were // With leaks, we want to unique them by the location where they were
// allocated, and only report a single path. // allocated, and only report a single path.
SymbolID Sym = static_cast<CFRefReport&>(R).getSymbol(); SymbolRef Sym = static_cast<CFRefReport&>(R).getSymbol();
ExplodedNode<GRState>* AllocNode = ExplodedNode<GRState>* AllocNode =
GetAllocationSite(0, R.getEndNode(), Sym).first; GetAllocationSite(0, R.getEndNode(), Sym).first;

View File

@ -1799,11 +1799,11 @@ void GRExprEngine::VisitDeclStmt(DeclStmt* DS, NodeTy* Pred, NodeSet& Dst) {
// UnknownVal. // UnknownVal.
if (InitVal.isUnknown()) { if (InitVal.isUnknown()) {
if (Loc::IsLocType(T)) { if (Loc::IsLocType(T)) {
SymbolID Sym = SymMgr.getConjuredSymbol(InitEx, Count); SymbolRef Sym = SymMgr.getConjuredSymbol(InitEx, Count);
InitVal = loc::SymbolVal(Sym); InitVal = loc::SymbolVal(Sym);
} }
else if (T->isIntegerType() && T->isScalarType()) { else if (T->isIntegerType() && T->isScalarType()) {
SymbolID Sym = SymMgr.getConjuredSymbol(InitEx, Count); SymbolRef Sym = SymMgr.getConjuredSymbol(InitEx, Count);
InitVal = nonloc::SymbolVal(Sym); InitVal = nonloc::SymbolVal(Sym);
} }
} }
@ -2399,7 +2399,7 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
if (RightV.isUnknown() && (Loc::IsLocType(T) || if (RightV.isUnknown() && (Loc::IsLocType(T) ||
(T->isScalarType() && T->isIntegerType()))) { (T->isScalarType() && T->isIntegerType()))) {
unsigned Count = Builder->getCurrentBlockCount(); unsigned Count = Builder->getCurrentBlockCount();
SymbolID Sym = SymMgr.getConjuredSymbol(B->getRHS(), Count); SymbolRef Sym = SymMgr.getConjuredSymbol(B->getRHS(), Count);
RightV = Loc::IsLocType(T) RightV = Loc::IsLocType(T)
? cast<SVal>(loc::SymbolVal(Sym)) ? cast<SVal>(loc::SymbolVal(Sym))
@ -2562,7 +2562,7 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
// The symbolic value is actually for the type of the left-hand side // The symbolic value is actually for the type of the left-hand side
// expression, not the computation type, as this is the value the // expression, not the computation type, as this is the value the
// LValue on the LHS will bind to. // LValue on the LHS will bind to.
SymbolID Sym = SymMgr.getConjuredSymbol(B->getRHS(), LTy, Count); SymbolRef Sym = SymMgr.getConjuredSymbol(B->getRHS(), LTy, Count);
LHSVal = Loc::IsLocType(LTy) LHSVal = Loc::IsLocType(LTy)
? cast<SVal>(loc::SymbolVal(Sym)) ? cast<SVal>(loc::SymbolVal(Sym))
: cast<SVal>(nonloc::SymbolVal(Sym)); : cast<SVal>(nonloc::SymbolVal(Sym));

View File

@ -415,7 +415,7 @@ void GRSimpleVals::EvalCall(ExplodedNodeSet<GRState>& Dst,
QualType T = CE->getType(); QualType T = CE->getType();
if (Loc::IsLocType(T) || (T->isIntegerType() && T->isScalarType())) { if (Loc::IsLocType(T) || (T->isIntegerType() && T->isScalarType())) {
unsigned Count = Builder.getCurrentBlockCount(); unsigned Count = Builder.getCurrentBlockCount();
SymbolID Sym = Eng.getSymbolManager().getConjuredSymbol(CE, Count); SymbolRef Sym = Eng.getSymbolManager().getConjuredSymbol(CE, Count);
SVal X = Loc::IsLocType(CE->getType()) SVal X = Loc::IsLocType(CE->getType())
? cast<SVal>(loc::SymbolVal(Sym)) ? cast<SVal>(loc::SymbolVal(Sym))

View File

@ -7,7 +7,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file defines SymbolID, ExprBindKey, and GRState* // This file defines SymbolRef, ExprBindKey, and GRState*
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

View File

@ -90,7 +90,7 @@ void DeclRegion::Profile(llvm::FoldingSetNodeID& ID) const {
DeclRegion::ProfileRegion(ID, D, superRegion, getKind()); DeclRegion::ProfileRegion(ID, D, superRegion, getKind());
} }
void SymbolicRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, SymbolID sym) { void SymbolicRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, SymbolRef sym) {
ID.AddInteger((unsigned) MemRegion::SymbolicRegionKind); ID.AddInteger((unsigned) MemRegion::SymbolicRegionKind);
ID.AddInteger(sym.getNumber()); ID.AddInteger(sym.getNumber());
} }
@ -300,7 +300,7 @@ ElementRegion* MemRegionManager::getElementRegion(SVal Idx,
} }
/// getSymbolicRegion - Retrieve or create a "symbolic" memory region. /// getSymbolicRegion - Retrieve or create a "symbolic" memory region.
SymbolicRegion* MemRegionManager::getSymbolicRegion(const SymbolID sym) { SymbolicRegion* MemRegionManager::getSymbolicRegion(const SymbolRef sym) {
llvm::FoldingSetNodeID ID; llvm::FoldingSetNodeID ID;
SymbolicRegion::ProfileRegion(ID, sym); SymbolicRegion::ProfileRegion(ID, sym);

View File

@ -734,7 +734,7 @@ Store RegionStoreManager::RemoveDeadBindings(const GRState* state, Stmt* Loc,
// Mark all non-live symbols that this region references as dead. // Mark all non-live symbols that this region references as dead.
if (const SymbolicRegion* SymR = dyn_cast<SymbolicRegion>(R)) { if (const SymbolicRegion* SymR = dyn_cast<SymbolicRegion>(R)) {
SymbolID Sym = SymR->getSymbol(); SymbolRef Sym = SymR->getSymbol();
if (!LSymbols.count(Sym)) DSymbols.insert(Sym); if (!LSymbols.count(Sym)) DSymbols.insert(Sym);
} }

View File

@ -29,9 +29,9 @@ SVal::symbol_iterator SVal::symbol_begin() const {
// FIXME: This is a rat's nest. Cleanup. // FIXME: This is a rat's nest. Cleanup.
if (isa<loc::SymbolVal>(this)) if (isa<loc::SymbolVal>(this))
return symbol_iterator(SymbolID((uintptr_t)Data)); return symbol_iterator(SymbolRef((uintptr_t)Data));
else if (isa<nonloc::SymbolVal>(this)) else if (isa<nonloc::SymbolVal>(this))
return symbol_iterator(SymbolID((uintptr_t)Data)); return symbol_iterator(SymbolRef((uintptr_t)Data));
else if (isa<nonloc::SymIntConstraintVal>(this)) { else if (isa<nonloc::SymIntConstraintVal>(this)) {
const SymIntConstraint& C = const SymIntConstraint& C =
cast<nonloc::SymIntConstraintVal>(this)->getConstraint(); cast<nonloc::SymIntConstraintVal>(this)->getConstraint();

View File

@ -16,7 +16,7 @@
using namespace clang; using namespace clang;
SymbolID SymbolManager::getSymbol(VarDecl* D) { SymbolRef SymbolManager::getSymbol(VarDecl* D) {
assert (isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D) || assert (isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D) ||
D->hasGlobalStorage()); D->hasGlobalStorage());
@ -52,7 +52,7 @@ SymbolID SymbolManager::getSymbol(VarDecl* D) {
return SymbolCounter++; return SymbolCounter++;
} }
SymbolID SymbolManager::getElementSymbol(const MemRegion* R, SymbolRef SymbolManager::getElementSymbol(const MemRegion* R,
const llvm::APSInt* Idx){ const llvm::APSInt* Idx){
llvm::FoldingSetNodeID ID; llvm::FoldingSetNodeID ID;
SymbolDataElement::Profile(ID, R, Idx); SymbolDataElement::Profile(ID, R, Idx);
@ -70,7 +70,7 @@ SymbolID SymbolManager::getElementSymbol(const MemRegion* R,
return SymbolCounter++; return SymbolCounter++;
} }
SymbolID SymbolManager::getFieldSymbol(const MemRegion* R, const FieldDecl* D) { SymbolRef SymbolManager::getFieldSymbol(const MemRegion* R, const FieldDecl* D) {
llvm::FoldingSetNodeID ID; llvm::FoldingSetNodeID ID;
SymbolDataField::Profile(ID, R, D); SymbolDataField::Profile(ID, R, D);
void* InsertPos; void* InsertPos;
@ -87,7 +87,7 @@ SymbolID SymbolManager::getFieldSymbol(const MemRegion* R, const FieldDecl* D) {
return SymbolCounter++; return SymbolCounter++;
} }
SymbolID SymbolManager::getConjuredSymbol(Stmt* E, QualType T, unsigned Count) { SymbolRef SymbolManager::getConjuredSymbol(Stmt* E, QualType T, unsigned Count) {
llvm::FoldingSetNodeID profile; llvm::FoldingSetNodeID profile;
SymbolConjured::Profile(profile, E, T, Count); SymbolConjured::Profile(profile, E, T, Count);
@ -107,7 +107,7 @@ SymbolID SymbolManager::getConjuredSymbol(Stmt* E, QualType T, unsigned Count) {
return SymbolCounter++; return SymbolCounter++;
} }
const SymbolData& SymbolManager::getSymbolData(SymbolID Sym) const { const SymbolData& SymbolManager::getSymbolData(SymbolRef Sym) const {
DataMapTy::const_iterator I = DataMap.find(Sym); DataMapTy::const_iterator I = DataMap.find(Sym);
assert (I != DataMap.end()); assert (I != DataMap.end());
return *I->second; return *I->second;