[PATCH] D82445: [analyzer][solver] Track symbol equivalence

Gábor Horváth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 7 02:37:12 PDT 2020


xazax.hun added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1254
+    //       sufficient.
+    return S1->get<ConstraintRange>() == S2->get<ConstraintRange>() &&
+           S1->get<ClassMap>() == S2->get<ClassMap>();
----------------
xazax.hun wrote:
> Sorry, but I am a bit confused here.
> 
> Does `haveEqualConstraints` have anything to do with equivalence classes?
> 
> I.e., what if I have two symbols with the same constraints (but those two symbols were never compared).
> ```
> void f(int a, int b) {
>   int c = clamp(a, 5, 10);
>   int d = clamp(b, 5, 10);
> }
> ```
> 
> In the code above if analyzer understands clamp, the range for `c` and `d` will be the same. Even though we never really compared them.
> I would expect `haveEqualConstraints` to return true, even if they do not belong to the same equivalence class.
> 
> Do I miss something?
Never mind, I misunderstood this function. It operates on program states not on symbols.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82445





More information about the cfe-commits mailing list