From 5b4c6f96b20cd309026e42c02133b28d1e0e64df Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ji=C5=99=C3=AD=20Techet?= Date: Sun, 24 May 2015 21:06:55 +0200 Subject: [PATCH] Don't use anon_struct_* and similar members unless we are sure it's the right one We can only be sure it's the right one if we previously resolved a typedef to it and the typedef was in the same file. --- tagmanager/src/tm_workspace.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tagmanager/src/tm_workspace.c b/tagmanager/src/tm_workspace.c index e7a0d6ab6..8d23e4978 100644 --- a/tagmanager/src/tm_workspace.c +++ b/tagmanager/src/tm_workspace.c @@ -805,6 +805,7 @@ find_scope_members (const GPtrArray *tags_array, const char *name, langType lang gboolean namespace) { gboolean has_members = FALSE; + gboolean typedef_struct = FALSE; GPtrArray *tags = NULL; TMTag *tag = NULL; const gchar *type_name; @@ -839,6 +840,7 @@ find_scope_members (const GPtrArray *tags_array, const char *name, langType lang * too many (wrong) results. */ fill_find_tags_array(type_tags, tag->file->tags_array, type_name, NULL, types, FALSE, lang); + typedef_struct = type_tags->len > 0; } if (type_tags->len == 0) fill_find_tags_array(type_tags, tags_array, type_name, NULL, types, FALSE, lang); @@ -870,7 +872,10 @@ find_scope_members (const GPtrArray *tags_array, const char *name, langType lang } } - if (has_members) + /* ignore anon_struct_* and similar unless we resolved a typedef to it within + * a single file so we can be sure we don't pick a wrong anon_struct_* from + * a different file */ + if (has_members && (typedef_struct || !tm_tag_is_anon(tag))) /* use the same file as the composite type if file information available */ tags = find_scope_members_tags(tag->file ? tag->file->tags_array : tags_array, tag, namespace); -- 2.11.4.GIT