namespace loc {
-enum Kind { GotoLabelKind, MemRegionKind, FuncValKind, ConcreteIntKind };
+enum Kind { GotoLabelKind, MemRegionKind, ConcreteIntKind };
class GotoLabel : public Loc {
public:
}
};
-class FuncVal : public Loc {
-public:
- FuncVal(const FunctionDecl* fd) : Loc(FuncValKind, fd) {}
-
- FunctionDecl* getDecl() const {
- return static_cast<FunctionDecl*>(Data);
- }
-
- inline bool operator==(const FuncVal& R) const {
- return getDecl() == R.getDecl();
- }
-
- inline bool operator!=(const FuncVal& R) const {
- return getDecl() != R.getDecl();
- }
-
- // Implement isa<T> support.
- static inline bool classof(const SVal* V) {
- return V->getBaseKind() == LocKind &&
- V->getSubKind() == FuncValKind;
- }
-
- static inline bool classof(const Loc* V) {
- return V->getSubKind() == FuncValKind;
- }
-};
-
class ConcreteInt : public Loc {
public:
ConcreteInt(const llvm::APSInt& V) : Loc(ConcreteIntKind, &V) {}
switch(BaseL.getSubKind()) {
case loc::GotoLabelKind:
- case loc::FuncValKind:
- // Technically we can get here if people do funny things with casts.
return UndefinedVal();
case loc::MemRegionKind:
switch(BaseL.getSubKind()) {
case loc::GotoLabelKind:
- case loc::FuncValKind:
// Technically we can get here if people do funny things with casts.
return UndefinedVal();
// they are doing a quick scan through their Locs (potentially to
// invalidate their bindings). Just return Undefined.
return UndefinedVal();
- case loc::FuncValKind:
- return loc;
default:
assert (false && "Invalid Loc.");
// Fall-through.
- case loc::FuncValKind:
case loc::GotoLabelKind:
return NonLoc::MakeIntTruthVal(BasicVals, L == R);
}
// Fall through:
}
- case loc::FuncValKind:
case loc::GotoLabelKind:
return NonLoc::MakeIntTruthVal(BasicVals, L != R);
}
break;
case loc::GotoLabelKind:
- case loc::FuncValKind:
// These are anormal cases. Flag an undefined value.
return UndefinedVal();
if (isa<loc::ConcreteInt>(L))
return UndefinedVal();
- // FIXME: Should this be refactored into GRExprEngine or GRStateManager?
- // It seems that all StoreManagers would do the same thing here.
- if (isa<loc::FuncVal>(L))
- return L;
-
const MemRegion* MR = cast<loc::MemRegionVal>(L).getRegion();
// We return unknown for symbolic region for now. This might be improved.
//===----------------------------------------------------------------------===//
const FunctionDecl* SVal::getAsFunctionDecl() const {
- if (const loc::FuncVal* FV = dyn_cast<loc::FuncVal>(this)) {
- return FV->getDecl();
- }
-
if (const loc::MemRegionVal* X = dyn_cast<loc::MemRegionVal>(this)) {
const MemRegion* R = X->getRegion();
if (const CodeTextRegion* CTR = dyn_cast<CodeTextRegion>(R)) {
Out << '&' << cast<loc::MemRegionVal>(this)->getRegion()->getString();
break;
- case loc::FuncValKind:
- Out << "function "
- << cast<loc::FuncVal>(this)->getDecl()->getIdentifier()->getName();
- break;
-
default:
assert (false && "Pretty-printing not implemented for this Loc.");
break;
// FALL-THROUGH.
}
- case loc::FuncValKind:
case loc::GotoLabelKind:
isFeasible = Assumption;
return St;