forked from OSchip/llvm-project
Convert more call sites over to the new GetAddressOfBaseClass.
llvm-svn: 102272
This commit is contained in:
parent
d5c231e745
commit
c6eaea70af
|
@ -1731,7 +1731,7 @@ public:
|
|||
return const_cast<CastExpr *>(this)->getSubExprAsWritten();
|
||||
}
|
||||
|
||||
const CXXBaseSpecifierArray& getBasePath() { return BasePath; }
|
||||
const CXXBaseSpecifierArray& getBasePath() const { return BasePath; }
|
||||
|
||||
static bool classof(const Stmt *T) {
|
||||
StmtClass SC = T->getStmtClass();
|
||||
|
|
|
@ -184,7 +184,7 @@ CodeGenFunction::GetAddressOfBaseClass(llvm::Value *Value,
|
|||
|
||||
// Get the base pointer type.
|
||||
const llvm::Type *BasePtrTy =
|
||||
llvm::PointerType::getUnqual(ConvertType((BasePath.end()[-1])->getType()));
|
||||
ConvertType((BasePath.end()[-1])->getType())->getPointerTo();
|
||||
|
||||
if (!NonVirtualOffset && !VBase) {
|
||||
// Just cast back.
|
||||
|
|
|
@ -174,16 +174,15 @@ RValue CodeGenFunction::EmitReferenceBindingToExpr(const Expr* E,
|
|||
PopCXXTemporary();
|
||||
}
|
||||
} else {
|
||||
const CXXRecordDecl *BaseClassDecl = 0;
|
||||
const CXXBaseSpecifierArray *BasePath = 0;
|
||||
const CXXRecordDecl *DerivedClassDecl = 0;
|
||||
|
||||
if (const CastExpr *CE =
|
||||
dyn_cast<CastExpr>(E->IgnoreParenNoopCasts(getContext()))) {
|
||||
if (CE->getCastKind() == CastExpr::CK_DerivedToBase) {
|
||||
E = CE->getSubExpr();
|
||||
|
||||
BaseClassDecl =
|
||||
cast<CXXRecordDecl>(CE->getType()->getAs<RecordType>()->getDecl());
|
||||
|
||||
BasePath = &CE->getBasePath();
|
||||
DerivedClassDecl =
|
||||
cast<CXXRecordDecl>(E->getType()->getAs<RecordType>()->getDecl());
|
||||
}
|
||||
|
@ -225,10 +224,10 @@ RValue CodeGenFunction::EmitReferenceBindingToExpr(const Expr* E,
|
|||
}
|
||||
|
||||
// Check if need to perform the derived-to-base cast.
|
||||
if (BaseClassDecl) {
|
||||
if (BasePath) {
|
||||
llvm::Value *Derived = Val.getAggregateAddr();
|
||||
llvm::Value *Base =
|
||||
GetAddressOfBaseClass(Derived, DerivedClassDecl, BaseClassDecl,
|
||||
GetAddressOfBaseClass(Derived, DerivedClassDecl, *BasePath,
|
||||
/*NullCheckValue=*/false);
|
||||
return RValue::get(Base);
|
||||
}
|
||||
|
@ -1681,16 +1680,13 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) {
|
|||
E->getSubExpr()->getType()->getAs<RecordType>();
|
||||
CXXRecordDecl *DerivedClassDecl =
|
||||
cast<CXXRecordDecl>(DerivedClassTy->getDecl());
|
||||
|
||||
const RecordType *BaseClassTy = E->getType()->getAs<RecordType>();
|
||||
CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(BaseClassTy->getDecl());
|
||||
|
||||
LValue LV = EmitLValue(E->getSubExpr());
|
||||
|
||||
// Perform the derived-to-base conversion
|
||||
llvm::Value *Base =
|
||||
GetAddressOfBaseClass(LV.getAddress(), DerivedClassDecl,
|
||||
BaseClassDecl, /*NullCheckValue=*/false);
|
||||
E->getBasePath(), /*NullCheckValue=*/false);
|
||||
|
||||
return LValue::MakeAddr(Base, MakeQualifiers(E->getType()));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue