// FIXME : Use SmallVector
uint64_t llvmSize = 0;
std::vector<const llvm::Type*> LLVMFields;
- bool packedStruct = false;
int NumMembers = RD.getNumMembers();
for (int curField = 0; curField < NumMembers; curField++) {
const FieldDecl *FD = RD.getMember(curField);
uint64_t offset = RL.getFieldOffset(curField);
const llvm::Type *Ty = CGT.ConvertTypeRecursive(FD->getType());
- uint64_t size = CGT.getTargetData().getABITypeSize(Ty) * 8;
+ uint64_t size = CGT.getTargetData().getTypeStoreSizeInBits(Ty);
if (FD->isBitField()) {
Expr *BitWidth = FD->getBitWidth();
llvmSize += 8;
}
- unsigned Align = CGT.getTargetData().getABITypeAlignment(Ty) * 8;
- if (llvmSize % Align)
- packedStruct = true;
- else if (offset == 0 && RL.getAlignment() % Align)
- packedStruct = true;
-
llvmSize += size;
CGT.addFieldInfo(FD, LLVMFields.size());
LLVMFields.push_back(Ty);
llvmSize += 8;
}
- STy = llvm::StructType::get(LLVMFields, packedStruct);
+ STy = llvm::StructType::get(LLVMFields, true);
assert(CGT.getTargetData().getABITypeSizeInBits(STy) == RL.getSize());
}
-// RUN: clang < %s -emit-llvm > %t1
-// Run grep "STest1 = type { i32, \[4 x i16\], double }" %t1 &&
-// RUN: grep "STest2 = type { i16, i16, i32, i32 }" %t1 &&
-// RUN: grep "STest3 = type { i8, i8, i16, i32 }" %t1 &&
-// RUN: grep "STestB1 = type { i8, i8 }" %t1 &&
-// RUN: grep "STestB2 = type { i8, i8, i8 }" %t1 &&
-// RUN: grep "STestB3 = type { i8, i8 }" %t1 &&
-// RUN: grep "STestB4 = type { i8, i8, i8, i8 }" %t1
-// RUN: grep "STestB5 = type { i8, i8, i8, i8, i8, i8 }" %t1
-// RUN: grep "STestB6 = type { i8, i8, i8, i8 }" %t1
+// RUN: clang < %s -emit-llvm > %t1 -triple=i686-apple-darwin9
+// Run grep "STest1 = type <{ i32, \[4 x i16\], double }>" %t1 &&
+// RUN: grep "STest2 = type <{ i16, i16, i32, i32 }>" %t1 &&
+// RUN: grep "STest3 = type <{ i8, i8, i16, i32 }>" %t1 &&
+// RUN: grep "STestB1 = type <{ i8, i8 }>" %t1 &&
+// RUN: grep "STestB2 = type <{ i8, i8, i8 }>" %t1 &&
+// RUN: grep "STestB3 = type <{ i8, i8 }>" %t1 &&
+// RUN: grep "STestB4 = type <{ i8, i8, i8, i8 }>" %t1
+// RUN: grep "STestB5 = type <{ i8, i8, i8, i8, i8, i8 }>" %t1
+// RUN: grep "STestB6 = type <{ i8, i8, i8, i8 }>" %t1
// Test struct layout for x86-darwin target
-// FIXME : Enable this test for x86-darwin only. At the moment clang hard codes
-// x86-darwin as the target
struct STest1 {int x; short y[4]; double z; } st1;
struct STest2 {short a,b; int c,d; } st2;