[PATCH] D59712: [APSInt][OpenMP] Fix isNegative, etc. for unsigned types
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 16 13:27:05 PDT 2019
lebedev.ri marked an inline comment as done.
lebedev.ri added inline comments.
================
Comment at: llvm/unittests/ADT/APSIntTest.cpp:162
+TEST(APSIntTest, UnsignedHighBit) {
+ APSInt False(APInt(1, 0));
----------------
Can you please duplicate this whole test but for signed `APSInt`?
================
Comment at: llvm/unittests/ADT/APSIntTest.cpp:188-194
+ EXPECT_FALSE(CharBoundaryUnder.isNegative());
+ EXPECT_TRUE(CharBoundaryUnder.isNonNegative());
+ EXPECT_TRUE(CharBoundaryUnder.isStrictlyPositive());
+
+ EXPECT_FALSE(CharBoundaryOver.isNegative());
+ EXPECT_TRUE(CharBoundaryOver.isNonNegative());
+ EXPECT_TRUE(CharBoundaryOver.isStrictlyPositive());
----------------
jdenny wrote:
> lebedev.ri wrote:
> > I do not understand.
> > `0x7f` is 127, it is obviously a maximal positive 8-bit value.
> > but `0x80` is 128 aka -128, is it not minimal negative 8-bit value?
> > Is the test correct?
> This test checks that unsigned types are never seen as negative, so it's checking values that would be negative if the type were signed.
Ooh, i see. I was looking at the wrong constructor.
```
explicit APSInt(APInt I, bool isUnsigned = true)
: APInt(std::move(I)), IsUnsigned(isUnsigned) {}
```
was the one being called.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59712/new/
https://reviews.llvm.org/D59712
More information about the llvm-commits
mailing list