r204394 - Fix PR19172 - wrong this adjustment calculated for virtual destructor in a class with complex inheritance

Reid Kleckner rnk at google.com
Tue Mar 25 14:01:22 PDT 2014


lgtm

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.


On Thu, Mar 20, 2014 at 1:38 PM, Timur Iskhodzhanov <timurrrr at google.com>wrote:

> Author: timurrrr
> Date: Thu Mar 20 15:38:34 2014
> New Revision: 204394
>
> URL: http://llvm.org/viewvc/llvm-project?rev=204394&view=rev
> Log:
> Fix PR19172 - wrong this adjustment calculated for virtual destructor in a
> class with complex inheritance
>
> Reviewed at http://llvm-reviews.chandlerc.com/D3128
>
> Modified:
>     cfe/trunk/lib/AST/VTableBuilder.cpp
>     cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
>     cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp
>
> Modified: cfe/trunk/lib/AST/VTableBuilder.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=204394&r1=204393&r2=204394&view=diff
>
> ==============================================================================
>

....


>    uint64_t getNumVTableComponents() const { return Components.size(); }
> @@ -3291,9 +3291,15 @@ void MicrosoftVTableContext::computeVTab
>      VFTableLayouts[id] = new VTableLayout(
>          Builder.getNumVTableComponents(),
> Builder.vtable_component_begin(),
>          VTableThunks.size(), VTableThunks.data(), EmptyAddressPointsMap,
> true);
> -    NewMethodLocations.insert(Builder.vtable_indices_begin(),
> -                              Builder.vtable_indices_end());
>      Thunks.insert(Builder.thunks_begin(), Builder.thunks_end());
> +
> +    for (const auto &I : Builder.vtable_locations()) {
> +      GlobalDecl GD = I.first;
> +      MethodVFTableLocation NewLoc = I.second;
> +      auto M = NewMethodLocations.find(GD);
> +      if (M == NewMethodLocations.end() || NewLoc < M->second)
>

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?


> +        NewMethodLocations[GD] = NewLoc;
> +    }
>    }
>
>    MethodVFTableLocations.insert(NewMethodLocations.begin(),
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140325/8bdab638/attachment.html>


More information about the llvm-commits mailing list