diff options
author | Alexey Gladkov <gladkov.alexey@gmail.com> | 2021-11-02 15:06:45 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2022-05-21 10:59:45 +0200 |
commit | 62dafeef8ba83d210d0ce861476d4071f66fc34a (patch) | |
tree | 2de4c4c3bc145b263b810b3eed5c835980c909fb | |
parent | 99fe3982ff45fc0bef5e5e414b85f87143e71ce5 (diff) | |
download | sparse-62dafeef8ba83d210d0ce861476d4071f66fc34a.tar.gz |
dissect: Show typedefs
For indexing purposes, it is useful to see type definitions.
$ semind search __kernel_ulong_t
(def) include/uapi/asm-generic/posix_types.h 16 23 typedef unsigned long __kernel_ulong_t;
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | dissect.c | 13 | ||||
-rw-r--r-- | test-dissect.c | 2 |
2 files changed, 14 insertions, 1 deletions
@@ -615,6 +615,11 @@ static inline bool is_macro(struct symbol *sym) return (sym->namespace == NS_MACRO || sym->namespace == NS_UNDEF); } +static inline bool is_typedef(struct symbol *sym) +{ + return (sym->namespace == NS_TYPEDEF); +} + static inline struct symbol *do_symbol(struct symbol *sym) { struct symbol *type = base_type(sym); @@ -659,7 +664,7 @@ static void do_sym_list(struct symbol_list *list) static inline bool valid_namespace(enum namespace ns) { - return (ns == NS_MACRO || ns == NS_UNDEF || ns == NS_STRUCT || ns == NS_SYMBOL); + return (ns == NS_TYPEDEF || ns == NS_MACRO || ns == NS_UNDEF || ns == NS_STRUCT || ns == NS_SYMBOL); } static void do_file(char *file) @@ -673,6 +678,12 @@ static void do_file(char *file) DO_LIST(file_scope->symbols, sym, if (input_streams[sym->pos.stream].fd != -1 && valid_namespace(sym->namespace)) { + if (is_typedef(sym)) { + sym->kind = 't'; + reporter->r_symdef(sym); + continue; + } + if (is_macro(sym)) { sym->kind = 'd'; reporter->r_symdef(sym); diff --git a/test-dissect.c b/test-dissect.c index 3d870a97..65b205f8 100644 --- a/test-dissect.c +++ b/test-dissect.c @@ -63,6 +63,8 @@ static void r_symbol(unsigned mode, struct position *pos, struct symbol *sym) if (sym->type == SYM_STRUCT || sym->type == SYM_UNION) break; goto err; + case 't': + break; case 'f': if (sym->type != SYM_BAD && sym->ctype.base_type->type != SYM_FN) goto err; |