[PATCH] D112621: [analyzer][solver] Introduce reasoning for not equal to operator

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 27 07:08:26 PDT 2021


steakhal added a comment.

Please also demonstrate that the patch can deal with sign mismatching ranges.
Aside from that, it looks clean and sweet.
Although, I still miss the point of how it would bypass anything.



================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1241
+  // in LHS, RHS respectively, will satisfy expression (x != y).
+  if ((LHS.To() < RHS.From()) || (LHS.From() > RHS.To())) {
+    return getTrueRange(T);
----------------
I would probably host this logic into a `Range::intersects(Range Other) const` member function.


================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1245-1250
+  // If both Ranges contain only one Point which is equal, then the expression
+  // will always return true.
+  if ((LHS.From() == RHS.To()) && (LHS.To() == RHS.To()) &&
+      (LHS.From() == RHS.From())) {
+    return getFalseRange(T);
+  }
----------------
Technically, it's correct, but I would rather follow a similar logic to what the comment would suggest.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112621



More information about the cfe-commits mailing list