https://github.com/tgs-sc created 
https://github.com/llvm/llvm-project/pull/154134

While computing class layout, I met with infinite recursion. This happened 
while executing user expression in lldb as record type was incorrectly received 
from dwarf. This assert will replace the infinite recursion with an error and 
will simplify further debugging of such cases.

>From 8feef619e2ef72cc2c6c9a107e5a5695ca8fd042 Mon Sep 17 00:00:00 2001
From: Timur Golubovich <timur.golubov...@syntacore.com>
Date: Mon, 18 Aug 2025 18:08:27 +0300
Subject: [PATCH] [clang][AST] Added assert to prevent infinite recursion in
 computing layout

While computing class layout, I met with infinite recursion. This
happened while executing user expression in lldb as record type was
incorrectly received from dwarf. This assert will replace the infinite
recursion with an error and will simplify further debugging of such cases.
---
 clang/lib/AST/RecordLayoutBuilder.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index 6d819031cbef4..93571543f1c7d 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -187,6 +187,8 @@ void EmptySubobjectMap::ComputeEmptySubobjectSizes() {
   // Check the bases.
   for (const CXXBaseSpecifier &Base : Class->bases()) {
     const CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl();
+    // Assert to prevent infinite recursion.
+    assert(BaseDecl != Class && "Class cannot inherit from itself.");
 
     CharUnits EmptySize;
     const ASTRecordLayout &Layout = Context.getASTRecordLayout(BaseDecl);

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to