summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/RecordLayoutBuilder.cpp
diff options
context:
space:
mode:
authorWarren Hunt <whunt@google.com>2013-12-26 22:09:12 +0000
committerWarren Hunt <whunt@google.com>2013-12-26 22:09:12 +0000
commit50de3522e699b23dee10bb8d1ef962c27b56f026 (patch)
tree5e159c6d00c409b30c82ad097c53d45b2bfe1b7d /clang/lib/AST/RecordLayoutBuilder.cpp
parentf4355eef5e415b84f6456d86c608146560773962 (diff)
downloadbcm5719-llvm-50de3522e699b23dee10bb8d1ef962c27b56f026.tar.gz
bcm5719-llvm-50de3522e699b23dee10bb8d1ef962c27b56f026.zip
[ms-abi] Fixes improperly sized vfptrs with pragma pack
With pragma pack, the layout engine would produce vfptrs that were packed width rather than pointer width. This patch addresses the issue and adds a test case. llvm-svn: 198059
Diffstat (limited to 'clang/lib/AST/RecordLayoutBuilder.cpp')
-rw-r--r--clang/lib/AST/RecordLayoutBuilder.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp
index 74010ce7aa0..832bfef90c9 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2316,15 +2316,14 @@ void MicrosoftRecordLayoutBuilder::layoutVFPtr(const CXXRecordDecl *RD) {
if (!HasExtendableVFPtr)
return;
+ updateAlignment(PointerAlignment);
+ Size = Size.RoundUpToAlignment(PointerAlignment) + PointerSize;
// MSVC 32 (but not 64) potentially over-aligns the vf-table pointer by giving
// it the max alignment of all the non-virtual data in the class. The
// resulting layout is essentially { vftbl, { nvdata } }. This is completely
// unnecessary, but we're not here to pass judgment.
- updateAlignment(PointerAlignment);
- if (Is64BitMode)
- Size = Size.RoundUpToAlignment(PointerAlignment) + PointerSize;
- else
- Size = Size.RoundUpToAlignment(PointerAlignment) + Alignment;
+ if (!Is64BitMode && Alignment > PointerSize)
+ Size += Alignment - PointerSize;
}
void
OpenPOWER on IntegriCloud