[clang] [clang] Reject invalid record declarations in builtin bit_cast checks (PR #235341)
Daniel Petrovic via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 24 12:32:20 PDT 2026
https://github.com/daniel-petrovic updated https://github.com/llvm/llvm-project/pull/235341
>From c5e0578fbf19b0a747ac7677e16622b8242bf07c Mon Sep 17 00:00:00 2001
From: Daniel Petrovic <daniel-dev at hotmail.de>
Date: Sat, 24 Oct 2026 20:51:26 +0200
Subject: [PATCH] [clang] Reject invalid record declarations in builtin
bit_cast checks
Fixes: #235252
---
clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp | 2 ++
clang/lib/AST/ExprConstant.cpp | 2 ++
2 files changed, 4 insertions(+)
diff --git a/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp b/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
index 3bec4f3bf1396b..ebaf4ecb2da637 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
@@ -295,6 +295,8 @@ static bool CheckBitcastType(InterpState &S, CodePtr OpPC, QualType T,
return diag(E_Volatile);
if (const RecordDecl *RD = T->getAsRecordDecl()) {
+ if (RD->isInvalidDecl())
+ return false;
if (const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
for (const CXXBaseSpecifier &BS : CXXRD->bases()) {
if (!CheckBitcastType(S, OpPC, BS.getType(), IsToType))
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 3762bc83c779b0..d8e3b0538a9bb8 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -8604,6 +8604,8 @@ static bool checkBitCastConstexprEligibilityType(SourceLocation Loc,
return diag(3);
if (RecordDecl *Record = Ty->getAsRecordDecl()) {
+ if (Record->isInvalidDecl())
+ return false;
if (auto *CXXRD = dyn_cast<CXXRecordDecl>(Record)) {
for (CXXBaseSpecifier &BS : CXXRD->bases())
if (!checkBitCastConstexprEligibilityType(Loc, BS.getType(), Info, Ctx,
More information about the cfe-commits
mailing list