• 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 namespace pdb {
19 
20 template <typename ChildType>
21 class ConcreteSymbolEnumerator : public IPDBEnumChildren<ChildType> {
22 public:
ConcreteSymbolEnumerator(std::unique_ptr<IPDBEnumSymbols> SymbolEnumerator)23   ConcreteSymbolEnumerator(std::unique_ptr<IPDBEnumSymbols> SymbolEnumerator)
24       : Enumerator(std::move(SymbolEnumerator)) {}
25 
~ConcreteSymbolEnumerator()26   ~ConcreteSymbolEnumerator() override {}
27 
getChildCount()28   uint32_t getChildCount() const override {
29     return Enumerator->getChildCount();
30   }
31 
getChildAtIndex(uint32_t Index)32   std::unique_ptr<ChildType> getChildAtIndex(uint32_t Index) const override {
33     std::unique_ptr<PDBSymbol> Child = Enumerator->getChildAtIndex(Index);
34     return make_concrete_child(std::move(Child));
35   }
36 
getNext()37   std::unique_ptr<ChildType> getNext() override {
38     std::unique_ptr<PDBSymbol> Child = Enumerator->getNext();
39     return make_concrete_child(std::move(Child));
40   }
41 
reset()42   void reset() override { Enumerator->reset(); }
43 
clone()44   ConcreteSymbolEnumerator<ChildType> *clone() const override {
45     std::unique_ptr<IPDBEnumSymbols> WrappedClone(Enumerator->clone());
46     return new ConcreteSymbolEnumerator<ChildType>(std::move(WrappedClone));
47   }
48 
49 private:
50   std::unique_ptr<ChildType>
make_concrete_child(std::unique_ptr<PDBSymbol> Child)51   make_concrete_child(std::unique_ptr<PDBSymbol> Child) const {
52     ChildType *ConcreteChild = dyn_cast_or_null<ChildType>(Child.release());
53     return std::unique_ptr<ChildType>(ConcreteChild);
54   }
55 
56   std::unique_ptr<IPDBEnumSymbols> Enumerator;
57 };
58 }
59 }
60 
61 #endif
62