summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-08-14 13:33:28 +0000
committerPavel Labath <pavel@labath.sk>2019-08-14 13:33:28 +0000
commit40837e97b199b4d6546df9f8912e14a56c434417 (patch)
tree99297768aa856be011a1fd62ef93806f019e2eb5 /llvm/lib/Support
parent4894eeecc99d9729259dba54efc207be4bc4ddf5 (diff)
downloadbcm5719-llvm-40837e97b199b4d6546df9f8912e14a56c434417.tar.gz
bcm5719-llvm-40837e97b199b4d6546df9f8912e14a56c434417.zip
raw_ostream: add operator<< overload for std::error_code
Summary: The main motivation for this is unit tests, which contain a large macro for pretty-printing std::error_code, and this macro is duplicated in every file that needs to do this. However, the functionality may be useful elsewhere too. In this patch I have reimplemented the existing ASSERT_NO_ERROR macros to reuse the new functionality, but I have kept the macro (as a one-liner) as it is slightly more readable than ASSERT_EQ(..., std::error_code()). Reviewers: sammccall, ilya-biryukov Subscribers: zturner, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65643 llvm-svn: 368849
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r--llvm/lib/Support/raw_ostream.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index b9989371f5e..4a2d6d20951 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -139,6 +139,11 @@ raw_ostream &raw_ostream::operator<<(long long N) {
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) {
llvm::write_hex(*this, N, HexPrintStyle::Lower);
return *this;
OpenPOWER on IntegriCloud