[clang] fix gh185270 consteval crash (PR #185511)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 9 13:47:41 PDT 2026


================
@@ -18455,9 +18452,9 @@ HandleImmediateInvocations(Sema &SemaRef,
   if (SemaRef.getLangOpts().CPlusPlus23 &&
       Rec.ExprContext ==
           Sema::ExpressionEvaluationContextRecord::EK_VariableInit) {
-    auto *VD = cast<VarDecl>(Rec.ManglingContextDecl);
-    if (VD->isUsableInConstantExpressions(SemaRef.Context) ||
-        VD->hasConstantInitialization()) {
+    auto *VD = dyn_cast_or_null<VarDecl>(Rec.ManglingContextDecl);
----------------
erichkeane wrote:

Have we come across a situation when `Rec.ManglingContextDecl` is null?  Is that possible?  If not, we probably should leave this as just dyn_cast.

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


More information about the cfe-commits mailing list