[cfe-commits] r102272 - in /cfe/trunk: include/clang/AST/Expr.h lib/CodeGen/CGClass.cpp lib/CodeGen/CGExpr.cpp

Anders Carlsson andersca at mac.com
Sat Apr 24 14:12:55 PDT 2010


Author: andersca
Date: Sat Apr 24 16:12:55 2010
New Revision: 102272

URL: http://llvm.org/viewvc/llvm-project?rev=102272&view=rev
Log:
Convert more call sites over to the new GetAddressOfBaseClass.

Modified:
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/lib/CodeGen/CGClass.cpp
    cfe/trunk/lib/CodeGen/CGExpr.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=102272&r1=102271&r2=102272&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sat Apr 24 16:12:55 2010
@@ -1731,7 +1731,7 @@
     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();

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=102272&r1=102271&r2=102272&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Sat Apr 24 16:12:55 2010
@@ -184,7 +184,7 @@
 
   // 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.

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=102272&r1=102271&r2=102272&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Sat Apr 24 16:12:55 2010
@@ -174,16 +174,15 @@
         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 @@
     }
     
     // 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 @@
       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()));
   }





More information about the cfe-commits mailing list