[clang] [Clang] skip consumed analysis for consteval conditions in control-flow terminators (PR #117403)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 22 15:55:15 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Oleksandr T. (a-tarasyuk)
<details>
<summary>Changes</summary>
Fixes #<!-- -->117385
---
Full diff: https://github.com/llvm/llvm-project/pull/117403.diff
2 Files Affected:
- (modified) clang/lib/Analysis/Consumed.cpp (+3)
- (modified) clang/test/SemaCXX/constexpr-return-non-void-cxx2b.cpp (+8-1)
``````````diff
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 {
+ }
+}
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/117403
More information about the cfe-commits
mailing list