[llvm] r296640 - [PDB] Remove use of std error codes.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 1 09:02:42 PST 2017
Author: zturner
Date: Wed Mar 1 11:02:41 2017
New Revision: 296640
URL: http://llvm.org/viewvc/llvm-project?rev=296640&view=rev
Log:
[PDB] Remove use of std error codes.
I already created a BinaryStreamError class for this purpose,
so update the code to use that on the remaining occurrences
of errc values.
This should also address the issue which led to r296583.
Modified:
llvm/trunk/unittests/DebugInfo/PDB/BinaryStreamTest.cpp
Modified: llvm/trunk/unittests/DebugInfo/PDB/BinaryStreamTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/PDB/BinaryStreamTest.cpp?rev=296640&r1=296639&r2=296640&view=diff
==============================================================================
--- llvm/trunk/unittests/DebugInfo/PDB/BinaryStreamTest.cpp (original)
+++ llvm/trunk/unittests/DebugInfo/PDB/BinaryStreamTest.cpp Wed Mar 1 11:02:41 2017
@@ -13,7 +13,6 @@
#include "llvm/DebugInfo/MSF/BinaryStreamReader.h"
#include "llvm/DebugInfo/MSF/BinaryStreamRef.h"
#include "llvm/DebugInfo/MSF/BinaryStreamWriter.h"
-#include "llvm/Support/Errc.h"
#include "gtest/gtest.h"
#include <unordered_map>
@@ -56,8 +55,8 @@ public:
Error readBytes(uint32_t Offset, uint32_t Size,
ArrayRef<uint8_t> &Buffer) override {
- if (Offset + Size > Data.size())
- return errorCodeToError(make_error_code(llvm::errc::function_not_supported));
+ if (auto EC = checkOffset(Offset, Size))
+ return EC;
uint32_t S = startIndex(Offset);
auto Ref = Data.drop_front(S);
if (Ref.size() >= Size) {
@@ -75,8 +74,8 @@ public:
Error readLongestContiguousChunk(uint32_t Offset,
ArrayRef<uint8_t> &Buffer) override {
- if (Offset >= Data.size())
- return errorCodeToError(make_error_code(llvm::errc::function_not_supported));
+ if (auto EC = checkOffset(Offset, 1))
+ return EC;
uint32_t S = startIndex(Offset);
Buffer = Data.drop_front(S);
return Error::success();
@@ -85,8 +84,8 @@ public:
uint32_t getLength() override { return Data.size(); }
Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> SrcData) override {
- if (Offset + SrcData.size() > Data.size())
- return errorCodeToError(make_error_code(llvm::errc::function_not_supported));
+ if (auto EC = checkOffset(Offset, SrcData.size()))
+ return EC;
if (SrcData.empty())
return Error::success();
More information about the llvm-commits
mailing list