More cleanup of data member access and then some.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77351 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index d82b976..0b22eb4 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -168,16 +168,23 @@
   getContext().getASTRecordLayout(ClassDecl);
   llvm::Type *I8Ptr = VMContext.getPointerTypeUnqual(llvm::Type::Int8Ty);
   unsigned Idx = 0;
+  bool DerivedToBaseConversion = false;
   for (CXXRecordDecl::base_class_const_iterator i = 
          ClassDecl->bases_begin(),
          e = ClassDecl->bases_end(); i != e; ++i, ++Idx) {
     if (!i->isVirtual()) {
         const CXXRecordDecl *Base =
         cast<CXXRecordDecl>(i->getType()->getAsRecordType()->getDecl());
-        if (Base == BaseClassDecl)
-          break;
+      if (Base == BaseClassDecl) {
+        DerivedToBaseConversion = true;
+        break;
+      }
     }
   }
+  if (!DerivedToBaseConversion) {
+    assert(false && "FIXME - Only derived to imm. base convesion is supported");
+    return BaseValue;
+  }
   uint64_t Offset = Layout.getFieldOffset(Idx) / 8;
   llvm::Value *OffsetVal = llvm::ConstantInt::get(llvm::Type::Int32Ty, Offset);
   BaseValue = Builder.CreateBitCast(BaseValue, I8Ptr);