mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-10 04:24:23 +00:00
[Support] Make Error::isA<T>() works on success values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263745 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
367051414e
commit
3d86278890
@ -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:
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user