[llvm] r263745 - [Support] Make Error::isA<T>() works on success values.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 17 13:35:00 PDT 2016
Author: lhames
Date: Thu Mar 17 15:35:00 2016
New Revision: 263745
URL: http://llvm.org/viewvc/llvm-project?rev=263745&view=rev
Log:
[Support] Make Error::isA<T>() works on success values.
Modified:
llvm/trunk/include/llvm/Support/Error.h
llvm/trunk/unittests/Support/ErrorTest.cpp
Modified: llvm/trunk/include/llvm/Support/Error.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Error.h?rev=263745&r1=263744&r2=263745&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Error.h (original)
+++ llvm/trunk/include/llvm/Support/Error.h Thu Mar 17 15:35:00 2016
@@ -195,7 +195,7 @@ public:
/// Check whether one error is a subclass of another.
template <typename ErrT> bool isA() const {
- return getPtr()->isA(ErrT::classID());
+ return getPtr() && getPtr()->isA(ErrT::classID());
}
private:
Modified: llvm/trunk/unittests/Support/ErrorTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ErrorTest.cpp?rev=263745&r1=263744&r2=263745&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/ErrorTest.cpp (original)
+++ llvm/trunk/unittests/Support/ErrorTest.cpp Thu Mar 17 15:35:00 2016
@@ -149,14 +149,17 @@ TEST(Error, CheckCustomErrors) {
{
Error E = make_error<CustomError>(1);
Error F = make_error<CustomSubError>(1, 2);
+ Error G = Error::success();
EXPECT_TRUE(E.isA<CustomError>());
EXPECT_FALSE(E.isA<CustomSubError>());
EXPECT_TRUE(F.isA<CustomError>());
EXPECT_TRUE(F.isA<CustomSubError>());
+ EXPECT_FALSE(G.isA<CustomError>());
consumeError(std::move(E));
consumeError(std::move(F));
+ consumeError(std::move(G));
}
// Check that we can handle a custom error.
More information about the llvm-commits
mailing list