diff options
| author | Diego Novillo <dnovillo@google.com> | 2015-05-01 17:59:15 +0000 |
|---|---|---|
| committer | Diego Novillo <dnovillo@google.com> | 2015-05-01 17:59:15 +0000 |
| commit | a7b5c5b5841eaed39e0ca918a75877da6f0404b6 (patch) | |
| tree | acbc5d26826ebb058eeb5c80497100792354e284 /llvm/unittests/Support/ScaledNumberTest.cpp | |
| parent | a3abd6da8be1659b5c4b697a1fa87f0ec36d56a7 (diff) | |
| download | llvm-a7b5c5b5841eaed39e0ca918a75877da6f0404b6.zip llvm-a7b5c5b5841eaed39e0ca918a75877da6f0404b6.tar.gz llvm-a7b5c5b5841eaed39e0ca918a75877da6f0404b6.tar.bz2 | |
Fix infinite recursion in ScaledNumber::toInt.
Patch from dexonsmith. The call to toInt() was calling compareTo() which
in some cases would call back to toInt(), creating an infinite loop.
Fixed by simplifying the logic in compareTo() to avoid the co-recursion.
llvm-svn: 236326
Diffstat (limited to 'llvm/unittests/Support/ScaledNumberTest.cpp')
| -rw-r--r-- | llvm/unittests/Support/ScaledNumberTest.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/unittests/Support/ScaledNumberTest.cpp b/llvm/unittests/Support/ScaledNumberTest.cpp index 3872155..2f38b2a 100644 --- a/llvm/unittests/Support/ScaledNumberTest.cpp +++ b/llvm/unittests/Support/ScaledNumberTest.cpp @@ -556,4 +556,9 @@ TEST(ScaledNumberHelpersTest, arithmeticOperators) { EXPECT_EQ(ScaledNumber<uint64_t>(1, 4), ScaledNumber<uint64_t>(1, 3) << 1); } +TEST(ScaledNumberHelpersTest, toIntBug) { + ScaledNumber<uint32_t> n(1, 0); + EXPECT_EQ(1u, (n * n).toInt<uint32_t>()); +} + } // end namespace |
