mirror of https://github.com/microsoft/clang.git
[analyzer] Fix logical not for pointers with different bit width
Differential Revision: https://reviews.llvm.org/D31029 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305669 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2d7e549a3c
commit
66bdcfb16d
|
@ -180,6 +180,11 @@ public:
|
||||||
return getValue(X);
|
return getValue(X);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const llvm::APSInt& getZeroWithTypeSize(QualType T) {
|
||||||
|
assert(T->isScalarType());
|
||||||
|
return getValue(0, Ctx.getTypeSize(T), true);
|
||||||
|
}
|
||||||
|
|
||||||
inline const llvm::APSInt& getZeroWithPtrWidth(bool isUnsigned = true) {
|
inline const llvm::APSInt& getZeroWithPtrWidth(bool isUnsigned = true) {
|
||||||
return getValue(0, Ctx.getTypeSize(Ctx.VoidPtrTy), isUnsigned);
|
return getValue(0, Ctx.getTypeSize(Ctx.VoidPtrTy), isUnsigned);
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,6 +315,13 @@ public:
|
||||||
return nonloc::ConcreteInt(BasicVals.getTruthValue(b));
|
return nonloc::ConcreteInt(BasicVals.getTruthValue(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create NULL pointer, with proper pointer bit-width for given address
|
||||||
|
/// space.
|
||||||
|
/// \param type pointer type.
|
||||||
|
Loc makeNullWithType(QualType type) {
|
||||||
|
return loc::ConcreteInt(BasicVals.getZeroWithTypeSize(type));
|
||||||
|
}
|
||||||
|
|
||||||
Loc makeNull() {
|
Loc makeNull() {
|
||||||
return loc::ConcreteInt(BasicVals.getZeroWithPtrWidth());
|
return loc::ConcreteInt(BasicVals.getZeroWithPtrWidth());
|
||||||
}
|
}
|
||||||
|
|
|
@ -980,10 +980,9 @@ void ExprEngine::VisitUnaryOperator(const UnaryOperator* U, ExplodedNode *Pred,
|
||||||
// transfer functions as "0 == E".
|
// transfer functions as "0 == E".
|
||||||
SVal Result;
|
SVal Result;
|
||||||
if (Optional<Loc> LV = V.getAs<Loc>()) {
|
if (Optional<Loc> LV = V.getAs<Loc>()) {
|
||||||
Loc X = svalBuilder.makeNull();
|
Loc X = svalBuilder.makeNullWithType(Ex->getType());
|
||||||
Result = evalBinOp(state, BO_EQ, *LV, X, U->getType());
|
Result = evalBinOp(state, BO_EQ, *LV, X, U->getType());
|
||||||
}
|
} else if (Ex->getType()->isFloatingType()) {
|
||||||
else if (Ex->getType()->isFloatingType()) {
|
|
||||||
// FIXME: handle floating point types.
|
// FIXME: handle floating point types.
|
||||||
Result = UnknownVal();
|
Result = UnknownVal();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue