Michael Ilseman | d6a8161 | 2014-11-20 19:33:33 +0000 | [diff] [blame] | 1 | //===- PostOrderIteratorTest.cpp - PostOrderIterator unit tests -----------===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Michael Ilseman | d6a8161 | 2014-11-20 19:33:33 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
Michael Ilseman | d6a8161 | 2014-11-20 19:33:33 +0000 | [diff] [blame] | 8 | #include "llvm/ADT/PostOrderIterator.h" |
| 9 | #include "llvm/IR/BasicBlock.h" |
| 10 | #include "llvm/IR/CFG.h" |
Chandler Carruth | 9a67b07 | 2017-06-06 11:06:56 +0000 | [diff] [blame] | 11 | #include "gtest/gtest.h" |
Michael Ilseman | d6a8161 | 2014-11-20 19:33:33 +0000 | [diff] [blame] | 12 | using namespace llvm; |
| 13 | |
| 14 | namespace { |
| 15 | |
| 16 | // Whether we're able to compile |
| 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; |
Tim Shen | e0793db | 2016-08-15 21:52:54 +0000 | [diff] [blame] | 23 | PIS.insertEdge(Optional<void *>(), Null); |
Michael Ilseman | d6a8161 | 2014-11-20 19:33:33 +0000 | [diff] [blame] | 24 | ExtSetTy Ext; |
| 25 | po_iterator_storage<ExtSetTy, true> PISExt(Ext); |
Tim Shen | e0793db | 2016-08-15 21:52:54 +0000 | [diff] [blame] | 26 | PIS.insertEdge(Optional<void *>(), Null); |
Michael Ilseman | d6a8161 | 2014-11-20 19:33:33 +0000 | [diff] [blame] | 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); |
Tim Shen | e0793db | 2016-08-15 21:52:54 +0000 | [diff] [blame] | 32 | PI.insertEdge(Optional<BasicBlock *>(), NullBB); |
Michael Ilseman | d6a8161 | 2014-11-20 19:33:33 +0000 | [diff] [blame] | 33 | auto PIExt = po_ext_end(NullBB, Ext); |
Tim Shen | e0793db | 2016-08-15 21:52:54 +0000 | [diff] [blame] | 34 | PIExt.insertEdge(Optional<BasicBlock *>(), NullBB); |
Michael Ilseman | d6a8161 | 2014-11-20 19:33:33 +0000 | [diff] [blame] | 35 | } |
| 36 | } |