mirror of
https://github.com/golang/go
synced 2024-10-04 08:21:22 -06:00
cmd/6g, cmd/8g: simplify calls to gvardef
The gvardef function does nothing if n->class == PEXTERN, so we don't need to test for that before calling it. This makes the 6g/8g code more like the 5g code and clarifies that the cases that do not test for n->class != PEXTERN are not buggy. LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/68900044
This commit is contained in:
parent
3734663805
commit
fa6375ea47
@ -1389,11 +1389,11 @@ sgen(Node *n, Node *ns, int64 w)
|
|||||||
|
|
||||||
if(n->ullman >= ns->ullman) {
|
if(n->ullman >= ns->ullman) {
|
||||||
agenr(n, &nodr, N);
|
agenr(n, &nodr, N);
|
||||||
if(ns->op == ONAME && ns->class != PEXTERN)
|
if(ns->op == ONAME)
|
||||||
gvardef(ns);
|
gvardef(ns);
|
||||||
agenr(ns, &nodl, N);
|
agenr(ns, &nodl, N);
|
||||||
} else {
|
} else {
|
||||||
if(ns->op == ONAME && ns->class != PEXTERN)
|
if(ns->op == ONAME)
|
||||||
gvardef(ns);
|
gvardef(ns);
|
||||||
agenr(ns, &nodl, N);
|
agenr(ns, &nodl, N);
|
||||||
agenr(n, &nodr, N);
|
agenr(n, &nodr, N);
|
||||||
@ -1575,7 +1575,7 @@ componentgen(Node *nr, Node *nl)
|
|||||||
switch(nl->type->etype) {
|
switch(nl->type->etype) {
|
||||||
case TARRAY:
|
case TARRAY:
|
||||||
// componentgen for arrays.
|
// componentgen for arrays.
|
||||||
if(nl->op == ONAME && nl->class != PEXTERN)
|
if(nl->op == ONAME)
|
||||||
gvardef(nl);
|
gvardef(nl);
|
||||||
t = nl->type;
|
t = nl->type;
|
||||||
if(!isslice(t)) {
|
if(!isslice(t)) {
|
||||||
@ -1626,7 +1626,7 @@ componentgen(Node *nr, Node *nl)
|
|||||||
goto yes;
|
goto yes;
|
||||||
|
|
||||||
case TSTRING:
|
case TSTRING:
|
||||||
if(nl->op == ONAME && nl->class != PEXTERN)
|
if(nl->op == ONAME)
|
||||||
gvardef(nl);
|
gvardef(nl);
|
||||||
nodl.xoffset += Array_array;
|
nodl.xoffset += Array_array;
|
||||||
nodl.type = ptrto(types[TUINT8]);
|
nodl.type = ptrto(types[TUINT8]);
|
||||||
@ -1651,7 +1651,7 @@ componentgen(Node *nr, Node *nl)
|
|||||||
goto yes;
|
goto yes;
|
||||||
|
|
||||||
case TINTER:
|
case TINTER:
|
||||||
if(nl->op == ONAME && nl->class != PEXTERN)
|
if(nl->op == ONAME)
|
||||||
gvardef(nl);
|
gvardef(nl);
|
||||||
nodl.xoffset += Array_array;
|
nodl.xoffset += Array_array;
|
||||||
nodl.type = ptrto(types[TUINT8]);
|
nodl.type = ptrto(types[TUINT8]);
|
||||||
@ -1676,7 +1676,7 @@ componentgen(Node *nr, Node *nl)
|
|||||||
goto yes;
|
goto yes;
|
||||||
|
|
||||||
case TSTRUCT:
|
case TSTRUCT:
|
||||||
if(nl->op == ONAME && nl->class != PEXTERN)
|
if(nl->op == ONAME)
|
||||||
gvardef(nl);
|
gvardef(nl);
|
||||||
loffset = nodl.xoffset;
|
loffset = nodl.xoffset;
|
||||||
roffset = nodr.xoffset;
|
roffset = nodr.xoffset;
|
||||||
|
@ -1384,7 +1384,7 @@ componentgen(Node *nr, Node *nl)
|
|||||||
|
|
||||||
switch(nl->type->etype) {
|
switch(nl->type->etype) {
|
||||||
case TARRAY:
|
case TARRAY:
|
||||||
if(nl->op == ONAME && nl->class != PEXTERN)
|
if(nl->op == ONAME)
|
||||||
gvardef(nl);
|
gvardef(nl);
|
||||||
nodl.xoffset += Array_array;
|
nodl.xoffset += Array_array;
|
||||||
nodl.type = ptrto(nl->type->type);
|
nodl.type = ptrto(nl->type->type);
|
||||||
@ -1419,7 +1419,7 @@ componentgen(Node *nr, Node *nl)
|
|||||||
goto yes;
|
goto yes;
|
||||||
|
|
||||||
case TSTRING:
|
case TSTRING:
|
||||||
if(nl->op == ONAME && nl->class != PEXTERN)
|
if(nl->op == ONAME)
|
||||||
gvardef(nl);
|
gvardef(nl);
|
||||||
nodl.xoffset += Array_array;
|
nodl.xoffset += Array_array;
|
||||||
nodl.type = ptrto(types[TUINT8]);
|
nodl.type = ptrto(types[TUINT8]);
|
||||||
@ -1444,7 +1444,7 @@ componentgen(Node *nr, Node *nl)
|
|||||||
goto yes;
|
goto yes;
|
||||||
|
|
||||||
case TINTER:
|
case TINTER:
|
||||||
if(nl->op == ONAME && nl->class != PEXTERN)
|
if(nl->op == ONAME)
|
||||||
gvardef(nl);
|
gvardef(nl);
|
||||||
nodl.xoffset += Array_array;
|
nodl.xoffset += Array_array;
|
||||||
nodl.type = ptrto(types[TUINT8]);
|
nodl.type = ptrto(types[TUINT8]);
|
||||||
|
Loading…
Reference in New Issue
Block a user