gh-111178: Skip undefined behavior checks in _PyPegen_lookahead() (#131714)

For example, expression_rule() return type is 'expr_ty', whereas
_PyPegen_lookahead() uses 'void*'.
This commit is contained in:
Victor Stinner 2025-03-27 10:03:58 +01:00 committed by GitHub
parent 9ef9d687ff
commit 3796884528
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -406,11 +406,14 @@ _PyPegen_lookahead_with_int(int positive, Token *(func)(Parser *, int), Parser *
return (res != NULL) == positive;
}
int
// gh-111178: Use _Py_NO_SANITIZE_UNDEFINED to disable sanitizer checks on
// undefined behavior (UBsan) in this function, rather than changing 'func'
// callback API.
int _Py_NO_SANITIZE_UNDEFINED
_PyPegen_lookahead(int positive, void *(func)(Parser *), Parser *p)
{
int mark = p->mark;
void *res = (void*)func(p);
void *res = func(p);
p->mark = mark;
return (res != NULL) == positive;
}