================
@@ -92,11 +96,39 @@ class DataflowAnalysisContext {
/*Logger=*/nullptr});
~DataflowAnalysisContext();
+ /// Sets a callback that returns the names and types of the synthetic fields
+ /// to add to a `RecordStorageLocation` of a given type.
+ /// Typically, this is called from the constructor of a `DataflowAnalysis`
+ ///
+ /// To maintain the invariant that all `RecordStorageLocation`s of a given
+ /// type have the same fields:
+ /// * The callback must always return the same result for a given type
+ /// * `setSyntheticFieldCallback()` must be called before any
+ // `RecordStorageLocation`s are created.
----------------
martinboehme wrote:
> Can this be integrated into the constructor? Could be in a followup patch (to
> minimize further churn in this one).
Unfortunately, that doesn't work because `setSyntheticFieldCallback()` needs to
be called by the `DataflowAnalysis`, and the `DataflowAnalysis` doesn't create
the `DataflowAnalysisContext` (i.e. it can't pass anything to its constructor).
I think we could consider changing this though: I don't think there's anything
that would prevent the `DataflowAnalysis` itself from creating the
`DataflowAnalysisContext`, and then the synthetic field callback could simply
be a constructor parameter. This would require changing existing analyses,
however, so I don't think this is something to tackle as part of this patch.
https://github.com/llvm/llvm-project/pull/73860
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits