[PATCH] D155204: [clang][dataflow] Add `refreshStructValue()`.

Gábor Horváth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 15 07:41:38 PDT 2023


xazax.hun accepted this revision.
xazax.hun added inline comments.


================
Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h:706-711
+/// This function is primarily intended for use by checks that set custom
+/// properties on `StructValue`s to model the state of these values. Such checks
+/// should avoid modifying the properties of an existing `StructValue` because
+/// these changes would be visible to other `Environment`s that share the same
+/// `StructValue`. Instead, call `refreshStructValue()`, then set the properties
+/// on the new `StructValue` that it returns. Typical usage:
----------------
I think this is fine for now, but I wonder if we should come up with an API where errors like this cannot happen. One potential way would be to no longer include these properties in the `StructValue`s, but have a separate mapping `StructValue => Properties`. So, one can update the mapping in an environment without any unintended consequences in other environments. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155204



More information about the cfe-commits mailing list