-
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
[dataflow] Fix crash when InitListExpr is not a prvalue #80970
Merged
paulsemel
merged 1 commit into
llvm:main
from
paulsemel:fix-init-list-expr-not-being-prvalues
Feb 15, 2024
Merged
[dataflow] Fix crash when InitListExpr is not a prvalue #80970
paulsemel
merged 1 commit into
llvm:main
from
paulsemel:fix-init-list-expr-not-being-prvalues
Feb 15, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
llvmbot
added
clang
Clang issues not falling into any other category
clang:dataflow
Clang Dataflow Analysis framework - https://clang.llvm.org/docs/DataFlowAnalysisIntro.html
clang:analysis
labels
Feb 7, 2024
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-analysis Author: Paul Semel (paulsemel) ChangesFull diff: https://github.com/llvm/llvm-project/pull/80970.diff 2 Files Affected:
diff --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index bb3aec763c29ca..dc0f1bd6dcc291 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -648,6 +648,12 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
QualType Type = S->getType();
if (!Type->isStructureOrClassType()) {
+ // It is possible that InitListExpr is not a prvalue, in which case
+ // `setValue` will fail. In this case, we can just let the next
+ // transfer function handle the value creation.
+ if (!S->isPRValue())
+ return;
+
if (auto *Val = Env.createValue(Type))
Env.setValue(*S, *Val);
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 8bbb04024dcce6..74e6f1abfa4ba3 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2313,6 +2313,20 @@ TEST(TransferTest, AssignmentOperatorWithInitAndInheritance) {
ASTContext &ASTCtx) {});
}
+TEST(TransferTest, InitListExprAsXValue) {
+ // This is a crash repro.
+ std::string Code = R"(
+ void target() {
+ auto&& test{false};
+ // [[p]]
+ }
+ )";
+ runDataflow(
+ Code,
+ [](const llvm::StringMap<DataflowAnalysisState<NoopLattice>> &Results,
+ ASTContext &ASTCtx) {});
+}
+
TEST(TransferTest, CopyConstructor) {
std::string Code = R"(
struct A {
|
martinboehme
requested changes
Feb 8, 2024
paulsemel
force-pushed
the
fix-init-list-expr-not-being-prvalues
branch
from
February 8, 2024 15:08
e56ced7
to
1ff7ea5
Compare
paulsemel
force-pushed
the
fix-init-list-expr-not-being-prvalues
branch
from
February 8, 2024 15:54
1ff7ea5
to
35fa8c1
Compare
martinboehme
requested changes
Feb 13, 2024
paulsemel
force-pushed
the
fix-init-list-expr-not-being-prvalues
branch
from
February 13, 2024 11:49
8b4d49d
to
584e875
Compare
martinboehme
approved these changes
Feb 14, 2024
bazuzi
added a commit
to bazuzi/llvm-project
that referenced
this pull request
Feb 26, 2024
Crashes resulted from single-element InitListExprs for arrays with elements of a record type after llvm#80970.
bazuzi
added a commit
to bazuzi/llvm-project
that referenced
this pull request
Feb 26, 2024
Crashes resulted from single-element InitListExprs for arrays with elements of a record type after llvm#80970.
ymand
pushed a commit
that referenced
this pull request
Feb 26, 2024
Crashes resulted from single-element InitListExprs for arrays with elements of a record type after #80970.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:analysis
clang:dataflow
Clang Dataflow Analysis framework - https://clang.llvm.org/docs/DataFlowAnalysisIntro.html
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.