[clang] [clang][dataflow] Add synthetic fields to `RecordStorageLocation` (PR #73860)

via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 1 06:04:44 PST 2023


================
@@ -492,6 +492,56 @@ transferCFGBlock(const CFGBlock &Block, AnalysisContext &AC,
   return State;
 }
 
+static Environment initializeEnvironment(const Environment &InitEnv) {
+  Environment ResultEnv = InitEnv.fork();
----------------
martinboehme wrote:

Now that this code has been moved to `Environment::initialize()`, the initialization happens in place there, and that function doesn't contain a `fork()`.

However, `runTypeErasedDataflowAnalysis()` now does a `fork()`, and I wanted to comment briefly on this. `runTypeErasedDataflowAnalysis()` takes a const reference to the `Environment`, so it can't initialize this existing `Environment` in place and instead has to fork it. (Previously, when the `Environment` constructor did all the initialization, this wasn't necessary because `runTypeErasedDataflowAnalysis()` received a fully initialized environment.)

I had considered changing the interface of `runTypeErasedDataflowAnalysis()` to take the `Environment` either by non-const reference or by value (as the caller typically no longer needs the `Environment` it has), but I decided against this because it would require changes in multiple analyses. If we want to, we can always make this change in a followup patch.

https://github.com/llvm/llvm-project/pull/73860


More information about the cfe-commits mailing list