aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Fix build with GCC 4.6 series.v0.4.3-gentooDiego Elio Pettenò2011-04-081-4/+0
| | | | | | | The label_statement attribute in the anonymous structures' union was duplicated for label_arg and labeled_struct alises, which were identical. Since the former is never used, delete it and leave the other as the only copy.
* parser: add support for asm gotoJiri Slaby2010-06-171-0/+1
| | | | | | | | | As of gcc 4.5, asm goto("jmp %l[label]" : OUT : IN : CLOB : LABELS) is supported. Add this support to the parser so that it won't choke on the newest Linux kernel when compiling with gcc 4.5. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Simplify get_number_value() and ctype_integer()Al Viro2009-07-181-1/+1
| | | | | | | | | | | There's no point whatsoever in constructing modifiers for chosen type when decoding integer constant only to have them picked apart by ctype_integer(). Seeing that the former is the only caller of the latter these days, we can bloody well just pass the rank and signedness explicitly and save a lot of efforts. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <chrisl@hera.kernel.org>
* Rewrite and fix specifiers handlingAl Viro2009-07-171-1/+0
| | | | | | | | | | | | | | | | | | | | Make sure that we accept the right set; kill ad-hackery around checks for banned combinations. Instead of that we keep a bitmap describing what we'd already seen (with several extra bits for 'long long' and for keeping track of can't-combine-with-anything stuff), check and update it using the values in ..._op and keep track of size modifiers more or less explicitly. Testcases added. A _lot_ of that used to be done wrong. Note that __attribute__((mode(...))) got more broken by this one; the next several changesets will take care of that. One more thing: we are -><- close to getting rid of MOD_SPECIFIER bits for good. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Revert the context tracking codeJohannes Berg2008-12-241-2/+1
| | | | | | | | | | | | | | | | | | > Do you want to resend your change which revert the context changes? > Make it base on Josh's git's tree and I will merge your changes in my > branch. Below. Or I can give it to you in git if you prefer. I still think we should redo this in some form so that annotations with different contexts can work properly, but I don't have time to take care of it right now. johannes >From ca95b62edf1600a2b55ed9ca0515d049807a84fc Mon Sep 17 00:00:00 2001 From: Johannes Berg <johannes@sipsolutions.net> Date: Tue, 23 Dec 2008 10:53:19 +0100 Subject: [PATCH] Revert context tracking code
* make sparse keep its promise about context trackingJohannes Berg2008-04-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The sparse man page promises that it will check this: Functions with the extended attribute __attribute__((context(expression,in_context,out_context)) require the context expression (for instance, a lock) to have the value in_context (a constant nonnegative integer) when called, and return with the value out_context (a constant nonnegative integer). It doesn't keep that promise though, nor can it, especially with contexts that can be acquired recursively (like RCU in the kernel.) This patch makes sparse track different contexts, and also follows up on that promise, but with slightly different semantics: * the "require the context to have the value" is changed to require it to have /at least/ the value if 'in_context', * an exact_context(...) attribute is introduced with the previously described semantics (to be used for non-recursive contexts), * the __context__ statement is extended to also include a required context argument (same at least semantics), Unfortunately, I wasn't able to keep the same output, so now you'll see different messages from sparse, especially when trying to unlock a lock that isn't locked you'll see a message pointing to the unlock function rather than complaining about the basic block, you can see that in the test suite changes. This patch also contains test updates and a lot of new tests for the new functionality. Except for the changed messages, old functionality should not be affected. However, the kernel use of __attribute__((context(...)) is actually wrong, the kernel often does things like: static void *dev_mc_seq_start(struct seq_file *seq, loff_t * pos) __acquires(dev_base_lock) { [...] read_lock(&dev_base_lock); [...] } rather than static void *dev_mc_seq_start(struct seq_file *seq, loff_t * pos) __acquires(dev_base_lock) { [...] __acquire__(dev_base_lock); read_lock(&dev_base_lock); [...] } (and possibly more when read_lock() is annotated appropriately, such as dropping whatever context read_lock() returns to convert the context to the dev_base_lock one.) Currently, sparse doesn't care, but if it's going to check the context of functions contained within another function then we need to put the actual __acquire__ together with acquiring the context. The great benefit of this patch is that you can now document at least some locking assumptions in a machine-readable way: before: /* requires mylock held */ static void myfunc(void) {...} after: static void myfunc(void) __requires(mylock) {...} where, for sparse, #define __requires(x) __attribute__((context(x,1,1))) Doing so may result in lots of other functions that need to be annoated along with it because they also have the same locking requirements, but ultimately sparse can check a lot of locking assumptions that way. I have already used this patch and identify a number of kernel bugs by marking things to require certain locks or RCU-protection and checking sparse output. To do that, you need a few kernel patches which I'll send separately. Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
* Free up some special bits in modifiers.Josh Triplett2007-03-071-0/+1
| | | | | | | | | This change using symbol_op to contain the specifier parsing function. It is easier to add new specifiers. We don't need special bits any more. Signed-Off-By: Christopher Li <sparse@chrisli.org> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Josh Triplett <josh@freedesktop.org>
* Add annotation for inline function call.Christopher Li2007-03-021-0/+2
| | | | | | | | For inline functions, Sparse inlines the function body at evaluation. It is very hard to find out the original function call. This change preserves the original call as an annotation. Signed-Off-By: Christopher Li <sparse@chrisli.org>
* [PATCH] Parse and track multiple contexts by expressionJosh Triplett2006-08-301-1/+4
| | | | | | | | | | | | | | | | | | | | | | 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>
* Make local declarations be statements of their ownLinus Torvalds2005-12-311-1/+4
| | | | | | | | | | | This removes the list of symbols for block statements, and instead makes a declaration be a statement of its own. This is necessary to correctly handle the case of mixed statements and declarations correctly, since the order of declarations and statements is meaningful. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* Get closer to parsing multiple files correctly.Linus Torvalds2005-08-031-1/+1
| | | | | | This actually seems to do some sane things when parsing even complex multiple files. In particular, it actually works right when used for multiple kernel C files together in limited testing.
* [PATCH] static declearChristopher Li2005-04-071-0/+1
| | | | This patch add static declare to make sparse happy of checking itself.
* Add compile-time "range-check" infrastructure to sparseLinus Torvalds2005-04-071-1/+7
|
* Save away (most) of the asm information when parsing inline assembly.Linus Torvalds2005-04-071-0/+6
| | | | | The named parameter thing is still unsupported. And the format we save things into is for simple saving rather than real usability.
* Allow the C99/C++ mixed variable declaration syntax.Linus Torvalds2005-04-071-1/+0
| | | | Currently we warn unconditionally about it.
* Make "translation_unit()" do symbol evaluation too.Linus Torvalds2005-04-071-1/+1
| | | | | Not only do all users want it, the list of used symbols is not stable until after the tree has been evaluated.
* Add an internal sparse "context" statement type.Linus Torvalds2005-04-071-0/+1
| | | | | It just ends up propagating the expression to the linearizer, which creates an internal "context" instruction for it.
* Remove "match_string_ident" now that nothing uses it.Linus Torvalds2005-04-071-1/+0
| | | | | | | | | | | | It may well come back as a debugging and prototyping thing, but I'd rather remove it and have to re-introduce it, than have people use that stupid interface just "because it's there". Sparse is very good at hashing identifiers and making them all unique. So you really should never need to match by string, you can just compare "struct ident" pointers directly. Thanks to Chris for getting rid of the users.
* [PATCH] uninlining inline functionsAlexander Viro2005-04-071-0/+1
| | | | | | | | | | | | | | | | When we take the address of an inline function or otherwise refusing to inline it, we need to output the now non-inline function properly. What we do is a) keeping body and symbol list of inlined function in new fields b) when expanding inlined call use these fields c) when evaluating the function itself (which happens if sparse decides that it can't be [always] inlined) uninline the sucker. I.e. create ->stmt and ->symbol_list by copying the ->inline_stmt and ->inline_symbol_list same as we would do while expanding a call. That guarantees that we won't run into trouble with inlined calls coming afterwards - evaluation doesn't mangle ->inline_stmt anymore.
* Mondane cleanups at the level of typos.welinder@troll.com2005-04-071-2/+2
|
* Keep track of computed target label lists per-function.Linus Torvalds2005-04-071-0/+6
| | | | | Associate them with each computed goto, and copy them properly when inlining.
* Remove now-obsolete temporary statement types.Linus Torvalds2005-04-071-6/+0
| | | | | They were only used for the original pre-instruction linearization.
* Add proper linearization of switch statements.Linus Torvalds2005-04-071-0/+7
|
* Split "STMT_GOTO_BB" into "STMT_CONDTRUE" and "STMT_CONDFALSE".Linus Torvalds2005-04-071-1/+2
| | | | This lets us get the type of comparison right.
* Linearize iterators, at least a first try at it.Linus Torvalds2005-04-071-1/+1
| | | | | | As with labels, this required us to do indirection through a symbol for branch targets. Now everything is handled that way, and things look a lot saner.
* Add real flow control to the basic-block handling.Linus Torvalds2005-04-071-0/+7
| | | | | Right now we only really do trivial if-statements, but the ideas are all there now.
* Update copyright notices to reflect the fact that TransmetaLinus Torvalds2005-04-071-0/+1
| | | | isn't the sole copyright owner these days.
* Clean up function inlining some, and fix the type of theLinus Torvalds2005-04-071-0/+1
| | | | | argument symbols that got corrupted by the incorrect partial symbol copy when creating the new argument symbols.
* [PATCH] Make all the anonymous structures truly anonymousRyan Anderson2005-04-071-9/+9
| | | | | | This patch removes the type-names on the anonymous structures. This fixes compilation when using gcc-3.3 (Debian). Credit for identifying the fix goes to Arnaldo Carvalho de Melo <acme@conectiva.com.br>.
* Create "inline.c", which contains the function "copy_statement()",Linus Torvalds2005-04-071-0/+1
| | | | | | | | used for inlining. Right now the copying is totally broken, since we don't actually do any symbol replacement, but hey, we'll get there some day. Make "inline_function()" call the new copy_statement() function.
* Make function returns a bit more realisticLinus Torvalds2005-04-071-0/+5
|
* Simplify if-statements without even evaluating the false sideLinus Torvalds2005-04-071-1/+0
| | | | | | | for compile-time constant conditionals. This allows inline functions and macros to do "illegal" things, as long as it's compile-time deterministic that they aren't done.
* Parse and evaluate gcc computed goto extensions: label addressingLinus Torvalds2005-04-071-0/+1
| | | | | | | | (&&label) and computed goto (goto *expr). Add label ctype for __label__ identifier. This is still quite broken (it should create a block-symbol in the NS_LABEL namespace, right now it creates a regular symbol).
* Parse C99 style 'for()' statements with variable declarations.Linus Torvalds2005-04-071-0/+1
|
* Fix switch/case statement show-parse.Linus Torvalds2005-04-071-0/+1
|
* Add comments about special terator/switch statement symbols.Linus Torvalds2005-04-071-1/+1
| | | | | | Add a "case" symbol for the switch statement, to let the statement keep track of all the cases. This cleans up handling a lot.
* Start updating the copyright license comments to the OSL,Linus Torvalds2005-04-071-1/+3
| | | | preparing for a public release.
* Show if/label/asm statements in a saner format.Linus Torvalds2005-04-071-2/+3
| | | | | | | Parse break-statements inside switch-statements correctly. Rename break/continue symbols to make switch/iterator statements have the same naming logic for the break targets.
* Turn 'break'/'continue' statements into goto's withLinus Torvalds2005-04-071-2/+2
| | | | | | per-iterator anonymous symbols. Make arrays also gracefully degenerate into "void *".
* Make statement and expression printouts be more "linearized", andLinus Torvalds2005-04-071-2/+2
| | | | | | | | | | | create the proper pseudo-registers for sub-expressions. This changes the printout a lot, but makes it a lot closer to what you'd output internally for a back-end to do the flow graph. show_statement() and show_expression() now return the pseudo number for the result of a statement or expression. Pseudo 0 is "void".
* Add some limited attribute parsing. "packed", "aligned" and "type".Linus Torvalds2005-04-071-0/+2
| | | | | | The last one gives a "context mask" and "context value" to a symbol, which can be used to verify that the symbol is only used in a certain context.
* Change the copyright to Transmeta Corp, that's likely to beLinus Torvalds2005-04-071-1/+1
| | | | the real one when it goes out the door.
* Make labels be symbols in their own namespace (NS_LABEL).Linus Torvalds2005-04-071-3/+3
| | | | | This still gets the nesting scope wrong, though. Labels should use function scope, not block scope.
* Remove last user of "struct token" from "struct expression".Linus Torvalds2005-04-071-1/+1
| | | | | | | | Now constant expressions (strings, integers and fp constants) are evaluated at parse-time into the proper EXPR_xxx type. Remove "struct token" from "struct statement", which really only wanted to know the position. So replace it with "struct position".
* Make a function call point an expression type of its own, andLinus Torvalds2005-04-071-1/+1
| | | | | | | | | make the arguments use a proper argument list instead of being a comma-expression (which has totally different type semantics). Evaluate assignments and function calls (and their arguments). Show function calls in the debug info.
* Clean up type handling in a big way. Don't leave thoseLinus Torvalds2005-04-071-0/+3
| | | | | dangling anonymous "int_type" types with magic modifiers, but turn all types into explicit C types.
* Replace for/while/do-while loops with a generic internalLinus Torvalds2005-04-071-6/+9
| | | | | 'iterator' representation so that the parse tree doesn't have to care.
* Move expression data structures to "expression.h", they gotLinus Torvalds2005-04-071-41/+0
| | | | left behind in "parse.h" when the files were split.
* Add copyright statements and file comments. Add a FAQ, README, andLinus Torvalds2005-04-071-0/+5
| | | | placeholder LICENSE file.
* Make iterators take a helper datum, and tell the callback whetherLinus Torvalds2005-04-071-1/+1
| | | | | | the entry is the first or last. Make printouts prettier by using the new iterator functionality.