[clang] [analyzer] Fix unary/binary op support for SMT symbolic execution (PR #205078)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 29 03:13:45 PDT 2026


================
@@ -171,6 +171,15 @@ class SMTConstraintManager : public clang::ento::SimpleConstraintManager {
       return BVF.Convert(SC->getType(), *Value).get();
     }
 
+    if (const UnarySymExpr *USE = dyn_cast<UnarySymExpr>(Sym)) {
+      SymbolRef Operand = USE->getOperand();
+      const llvm::APSInt *Value;
+      if (!(Value = getSymVal(State, Operand)))
+        return nullptr;
+      std::optional<APSIntPtr> Res = BVF.evalAPSInt(USE->getOpcode(), *Value);
+      return Res ? Res.value().get() : nullptr;
----------------
steakhal wrote:

Doesn't the `std::optional` have a `value_or` method? IMO that should be used instead.

https://github.com/llvm/llvm-project/pull/205078


More information about the cfe-commits mailing list