summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorYunzhong Gao <Yunzhong_Gao@playstation.sony.com>2014-01-29 00:09:16 +0000
committerYunzhong Gao <Yunzhong_Gao@playstation.sony.com>2014-01-29 00:09:16 +0000
commiteeeb8dafedf4ea6d0882d5e07291d8124582397e (patch)
tree1b11726151f296e9df24fb800862f87d7950ef58 /clang/lib/CodeGen
parent1625245b6838b50009ae50ed7d373a2e7ce0076c (diff)
downloadbcm5719-llvm-eeeb8dafedf4ea6d0882d5e07291d8124582397e.tar.gz
bcm5719-llvm-eeeb8dafedf4ea6d0882d5e07291d8124582397e.zip
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 llvm-svn: 200359
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGRecordLayoutBuilder.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
index a1cc2aec506..3c1e7431eb6 100644
--- a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ b/clang/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.
OpenPOWER on IntegriCloud