[cfe-commits] r102284 - in /cfe/trunk/lib/CodeGen: CGClass.cpp CodeGenFunction.h
Anders Carlsson
andersca at mac.com
Sat Apr 24 16:01:50 PDT 2010
Author: andersca
Date: Sat Apr 24 18:01:49 2010
New Revision: 102284
URL: http://llvm.org/viewvc/llvm-project?rev=102284&view=rev
Log:
RenameGetAddressOfBaseOfCompleteClass to GetAddressOfDirectBaseInCompleteClass to reflect that it only handles direct bases.
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=102284&r1=102283&r2=102284&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Sat Apr 24 18:01:49 2010
@@ -90,16 +90,16 @@
return llvm::ConstantInt::get(PtrDiffTy, Offset);
}
-/// Gets the address of a virtual base class within a complete object.
+/// Gets the address of a direct base class within a complete object.
/// This should only be used for (1) non-virtual bases or (2) virtual bases
/// when the type is known to be complete (e.g. in complete destructors).
///
/// The object pointed to by 'This' is assumed to be non-null.
llvm::Value *
-CodeGenFunction::GetAddressOfBaseOfCompleteClass(llvm::Value *This,
- bool isBaseVirtual,
- const CXXRecordDecl *Derived,
- const CXXRecordDecl *Base) {
+CodeGenFunction::GetAddressOfDirectBaseInCompleteClass(llvm::Value *This,
+ const CXXRecordDecl *Derived,
+ const CXXRecordDecl *Base,
+ bool BaseIsVirtual) {
// 'this' must be a pointer (in some address space) to Derived.
assert(This->getType()->isPointerTy() &&
cast<llvm::PointerType>(This->getType())->getElementType()
@@ -108,7 +108,7 @@
// Compute the offset of the virtual base.
uint64_t Offset;
const ASTRecordLayout &Layout = getContext().getASTRecordLayout(Derived);
- if (isBaseVirtual)
+ if (BaseIsVirtual)
Offset = Layout.getVBaseClassOffset(Base);
else
Offset = Layout.getBaseClassOffset(Base);
@@ -155,7 +155,7 @@
llvm::Value *
CodeGenFunction::GetAddressOfBaseClass(llvm::Value *Value,
- const CXXRecordDecl *ClassDecl,
+ const CXXRecordDecl *Derived,
const CXXBaseSpecifierArray &BasePath,
bool NullCheckValue) {
assert(!BasePath.empty() && "Base path should not be empty!");
@@ -171,7 +171,7 @@
}
uint64_t NonVirtualOffset =
- ComputeNonVirtualBaseClassOffset(getContext(), VBase ? VBase : ClassDecl,
+ ComputeNonVirtualBaseClassOffset(getContext(), VBase ? VBase : Derived,
Start, BasePath.end());
// Get the base pointer type.
@@ -202,7 +202,7 @@
llvm::Value *VirtualOffset = 0;
if (VBase)
- VirtualOffset = GetVirtualBaseClassOffset(Value, ClassDecl, VBase);
+ VirtualOffset = GetVirtualBaseClassOffset(Value, Derived, VBase);
// Apply the offsets.
Value = ApplyNonVirtualAndVirtualOffset(*this, Value, NonVirtualOffset,
@@ -296,18 +296,17 @@
llvm::Value *
CodeGenFunction::GetAddressOfDerivedClass(llvm::Value *Value,
- const CXXRecordDecl *DerivedClass,
+ const CXXRecordDecl *Derived,
const CXXBaseSpecifierArray &BasePath,
bool NullCheckValue) {
assert(!BasePath.empty() && "Base path should not be empty!");
QualType DerivedTy =
- getContext().getCanonicalType(
- getContext().getTypeDeclType(const_cast<CXXRecordDecl*>(DerivedClass)));
+ getContext().getCanonicalType(getContext().getTagDeclType(Derived));
const llvm::Type *DerivedPtrTy = ConvertType(DerivedTy)->getPointerTo();
llvm::Value *NonVirtualOffset =
- CGM.GetNonVirtualBaseClassOffset(DerivedClass, BasePath);
+ CGM.GetNonVirtualBaseClassOffset(Derived, BasePath);
if (!NonVirtualOffset) {
// No offset, we can just cast back.
@@ -837,9 +836,10 @@
// We can pretend to be a complete class because it only matters for
// virtual bases, and we only do virtual bases for complete ctors.
- llvm::Value *V = ThisPtr;
- V = CGF.GetAddressOfBaseOfCompleteClass(V, isBaseVirtual,
- ClassDecl, BaseClassDecl);
+ llvm::Value *V =
+ CGF.GetAddressOfDirectBaseInCompleteClass(ThisPtr, ClassDecl,
+ BaseClassDecl,
+ BaseInit->isBaseVirtual());
CGF.EmitAggExpr(BaseInit->getInit(), V, false, false, true);
@@ -1154,10 +1154,10 @@
if (BaseClassDecl->hasTrivialDestructor())
continue;
const CXXDestructorDecl *D = BaseClassDecl->getDestructor(getContext());
- llvm::Value *V = GetAddressOfBaseOfCompleteClass(LoadCXXThis(),
- true,
- ClassDecl,
- BaseClassDecl);
+ llvm::Value *V =
+ GetAddressOfDirectBaseInCompleteClass(LoadCXXThis(),
+ ClassDecl, BaseClassDecl,
+ /*BaseIsVirtual=*/true);
EmitCXXDestructorCall(D, Dtor_Base, V);
}
return;
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=102284&r1=102283&r2=102284&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Sat Apr 24 18:01:49 2010
@@ -775,11 +775,12 @@
}
/// GetAddressOfBaseOfCompleteClass - Convert the given pointer to a
- /// complete class down to one of its virtual bases.
- llvm::Value *GetAddressOfBaseOfCompleteClass(llvm::Value *Value,
- bool IsVirtual,
- const CXXRecordDecl *Derived,
- const CXXRecordDecl *Base);
+ /// complete class to the given direct base.
+ llvm::Value *
+ GetAddressOfDirectBaseInCompleteClass(llvm::Value *Value,
+ const CXXRecordDecl *Derived,
+ const CXXRecordDecl *Base,
+ bool BaseIsVirtual);
llvm::Value *OldGetAddressOfBaseClass(llvm::Value *Value,
const CXXRecordDecl *ClassDecl,
@@ -788,12 +789,12 @@
/// 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,
- const CXXRecordDecl *ClassDecl,
+ const CXXRecordDecl *Derived,
const CXXBaseSpecifierArray &BasePath,
bool NullCheckValue);
llvm::Value *GetAddressOfDerivedClass(llvm::Value *Value,
- const CXXRecordDecl *DerivedClassDecl,
+ const CXXRecordDecl *Derived,
const CXXBaseSpecifierArray &BasePath,
bool NullCheckValue);
More information about the cfe-commits
mailing list