r206087 - [MS-ABI] Fixed alias-avoidance padding in the presence of vtordisps

Duncan P. N. Exon Smith dexonsmith at apple.com
Fri Apr 11 17:34:20 PDT 2014


On Apr 11, 2014, at 16:33, Warren Hunt <whunt at google.com> wrote:

> Author: whunt
> Date: Fri Apr 11 18:33:35 2014
> New Revision: 206087
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=206087&view=rev
> Log:
> [MS-ABI] Fixed alias-avoidance padding in the presence of vtordisps
> If a vtordisp exists between two bases, then there is no need for 
> additional alias avoidance padding.  Test case included.
> 
> Modified:
>    cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
>    cfe/trunk/test/Layout/ms-x86-alias-avoidance-padding.cpp
> 
> Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=206087&r1=206086&r2=206087&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
> +++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Fri Apr 11 18:33:35 2014
> @@ -2620,10 +2620,7 @@ void MicrosoftRecordLayoutBuilder::layou
>     // bytes (in both 32 and 64 bits modes) and always involves rounding up to
>     // the required alignment, we don't know why.
>     if (PreviousBaseLayout && PreviousBaseLayout->hasZeroSizedSubObject() &&
> -        BaseLayout.leadsWithZeroSizedBase())
> -      Size = Size.RoundUpToAlignment(VtorDispAlignment) + VtorDispSize;
> -    // Insert the vtordisp.
> -    if (HasVtordisp)
> +        BaseLayout.leadsWithZeroSizedBase() || HasVtordisp)

Can you add parentheses to silence warnings?  I.e.:

    if ((PreviousBaseLayout && PreviousBaseLayout->hasZeroSizedSubObject() &&
         BaseLayout.leadsWithZeroSizedBase()) || HasVtordisp)

Actually, putting the HasVtordisp first might even be easier to read:

    if (HasVtordisp ||
        (PreviousBaseLayout &&
         PreviousBaseLayout->hasZeroSizedSubObject() &&
         BaseLayout.leadsWithZeroSizedBase()))

>       Size = Size.RoundUpToAlignment(VtorDispAlignment) + VtorDispSize;




More information about the cfe-commits mailing list