fcl-passrc: useanalyzer: collect proc references only for implprocs

git-svn-id: trunk@38377 -
This commit is contained in:
Mattias Gaertner 2018-02-28 13:49:13 +00:00
parent 93ec82315a
commit a1033eb1af
2 changed files with 23 additions and 16 deletions

View File

@ -147,7 +147,7 @@ type
TPasAnalyzerOption = (
paoOnlyExports, // default: use all class members accessible from outside (protected, but not private)
paoProcReferences // collect TPasProcedureScope.References of top lvl proc implementations
paoProcImplReferences // collect TPasProcedureScope.References of top lvl proc implementations
);
TPasAnalyzerOptions = set of TPasAnalyzerOption;
@ -656,23 +656,30 @@ end;
procedure TPasAnalyzer.MarkScopeRef(Parent, El: TPasElement;
Access: TPSRefAccess);
var
ParentProcScope, ElProcScope: TPasProcedureScope;
procedure CheckImplRef;
var
ParentProcScope, ElProcScope: TPasProcedureScope;
ImplProc: TPasProcedure;
begin
ParentProcScope:=FindTopProcScope(Parent,true);
if ParentProcScope=nil then exit;
ImplProc:=ParentProcScope.ImplProc;
if ImplProc=nil then
ImplProc:=TPasProcedure(ParentProcScope.Element);
if ImplProc.Body=nil then
exit; // has no implementation, e.g. external proc
ElProcScope:=FindTopProcScope(El,true);
if ElProcScope=ParentProcScope then exit;
ParentProcScope.AddReference(El,Access);
end;
begin
if El=nil then exit;
if El.Parent=Parent then exit; // same scope
if paoProcReferences in Options then
begin
ParentProcScope:=FindTopProcScope(Parent,true);
if ParentProcScope<>nil then
begin
ElProcScope:=FindTopProcScope(El,true);
if ElProcScope<>ParentProcScope then
begin
ParentProcScope.AddReference(El,Access);
end;
end;
end;
if paoProcImplReferences in Options then
CheckImplRef;
end;
procedure TPasAnalyzer.UseElement(El: TPasElement; Access: TResolvedRefAccess;

View File

@ -2267,7 +2267,7 @@ begin
' b:=i;',
'end;',
'']);
Analyzer.Options:=Analyzer.Options+[paoProcReferences];
Analyzer.Options:=Analyzer.Options+[paoProcImplReferences];
AnalyzeUnit;
CheckUnitProcedureReferences('DoIt',['i','tintcolor']);
end;