diff options
-rw-r--r-- | lib/AST/RecordLayoutBuilder.cpp | 70 |
1 files changed, 34 insertions, 36 deletions
diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp index 043e46e9d6..fba23fb468 100644 --- a/lib/AST/RecordLayoutBuilder.cpp +++ b/lib/AST/RecordLayoutBuilder.cpp @@ -2260,28 +2260,26 @@ RecordLayoutBuilder::updateExternalFieldOffset(const FieldDecl *Field, } // Use the externally-supplied field offset. - 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: assert("Invalid tag kind for field padding diagnostic!");
- }
- return -1;
-}
-
-void RecordLayoutBuilder::CheckFieldPadding(uint64_t Offset,
- uint64_t UnpaddedOffset,
- uint64_t UnpackedOffset,
+ 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) { @@ -2304,20 +2302,20 @@ void RecordLayoutBuilder::CheckFieldPadding(uint64_t Offset, if (PadSize % CharBitNum == 0) { PadSize = PadSize / CharBitNum; InBits = false; - }
- 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
+ } + 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 |