1 //===- PostOrderIteratorTest.cpp - PostOrderIterator unit tests -----------===//
2 //
3 // 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
6 //
7 //===----------------------------------------------------------------------===//
8 #include "llvm/ADT/PostOrderIterator.h"
9 #include "llvm/IR/BasicBlock.h"
10 #include "llvm/IR/CFG.h"
11 #include "gtest/gtest.h"
12 using namespace llvm;
13
14 namespace {
15
16 // Whether we're able to compile
TEST(PostOrderIteratorTest,Compiles)17 TEST(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;
23 PIS.insertEdge(Optional<void *>(), Null);
24 ExtSetTy Ext;
25 po_iterator_storage<ExtSetTy, true> PISExt(Ext);
26 PIS.insertEdge(Optional<void *>(), Null);
27
28 // Test above, but going through po_iterator (which inherits from template
29 // base)
30 BasicBlock *NullBB = nullptr;
31 auto PI = po_end(NullBB);
32 PI.insertEdge(Optional<BasicBlock *>(), NullBB);
33 auto PIExt = po_ext_end(NullBB, Ext);
34 PIExt.insertEdge(Optional<BasicBlock *>(), NullBB);
35 }
36 }
37