[clang] [clang][dataflow] fix assert in `Environment::getResultObjectLocation` (PR #79608)
Paul Semel via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 26 07:44:39 PST 2024
https://github.com/paulsemel created https://github.com/llvm/llvm-project/pull/79608
When calling `Environment::getResultObjectLocation` with a CXXOperatorCallExpr that is a prvalue, we just hit an assert because no record was ever created.
>From 6af0f5971783214f6f3ce5f95aba97ed1c79824e Mon Sep 17 00:00:00 2001
From: Paul Semel <semelpaul at gmail.com>
Date: Fri, 26 Jan 2024 15:29:58 +0000
Subject: [PATCH] [dataflow] fix assert in
`Environment::getResultObjectLocation`
When calling `Environment::getResultObjectLocation` with a
CXXOperatorCallExpr that is a prvalue, we just hit an assert because no
record was ever created.
---
clang/lib/Analysis/FlowSensitive/Transfer.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index 2271a75fbcaf709..3b028a3200b72b2 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -536,6 +536,11 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
copyRecord(*LocSrc, *LocDst, Env);
Env.setStorageLocation(*S, *LocDst);
+ } else {
+ // CXXOperatorCallExpr can be prvalues, in which case we must create a
+ // record for them in order for `Environment::getResultObjectLocation()`
+ // to be able to return a value.
+ VisitCallExpr(S);
}
}
More information about the cfe-commits
mailing list