[PATCH] D127734: [analyzer][NFC] Substitute the SVal::evalMinus and evalComplement functions
Balázs Benics via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 14 03:28:31 PDT 2022
steakhal created this revision.
steakhal added a reviewer: martong.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun.
Herald added a reviewer: Szelethus.
Herald added a project: All.
steakhal requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Depends on D126127 <https://reviews.llvm.org/D126127>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D127734
Files:
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
clang/lib/StaticAnalyzer/Core/SVals.cpp
Index: clang/lib/StaticAnalyzer/Core/SVals.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/SVals.cpp
+++ clang/lib/StaticAnalyzer/Core/SVals.cpp
@@ -252,20 +252,6 @@
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.
//===----------------------------------------------------------------------===//
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -441,13 +441,13 @@
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::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));
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===================================================================
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -338,11 +338,6 @@
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127734.436726.patch
Type: text/x-patch
Size: 2903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220614/2a3731ae/attachment.bin>
More information about the cfe-commits
mailing list