[clang] [clang][dataflow] Correctly handle `InitListExpr` of union type. (PR #82348)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 20 09:10:27 PST 2024


================
@@ -1104,12 +1104,22 @@ RecordStorageLocation *getBaseObjectLocation(const MemberExpr &ME,
   return Env.get<RecordStorageLocation>(*Base);
 }
 
-std::vector<FieldDecl *> getFieldsForInitListExpr(const RecordDecl *RD) {
+std::vector<const FieldDecl *>
+getFieldsForInitListExpr(const InitListExpr *InitList) {
+  const RecordDecl *RD = InitList->getType()->getAsRecordDecl();
+  assert(RD != nullptr);
+
+  std::vector<const FieldDecl *> Fields;
----------------
Xazax-hun wrote:

I wonder if a `reserve` call for this vector would be beneficial. Even if we do not know the exact number of fields we want to insert, probably relatively few of them are unnamed bit fields in most code bases. 

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


More information about the cfe-commits mailing list