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