[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers

Denys Petrov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 27 11:15:04 PDT 2022


ASDenysPetrov marked 4 inline comments as done.
ASDenysPetrov added a comment.

@martong Just FYI. I've been working on reworking this solution to using `EquivalenceClasses` for several weeks. It turned out that this is an extremely hard task to acomplish. There a lot of cast cases like: `(int8)x==y, (uint16)a==(int64)b, (uint8)y == b`, Merging and inferring all of this without going beyond the complexity O(n) is really tricky.



================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1289-1291
+      auto It = llvm::find_if(*CM, [MinBitWidth](CastMap::value_type &Item) {
+        return Item.first >= MinBitWidth;
+      });
----------------
martong wrote:
> There might be a problem here because the iteration of the map is non-deterministic. We should probably have a copy that is sorted, or the container should be sorted (sorted immutable list maybe?).
> 
> Your tests below passed probably because the cast chains are too small. Could you please have a test, where the chain is really long (20 maybe) and shuffled.
> (My thanks for @steakhal for this additional comment.)
I've checked. `ImmutableSet` gave me a sorted order. But I agree that it could be just a coincidence. I'll try to add more tests.


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

https://reviews.llvm.org/D103096



More information about the cfe-commits mailing list