Skip to content

Commit a8cb419

Browse files
committed
Use for-loop trick for debug(). Remove Voidifier.
1 parent cd2be5e commit a8cb419

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

src/Debug.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ bool debug_is_active_impl(int verbosity, const char *file, const char *function,
4848
* is determined by the value of the environment variable
4949
* HL_DEBUG_CODEGEN
5050
*/
51+
// clang-format off
5152
#define debug(n) \
5253
/* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \
53-
(!debug_is_active((n))) ? (void)0 : ::Halide::Internal::Voidifier() & std::cerr
54+
for (int _ran = 0; !_ran && debug_is_active((n)); ++_ran) std::cerr
55+
// clang-format on
5456

5557
/** Allow easily printing the contents of containers, or std::vector-like containers,
5658
* in debug output. Used like so:

src/Error.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,6 @@ struct WarningReport : ReportBase<WarningReport> {
177177
}
178178
};
179179

180-
// This uses operator precedence as a trick to avoid argument evaluation if
181-
// an assertion is true: it is intended to be used as part of the
182-
// _halide_internal_assertion macro, to coerce the result of the stream
183-
// expression to void (to match the condition-is-false case).
184-
struct Voidifier {
185-
// This has to be an operator with a precedence lower than << but
186-
// higher than ?:
187-
template<typename T>
188-
HALIDE_ALWAYS_INLINE void operator&(T &) {
189-
}
190-
};
191-
192180
/**
193181
* _halide_internal_assertion is used to implement our assertion macros
194182
* in such a way that the messages output for the assertion are only

0 commit comments

Comments
 (0)