6eee2ffe3fa15457e190942e85513b1c2f6da666
[oota-llvm.git] / lib / DebugInfo / PDB / PDBSymbolTypeVTable.cpp
1 //===- PDBSymbolTypeVTable.cpp - --------------------------------*- 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 #include <utility>
11
12 #include "llvm/DebugInfo/PDB/IPDBSession.h"
13 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
14 #include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
15 #include "llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h"
16 #include "llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h"
17
18 using namespace llvm;
19
20 PDBSymbolTypeVTable::PDBSymbolTypeVTable(const IPDBSession &PDBSession,
21                                          std::unique_ptr<IPDBRawSymbol> Symbol)
22     : PDBSymbol(PDBSession, std::move(Symbol)) {}
23
24 void PDBSymbolTypeVTable::dump(raw_ostream &OS, int Indent,
25                                PDB_DumpLevel Level) const {
26   OS << stream_indent(Indent);
27   uint32_t ClassId = getClassParentId();
28   if (auto ClassParent = Session.getSymbolById(ClassId)) {
29     ClassParent->dump(OS, 0, PDB_DumpLevel::Compact);
30     OS << "::";
31   }
32   OS << "<vtbl> ";
33   if (auto VtblPointer =
34           Session.getConcreteSymbolById<PDBSymbolTypePointer>(getTypeId())) {
35     if (auto VtblShape =
36             Session.getConcreteSymbolById<PDBSymbolTypeVTableShape>(
37                 VtblPointer->getTypeId()))
38       OS << "(" << VtblShape->getCount() << " entries)";
39   }
40   OS.flush();
41 }