summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/RecordLayoutBuilder.cpp
diff options
context:
space:
mode:
authorWarren Hunt <whunt@google.com>2013-11-01 23:59:41 +0000
committerWarren Hunt <whunt@google.com>2013-11-01 23:59:41 +0000
commit5ae586ad459617f6266ceb4aa7ccf132b73f65fd (patch)
tree45f565c044a4d6a4064befafc1b51d8dd7c27ac5 /clang/lib/AST/RecordLayoutBuilder.cpp
parent365bd0c88cb36f5d92bca3b396fbb0fbe36bc44a (diff)
downloadbcm5719-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/RecordLayoutBuilder.cpp')
-rw-r--r--clang/lib/AST/RecordLayoutBuilder.cpp22
1 files changed, 3 insertions, 19 deletions
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp
index fb35343a477..87d00bc9f5d 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2140,23 +2140,8 @@ public:
std::pair<CharUnits, CharUnits>
MicrosoftRecordLayoutBuilder::getAdjustedFieldInfo(const FieldDecl *FD) {
- std::pair<CharUnits, CharUnits> FieldInfo;
- if (FD->getType()->isIncompleteArrayType()) {
- // This is a flexible array member; we can't directly
- // query getTypeInfo about these, so we figure it out here.
- // Flexible array members don't have any size, but they
- // have to be aligned appropriately for their element type.
- FieldInfo.first = CharUnits::Zero();
- const ArrayType *ATy = Context.getAsArrayType(FD->getType());
- FieldInfo.second = Context.getTypeAlignInChars(ATy->getElementType());
- } else if (const ReferenceType *RT = FD->getType()->getAs<ReferenceType>()) {
- unsigned AS = RT->getPointeeType().getAddressSpace();
- FieldInfo.first = Context
- .toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(AS));
- FieldInfo.second = Context
- .toCharUnitsFromBits(Context.getTargetInfo().getPointerAlign(AS));
- } else
- FieldInfo = Context.getTypeInfoInChars(FD->getType());
+ std::pair<CharUnits, CharUnits> FieldInfo =
+ Context.getTypeInfoInChars(FD->getType());
// If we're not on win32 and using ms_struct the field alignment will be wrong
// for 64 bit types, so we fix that here.
@@ -2187,8 +2172,7 @@ MicrosoftRecordLayoutBuilder::getAdjustedFieldInfo(const FieldDecl *FD) {
void MicrosoftRecordLayoutBuilder::initializeLayout(const RecordDecl *RD) {
IsUnion = RD->isUnion();
- Is64BitMode = RD->getASTContext().getTargetInfo().getTriple().getArch() ==
- llvm::Triple::x86_64;
+ Is64BitMode = Context.getTargetInfo().getPointerWidth(0) == 64;
Size = CharUnits::Zero();
Alignment = CharUnits::One();
OpenPOWER on IntegriCloud