[cfe-commits] r102889 - in /cfe/trunk/lib/CodeGen: CGClass.cpp CodeGenFunction.h
Anders Carlsson
andersca at mac.com
Sun May 2 17:32:27 PDT 2010
Author: andersca
Date: Sun May 2 19:32:27 2010
New Revision: 102889
URL: http://llvm.org/viewvc/llvm-project?rev=102889&view=rev
Log:
Remove OldGetAddressOfBaseClass - bye bye ambiguities.
Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=102889&r1=102888&r2=102889&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Sun May 2 19:32:27 2010
@@ -47,31 +47,6 @@
// 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,
@@ -229,72 +204,6 @@
}
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,
const CXXBaseSpecifierArray &BasePath,
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=102889&r1=102888&r2=102889&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Sun May 2 19:32:27 2010
@@ -786,10 +786,6 @@
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,
More information about the cfe-commits
mailing list