AppendBitField really can never fail, so return its return value.
Everyone knows that no bugs are ever possible with bitfields.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107620 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp
index d4c3877..f8e91c2 100644
--- a/lib/CodeGen/CGExprConstant.cpp
+++ b/lib/CodeGen/CGExprConstant.cpp
@@ -52,8 +52,8 @@
bool AppendField(const FieldDecl *Field, uint64_t FieldOffset,
llvm::Constant *InitExpr);
- bool AppendBitField(const FieldDecl *Field, uint64_t FieldOffset,
- llvm::Constant *InitExpr);
+ void AppendBitField(const FieldDecl *Field, uint64_t FieldOffset,
+ llvm::ConstantInt *InitExpr);
void AppendPadding(uint64_t NumBytes);
@@ -123,14 +123,9 @@
return true;
}
-bool ConstStructBuilder::
- AppendBitField(const FieldDecl *Field, uint64_t FieldOffset,
- llvm::Constant *InitCst) {
- llvm::ConstantInt *CI = cast_or_null<llvm::ConstantInt>(InitCst);
- // FIXME: Can this ever happen?
- if (!CI)
- return false;
-
+void ConstStructBuilder::AppendBitField(const FieldDecl *Field,
+ uint64_t FieldOffset,
+ llvm::ConstantInt *CI) {
if (FieldOffset > NextFieldOffsetInBytes * 8) {
// We need to add padding.
uint64_t NumBytes =
@@ -204,7 +199,7 @@
Elements.back() = llvm::ConstantInt::get(CGM.getLLVMContext(), Tmp);
if (FitsCompletelyInPreviousByte)
- return true;
+ return;
}
while (FieldValue.getBitWidth() > 8) {
@@ -248,7 +243,6 @@
Elements.push_back(llvm::ConstantInt::get(CGM.getLLVMContext(),
FieldValue));
NextFieldOffsetInBytes++;
- return true;
}
void ConstStructBuilder::AppendPadding(uint64_t NumBytes) {
@@ -346,8 +340,8 @@
return false;
} else {
// Otherwise we have a bitfield.
- if (!AppendBitField(*Field, Layout.getFieldOffset(FieldNo), EltInit))
- return false;
+ AppendBitField(*Field, Layout.getFieldOffset(FieldNo),
+ cast<llvm::ConstantInt>(EltInit));
}
}