10b57cec5SDimitry Andric //===- DIATable.cpp - DIA implementation of IPDBTable -----------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/DIA/DIATable.h"
100b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/DIA/DIAUtils.h"
110b57cec5SDimitry Andric 
120b57cec5SDimitry Andric using namespace llvm;
130b57cec5SDimitry Andric using namespace llvm::pdb;
140b57cec5SDimitry Andric 
DIATable(CComPtr<IDiaTable> DiaTable)150b57cec5SDimitry Andric DIATable::DIATable(CComPtr<IDiaTable> DiaTable) : Table(DiaTable) {}
160b57cec5SDimitry Andric 
getItemCount() const170b57cec5SDimitry Andric uint32_t DIATable::getItemCount() const {
180b57cec5SDimitry Andric   LONG Count = 0;
190b57cec5SDimitry Andric   return (S_OK == Table->get_Count(&Count)) ? Count : 0;
200b57cec5SDimitry Andric }
210b57cec5SDimitry Andric 
getName() const220b57cec5SDimitry Andric std::string DIATable::getName() const {
230b57cec5SDimitry Andric   return invokeBstrMethod(*Table, &IDiaTable::get_name);
240b57cec5SDimitry Andric }
250b57cec5SDimitry Andric 
getTableType() const260b57cec5SDimitry Andric PDB_TableType DIATable::getTableType() const {
270b57cec5SDimitry Andric   CComBSTR Name16;
280b57cec5SDimitry Andric   if (S_OK != Table->get_name(&Name16))
290b57cec5SDimitry Andric     return PDB_TableType::TableInvalid;
300b57cec5SDimitry Andric 
310b57cec5SDimitry Andric   if (Name16 == DiaTable_Symbols)
320b57cec5SDimitry Andric     return PDB_TableType::Symbols;
330b57cec5SDimitry Andric   if (Name16 == DiaTable_SrcFiles)
340b57cec5SDimitry Andric     return PDB_TableType::SourceFiles;
350b57cec5SDimitry Andric   if (Name16 == DiaTable_Sections)
360b57cec5SDimitry Andric     return PDB_TableType::SectionContribs;
370b57cec5SDimitry Andric   if (Name16 == DiaTable_LineNums)
380b57cec5SDimitry Andric     return PDB_TableType::LineNumbers;
390b57cec5SDimitry Andric   if (Name16 == DiaTable_SegMap)
400b57cec5SDimitry Andric     return PDB_TableType::Segments;
410b57cec5SDimitry Andric   if (Name16 == DiaTable_InjSrc)
420b57cec5SDimitry Andric     return PDB_TableType::InjectedSources;
430b57cec5SDimitry Andric   if (Name16 == DiaTable_FrameData)
440b57cec5SDimitry Andric     return PDB_TableType::FrameData;
450b57cec5SDimitry Andric   if (Name16 == DiaTable_InputAssemblyFiles)
460b57cec5SDimitry Andric     return PDB_TableType::InputAssemblyFiles;
470b57cec5SDimitry Andric   if (Name16 == DiaTable_Dbg)
480b57cec5SDimitry Andric     return PDB_TableType::Dbg;
490b57cec5SDimitry Andric   return PDB_TableType::TableInvalid;
500b57cec5SDimitry Andric }
51