[clang] [clang][dataflow] Introduce a helper class for handling record initializer lists. (PR #86675)
Yitzhak Mandelbaum via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 27 07:52:51 PDT 2024
================
@@ -744,6 +744,35 @@ RecordStorageLocation *getBaseObjectLocation(const MemberExpr &ME,
std::vector<const FieldDecl *>
getFieldsForInitListExpr(const InitListExpr *InitList);
+/// Helper class for initialization of a record with an `InitListExpr`.
+/// `InitListExpr::inits()` contains the initializers for both the base classes
+/// and the fields of the record; this helper class separates these out into two
+/// different lists. In addition, it deals with special cases associated with
+/// unions.
+class RecordInitListHelper {
----------------
ymand wrote:
Why an object vs something like:
```
struct RecordInits {
SmallVector<std::pair<const CXXBaseSpecifier *, Expr *>> BaseInits;
SmallVector<std::pair<const FieldDecl *, Expr *>> FieldInits;
};
RecordInits RecordInitListHelper(const InitListExpr *InitList);
```
Is it because of the optional storage needed for the union?
https://github.com/llvm/llvm-project/pull/86675
More information about the cfe-commits
mailing list