diff options
author | 2006-08-30 10:14:53 -0700 | |
---|---|---|
committer | 2006-08-30 16:07:55 -0700 | |
commit | 37475a6c1c3e66219e68d912d5eb833f4098fd72 (patch) | |
tree | d4b87d24a087663e44c900929f3f7cd5b8cc9914 /show-parse.c | |
parent | [PATCH] Add -Wno-cast-truncate (diff) | |
download | sparse-37475a6c1c3e66219e68d912d5eb833f4098fd72.tar.gz sparse-37475a6c1c3e66219e68d912d5eb833f4098fd72.tar.bz2 sparse-37475a6c1c3e66219e68d912d5eb833f4098fd72.zip |
[PATCH] Parse and track multiple contexts by expression
sparse currently only tracks one global context for __context__ and
__attribute__((context)).
This adds support for parsing an additional argument to each of these
which gives a context expression. For __attribute__((context)), store
each context attribute as a separate context structure containing the
expression, the entry context, and the exit context, and keep a list of
these structures in the ctype. For __context__, store the context
expression in the context instruction. Modify the various frontends to
adapt to this change, without changing functionality.
This change should not affect parsing of programs which worked with
previous versions of sparse, unless those programs use comma expressions
as arguments to __context__ or __attribute__((context)), which seems
highly dubious and unlikely. sparse with -Wcontext generates identical
output with or without this change on Linux 2.6.18-rc4.
Signed-off-by: Josh Triplett <josh@freedesktop.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'show-parse.c')
-rw-r--r-- | show-parse.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/show-parse.c b/show-parse.c index 70a5b08..5437a62 100644 --- a/show-parse.c +++ b/show-parse.c @@ -50,18 +50,27 @@ static void do_debug_symbol(struct symbol *sym, int indent) [SYM_RESTRICT] = "rstr", [SYM_BAD] = "bad.", }; + struct context *context; + int i; if (!sym) return; - fprintf(stderr, "%.*s%s%3d:%lu %lx %s (as: %d, context: %x:%x) %p (%s:%d:%d)\n", + fprintf(stderr, "%.*s%s%3d:%lu %lx %s (as: %d) %p (%s:%d:%d)\n", indent, indent_string, typestr[sym->type], sym->bit_size, sym->ctype.alignment, - sym->ctype.modifiers, show_ident(sym->ident), - sym->ctype.as, sym->ctype.in_context, sym->ctype.out_context, + sym->ctype.modifiers, show_ident(sym->ident), sym->ctype.as, sym, stream_name(sym->pos.stream), sym->pos.line, sym->pos.pos); + i = 0; + FOR_EACH_PTR(sym->ctype.contexts, context) { + /* FIXME: should print context expression */ + fprintf(stderr, "< context%d: in=%d, out=%d\n", + i, context->in, context->out); + fprintf(stderr, " end context%d >\n", i); + i++; + } END_FOR_EACH_PTR(context); if (sym->type == SYM_FN) { - int i = 1; struct symbol *arg; + i = 0; FOR_EACH_PTR(sym->arguments, arg) { fprintf(stderr, "< arg%d:\n", i); do_debug_symbol(arg, 0); |