Author: tgs-sc
Date: 2025-09-09T13:35:45Z
New Revision: 7d673ca1abac71825dd3d8c9b02e0f78b8d9427f

URL: 
https://github.com/llvm/llvm-project/commit/7d673ca1abac71825dd3d8c9b02e0f78b8d9427f
DIFF: 
https://github.com/llvm/llvm-project/commit/7d673ca1abac71825dd3d8c9b02e0f78b8d9427f.diff

LOG: [clang][AST] Added assert to prevent infinite recursion in computing 
layout (#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.

Added: 
    

Modified: 
    clang/lib/AST/RecordLayoutBuilder.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index 4b312c559bf2a..43f4e070748bb 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -187,6 +187,7 @@ void EmptySubobjectMap::ComputeEmptySubobjectSizes() {
   // Check the bases.
   for (const CXXBaseSpecifier &Base : Class->bases()) {
     const CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl();
+    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