Skip to content

Commit 08eae4d

Browse files
committed
[PDB][NativeSession] Use better error code for invalid format
Replaces the default "Success" std::error_code with a more meaningful one.
1 parent 35ffe10 commit 08eae4d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,12 @@ loadPdbFile(StringRef PdbPath, std::unique_ptr<BumpPtrAllocator> &Allocator) {
9999
PdbPath = Buffer->getBufferIdentifier();
100100
file_magic Magic;
101101
auto EC = identify_magic(PdbPath, Magic);
102-
if (EC || Magic != file_magic::pdb)
102+
if (EC)
103103
return make_error<RawError>(EC);
104104

105+
if (Magic != file_magic::pdb)
106+
return make_error<RawError>(raw_error_code::invalid_format);
107+
105108
auto Stream = std::make_unique<MemoryBufferByteStream>(
106109
std::move(Buffer), llvm::endianness::little);
107110

@@ -154,9 +157,12 @@ Error NativeSession::createFromExe(StringRef ExePath,
154157

155158
file_magic Magic;
156159
auto EC = identify_magic(PdbPath.get(), Magic);
157-
if (EC || Magic != file_magic::pdb)
160+
if (EC)
158161
return make_error<RawError>(EC);
159162

163+
if (Magic != file_magic::pdb)
164+
return make_error<RawError>(raw_error_code::invalid_format);
165+
160166
auto Allocator = std::make_unique<BumpPtrAllocator>();
161167
auto File = loadPdbFile(PdbPath.get(), Allocator);
162168
if (!File)

0 commit comments

Comments
 (0)