}
const llvm::APSInt &Convert(QualType T, const llvm::APSInt &From) {
- assert(T->isIntegerType() || Loc::IsLocType(T));
+ assert(T->isIntegerType() || Loc::isLocType(T));
unsigned bitwidth = Ctx.getTypeSize(T);
- bool isUnsigned = T->isUnsignedIntegerType() || Loc::IsLocType(T);
+ bool isUnsigned = T->isUnsignedIntegerType() || Loc::isLocType(T);
if (isUnsigned == From.isUnsigned() && bitwidth == From.getBitWidth())
return From;
}
inline const llvm::APSInt& getMaxValue(QualType T) {
- assert(T->isIntegerType() || Loc::IsLocType(T));
- bool isUnsigned = T->isUnsignedIntegerType() || Loc::IsLocType(T);
+ assert(T->isIntegerType() || Loc::isLocType(T));
+ bool isUnsigned = T->isUnsignedIntegerType() || Loc::isLocType(T);
return getValue(llvm::APSInt::getMaxValue(Ctx.getTypeSize(T), isUnsigned));
}
inline const llvm::APSInt& getMinValue(QualType T) {
- assert(T->isIntegerType() || Loc::IsLocType(T));
- bool isUnsigned = T->isUnsignedIntegerType() || Loc::IsLocType(T);
+ assert(T->isIntegerType() || Loc::isLocType(T));
+ bool isUnsigned = T->isUnsignedIntegerType() || Loc::isLocType(T);
return getValue(llvm::APSInt::getMinValue(Ctx.getTypeSize(T), isUnsigned));
}
inline SVal GRState::getSValAsScalarOrLoc(const Stmt *S) const {
if (const Expr *Ex = dyn_cast<Expr>(S)) {
QualType T = Ex->getType();
- if (Loc::IsLocType(T) || T->isIntegerType())
+ if (Loc::isLocType(T) || T->isIntegerType())
return getSVal(S);
}
}
DefinedSVal makeIntVal(uint64_t X, QualType T) {
- if (Loc::IsLocType(T))
+ if (Loc::isLocType(T))
return loc::ConcreteInt(BasicVals.getValue(X, T));
return nonloc::ConcreteInt(BasicVals.getValue(X, T));
/// The higher bits are an unsigned "kind" value.
unsigned Kind;
-protected:
explicit SVal(const void* d, bool isLoc, unsigned ValKind)
: Data(d), Kind((isLoc ? LocKind : NonLocKind) | (ValKind << BaseBits)) {}
inline BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); }
inline unsigned getSubKind() const { return (Kind & ~BaseMask) >> BaseBits; }
+ // This method is required for using SVal in a FoldingSetNode. It
+ // extracts a unique signature for this SVal object.
inline void Profile(llvm::FoldingSetNodeID& ID) const {
ID.AddInteger((unsigned) getRawKind());
ID.AddPointer(Data);
return V->getBaseKind() == LocKind;
}
- static inline bool IsLocType(QualType T) {
+ static inline bool isLocType(QualType T) {
return T->isAnyPointerType() || T->isBlockPointerType() ||
T->isReferenceType();
}
return static_cast<const MemRegion*>(Data);
}
- const MemRegion* StripCasts() const;
+ const MemRegion* stripCasts() const;
template <typename REGION>
const REGION* getRegionAs() const {
if (!LV)
return;
- const TypedRegion* R = dyn_cast<TypedRegion>(LV->StripCasts());
+ const TypedRegion* R = dyn_cast<TypedRegion>(LV->stripCasts());
if (!R)
return;
// container. We will do this with dispatch logic to the store.
// For now, just 'conjure' up a symbolic value.
QualType T = R->getValueType();
- assert(Loc::IsLocType(T));
+ assert(Loc::isLocType(T));
unsigned Count = Builder->getCurrentBlockCount();
SymbolRef Sym = SymMgr.getConjuredSymbol(elem, T, Count);
SVal V = svalBuilder.makeLoc(Sym);
return;
}
- if (Loc::IsLocType(T) || T->isIntegerType()) {
+ if (Loc::isLocType(T) || T->isIntegerType()) {
assert (E->getNumInits() == 1);
ExplodedNodeSet Tmp;
const Expr* Init = E->getInit(0);
// If the value is a location, ++/-- should always preserve
// non-nullness. Check if the original value was non-null, and if so
// propagate that constraint.
- if (Loc::IsLocType(U->getType())) {
+ if (Loc::isLocType(U->getType())) {
DefinedOrUnknownSVal Constraint =
svalBuilder.evalEQ(state, V2,svalBuilder.makeZeroVal(U->getType()));
// a pointer. We may wish to flag a type error here if the types
// are incompatible. This may also cause lots of breakage
// elsewhere. Food for thought.
- if (TyR->isBoundable() && Loc::IsLocType(TyR->getValueType()))
+ if (TyR->isBoundable() && Loc::isLocType(TyR->getValueType()))
V = X->getLoc();
}
// unsigned) zero;
if (!InitVal) {
QualType T = VD->getType();
- if (Loc::IsLocType(T))
+ if (Loc::isLocType(T))
store = Bind(store, loc::MemRegionVal(VR),
loc::ConcreteInt(BasicVals.getValue(0, T)));
else if (T->isIntegerType() && T->isScalarType())
const llvm::APSInt& BasicValueFactory::getValue(uint64_t X, QualType T) {
unsigned bits = Ctx.getTypeSize(T);
- llvm::APSInt V(bits, T->isUnsignedIntegerType() || Loc::IsLocType(T));
+ llvm::APSInt V(bits, T->isUnsignedIntegerType() || Loc::isLocType(T));
V = X;
return getValue(V);
}
const SVal* BasicValueFactory::getPersistentSVal(SVal X) {
return &getPersistentSValWithData(X, 0).first;
}
-
-
// Create the diagnostic.
FullSourceLoc L(S->getLocStart(), BR.getSourceManager());
- if (Loc::IsLocType(VD->getType())) {
+ if (Loc::isLocType(VD->getType())) {
std::string msg = "'" + std::string(VD->getNameAsString()) +
"' now aliases '" + MostRecent->getNameAsString() + "'";
// that are returned by value.
QualType T = callOrMsg.getResultType(Eng.getContext());
- if (Loc::IsLocType(T) || (T->isIntegerType() && T->isScalarType())) {
+ if (Loc::isLocType(T) || (T->isIntegerType() && T->isScalarType())) {
unsigned Count = Builder.getCurrentBlockCount();
SValBuilder &svalBuilder = Eng.getSValBuilder();
SVal X = svalBuilder.getConjuredSymbolVal(NULL, Ex, T, Count);
if (const TypedRegion *TR = dyn_cast<TypedRegion>(R)) {
QualType T = TR->getValueType();
- if (Loc::IsLocType(T) || T->isIntegerType())
+ if (Loc::isLocType(T) || T->isIntegerType())
return getSVal(R);
}
assert(i < getNumArgs());
if (CallE) return State->getSValAsScalarOrLoc(CallE->getArg(i));
QualType argT = Msg.getArgType(i);
- if (Loc::IsLocType(argT) || argT->isIntegerType())
+ if (Loc::isLocType(argT) || argT->isIntegerType())
return Msg.getArgSVal(i, State);
return UnknownVal();
}
RegionBindings B = GetRegionBindings(store);
SVal V;
- if (Loc::IsLocType(T))
+ if (Loc::isLocType(T))
V = svalBuilder.makeNull();
else if (T->isIntegerType())
V = svalBuilder.makeZeroVal(T);
//===----------------------------------------------------------------------===//
DefinedOrUnknownSVal SValBuilder::makeZeroVal(QualType T) {
- if (Loc::IsLocType(T))
+ if (Loc::isLocType(T))
return makeNull();
if (T->isIntegerType())
// The Environment ensures we always get a persistent APSInt in
// BasicValueFactory, so we don't need to get the APSInt from
// BasicValueFactory again.
- assert(!Loc::IsLocType(T));
+ assert(!Loc::isLocType(T));
return nonloc::SymExprVal(SymMgr.getSymIntExpr(lhs, op, v, T));
}
NonLoc SValBuilder::makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
const SymExpr *rhs, QualType T) {
assert(SymMgr.getType(lhs) == SymMgr.getType(rhs));
- assert(!Loc::IsLocType(T));
+ assert(!Loc::isLocType(T));
return nonloc::SymExprVal(SymMgr.getSymSymExpr(lhs, op, rhs, T));
}
SymbolRef sym = SymMgr.getRegionValueSymbol(R);
- if (Loc::IsLocType(T))
+ if (Loc::isLocType(T))
return loc::MemRegionVal(MemMgr.getSymbolicRegion(sym));
return nonloc::SymbolVal(sym);
SymbolRef sym = SymMgr.getConjuredSymbol(E, Count, SymbolTag);
- if (Loc::IsLocType(T))
+ if (Loc::isLocType(T))
return loc::MemRegionVal(MemMgr.getSymbolicRegion(sym));
return nonloc::SymbolVal(sym);
SymbolRef sym = SymMgr.getConjuredSymbol(E, T, Count, SymbolTag);
- if (Loc::IsLocType(T))
+ if (Loc::isLocType(T))
return loc::MemRegionVal(MemMgr.getSymbolicRegion(sym));
return nonloc::SymbolVal(sym);
SymbolRef sym = SymMgr.getMetadataSymbol(MR, E, T, Count, SymbolTag);
- if (Loc::IsLocType(T))
+ if (Loc::isLocType(T))
return loc::MemRegionVal(MemMgr.getSymbolicRegion(sym));
return nonloc::SymbolVal(sym);
SymbolRef sym = SymMgr.getDerivedSymbol(parentSymbol, R);
- if (Loc::IsLocType(T))
+ if (Loc::isLocType(T))
return loc::MemRegionVal(MemMgr.getSymbolicRegion(sym));
return nonloc::SymbolVal(sym);
return evalCastNL(cast<NonLoc>(val), castTy);
// Check for casts from pointers to integers.
- if (castTy->isIntegerType() && Loc::IsLocType(originalTy))
+ if (castTy->isIntegerType() && Loc::isLocType(originalTy))
return evalCastL(cast<Loc>(val), castTy);
// Check for casts from integers to pointers.
- if (Loc::IsLocType(castTy) && originalTy->isIntegerType()) {
+ if (Loc::isLocType(castTy) && originalTy->isIntegerType()) {
if (nonloc::LocAsInteger *LV = dyn_cast<nonloc::LocAsInteger>(&val)) {
if (const MemRegion *R = LV->getLoc().getAsRegion()) {
StoreManager &storeMgr = StateMgr.getStoreManager();
// Just pass through function and block pointers.
if (originalTy->isBlockPointerType() || originalTy->isFunctionPointerType()) {
- assert(Loc::IsLocType(castTy));
+ assert(Loc::isLocType(castTy));
return val;
}
// FIXME: We should handle the case where we strip off view layers to get
// to a desugared type.
- if (!Loc::IsLocType(castTy)) {
+ if (!Loc::isLocType(castTy)) {
// FIXME: There can be gross cases where one casts the result of a function
// (that returns a pointer) to some other value that happens to fit
// within that pointer value. We currently have no good way to
// return bar(x)+1; // no-warning
// }
- assert(Loc::IsLocType(originalTy) || originalTy->isFunctionType() ||
+ assert(Loc::isLocType(originalTy) || originalTy->isFunctionType() ||
originalTy->isBlockPointerType());
StoreManager &storeMgr = StateMgr.getStoreManager();
return X->getLoc().getAsLocSymbol();
if (const loc::MemRegionVal *X = dyn_cast<loc::MemRegionVal>(this)) {
- const MemRegion *R = X->StripCasts();
+ const MemRegion *R = X->stripCasts();
if (const SymbolicRegion *SymR = dyn_cast<SymbolicRegion>(R))
return SymR->getSymbol();
}
return 0;
}
-const MemRegion *loc::MemRegionVal::StripCasts() const {
+const MemRegion *loc::MemRegionVal::stripCasts() const {
const MemRegion *R = getRegion();
return R ? R->StripCasts() : NULL;
}
ASTContext &Ctx = StateMgr.getContext();
QualType T = Sym->getType(Ctx);
- assert(T->isIntegerType() || Loc::IsLocType(T));
+ assert(T->isIntegerType() || Loc::isLocType(T));
unsigned bitwidth = Ctx.getTypeSize(T);
- bool isSymUnsigned = T->isUnsignedIntegerType() || Loc::IsLocType(T);
+ bool isSymUnsigned = T->isUnsignedIntegerType() || Loc::isLocType(T);
// Convert the adjustment.
Adjustment.setIsUnsigned(isSymUnsigned);
SVal SimpleSValBuilder::evalCastNL(NonLoc val, QualType castTy) {
- bool isLocType = Loc::IsLocType(castTy);
+ bool isLocType = Loc::isLocType(castTy);
if (nonloc::LocAsInteger *LI = dyn_cast<nonloc::LocAsInteger>(&val)) {
if (isLocType)
return UnknownVal();
llvm::APSInt i = cast<nonloc::ConcreteInt>(val).getValue();
- i.setIsUnsigned(castTy->isUnsignedIntegerType() || Loc::IsLocType(castTy));
+ i.setIsUnsigned(castTy->isUnsignedIntegerType() || Loc::isLocType(castTy));
i = i.extOrTrunc(Context.getTypeSize(castTy));
if (isLocType)
// can be introduced by the frontend for corner cases, e.g
// casting from va_list* to __builtin_va_list&.
//
- if (Loc::IsLocType(castTy) || castTy->isReferenceType())
+ if (Loc::isLocType(castTy) || castTy->isReferenceType())
return val;
// FIXME: Handle transparent unions where a value can be "transparently"
return makeLocAsInteger(val, BitWidth);
llvm::APSInt i = cast<loc::ConcreteInt>(val).getValue();
- i.setIsUnsigned(castTy->isUnsignedIntegerType() || Loc::IsLocType(castTy));
+ i.setIsUnsigned(castTy->isUnsignedIntegerType() || Loc::isLocType(castTy));
i = i.extOrTrunc(BitWidth);
return makeIntVal(i);
}
bool SymbolManager::canSymbolicate(QualType T) {
T = T.getCanonicalType();
- if (Loc::IsLocType(T))
+ if (Loc::isLocType(T))
return true;
if (T->isIntegerType())