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