summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Smith <aaron.smith@microsoft.com>2018-09-28 02:32:07 +0000
committerAaron Smith <aaron.smith@microsoft.com>2018-09-28 02:32:07 +0000
commite956a994c2c32ab21d548e685dc1a155ecff8bc3 (patch)
tree494d7c4a46dd33e7a1654dfb45a8e149c7701c35
parent18b8d4e7a52ef2b088d9fd45f87d3bb43cc5147f (diff)
[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
-rw-r--r--llvm/lib/DebugInfo/PDB/DIA/DIADataStream.cpp14
-rw-r--r--llvm/lib/DebugInfo/PDB/DIA/DIAEnumTables.cpp5
-rw-r--r--llvm/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp12
-rw-r--r--llvm/lib/DebugInfo/PDB/DIA/DIASourceFile.cpp14
-rw-r--r--llvm/lib/DebugInfo/PDB/DIA/DIATable.cpp17
5 files changed, 11 insertions, 51 deletions
diff --git a/llvm/lib/DebugInfo/PDB/DIA/DIADataStream.cpp b/llvm/lib/DebugInfo/PDB/DIA/DIADataStream.cpp
index 5c095eac53b..6a10513fad9 100644
--- a/llvm/lib/DebugInfo/PDB/DIA/DIADataStream.cpp
+++ b/llvm/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 @@ 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>
diff --git a/llvm/lib/DebugInfo/PDB/DIA/DIAEnumTables.cpp b/llvm/lib/DebugInfo/PDB/DIA/DIAEnumTables.cpp
index f0f0241bf14..6fa096156d4 100644
--- a/llvm/lib/DebugInfo/PDB/DIA/DIAEnumTables.cpp
+++ b/llvm/lib/DebugInfo/PDB/DIA/DIAEnumTables.cpp
@@ -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;
diff --git a/llvm/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp b/llvm/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp
index 5fa783d7134..cd4d00a13b1 100644
--- a/llvm/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp
+++ b/llvm/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 @@ 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
diff --git a/llvm/lib/DebugInfo/PDB/DIA/DIASourceFile.cpp b/llvm/lib/DebugInfo/PDB/DIA/DIASourceFile.cpp
index 8605f55b402..d3e408166a8 100644
--- a/llvm/lib/DebugInfo/PDB/DIA/DIASourceFile.cpp
+++ b/llvm/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 @@ 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 {
diff --git a/llvm/lib/DebugInfo/PDB/DIA/DIATable.cpp b/llvm/lib/DebugInfo/PDB/DIA/DIATable.cpp
index 5705c2370dc..6017081b2cb 100644
--- a/llvm/lib/DebugInfo/PDB/DIA/DIATable.cpp
+++ b/llvm/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<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 {