This is an archive of the discontinued LLVM Phabricator instance.

[mlir][sparse] Improving the FATAL macro
ClosedPublic

Authored by wrengr on May 26 2022, 6:38 PM.

Details

Summary

The previous macro definition using {...} would fail to compile when the callsite uses a semicolon followed by an else-statement (i.e., if (...) FATAL(...); else ...;). Replacing the simple braces with do{...}while(0) (n.b., semicolon not included in the macro definition) enables callsites to use the semicolon plus else-statement syntax without problems. The new definition now requires the semicolon at all callsites, but since it was already being called that way nothing changes.

For more explanation, see https://gcc.gnu.org/onlinedocs/cpp/Swallowing-the-Semicolon.html

Diff Detail

Event Timeline

wrengr created this revision.May 26 2022, 6:38 PM
wrengr requested review of this revision.May 26 2022, 6:38 PM
aartbik accepted this revision.May 27 2022, 2:04 PM
This revision is now accepted and ready to land.May 27 2022, 2:04 PM
wrengr updated this revision to Diff 433169.May 31 2022, 1:22 PM

rebase (attempting to fix the spurious Debian build failure before landing)

wrengr updated this revision to Diff 433188.May 31 2022, 2:10 PM

rebasing for D126233

This revision was automatically updated to reflect the committed changes.