• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- ConcreteSymbolEnumerator.h -------------------------------*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_DEBUGINFO_PDB_CONCRETESYMBOLENUMERATOR_H
11 #define LLVM_DEBUGINFO_PDB_CONCRETESYMBOLENUMERATOR_H
12 
13 #include "IPDBEnumChildren.h"
14 #include "llvm/Support/Casting.h"
15 #include <memory>
16 
17 namespace llvm {
18 
19 template <typename ChildType>
20 class ConcreteSymbolEnumerator : public IPDBEnumChildren<ChildType> {
21 public:
ConcreteSymbolEnumerator(std::unique_ptr<IPDBEnumSymbols> SymbolEnumerator)22   ConcreteSymbolEnumerator(std::unique_ptr<IPDBEnumSymbols> SymbolEnumerator)
23       : Enumerator(std::move(SymbolEnumerator)) {}
24 
~ConcreteSymbolEnumerator()25   ~ConcreteSymbolEnumerator() override {}
26 
getChildCount()27   uint32_t getChildCount() const override {
28     return Enumerator->getChildCount();
29   }
30 
getChildAtIndex(uint32_t Index)31   std::unique_ptr<ChildType> getChildAtIndex(uint32_t Index) const override {
32     std::unique_ptr<PDBSymbol> Child = Enumerator->getChildAtIndex(Index);
33     return make_concrete_child(std::move(Child));
34   }
35 
getNext()36   std::unique_ptr<ChildType> getNext() override {
37     std::unique_ptr<PDBSymbol> Child = Enumerator->getNext();
38     return make_concrete_child(std::move(Child));
39   }
40 
reset()41   void reset() override { Enumerator->reset(); }
42 
clone()43   ConcreteSymbolEnumerator<ChildType> *clone() const override {
44     std::unique_ptr<IPDBEnumSymbols> WrappedClone(Enumerator->clone());
45     return new ConcreteSymbolEnumerator<ChildType>(std::move(WrappedClone));
46   }
47 
48 private:
49   std::unique_ptr<ChildType>
make_concrete_child(std::unique_ptr<PDBSymbol> Child)50   make_concrete_child(std::unique_ptr<PDBSymbol> Child) const {
51     ChildType *ConcreteChild = dyn_cast_or_null<ChildType>(Child.release());
52     return std::unique_ptr<ChildType>(ConcreteChild);
53   }
54 
55   std::unique_ptr<IPDBEnumSymbols> Enumerator;
56 };
57 }
58 
59 #endif
60