[PATCH] D131006: [analyzer] Use DisequalityMap while inferring constraints

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 4 02:50:01 PDT 2022

martong added a comment.


Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1512-1516
+        if (IsFirst) {
+          IsFirst = false;
+          RS = *RSPtr;
+        } else
+          RS = RangeFactory.unite(RS, *RSPtr);
`unite` should be working with an empty set as well, shouldn't it?

Comment at: clang/test/Analysis/range-inferring-from-disequality-map.cpp:10-11
+     clang_analyzer_value(x); // expected-warning {{32s:{ [0, 0] }}}
+  // TODO:  TODO: Keep x range correct even if associated disequalities are
+  // already dead.
+  (void)tmp; // Keep alive.
Good point.

We should have an additional check in `removeDeadBindings` that goes through the disequality map of the dead symbol. And if any of the mapped classes are not dead then we shall not delete the dead symbol's equivalent class.

Comment at: clang/test/Analysis/range-inferring-from-disequality-map.cpp:50-51
+    if(x != tmp1 && x != tmp2)
+      // TODO: This condition should be infeasible.
+      //       Thus, the branch should be unreachable.
+      clang_analyzer_value(x); // expected-warning {{{ empty }}}
Why can't we return an empty set from `getInvertedRangeFromDisequalityMap` in this case? `intersect` should handle the rest then.

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list