* [PATCH] sparse/dissect: change do_symbol(sym) to use sym->definition
@ 2026-01-11 17:28 Oleg Nesterov
0 siblings, 0 replies; only message in thread
From: Oleg Nesterov @ 2026-01-11 17:28 UTC (permalink / raw)
To: Chris Li, Luc Van Oostenryck; +Cc: Alexey Gladkov, linux-sparse
Test-case:
$ cat TEST.c
static inline void i_func(void) { FUNC(); }
static inline void i_func(void);
void func(void) { i_func(); }
$ ./test-dissect TEST.c
3:6 def f func void ( ... )
2:20 def f i_func void ( ... )
3:19 func --r f i_func void ( ... )
dissect reports the wrong position for the definition of i_func()
and doesn't inspect its body.
This is because the 2nd external_declaration() binds another SYM_NODE
to the same ident and lookup_symbol() called during parsing returns
the most recent one, which is then used by do_symbol().
With this patch:
$ ./test-dissect TEST.c
3:6 def f func void ( ... )
1:20 def f i_func void ( ... )
1:35 i_func --r f FUNC bad type
3:19 func --r f i_func void ( ... )
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
dissect.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/dissect.c b/dissect.c
index a0fda09c..f20522f0 100644
--- a/dissect.c
+++ b/dissect.c
@@ -630,12 +630,17 @@ static inline bool is_typedef(struct symbol *sym)
return (sym->namespace == NS_TYPEDEF);
}
-static struct symbol *do_symbol(struct symbol *sym)
+static struct symbol *do_symbol(struct symbol *__sym)
{
+ struct symbol *sym = __sym->definition ?: __sym;
struct symbol *type = base_type(sym);
struct symbol *dctx = dissect_ctx;
struct statement *stmt;
+ if (sym->inspected)
+ return type;
+ sym->inspected = 1;
+
reporter->r_symdef(sym);
switch (type->type) {
--
2.52.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-01-11 17:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-11 17:28 [PATCH] sparse/dissect: change do_symbol(sym) to use sym->definition Oleg Nesterov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox