mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-03 22:53:33 +01:00
* removed "and not is_class()" condition from is_managed_type(), because
tobjectdef.needs_inittable returns false for classes nowadays (and already
since quite some time)
* nevertheless replaced all usages in the compiler of x.needs_inittable with
is_managed_type(x) (in case some other condition is added again in the
future) and removed all remaining accompanying "and not is_class(x)"
checks
git-svn-id: trunk@15320 -
This commit is contained in:
parent
40705a085f
commit
f5c52b25cd
@ -99,7 +99,7 @@ interface
|
||||
function is_in_limit(def_from,def_to : tdef) : boolean;
|
||||
|
||||
{# Returns whether def is reference counted }
|
||||
function is_managed_type(def: tdef) : boolean;
|
||||
function is_managed_type(def: tdef) : boolean;{$ifdef USEINLINE}inline;{$endif}
|
||||
|
||||
|
||||
{ function is_in_limit_value(val_from:TConstExprInt;def_from,def_to : tdef) : boolean;}
|
||||
@ -526,11 +526,9 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
function is_managed_type(def: tdef): boolean;
|
||||
function is_managed_type(def: tdef): boolean;{$ifdef USEINLINE}inline;{$endif}
|
||||
begin
|
||||
result:=
|
||||
def.needs_inittable and
|
||||
not is_class(def);
|
||||
result:=def.needs_inittable;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
@ -923,10 +923,8 @@ implementation
|
||||
begin
|
||||
{ look for type conversion nodes which convert a }
|
||||
{ refcounted type into a non-refcounted type }
|
||||
if (not n.resultdef.needs_inittable or
|
||||
is_class(n.resultdef)) and
|
||||
(ttypeconvnode(n).left.resultdef.needs_inittable and
|
||||
not is_class(ttypeconvnode(n).left.resultdef)) then
|
||||
if not is_managed_type(n.resultdef) and
|
||||
is_managed_type(ttypeconvnode(n).left.resultdef) then
|
||||
exit;
|
||||
n:=ttypeconvnode(n).left;
|
||||
end;
|
||||
@ -2160,7 +2158,7 @@ implementation
|
||||
not assigned(funcretnode) and
|
||||
(
|
||||
(cnf_do_inline in callnodeflags) or
|
||||
resultdef.needs_inittable or
|
||||
is_managed_type(resultdef) or
|
||||
paramanager.ret_in_param(resultdef,procdefinition.proccalloption)
|
||||
) then
|
||||
begin
|
||||
|
||||
@ -396,8 +396,7 @@ interface
|
||||
internalerror(200108222);
|
||||
|
||||
{ get a (persistent) temp }
|
||||
if (tempinfo^.typedef.needs_inittable) and
|
||||
not is_class(tempinfo^.typedef) then
|
||||
if is_managed_type(tempinfo^.typedef) then
|
||||
begin
|
||||
location_reset_ref(tempinfo^.location,LOC_REFERENCE,def_cgsize(tempinfo^.typedef),0);
|
||||
tg.GetTempTyped(current_asmdata.CurrAsmList,tempinfo^.typedef,tempinfo^.temptype,tempinfo^.location.reference);
|
||||
|
||||
@ -163,7 +163,7 @@ implementation
|
||||
|
||||
{ release memory for refcnt out parameters }
|
||||
if (parasym.varspez=vs_out) and
|
||||
(left.resultdef.needs_inittable) then
|
||||
is_managed_type(left.resultdef) then
|
||||
begin
|
||||
location_get_data_ref(current_asmdata.CurrAsmList,left.location,href,false,sizeof(pint));
|
||||
cg.g_decrrefcount(current_asmdata.CurrAsmList,left.resultdef,href);
|
||||
@ -455,7 +455,7 @@ implementation
|
||||
we have used a temp, because then it is already done from tempcreatenode.
|
||||
Also no finalize is needed, because there is no risk of exceptions from the
|
||||
function since this is code is only executed after the function call has returned }
|
||||
if funcretnode.resultdef.needs_inittable and
|
||||
if is_managed_type(funcretnode.resultdef) and
|
||||
(funcretnode.nodetype<>temprefn) then
|
||||
cg.g_decrrefcount(current_asmdata.CurrAsmList,funcretnode.resultdef,funcretnode.location.reference);
|
||||
|
||||
@ -496,7 +496,7 @@ implementation
|
||||
case location.loc of
|
||||
LOC_REFERENCE :
|
||||
begin
|
||||
if resultdef.needs_inittable then
|
||||
if is_managed_type(resultdef) then
|
||||
cg.g_finalize(current_asmdata.CurrAsmList,resultdef,location.reference);
|
||||
tg.ungetiftemp(current_asmdata.CurrAsmList,location.reference);
|
||||
end;
|
||||
|
||||
@ -153,8 +153,7 @@ implementation
|
||||
([fc_inflowcontrol,fc_gotolabel] * flowcontrol <> []) or
|
||||
{ not for refcounted types, because those locations are }
|
||||
{ still used later on in initialisation/finalisation code }
|
||||
(not(is_class(n.resultdef)) and
|
||||
n.resultdef.needs_inittable) or
|
||||
is_managed_type(n.resultdef) or
|
||||
{ source and destination are temps (= not global variables) }
|
||||
not tg.istemp(n.location.reference) or
|
||||
not tg.istemp(newref) or
|
||||
@ -582,13 +581,13 @@ implementation
|
||||
loading the left node afterwards can destroy the flags.
|
||||
}
|
||||
if not(right.expectloc in [LOC_FLAGS,LOC_JUMP]) and
|
||||
((right.resultdef.needs_inittable) or
|
||||
(is_managed_type(right.resultdef) or
|
||||
(node_complexity(right)>node_complexity(left))) then
|
||||
begin
|
||||
secondpass(right);
|
||||
{ increment source reference counter, this is
|
||||
useless for constants }
|
||||
if (right.resultdef.needs_inittable) and
|
||||
if is_managed_type(right.resultdef) and
|
||||
not is_constnode(right) then
|
||||
begin
|
||||
location_force_mem(current_asmdata.CurrAsmList,right.location);
|
||||
@ -602,7 +601,7 @@ implementation
|
||||
{ can be false }
|
||||
secondpass(left);
|
||||
{ decrement destination reference counter }
|
||||
if (left.resultdef.needs_inittable) then
|
||||
if is_managed_type(left.resultdef) then
|
||||
begin
|
||||
location_get_data_ref(current_asmdata.CurrAsmList,left.location,href,false,sizeof(pint));
|
||||
cg.g_decrrefcount(current_asmdata.CurrAsmList,left.resultdef,href);
|
||||
@ -615,7 +614,7 @@ implementation
|
||||
{ calculate left sides }
|
||||
secondpass(left);
|
||||
{ decrement destination reference counter }
|
||||
if (left.resultdef.needs_inittable) then
|
||||
if is_managed_type(left.resultdef) then
|
||||
begin
|
||||
location_get_data_ref(current_asmdata.CurrAsmList,left.location,href,false,sizeof(pint));
|
||||
cg.g_decrrefcount(current_asmdata.CurrAsmList,left.resultdef,href);
|
||||
@ -635,7 +634,7 @@ implementation
|
||||
flowcontrol:=oldflowcontrol;
|
||||
{ increment source reference counter, this is
|
||||
useless for string constants}
|
||||
if (right.resultdef.needs_inittable) and
|
||||
if is_managed_type(right.resultdef) and
|
||||
(right.nodetype<>stringconstn) then
|
||||
begin
|
||||
location_force_mem(current_asmdata.CurrAsmList,right.location);
|
||||
@ -1171,7 +1170,7 @@ implementation
|
||||
else
|
||||
{ normal array constructor of the same type }
|
||||
begin
|
||||
if resultdef.needs_inittable then
|
||||
if is_managed_type(resultdef) then
|
||||
freetemp:=false;
|
||||
case hp.left.location.loc of
|
||||
LOC_MMREGISTER,
|
||||
|
||||
@ -1223,7 +1223,7 @@ implementation
|
||||
if ((tsym(p).typ=localvarsym) or
|
||||
((tsym(p).typ=paravarsym) and
|
||||
(vo_is_funcret in tparavarsym(p).varoptions))) and
|
||||
not(tabstractnormalvarsym(p).vardef.needs_inittable) and
|
||||
not(is_managed_type(tabstractnormalvarsym(p).vardef)) and
|
||||
not(assigned(tabstractnormalvarsym(p).defaultconstsym)) then
|
||||
begin
|
||||
trashintval := trashintvalues[localvartrashing];
|
||||
@ -1324,8 +1324,7 @@ implementation
|
||||
) and
|
||||
not(vo_is_typed_const in tabstractvarsym(p).varoptions) and
|
||||
not(vo_is_external in tabstractvarsym(p).varoptions) and
|
||||
not(is_class(tabstractvarsym(p).vardef)) and
|
||||
tabstractvarsym(p).vardef.needs_inittable then
|
||||
is_managed_type(tabstractvarsym(p).vardef) then
|
||||
begin
|
||||
OldAsmList:=current_asmdata.CurrAsmList;
|
||||
current_asmdata.CurrAsmList:=TAsmList(arg);
|
||||
@ -1361,8 +1360,7 @@ implementation
|
||||
(tlocalvarsym(p).refs>0) and
|
||||
not(vo_is_external in tlocalvarsym(p).varoptions) and
|
||||
not(vo_is_funcret in tlocalvarsym(p).varoptions) and
|
||||
not(is_class(tlocalvarsym(p).vardef)) and
|
||||
tlocalvarsym(p).vardef.needs_inittable then
|
||||
is_managed_type(tlocalvarsym(p).vardef) then
|
||||
finalize_sym(TAsmList(arg),tsym(p));
|
||||
end;
|
||||
|
||||
@ -1388,8 +1386,7 @@ implementation
|
||||
(tstaticvarsym(p).varspez<>vs_const) and
|
||||
not(vo_is_funcret in tstaticvarsym(p).varoptions) and
|
||||
not(vo_is_external in tstaticvarsym(p).varoptions) and
|
||||
not(is_class(tstaticvarsym(p).vardef)) and
|
||||
tstaticvarsym(p).vardef.needs_inittable then
|
||||
is_managed_type(tstaticvarsym(p).vardef) then
|
||||
finalize_sym(TAsmList(arg),tsym(p));
|
||||
end;
|
||||
procsym :
|
||||
@ -1420,10 +1417,8 @@ implementation
|
||||
list:=TAsmList(arg);
|
||||
if (tsym(p).typ=paravarsym) then
|
||||
begin
|
||||
needs_inittable :=
|
||||
not is_class(tparavarsym(p).vardef) and
|
||||
tparavarsym(p).vardef.needs_inittable;
|
||||
do_trashing :=
|
||||
needs_inittable:=is_managed_type(tparavarsym(p).vardef);
|
||||
do_trashing:=
|
||||
(localvartrashing <> -1) and
|
||||
(not assigned(tparavarsym(p).defaultconstsym)) and
|
||||
not needs_inittable;
|
||||
@ -1499,8 +1494,7 @@ implementation
|
||||
if not(tsym(p).typ=paravarsym) then
|
||||
exit;
|
||||
list:=TAsmList(arg);
|
||||
if not is_class(tparavarsym(p).vardef) and
|
||||
tparavarsym(p).vardef.needs_inittable then
|
||||
if is_managed_type(tparavarsym(p).vardef) then
|
||||
begin
|
||||
if (tparavarsym(p).varspez=vs_value) then
|
||||
begin
|
||||
@ -1532,7 +1526,7 @@ implementation
|
||||
while assigned(hp) do
|
||||
begin
|
||||
if assigned(hp^.def) and
|
||||
hp^.def.needs_inittable then
|
||||
is_managed_type(hp^.def) then
|
||||
begin
|
||||
reference_reset_base(href,current_procinfo.framepointer,hp^.pos,sizeof(pint));
|
||||
cg.g_initialize(list,hp^.def,href);
|
||||
@ -1551,7 +1545,7 @@ implementation
|
||||
while assigned(hp) do
|
||||
begin
|
||||
if assigned(hp^.def) and
|
||||
hp^.def.needs_inittable then
|
||||
is_managed_type(hp^.def) then
|
||||
begin
|
||||
include(current_procinfo.flags,pi_needs_implicit_finally);
|
||||
reference_reset_base(href,current_procinfo.framepointer,hp^.pos,sizeof(pint));
|
||||
@ -1587,7 +1581,8 @@ implementation
|
||||
ressym:=tabstractnormalvarsym(current_procinfo.procdef.parast.Find('self'))
|
||||
else
|
||||
ressym:=tabstractnormalvarsym(current_procinfo.procdef.funcretsym);
|
||||
if (ressym.refs>0) or (ressym.vardef.needs_inittable) then
|
||||
if (ressym.refs>0) or
|
||||
is_managed_type(ressym.vardef) then
|
||||
begin
|
||||
restmploc:=ressym.localloc;
|
||||
|
||||
|
||||
@ -666,8 +666,7 @@ implementation
|
||||
exit;
|
||||
|
||||
{ assignment to refcounted variable -> inc/decref }
|
||||
if (not is_class(left.resultdef) and
|
||||
left.resultdef.needs_inittable) then
|
||||
if is_managed_type(left.resultdef) then
|
||||
include(current_procinfo.flags,pi_do_call);
|
||||
|
||||
if (is_shortstring(left.resultdef)) then
|
||||
@ -689,7 +688,7 @@ implementation
|
||||
end;
|
||||
end
|
||||
{ call helpers for composite types containing automated types }
|
||||
else if (left.resultdef.needs_inittable) and
|
||||
else if is_managed_type(left.resultdef) and
|
||||
(left.resultdef.typ in [arraydef,objectdef,recorddef]) and
|
||||
not is_interfacecom(left.resultdef) and
|
||||
not is_dynamic_array(left.resultdef) then
|
||||
|
||||
@ -35,7 +35,7 @@ unit opttail;
|
||||
uses
|
||||
globtype,
|
||||
symconst,symsym,
|
||||
defcmp,
|
||||
defcmp,defutil,
|
||||
nutils,nbas,nflw,ncal,nld,ncnv,
|
||||
pass_1,
|
||||
paramgr;
|
||||
@ -192,7 +192,7 @@ unit opttail;
|
||||
and slow down things anyways so a tail recursion call
|
||||
makes no sense
|
||||
}
|
||||
vardef.needs_inittable) then
|
||||
is_managed_type(vardef)) then
|
||||
exit;
|
||||
|
||||
labelsym:=tlabelsym.create('$opttail');
|
||||
|
||||
@ -396,7 +396,7 @@ implementation
|
||||
exit;
|
||||
with tparavarsym(p) do
|
||||
begin
|
||||
if not vardef.needs_inittable and
|
||||
if not is_managed_type(vardef) and
|
||||
paramanager.push_addr_param(varspez,vardef,tprocdef(arg).proccalloption) then
|
||||
varregable:=vr_intreg;
|
||||
end;
|
||||
|
||||
@ -1480,7 +1480,7 @@ implementation
|
||||
{ types that use init/final are not allowed in variant parts, but
|
||||
classes are allowed }
|
||||
if (variantrecordlevel>0) and
|
||||
(hdef.needs_inittable and not is_class(hdef)) then
|
||||
is_managed_type(hdef) then
|
||||
Message(parser_e_cant_use_inittable_here);
|
||||
|
||||
{ try to parse the hint directives }
|
||||
|
||||
@ -312,7 +312,7 @@ implementation
|
||||
ccallnode.createintern('fpc_getmem',para)));
|
||||
|
||||
{ create call to fpc_initialize }
|
||||
if tpointerdef(p.resultdef).pointeddef.needs_inittable then
|
||||
if is_managed_type(tpointerdef(p.resultdef).pointeddef) then
|
||||
addstatement(newstatement,initialize_data_node(cderefnode.create(ctemprefnode.create(temp))));
|
||||
|
||||
{ copy the temp to the destination }
|
||||
@ -326,7 +326,7 @@ implementation
|
||||
else
|
||||
begin
|
||||
{ create call to fpc_finalize }
|
||||
if tpointerdef(p.resultdef).pointeddef.needs_inittable then
|
||||
if is_managed_type(tpointerdef(p.resultdef).pointeddef) then
|
||||
addstatement(newstatement,finalize_data_node(cderefnode.create(p.getcopy)));
|
||||
|
||||
{ create call to fpc_freemem }
|
||||
@ -394,7 +394,7 @@ implementation
|
||||
ccallnode.createintern('fpc_getmem',para)));
|
||||
|
||||
{ create call to fpc_initialize }
|
||||
if tpointerdef(p1.resultdef).pointeddef.needs_inittable then
|
||||
if is_managed_type(tpointerdef(p1.resultdef).pointeddef) then
|
||||
begin
|
||||
para := ccallparanode.create(caddrnode.create_internal(crttinode.create
|
||||
(tstoreddef(tpointerdef(p1.resultdef).pointeddef),initrtti,rdt_normal)),
|
||||
|
||||
@ -148,8 +148,7 @@ implementation
|
||||
begin
|
||||
if (tsym(p).typ=paravarsym) and
|
||||
(tparavarsym(p).varspez=vs_value) and
|
||||
not is_class(tparavarsym(p).vardef) and
|
||||
tparavarsym(p).vardef.needs_inittable then
|
||||
is_managed_type(tparavarsym(p).vardef) then
|
||||
include(current_procinfo.flags,pi_needs_implicit_finally);
|
||||
end;
|
||||
|
||||
@ -160,8 +159,7 @@ implementation
|
||||
{ occurs }
|
||||
if (tsym(p).typ=localvarsym) and
|
||||
(tlocalvarsym(p).refs>0) and
|
||||
not(is_class(tlocalvarsym(p).vardef)) and
|
||||
tlocalvarsym(p).vardef.needs_inittable then
|
||||
is_managed_type(tlocalvarsym(p).vardef) then
|
||||
include(current_procinfo.flags,pi_needs_implicit_finally);
|
||||
end;
|
||||
|
||||
@ -419,7 +417,7 @@ implementation
|
||||
if is_object(current_objectdef) then
|
||||
begin
|
||||
{ finalize object data }
|
||||
if current_objectdef.needs_inittable then
|
||||
if is_managed_type(current_objectdef) then
|
||||
addstatement(newstatement,finalize_data_node(load_self_node));
|
||||
{ parameter 3 : vmt_offset }
|
||||
{ parameter 2 : pointer to vmt }
|
||||
@ -485,7 +483,7 @@ implementation
|
||||
{ no constructor }
|
||||
{ must be the return value finalized before reraising the exception? }
|
||||
if (not is_void(current_procinfo.procdef.returndef)) and
|
||||
(current_procinfo.procdef.returndef.needs_inittable) and
|
||||
is_managed_type(current_procinfo.procdef.returndef) and
|
||||
(not paramanager.ret_in_param(current_procinfo.procdef.returndef, current_procinfo.procdef.proccalloption)) and
|
||||
(not is_class(current_procinfo.procdef.returndef)) then
|
||||
addstatement(newstatement,finalize_data_node(load_result_node));
|
||||
@ -1509,9 +1507,8 @@ implementation
|
||||
if tsym(p).typ<>paravarsym then
|
||||
exit;
|
||||
with tparavarsym(p) do
|
||||
if (not is_class(vardef) and
|
||||
vardef.needs_inittable and
|
||||
(varspez in [vs_value,vs_out])) then
|
||||
if is_managed_type(vardef) and
|
||||
(varspez in [vs_value,vs_out]) then
|
||||
include(current_procinfo.flags,pi_do_call);
|
||||
end;
|
||||
|
||||
|
||||
@ -523,7 +523,7 @@ implementation
|
||||
{ restore symtable stack }
|
||||
symtablestack.pop(recst);
|
||||
if trecorddef(record_dec).is_packed and
|
||||
record_dec.needs_inittable then
|
||||
is_managed_type(record_dec) then
|
||||
Message(type_e_no_packed_inittable);
|
||||
end;
|
||||
|
||||
@ -829,7 +829,7 @@ implementation
|
||||
begin
|
||||
arrdef.elementdef:=tt2;
|
||||
if is_packed and
|
||||
tt2.needs_inittable then
|
||||
is_managed_type(tt2) then
|
||||
Message(type_e_no_packed_inittable);
|
||||
end;
|
||||
end;
|
||||
@ -1148,7 +1148,7 @@ implementation
|
||||
(st.symtabletype=globalsymtable) and
|
||||
not is_objc_class_or_protocol(def)
|
||||
) or
|
||||
def.needs_inittable or
|
||||
is_managed_type(def) or
|
||||
(ds_init_table_used in def.defstates) then
|
||||
RTTIWriter.write_rtti(def,initrtti);
|
||||
{ RTTI }
|
||||
|
||||
@ -741,8 +741,7 @@ implementation
|
||||
localvarsym,
|
||||
paravarsym :
|
||||
begin
|
||||
if not(is_class(tabstractvarsym(sym).vardef)) and
|
||||
tstoreddef(tabstractvarsym(sym).vardef).needs_inittable then
|
||||
if is_managed_type(tabstractvarsym(sym).vardef) then
|
||||
b_needs_init_final:=true;
|
||||
end;
|
||||
end;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user