From 7aaa167abba495ecb0e99eb4f2fa155cf28c798d Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 31 Aug 2012 22:14:25 +0000 Subject: [PATCH] Remove windows line endings. While there fix a dead assert. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163031 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/RecordLayoutBuilder.cpp | 70 ++++++++++++++++----------------- 1 file 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 -- 2.40.0