llvm-project/clang/test/Layout
David Majnemer cd3ebfe293 [MS ABI] Implement __declspec(empty_bases) and __declspec(layout_version)
The layout_version attribute is pretty straightforward: use the layout
rules from version XYZ of MSVC when used like
struct __declspec(layout_version(XYZ)) S {};

The empty_bases attribute is more interesting.  It tries to get the C++
empty base optimization to fire more often by tweaking the MSVC ABI
rules in subtle ways:
1. Disable the leading and trailing zero-sized object flags if a class
   is marked __declspec(empty_bases) and is empty.

   This means that given:
   struct __declspec(empty_bases) A {};
   struct __declspec(empty_bases) B {};
   struct C : A, B {};

   'C' will have size 1 and nvsize 0 despite not being annotated
   __declspec(empty_bases).

2. When laying out virtual or non-virtual bases, disable the injection
   of padding between classes if the most derived class is marked
   __declspec(empty_bases).

   This means that given:
   struct A {};
   struct B {};
   struct __declspec(empty_bases) C : A, B {};

   'C' will have size 1 and nvsize 0.

3. When calculating the offset of a non-virtual base, choose offset zero
   if the most derived class is marked __declspec(empty_bases) and the
   base is empty _and_ has an nvsize of 0.

   Because of the ABI rules, this does not mean that empty bases
   reliably get placed at offset 0!

   For example:
   struct A {};
   struct B {};
   struct __declspec(empty_bases) C : A, B { virtual ~C(); };

   'C' will be pointer sized to account for the vfptr at offset 0.
   'A' and 'B' will _not_ be at offset 0 despite being empty!
   Instead, they will be located right after the vfptr.

   This occurs due to the interaction betweeen non-virtual base layout
   and virtual function pointer injection: injection occurs after the
   nv-bases and shifts them down by the size of a pointer.

llvm-svn: 270457
2016-05-23 17:16:12 +00:00
..
itanium-union-bitfield.cpp Fix the layout of bitfields in ms_struct unions: their 2015-08-19 22:42:36 +00:00
ms-vtordisp-local.cpp [MS] Fix for bug 25013 - #pragma vtordisp is unknown inside functions, by Denis Zobnin. 2015-11-20 07:02:57 +00:00
ms-x86-alias-avoidance-padding.cpp Fix the layout of bitfields in ms_struct unions: their 2015-08-19 22:42:36 +00:00
ms-x86-aligned-tail-padding.cpp __declspec is not a core Clang language extension. Instead, require -fms-extensions or -fborland to enable the language extension. 2015-05-26 19:44:52 +00:00
ms-x86-basic-layout.cpp __declspec is not a core Clang language extension. Instead, require -fms-extensions or -fborland to enable the language extension. 2015-05-26 19:44:52 +00:00
ms-x86-bitfields-vbases.cpp Fix the layout of bitfields in ms_struct unions: their 2015-08-19 22:42:36 +00:00
ms-x86-declspec-empty_bases.cpp [MS ABI] Implement __declspec(empty_bases) and __declspec(layout_version) 2016-05-23 17:16:12 +00:00
ms-x86-empty-base-after-base-with-vbptr.cpp
ms-x86-empty-layout.c Fix the layout of bitfields in ms_struct unions: their 2015-08-19 22:42:36 +00:00
ms-x86-empty-nonvirtual-bases.cpp [MS ABI] Don't crash when inheriting from base with trailing empty array member 2015-10-22 18:04:22 +00:00
ms-x86-empty-virtual-base.cpp Fix the layout of bitfields in ms_struct unions: their 2015-08-19 22:42:36 +00:00
ms-x86-lazy-empty-nonvirtual-base.cpp __declspec is not a core Clang language extension. Instead, require -fms-extensions or -fborland to enable the language extension. 2015-05-26 19:44:52 +00:00
ms-x86-member-pointers.cpp
ms-x86-misalignedarray.cpp
ms-x86-pack-and-align.cpp Fix the layout of bitfields in ms_struct unions: their 2015-08-19 22:42:36 +00:00
ms-x86-primary-bases.cpp
ms-x86-size-alignment-fail.cpp __declspec is not a core Clang language extension. Instead, require -fms-extensions or -fborland to enable the language extension. 2015-05-26 19:44:52 +00:00
ms-x86-vfvb-alignment.cpp __declspec is not a core Clang language extension. Instead, require -fms-extensions or -fborland to enable the language extension. 2015-05-26 19:44:52 +00:00
ms-x86-vfvb-sharing.cpp __declspec is not a core Clang language extension. Instead, require -fms-extensions or -fborland to enable the language extension. 2015-05-26 19:44:52 +00:00
ms-x86-vtordisp.cpp MS ABI: Pure virtual functions don't contribute to vtordisps 2014-09-23 22:58:15 +00:00
ms_struct-bitfields.c Fix the layout of bitfields in ms_struct unions: their 2015-08-19 22:42:36 +00:00