[PATCH] D131337: Wrap `llvm_unreachable` macro in do-while loop
Stefan Gränitz via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 8 00:58:06 PDT 2022
sgraenitz added inline comments.
================
Comment at: llvm/include/llvm/Support/ErrorHandling.h:150
#else
-#define llvm_unreachable(msg) LLVM_BUILTIN_TRAP, LLVM_BUILTIN_UNREACHABLE
+#define llvm_unreachable(msg) \
+ do { LLVM_BUILTIN_TRAP; LLVM_BUILTIN_UNREACHABLE; \
----------------
barannikov88 wrote:
> This is improperly formatted, please use clang-format.
Right, clang-format want's this:
```
do { \
LLVM_BUILTIN_TRAP; \
LLVM_BUILTIN_UNREACHABLE; \
} while (false)
```
I choose not to follow it in my patch, because the existing code is only 6 months old and didn't respect clang-format. Instead I mimicked the style of the `LLVM_DEBUG` macro which expands into a similar do-while construct: https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Support/Debug.h#L64
Of course, I can change that if there are good reasons or strong opinions on it.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131337/new/
https://reviews.llvm.org/D131337
More information about the llvm-commits
mailing list