]> granicus.if.org Git - clang/commitdiff
Get rid of the old GetNonVirtualBaseClassOffset and change all call sites to use...
authorAnders Carlsson <andersca@mac.com>
Sat, 24 Apr 2010 21:27:51 +0000 (21:27 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 24 Apr 2010 21:27:51 +0000 (21:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102274 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGClass.cpp
lib/CodeGen/CGExprAgg.cpp
lib/CodeGen/CGExprConstant.cpp
lib/CodeGen/CGExprScalar.cpp
lib/CodeGen/CodeGenModule.h

index 6dea9f77ae984a8fd78b2f94ce692144848b6671..45390c7bdc42a60c24ca5660adaeb9ad66308bbd 100644 (file)
@@ -87,31 +87,6 @@ CodeGenModule::GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl,
   const llvm::Type *PtrDiffTy = 
   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);
 }
 
index 32fab45a8a372288f9056c9e2ace37162054d55c..84841bf5b9f854cf4a6da31bdd3b18b2fbfcfe6b 100644 (file)
@@ -263,7 +263,7 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) {
       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
index ce0d69bcfeb790ba21bd2b653e6a650736f57e6e..ab0805ee7cf93e070102456e9bb0afcf1143ac4c 100644 (file)
@@ -556,8 +556,6 @@ public:
       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 @@ public:
         
         // 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);
index ad072c6d01b51e152576ca6dd5866d2578e6fb24..842590b24ca8831a971a72f65af868d436b39cd4 100644 (file)
@@ -888,7 +888,8 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) {
       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
index c324d61a5d782cee681aeb05b9a5c27fee5050bf..b0abc492a853231f6d1866fc60d1161065f839d2 100644 (file)
@@ -241,10 +241,7 @@ public:
   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);