зеркало из https://github.com/microsoft/clang-1.git
[analyzer] Loc-Loc operations (subtraction or comparison) produce a NonLoc.
For two concrete locations, we were producing another concrete location and then casting it to an integer. We should just create a nonloc::ConcreteInt to begin with. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177805 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
e30024c96f
Коммит
a339cd66be
|
@ -214,13 +214,12 @@ SVal loc::ConcreteInt::evalBinOp(BasicValueFactory& BasicVals,
|
|||
BinaryOperator::Opcode Op,
|
||||
const loc::ConcreteInt& R) const {
|
||||
|
||||
assert (Op == BO_Add || Op == BO_Sub ||
|
||||
(Op >= BO_LT && Op <= BO_NE));
|
||||
assert(BinaryOperator::isComparisonOp(Op) || Op == BO_Sub);
|
||||
|
||||
const llvm::APSInt* X = BasicVals.evalAPSInt(Op, getValue(), R.getValue());
|
||||
const llvm::APSInt *X = BasicVals.evalAPSInt(Op, getValue(), R.getValue());
|
||||
|
||||
if (X)
|
||||
return loc::ConcreteInt(*X);
|
||||
return nonloc::ConcreteInt(*X);
|
||||
else
|
||||
return UndefinedVal();
|
||||
}
|
||||
|
|
|
@ -582,10 +582,11 @@ SVal SimpleSValBuilder::evalBinOpLL(ProgramStateRef state,
|
|||
if (Optional<loc::ConcreteInt> rInt = rhs.getAs<loc::ConcreteInt>()) {
|
||||
SVal ResultVal =
|
||||
lhs.castAs<loc::ConcreteInt>().evalBinOp(BasicVals, op, *rInt);
|
||||
if (Optional<Loc> Result = ResultVal.getAs<Loc>())
|
||||
return evalCastFromLoc(*Result, resultTy);
|
||||
else
|
||||
return UnknownVal();
|
||||
if (Optional<NonLoc> Result = ResultVal.getAs<NonLoc>())
|
||||
return evalCastFromNonLoc(*Result, resultTy);
|
||||
|
||||
assert(!ResultVal.getAs<Loc>() && "Loc-Loc ops should not produce Locs");
|
||||
return UnknownVal();
|
||||
}
|
||||
|
||||
// Special case comparisons against NULL.
|
||||
|
|
Загрузка…
Ссылка в новой задаче