[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


================
@@ -242,6 +242,20 @@ const PointerToMemberData *BasicValueFactory::accumCXXBase(
   return getPointerToMemberData(ND, BaseSpecList);
 }
 
+std::optional<APSIntPtr> BasicValueFactory::evalAPSInt(UnaryOperator::Opcode Op,
+                                                       const llvm::APSInt &V1) {
+  switch (Op) {
+  default:
+    llvm_unreachable("Invalid Opcode.");
----------------
steakhal wrote:

This definitely feels like a wrong choice here.
`evalAPSInt` should not invoke UB when passing non -,~ to it. It should just return nullopt - as the function signature would suggest, right?
btw, couldn't we also have unary `+`? Just like we have for explicit converting lambdas to function pointers?

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


More information about the cfe-commits mailing list