Skip to content
Snippets Groups Projects
Commit 6532e427 authored by Chris Lattner's avatar Chris Lattner
Browse files

* Fix divide by zero error with empty structs

* Empty structs should have ALIGNMENT 1, not SIZE 1.

llvm-svn: 6263
parent 2a651d7a
No related branches found
No related tags found
No related merge requests found
......@@ -56,15 +56,13 @@ StructLayout::StructLayout(const StructType *ST, const TargetData &TD)
StructSize += TySize; // Consume space for this data item
}
// Empty structures have alignment of 1 byte.
if (StructAlignment == 0) StructAlignment = 1;
// Add padding to the end of the struct so that it could be put in an array
// and all array elements would be aligned correctly.
if (StructSize % StructAlignment != 0)
StructSize = (StructSize/StructAlignment + 1) * StructAlignment;
if (StructSize == 0) {
StructSize = 1; // Empty struct is 1 byte
StructAlignment = 1;
}
}
Annotation *TargetData::TypeAnFactory(AnnotationID AID, const Annotable *T,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment