Add the thunks needed by this vtable.

llvm-svn: 99793
diff --git a/clang/lib/CodeGen/CGVtable.cpp b/clang/lib/CodeGen/CGVtable.cpp
index 1c94a4e..592f782 100644
--- a/clang/lib/CodeGen/CGVtable.cpp
+++ b/clang/lib/CodeGen/CGVtable.cpp
@@ -3963,6 +3963,17 @@
   // Add the known thunks.
   Thunks.insert(Builder.thunks_begin(), Builder.thunks_end());
   
+  // Add the thunks needed in this vtable.
+  assert(!VTableThunksMap.count(RD) && 
+         "Thunks already exists for this vtable!");
+
+  VTableThunksTy &VTableThunks = VTableThunksMap[RD];
+  VTableThunks.append(Builder.vtable_thunks_begin(),
+                      Builder.vtable_thunks_end());
+  
+  // Sort them.
+  std::sort(VTableThunks.begin(), VTableThunks.end());
+  
   // Add the address points.
   for (VtableBuilder::AddressPointsMapTy::const_iterator I =
        Builder.address_points_begin(), E = Builder.address_points_end();