Add the same 'ForVirtualBase' parameter to EmitCXXDestructorCall.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102882 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp
index 9e96727..e058a45 100644
--- a/lib/CodeGen/CGClass.cpp
+++ b/lib/CodeGen/CGClass.cpp
@@ -626,7 +626,7 @@
     CodeGenFunction::EHCleanupBlock Cleanup(CGF);
 
     CXXDestructorDecl *DD = BaseClassDecl->getDestructor(CGF.getContext());
-    CGF.EmitCXXDestructorCall(DD, Dtor_Base, V);
+    CGF.EmitCXXDestructorCall(DD, Dtor_Base, isBaseVirtual, V);
   }
 }
 
@@ -685,7 +685,8 @@
       LValue LHS = CGF.EmitLValueForField(ThisPtr, Field, 0);
 
       CXXDestructorDecl *DD = RD->getDestructor(CGF.getContext());
-      CGF.EmitCXXDestructorCall(DD, Dtor_Complete, LHS.getAddress());
+      CGF.EmitCXXDestructorCall(DD, Dtor_Complete, /*ForVirtualBase=*/false,
+                                LHS.getAddress());
     }
   }
 }
@@ -843,7 +844,8 @@
   // variant, then call the appropriate operator delete() on the way
   // out.
   if (DtorType == Dtor_Deleting) {
-    EmitCXXDestructorCall(Dtor, Dtor_Complete, LoadCXXThis());
+    EmitCXXDestructorCall(Dtor, Dtor_Complete, /*ForVirtualBase=*/false,
+                          LoadCXXThis());
     SkipBody = true;
 
   // If this is the complete variant, just invoke the base variant;
@@ -851,7 +853,8 @@
   // this optimization if the body is a function-try-block, because
   // we'd introduce *two* handler blocks.
   } else if (!isTryBody && DtorType == Dtor_Complete) {
-    EmitCXXDestructorCall(Dtor, Dtor_Base, LoadCXXThis());
+    EmitCXXDestructorCall(Dtor, Dtor_Base, /*ForVirtualBase=*/false,
+                          LoadCXXThis());
     SkipBody = true;
       
   // Otherwise, we're in the base variant, so we need to ensure the
@@ -936,7 +939,7 @@
         GetAddressOfDirectBaseInCompleteClass(LoadCXXThis(),
                                               ClassDecl, BaseClassDecl,
                                               /*BaseIsVirtual=*/true);
-      EmitCXXDestructorCall(D, Dtor_Base, V);
+      EmitCXXDestructorCall(D, Dtor_Base, /*ForVirtualBase=*/true, V);
     }
     return;
   }
@@ -990,7 +993,8 @@
                                 Array, BaseAddrPtr);
     } else
       EmitCXXDestructorCall(FieldClassDecl->getDestructor(getContext()),
-                            Dtor_Complete, LHS.getAddress());
+                            Dtor_Complete, /*ForVirtualBase=*/false,
+                            LHS.getAddress());
   }
 
   // Destroy non-virtual bases.
@@ -1012,7 +1016,7 @@
     
     llvm::Value *V = OldGetAddressOfBaseClass(LoadCXXThis(),
                                               ClassDecl, BaseClassDecl);
-    EmitCXXDestructorCall(D, Dtor_Base, V);
+    EmitCXXDestructorCall(D, Dtor_Base, /*ForVirtualBase=*/false, V);
   }
 }
 
@@ -1160,7 +1164,7 @@
   Counter = Builder.CreateLoad(IndexPtr);
   Counter = Builder.CreateSub(Counter, One);
   llvm::Value *Address = Builder.CreateInBoundsGEP(This, Counter, "arrayidx");
-  EmitCXXDestructorCall(D, Dtor_Complete, Address);
+  EmitCXXDestructorCall(D, Dtor_Complete, /*ForVirtualBase=*/false, Address);
 
   EmitBlock(ContinueBlock);
 
@@ -1318,6 +1322,7 @@
 
 void CodeGenFunction::EmitCXXDestructorCall(const CXXDestructorDecl *DD,
                                             CXXDtorType Type,
+                                            bool ForVirtualBase,
                                             llvm::Value *This) {
   llvm::Value *VTT = GetVTTParameter(*this, GlobalDecl(DD, Type));
   llvm::Value *Callee = CGM.GetAddrOfCXXDestructor(DD, Type);
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index 331ae7a..98a449a 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -676,14 +676,16 @@
         } else {
           {
             DelayedCleanupBlock Scope(*this);
-            EmitCXXDestructorCall(D, Dtor_Complete, DeclPtr);
+            EmitCXXDestructorCall(D, Dtor_Complete, /*ForVirtualBase=*/false,
+                                  DeclPtr);
 
             // Make sure to jump to the exit block.
             EmitBranch(Scope.getCleanupExitBlock());
           }
           if (Exceptions) {
             EHCleanupBlock Cleanup(*this);
-            EmitCXXDestructorCall(D, Dtor_Complete, DeclPtr);
+            EmitCXXDestructorCall(D, Dtor_Complete, /*ForVirtualBase=*/false,
+                                  DeclPtr);
           }
         }
       }
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 5c9374d..9ade916 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -208,6 +208,7 @@
             {
               DelayedCleanupBlock Scope(*this);
               EmitCXXDestructorCall(Dtor, Dtor_Complete,
+                                    /*ForVirtualBase=*/false,
                                     Val.getAggregateAddr());
               
               // Make sure to jump to the exit block.
@@ -216,6 +217,7 @@
             if (Exceptions) {
               EHCleanupBlock Cleanup(*this);
               EmitCXXDestructorCall(Dtor, Dtor_Complete,
+                                    /*ForVirtualBase=*/false,
                                     Val.getAggregateAddr());
             }
           }
diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp
index 5191f92..149f616 100644
--- a/lib/CodeGen/CGExprCXX.cpp
+++ b/lib/CodeGen/CGExprCXX.cpp
@@ -765,7 +765,8 @@
           // The dtor took care of deleting the object.
           ShouldCallDelete = false;
         } else 
-          EmitCXXDestructorCall(Dtor, Dtor_Complete, Ptr);
+          EmitCXXDestructorCall(Dtor, Dtor_Complete, /*ForVirtualBase=*/false,
+                                Ptr);
       }
     }
   }
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index 4a874e2..3359250 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -451,7 +451,8 @@
       }
       else 
         EmitCXXDestructorCall(FieldClassDecl->getDestructor(CGM.getContext()),
-                              Dtor_Complete, LV.getAddress());
+                              Dtor_Complete, /*ForVirtualBase=*/false,
+                              LV.getAddress());
     }    
   }
   FinishFunction();
diff --git a/lib/CodeGen/CGTemporaries.cpp b/lib/CodeGen/CGTemporaries.cpp
index d6d3be5..a8f0467 100644
--- a/lib/CodeGen/CGTemporaries.cpp
+++ b/lib/CodeGen/CGTemporaries.cpp
@@ -61,7 +61,8 @@
     }
 
     EmitCXXDestructorCall(Info.Temporary->getDestructor(),
-                          Dtor_Complete, Info.ThisPtr);
+                          Dtor_Complete, /*ForVirtualBase=*/false,
+                          Info.ThisPtr);
 
     if (CondEnd) {
       // Reset the condition. to false.
@@ -104,7 +105,7 @@
   }
 
   EmitCXXDestructorCall(Info.Temporary->getDestructor(),
-                        Dtor_Complete, Info.ThisPtr);
+                        Dtor_Complete, /*ForVirtualBase=*/false, Info.ThisPtr);
 
   if (CondEnd) {
     // Reset the condition. to false.
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index b8435d3..7c91c28 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -845,7 +845,7 @@
                                                 llvm::Value *This);
 
   void EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type,
-                             llvm::Value *This);
+                             bool ForVirtualBase, llvm::Value *This);
 
   void PushCXXTemporary(const CXXTemporary *Temporary, llvm::Value *Ptr);
   void PopCXXTemporary();