diff options
author | Lang Hames <lhames@gmail.com> | 2016-03-17 20:35:00 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2016-03-17 20:35:00 +0000 |
commit | 01a3cf4d31f3e7fa5a8ab4b4b7622900acda5340 (patch) | |
tree | f5e5165d8485923aef83fb667148397ebd556cac | |
parent | b0c4eae07339dce7d0d6e7e697fba37b41cb28cf (diff) | |
download | bcm5719-llvm-01a3cf4d31f3e7fa5a8ab4b4b7622900acda5340.tar.gz bcm5719-llvm-01a3cf4d31f3e7fa5a8ab4b4b7622900acda5340.zip |
[Support] Make Error::isA<T>() works on success values.
llvm-svn: 263745
-rw-r--r-- | llvm/include/llvm/Support/Error.h | 2 | ||||
-rw-r--r-- | llvm/unittests/Support/ErrorTest.cpp | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/llvm/include/llvm/Support/Error.h b/llvm/include/llvm/Support/Error.h index b0eaa44498f..33a3bc9404e 100644 --- a/llvm/include/llvm/Support/Error.h +++ b/llvm/include/llvm/Support/Error.h @@ -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: diff --git a/llvm/unittests/Support/ErrorTest.cpp b/llvm/unittests/Support/ErrorTest.cpp index ed3d1c1852c..d5af2cab967 100644 --- a/llvm/unittests/Support/ErrorTest.cpp +++ b/llvm/unittests/Support/ErrorTest.cpp @@ -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. |