| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
> 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
This patch add static declare to make sparse happy of checking itself.
|
| |
|
|
|
|
|
| |
The named parameter thing is still unsupported. And the format we save
things into is for simple saving rather than real usability.
|
|
|
|
| |
Currently we warn unconditionally about it.
|
|
|
|
|
| |
Not only do all users want it, the list of used symbols
is not stable until after the tree has been evaluated.
|
|
|
|
|
| |
It just ends up propagating the expression to the linearizer,
which creates an internal "context" instruction for it.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
Associate them with each computed goto, and copy them properly
when inlining.
|
|
|
|
|
| |
They were only used for the original pre-instruction
linearization.
|
| |
|
|
|
|
| |
This lets us get the type of comparison right.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Right now we only really do trivial if-statements, but the
ideas are all there now.
|
|
|
|
| |
isn't the sole copyright owner these days.
|
|
|
|
|
| |
argument symbols that got corrupted by the incorrect
partial symbol copy when creating the new argument symbols.
|
|
|
|
|
|
| |
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>.
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
(&&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).
|
| |
|
| |
|
|
|
|
|
|
| |
Add a "case" symbol for the switch statement, to let the
statement keep track of all the cases. This cleans up handling
a lot.
|
|
|
|
| |
preparing for a public release.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
per-iterator anonymous symbols.
Make arrays also gracefully degenerate into "void *".
|
|
|
|
|
|
|
|
|
|
|
| |
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".
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
the real one when it goes out the door.
|
|
|
|
|
| |
This still gets the nesting scope wrong, though. Labels
should use function scope, not block scope.
|
|
|
|
|
|
|
|
| |
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 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.
|
|
|
|
|
| |
dangling anonymous "int_type" types with magic modifiers,
but turn all types into explicit C types.
|
|
|
|
|
| |
'iterator' representation so that the parse tree doesn't
have to care.
|
|
|
|
| |
left behind in "parse.h" when the files were split.
|
|
|
|
| |
placeholder LICENSE file.
|
|
|
|
|
|
| |
the entry is the first or last.
Make printouts prettier by using the new iterator functionality.
|