mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-19 05:09:07 +02:00
fcl-passrc: useanalyzer: collect proc references only for implprocs
git-svn-id: trunk@38377 -
This commit is contained in:
parent
93ec82315a
commit
a1033eb1af
@ -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;
|
||||
|
@ -2267,7 +2267,7 @@ begin
|
||||
' b:=i;',
|
||||
'end;',
|
||||
'']);
|
||||
Analyzer.Options:=Analyzer.Options+[paoProcReferences];
|
||||
Analyzer.Options:=Analyzer.Options+[paoProcImplReferences];
|
||||
AnalyzeUnit;
|
||||
CheckUnitProcedureReferences('DoIt',['i','tintcolor']);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user