Only add thunks for the most derived class. This fixes some link errors I was seeing in files generated by the vtable tester utility.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99801 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGVtable.cpp b/lib/CodeGen/CGVtable.cpp
index 3322510..f44b7cc 100644
--- a/lib/CodeGen/CGVtable.cpp
+++ b/lib/CodeGen/CGVtable.cpp
@@ -1803,8 +1803,9 @@
             ComputeThisAdjustment(OverriddenMD, BaseOffsetInLayoutClass,
                                   Overrider);
 
-          if (ThisAdjustment.VCallOffsetOffset) {
-            // This is a virtual thunk, add it.
+          if (ThisAdjustment.VCallOffsetOffset &&
+              Overrider.Method->getParent() == MostDerivedClass) {
+            // This is a virtual thunk for the most derived class, add it.
             AddThunk(Overrider.Method, 
                      ThunkInfo(ThisAdjustment, ReturnAdjustment()));
           }