summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2022-11-17 14:30:39 +1100
committerJames E Keenan <jkeenan@cpan.org>2022-11-18 18:12:45 -0500
commit2e4090b82403991910f1fe64866048b62ccf5402 (patch)
tree8ca250b0bfb4e386128336ee73db71caba26c032 /sv.c
parenta33534361e54c6342c59edd0c06b6bbb9ac5776c (diff)
downloadperl-2e4090b82403991910f1fe64866048b62ccf5402.tar.gz
only fully calculate the stash (effective) name where needed
gcc 12 was complaining that evaluating (somehekptr)->hek_key was always true in many places where HvNAME() or HvENAME() was being called in boolean context. Add new macros to check whether the names should be available and use those instead.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/sv.c b/sv.c
index 139d3fefa2..8d80b5e31b 100644
--- a/sv.c
+++ b/sv.c
@@ -3728,7 +3728,7 @@ S_glob_assign_glob(pTHX_ SV *const dsv, SV *const ssv, const int dtype)
/* If source has a real method, then a method is
going to change */
else if(
- GvCV((const GV *)ssv) && GvSTASH(dsv) && HvENAME(GvSTASH(dsv))
+ GvCV((const GV *)ssv) && GvSTASH(dsv) && HvHasENAME(GvSTASH(dsv))
) {
mro_changes = 1;
}
@@ -3737,7 +3737,7 @@ S_glob_assign_glob(pTHX_ SV *const dsv, SV *const ssv, const int dtype)
/* If dest already had a real method, that's a change as well */
if(
!mro_changes && GvGP(MUTABLE_GV(dsv)) && GvCVu((const GV *)dsv)
- && GvSTASH(dsv) && HvENAME(GvSTASH(dsv))
+ && GvSTASH(dsv) && HvHasENAME(GvSTASH(dsv))
) {
mro_changes = 1;
}
@@ -3750,7 +3750,7 @@ S_glob_assign_glob(pTHX_ SV *const dsv, SV *const ssv, const int dtype)
if(memEQs(name, len, "ISA")
/* The stash may have been detached from the symbol table, so
check its name. */
- && GvSTASH(dsv) && HvENAME(GvSTASH(dsv))
+ && GvSTASH(dsv) && HvHasENAME(GvSTASH(dsv))
)
mro_changes = 2;
else {
@@ -3808,7 +3808,7 @@ S_glob_assign_glob(pTHX_ SV *const dsv, SV *const ssv, const int dtype)
}
else if(mro_changes == 3) {
HV * const stash = GvHV(dsv);
- if(old_stash ? (HV *)HvENAME_get(old_stash) : stash)
+ if(old_stash ? HvHasENAME(old_stash) : cBOOL(stash))
mro_package_moved(
stash, old_stash,
(GV *)dsv, 0
@@ -3958,7 +3958,7 @@ Perl_gv_setref(pTHX_ SV *const dsv, SV *const ssv)
(len > 1 && name[len-2] == ':' && name[len-1] == ':')
|| (len == 1 && name[0] == ':')
)
- && (!dref || HvENAME_get(dref))
+ && (!dref || HvHasENAME(dref))
) {
mro_package_moved(
(HV *)sref, (HV *)dref,
@@ -3971,7 +3971,7 @@ Perl_gv_setref(pTHX_ SV *const dsv, SV *const ssv)
&& memEQs(GvNAME((GV*)dsv), GvNAMELEN((GV*)dsv), "ISA")
/* The stash may have been detached from the symbol table, so
check its name before doing anything. */
- && GvSTASH(dsv) && HvENAME(GvSTASH(dsv))
+ && GvSTASH(dsv) && HvHasENAME(GvSTASH(dsv))
) {
MAGIC *mg;
MAGIC * const omg = dref && SvSMAGICAL(dref)
@@ -4432,7 +4432,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dsv, SV* ssv, const I32 flags)
if (reset_isa) {
HV * const stash = GvHV(dsv);
if(
- old_stash ? (HV *)HvENAME_get(old_stash) : stash
+ old_stash ? HvHasENAME(old_stash) : cBOOL(stash)
)
mro_package_moved(
stash, old_stash,
@@ -6558,7 +6558,7 @@ S_anonymise_cv_maybe(pTHX_ GV *gv, CV* cv)
}
/* if not, anonymise: */
- gvname = (GvSTASH(gv) && HvNAME(GvSTASH(gv)) && HvENAME(GvSTASH(gv)))
+ gvname = (GvSTASH(gv) && HvHasNAME(GvSTASH(gv)) && HvHasENAME(GvSTASH(gv)))
? newSVhek(HvENAME_HEK(GvSTASH(gv)))
: newSVpvn_flags( "__ANON__", 8, 0 );
sv_catpvs(gvname, "::__ANON__");
@@ -6793,7 +6793,7 @@ Perl_sv_clear(pTHX_ SV *const orig_sv)
case SVt_PVGV:
if (isGV_with_GP(sv)) {
if(GvCVu((const GV *)sv) && (stash = GvSTASH(MUTABLE_GV(sv)))
- && HvENAME_get(stash))
+ && HvHasENAME(stash))
mro_method_changed_in(stash);
gp_free(MUTABLE_GV(sv));
if (GvNAME_HEK(sv))
@@ -10082,7 +10082,7 @@ Perl_sv_resetpvn(pTHX_ const char *s, STRLEN len, HV * const stash)
if (GvAV(gv)) {
av_clear(GvAV(gv));
}
- if (GvHV(gv) && !HvNAME_get(GvHV(gv))) {
+ if (GvHV(gv) && !HvHasNAME(GvHV(gv))) {
hv_clear(GvHV(gv));
}
}
@@ -10458,9 +10458,10 @@ Perl_sv_ref(pTHX_ SV *dst, const SV *const sv, const int ob)
dst = sv_newmortal();
if (ob && SvOBJECT(sv)) {
- HvNAME_get(SvSTASH(sv))
- ? sv_sethek(dst, HvNAME_HEK(SvSTASH(sv)))
- : sv_setpvs(dst, "__ANON__");
+ if (HvHasNAME(SvSTASH(sv)))
+ sv_sethek(dst, HvNAME_HEK(SvSTASH(sv)));
+ else
+ sv_setpvs(dst, "__ANON__");
}
else {
const char * reftype = sv_reftype(sv, 0);
@@ -10774,7 +10775,7 @@ S_sv_unglob(pTHX_ SV *const sv, U32 flags)
SvREFCNT_inc_simple_void_NN(sv_2mortal(sv));
if (GvGP(sv)) {
if(GvCVu((const GV *)sv) && (stash = GvSTASH(MUTABLE_GV(sv)))
- && HvNAME_get(stash))
+ && HvHasNAME(stash))
mro_method_changed_in(stash);
gp_free(MUTABLE_GV(sv));
}