diff options
author | Warren Hunt <whunt@google.com> | 2013-11-01 23:59:41 +0000 |
---|---|---|
committer | Warren Hunt <whunt@google.com> | 2013-11-01 23:59:41 +0000 |
commit | 5ae586ad459617f6266ceb4aa7ccf132b73f65fd (patch) | |
tree | 45f565c044a4d6a4064befafc1b51d8dd7c27ac5 /clang/lib/AST/ASTContext.cpp | |
parent | 365bd0c88cb36f5d92bca3b396fbb0fbe36bc44a (diff) | |
download | bcm5719-llvm-5ae586ad459617f6266ceb4aa7ccf132b73f65fd.tar.gz bcm5719-llvm-5ae586ad459617f6266ceb4aa7ccf132b73f65fd.zip |
Improves compatibility with cl.exe when laying out array fields
Differential Revision: http://llvm-reviews.chandlerc.com/D2090
Clang was "improperly" over-aligning arrays with sizes are not a multiple of
their alignment.
This behavior was removed in microsoft 32 bit mode.
In addition, after examination of ASTContext::getTypeInfoImpl, a redundant code block in
MicrosoftRecordLayoutBuilder::getAdjustedFieldInfo was deleted.
llvm-svn: 193898
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 88e1d04ddf8..2ed345aec8d 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1387,7 +1387,9 @@ static getConstantArrayInfoInChars(const ASTContext &Context, "Overflow in array type char size evaluation"); uint64_t Width = EltInfo.first.getQuantity() * Size; unsigned Align = EltInfo.second.getQuantity(); - Width = llvm::RoundUpToAlignment(Width, Align); + if (!Context.getTargetInfo().getCXXABI().isMicrosoft() || + Context.getTargetInfo().getPointerWidth(0) == 64) + Width = llvm::RoundUpToAlignment(Width, Align); return std::make_pair(CharUnits::fromQuantity(Width), CharUnits::fromQuantity(Align)); } @@ -1460,7 +1462,9 @@ ASTContext::getTypeInfoImpl(const Type *T) const { "Overflow in array type bit size evaluation"); Width = EltInfo.first*Size; Align = EltInfo.second; - Width = llvm::RoundUpToAlignment(Width, Align); + if (!getTargetInfo().getCXXABI().isMicrosoft() || + getTargetInfo().getPointerWidth(0) == 64) + Width = llvm::RoundUpToAlignment(Width, Align); break; } case Type::ExtVector: |