[clang] [analyzer] Fix handling of zero-sized elements in ArrayBound (PR #218712)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 26 06:00:39 PDT 2026


================
@@ -91,16 +92,30 @@ class CheckResult {
   ProgramStateRef InBoundsState = nullptr;
 };
 
-// Evaluate the comparison Value < Threshold with the help of the custom
+enum class Comparison { LT, LE, EQ };
+
+inline BinaryOperator::Opcode asOpcode(Comparison C) {
+  switch (C) {
+  case Comparison::LT:
+    return BO_LT;
+  case Comparison::LE:
+    return BO_LE;
+  case Comparison::EQ:
+    return BO_EQ;
+  }
+  llvm_unreachable("unhandled Comparison kind");
+}
----------------
NagyDonat wrote:

I really dislike the pattern where an `enum` is wrapped in boilerplate struct, and also I prefer to avoid implicit conversions unless they are very natural and significantly simplify lots of code. (I'd say that an implicit conversion needs at least a dozen uses to be useful.)

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


More information about the cfe-commits mailing list