]> granicus.if.org Git - clang/commitdiff
Add a simple debug-only verification pass to the record layout builder.
authorAnders Carlsson <andersca@mac.com>
Sat, 10 Apr 2010 21:24:48 +0000 (21:24 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 10 Apr 2010 21:24:48 +0000 (21:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100951 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/RecordLayoutBuilder.cpp

index 44a4d4cabcbcf6d4e271420386f58adc5cb890ec..b2426833a2ec688e26da7203c90a4d638c2d6864 100644 (file)
@@ -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.