From fc89c31a329eb6b36c6dbd8b7cb945d1a831650e Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 24 Apr 2010 21:12:55 +0000 Subject: [PATCH] Convert more call sites over to the new GetAddressOfBaseClass. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102272 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Expr.h | 2 +- lib/CodeGen/CGClass.cpp | 2 +- lib/CodeGen/CGExpr.cpp | 16 ++++++---------- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index b5ead937b0..d824a56acf 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -1731,7 +1731,7 @@ public: return const_cast(this)->getSubExprAsWritten(); } - const CXXBaseSpecifierArray& getBasePath() { return BasePath; } + const CXXBaseSpecifierArray& getBasePath() const { return BasePath; } static bool classof(const Stmt *T) { StmtClass SC = T->getStmtClass(); diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp index 991b6a71d3..b8f7df927c 100644 --- a/lib/CodeGen/CGClass.cpp +++ b/lib/CodeGen/CGClass.cpp @@ -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. diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 76ad40b2fc..62b5a3dbee 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -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(E->IgnoreParenNoopCasts(getContext()))) { if (CE->getCastKind() == CastExpr::CK_DerivedToBase) { E = CE->getSubExpr(); - - BaseClassDecl = - cast(CE->getType()->getAs()->getDecl()); + + BasePath = &CE->getBasePath(); DerivedClassDecl = cast(E->getType()->getAs()->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(); CXXRecordDecl *DerivedClassDecl = cast(DerivedClassTy->getDecl()); - - const RecordType *BaseClassTy = E->getType()->getAs(); - CXXRecordDecl *BaseClassDecl = cast(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())); } -- 2.40.0