Remove the last uses of 'using std::error_code'

This finishes the transition to std::error_code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210877 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2014-06-13 03:20:08 +00:00
parent 1ad45020ec
commit 250305156a
8 changed files with 72 additions and 78 deletions

View File

@ -31,7 +31,6 @@
#include <vector>
using namespace llvm;
using std::error_code;
// This variable is intentionally defined differently in the statically-compiled
// program from the IR input to the JIT to assert that the JIT doesn't use its
@ -634,7 +633,7 @@ ExecutionEngine *getJITFromBitcode(
MemoryBuffer *BitcodeBuffer =
MemoryBuffer::getMemBuffer(Bitcode, "Bitcode for test");
ErrorOr<Module*> ModuleOrErr = getLazyBitcodeModule(BitcodeBuffer, Context);
if (error_code EC = ModuleOrErr.getError()) {
if (std::error_code EC = ModuleOrErr.getError()) {
ADD_FAILURE() << EC.message();
delete BitcodeBuffer;
return nullptr;

View File

@ -16,14 +16,14 @@
using namespace llvm;
using namespace llvm::sys;
using std::error_code;
#define ASSERT_NO_ERROR(x) \
if (error_code ASSERT_NO_ERROR_ec = x) { \
errs() << #x ": did not return errc::success.\n" \
<< "error number: " << ASSERT_NO_ERROR_ec.value() << "\n" \
<< "error message: " << ASSERT_NO_ERROR_ec.message() << "\n"; \
} else {}
#define ASSERT_NO_ERROR(x) \
if (std::error_code ASSERT_NO_ERROR_ec = x) { \
errs() << #x ": did not return errc::success.\n" \
<< "error number: " << ASSERT_NO_ERROR_ec.value() << "\n" \
<< "error message: " << ASSERT_NO_ERROR_ec.message() << "\n"; \
} else { \
}
namespace {
TEST(FileOutputBuffer, Test) {

View File

@ -14,13 +14,12 @@
#include <memory>
using namespace llvm;
using std::error_code;
namespace {
TEST(LockFileManagerTest, Basic) {
SmallString<64> TmpDir;
error_code EC;
std::error_code EC;
EC = sys::fs::createUniqueDirectory("LockFileManagerTestDir", TmpDir);
ASSERT_FALSE(EC);
@ -47,7 +46,7 @@ TEST(LockFileManagerTest, Basic) {
TEST(LockFileManagerTest, LinkLockExists) {
SmallString<64> TmpDir;
error_code EC;
std::error_code EC;
EC = sys::fs::createUniqueDirectory("LockFileManagerTestDir", TmpDir);
ASSERT_FALSE(EC);
@ -90,7 +89,7 @@ TEST(LockFileManagerTest, LinkLockExists) {
TEST(LockFileManagerTest, RelativePath) {
SmallString<64> TmpDir;
error_code EC;
std::error_code EC;
EC = sys::fs::createUniqueDirectory("LockFileManagerTestDir", TmpDir);
ASSERT_FALSE(EC);

View File

@ -17,7 +17,6 @@
#include "gtest/gtest.h"
using namespace llvm;
using std::error_code;
namespace {
@ -79,7 +78,7 @@ TEST_F(MemoryBufferTest, NullTerminator4K) {
OF.close();
OwningBuffer MB;
error_code EC = MemoryBuffer::getFile(TestPath.c_str(), MB);
std::error_code EC = MemoryBuffer::getFile(TestPath.c_str(), MB);
ASSERT_FALSE(EC);
const char *BufData = MB->getBufferStart();
@ -148,10 +147,11 @@ void MemoryBufferTest::testGetOpenFileSlice(bool Reopen) {
}
OwningBuffer Buf;
error_code EC = MemoryBuffer::getOpenFileSlice(TestFD, TestPath.c_str(), Buf,
40000, // Size
80000 // Offset
);
std::error_code EC =
MemoryBuffer::getOpenFileSlice(TestFD, TestPath.c_str(), Buf,
40000, // Size
80000 // Offset
);
EXPECT_FALSE(EC);
StringRef BufData = Buf->getBuffer();

View File

@ -14,7 +14,6 @@
using namespace llvm;
using namespace sys;
using std::error_code;
namespace {
@ -58,9 +57,9 @@ protected:
};
TEST_P(MappedMemoryTest, AllocAndRelease) {
error_code EC;
std::error_code EC;
MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), nullptr, Flags,EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(sizeof(int), M1.size());
@ -69,13 +68,13 @@ TEST_P(MappedMemoryTest, AllocAndRelease) {
}
TEST_P(MappedMemoryTest, MultipleAllocAndRelease) {
error_code EC;
std::error_code EC;
MemoryBlock M1 = Memory::allocateMappedMemory(16, nullptr, Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
MemoryBlock M2 = Memory::allocateMappedMemory(64, nullptr, Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
MemoryBlock M3 = Memory::allocateMappedMemory(32, nullptr, Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(16U, M1.size());
@ -91,7 +90,7 @@ TEST_P(MappedMemoryTest, MultipleAllocAndRelease) {
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
EXPECT_FALSE(Memory::releaseMappedMemory(M3));
MemoryBlock M4 = Memory::allocateMappedMemory(16, nullptr, Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
EXPECT_NE((void*)nullptr, M4.base());
EXPECT_LE(16U, M4.size());
EXPECT_FALSE(Memory::releaseMappedMemory(M4));
@ -104,9 +103,9 @@ TEST_P(MappedMemoryTest, BasicWrite) {
!((Flags & Memory::MF_READ) && (Flags & Memory::MF_WRITE)))
return;
error_code EC;
std::error_code EC;
MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), nullptr, Flags,EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(sizeof(int), M1.size());
@ -123,16 +122,16 @@ TEST_P(MappedMemoryTest, MultipleWrite) {
if (Flags &&
!((Flags & Memory::MF_READ) && (Flags & Memory::MF_WRITE)))
return;
error_code EC;
std::error_code EC;
MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), nullptr, Flags,
EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), nullptr, Flags,
EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), nullptr, Flags,
EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
EXPECT_FALSE(doesOverlap(M1, M2));
EXPECT_FALSE(doesOverlap(M2, M3));
@ -165,7 +164,7 @@ TEST_P(MappedMemoryTest, MultipleWrite) {
MemoryBlock M4 = Memory::allocateMappedMemory(64 * sizeof(int), nullptr,
Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
EXPECT_NE((void*)nullptr, M4.base());
EXPECT_LE(64U * sizeof(int), M4.size());
x = (int*)M4.base();
@ -181,16 +180,16 @@ TEST_P(MappedMemoryTest, MultipleWrite) {
}
TEST_P(MappedMemoryTest, EnabledWrite) {
error_code EC;
std::error_code EC;
MemoryBlock M1 = Memory::allocateMappedMemory(2 * sizeof(int), nullptr, Flags,
EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), nullptr, Flags,
EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), nullptr, Flags,
EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(2U * sizeof(int), M1.size());
@ -225,10 +224,11 @@ TEST_P(MappedMemoryTest, EnabledWrite) {
EXPECT_EQ(6, y[6]);
MemoryBlock M4 = Memory::allocateMappedMemory(16, nullptr, Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
EXPECT_NE((void*)nullptr, M4.base());
EXPECT_LE(16U, M4.size());
EXPECT_EQ(error_code(), Memory::protectMappedMemory(M4, getTestableEquivalent(Flags)));
EXPECT_EQ(std::error_code(),
Memory::protectMappedMemory(M4, getTestableEquivalent(Flags)));
x = (int*)M4.base();
*x = 4;
EXPECT_EQ(4, *x);
@ -237,13 +237,13 @@ TEST_P(MappedMemoryTest, EnabledWrite) {
}
TEST_P(MappedMemoryTest, SuccessiveNear) {
error_code EC;
std::error_code EC;
MemoryBlock M1 = Memory::allocateMappedMemory(16, nullptr, Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
MemoryBlock M2 = Memory::allocateMappedMemory(64, &M1, Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
MemoryBlock M3 = Memory::allocateMappedMemory(32, &M2, Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(16U, M1.size());
@ -262,14 +262,14 @@ TEST_P(MappedMemoryTest, SuccessiveNear) {
}
TEST_P(MappedMemoryTest, DuplicateNear) {
error_code EC;
std::error_code EC;
MemoryBlock Near((void*)(3*PageSize), 16);
MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(16U, M1.size());
@ -284,14 +284,14 @@ TEST_P(MappedMemoryTest, DuplicateNear) {
}
TEST_P(MappedMemoryTest, ZeroNear) {
error_code EC;
std::error_code EC;
MemoryBlock Near(nullptr, 0);
MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(16U, M1.size());
@ -310,14 +310,14 @@ TEST_P(MappedMemoryTest, ZeroNear) {
}
TEST_P(MappedMemoryTest, ZeroSizeNear) {
error_code EC;
std::error_code EC;
MemoryBlock Near((void*)(4*PageSize), 0);
MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(16U, M1.size());
@ -336,10 +336,10 @@ TEST_P(MappedMemoryTest, ZeroSizeNear) {
}
TEST_P(MappedMemoryTest, UnalignedNear) {
error_code EC;
std::error_code EC;
MemoryBlock Near((void*)(2*PageSize+5), 0);
MemoryBlock M1 = Memory::allocateMappedMemory(15, &Near, Flags, EC);
EXPECT_EQ(error_code(), EC);
EXPECT_EQ(std::error_code(), EC);
EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(sizeof(int), M1.size());

View File

@ -20,17 +20,17 @@
using namespace llvm;
using namespace llvm::sys;
using std::error_code;
#define ASSERT_NO_ERROR(x) \
if (error_code ASSERT_NO_ERROR_ec = x) { \
SmallString<128> MessageStorage; \
raw_svector_ostream Message(MessageStorage); \
Message << #x ": did not return errc::success.\n" \
<< "error number: " << ASSERT_NO_ERROR_ec.value() << "\n" \
<< "error message: " << ASSERT_NO_ERROR_ec.message() << "\n"; \
GTEST_FATAL_FAILURE_(MessageStorage.c_str()); \
} else {}
#define ASSERT_NO_ERROR(x) \
if (std::error_code ASSERT_NO_ERROR_ec = x) { \
SmallString<128> MessageStorage; \
raw_svector_ostream Message(MessageStorage); \
Message << #x ": did not return errc::success.\n" \
<< "error number: " << ASSERT_NO_ERROR_ec.value() << "\n" \
<< "error message: " << ASSERT_NO_ERROR_ec.message() << "\n"; \
GTEST_FATAL_FAILURE_(MessageStorage.c_str()); \
} else { \
}
namespace {
@ -357,7 +357,7 @@ TEST_F(FileSystemTest, TempFiles) {
ASSERT_EQ(fs::remove(Twine(TempPath2), false),
std::errc::no_such_file_or_directory);
error_code EC = fs::status(TempPath2.c_str(), B);
std::error_code EC = fs::status(TempPath2.c_str(), B);
EXPECT_EQ(EC, std::errc::no_such_file_or_directory);
EXPECT_EQ(B.type(), fs::file_type::file_not_found);
@ -411,7 +411,7 @@ TEST_F(FileSystemTest, CreateDir) {
}
TEST_F(FileSystemTest, DirectoryIteration) {
error_code ec;
std::error_code ec;
for (fs::directory_iterator i(".", ec), e; i != e; i.increment(ec))
ASSERT_NO_ERROR(ec);
@ -583,7 +583,7 @@ TEST_F(FileSystemTest, FileMapping) {
ASSERT_NO_ERROR(
fs::createTemporaryFile("prefix", "temp", FileDescriptor, TempPath));
// Map in temp file and add some content
error_code EC;
std::error_code EC;
StringRef Val("hello there");
{
fs::mapped_file_region mfr(FileDescriptor,

View File

@ -34,7 +34,6 @@
#include <system_error>
#include <vector>
using namespace llvm;
using std::error_code;
static cl::opt<std::string>
CheckFilename(cl::Positional, cl::desc("<check-file>"), cl::Required);
@ -822,8 +821,7 @@ static StringRef FindFirstMatchingPrefix(StringRef &Buffer,
static bool ReadCheckFile(SourceMgr &SM,
std::vector<CheckString> &CheckStrings) {
std::unique_ptr<MemoryBuffer> File;
if (error_code ec =
MemoryBuffer::getFileOrSTDIN(CheckFilename, File)) {
if (std::error_code ec = MemoryBuffer::getFileOrSTDIN(CheckFilename, File)) {
errs() << "Could not open check file '" << CheckFilename << "': "
<< ec.message() << '\n';
return true;
@ -1226,8 +1224,7 @@ int main(int argc, char **argv) {
// Open the file to check and add it to SourceMgr.
std::unique_ptr<MemoryBuffer> File;
if (error_code ec =
MemoryBuffer::getFileOrSTDIN(InputFilename, File)) {
if (std::error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename, File)) {
errs() << "Could not open input file '" << InputFilename << "': "
<< ec.message() << '\n';
return 2;

View File

@ -21,7 +21,6 @@
#include "llvm/Support/ToolOutputFile.h"
#include <system_error>
using namespace llvm;
using std::error_code;
static cl::opt<bool>
Quiet("quiet", cl::desc("Don't print unnecessary status information"),
@ -46,7 +45,7 @@ int main(int argc, char **argv) {
// Get the input data.
std::unique_ptr<MemoryBuffer> In;
if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename, In)) {
if (std::error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename, In)) {
errs() << argv[0] << ": error: Unable to get input '"
<< InputFilename << "': " << ec.message() << '\n';
return 1;