summaryrefslogtreecommitdiff
path: root/lib/DebugInfo/PDB/PDB.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/DebugInfo/PDB/PDB.cpp')
-rw-r--r--lib/DebugInfo/PDB/PDB.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/DebugInfo/PDB/PDB.cpp b/lib/DebugInfo/PDB/PDB.cpp
index 501d4f5985b7..40f5ae9ba845 100644
--- a/lib/DebugInfo/PDB/PDB.cpp
+++ b/lib/DebugInfo/PDB/PDB.cpp
@@ -16,6 +16,7 @@
#endif
#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/MemoryBuffer.h"
using namespace llvm;
using namespace llvm::pdb;
@@ -23,8 +24,15 @@ using namespace llvm::pdb;
Error llvm::pdb::loadDataForPDB(PDB_ReaderType Type, StringRef Path,
std::unique_ptr<IPDBSession> &Session) {
// Create the correct concrete instance type based on the value of Type.
- if (Type == PDB_ReaderType::Native)
- return NativeSession::createFromPdb(Path, Session);
+ if (Type == PDB_ReaderType::Native) {
+ ErrorOr<std::unique_ptr<MemoryBuffer>> ErrorOrBuffer =
+ MemoryBuffer::getFileOrSTDIN(Path, /*FileSize=*/-1,
+ /*RequiresNullTerminator=*/false);
+ if (!ErrorOrBuffer)
+ return make_error<GenericError>(generic_error_code::invalid_path, Path);
+
+ return NativeSession::createFromPdb(std::move(*ErrorOrBuffer), Session);
+ }
#if LLVM_ENABLE_DIA_SDK
return DIASession::createFromPdb(Path, Session);