Skip to content

Commit 7d673ca

Browse files
authored
[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.
1 parent d281db9 commit 7d673ca

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

clang/lib/AST/RecordLayoutBuilder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ void EmptySubobjectMap::ComputeEmptySubobjectSizes() {
187187
// Check the bases.
188188
for (const CXXBaseSpecifier &Base : Class->bases()) {
189189
const CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl();
190+
assert(BaseDecl != Class && "Class cannot inherit from itself.");
190191

191192
CharUnits EmptySize;
192193
const ASTRecordLayout &Layout = Context.getASTRecordLayout(BaseDecl);

0 commit comments

Comments
 (0)