Skip to content

Commit 207f702

Browse files
committed
[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.
1 parent e717e50 commit 207f702

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)