llvm.org GIT mirror llvm / 3df7687
[Support] Fix a bug in ErrorList::join / joinErrors. When concatenating two error lists the ErrorList::join method (which is called by joinErrors) was failing to set the checked bit on the second error, leading to a 'failure to check error' assertion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274249 91177308-0d34-0410-b5e6-96231b3b80d8 Lang Hames 4 years ago
2 changed file(s) with 47 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
344344 if (E1.isA()) {
345345 auto &E1List = static_cast(*E1.getPtr());
346346 if (E2.isA()) {
347 auto &E2List = static_cast(*E2.getPtr());
347 auto E2Payload = E2.takePayload();
348 auto &E2List = static_cast(*E2Payload);
348349 for (auto &Payload : E2List.Payloads)
349350 E1List.Payloads.push_back(std::move(Payload));
350351 } else
313313 EXPECT_TRUE(CustomErrorInfo1 == 7 && CustomErrorInfo2 == 42 &&
314314 CustomErrorExtraInfo == 7)
315315 << "Failed handling compound Error.";
316
317 // Test appending a single item to a list.
318 {
319 int Sum = 0;
320 handleAllErrors(
321 joinErrors(
322 joinErrors(make_error(7),
323 make_error(7)),
324 make_error(7)),
325 [&](const CustomError &CE) {
326 Sum += CE.getInfo();
327 });
328 EXPECT_EQ(Sum, 21) << "Failed to correctly append error to error list.";
329 }
330
331 // Test prepending a single item to a list.
332 {
333 int Sum = 0;
334 handleAllErrors(
335 joinErrors(
336 make_error(7),
337 joinErrors(make_error(7),
338 make_error(7))),
339 [&](const CustomError &CE) {
340 Sum += CE.getInfo();
341 });
342 EXPECT_EQ(Sum, 21) << "Failed to correctly prepend error to error list.";
343 }
344
345 // Test concatenating two error lists.
346 {
347 int Sum = 0;
348 handleAllErrors(
349 joinErrors(
350 joinErrors(
351 make_error(7),
352 make_error(7)),
353 joinErrors(
354 make_error(7),
355 make_error(7))),
356 [&](const CustomError &CE) {
357 Sum += CE.getInfo();
358 });
359 EXPECT_EQ(Sum, 28) << "Failed to correctly concatenate erorr lists.";
360 }
316361 }
317362
318363 // Test that we can consume success values.