[mlir][sparse] Improving the FATAL macro
authorwren romano <2998727+wrengr@users.noreply.github.com>
Tue, 31 May 2022 20:06:10 +0000 (13:06 -0700)
committerwren romano <2998727+wrengr@users.noreply.github.com>
Tue, 31 May 2022 21:31:38 +0000 (14:31 -0700)
commitc63d4fac4f2a726e1fe214dabbe574ef863fe896
tree703e440e1f15310a0964f858580d99ccac7f1790
parentda9d41cb8777738ab2c054ba67467cd22dc8dbc2
[mlir][sparse] Improving the FATAL macro

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>

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D126514
mlir/lib/ExecutionEngine/SparseTensorUtils.cpp