forked from OSchip/llvm-project
[analyzer][NFC] Substitute the SVal::evalMinus and evalComplement functions
Depends on D126127 Reviewed By: martong Differential Revision: https://reviews.llvm.org/D127734
This commit is contained in:
parent
cfc915149c
commit
40940fb2a6
|
@ -331,11 +331,6 @@ public:
|
||||||
return *static_cast<const llvm::APSInt *>(Data);
|
return *static_cast<const llvm::APSInt *>(Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer functions for unary operations on ConcreteInts.
|
|
||||||
ConcreteInt evalComplement(SValBuilder &svalBuilder) const;
|
|
||||||
|
|
||||||
ConcreteInt evalMinus(SValBuilder &svalBuilder) const;
|
|
||||||
|
|
||||||
static bool classof(SVal V) {
|
static bool classof(SVal V) {
|
||||||
return V.getBaseKind() == NonLocKind && V.getSubKind() == ConcreteIntKind;
|
return V.getBaseKind() == NonLocKind && V.getSubKind() == ConcreteIntKind;
|
||||||
}
|
}
|
||||||
|
|
|
@ -441,13 +441,13 @@ SVal SValBuilder::makeSymExprValNN(BinaryOperator::Opcode Op,
|
||||||
return UnknownVal();
|
return UnknownVal();
|
||||||
}
|
}
|
||||||
|
|
||||||
SVal SValBuilder::evalMinus(NonLoc val) {
|
SVal SValBuilder::evalMinus(NonLoc X) {
|
||||||
switch (val.getSubKind()) {
|
switch (X.getSubKind()) {
|
||||||
case nonloc::ConcreteIntKind:
|
case nonloc::ConcreteIntKind:
|
||||||
return val.castAs<nonloc::ConcreteInt>().evalMinus(*this);
|
return makeIntVal(-X.castAs<nonloc::ConcreteInt>().getValue());
|
||||||
case nonloc::SymbolValKind:
|
case nonloc::SymbolValKind:
|
||||||
return makeNonLoc(val.castAs<nonloc::SymbolVal>().getSymbol(), UO_Minus,
|
return makeNonLoc(X.castAs<nonloc::SymbolVal>().getSymbol(), UO_Minus,
|
||||||
val.getType(Context));
|
X.getType(Context));
|
||||||
default:
|
default:
|
||||||
return UnknownVal();
|
return UnknownVal();
|
||||||
}
|
}
|
||||||
|
@ -456,7 +456,7 @@ SVal SValBuilder::evalMinus(NonLoc val) {
|
||||||
SVal SValBuilder::evalComplement(NonLoc X) {
|
SVal SValBuilder::evalComplement(NonLoc X) {
|
||||||
switch (X.getSubKind()) {
|
switch (X.getSubKind()) {
|
||||||
case nonloc::ConcreteIntKind:
|
case nonloc::ConcreteIntKind:
|
||||||
return X.castAs<nonloc::ConcreteInt>().evalComplement(*this);
|
return makeIntVal(~X.castAs<nonloc::ConcreteInt>().getValue());
|
||||||
case nonloc::SymbolValKind:
|
case nonloc::SymbolValKind:
|
||||||
return makeNonLoc(X.castAs<nonloc::SymbolVal>().getSymbol(), UO_Not,
|
return makeNonLoc(X.castAs<nonloc::SymbolVal>().getSymbol(), UO_Not,
|
||||||
X.getType(Context));
|
X.getType(Context));
|
||||||
|
|
|
@ -252,20 +252,6 @@ bool SVal::isZeroConstant() const {
|
||||||
return isConstant(0);
|
return isConstant(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
// Transfer function dispatch for Non-Locs.
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
nonloc::ConcreteInt
|
|
||||||
nonloc::ConcreteInt::evalComplement(SValBuilder &svalBuilder) const {
|
|
||||||
return svalBuilder.makeIntVal(~getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
nonloc::ConcreteInt
|
|
||||||
nonloc::ConcreteInt::evalMinus(SValBuilder &svalBuilder) const {
|
|
||||||
return svalBuilder.makeIntVal(-getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Pretty-Printing.
|
// Pretty-Printing.
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
Loading…
Reference in New Issue