summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB/Raw/NameHashTable.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-05-06 20:51:57 +0000
committerZachary Turner <zturner@google.com>2016-05-06 20:51:57 +0000
commit819e77d196f208cc8ef15b4186e07ecb14a115c8 (patch)
tree409e2ff42a99563c75759c4c22116c35eb60569c /llvm/lib/DebugInfo/PDB/Raw/NameHashTable.cpp
parent091fcfa3a7632b6bbfbefdac84e0425d827d288c (diff)
downloadbcm5719-llvm-819e77d196f208cc8ef15b4186e07ecb14a115c8.tar.gz
bcm5719-llvm-819e77d196f208cc8ef15b4186e07ecb14a115c8.zip
Port DebugInfoPDB over to using llvm::Error.
Differential Revision: http://reviews.llvm.org/D19940 Reviewed By: rnk llvm-svn: 268791
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Raw/NameHashTable.cpp')
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/NameHashTable.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/NameHashTable.cpp b/llvm/lib/DebugInfo/PDB/Raw/NameHashTable.cpp
index 1a468c436d8..2ecb02d1412 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/NameHashTable.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/NameHashTable.cpp
@@ -11,6 +11,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/DebugInfo/PDB/Raw/ByteStream.h"
+#include "llvm/DebugInfo/PDB/Raw/RawError.h"
#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
#include "llvm/Support/Endian.h"
@@ -18,9 +19,6 @@ using namespace llvm;
using namespace llvm::support;
using namespace llvm::pdb;
-typedef uint32_t *PUL;
-typedef uint16_t *PUS;
-
static inline uint32_t HashStringV1(StringRef Str) {
uint32_t Result = 0;
uint32_t Size = Str.size();
@@ -80,7 +78,7 @@ static inline uint32_t HashStringV2(StringRef Str) {
NameHashTable::NameHashTable() : Signature(0), HashVersion(0), NameCount(0) {}
-std::error_code NameHashTable::load(StreamReader &Stream) {
+Error NameHashTable::load(StreamReader &Stream) {
struct Header {
support::ulittle32_t Signature;
support::ulittle32_t HashVersion;
@@ -88,27 +86,39 @@ std::error_code NameHashTable::load(StreamReader &Stream) {
};
Header H;
- Stream.readObject(&H);
+ if (auto EC = Stream.readObject(&H))
+ return EC;
+
if (H.Signature != 0xEFFEEFFE)
- return std::make_error_code(std::errc::illegal_byte_sequence);
+ return make_error<RawError>(raw_error_code::corrupt_file,
+ "Invalid hash table signature");
if (H.HashVersion != 1 && H.HashVersion != 2)
- return std::make_error_code(std::errc::not_supported);
+ return make_error<RawError>(raw_error_code::corrupt_file,
+ "Unsupported hash version");
Signature = H.Signature;
HashVersion = H.HashVersion;
- NamesBuffer.initialize(Stream, H.ByteSize);
+ if (auto EC = NamesBuffer.initialize(Stream, H.ByteSize))
+ return make_error<RawError>(raw_error_code::corrupt_file,
+ "Invalid hash table byte length");
support::ulittle32_t HashCount;
- Stream.readObject(&HashCount);
+ if (auto EC = Stream.readObject(&HashCount))
+ return EC;
+
std::vector<support::ulittle32_t> BucketArray(HashCount);
- Stream.readArray<support::ulittle32_t>(BucketArray);
+ if (auto EC = Stream.readArray<support::ulittle32_t>(BucketArray))
+ return make_error<RawError>(raw_error_code::corrupt_file,
+ "Could not read bucket array");
IDs.assign(BucketArray.begin(), BucketArray.end());
if (Stream.bytesRemaining() < sizeof(support::ulittle32_t))
- return std::make_error_code(std::errc::illegal_byte_sequence);
+ return make_error<RawError>(raw_error_code::corrupt_file,
+ "Missing name count");
- Stream.readInteger(NameCount);
- return std::error_code();
+ if (auto EC = Stream.readInteger(NameCount))
+ return EC;
+ return Error::success();
}
StringRef NameHashTable::getStringForID(uint32_t ID) const {
OpenPOWER on IntegriCloud