[clang] Disable constexpr function body checking in more situations (PR #94347)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 4 06:30:46 PDT 2024


================
@@ -2469,11 +2469,20 @@ static bool CheckConstexprFunctionBody(Sema &SemaRef, const FunctionDecl *Dcl,
   //     base class sub-objects shall be a constexpr constructor.
   //
   // Note that this rule is distinct from the "requirements for a constexpr
-  // function", so is not checked in CheckValid mode.
+  // function", so is not checked in CheckValid mode. Because the check for
+  // constexpr potential is expensive, skip the check if the diagnostic is
+  // disabled, the function is declared in a system header, or we're in C++23
+  // or later mode (see https://wg21.link/P2448).
+  auto SkipCheck = [&SemaRef, Dcl] {
----------------
Fznamznon wrote:

Is lambda necessary here? Won't `bool` variable do the job?

https://github.com/llvm/llvm-project/pull/94347


More information about the cfe-commits mailing list