@@ -22,6 +22,7 @@ import type { REnvironmentInformation } from '../environments/environment';
2222import { findByPrefixIfUnique } from '../../util/prefix' ;
2323import type { ExitPoint } from '../info' ;
2424import { doesExitPointPropagateCalls } from '../info' ;
25+ import { UnnamedFunctionCallPrefix } from './process/functions/call/unnamed-call-handling' ;
2526
2627export type NameIdMap = DefaultMap < string , IdentifierReference [ ] >
2728
@@ -361,7 +362,7 @@ export function linkFunctionCalls(
361362 * convenience function returning all known call targets, as well as the name source which defines them
362363 */
363364export function getAllFunctionCallTargets ( call : NodeId , graph : DataflowGraph , environment ?: REnvironmentInformation ) : NodeId [ ] {
364- let found : NodeId [ ] = [ ] ;
365+ const found : Set < NodeId > = new Set ( ) ;
365366 const callVertex = graph . get ( call , true ) ;
366367 if ( callVertex === undefined ) {
367368 return [ ] ;
@@ -373,23 +374,31 @@ export function getAllFunctionCallTargets(call: NodeId, graph: DataflowGraph, en
373374 return [ ] ;
374375 }
375376
376- if ( info . name !== undefined && ( environment !== undefined || info . environment !== undefined ) ) {
377- const functionCallDefs = resolveByName (
378- info . name , environment ?? info . environment as REnvironmentInformation , info . origin . includes ( BuiltInProcName . S3Dispatch ) ? ReferenceType . S3MethodPrefix : ReferenceType . Function
379- ) ?. map ( d => d . nodeId ) ?? [ ] ;
377+ if ( environment !== undefined || info . environment !== undefined ) {
378+ let functionCallDefs : NodeId [ ] = [ ] ;
379+ if ( info . name !== undefined && ! info . name . startsWith ( UnnamedFunctionCallPrefix ) ) {
380+ functionCallDefs = resolveByName (
381+ info . name , environment ?? info . environment as REnvironmentInformation , info . origin . includes ( BuiltInProcName . S3Dispatch ) ? ReferenceType . S3MethodPrefix : ReferenceType . Function
382+ ) ?. map ( d => d . nodeId ) ?? [ ] ;
383+ }
380384 for ( const [ target , outgoingEdge ] of outgoingEdges . entries ( ) ) {
381385 if ( edgeIncludesType ( outgoingEdge . types , EdgeType . Calls ) ) {
382386 functionCallDefs . push ( target ) ;
383387 }
384388 }
389+
385390 const [ functionCallTargets , builtInTargets ] = getAllLinkedFunctionDefinitions ( new Set ( functionCallDefs ) , graph ) ;
386391 for ( const target of functionCallTargets ) {
387- found . push ( target . id ) ;
392+ found . add ( target . id ) ;
393+ }
394+ for ( const arr of [ builtInTargets , functionCallDefs ] ) {
395+ for ( const target of arr ) {
396+ found . add ( target ) ;
397+ }
388398 }
389- found = found . concat ( Array . from ( builtInTargets ) , functionCallDefs ) ;
390399 }
391400
392- return found ;
401+ return Array . from ( found ) ;
393402}
394403
395404const LinkedFnFollowBits = EdgeType . Reads | EdgeType . DefinedBy | EdgeType . DefinedByOnCall ;
0 commit comments