<div dir="ltr">lgtm<div><br></div><div>I think I understand why this is necessary.  The method definition will assume 'this' on entry points to the type of the earliest vftable it appears in.</div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Mar 20, 2014 at 1:38 PM, Timur Iskhodzhanov <span dir="ltr"><<a href="mailto:timurrrr@google.com" target="_blank">timurrrr@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Author: timurrrr<br>
Date: Thu Mar 20 15:38:34 2014<br>
New Revision: 204394<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=204394&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=204394&view=rev</a><br>
Log:<br>
Fix PR19172 - wrong this adjustment calculated for virtual destructor in a class with complex inheritance<br>
<br>
Reviewed at <a href="http://llvm-reviews.chandlerc.com/D3128" target="_blank">http://llvm-reviews.chandlerc.com/D3128</a><br>
<br>
Modified:<br>
    cfe/trunk/lib/AST/VTableBuilder.cpp<br>
    cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp<br>
    cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp<br>
<br>
Modified: cfe/trunk/lib/AST/VTableBuilder.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=204394&r1=204393&r2=204394&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=204394&r1=204393&r2=204394&view=diff</a><br>

==============================================================================<br></blockquote><div><br></div><div>....</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

   uint64_t getNumVTableComponents() const { return Components.size(); }<br>
@@ -3291,9 +3291,15 @@ void MicrosoftVTableContext::computeVTab<br>
     VFTableLayouts[id] = new VTableLayout(<br>
         Builder.getNumVTableComponents(), Builder.vtable_component_begin(),<br>
         VTableThunks.size(), VTableThunks.data(), EmptyAddressPointsMap, true);<br>
-    NewMethodLocations.insert(Builder.vtable_indices_begin(),<br>
-                              Builder.vtable_indices_end());<br>
     Thunks.insert(Builder.thunks_begin(), Builder.thunks_end());<br>
+<br>
+    for (const auto &I : Builder.vtable_locations()) {<br>
+      GlobalDecl GD = I.first;<br>
+      MethodVFTableLocation NewLoc = I.second;<br>
+      auto M = NewMethodLocations.find(GD);<br>
+      if (M == NewMethodLocations.end() || NewLoc < M->second)<br></blockquote><div> </div><div>I believe MethodVFTableLocation::operator< is equivalent to layout order, but I could be wrong.  Which vbtable does the VBTableIndex field refer to?  Always the vbtable used by the MDC, or is it possible to compare indices from different tables?<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+        NewMethodLocations[GD] = NewLoc;<br>
+    }<br>
   }<br>
<br>
   MethodVFTableLocations.insert(NewMethodLocations.begin(),<br></blockquote></div></div></div>