Index: lib/DebugInfo/PDB/DIA/DIADataStream.cpp =================================================================== --- lib/DebugInfo/PDB/DIA/DIADataStream.cpp +++ lib/DebugInfo/PDB/DIA/DIADataStream.cpp @@ -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 @@ } std::string DIADataStream::getName() const { - CComBSTR Name16; - if (S_OK != StreamData->get_name(&Name16)) - return std::string(); - - std::string Name8; - llvm::ArrayRef Name16Bytes(reinterpret_cast(Name16.m_str), - Name16.ByteLength()); - if (!llvm::convertUTF16ToUTF8String(Name16Bytes, Name8)) - return std::string(); - return Name8; + return invokeBstrMethod(*StreamData, &IDiaEnumDebugStreamData::get_name); } llvm::Optional Index: lib/DebugInfo/PDB/DIA/DIAEnumTables.cpp =================================================================== --- lib/DebugInfo/PDB/DIA/DIAEnumTables.cpp +++ lib/DebugInfo/PDB/DIA/DIAEnumTables.cpp @@ -13,9 +13,8 @@ using namespace llvm; using namespace llvm::pdb; -DIAEnumTables::DIAEnumTables( - CComPtr DiaEnumerator) - : Enumerator(DiaEnumerator) {} +DIAEnumTables::DIAEnumTables(CComPtr DiaEnumerator) + : Enumerator(DiaEnumerator) {} uint32_t DIAEnumTables::getChildCount() const { LONG Count = 0; Index: lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp =================================================================== --- lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp +++ lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp @@ -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 @@ 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(Result16.m_str); - llvm::ArrayRef SrcByteArray(SrcBytes, Result16.ByteLength()); - std::string Result8; - if (!llvm::convertUTF16ToUTF8String(SrcByteArray, Result8)) - return std::string(); - return Result8; + return invokeBstrMethod(*Symbol, Method); } codeview::GUID Index: lib/DebugInfo/PDB/DIA/DIASourceFile.cpp =================================================================== --- lib/DebugInfo/PDB/DIA/DIASourceFile.cpp +++ lib/DebugInfo/PDB/DIA/DIASourceFile.cpp @@ -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 @@ : 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 FileNameBytes(reinterpret_cast(FileName16.m_str), - FileName16.ByteLength()); - llvm::convertUTF16ToUTF8String(FileNameBytes, FileName8); - return FileName8; + return invokeBstrMethod(*SourceFile, &IDiaSourceFile::get_fileName); } uint32_t DIASourceFile::getUniqueId() const { Index: lib/DebugInfo/PDB/DIA/DIATable.cpp =================================================================== --- lib/DebugInfo/PDB/DIA/DIATable.cpp +++ lib/DebugInfo/PDB/DIA/DIATable.cpp @@ -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 DiaTable) - : Table(DiaTable) {} +DIATable::DIATable(CComPtr DiaTable) : Table(DiaTable) {} uint32_t DIATable::getItemCount() const { LONG Count = 0; @@ -23,16 +21,7 @@ } std::string DIATable::getName() const { - CComBSTR Name16; - if (S_OK != Table->get_name(&Name16)) - return std::string(); - - std::string Name8; - llvm::ArrayRef Name16Bytes(reinterpret_cast(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 {