[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 09:57:31 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG40940fb2a63d: [analyzer][NFC] Substitute the SVal::evalMinus and evalComplement functions (authored by steakhal).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127734/new/

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
@@ -331,11 +331,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.436835.patch
Type: text/x-patch
Size: 2903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220614/2e21481d/attachment-0001.bin>


More information about the cfe-commits mailing list