[clang] 40940fb - [analyzer][NFC] Substitute the SVal::evalMinus and evalComplement functions
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 14 09:57:02 PDT 2022
Author: Balazs Benics
Date: 2022-06-14T18:56:43+02:00
New Revision: 40940fb2a63d76d8eea601f9e6893aa24cbb0ad9
URL: https://github.com/llvm/llvm-project/commit/40940fb2a63d76d8eea601f9e6893aa24cbb0ad9
DIFF: https://github.com/llvm/llvm-project/commit/40940fb2a63d76d8eea601f9e6893aa24cbb0ad9.diff
LOG: [analyzer][NFC] Substitute the SVal::evalMinus and evalComplement functions
Depends on D126127
Reviewed By: martong
Differential Revision: https://reviews.llvm.org/D127734
Added:
Modified:
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
clang/lib/StaticAnalyzer/Core/SVals.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
index c3750b2320c89..69f19f7d85655 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -331,11 +331,6 @@ class ConcreteInt : public NonLoc {
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) {
return V.getBaseKind() == NonLocKind && V.getSubKind() == ConcreteIntKind;
}
diff --git a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
index f5e4b176c5dda..754699ac88980 100644
--- a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -441,13 +441,13 @@ SVal SValBuilder::makeSymExprValNN(BinaryOperator::Opcode Op,
return UnknownVal();
}
-SVal SValBuilder::evalMinus(NonLoc val) {
- switch (val.getSubKind()) {
+SVal SValBuilder::evalMinus(NonLoc X) {
+ switch (X.getSubKind()) {
case nonloc::ConcreteIntKind:
- return val.castAs<nonloc::ConcreteInt>().evalMinus(*this);
+ return makeIntVal(-X.castAs<nonloc::ConcreteInt>().getValue());
case nonloc::SymbolValKind:
- return makeNonLoc(val.castAs<nonloc::SymbolVal>().getSymbol(), UO_Minus,
- val.getType(Context));
+ return makeNonLoc(X.castAs<nonloc::SymbolVal>().getSymbol(), UO_Minus,
+ X.getType(Context));
default:
return UnknownVal();
}
@@ -456,7 +456,7 @@ SVal SValBuilder::evalMinus(NonLoc val) {
SVal SValBuilder::evalComplement(NonLoc X) {
switch (X.getSubKind()) {
case nonloc::ConcreteIntKind:
- return X.castAs<nonloc::ConcreteInt>().evalComplement(*this);
+ return makeIntVal(~X.castAs<nonloc::ConcreteInt>().getValue());
case nonloc::SymbolValKind:
return makeNonLoc(X.castAs<nonloc::SymbolVal>().getSymbol(), UO_Not,
X.getType(Context));
diff --git a/clang/lib/StaticAnalyzer/Core/SVals.cpp b/clang/lib/StaticAnalyzer/Core/SVals.cpp
index 1429d36107e9e..67913a55b3dcc 100644
--- a/clang/lib/StaticAnalyzer/Core/SVals.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SVals.cpp
@@ -252,20 +252,6 @@ bool SVal::isZeroConstant() const {
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.
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list