[PATCH] D110910: [analyzer][solver] Fix CmpOpTable handling bug

Denys Petrov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 6 07:01:59 PDT 2021


ASDenysPetrov accepted this revision.
ASDenysPetrov added a comment.
This revision is now accepted and ready to land.

I see the problem. It appears when you meet, say, '>' in a //true// branch and '<=' in a //false// branch which then turns into `>` again and trigger the flag, but shouldn't. Your solution is correct and looks clear.
Here I propose you one more to not use additional abstruction in a favor of performance. See inlines.



================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1129
 
-    int UnknownStates = 0;
+    llvm::SmallSet<BinaryOperatorKind, 2> QueriedToUnknown;
 
----------------



================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1166-1167
       if (BranchState == OperatorRelationsTable::Unknown) {
-        if (++UnknownStates == 2)
+        QueriedToUnknown.insert(QueriedOP);
+        if (QueriedToUnknown.size() == 2)
           // If we met both Unknown states.
----------------



================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1174-1175
           BranchState = CmpOpTable.getCmpOpStateForUnknownX2(CurrentOP);
         else
           continue;
       }
----------------



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110910



More information about the cfe-commits mailing list