14 static int extern_node_matches(struct name
*expected
, struct node
*node
)
16 int flags
= guess_name_flags(node
);
17 if (!modifiers_match(expected
, flags
) || expected
->flags
& NAME_STATIC
)
19 return !(flags
& (NAME_FIELD
| NAME_PARAMDECL
));
22 static int does_match(struct node
*node
, void *data
)
24 struct finddata
*finddata
= data
;
25 if ((node
->type
== AST_IDENTIFIER
|| node
->type
== AST_TYPENAME
) &&
26 !strcmp(finddata
->name
->name
, node
->data
)) {
27 struct block
*block
= block_find(finddata
->block
, node
->start
);
28 struct name
*name
= block_lookup(block
, node
);
29 if ((!name
&& extern_node_matches(finddata
->name
, node
)) ||
30 name
== finddata
->name
) {
31 struct hit
*hit
= xmalloc(sizeof(struct hit
));
32 hit
->start
= node
->start
;
34 hit
->cfile
= finddata
->cfile
;
35 hit
->next
= finddata
->hit
;
39 /* don't check nodes outside defining block */
43 static struct hit
*reverse(struct hit
*o
)
45 struct hit
*newhead
= NULL
;
48 struct hit
*next
= cur
->next
;
56 struct hit
*find_name(struct project
*project
, struct name
*name
)
59 struct finddata finddata
;
63 for (i
= project
->count
- 1; i
>= 0; --i
) {
64 struct cfile
*cur
= project
->files
[i
];
65 finddata
.block
= cur
->block
;
67 node_walk(cur
->node
, does_match
, &finddata
);
69 return reverse(finddata
.hit
);
74 void free_hits(struct hit
*hit_list
)
76 struct hit
*cur
= hit_list
;
78 struct hit
*next
= cur
->next
;