[PATCH] D123858: [clang][dataflow] Ensure well-formed flow conditions.

Yitzhak Mandelbaum via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 19 11:18:00 PDT 2022


ymandel marked an inline comment as done.
ymandel added inline comments.


================
Comment at: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp:123-136
+      } else if (auto *CondVal = cast_or_null<ReferenceValue>(
+                     Env.getValue(Cond, SkipPast::None))) {
+        Env.setValue(CondVal->getPointeeLoc(), *Val);
+      } else {
+        QualType PointeeType = Type->castAs<ReferenceType>()->getPointeeType();
+        StorageLocation &PointeeLoc = Env.createStorageLocation(PointeeType);
+        Env.setValue(PointeeLoc, *Val);
----------------
sgatev wrote:
> Let's also add tests for these two paths.
Turns out this code was overkill -- the conditions are rvalues (even lvalues have an implicit cast inserted), so regardless of any pre-existing form, we should just replace it unconditionally with a simple boolean representation.

I've added a new test, though, for fields (vs the existing one for functions), which should exercise the path of `Loc != nullptr`, vs the function which (with current implementation) will exercise `Loc == nullptr`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123858



More information about the cfe-commits mailing list