-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang][dataflow] fix assert in Environment::getResultObjectLocation
#79608
[clang][dataflow] fix assert in Environment::getResultObjectLocation
#79608
Conversation
When calling `Environment::getResultObjectLocation` with a CXXOperatorCallExpr that is a prvalue, we just hit an assert because no record was ever created.
@llvm/pr-subscribers-clang-analysis @llvm/pr-subscribers-clang Author: Paul Semel (paulsemel) ChangesWhen calling Full diff: https://github.com/llvm/llvm-project/pull/79608.diff 1 Files Affected:
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);
}
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this!
Can you add a test that fails without the fix? See the existing test ResultObjectLocation
in TransferTest.cpp -- you should be able to create a new test based on this that has a CXXOperatorCallExpr
returning a record by value.
Co-authored-by: martinboehme <mboehme@google.com>
The added test aborts (assert fails) without this patch. |
9a6a383
to
7375c69
Compare
When calling
Environment::getResultObjectLocation
with a CXXOperatorCallExpr that is a prvalue, we just hit an assert because no record was ever created.