blob: 8e53247fc2f6f7403974bab514cecde01f8b4ecd [file] [log] [blame]
Michael Ilsemand6a81612014-11-20 19:33:33 +00001//===- PostOrderIteratorTest.cpp - PostOrderIterator unit tests -----------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Michael Ilsemand6a81612014-11-20 19:33:33 +00006//
7//===----------------------------------------------------------------------===//
Michael Ilsemand6a81612014-11-20 19:33:33 +00008#include "llvm/ADT/PostOrderIterator.h"
9#include "llvm/IR/BasicBlock.h"
10#include "llvm/IR/CFG.h"
Chandler Carruth9a67b072017-06-06 11:06:56 +000011#include "gtest/gtest.h"
Michael Ilsemand6a81612014-11-20 19:33:33 +000012using namespace llvm;
13
14namespace {
15
16// Whether we're able to compile
17TEST(PostOrderIteratorTest, Compiles) {
18 typedef SmallPtrSet<void *, 4> ExtSetTy;
19
20 // Tests that template specializations are kept up to date
21 void *Null = nullptr;
22 po_iterator_storage<std::set<void *>, false> PIS;
Tim Shene0793db2016-08-15 21:52:54 +000023 PIS.insertEdge(Optional<void *>(), Null);
Michael Ilsemand6a81612014-11-20 19:33:33 +000024 ExtSetTy Ext;
25 po_iterator_storage<ExtSetTy, true> PISExt(Ext);
Tim Shene0793db2016-08-15 21:52:54 +000026 PIS.insertEdge(Optional<void *>(), Null);
Michael Ilsemand6a81612014-11-20 19:33:33 +000027
28 // Test above, but going through po_iterator (which inherits from template
29 // base)
30 BasicBlock *NullBB = nullptr;
31 auto PI = po_end(NullBB);
Tim Shene0793db2016-08-15 21:52:54 +000032 PI.insertEdge(Optional<BasicBlock *>(), NullBB);
Michael Ilsemand6a81612014-11-20 19:33:33 +000033 auto PIExt = po_ext_end(NullBB, Ext);
Tim Shene0793db2016-08-15 21:52:54 +000034 PIExt.insertEdge(Optional<BasicBlock *>(), NullBB);
Michael Ilsemand6a81612014-11-20 19:33:33 +000035}
36}