From: Oleg Nesterov <oleg@redhat.com>
To: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Cc: Alexey Gladkov <gladkov.alexey@gmail.com>, linux-sparse@vger.kernel.org
Subject: [PATCH] dissect: introduce reporter->r_memdef()
Date: Wed, 5 Feb 2020 13:53:18 +0100 [thread overview]
Message-ID: <20200205125318.GA14560@redhat.com> (raw)
To report where is the member of struct/union defined.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
dissect.c | 12 +++++++++++-
dissect.h | 1 +
test-dissect.c | 6 ++++++
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/dissect.c b/dissect.c
index 88eaab1..60fccbd 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 664736c..1f5b1d9 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 af1212a..e725eec 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,
};
--
2.5.0
reply other threads:[~2020-02-05 12:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200205125318.GA14560@redhat.com \
--to=oleg@redhat.com \
--cc=gladkov.alexey@gmail.com \
--cc=linux-sparse@vger.kernel.org \
--cc=luc.vanoostenryck@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.