[cfe-commits] r102274 - in /cfe/trunk/lib/CodeGen: CGClass.cpp CGExprAgg.cpp CGExprConstant.cpp CGExprScalar.cpp CodeGenModule.h

Anders Carlsson andersca at mac.com
Sat Apr 24 14:27:51 PDT 2010


Author: andersca
Date: Sat Apr 24 16:27:51 2010
New Revision: 102274

URL: http://llvm.org/viewvc/llvm-project?rev=102274&view=rev
Log:
Get rid of the old GetNonVirtualBaseClassOffset and change all call sites to use the new version.

Modified:
    cfe/trunk/lib/CodeGen/CGClass.cpp
    cfe/trunk/lib/CodeGen/CGExprAgg.cpp
    cfe/trunk/lib/CodeGen/CGExprConstant.cpp
    cfe/trunk/lib/CodeGen/CGExprScalar.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=102274&r1=102273&r2=102274&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Sat Apr 24 16:27:51 2010
@@ -88,31 +88,6 @@
   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);
 }
 
 /// Gets the address of a virtual base class within a complete object.

Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=102274&r1=102273&r2=102274&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Sat Apr 24 16:27:51 2010
@@ -263,7 +263,7 @@
       std::swap(DerivedDecl, BaseDecl);
 
     if (llvm::Constant *Adj = 
-          CGF.CGM.GetNonVirtualBaseClassOffset(DerivedDecl, BaseDecl)) {
+          CGF.CGM.GetNonVirtualBaseClassOffset(DerivedDecl, E->getBasePath())) {
       if (E->getCastKind() == CastExpr::CK_DerivedToBaseMemberPointer)
         SrcAdj = Builder.CreateSub(SrcAdj, Adj, "adj");
       else

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=102274&r1=102273&r2=102274&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Sat Apr 24 16:27:51 2010
@@ -556,8 +556,6 @@
       const MemberPointerType *DestTy = 
         E->getType()->getAs<MemberPointerType>();
       
-      const CXXRecordDecl *BaseClass =
-        cast<CXXRecordDecl>(cast<RecordType>(SrcTy->getClass())->getDecl());
       const CXXRecordDecl *DerivedClass =
         cast<CXXRecordDecl>(cast<RecordType>(DestTy->getClass())->getDecl());
 
@@ -571,7 +569,7 @@
         
         // Check if we need to update the adjustment.
         if (llvm::Constant *Offset = 
-              CGM.GetNonVirtualBaseClassOffset(DerivedClass, BaseClass)) {
+            CGM.GetNonVirtualBaseClassOffset(DerivedClass, E->getBasePath())) {
           llvm::Constant *Values[2];
         
           Values[0] = CS->getOperand(0);

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=102274&r1=102273&r2=102274&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Sat Apr 24 16:27:51 2010
@@ -888,7 +888,8 @@
       std::swap(DerivedDecl, BaseDecl);
 
     if (llvm::Constant *Adj = 
-          CGF.CGM.GetNonVirtualBaseClassOffset(DerivedDecl, BaseDecl)) {
+          CGF.CGM.GetNonVirtualBaseClassOffset(DerivedDecl, 
+                                               CE->getBasePath())) {
       if (CE->getCastKind() == CastExpr::CK_DerivedToBaseMemberPointer)
         Src = Builder.CreateSub(Src, Adj, "adj");
       else

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=102274&r1=102273&r2=102274&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Sat Apr 24 16:27:51 2010
@@ -241,10 +241,7 @@
   llvm::Constant *GetWeakRefReference(const ValueDecl *VD);
 
   /// GetNonVirtualBaseClassOffset - Returns the offset from a derived class to 
-  /// its base class. Returns null if the offset is 0. 
-  llvm::Constant *
-  GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl,
-                               const CXXRecordDecl *BaseClassDecl);
+  /// a class. Returns null if the offset is 0. 
   llvm::Constant *
   GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl,
                                const CXXBaseSpecifierArray &BasePath);





More information about the cfe-commits mailing list