[flang-commits] [flang] 2d3d62d - [flang] fix: split ifndef for CHECK and CHECK_MSG (#114707)
via flang-commits
flang-commits at lists.llvm.org
Tue Dec 24 23:47:34 PST 2024
Author: Ivan Aksamentov
Date: 2024-12-25T07:47:30Z
New Revision: 2d3d62d77e2d011c9dbdb12732aca3070efc83ca
URL: https://github.com/llvm/llvm-project/commit/2d3d62d77e2d011c9dbdb12732aca3070efc83ca
DIFF: https://github.com/llvm/llvm-project/commit/2d3d62d77e2d011c9dbdb12732aca3070efc83ca.diff
LOG: [flang] fix: split ifndef for CHECK and CHECK_MSG (#114707)
Resolves https://github.com/llvm/llvm-project/issues/114703
I think it's the best practice that each macro has it's own `ifndef`
check and this way the build issue is resolved for me.
I also find the names of these macro a bit too generic - an easy recipe
for conflicts. In my case, the error was likely caused by something else
defining `CHECK` but not `CHECK_MSG`, so likely these `CHECK` and
`CHECK_MSG` weren't actually working at all because the result of
`ifndef` is always false.
As a definitive fix, perhaps it makes sense to rename them to something
more specific, e.g. `FLANG_CHECK` and `FLANG_CHECK_MSG`.
Added:
Modified:
flang/include/flang/Common/idioms.h
Removed:
################################################################################
diff --git a/flang/include/flang/Common/idioms.h b/flang/include/flang/Common/idioms.h
index 99f383ec75b999..06631bcf2e4450 100644
--- a/flang/include/flang/Common/idioms.h
+++ b/flang/include/flang/Common/idioms.h
@@ -87,7 +87,10 @@ template <typename... LAMBDAS> visitors(LAMBDAS... x) -> visitors<LAMBDAS...>;
// To disable, compile with '-DCHECK=(void)'
#ifndef CHECK
#define CHECK(x) ((x) || (DIE("CHECK(" #x ") failed"), false))
+#endif
+
// Same as above, but with a custom error message.
+#ifndef CHECK_MSG
#define CHECK_MSG(x, y) ((x) || (DIE("CHECK(" #x ") failed: " #y), false))
#endif
More information about the flang-commits
mailing list