[PATCH] Fixing a struct layout bug with bitfields before virtual base

David Majnemer david.majnemer at gmail.com
Fri Jan 24 22:44:03 PST 2014


  I think it makes sense for the two bugs to be distinct.


================
Comment at: lib/CodeGen/CGRecordLayoutBuilder.cpp:347
@@ -346,2 +346,3 @@
   // beneficial.
   uint64_t EndOffset = Types.getContext().toBits(Layout.getDataSize());
+  if (Types.getContext().getLangOpts().CPlusPlus)
----------------
This would make more sense written as:

  uint64_t EndOffset;
  if (Types.getContext().getLangOpts().CPlusPlus)
    EndOffset = Types.getContext().toBits(Layout.getNonVirtualSize());
  else
    EndOffset = Types.getContext().toBits(Layout.getDataSize());

That being said, why do we need the language check at all? Couldn't we always use `Layout.getNonVirtualSize()`?


http://llvm-reviews.chandlerc.com/D2560



More information about the cfe-commits mailing list