aboutsummaryrefslogtreecommitdiffstats
path: root/symbol.c
diff options
context:
space:
mode:
authorJosh Triplett <josht@us.ibm.com>2006-08-30 10:14:53 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2006-08-30 16:07:55 -0700
commit37475a6c1c3e66219e68d912d5eb833f4098fd72 (patch)
treed4b87d24a087663e44c900929f3f7cd5b8cc9914 /symbol.c
parentc974e38bfdf1484f39b473577f1dd047706384e4 (diff)
downloadsparse-37475a6c1c3e66219e68d912d5eb833f4098fd72.tar.gz
[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 'symbol.c')
-rw-r--r--symbol.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/symbol.c b/symbol.c
index 48563490..1ebfd560 100644
--- a/symbol.c
+++ b/symbol.c
@@ -53,6 +53,11 @@ struct symbol *lookup_symbol(struct ident *ident, enum namespace ns)
return sym;
}
+struct context *alloc_context(void)
+{
+ return __alloc_context(0);
+}
+
struct symbol *alloc_symbol(struct position pos, int type)
{
struct symbol *sym = __alloc_symbol(0);
@@ -247,8 +252,8 @@ void merge_type(struct symbol *sym, struct symbol *base_type)
{
sym->ctype.as |= base_type->ctype.as;
sym->ctype.modifiers |= (base_type->ctype.modifiers & ~MOD_STORAGE);
- sym->ctype.in_context += base_type->ctype.in_context;
- sym->ctype.out_context += base_type->ctype.out_context;
+ concat_ptr_list((struct ptr_list *)base_type->ctype.contexts,
+ (struct ptr_list **)&sym->ctype.contexts);
sym->ctype.base_type = base_type->ctype.base_type;
}