diff options
author | Chris Lattner <sabre@nondot.org> | 2010-07-05 17:04:23 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-07-05 17:04:23 +0000 |
commit | 1880666c13b909f858ddec9c2a7784c5a0c04041 (patch) | |
tree | f3779a873fa8263f964df86b7c605d62ad3e44cb /lib/CodeGen/CGExprConstant.cpp | |
parent | c8f9af2943699ff623ca08f2e5ed4d72e0351189 (diff) |
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
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index d4c387796f..f8e91c2272 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -52,8 +52,8 @@ private: 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 @@ AppendField(const FieldDecl *Field, uint64_t FieldOffset, 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 @@ bool ConstStructBuilder:: Elements.back() = llvm::ConstantInt::get(CGM.getLLVMContext(), Tmp); if (FitsCompletelyInPreviousByte) - return true; + return; } while (FieldValue.getBitWidth() > 8) { @@ -248,7 +243,6 @@ bool ConstStructBuilder:: Elements.push_back(llvm::ConstantInt::get(CGM.getLLVMContext(), FieldValue)); NextFieldOffsetInBytes++; - return true; } void ConstStructBuilder::AppendPadding(uint64_t NumBytes) { @@ -346,8 +340,8 @@ bool ConstStructBuilder::Build(InitListExpr *ILE) { 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)); } } |