}
// Use the externally-supplied field offset.
- return ExternalFieldOffset;\r
-}\r
-\r
-/// \brief Get diagnostic %select index for tag kind for\r
-/// field padding diagnostic message.\r
-/// WARNING: Indexes apply to particular diagnostics only!\r
-///\r
-/// \returns diagnostic %select index.\r
-static unsigned getPaddingDiagFromTagKind(TagTypeKind Tag)\r
-{\r
- switch (Tag) {\r
- case TTK_Struct: return 0;\r
- case TTK_Interface: return 1;\r
- case TTK_Class: return 2;\r
- default: assert("Invalid tag kind for field padding diagnostic!");\r
- }\r
- return -1;\r
-}\r
-\r
-void RecordLayoutBuilder::CheckFieldPadding(uint64_t Offset,\r
- uint64_t UnpaddedOffset,\r
- uint64_t UnpackedOffset,\r
+ return ExternalFieldOffset;
+}
+
+/// \brief Get diagnostic %select index for tag kind for
+/// field padding diagnostic message.
+/// WARNING: Indexes apply to particular diagnostics only!
+///
+/// \returns diagnostic %select index.
+static unsigned getPaddingDiagFromTagKind(TagTypeKind Tag) {
+ switch (Tag) {
+ case TTK_Struct: return 0;
+ case TTK_Interface: return 1;
+ case TTK_Class: return 2;
+ default: llvm_unreachable("Invalid tag kind for field padding diagnostic!");
+ }
+}
+
+void RecordLayoutBuilder::CheckFieldPadding(uint64_t Offset,
+ uint64_t UnpaddedOffset,
+ uint64_t UnpackedOffset,
unsigned UnpackedAlign,
bool isPacked,
const FieldDecl *D) {
if (PadSize % CharBitNum == 0) {
PadSize = PadSize / CharBitNum;
InBits = false;
- }\r
- if (D->getIdentifier())\r
- Diag(D->getLocation(), diag::warn_padded_struct_field)\r
- << getPaddingDiagFromTagKind(D->getParent()->getTagKind())\r
- << Context.getTypeDeclType(D->getParent())\r
- << PadSize\r
- << (InBits ? 1 : 0) /*(byte|bit)*/ << (PadSize > 1) // plural or not\r
- << D->getIdentifier();\r
- else\r
- Diag(D->getLocation(), diag::warn_padded_struct_anon_field)\r
- << getPaddingDiagFromTagKind(D->getParent()->getTagKind())\r
- << Context.getTypeDeclType(D->getParent())\r
- << PadSize\r
- << (InBits ? 1 : 0) /*(byte|bit)*/ << (PadSize > 1); // plural or not\r
+ }
+ if (D->getIdentifier())
+ Diag(D->getLocation(), diag::warn_padded_struct_field)
+ << getPaddingDiagFromTagKind(D->getParent()->getTagKind())
+ << Context.getTypeDeclType(D->getParent())
+ << PadSize
+ << (InBits ? 1 : 0) /*(byte|bit)*/ << (PadSize > 1) // plural or not
+ << D->getIdentifier();
+ else
+ Diag(D->getLocation(), diag::warn_padded_struct_anon_field)
+ << getPaddingDiagFromTagKind(D->getParent()->getTagKind())
+ << Context.getTypeDeclType(D->getParent())
+ << PadSize
+ << (InBits ? 1 : 0) /*(byte|bit)*/ << (PadSize > 1); // plural or not
}
// Warn if we packed it unnecessarily. If the alignment is 1 byte don't