[all-commits] [llvm/llvm-project] 9cf8f8: Fix _BitInt suffix width calculation

Aaron Ballman via All-commits all-commits at lists.llvm.org
Tue Mar 22 07:01:04 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9cf8f81ca45de198013f29442a7de6600b226d70
      https://github.com/llvm/llvm-project/commit/9cf8f81ca45de198013f29442a7de6600b226d70
  Author: Aaron Ballman <aaron at aaronballman.com>
  Date:   2022-03-22 (Tue, 22 Mar 2022)

  Changed paths:
    M clang/lib/Sema/SemaExpr.cpp
    M clang/test/Lexer/bitint-constants.c

  Log Message:
  -----------
  Fix _BitInt suffix width calculation

@mgehre-amd pointed out the following post-commit review feedback on
the changes in 8cba72177dcd8de5d37177dbaf2347e5c1f0f1e8:

As an example, the paper says 3wb /* Yields an _BitInt(3); two value
bits, one sign bit */.
So I would expect that 0xFwb gives _BitInt(5); four value bits, one
sign bit, but with this implementation I get _BitInt(2).
This is because ResultVal as 4 bits, and getMinSignedBits() inteprets
it as negative and thus says that 1 bit is enough to represent -1.

This corrects the behavior for calculating the bit-width and adds some
test coverage.




More information about the All-commits mailing list