]> granicus.if.org Git - clang/commitdiff
Remove OldGetAddressOfBaseClass - bye bye ambiguities.
authorAnders Carlsson <andersca@mac.com>
Mon, 3 May 2010 00:32:27 +0000 (00:32 +0000)
committerAnders Carlsson <andersca@mac.com>
Mon, 3 May 2010 00:32:27 +0000 (00:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102889 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGClass.cpp
lib/CodeGen/CodeGenFunction.h

index a070b7f55e99be68e53a8c80d9a34c54ae628acd..6e7208bdcbd10e258dab2f18dac19c5fb62b12ad 100644 (file)
@@ -47,31 +47,6 @@ ComputeNonVirtualBaseClassOffset(ASTContext &Context,
   // FIXME: We should not use / 8 here.
   return Offset / 8;
 }
-                                 
-static uint64_t 
-ComputeNonVirtualBaseClassOffset(ASTContext &Context,
-                                 const CXXBasePath &Path,
-                                 unsigned Start) {
-  uint64_t Offset = 0;
-
-  for (unsigned i = Start, e = Path.size(); i != e; ++i) {
-    const CXXBasePathElement& Element = Path[i];
-
-    // Get the layout.
-    const ASTRecordLayout &Layout = Context.getASTRecordLayout(Element.Class);
-    
-    const CXXBaseSpecifier *BS = Element.Base;
-    assert(!BS->isVirtual() && "Should not see virtual bases here!");
-    
-    const CXXRecordDecl *Base = 
-      cast<CXXRecordDecl>(BS->getType()->getAs<RecordType>()->getDecl());
-    
-    // Add the offset.
-    Offset += Layout.getBaseClassOffset(Base) / 8;
-  }
-
-  return Offset;
-}
 
 llvm::Constant *
 CodeGenModule::GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl,
@@ -228,72 +203,6 @@ CodeGenFunction::GetAddressOfBaseClass(llvm::Value *Value,
   return Value;
 }
 
-llvm::Value *
-CodeGenFunction::OldGetAddressOfBaseClass(llvm::Value *Value,
-                                          const CXXRecordDecl *Class,
-                                          const CXXRecordDecl *BaseClass) {
-  QualType BTy =
-    getContext().getCanonicalType(
-      getContext().getTypeDeclType(BaseClass));
-  const llvm::Type *BasePtrTy = llvm::PointerType::getUnqual(ConvertType(BTy));
-
-  if (Class == BaseClass) {
-    // Just cast back.
-    return Builder.CreateBitCast(Value, BasePtrTy);
-  }
-
-#ifndef NDEBUG
-  CXXBasePaths Paths(/*FindAmbiguities=*/true,
-                     /*RecordPaths=*/true, /*DetectVirtual=*/false);
-#else
-  CXXBasePaths Paths(/*FindAmbiguities=*/false,
-                     /*RecordPaths=*/true, /*DetectVirtual=*/false);
-#endif
-  if (!const_cast<CXXRecordDecl *>(Class)->
-        isDerivedFrom(const_cast<CXXRecordDecl *>(BaseClass), Paths)) {
-    assert(false && "Class must be derived from the passed in base class!");
-    return 0;
-  }
-
-#if 0
-  // FIXME: Re-enable this assert when the underlying bugs have been fixed.
-  assert(!Paths.isAmbiguous(BTy) && "Path is ambiguous");
-#endif
-
-  unsigned Start = 0;
-
-  const CXXBasePath &Path = Paths.front();
-  const CXXRecordDecl *VBase = 0;
-  for (unsigned i = 0, e = Path.size(); i != e; ++i) {
-    const CXXBasePathElement& Element = Path[i];
-    if (Element.Base->isVirtual()) {
-      Start = i+1;
-      QualType VBaseType = Element.Base->getType();
-      VBase = cast<CXXRecordDecl>(VBaseType->getAs<RecordType>()->getDecl());
-    }
-  }
-
-  uint64_t Offset = 
-    ComputeNonVirtualBaseClassOffset(getContext(), Paths.front(), Start);
-  
-  if (!Offset && !VBase) {
-    // Just cast back.
-    return Builder.CreateBitCast(Value, BasePtrTy);
-  }    
-
-  llvm::Value *VirtualOffset = 0;
-
-  if (VBase)
-    VirtualOffset = GetVirtualBaseClassOffset(Value, Class, VBase);
-
-  // Apply the offsets.
-  Value = ApplyNonVirtualAndVirtualOffset(*this, Value, Offset, VirtualOffset);
-  
-  // Cast back.
-  Value = Builder.CreateBitCast(Value, BasePtrTy);
-  return Value;
-}
-
 llvm::Value *
 CodeGenFunction::GetAddressOfDerivedClass(llvm::Value *Value,
                                           const CXXRecordDecl *Derived,
index 77d4a97d0c13bcaa1b8e999abdc85115c4e141e3..90a3ec4a4b109d5f489e247b3738c804e89c5a16 100644 (file)
@@ -786,10 +786,6 @@ public:
                                         const CXXRecordDecl *Base,
                                         bool BaseIsVirtual);
 
-  llvm::Value *OldGetAddressOfBaseClass(llvm::Value *Value,
-                                        const CXXRecordDecl *ClassDecl,
-                                        const CXXRecordDecl *BaseClassDecl);
-
   /// GetAddressOfBaseClass - This function will add the necessary delta to the
   /// load of 'this' and returns address of the base class.
   llvm::Value *GetAddressOfBaseClass(llvm::Value *Value,