[llvm] r237970 - [Support] Fix ErrorOr equality operator.
Michael J. Spencer
bigcheesegs at gmail.com
Thu May 21 16:15:01 PDT 2015
Author: mspencer
Date: Thu May 21 18:15:00 2015
New Revision: 237970
URL: http://llvm.org/viewvc/llvm-project?rev=237970&view=rev
Log:
[Support] Fix ErrorOr equality operator.
Modified:
llvm/trunk/include/llvm/Support/ErrorOr.h
llvm/trunk/unittests/Support/ErrorOrTest.cpp
Modified: llvm/trunk/include/llvm/Support/ErrorOr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ErrorOr.h?rev=237970&r1=237969&r2=237970&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ErrorOr.h (original)
+++ llvm/trunk/include/llvm/Support/ErrorOr.h Thu May 21 18:15:00 2015
@@ -281,8 +281,8 @@ template <class T, class E>
typename std::enable_if<std::is_error_code_enum<E>::value ||
std::is_error_condition_enum<E>::value,
bool>::type
-operator==(ErrorOr<T> &Err, E Code) {
- return std::error_code(Err) == Code;
+operator==(const ErrorOr<T> &Err, E Code) {
+ return Err.getError() == Code;
}
} // end namespace llvm
Modified: llvm/trunk/unittests/Support/ErrorOrTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ErrorOrTest.cpp?rev=237970&r1=237969&r2=237970&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/ErrorOrTest.cpp (original)
+++ llvm/trunk/unittests/Support/ErrorOrTest.cpp Thu May 21 18:15:00 2015
@@ -66,6 +66,11 @@ TEST(ErrorOr, Covariant) {
ErrorOr<std::unique_ptr<int>> b4(b3);
}
+TEST(ErrorOr, Comparison) {
+ ErrorOr<int> x(std::errc::no_such_file_or_directory);
+ EXPECT_EQ(x, std::errc::no_such_file_or_directory);
+}
+
// ErrorOr<int*> x(nullptr);
// ErrorOr<std::unique_ptr<int>> y = x; // invalid conversion
static_assert(
More information about the llvm-commits
mailing list