|
@@ -57,7 +57,8 @@ interface
|
|
|
cnf_call_self_node_done,{ the call_self_node has been generated if necessary
|
|
|
(to prevent it from potentially happening again in a wrong context in case of constant propagation or so) }
|
|
|
cnf_ignore_visibility, { internally generated call that should ignore visibility checks }
|
|
|
- cnf_check_fpu_exceptions { after the call fpu exceptions shall be checked }
|
|
|
+ cnf_check_fpu_exceptions, { after the call fpu exceptions shall be checked }
|
|
|
+ cnf_ignore_devirt_wpo { ignore this call for devirtualisatio info tracking: calls to newinstance generated by the compiler do not result in extra class types being instanced }
|
|
|
);
|
|
|
tcallnodeflags = set of tcallnodeflag;
|
|
|
|
|
@@ -2560,10 +2561,22 @@ implementation
|
|
|
{ only makes sense for methods }
|
|
|
if not assigned(methodpointer) then
|
|
|
exit;
|
|
|
+ { inherited calls don't create an instance of the inherited type, but of
|
|
|
+ the current type }
|
|
|
+ if ([cnf_inherited,cnf_anon_inherited,cnf_ignore_devirt_wpo]*callnodeflags)<>[] then
|
|
|
+ exit;
|
|
|
if (methodpointer.resultdef.typ=classrefdef) then
|
|
|
begin
|
|
|
- { constructor call via classreference => allocate memory }
|
|
|
- if (procdefinition.proctypeoption=potype_constructor) then
|
|
|
+ { constructor call via classreference => instance can be created
|
|
|
+ same with calling newinstance without a instance-self (don't
|
|
|
+ consider self-based newinstance calls, because then everything
|
|
|
+ will be assumed to be just a TObject since TObject.Create calls
|
|
|
+ NewInstance) }
|
|
|
+ if (procdefinition.proctypeoption=potype_constructor) or
|
|
|
+ ((procdefinition.typ=procdef) and
|
|
|
+ ((methodpointer.resultdef.typ=classrefdef) or
|
|
|
+ (methodpointer.nodetype=typen)) and
|
|
|
+ (tprocdef(procdefinition).procsym.Name='NEWINSTANCE')) then
|
|
|
begin
|
|
|
{ Only a typenode can be passed when it is called with <class of xx>.create }
|
|
|
if (methodpointer.nodetype=typen) then
|