1d6a81614SMichael Ilseman //===- PostOrderIteratorTest.cpp - PostOrderIterator unit tests -----------===//
2d6a81614SMichael Ilseman //
3*2946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*2946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
5*2946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6d6a81614SMichael Ilseman //
7d6a81614SMichael Ilseman //===----------------------------------------------------------------------===//
8d6a81614SMichael Ilseman #include "llvm/ADT/PostOrderIterator.h"
9d6a81614SMichael Ilseman #include "llvm/IR/BasicBlock.h"
10d6a81614SMichael Ilseman #include "llvm/IR/CFG.h"
119a67b073SChandler Carruth #include "gtest/gtest.h"
12d6a81614SMichael Ilseman using namespace llvm;
13d6a81614SMichael Ilseman 
14d6a81614SMichael Ilseman namespace {
15d6a81614SMichael Ilseman 
16d6a81614SMichael Ilseman // Whether we're able to compile
17d6a81614SMichael Ilseman TEST(PostOrderIteratorTest, Compiles) {
18d6a81614SMichael Ilseman   typedef SmallPtrSet<void *, 4> ExtSetTy;
19d6a81614SMichael Ilseman 
20d6a81614SMichael Ilseman   // Tests that template specializations are kept up to date
21d6a81614SMichael Ilseman   void *Null = nullptr;
22d6a81614SMichael Ilseman   po_iterator_storage<std::set<void *>, false> PIS;
23e0793db4STim Shen   PIS.insertEdge(Optional<void *>(), Null);
24d6a81614SMichael Ilseman   ExtSetTy Ext;
25d6a81614SMichael Ilseman   po_iterator_storage<ExtSetTy, true> PISExt(Ext);
26e0793db4STim Shen   PIS.insertEdge(Optional<void *>(), Null);
27d6a81614SMichael Ilseman 
28d6a81614SMichael Ilseman   // Test above, but going through po_iterator (which inherits from template
29d6a81614SMichael Ilseman   // base)
30d6a81614SMichael Ilseman   BasicBlock *NullBB = nullptr;
31d6a81614SMichael Ilseman   auto PI = po_end(NullBB);
32e0793db4STim Shen   PI.insertEdge(Optional<BasicBlock *>(), NullBB);
33d6a81614SMichael Ilseman   auto PIExt = po_ext_end(NullBB, Ext);
34e0793db4STim Shen   PIExt.insertEdge(Optional<BasicBlock *>(), NullBB);
35d6a81614SMichael Ilseman }
36d6a81614SMichael Ilseman }
37