llvm/llvm/unittests/CodeGen/MachineInstrBundleIteratorTest.cpp

//===- MachineInstrBundleIteratorTest.cpp ---------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "llvm/CodeGen/MachineInstrBundleIterator.h"
#include "llvm/ADT/ilist_node.h"
#include "gtest/gtest.h"

usingnamespacellvm;

namespace {

struct MyBundledInstr
    : public ilist_node<MyBundledInstr, ilist_sentinel_tracking<true>> {};
bundled_iterator;
const_bundled_iterator;
reverse_bundled_iterator;
const_reverse_bundled_iterator;

#ifdef GTEST_HAS_DEATH_TEST
#ifndef NDEBUG
TEST(MachineInstrBundleIteratorTest, CheckForBundles) {
  MyBundledInstr MBI;
  auto I = MBI.getIterator();
  auto RI = I.getReverse();

  // Confirm that MBI is always considered bundled.
  EXPECT_TRUE(MBI.isBundledWithPred());
  EXPECT_TRUE(MBI.isBundledWithSucc());

  // Confirm that iterators check in their constructor for bundled iterators.
  EXPECT_DEATH((void)static_cast<bundled_iterator>(I),
               "not legal to initialize");
  EXPECT_DEATH((void)static_cast<bundled_iterator>(MBI),
               "not legal to initialize");
  EXPECT_DEATH((void)static_cast<bundled_iterator>(&MBI),
               "not legal to initialize");
  EXPECT_DEATH((void)static_cast<const_bundled_iterator>(I),
               "not legal to initialize");
  EXPECT_DEATH((void)static_cast<const_bundled_iterator>(MBI),
               "not legal to initialize");
  EXPECT_DEATH((void)static_cast<const_bundled_iterator>(&MBI),
               "not legal to initialize");
  EXPECT_DEATH((void)static_cast<reverse_bundled_iterator>(RI),
               "not legal to initialize");
  EXPECT_DEATH((void)static_cast<reverse_bundled_iterator>(MBI),
               "not legal to initialize");
  EXPECT_DEATH((void)static_cast<reverse_bundled_iterator>(&MBI),
               "not legal to initialize");
  EXPECT_DEATH((void)static_cast<const_reverse_bundled_iterator>(RI),
               "not legal to initialize");
  EXPECT_DEATH((void)static_cast<const_reverse_bundled_iterator>(MBI),
               "not legal to initialize");
  EXPECT_DEATH((void)static_cast<const_reverse_bundled_iterator>(&MBI),
               "not legal to initialize");
}
#endif
#endif

TEST(MachineInstrBundleIteratorTest, CompareToBundledMI) {}

struct MyUnbundledInstr
    : ilist_node<MyUnbundledInstr, ilist_sentinel_tracking<true>> {};
unbundled_iterator;
const_unbundled_iterator;
reverse_unbundled_iterator;
const_reverse_unbundled_iterator;

TEST(MachineInstrBundleIteratorTest, ReverseConstructor) {}

} // end namespace