1d6a81614SMichael Ilseman //===- PostOrderIteratorTest.cpp - PostOrderIterator unit tests -----------===// 2d6a81614SMichael Ilseman // 3d6a81614SMichael Ilseman // The LLVM Compiler Infrastructure 4d6a81614SMichael Ilseman // 5d6a81614SMichael Ilseman // This file is distributed under the University of Illinois Open Source 6d6a81614SMichael Ilseman // License. See LICENSE.TXT for details. 7d6a81614SMichael Ilseman // 8d6a81614SMichael Ilseman //===----------------------------------------------------------------------===// 9d6a81614SMichael Ilseman #include "llvm/ADT/PostOrderIterator.h" 10d6a81614SMichael Ilseman #include "llvm/IR/BasicBlock.h" 11d6a81614SMichael Ilseman #include "llvm/IR/CFG.h" 12*9a67b073SChandler Carruth #include "gtest/gtest.h" 13d6a81614SMichael Ilseman using namespace llvm; 14d6a81614SMichael Ilseman 15d6a81614SMichael Ilseman namespace { 16d6a81614SMichael Ilseman 17d6a81614SMichael Ilseman // Whether we're able to compile 18d6a81614SMichael Ilseman TEST(PostOrderIteratorTest, Compiles) { 19d6a81614SMichael Ilseman typedef SmallPtrSet<void *, 4> ExtSetTy; 20d6a81614SMichael Ilseman 21d6a81614SMichael Ilseman // Tests that template specializations are kept up to date 22d6a81614SMichael Ilseman void *Null = nullptr; 23d6a81614SMichael Ilseman po_iterator_storage<std::set<void *>, false> PIS; 24e0793db4STim Shen PIS.insertEdge(Optional<void *>(), Null); 25d6a81614SMichael Ilseman ExtSetTy Ext; 26d6a81614SMichael Ilseman po_iterator_storage<ExtSetTy, true> PISExt(Ext); 27e0793db4STim Shen PIS.insertEdge(Optional<void *>(), Null); 28d6a81614SMichael Ilseman 29d6a81614SMichael Ilseman // Test above, but going through po_iterator (which inherits from template 30d6a81614SMichael Ilseman // base) 31d6a81614SMichael Ilseman BasicBlock *NullBB = nullptr; 32d6a81614SMichael Ilseman auto PI = po_end(NullBB); 33e0793db4STim Shen PI.insertEdge(Optional<BasicBlock *>(), NullBB); 34d6a81614SMichael Ilseman auto PIExt = po_ext_end(NullBB, Ext); 35e0793db4STim Shen PIExt.insertEdge(Optional<BasicBlock *>(), NullBB); 36d6a81614SMichael Ilseman } 37d6a81614SMichael Ilseman } 38