-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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] skip consumed analysis for consteval conditions in control-flow terminators #117403
Conversation
@llvm/pr-subscribers-clang-analysis @llvm/pr-subscribers-clang Author: Oleksandr T. (a-tarasyuk) ChangesFixes #117385 Full diff: https://github.com/llvm/llvm-project/pull/117403.diff 2 Files Affected:
diff --git a/clang/lib/Analysis/Consumed.cpp b/clang/lib/Analysis/Consumed.cpp
index 63c59432429447..3eb7e5abff7145 100644
--- a/clang/lib/Analysis/Consumed.cpp
+++ b/clang/lib/Analysis/Consumed.cpp
@@ -1229,6 +1229,9 @@ bool ConsumedAnalyzer::splitState(const CFGBlock *CurrBlock,
if (const auto *IfNode =
dyn_cast_or_null<IfStmt>(CurrBlock->getTerminator().getStmt())) {
+ if (IfNode->isConsteval())
+ return false;
+
const Expr *Cond = IfNode->getCond();
PInfo = Visitor.getInfo(Cond);
diff --git a/clang/test/SemaCXX/constexpr-return-non-void-cxx2b.cpp b/clang/test/SemaCXX/constexpr-return-non-void-cxx2b.cpp
index 19e7d4976428a7..e3228dddef5f66 100644
--- a/clang/test/SemaCXX/constexpr-return-non-void-cxx2b.cpp
+++ b/clang/test/SemaCXX/constexpr-return-non-void-cxx2b.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++23 -fsyntax-only -Wimplicit-fallthrough -verify %s
+// RUN: %clang_cc1 -std=c++23 -fsyntax-only -Wimplicit-fallthrough -Wconsumed -verify %s
constexpr int f() { } // expected-warning {{non-void function does not return a value}}
static_assert(__is_same(decltype([] constexpr -> int { }( )), int)); // expected-warning {{non-void lambda does not return a value}}
@@ -34,3 +34,10 @@ constinit bool l = j(); // expected-error {{variable does not have a constant in
// expected-note {{in call to 'j()'}}
}
+
+namespace GH117385 {
+void f() {
+ if consteval {
+ }
+}
+}
|
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.
Can you add a release note / commit description?
Otherwise, LGTM
@cor3ntin Thanks for there feedback. I've added release notes and updated the description. @AaronBallman could you review these changes? |
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.
LGTM!
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/23/builds/5268 Here is the relevant piece of the build log for the reference
|
Fixes #117385
These changes extend the work done in #116513. The changes add additional handling to ensure correct behavior by skipping further checks when a CFG contains a
consteval
condition, where no explicit expression is present, which is required to proceed with consumed analyses.