diff options
| author | Yunzhong Gao <Yunzhong_Gao@playstation.sony.com> | 2014-01-29 00:09:16 +0000 |
|---|---|---|
| committer | Yunzhong Gao <Yunzhong_Gao@playstation.sony.com> | 2014-01-29 00:09:16 +0000 |
| commit | 9124a4b7f4e310c9f4aa305f42ce48fd352eaaf3 (patch) | |
| tree | 46627f1cd993f224d741220208195d3da8513763 /lib/CodeGen/CGRecordLayoutBuilder.cpp | |
| parent | 2ca8d0c1e640fdad9d49160b852b90e0f2e6ba60 (diff) | |
| download | clang-9124a4b7f4e310c9f4aa305f42ce48fd352eaaf3.tar.gz clang-9124a4b7f4e310c9f4aa305f42ce48fd352eaaf3.tar.bz2 clang-9124a4b7f4e310c9f4aa305f42ce48fd352eaaf3.tar.xz | |
Fixing PR18430 by checking that the size of bitfields plus padding does not
grow into the following virtual base.
Differential Revision: http://llvm-reviews.chandlerc.com/D2560
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200359 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGRecordLayoutBuilder.cpp')
| -rw-r--r-- | lib/CodeGen/CGRecordLayoutBuilder.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp index a1cc2aec50..3c1e7431eb 100644 --- a/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -344,7 +344,12 @@ bool CGRecordLayoutBuilder::LayoutBitfields(const ASTRecordLayout &Layout, // maximum latitude the language provides, and rely on the backend to lower // these in conjunction with shifts and masks to narrower operations where // beneficial. - uint64_t EndOffset = Types.getContext().toBits(Layout.getDataSize()); + uint64_t EndOffset; + if (Types.getContext().getLangOpts().CPlusPlus) + // Do not grow the bitfield storage into the following virtual base. + EndOffset = Types.getContext().toBits(Layout.getNonVirtualSize()); + else + EndOffset = Types.getContext().toBits(Layout.getDataSize()); if (BFE != FE) // If there are more fields to be laid out, the offset at the end of the // bitfield is the offset of the next field in the record. |
