diff options
Diffstat (limited to 'llvm')
-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. |