diff options
author | Oleg Nesterov <oleg@redhat.com> | 2020-02-04 17:51:40 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-02-06 03:36:29 +0100 |
commit | cac470f792eb320c243f5084f609276380fd539d (patch) | |
tree | ecfa94297bacb9e3697377992557a541fb2045cf | |
parent | c7b778b311d373ec5a2ff0f6af2855a4c6c4b01d (diff) | |
download | sparse-cac470f792eb320c243f5084f609276380fd539d.tar.gz |
dissect: turn mk_name() into deanon()
Preparation. Change mk_name() to initialize base->ident itself, simplify it,
and rename to deanon().
Also change examine_sym_node() to accept "struct symbol *parent" rather than
"struct ident *root". Currently it is only used as ->ident holder, but this
will be changed.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | dissect.c | 24 |
1 files changed, 14 insertions, 10 deletions
@@ -190,18 +190,22 @@ static struct symbol *report_symbol(usage_t mode, struct expression *expr) return ret; } -static inline struct ident *mk_name(struct ident *root, struct ident *node) +static bool deanon(struct symbol *base, struct ident *node, struct symbol *parent) { + struct ident *pi = parent ? parent->ident : NULL; char name[256]; + if (!node) + return false; + snprintf(name, sizeof(name), "%.*s:%.*s", - root ? root->len : 0, root ? root->name : "", - node ? node->len : 0, node ? node->name : ""); + pi ? pi->len : 0, pi ? pi->name : NULL, node->len, node->name); - return built_in_ident(name); + base->ident = built_in_ident(name); + return true; } -static void examine_sym_node(struct symbol *node, struct ident *root) +static void examine_sym_node(struct symbol *node, struct symbol *parent) { struct symbol *base; struct ident *name; @@ -232,12 +236,12 @@ static void examine_sym_node(struct symbol *node, struct ident *root) return; base->evaluated = 1; - if (!base->ident && name) - base->ident = mk_name(root, name); - if (base->ident && reporter->r_symdef) - reporter->r_symdef(base); + if (base->ident || deanon(base, name, parent)) { + if (reporter->r_symdef) + reporter->r_symdef(base); + } DO_LIST(base->symbol_list, mem, - examine_sym_node(mem, base->ident ?: root)); + examine_sym_node(mem, base->ident ? base : parent)); default: return; } |