]> granicus.if.org Git - clang/commitdiff
Revert r86741; it doesn't handle virtual bases correctly.
authorEli Friedman <eli.friedman@gmail.com>
Tue, 10 Nov 2009 22:48:10 +0000 (22:48 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Tue, 10 Nov 2009 22:48:10 +0000 (22:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86745 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCXXClass.cpp

index 668139ffb5219241a9148ddbb0ce175a51085bed..56a28fc9a007a7a2f904d7dbd8fc5c30e4ef6388 100644 (file)
@@ -127,14 +127,7 @@ CodeGenFunction::GetAddressCXXOfBaseClass(llvm::Value *BaseValue,
     // Just cast back.
     return Builder.CreateBitCast(BaseValue, BasePtrTy);
   }
-
-  llvm::Value *Offset = 
-    GetCXXBaseClassOffset(*this, BaseValue, ClassDecl, BaseClassDecl);
-
-  // If there is no offset, simply cast the pointer and return it.
-  if (!Offset)
-    return Builder.CreateBitCast(BaseValue, BasePtrTy);
-
+  
   llvm::BasicBlock *CastNull = 0;
   llvm::BasicBlock *CastNotNull = 0;
   llvm::BasicBlock *CastEnd = 0;
@@ -152,10 +145,15 @@ CodeGenFunction::GetAddressCXXOfBaseClass(llvm::Value *BaseValue,
   }
   
   const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext);
+
+  llvm::Value *Offset = 
+    GetCXXBaseClassOffset(*this, BaseValue, ClassDecl, BaseClassDecl);
   
-  // Apply the offset.
-  BaseValue = Builder.CreateBitCast(BaseValue, Int8PtrTy);
-  BaseValue = Builder.CreateGEP(BaseValue, Offset, "add.ptr");
+  if (Offset) {
+    // Apply the offset.
+    BaseValue = Builder.CreateBitCast(BaseValue, Int8PtrTy);
+    BaseValue = Builder.CreateGEP(BaseValue, Offset, "add.ptr");
+  }
   
   // Cast back.
   BaseValue = Builder.CreateBitCast(BaseValue, BasePtrTy);