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

use ref in el_parent() #16379

Merged
merged 1 commit into from
Apr 14, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 14 additions & 14 deletions compiler/src/dmd/backend/elem.d
Original file line number Diff line number Diff line change
Expand Up @@ -1757,26 +1757,26 @@ elem *el_zero(type *t)
}

/*******************
* Find and return pointer to parent of e starting at *pe.
* Find and return pointer to parent of e starting at pe.
* Return null if can't find it.
*/

@trusted
elem ** el_parent(elem *e,elem **pe)
elem ** el_parent(elem *e, return ref elem* pe)
{
assert(e && pe && *pe);
assert(e && pe);
elem_debug(e);
elem_debug(*pe);
if (e == *pe)
return pe;
else if (OTunary((*pe).Eoper))
return el_parent(e,&((*pe).EV.E1));
else if (OTbinary((*pe).Eoper))
{
elem **pe2;
return ((pe2 = el_parent(e,&((*pe).EV.E1))) != null)
? pe2
: el_parent(e,&((*pe).EV.E2));
elem_debug(pe);
if (e == pe)
return &pe; // not @safe
else if (OTunary(pe.Eoper))
return el_parent(e, pe.EV.E1);
else if (OTbinary(pe.Eoper))
{
elem** pe2 = el_parent(e, pe.EV.E1);
if (pe2)
return pe2;
return el_parent(e, pe.EV.E2);
}
else
return null;
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dmd/backend/gloop.d
Original file line number Diff line number Diff line change
Expand Up @@ -2147,7 +2147,7 @@ private void findbasivs(ref Loop l)
go.defnod[j].DNelem.EV.E1.EV.Vsym == s &&
vec_testbit(go.defnod[j].DNblock.Bdfoidx,l.Lloop))
{
biv.IVincr = el_parent(go.defnod[j].DNelem,&(go.defnod[j].DNblock.Belem));
biv.IVincr = el_parent(go.defnod[j].DNelem, go.defnod[j].DNblock.Belem);
assert(s == (*biv.IVincr).EV.E1.EV.Vsym);

debug if (debugc)
Expand Down Expand Up @@ -2283,7 +2283,7 @@ private void findopeqs(ref Loop l)
go.defnod[j].DNelem.EV.E1.EV.Vsym == s &&
vec_testbit(go.defnod[j].DNblock.Bdfoidx,l.Lloop))
{
biv.IVincr = el_parent(go.defnod[j].DNelem,&(go.defnod[j].DNblock.Belem));
biv.IVincr = el_parent(go.defnod[j].DNelem, go.defnod[j].DNblock.Belem);
assert(s == (*biv.IVincr).EV.E1.EV.Vsym);

debug if (debugc)
Expand Down