Get rid of the old GetNonVirtualBaseClassOffset and change all call sites to use the new version.
llvm-svn: 102274
This commit is contained in:
parent
8a64c1c94c
commit
795213efde
|
@ -87,31 +87,6 @@ CodeGenModule::GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl,
|
||||||
const llvm::Type *PtrDiffTy =
|
const llvm::Type *PtrDiffTy =
|
||||||
Types.ConvertType(getContext().getPointerDiffType());
|
Types.ConvertType(getContext().getPointerDiffType());
|
||||||
|
|
||||||
return llvm::ConstantInt::get(PtrDiffTy, Offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
llvm::Constant *
|
|
||||||
CodeGenModule::GetNonVirtualBaseClassOffset(const CXXRecordDecl *Class,
|
|
||||||
const CXXRecordDecl *BaseClass) {
|
|
||||||
if (Class == BaseClass)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
CXXBasePaths Paths(/*FindAmbiguities=*/false,
|
|
||||||
/*RecordPaths=*/true, /*DetectVirtual=*/false);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t Offset = ComputeNonVirtualBaseClassOffset(getContext(),
|
|
||||||
Paths.front(), 0);
|
|
||||||
if (!Offset)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
const llvm::Type *PtrDiffTy =
|
|
||||||
Types.ConvertType(getContext().getPointerDiffType());
|
|
||||||
|
|
||||||
return llvm::ConstantInt::get(PtrDiffTy, Offset);
|
return llvm::ConstantInt::get(PtrDiffTy, Offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,7 +263,7 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) {
|
||||||
std::swap(DerivedDecl, BaseDecl);
|
std::swap(DerivedDecl, BaseDecl);
|
||||||
|
|
||||||
if (llvm::Constant *Adj =
|
if (llvm::Constant *Adj =
|
||||||
CGF.CGM.GetNonVirtualBaseClassOffset(DerivedDecl, BaseDecl)) {
|
CGF.CGM.GetNonVirtualBaseClassOffset(DerivedDecl, E->getBasePath())) {
|
||||||
if (E->getCastKind() == CastExpr::CK_DerivedToBaseMemberPointer)
|
if (E->getCastKind() == CastExpr::CK_DerivedToBaseMemberPointer)
|
||||||
SrcAdj = Builder.CreateSub(SrcAdj, Adj, "adj");
|
SrcAdj = Builder.CreateSub(SrcAdj, Adj, "adj");
|
||||||
else
|
else
|
||||||
|
|
|
@ -556,8 +556,6 @@ public:
|
||||||
const MemberPointerType *DestTy =
|
const MemberPointerType *DestTy =
|
||||||
E->getType()->getAs<MemberPointerType>();
|
E->getType()->getAs<MemberPointerType>();
|
||||||
|
|
||||||
const CXXRecordDecl *BaseClass =
|
|
||||||
cast<CXXRecordDecl>(cast<RecordType>(SrcTy->getClass())->getDecl());
|
|
||||||
const CXXRecordDecl *DerivedClass =
|
const CXXRecordDecl *DerivedClass =
|
||||||
cast<CXXRecordDecl>(cast<RecordType>(DestTy->getClass())->getDecl());
|
cast<CXXRecordDecl>(cast<RecordType>(DestTy->getClass())->getDecl());
|
||||||
|
|
||||||
|
@ -571,7 +569,7 @@ public:
|
||||||
|
|
||||||
// Check if we need to update the adjustment.
|
// Check if we need to update the adjustment.
|
||||||
if (llvm::Constant *Offset =
|
if (llvm::Constant *Offset =
|
||||||
CGM.GetNonVirtualBaseClassOffset(DerivedClass, BaseClass)) {
|
CGM.GetNonVirtualBaseClassOffset(DerivedClass, E->getBasePath())) {
|
||||||
llvm::Constant *Values[2];
|
llvm::Constant *Values[2];
|
||||||
|
|
||||||
Values[0] = CS->getOperand(0);
|
Values[0] = CS->getOperand(0);
|
||||||
|
|
|
@ -888,7 +888,8 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) {
|
||||||
std::swap(DerivedDecl, BaseDecl);
|
std::swap(DerivedDecl, BaseDecl);
|
||||||
|
|
||||||
if (llvm::Constant *Adj =
|
if (llvm::Constant *Adj =
|
||||||
CGF.CGM.GetNonVirtualBaseClassOffset(DerivedDecl, BaseDecl)) {
|
CGF.CGM.GetNonVirtualBaseClassOffset(DerivedDecl,
|
||||||
|
CE->getBasePath())) {
|
||||||
if (CE->getCastKind() == CastExpr::CK_DerivedToBaseMemberPointer)
|
if (CE->getCastKind() == CastExpr::CK_DerivedToBaseMemberPointer)
|
||||||
Src = Builder.CreateSub(Src, Adj, "adj");
|
Src = Builder.CreateSub(Src, Adj, "adj");
|
||||||
else
|
else
|
||||||
|
|
|
@ -241,10 +241,7 @@ public:
|
||||||
llvm::Constant *GetWeakRefReference(const ValueDecl *VD);
|
llvm::Constant *GetWeakRefReference(const ValueDecl *VD);
|
||||||
|
|
||||||
/// GetNonVirtualBaseClassOffset - Returns the offset from a derived class to
|
/// GetNonVirtualBaseClassOffset - Returns the offset from a derived class to
|
||||||
/// its base class. Returns null if the offset is 0.
|
/// a class. Returns null if the offset is 0.
|
||||||
llvm::Constant *
|
|
||||||
GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl,
|
|
||||||
const CXXRecordDecl *BaseClassDecl);
|
|
||||||
llvm::Constant *
|
llvm::Constant *
|
||||||
GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl,
|
GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl,
|
||||||
const CXXBaseSpecifierArray &BasePath);
|
const CXXBaseSpecifierArray &BasePath);
|
||||||
|
|
Loading…
Reference in New Issue