Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check SvTYPES in assert args macros #22421

Merged
merged 4 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 28 additions & 21 deletions embed.fnc
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,13 @@
: know "I have defined whether NULL is OK or not" rather than having neither
: NULL or NULLOK, which is ambiguous.
:
: Pointer parameters that point to AVs, CVs or HVs will generate additional
: checks in the arguments assertion macro, that check on entry to the
: function that the SV being pointed to is of the intended type, by
: inspecting its SvTYPE(). For some functions this check may be inappropriate
: as in rare cases the arguments passed may not be of the correct type. To
: skip checking on an argument type, prefix its type with NOCHECK.
:
: Numeric arguments may also be prefixed with NZ, which will cause the
: appropriate asserts to be generated to validate that this is the case.
:
Expand Down Expand Up @@ -924,7 +931,7 @@ AMdip |GV * |CvGV |NN CV *sv
Xop |GV * |cvgv_from_hek |NN CV *cv
Xp |void |cvgv_set |NN CV *cv \
tonycoz marked this conversation as resolved.
Show resolved Hide resolved
|NULLOK GV *gv
Adp |SV * |cv_name |NN CV *cv \
Adp |SV * |cv_name |NN NOCHECK CV *cv \
|NULLOK SV *sv \
|U32 flags
Adp |void |cv_set_call_checker \
Expand Down Expand Up @@ -1291,14 +1298,14 @@ Adp |GV * |gv_add_by_type |NULLOK GV *gv \
|svtype type
Adp |int |Gv_AMupdate |NN HV *stash \
|bool destructing
ARdp |GV * |gv_autoload_pv |NULLOK HV *stash \
ARdp |GV * |gv_autoload_pv |NULLOK NOCHECK HV *stash \
|NN const char *namepv \
|U32 flags
ARdp |GV * |gv_autoload_pvn|NULLOK HV *stash \
ARdp |GV * |gv_autoload_pvn|NULLOK NOCHECK HV *stash \
|NN const char *name \
|STRLEN len \
|U32 flags
ARdp |GV * |gv_autoload_sv |NULLOK HV *stash \
ARdp |GV * |gv_autoload_sv |NULLOK NOCHECK HV *stash \
|NN SV *namesv \
|U32 flags
AMbdp |GV * |gv_AVadd |NULLOK GV *gv
Expand All @@ -1318,61 +1325,61 @@ Adp |GV * |gv_fetchfile_flags \
|NN const char * const name \
|const STRLEN len \
|const U32 flags
Adm |GV * |gv_fetchmeth |NULLOK HV *stash \
Adm |GV * |gv_fetchmeth |NULLOK NOCHECK HV *stash \
|NN const char *name \
|STRLEN len \
|I32 level
Adm |GV * |gv_fetchmeth_autoload \
|NULLOK HV *stash \
|NULLOK NOCHECK HV *stash \
|NN const char *name \
|STRLEN len \
|I32 level
AMbdp |GV * |gv_fetchmethod |NN HV *stash \
AMbdp |GV * |gv_fetchmethod |NN NOCHECK HV *stash \
|NN const char *name
Adp |GV * |gv_fetchmethod_autoload \
|NN HV *stash \
|NN NOCHECK HV *stash \
|NN const char *name \
|I32 autoload
Apx |GV * |gv_fetchmethod_pv_flags \
|NN HV *stash \
|NN NOCHECK HV *stash \
|NN const char *name \
|U32 flags
Apx |GV * |gv_fetchmethod_pvn_flags \
|NN HV *stash \
|NN NOCHECK HV *stash \
|NN const char *name \
|const STRLEN len \
|U32 flags
Apx |GV * |gv_fetchmethod_sv_flags \
|NN HV *stash \
|NN NOCHECK HV *stash \
|NN SV *namesv \
|U32 flags
Adp |GV * |gv_fetchmeth_pv|NULLOK HV *stash \
Adp |GV * |gv_fetchmeth_pv|NULLOK NOCHECK HV *stash \
|NN const char *name \
|I32 level \
|U32 flags
Adp |GV * |gv_fetchmeth_pv_autoload \
|NULLOK HV *stash \
|NULLOK NOCHECK HV *stash \
|NN const char *name \
|I32 level \
|U32 flags
Adp |GV * |gv_fetchmeth_pvn \
|NULLOK HV *stash \
|NULLOK NOCHECK HV *stash \
|NN const char *name \
|STRLEN len \
|I32 level \
|U32 flags
Adp |GV * |gv_fetchmeth_pvn_autoload \
|NULLOK HV *stash \
|NULLOK NOCHECK HV *stash \
|NN const char *name \
|STRLEN len \
|I32 level \
|U32 flags
Adp |GV * |gv_fetchmeth_sv|NULLOK HV *stash \
Adp |GV * |gv_fetchmeth_sv|NULLOK NOCHECK HV *stash \
|NN SV *namesv \
|I32 level \
|U32 flags
Adp |GV * |gv_fetchmeth_sv_autoload \
|NULLOK HV *stash \
|NULLOK NOCHECK HV *stash \
|NN SV *namesv \
|I32 level \
|U32 flags
Expand Down Expand Up @@ -3053,7 +3060,7 @@ ATdip |void |SvAMAGIC_off |NN SV *sv
ATdip |void |SvAMAGIC_on |NN SV *sv
ATdp |void |sv_backoff |NN SV * const sv
Adp |SV * |sv_bless |NN SV * const sv \
|NN HV * const stash
|NN NOCHECK HV * const stash
CMbdp |bool |sv_2bool |NN SV * const sv
Cdp |bool |sv_2bool_flags |NN SV *sv \
|I32 flags
Expand Down Expand Up @@ -4409,7 +4416,7 @@ RS |HE * |new_he
: Used in hv.c and mg.c
opx |void |sv_kill_backrefs \
|NN SV * const sv \
|NULLOK AV * const av
|NULLOK NOCHECK AV * const av
#endif
#if defined(PERL_IN_HV_C) || defined(PERL_IN_SV_C)
op |SV * |hfree_next_entry \
Expand Down Expand Up @@ -4829,7 +4836,7 @@ Rp |SV * |varname |NULLOK const GV * const gv \
Sd |PADOFFSET|pad_alloc_name \
|NN PADNAME *name \
|U32 flags \
|NULLOK HV *typestash \
|NULLOK NOCHECK HV *typestash \
|NULLOK HV *ourstash
Sd |void |pad_check_dup |NN PADNAME *name \
|U32 flags \
Expand Down Expand Up @@ -5861,7 +5868,7 @@ S |void |incline |NN const char *s \
|NN const char *end
S |int |intuit_method |NN char *s \
|NULLOK SV *ioname \
|NULLOK CV *cv
|NULLOK NOCHECK CV *cv
S |int |intuit_more |NN char *s \
|NN char *e
S |I32 |lop |I32 f \
Expand Down
3 changes: 3 additions & 0 deletions pad.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ Perl_cv_undef_flags(pTHX_ CV *cv, U32 flags)
CV cvbody;/*CV body will never be realloced inside this func,
so don't read it more than once, use fake CV so existing macros
will work, the indirection and CV head struct optimized away*/
#ifdef DEBUGGING
SvFLAGS(&cvbody) = SVt_PVCV;
#endif
SvANY(&cvbody) = SvANY(cv);

PERL_ARGS_ASSERT_CV_UNDEF_FLAGS;
Expand Down
Loading
Loading