Skip to content

Commit 09db537

Browse files
author
Anders Carlsson
committed
Assert that primary bases always have offset 0.
llvm-svn: 98223
1 parent c5ddbad commit 09db537

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

clang/clang.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
1A81AA19108144F40094E50B /* CGVtable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A81AA18108144F40094E50B /* CGVtable.cpp */; };
5050
1A869A700BA2164C008DA07A /* LiteralSupport.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1A869A6E0BA2164C008DA07A /* LiteralSupport.h */; };
5151
1A869AA80BA21ABA008DA07A /* LiteralSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A869AA70BA21ABA008DA07A /* LiteralSupport.cpp */; };
52+
1A96785211486FDC00F24372 /* RecordLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A96785111486FDC00F24372 /* RecordLayout.cpp */; };
5253
1A97825B1108BA18002B98FC /* CGVTT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A97825A1108BA18002B98FC /* CGVTT.cpp */; };
5354
1A986AB710D0746D00A8EA9E /* CGDeclCXX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A986AB610D0746D00A8EA9E /* CGDeclCXX.cpp */; };
5455
1AA1D91810125DE30078DEBC /* RecordLayoutBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA1D91610125DE30078DEBC /* RecordLayoutBuilder.cpp */; };
@@ -420,6 +421,7 @@
420421
1A81AA5D108278A20094E50B /* CGVtable.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = CGVtable.h; path = lib/CodeGen/CGVtable.h; sourceTree = "<group>"; tabWidth = 2; };
421422
1A869A6E0BA2164C008DA07A /* LiteralSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LiteralSupport.h; sourceTree = "<group>"; };
422423
1A869AA70BA21ABA008DA07A /* LiteralSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = LiteralSupport.cpp; sourceTree = "<group>"; };
424+
1A96785111486FDC00F24372 /* RecordLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = RecordLayout.cpp; path = lib/AST/RecordLayout.cpp; sourceTree = "<group>"; tabWidth = 2; };
423425
1A97825A1108BA18002B98FC /* CGVTT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = CGVTT.cpp; path = lib/CodeGen/CGVTT.cpp; sourceTree = "<group>"; tabWidth = 2; };
424426
1A986AB610D0746D00A8EA9E /* CGDeclCXX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = CGDeclCXX.cpp; path = lib/CodeGen/CGDeclCXX.cpp; sourceTree = "<group>"; tabWidth = 2; };
425427
1AA1D91610125DE30078DEBC /* RecordLayoutBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = RecordLayoutBuilder.cpp; path = lib/AST/RecordLayoutBuilder.cpp; sourceTree = "<group>"; tabWidth = 2; };
@@ -1438,6 +1440,7 @@
14381440
3557D1A80EB136B100C59739 /* InheritViz.cpp */,
14391441
DEDFE5CE0F7206E40035BD10 /* NestedNameSpecifier.cpp */,
14401442
35EE48B00E0C4CCA00715C54 /* ParentMap.cpp */,
1443+
1A96785111486FDC00F24372 /* RecordLayout.cpp */,
14411444
1AA1D91610125DE30078DEBC /* RecordLayoutBuilder.cpp */,
14421445
1AA1D91710125DE30078DEBC /* RecordLayoutBuilder.h */,
14431446
DE3452400AEF1A2D00DBC861 /* Stmt.cpp */,
@@ -1993,6 +1996,7 @@
19931996
1A621C4411111D61009E6834 /* CIndexInclusionStack.cpp in Sources */,
19941997
1A621C4511111D61009E6834 /* CIndexUSRs.cpp in Sources */,
19951998
1A621C4611111D61009E6834 /* CXCursor.cpp in Sources */,
1999+
1A96785211486FDC00F24372 /* RecordLayout.cpp in Sources */,
19962000
);
19972001
runOnlyForDeploymentPostprocessing = 0;
19982002
};

clang/lib/AST/RecordLayout.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,15 @@ ASTRecordLayout::ASTRecordLayout(ASTContext &Ctx,
6464
CXXInfo->BaseOffsets[bases[i].first] = bases[i].second;
6565
for (unsigned i = 0; i != numvbases; ++i)
6666
CXXInfo->VBaseOffsets[vbases[i].first] = vbases[i].second;
67+
68+
#ifndef NDEBUG
69+
if (const CXXRecordDecl *PrimaryBase = getPrimaryBase()) {
70+
if (getPrimaryBaseWasVirtual())
71+
assert(getVBaseClassOffset(PrimaryBase) == 0 &&
72+
"Primary virtual base must be at offset 0!");
73+
else
74+
assert(getBaseClassOffset(PrimaryBase) == 0 &&
75+
"Primary base must be at offset 0!");
76+
}
77+
#endif
6778
}

0 commit comments

Comments
 (0)