aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2020-02-05 13:53:18 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-02-06 03:37:12 +0100
commit100509c0789f1176fc5881da45917e9af77597ca (patch)
tree4b4f9965e5866c398fe65db6cc455cf315eb5ac0
parentb0f73c73c1f05f888321b4441a94758267c83703 (diff)
downloadsparse-100509c0789f1176fc5881da45917e9af77597ca.tar.gz
dissect: introduce reporter->r_memdef()
To report where is the member of struct/union defined. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--dissect.c12
-rw-r--r--dissect.h1
-rw-r--r--test-dissect.c6
3 files changed, 18 insertions, 1 deletions
diff --git a/dissect.c b/dissect.c
index 88eaab1c..60fccbdb 100644
--- a/dissect.c
+++ b/dissect.c
@@ -203,6 +203,12 @@ static bool deanon(struct symbol *base, struct ident *node, struct symbol *paren
return true;
}
+static void report_memdef(struct symbol *sym, struct symbol *mem)
+{
+ if (sym && mem->ident)
+ reporter->r_memdef(sym, mem);
+}
+
static void examine_sym_node(struct symbol *node, struct symbol *parent)
{
struct symbol *base;
@@ -236,8 +242,12 @@ static void examine_sym_node(struct symbol *node, struct symbol *parent)
if (base->ident || deanon(base, name, parent))
reporter->r_symdef(base);
+
+ if (base->ident)
+ parent = base;
DO_LIST(base->symbol_list, mem,
- examine_sym_node(mem, base->ident ? base : parent));
+ examine_sym_node(mem, parent);
+ report_memdef(parent, mem));
default:
return;
}
diff --git a/dissect.h b/dissect.h
index 664736ce..1f5b1d9e 100644
--- a/dissect.h
+++ b/dissect.h
@@ -19,6 +19,7 @@
struct reporter
{
void (*r_symdef)(struct symbol *);
+ void (*r_memdef)(struct symbol *, struct symbol *);
void (*r_symbol)(unsigned, struct position *, struct symbol *);
void (*r_member)(unsigned, struct position *, struct symbol *, struct symbol *);
diff --git a/test-dissect.c b/test-dissect.c
index af1212a0..e725eec5 100644
--- a/test-dissect.c
+++ b/test-dissect.c
@@ -75,10 +75,16 @@ static void r_symdef(struct symbol *sym)
r_symbol(-1, &sym->pos, sym);
}
+static void r_memdef(struct symbol *sym, struct symbol *mem)
+{
+ r_member(-1, &mem->pos, sym, mem);
+}
+
int main(int argc, char **argv)
{
static struct reporter reporter = {
.r_symdef = r_symdef,
+ .r_memdef = r_memdef,
.r_symbol = r_symbol,
.r_member = r_member,
};