[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 8 06:35:51 PDT 2024


================
@@ -460,25 +460,35 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
     // So make sure we have a value if we didn't propagate one above.
     if (S->isPRValue() && S->getType()->isRecordType()) {
       if (Env.getValue(*S) == nullptr) {
-        Value *Val = Env.createValue(S->getType());
-        // We're guaranteed to always be able to create a value for record
-        // types.
-        assert(Val != nullptr);
-        Env.setValue(*S, *Val);
+        auto &Loc = Env.getResultObjectLocation(*S);
+        Env.initializeFieldsWithValues(Loc);
+        refreshRecordValue(Loc, Env);
       }
     }
   }
 
   void VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
     const Expr *InitExpr = S->getExpr();
     assert(InitExpr != nullptr);
-    propagateValueOrStorageLocation(*InitExpr, *S, Env);
+    if (!(S->getType()->isRecordType() && S->isPRValue()))
----------------
martinboehme wrote:

Done. While I'm here, converted this to an early-out (which then also aligns better with the comment).

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


More information about the cfe-commits mailing list