diff options
| author | Anders Carlsson <andersca@mac.com> | 2010-04-10 21:24:48 +0000 |
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2010-04-10 21:24:48 +0000 |
| commit | 5b441d73b757b69c44fedd5f04daeb344d6eb088 (patch) | |
| tree | 6d4518ab79ab598d71971b5b8ea7cdc0c5c9a1f1 /clang/lib | |
| parent | 88cf34f2b49b53493c3d96378136f2da0607455e (diff) | |
| download | bcm5719-llvm-5b441d73b757b69c44fedd5f04daeb344d6eb088.tar.gz bcm5719-llvm-5b441d73b757b69c44fedd5f04daeb344d6eb088.zip | |
Add a simple debug-only verification pass to the record layout builder.
llvm-svn: 100951
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/RecordLayoutBuilder.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index 44a4d4cabcb..b2426833a2e 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -504,6 +504,31 @@ void ASTRecordLayoutBuilder::Layout(const RecordDecl *D) { // Finally, round the size of the total struct up to the alignment of the // struct itself. FinishLayout(); + +#ifndef NDEBUG + if (RD) { + // Check that we have base offsets for all bases. + for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(), + E = RD->bases_end(); I != E; ++I) { + if (I->isVirtual()) + continue; + + const CXXRecordDecl *BaseDecl = + cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl()); + + assert(Bases.count(BaseDecl) && "Did not find base offset!"); + } + + // And all virtual bases. + for (CXXRecordDecl::base_class_const_iterator I = RD->vbases_begin(), + E = RD->vbases_end(); I != E; ++I) { + const CXXRecordDecl *BaseDecl = + cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl()); + + assert(VBases.count(BaseDecl) && "Did not find base offset!"); + } + } +#endif } // FIXME. Impl is no longer needed. |

