mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Revert "raw_ostream: add operator<< overload for std::error_code"
This reverts commit r368849, because it breaks some bots (e.g. llvm-clang-x86_64-win-fast). It turns out this is not as NFC as we had hoped, because operator== will consider two std::error_codes to be distinct even though they both hold "success" values if they have different categories. llvm-svn: 368854
This commit is contained in:
parent
2c377876d9
commit
623bce661a
@ -223,8 +223,6 @@ public:
|
|||||||
|
|
||||||
raw_ostream &operator<<(double N);
|
raw_ostream &operator<<(double N);
|
||||||
|
|
||||||
raw_ostream &operator<<(std::error_code EC);
|
|
||||||
|
|
||||||
/// Output \p N in hexadecimal, without any prefix or padding.
|
/// Output \p N in hexadecimal, without any prefix or padding.
|
||||||
raw_ostream &write_hex(unsigned long long N);
|
raw_ostream &write_hex(unsigned long long N);
|
||||||
|
|
||||||
|
@ -139,11 +139,6 @@ raw_ostream &raw_ostream::operator<<(long long N) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
raw_ostream &raw_ostream::operator<<(std::error_code EC) {
|
|
||||||
return *this << EC.message() << " (" << EC.category().name() << ':'
|
|
||||||
<< EC.value() << ')';
|
|
||||||
}
|
|
||||||
|
|
||||||
raw_ostream &raw_ostream::write_hex(unsigned long long N) {
|
raw_ostream &raw_ostream::write_hex(unsigned long long N) {
|
||||||
llvm::write_hex(*this, N, HexPrintStyle::Lower);
|
llvm::write_hex(*this, N, HexPrintStyle::Lower);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -17,7 +17,16 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
namespace fs = llvm::sys::fs;
|
namespace fs = llvm::sys::fs;
|
||||||
|
|
||||||
#define ASSERT_NO_ERROR(x) ASSERT_EQ(x, std::error_code())
|
#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 { \
|
||||||
|
}
|
||||||
|
|
||||||
class MagicTest : public testing::Test {
|
class MagicTest : public testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
@ -933,7 +933,7 @@ public:
|
|||||||
|
|
||||||
class TestErrorCategory : public std::error_category {
|
class TestErrorCategory : public std::error_category {
|
||||||
public:
|
public:
|
||||||
const char *name() const noexcept override { return "test_error"; }
|
const char *name() const noexcept override { return "error"; }
|
||||||
std::string message(int Condition) const override {
|
std::string message(int Condition) const override {
|
||||||
switch (static_cast<test_error_code>(Condition)) {
|
switch (static_cast<test_error_code>(Condition)) {
|
||||||
case test_error_code::unspecified:
|
case test_error_code::unspecified:
|
||||||
@ -975,11 +975,4 @@ TEST(Error, SubtypeStringErrorTest) {
|
|||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Error, error_codeErrorMessageTest) {
|
|
||||||
EXPECT_NONFATAL_FAILURE(
|
|
||||||
EXPECT_EQ(make_error_code(test_error_code::unspecified),
|
|
||||||
make_error_code(test_error_code::error_2)),
|
|
||||||
"Which is: An unknown error has occurred. (test_error:1)");
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -18,7 +18,16 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
using namespace llvm::sys;
|
using namespace llvm::sys;
|
||||||
|
|
||||||
#define ASSERT_NO_ERROR(x) ASSERT_EQ(x, std::error_code())
|
#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 {
|
namespace {
|
||||||
TEST(FileOutputBuffer, Test) {
|
TEST(FileOutputBuffer, Test) {
|
||||||
|
@ -16,7 +16,16 @@
|
|||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
#define ASSERT_NO_ERROR(x) ASSERT_EQ(x, std::error_code())
|
#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 { \
|
||||||
|
}
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
@ -38,8 +38,24 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
using namespace llvm::sys;
|
using namespace llvm::sys;
|
||||||
|
|
||||||
#define ASSERT_NO_ERROR(x) ASSERT_EQ(x, std::error_code())
|
#define ASSERT_NO_ERROR(x) \
|
||||||
#define ASSERT_ERROR(x) ASSERT_NE(x, std::error_code())
|
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 { \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ASSERT_ERROR(x) \
|
||||||
|
if (!x) { \
|
||||||
|
SmallString<128> MessageStorage; \
|
||||||
|
raw_svector_ostream Message(MessageStorage); \
|
||||||
|
Message << #x ": did not return a failure error code.\n"; \
|
||||||
|
GTEST_FATAL_FAILURE_(MessageStorage.c_str()); \
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -1249,7 +1265,7 @@ TEST_F(FileSystemTest, OpenFileForRead) {
|
|||||||
int FileDescriptor2;
|
int FileDescriptor2;
|
||||||
SmallString<64> ResultPath;
|
SmallString<64> ResultPath;
|
||||||
ASSERT_NO_ERROR(fs::openFileForRead(Twine(TempPath), FileDescriptor2,
|
ASSERT_NO_ERROR(fs::openFileForRead(Twine(TempPath), FileDescriptor2,
|
||||||
fs::OF_None, &ResultPath));
|
fs::OF_None, &ResultPath))
|
||||||
|
|
||||||
// If we succeeded, check that the paths are the same (modulo case):
|
// If we succeeded, check that the paths are the same (modulo case):
|
||||||
if (!ResultPath.empty()) {
|
if (!ResultPath.empty()) {
|
||||||
|
@ -35,8 +35,16 @@ void sleep_for(unsigned int seconds) {
|
|||||||
#error sleep_for is not implemented on your platform.
|
#error sleep_for is not implemented on your platform.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ASSERT_NO_ERROR(x) ASSERT_EQ(x, std::error_code())
|
#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 { \
|
||||||
|
}
|
||||||
// From TestMain.cpp.
|
// From TestMain.cpp.
|
||||||
extern const char *TestMainArgv0;
|
extern const char *TestMainArgv0;
|
||||||
|
|
||||||
|
@ -17,7 +17,14 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
using namespace llvm::sys;
|
using namespace llvm::sys;
|
||||||
|
|
||||||
#define ASSERT_NO_ERROR(x) ASSERT_EQ(x, std::error_code())
|
#define ASSERT_NO_ERROR(x) \
|
||||||
|
do { \
|
||||||
|
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"; \
|
||||||
|
} \
|
||||||
|
} while (false)
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
std::error_code CreateFileWithContent(const SmallString<128> &FilePath,
|
std::error_code CreateFileWithContent(const SmallString<128> &FilePath,
|
||||||
|
@ -15,7 +15,16 @@
|
|||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
#define ASSERT_NO_ERROR(x) ASSERT_EQ(x, std::error_code())
|
#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 {
|
namespace {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user