Skip to content

Commit b685fb2

Browse files
committed
More general assert() gcov solution
Fully disable assert() when compiling with gcov instead of overriding individual macros.
1 parent ef8b1b8 commit b685fb2

3 files changed

Lines changed: 5 additions & 9 deletions

File tree

Zend/zend_API.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,13 +1055,7 @@ static zend_always_inline bool zend_char_has_nul_byte(const char *s, size_t know
10551055
#define RETURN_ZVAL(zv, copy, dtor) do { RETVAL_ZVAL(zv, copy, dtor); return; } while (0)
10561056
#define RETURN_FALSE do { RETVAL_FALSE; return; } while (0)
10571057
#define RETURN_TRUE do { RETVAL_TRUE; return; } while (0)
1058-
1059-
#ifndef HAVE_GCOV
1060-
# define RETURN_THROWS() do { ZEND_ASSERT(EG(exception)); (void) return_value; return; } while (0)
1061-
#else
1062-
/* Drop ZEND_ASSERT() to avoid untested branch warning in gcov. */
1063-
# define RETURN_THROWS() do { (void) return_value; return; } while (0)
1064-
#endif
1058+
#define RETURN_THROWS() do { ZEND_ASSERT(EG(exception)); (void) return_value; return; } while (0)
10651059

10661060
#define HASH_OF(p) (Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties(Z_OBJ_P(p)) : NULL)))
10671061

Zend/zend_portability.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@
106106
# define ZEND_ASSUME(c)
107107
#endif
108108

109-
#if ZEND_DEBUG
109+
#ifdef HAVE_GCOV
110+
/* Disable assert() when compiling with gcov to avoid untested branch warning. */
111+
# define ZEND_ASSERT(c) ((void)sizeof(c))
112+
#elif ZEND_DEBUG
110113
# define ZEND_ASSERT(c) assert(c)
111114
#else
112115
# define ZEND_ASSERT(c) ZEND_ASSUME(c)

build/Makefile.gcov

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ GCOVR_EXCLUDES = \
3131
GCOVR_EXCLUDE_LINES_BY_PATTERNS = \
3232
'.*\b(ZEND_PARSE_PARAMETERS_(START|END|NONE)|Z_PARAM_).*' \
3333
'\s*EMPTY_SWITCH_DEFAULT_CASE\(\)(;)?\s*' \
34-
'\s*ZEND_ASSERT\(.*\);\s*' \
3534
'\s*ZEND_UNREACHABLE\(\);\s*'
3635

3736
lcov: lcov-html

0 commit comments

Comments
 (0)