[clang] [clang][bytecode] Work around virtual bases being present in APValues (PR #205553)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 24 06:05:33 PDT 2026
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/205553
This happen in code called via `evaluateDestruction()`, where we consume an `APValue` created by the current interpreter. APValues don't have a notion of virtual bases right now, so the virtual bases simply appear as regular ones.
>From d30a93178160f3cb4a49fd1fc5dae6bcf0b15244 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Wed, 24 Jun 2026 15:00:07 +0200
Subject: [PATCH] bases
---
clang/lib/AST/ByteCode/Compiler.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 9444eeb0c2ad3..be11c6ec45100 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -5529,6 +5529,11 @@ bool Compiler<Emitter>::visitAPValueInitializer(const APValue &Val,
// Bases.
for (unsigned I = 0, N = Val.getStructNumBases(); I != N; ++I) {
+ // FIXME: APValue doesn't know about virtual bases.
+ // We simply assume that if the APValue has more bases than the Record,
+ // those additional bases must be virtual.
+ if (I >= R->getNumBases())
+ break;
const APValue &B = Val.getStructBase(I);
const Record::Base *RB = R->getBase(I);
QualType BaseType = Ctx.getASTContext().getCanonicalTagType(RB->Decl);
More information about the cfe-commits
mailing list