[cfe-commits] r100951 - /cfe/trunk/lib/AST/RecordLayoutBuilder.cpp

Anders Carlsson andersca at mac.com
Sat Apr 10 14:24:48 PDT 2010


Author: andersca
Date: Sat Apr 10 16:24:48 2010
New Revision: 100951

URL: http://llvm.org/viewvc/llvm-project?rev=100951&view=rev
Log:
Add a simple debug-only verification pass to the record layout builder.

Modified:
    cfe/trunk/lib/AST/RecordLayoutBuilder.cpp

Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=100951&r1=100950&r2=100951&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Sat Apr 10 16:24:48 2010
@@ -504,6 +504,31 @@
   // 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.





More information about the cfe-commits mailing list