[PATCH] D118596: [clang][dataflow] Enable comparison of distinct values in Environment

Stanislav Gatev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 1 04:54:40 PST 2022


sgatev added a comment.

Mentioned the breaking interface change in the description.



================
Comment at: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp:151
 
-    if (auto *FirstVal = dyn_cast<PointerValue>(Val)) {
-      auto *SecondVal = cast<PointerValue>(It->second);
-      if (&FirstVal->getPointeeLoc() == &SecondVal->getPointeeLoc()) {
-        LocToVal.insert({Loc, FirstVal});
+    if (auto *Val1 = dyn_cast<PointerValue>(Val)) {
+      auto *Val2 = cast<PointerValue>(It->second);
----------------
xazax.hun wrote:
> Now we have multiple, slightly different versions of equality for values. One here, one in `Environment::equivalentTo`. I'd prefer to have one way to check value equality factored out somewhere and reused it both here and there. Also, `Environment::equivalentTo` works with any indirection, this snippet only works with pointers (and not with references).
> 
> It is also not clear to me at this point what is the role of `compareEquivalent`. Is it intentional that it is not used here?
Good point, I updated the code. Please take a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118596



More information about the cfe-commits mailing list