Skip to content

Commit 9534ed9

Browse files
authored
[orc-rt] Add ErrorAsOutParameter convenience constructor. (#169467)
Allows construction of ErrorAsOutParameters from Error references.
1 parent ebf5d9e commit 9534ed9

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

orc-rt/include/orc-rt/Error.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ class ErrorAsOutParameter {
278278
(void)!!*Err;
279279
}
280280

281+
ErrorAsOutParameter(Error &Err) : Err(&Err) { (void)!!Err; }
282+
281283
~ErrorAsOutParameter() {
282284
// Clear the checked bit.
283285
if (Err && !*Err)

orc-rt/unittests/ErrorTest.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,15 @@ TEST(ErrorTest, ErrorAsOutParameterUnchecked) {
257257
<< "ErrorAsOutParameter did not clear the checked flag on destruction.";
258258
}
259259

260+
// Test that we can construct an ErrorAsOutParameter from an Error&.
261+
TEST(ErrorTest, ErrorAsOutParameterRefConstructor) {
262+
Error E = Error::success();
263+
{
264+
ErrorAsOutParameter _(E); // construct with Error&.
265+
}
266+
(void)!!E;
267+
}
268+
260269
// Check 'Error::isA<T>' method handling.
261270
TEST(ErrorTest, IsAHandling) {
262271
// Check 'isA' handling.

0 commit comments

Comments
 (0)