[clang] [clang][bytecode] Work around virtual bases being present in APValues (PR #205553)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 24 07:50:39 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

This happens 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.

---
Full diff: https://github.com/llvm/llvm-project/pull/205553.diff


1 Files Affected:

- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+5) 


``````````diff
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);

``````````

</details>


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


More information about the cfe-commits mailing list