[PATCH] D153852: [clang][dataflow] Initialize fields of anonymous records correctly.

Martin Böhme via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 27 03:13:46 PDT 2023


mboehme added inline comments.


================
Comment at: clang/lib/Analysis/FlowSensitive/Transfer.cpp:575
     assert(InitExpr != nullptr);
-
-    Value *InitExprVal = Env.getValue(*InitExpr, SkipPast::None);
-    if (InitExprVal == nullptr)
-      return;
-
-    const FieldDecl *Field = S->getField();
-    assert(Field != nullptr);
-
-    auto &ThisLoc =
-        *cast<AggregateStorageLocation>(Env.getThisPointeeStorageLocation());
-    auto &FieldLoc = ThisLoc.getChild(*Field);
-    Env.setValue(FieldLoc, *InitExprVal);
+    propagateValueOrStorageLocation(*InitExpr, *S, Env);
   }
----------------
It turns out this was doing strictly too much work.

`CXXDefaultInitExpr` should only be producing the default value. The actual initialization should be left to `CXXCtorInitializer`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153852



More information about the cfe-commits mailing list