1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

[pdb] Simplify the code by replacing a few string conversions with calls to invokeBstrMethod()

Reviewers: aleksandr.urakov, zturner, llvm-commits

Reviewed By: zturner

Differential Revision: https://reviews.llvm.org/D52624

llvm-svn: 343291
This commit is contained in:
Aaron Smith 2018-09-28 02:32:07 +00:00
parent 857477a1f4
commit f88f846bf9
5 changed files with 11 additions and 51 deletions

View File

@ -8,8 +8,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/PDB/DIA/DIADataStream.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/DebugInfo/PDB/DIA/DIAUtils.h"
using namespace llvm;
using namespace llvm::pdb;
@ -23,16 +22,7 @@ uint32_t DIADataStream::getRecordCount() const {
}
std::string DIADataStream::getName() const {
CComBSTR Name16;
if (S_OK != StreamData->get_name(&Name16))
return std::string();
std::string Name8;
llvm::ArrayRef<char> Name16Bytes(reinterpret_cast<char *>(Name16.m_str),
Name16.ByteLength());
if (!llvm::convertUTF16ToUTF8String(Name16Bytes, Name8))
return std::string();
return Name8;
return invokeBstrMethod(*StreamData, &IDiaEnumDebugStreamData::get_name);
}
llvm::Optional<DIADataStream::RecordType>

View File

@ -13,9 +13,8 @@
using namespace llvm;
using namespace llvm::pdb;
DIAEnumTables::DIAEnumTables(
CComPtr<IDiaEnumTables> DiaEnumerator)
: Enumerator(DiaEnumerator) {}
DIAEnumTables::DIAEnumTables(CComPtr<IDiaEnumTables> DiaEnumerator)
: Enumerator(DiaEnumerator) {}
uint32_t DIAEnumTables::getChildCount() const {
LONG Count = 0;

View File

@ -15,6 +15,7 @@
#include "llvm/DebugInfo/PDB/DIA/DIAEnumSymbols.h"
#include "llvm/DebugInfo/PDB/DIA/DIALineNumber.h"
#include "llvm/DebugInfo/PDB/DIA/DIASession.h"
#include "llvm/DebugInfo/PDB/DIA/DIAUtils.h"
#include "llvm/DebugInfo/PDB/PDBExtras.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
@ -115,16 +116,7 @@ RetType PrivateGetDIAValue(IDiaSymbol *Symbol,
std::string
PrivateGetDIAValue(IDiaSymbol *Symbol,
HRESULT (__stdcall IDiaSymbol::*Method)(BSTR *)) {
CComBSTR Result16;
if (S_OK != (Symbol->*Method)(&Result16))
return std::string();
const char *SrcBytes = reinterpret_cast<const char *>(Result16.m_str);
llvm::ArrayRef<char> SrcByteArray(SrcBytes, Result16.ByteLength());
std::string Result8;
if (!llvm::convertUTF16ToUTF8String(SrcByteArray, Result8))
return std::string();
return Result8;
return invokeBstrMethod(*Symbol, Method);
}
codeview::GUID

View File

@ -8,12 +8,11 @@
//===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/PDB/DIA/DIASourceFile.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h"
#include "llvm/DebugInfo/PDB/DIA/DIAEnumSymbols.h"
#include "llvm/DebugInfo/PDB/DIA/DIASession.h"
#include "llvm/DebugInfo/PDB/DIA/DIAUtils.h"
#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
#include "llvm/Support/ConvertUTF.h"
using namespace llvm;
using namespace llvm::pdb;
@ -23,16 +22,7 @@ DIASourceFile::DIASourceFile(const DIASession &PDBSession,
: Session(PDBSession), SourceFile(DiaSourceFile) {}
std::string DIASourceFile::getFileName() const {
CComBSTR FileName16;
HRESULT Result = SourceFile->get_fileName(&FileName16);
if (S_OK != Result)
return std::string();
std::string FileName8;
llvm::ArrayRef<char> FileNameBytes(reinterpret_cast<char *>(FileName16.m_str),
FileName16.ByteLength());
llvm::convertUTF16ToUTF8String(FileNameBytes, FileName8);
return FileName8;
return invokeBstrMethod(*SourceFile, &IDiaSourceFile::get_fileName);
}
uint32_t DIASourceFile::getUniqueId() const {

View File

@ -8,14 +8,12 @@
//===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/PDB/DIA/DIATable.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/DebugInfo/PDB/DIA/DIAUtils.h"
using namespace llvm;
using namespace llvm::pdb;
DIATable::DIATable(CComPtr<IDiaTable> DiaTable)
: Table(DiaTable) {}
DIATable::DIATable(CComPtr<IDiaTable> DiaTable) : Table(DiaTable) {}
uint32_t DIATable::getItemCount() const {
LONG Count = 0;
@ -23,16 +21,7 @@ uint32_t DIATable::getItemCount() const {
}
std::string DIATable::getName() const {
CComBSTR Name16;
if (S_OK != Table->get_name(&Name16))
return std::string();
std::string Name8;
llvm::ArrayRef<char> Name16Bytes(reinterpret_cast<char *>(Name16.m_str),
Name16.ByteLength());
if (!llvm::convertUTF16ToUTF8String(Name16Bytes, Name8))
return std::string();
return Name8;
return invokeBstrMethod(*Table, &IDiaTable::get_name);
}
PDB_TableType DIATable::getTableType() const {