From d6d113268daec774e6dfd7f2833ea4fd62dbe386 Mon Sep 17 00:00:00 2001 From: Patrick Wildt Date: Tue, 14 Mar 2017 08:08:16 +0000 Subject: Import LLVM 4.0.0 release including clang and lld. --- .../CodeGen/MachineInstrBundleIteratorTest.cpp | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'gnu/llvm/unittests/CodeGen') diff --git a/gnu/llvm/unittests/CodeGen/MachineInstrBundleIteratorTest.cpp b/gnu/llvm/unittests/CodeGen/MachineInstrBundleIteratorTest.cpp index 416f5774f4c..8f15fbf3941 100644 --- a/gnu/llvm/unittests/CodeGen/MachineInstrBundleIteratorTest.cpp +++ b/gnu/llvm/unittests/CodeGen/MachineInstrBundleIteratorTest.cpp @@ -130,4 +130,68 @@ TEST(MachineInstrBundleIteratorTest, CompareToBundledMI) { ASSERT_TRUE(CI != CMBI.getIterator()); } +struct MyUnbundledInstr + : ilist_node> { + bool isBundledWithPred() const { return false; } + bool isBundledWithSucc() const { return false; } +}; +typedef MachineInstrBundleIterator unbundled_iterator; +typedef MachineInstrBundleIterator + const_unbundled_iterator; +typedef MachineInstrBundleIterator + reverse_unbundled_iterator; +typedef MachineInstrBundleIterator + const_reverse_unbundled_iterator; + +TEST(MachineInstrBundleIteratorTest, ReverseConstructor) { + simple_ilist> L; + const auto &CL = L; + MyUnbundledInstr A, B; + L.insert(L.end(), A); + L.insert(L.end(), B); + + // Save typing. + typedef MachineInstrBundleIterator iterator; + typedef MachineInstrBundleIterator reverse_iterator; + typedef MachineInstrBundleIterator const_iterator; + typedef MachineInstrBundleIterator + const_reverse_iterator; + + // Convert to bundle iterators. + auto begin = [&]() -> iterator { return L.begin(); }; + auto end = [&]() -> iterator { return L.end(); }; + auto rbegin = [&]() -> reverse_iterator { return L.rbegin(); }; + auto rend = [&]() -> reverse_iterator { return L.rend(); }; + auto cbegin = [&]() -> const_iterator { return CL.begin(); }; + auto cend = [&]() -> const_iterator { return CL.end(); }; + auto crbegin = [&]() -> const_reverse_iterator { return CL.rbegin(); }; + auto crend = [&]() -> const_reverse_iterator { return CL.rend(); }; + + // Check conversion values. + EXPECT_EQ(begin(), iterator(rend())); + EXPECT_EQ(++begin(), iterator(++rbegin())); + EXPECT_EQ(end(), iterator(rbegin())); + EXPECT_EQ(rbegin(), reverse_iterator(end())); + EXPECT_EQ(++rbegin(), reverse_iterator(++begin())); + EXPECT_EQ(rend(), reverse_iterator(begin())); + + // Check const iterator constructors. + EXPECT_EQ(cbegin(), const_iterator(rend())); + EXPECT_EQ(cbegin(), const_iterator(crend())); + EXPECT_EQ(crbegin(), const_reverse_iterator(end())); + EXPECT_EQ(crbegin(), const_reverse_iterator(cend())); + + // Confirm lack of implicit conversions. + static_assert(!std::is_convertible::value, + "unexpected implicit conversion"); + static_assert(!std::is_convertible::value, + "unexpected implicit conversion"); + static_assert( + !std::is_convertible::value, + "unexpected implicit conversion"); + static_assert( + !std::is_convertible::value, + "unexpected implicit conversion"); +} + } // end namespace -- cgit v1.2.3