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

>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 1/2] [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);

>From 0e7618322cee752c143b48b97c27a36ee554d02a Mon Sep 17 00:00:00 2001
From: tgs-sc <timur.golubov...@syntacore.com>
Date: Tue, 9 Sep 2025 14:22:18 +0300
Subject: [PATCH 2/2] Update clang/lib/AST/RecordLayoutBuilder.cpp

Co-authored-by: Michael Buch <michaelbuc...@gmail.com>
---
 clang/lib/AST/RecordLayoutBuilder.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index 93571543f1c7d..38618eefc5a87 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -187,7 +187,6 @@ 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;

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

Reply via email to