[orc-rt] Add ErrorAsOutParameter convenience constructor. (#169467)

Allows construction of ErrorAsOutParameters from Error references.
This commit is contained in:
Lang Hames
2025-11-26 09:58:53 +11:00
committed by GitHub
parent ebf5d9ef7d
commit 9534ed9f30
2 changed files with 11 additions and 0 deletions

View File

@@ -278,6 +278,8 @@ public:
(void)!!*Err;
}
ErrorAsOutParameter(Error &Err) : Err(&Err) { (void)!!Err; }
~ErrorAsOutParameter() {
// Clear the checked bit.
if (Err && !*Err)

View File

@@ -257,6 +257,15 @@ TEST(ErrorTest, ErrorAsOutParameterUnchecked) {
<< "ErrorAsOutParameter did not clear the checked flag on destruction.";
}
// Test that we can construct an ErrorAsOutParameter from an Error&.
TEST(ErrorTest, ErrorAsOutParameterRefConstructor) {
Error E = Error::success();
{
ErrorAsOutParameter _(E); // construct with Error&.
}
(void)!!E;
}
// Check 'Error::isA<T>' method handling.
TEST(ErrorTest, IsAHandling) {
// Check 'isA' handling.