[PATCH] D99797: [analyzer] Handle intersections and adjacency in RangeSet::Factory::add function

Denys Petrov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 3 07:25:56 PDT 2021


ASDenysPetrov added a comment.

@vsavchenko Many thanks for your feedback!
I will make a new separate function for checking intersections considering all your suggestions along with the old quick `add` versions. I'll be more optimized.



================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:142
+  ContainerType::size_type InsertIdx = 0;
+  for (auto it = Original.begin(), e = Original.end(); it != e; ++it) {
+    const llvm::APSInt &RFrom = it->From();
----------------
vsavchenko wrote:
> Is there a reason not to use range-based loop in this case?
You are right. Working on restoring O(N) I been played with iterators, then found another solution, but forgot to return range-based loop back. Thnx.


================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:150
+    if (!IsIntersected) {
+      auto One = APSIntType(From).getValue(1);
+      const bool isCurrentRangeOnTheLeft = RTo < From;
----------------
vsavchenko wrote:
> This should be done outside of the loop, we assume that all the ranges are of the same type.
+1 I'll move it outside the loop.


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

https://reviews.llvm.org/D99797



More information about the cfe-commits mailing list