Change the way clang generates union types a bit so it plays well

with the LLVM C backend.

llvm-svn: 65615
This commit is contained in:
Eli Friedman 2009-02-27 04:53:40 +00:00
parent 8d03f59479
commit 8f5f4ea466
1 changed files with 6 additions and 1 deletions

View File

@ -555,6 +555,11 @@ void RecordOrganizer::layoutUnionFields(const ASTRecordLayout &RL) {
// of the result doesn't matter because anyone allocating // of the result doesn't matter because anyone allocating
// structures should be aligning them appropriately anyway. // structures should be aligning them appropriately anyway.
// FIXME: We can be a bit more intuitive in a lot of cases. // FIXME: We can be a bit more intuitive in a lot of cases.
STy = llvm::ArrayType::get(llvm::Type::Int8Ty, RL.getSize() / 8); // FIXME: Make this a struct type to work around PR2399; the
// C backend doesn't like structs using array types.
std::vector<const llvm::Type*> LLVMFields;
LLVMFields.push_back(llvm::ArrayType::get(llvm::Type::Int8Ty,
RL.getSize() / 8));
STy = llvm::StructType::get(LLVMFields, true);
assert(CGT.getTargetData().getTypePaddedSizeInBits(STy) == RL.getSize()); assert(CGT.getTargetData().getTypePaddedSizeInBits(STy) == RL.getSize());
} }