diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-10 18:28:20 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-10 18:28:20 +0000 |
commit | a6b8b2c09610b8bc4330e948ece8b940c2386406 (patch) | |
tree | f59c822c4be1f7a73f2e536222e27fe1fe35c04d /lib/CodeGen/CGRecordLayoutBuilder.cpp | |
parent | fcdd2cb2fdf35f806dd800b369fe0772a1c8c26c (diff) |
Constant expression evaluation refactoring:
- Remodel Expr::EvaluateAsInt to behave like the other EvaluateAs* functions,
and add Expr::EvaluateKnownConstInt to capture the current fold-or-assert
behaviour.
- Factor out evaluation of bitfield bit widths.
- Fix a few places which would evaluate an expression twice: once to determine
whether it is a constant expression, then again to get the value.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141561 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGRecordLayoutBuilder.cpp')
-rw-r--r-- | lib/CodeGen/CGRecordLayoutBuilder.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp index d55ea5171a..6475ccac03 100644 --- a/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -363,8 +363,7 @@ CGBitFieldInfo CGBitFieldInfo::MakeInfo(CodeGenTypes &Types, void CGRecordLayoutBuilder::LayoutBitField(const FieldDecl *D, uint64_t fieldOffset) { - uint64_t fieldSize = - D->getBitWidth()->EvaluateAsInt(Types.getContext()).getZExtValue(); + uint64_t fieldSize = D->getBitWidthValue(Types.getContext()); if (fieldSize == 0) return; @@ -492,8 +491,7 @@ llvm::Type * CGRecordLayoutBuilder::LayoutUnionField(const FieldDecl *Field, const ASTRecordLayout &Layout) { if (Field->isBitField()) { - uint64_t FieldSize = - Field->getBitWidth()->EvaluateAsInt(Types.getContext()).getZExtValue(); + uint64_t FieldSize = Field->getBitWidthValue(Types.getContext()); // Ignore zero sized bit fields. if (FieldSize == 0) |