aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib.c
AgeCommit message (Collapse)AuthorFilesLines
2017-12-16fix: spaces in macro definition on the command lineLuc Van Oostenryck1-1/+1
GCC's manual or POSIX say about the '-D' option something like: '−D name[=value]' should be treated as if in directive '#define name value' (with '1' as default for the value), including its tokenization. So an option like '-DM(X, Y)=...' should be processed like a directive '#define M(X, Y) ...'. However, the current code treat a space as a separator between the macro and its definition, just like the '='. As consequence, the above option is processed like the directive would be '#define M(X, Y)=...', with 'M(X,' as the macro (name) and 'Y)=...' as its definition. Fix this by stopping to treat the space character specially, thus only using '=' as the separator. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-13fix: accept 'sparse -D M...'Luc Van Oostenryck1-4/+8
Till now, sparse was unneedlessly strict in what it accepted in '-D' options. More specifically, it doesn't accept: 1) separated '-D' and the macro definition, like: sparse -D MACRO[=definition] ... 2) a space between the '-D' and the macro name, like: sparse '-D MACRO[=definition] ... Case 1) is clearly accepted by GCC, clang and should be accepted for a POSIX's c99. Case 2's status is less clear but is also accepted by GCC and clang (leaving any validation to the corresponding internal #define). Fix this by accepting separated command line argument for '-D' and the macro (and removing the check that rejected the macro part if it started with a space). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13Merge branch 'dump-ir' into tipLuc Van Oostenryck1-61/+185
2017-11-13dump-ir: make it more flexibleLuc Van Oostenryck1-8/+62
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13dump-ir: rename -fdump-linearize to -fdump-irLuc Van Oostenryck1-4/+4
as it will be used for dumping the IR not only just after linearization but after other passes too. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-12dump-ir: allow to specify the passes to execute via cli's optionsLuc Van Oostenryck1-0/+34
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-11Merge branches 'volatile-loads-are-side-effects', ↵Luc Van Oostenryck1-0/+1
'fix-volatile-simplification', 'struct-asm-ops', 'restricted-pointers', 'fix-f2i-casts', 'symaddr-description', 'flush-stdout' and 'diet-simple' into tip
2017-11-11flush stdout when warningLuc Van Oostenryck1-0/+1
This is much needed for tools like test-linearize which output on stderr & stdout and without this patch error messages and normal output are out-of-sync. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-09-18fix: missing evaluate with '-include'Luc Van Oostenryck1-0/+14
Symbols declared or defined in files directly or indirectly given in the command line and thus processed via sparse() are always automatically evaluated. Symbols processed via sparse_initialize(), thus the predefined ones, are not systematically evaluated, which is normaly fine as they are just declarations and will be evaluated when needed. However, if the command line include a file via '-include <file>', the symbols of this file will also not be evaluated, which is still fine as long as it's only definitions. But, in the rare and odd cases where the file should contains a function definition, this function will not be evaluated and it's expansion and linearization won't happen as it should have. Fix this by evaluating the symbols issued from sparse_intialize() like it is done for sparse(). Reported-by: Jason A. Donenfeld <Jason@zx2c4.com> Tested-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-09-14option: handle switches by tableLuc Van Oostenryck1-43/+48
Currently, the parsing of options is often quite ad-hoc and thus: - need a lot of code - is not clear at all Improve this by making this table driven. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-09-14option: constify match_option()Luc Van Oostenryck1-7/+7
Until now, match_option() needed a non-const argment and returned a non-const result. Since it is no more needed, let's use const. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-09-14option: use OPTION_NUMERIC() for handle_switch_fmemcpy_max_count()Luc Van Oostenryck1-17/+5
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-09-14option: add support for '-<some-option>=unlimited'Luc Van Oostenryck1-0/+4
For some options with a numerical value, it is sometimes desirable, when the value is used to limits something, to easily specify we want to remove any limits. This patch allow to use 'unlimited' for this by interpreting it as the maximum value. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-09-14option: add support for options with 'zero is infinity'Luc Van Oostenryck1-1/+6
For some options with a numerical value, it is sometimes desirable, to easily specify we want the maximum possible value. This patch allow to interpret '=0' as meaning the maximum value. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-09-14option: extract OPTION_NUMERIC() from handle_switch_fmemcpy_max_count()Luc Van Oostenryck1-0/+19
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-09-14option: let handle_simple_switch() handle an array of flagsLuc Van Oostenryck1-9/+18
This was used to handle a single flag but we need something more compact when we need to handle several flags. So, adapt this helper so that it now takes an array of flags instead of a single flag. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-09-14option: rename 'struct warning' to 'struct flag'Luc Van Oostenryck1-5/+5
'struct warning' can be reused for flags other than warnings. To avoid future confusion, rename it to something more general: 'struct flag' (which in its context, handling of compiler flags, is clear enough). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-09-14option: add helper to parse/match command line optionsLuc Van Oostenryck1-14/+20
The goal of this helper is: - to avoid to have to hardoce the length od the substring - separate the suffix/option part from the whole argument which help for error message. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-08-28Merge remote-tracking branch 'luc/constexpr-v4' into masterChristopher Li1-0/+2
2017-08-09lib: workaround the 'redeclared with different type' errorsRamsay Jones1-0/+2
The 'selfcheck' make target issues sparse errors for function symbols 'error_die' and 'die', like so: CHECK lib.c lib.c:194:6: error: symbol 'error_die' redeclared with different type \ (originally declared at lib.h:98) - different modifiers lib.c:203:6: error: symbol 'die' redeclared with different type \ (originally declared at lib.h:94) - different modifiers This is caused by the 'noreturn' attribute being treated similar to a type qualifier and insisting that, not only the declaration and the definition of the function have the 'noreturn', but that they have the attribute in the same position. In order to suppress the error, move the attribute(s) to the beginning of the declaration, in the header file, and add an 'noreturn' attribute at the beginning of the definition (in lib.c). Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-08-09Adding _Pragma()Christopher Li1-0/+1
This will make the selfcheck target reduce a lot of error on test-inspect.c. The gtk header file use _Pragma(). Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-06-21teach sparse about __BYTE_ORDER__ & __ORDER_{BIG,LITTLE}_ENDIAN__Luc Van Oostenryck1-0/+6
Some macros, structures definitions, ... are endianness specific. This is generaly done with the help of some header files but these headers often need information from the compiler via the macro __BYTE_ORDER__, itself being defined to __ORDER_BIG_ENDIAN__ or __ORDER_LITTLE_ENDIAN__. Without these defines, sparse's pre-processor may interpret things differently than the compiler would do which may hide errors or warn on code that is compiled out. Fix this by letting sparse predefine these macros like compilers do. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Acked-by: Christopher Li <sparse@chrisli.org>
2017-06-21teach sparse about __{BIG,LITTLE}_ENDIAN__Luc Van Oostenryck1-0/+3
Some macros, structures definitions, ... are endianness specific. This is generaly done with the help of some header files but these headers often need information from the compiler via the macros __BIG_ENDIAN__ / __LITTLE_ENDIAN__. Without these defines, sparse's pre-processor may interpret things differently than the compiler would do which may hide errors or warn on code that is compiled out. Fix this by letting sparse predefine these macros like compilers do. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Acked-by: Christopher Li <sparse@chrisli.org>
2017-06-21teach sparse about -m{big,little}-endianLuc Van Oostenryck1-1/+14
Some macros, structures definitions, ... are endianness specific. This is generaly done with the help of some header files but these headers often need information from the compiler which then need to be endian-aware. In order to not interpret things differently than the compiler would, sparse thus also need to be endian-aware, even more so given that sparse must cover all archs and their variants. Give this information to sparse with two flags: -mbig-endian/-mlittle-endian, and by default use the endianness of the platform used to compile sparse. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Acked-by: Christopher Li <sparse@chrisli.org>
2017-06-15add support for -fmemcpy-max-countLuc Van Oostenryck1-0/+18
By default, sparse will warn if memcpy() (or memset(), copy_from_user(), copy_to_user()) is called with a very large static byte-count. But the limit is currently fixed at 100000, which may be fine for some uses but not for others. For example, this value is too low for sparse to be used on the git tree where, for example, some array used to sort the index is cleared with memset(). Change this by making the limit configurable via a new flag: -fmemcpy-max-count. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-06-15add support for -Wmemcpy-max-countLuc Van Oostenryck1-0/+2
sparse will warn if memcpy() (or memset(), copy_from_user(), copy_to_user()) is called with a very large static byte-count. But this warning is given unconditionaly while there are projects where this warning may not be not desired. Change this by making this warning conditional on a new warning flag: -W[no-]memcpy-max-count Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-06-15keep the warnings table alphabetically sortedLuc Van Oostenryck1-1/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-06-14Merge branches 'quiets-bool-cast-restricted-v3', 'error-vs-warnings-v2', ↵Luc Van Oostenryck1-17/+125
'implicit-int', 'cgcc-darwin' and 'more-builtin-decls' into rc2
2017-06-13Add more declarations for more builtin functionsLuc Van Oostenryck1-0/+44
Those are used by GCC testsuite. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-06-10finer control over error vs. warningsLuc Van Oostenryck1-2/+5
Currently, once an error is issued, warnings are no more issued, only others errors are. It make sense as once an error is encountered things can be left in an incoherent state and could cause lots of useless warnings because of this incoherence. However, it's also quite annoying as even unrelated warnings are so silenced and potential bugs stay thus hidden. Fix this by: - use a specific flag for this: 'has_error' - make the distinction between the current phase and some previous phases (but for now we only care about parsing vs evaluation) - if an error has been issued in a previous phase (at parsing) warnings are suppressed for the current phase and all future phases - if an error is issued in the current phase (evaluation) the flag is reset after each functions/symbols For example, with this patch, a typing error in function fa() will not suppress warnings for function fb(), while a parsing error will still inhibit all further warnings. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-05-19Merge branches 'dump-macros-v2', 'fix-predefined-size', 'fix-bool-context', ↵v0.5.1-rc1Luc Van Oostenryck1-15/+76
'fix-missing-reload', 'fix-insert-branch', 'fix-NULL-type', 'testsuite-clean', 'fix-bitfield-init-v3' and 'fdump-linearize' into tip * fix missing reload * fix boolean context for OP_AND_BOOL & OP_OR_BOOL * fix bitfields implicit zero initializer. * fix: kill old branch in insert_branch() * returns the correct type when evaluating NULL * use internal size for __INT_MAX__ & friends * testsuite: cleanup result files * add support for '-fdump-linearize[=only]' * add support for '-fmem-report' * add support for '-dD' Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-05-19let -dD report macro definitionsLuc Van Oostenryck1-0/+5
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-05-19teach sparse how to handle -dD flagLuc Van Oostenryck1-0/+16
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-05-19fix definition of __SCHAR_MAX__ & friendsLuc Van Oostenryck1-7/+10
The predefined macros __SCHAR_MAX__, __SHRT_MAX__, __WCHAR_MAX__ & __CHAR_BIT__ are defined based on the size of these types on the machine where sparse was compiled. But since sparse has flags like -m32/-m64 and it's not unlikely to have one day a flag like -march=<some arch>, better to use the used by sparse for these types as stored in 'bits_in_char', 'bits_in_short', ... Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-05-19avoid to redefine __INT_MAX__ and friendsLuc Van Oostenryck1-4/+0
Since commit 4fae9be00 & 5466cf8f3 ("predefine __INT_MAX__ and friends" & "predefine __SIZEOF_INT__ & friends"), macros like __INT_MAX__ and __SIZEOF_POINTER__ are predefine twice. Fix this by removing the old definition, based on the size of these types on the machine where sparse was compiled. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-05-19add support for a new flag: -fdump-linearize[=only]Luc Van Oostenryck1-0/+22
The effect of this flag is to dump the IR just after the linearization, before any simplification, and to stop further processing if '=only' is given as argument. The motivation of this flag is of course for debugging, to be able to inspect the raw result of the linearization, undisturbed by an simplification. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-05-15teach sparse how to handle '-fmem-report'Luc Van Oostenryck1-4/+4
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-05-15add helper handle_simple_switch()Luc Van Oostenryck1-0/+19
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-04-30Merge branches 'sent/float-expand-v2', 'sent/fix-kill-ttsb-v2', ↵Luc Van Oostenryck1-0/+2
'sent/fix-cond-address' and 'careful-concat-user-list' into tip
2017-03-31constexpr: check static storage duration objects' intializers' constnessNicolai Stange1-0/+2
Initializers of static storage duration objects shall be constant expressions [6.7.8(4)]. Warn if that requirement is not met and the -Wstatic-initializer-not-const flag has been given on sparse's command line. Identify static storage duration objects by having either of MOD_TOPLEVEL or MOD_STATIC set. Check an initializer's constness at the lowest possible subobject level, i.e. at the level of the "assignment-expression" production in [6.7.8]. Signed-off-by: Nicolai Stange <nicstange@gmail.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-03-27predefine __SIZEOF_INT__ & friendsLuc Van Oostenryck1-0/+10
Some tests or some code depends on these macros being predefined by the compiler. Predefine them. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-03-27predefine __INT_MAX__ and friendsLuc Van Oostenryck1-5/+18
Some tests or some code depends on these macros being predefined by the compiler. Predefine them. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-03-22teach sparse about -WaddressLuc Van Oostenryck1-0/+2
This is used by GCC to report suspicious use of addresses. So, reuse the same name for same or similar use. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-03-06add an optional validation method to external_declaration()Luc Van Oostenryck1-1/+1
After parsing and validation, the symbols in the declaration are added to the list given in argument, *if* they are not extern symbols. The symbols that are extern are them not added to the list. This is what is needed for usual declarations but ignoring extern symbols make it impossible to emit a diagnostic in less usual situation. This is motivated by the validation of variable declaration inside a for-loop initializer, which is valid in C99 but only for variable with local storage. The change consists in adding to external_declaration() an optional callback 'validate_decl()' which, if present (non-null), is called just before adding the declaration to the list. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-03-04ignore whole-range overlapping initializerLuc Van Oostenryck1-0/+1
When an array is initialized, it may be convenient to first initialize all entries with some default value via the '[a ... b]' notation and then override some of these entries with a non-default value. Unfortunately, this, of course, is not compatible with the default warning flag '-Woverride-init'. Fix this by introducing an exception to the usual detection of overlapping initializers which, only for what concerns this warning, ignore an '[a ... b]' entry if: - it is the first one - it covers the whole range of the array. If needed, the previous ehaviour can be restored by using a new warning flag, disabled by default: '-Woverride-init-whole-range'. Suggested-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-03-04allow to warn on all overlapping initializersLuc Van Oostenryck1-0/+2
By default, sparse only warns on the first overlapping initialier. While this may be sensible for most situation, it's not always wanted to hide those others errors. This is especially annoying when testing. Change this by introducing a new warning flag '-Woverride-init-all', disabled by default and whose intented use is sparse's testsuite. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-03-04use option: '-Woverride-init'Luc Van Oostenryck1-0/+2
Sparse warns unconditionally about overlapping initilalizers. Introduces a warning flag to control this, use the same name as GCC's and enabled it by default. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-03-04make -Wbitwise operational againLuc Van Oostenryck1-1/+1
The flag -Wbitwise have no effect since patch 02a886bfa ("Introduce keyword driven attribute parsing"): the corresponding checks are now always done. Fix that by reintroducing it in the same way as it was: ignore the bitwise attribute if the flag is not set. It's less invasive that checking the flag at each place an corresponding warning is emitted. Also, to not perturb the current situation the flag is now enabled by default. Reported-by: Edward Cree <ecree@solarflare.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-02-13expand __builtin_bswap*() with constant argsLuc Van Oostenryck1-32/+3
Things are greatly simplified now that such builtins can have a prototype: the args and result are already evaluated, the arguments number and their type are already checked, etc. Based-on-patch-by: Christopher Li <sparse@chrisli.org> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-02-13add support for LLP64 archLuc Van Oostenryck1-7/+27
There was recently on the mailing list some questions and a need to support LLP64 model. This patch add is by adjusting a few size-related variables under the control of a new flag: -msize-llp64 (ugly name but we already have we have '-msize-long'). CC: Dibyendu Majumdar <mobile@majumdar.org.uk> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-02-13add warning option '-Wtautological-compare'Luc Van Oostenryck1-0/+2
Now that we optimize away expressions like 'x == x' or 'x < x', also add a warning for it (but disabled by default). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-02-13define __LONG_MAX__ & __SIZEOF_POINTER__Luc Van Oostenryck1-0/+6
They're part of GCC's common predefined macros and some code & header files depends on them. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-02-13add an helper for common predefined macrosLuc Van Oostenryck1-1/+6
Eventually, most of what GCC predefine (gcc -E -dM) should be defined here. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-02-13define __LP64__ & _LP64 if arch_m64 is enabledLuc Van Oostenryck1-0/+2
They're part of GCC's common predefined macros and some code & header files depend on them. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-02-13C11: teach sparse about '--std={c11,gnu11}'Luc Van Oostenryck1-0/+21
Now that support have been added for C11 new syntax we can accept '--std={c11,gnu11}' no more dying with "Unsupported C dialect" message. Also adjust __STDC_VERSION__ accordingly and define the few associated feature macros (__STD_NO_ATOMICS__, ...). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-02-13implement constant-folding in __builtin_bswap*()Johannes Berg1-3/+32
Since gcc does this, it's apparently valid to write switch (x) { case __builtin_bswap16(12): break; } but sparse will flag it as an error today. The constant folding used to be done in the kernel's htons() and friends, but due to gcc bugs that isn't done anymore since commit 7322dd755e7d ("byteswap: try to avoid __builtin_constant_p gcc bug"). To get rid of the sparse errors on every such instance now, just add constant folding to __builtin_bswap*() in sparse. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-02-13Warn on unknown attributes instead of throwing errorsLuc Van Oostenryck1-0/+2
GCC creates new attributes quite often, generaly for specific usages irrelevant to what sparse is used for. Throwing errors on these create needless noise and annoyance which is better to avoid. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-01-27sparse: update __builtin_object_size() prototypeLance Richardson1-1/+1
Sparse emits a large number of warnings for the linux kernel source tree of the form: ./arch/x86/include/asm/uaccess.h:735:18: \ warning: incorrect type in argument 1 (different modifiers) ./arch/x86/include/asm/uaccess.h:735:18: expected void *<noident> ./arch/x86/include/asm/uaccess.h:735:18: got void const *from Fix by making the first parameter to __builtin_object_size() type "const void *" instead of "void *", which is consistent with GCC behavior (the prototype for this builtin in GCC documentation is evidently incorrect). Signed-off-by: Lance Richardson <lrichard@redhat.com> Acked-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2015-03-13Add a define for __builtin_ms_va_copy()Michael Stefaniuc1-0/+1
Signed-off-by: Michael Stefaniuc <mstefani@redhat.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2015-03-13Add the __builtin functions needed for INFINITY and nan().Michael Stefaniuc1-0/+11
Signed-off-by: Michael Stefaniuc <mstefani@redhat.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2014-10-10Add support for multiarch system header filesRamsay Jones1-1/+17
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
2014-10-10don't call isdigit/tolower with a char argumentRamsay Jones1-2/+2
This suppresses some "array subscript has type 'char'" warnings from gcc (version 4.8.3). (see also, commit cf5114a1) Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
2014-10-10rename -Werror to -Wsparse-errorChristopher Li1-4/+4
Sparse is often share compile flags. So Werror is usually mean gcc should treat warning as error. Apply the same option to sparse will cause the Linux kernel checking fail the build. We don't want that. Rename the sparse option to -Wsparse-error. It allow caller to control gcc and sparse behavior seperately. It also make sparse return error status only when -Wsparse-error is present. Signed-off-by: Christopher Li <sparse@chrisli.org>
2014-09-28sparse: Make -Werror turn warnigns into errorsThomas Graf1-20/+29
Make sparse fail and return an error code if a warning is encountered and -Werror is specified or a hard error is found. This allows to use sparse in automated build systems to more easily catch new sparse warnings. The validation script is extended to parse the expected output message for an error message and validate the a non zero return value if such a error message is found. Also changes cgcc to die if the checker fails. Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Christopher Li <sparse@chrisli.org>
2014-06-29Minor clean up for option handlingChristopher Li1-20/+24
Remove the loop for short option. Signed-off-by: Christopher Li <sparse@chrisli.org>
2014-06-28lib.c: skip --param parametersAndy Shevchenko1-2/+22
Very dumb patch to just skip --param allow-store-data-races=0 introduced in newer GCC versions. Without this patch sparse recognizes parameter of the --param option as a file name which obviously couldn't be found. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2014-02-27sparse: Allow override of sizeof(bool) warningJoe Perches1-0/+2
Allow an override to emit or not the sizeof(bool) warning. Add a "-Wsizeof-bool" description to the manpage. Signed-off-by: Joe Perches <joe@perches.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
2014-01-29Define __CHAR_BIT__Emilio G. Cota1-0/+1
gcc defines __CHAR_BIT__ as a pre-defined macro. Define __CHAR_BIT__ in sparse so that code that needs it (e.g. code using CHAR_BIT from limits.h) does not generate false warnings. Signed-off-by: Emilio G. Cota <cota@braap.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
2013-12-21sparse: add built-in atomic memory access identifiersKim Phillips1-2/+19
this patch stops sparse from complaining about them not being defined: source/odp_spinlock.c:41:10: error: undefined identifier '__sync_lock_release' source/odp_spinlock.c:54:10: error: undefined identifier '__sync_lock_release' ./odp_atomic.h:112:16: error: undefined identifier '__sync_fetch_and_add' Reported-by: Mike Holmes <mike.holmes@linaro.org> Signed-off-by: Kim Phillips <kim.phillips@linaro.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
2013-11-29sparse: Relicense under the MIT licenseFranz Schrober1-1/+17
The old code was relicensed by Novafora Corporation, successor in interest to Transmeta Corporation, in 2009. Other authors were also asked about the change of their contributions to the MIT license and all with copyrightable changes agreed to it. Signed-off-by: Franz Schrober <franzschrober@yahoo.de> Acked-by: Adam DiCarlo <adam@bikko.org> Acked-by: Al Viro <viro@ZenIV.linux.org.uk> Acked-by: Alberto Bertogli <albertito@blitiri.com.ar> Acked-by: Alecs King <alecs@perlchina.org> Acked-by: Alexander Shishkin <alexander.shishckin@gmail.com> Acked-by: Alexey Dobriyan <adobriyan@gmail.com> Acked-by: Alexey Zaytsev <alexey.zaytsev@gmail.com> Acked-by: Andries E. Brouwer <Andries.Brouwer@cwi.nl> Acked-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Acked-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Acked-by: Ben Pfaff <blp@nicira.com> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Acked-by: Bernd Petrovitsch <bernd@petrovitsch.priv.at> Acked-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> Acked-by: Blue Swirl <blauwirbel@gmail.com> Acked-by: Chris Forbes <chrisf@ijw.co.nz> Acked-by: Chris Wedgwood <cw@f00f.org> Acked-by: Christopher Li <sparse@chrisli.org> Acked-by: Damien Lespiau <damien.lespiau@gmail.com> Acked-by: Dan Carpenter <error27@gmail.com> Acked-by: Dan McGee <dan@archlinux.org> Acked-by: Daniel De Graaf <danieldegraaf@gmail.com> Acked-by: Daniel Sheridan <dan.sheridan@postman.org.uk> Acked-by: Dave Jones <davej@redhat.com> Acked-by: David Given <dg@cowlark.com> Acked-by: David Miller <davem@redhat.com> Acked-by: David Mosberger-Tang <dmosberger@gmail.com> Acked-by: David Olien <David.Olien@lsi.com> Acked-by: Diego Elio Pettenò <flameeyes@flameeyes.eu> Acked-by: Emil Medve <Emilian.Medve@Freescale.com> Acked-by: Ethan Jackson <jacksone@nicira.com> Acked-by: Florian Fainelli <f.fainelli@gmail.com> Acked-by: Frank Zago <fzago@systemfabricworks.com> Acked-by: Frederic Crozat <fcrozat@suse.com> Acked-by: Geoff Johnstone <geoff.johnstone@gmail.com> Acked-by: Hannes Eder <hannes@hanneseder.net> Acked-by: Jan Pokorný <pokorny_jan@seznam.cz> Acked-by: Jeff Garzik <jgarzik@redhat.com> Acked-by: Jiri Slaby <jslaby@suse.cz> Acked-by: Joe Perches <joe@perches.com> Acked-by: Joel Soete <rubisher@scarlet.be> Acked-by: Johannes Berg <johannes@sipsolutions.net> Acked-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Acked-by: Josh Triplett <josh@kernel.org> Acked-by: Kamil Dudka <kdudka@redhat.com> Acked-by: Kim Phillips <kim.phillips@linaro.org> Acked-by: KOSAKI Motohiro <kosaki.motohiro@gmail.com> Acked-by: Kovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Acked-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Acked-by: Martin Nagy <nagy.martin@gmail.com> Acked-by: Masatake YAMATO <yamato@redhat.com> Acked-by: Mauro Dreissig <mukadr@gmail.com> Acked-by: Michael Büsch <m@bues.ch> Acked-by: Michael Stefaniuc <mstefani@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Mika Kukkonen <mikukkon@iki.fi> Acked-by: Mike Frysinger <vapier@gentoo.org> Acked-by: Mitesh Shah <Mitesh.Shah@synopsys.com> Acked-by: Morten Welinder <mortenw@gnome.org> Acked-by: Namhyung Kim <namhyung@gmail.com> Acked-by: Nicolas Kaiser <nikai@nikai.net> Acked-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Pavel Roskin <proski@gnu.org> Acked-by: Pekka Enberg <penberg@cs.helsinki.fi> Acked-by: Peter Jones <pjones@redhat.com> Acked-by: Peter A Jonsson <pj@sics.se> Acked-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de> Acked-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Acked-by: Randy Dunlap <rdunlap@xenotime.net> Acked-by: Reinhard Tartler <siretart@tauware.de> Ached-by: Richard Knutsson <richard.knutsson@gmail.com> Acked-by: Rob Taylor <rob.taylor@codethink.co.uk> Acked-by: Rui Saraiva <rmpsaraiva@gmail.com> Acked-by: Ryan Anderson <ryan@michonline.com> Acked-by: Sam Ravnborg <sam@ravnborg.org> Acked-by: Samuel Bronson <naesten@gmail.com> Acked-by: Santtu Hyrkkö <santtu.hyrkko@gmail.com> Acked-by: Shakthi Kannan <shakthimaan@gmail.com> Acked-by: Stephen Hemminger <shemminger@linux-foundation.org> Acked-by: Thomas Schmid <Thomas.Schmid@br-automation.com> Acked-by: Tilman Sauerbeck <tilman@code-monkey.de> Acked-by: Vegard Nossum <vegardno@ifi.uio.no> Acked-by: Xi Wang <xi.wang@gmail.com> Acked-by: Yura Pakhuchiy <pakhuchiy@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2013-07-25sparse: add __builtin_va_arg_pack() and __builtin_va_arg_pack_len()Jeff Layton1-0/+2
this patch stops sparse from complaining about them not being defined: /usr/include/bits/stdio2.h:98:25: error: undefined identifier '__builtin_va_arg_pack' /usr/include/bits/stdio2.h:98:25: error: not a function <noident> Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2013-04-21Define __SIZEOF_POINTER__Josh Triplett1-0/+1
GCC defines a macro __SIZEOF_POINTER__ to the size of a pointer in bytes. Define it in sparse as well. Signed-off-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
2013-04-19Warn about initialization of a char array with a too long constant C string.Masatake YAMATO1-0/+2
This patch adds new option -Winit-cstring to sparse. With the option sparse can Warn about initialization of a char array with a too long constant C string. If the size of the char array and the length of the string is the same, there is no space for the last nul char of the string in the array. char s[3] = "abc"; If the array is used as just a byte array, not as C string, this warning is just noise. However, if the array is passed to functions dealing with C string like printf(%s) and strcmp, it may cause a trouble. Here is a example of such trouble: http://www.spinics.net/lists/netdev/msg229765.html http://www.spinics.net/lists/netdev/msg229870.html Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2013-04-08Proper variable length array warningChristopher Li1-2/+4
The previous warning about bad constant is actually mean for variable length array. Signed-off-by: Christopher Li <sparse@chrisli.org>
2013-03-06There's no current way to know the versionJoe Perches1-0/+25
of sparse. Add --version to see it. Reviewed-by: Joe Perches <joe@perches.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2013-02-19sparse: add built-in byte swap identifiersKim Phillips1-0/+5
this patch stops sparse from complaining about them not being defined: include/uapi/linux/swab.h:60:16: error: undefined identifier '__builtin_bswap32' include/uapi/linux/swab.h:60:33: error: not a function <noident> Signed-off-by: Kim Phillips <kim.phillips@freescale.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2013-02-13Merge git://git.kernel.org/pub/scm/linux/kernel/git/viro/sparse into margeChristopher Li1-19/+6
Pull preprocessor fix from Al Viro. 1) we really, really shouldn't convert escape sequences too early; #define A(x) #x A('\12') should yield "'\\12'", *not* "'\\n'". 2) literal merging handles all sequences of string/wide string literals; result is wide if any of them is wide. string_expression() is handling that wrong - "ab"L"c" is L"abc" 3) with support (no matter how cursory) of wide char constants and wide string literals, we really ought to handle #define A(x,y) A(L,'a') properly; it's not that tricky - combine() needs to recognize <IDENT["L"],CHAR> and <IDENT["L"],STRING> pairs. 4) '\777' is an error, while L'\777' is valid - the value should fit into unsigned char or unsigned counterpart of wchar_t. Note that for string literals this happens *after* phase 6 - what matters is the type of literal after joining the adjacent ones (see (2) above). 5) stringifying should only quote \ and " in character constants and string literals, #define A(x) #x A(\n) should produce "\n", not "\\n" 6) we are losing L when stringifying wide string literals; that's wrong. I've patches hopefully fixing the above. Basically, I delay interpreting escape sequences (past the bare minimum needed to find where the token ends) until we are handling an expression with character constant or string literal in it. For character constants I'm keeping the token body in token->embedded - 4-character array replacing token->character. That covers practically all realistic instances; character constant *may* be longer than that, but it has to be something like '\x000000000000000000000000041' - sure, that's 100% legitimate C and it's going to be the same as '\x41' on everything, but when was the last time you've seen something like that? So I've split TOKEN_CHAR into 5 values - TOKEN_CHAR+1--TOKEN_CHAR+4 meaning 1--4 characters kept in ->embedded[], TOKEN_CHAR itself used for extremely rare cases longer than that (token->string holds the body in that case). TOKEN_WIDE_CHAR got the same treatment. AFAICS, with those fixes we get the same behaviour as in gcc for silently ignored by cpp if the string/char constant doesn't make it out of preprocessor. sparse still warns about those. The situation with this one is frustrating; on one hand C99 is saying that e.g. '\x' is not a token. Moreover, in a footnote in 6.4.4.4 it flat-out requires diagnostics for such. On the other hand... footnotes are informative-only and having "other character" token match ' would puts us in nasal daemon country, so gcc is free to do whatever it feels like doing. I think we shouldn't play that kind of standard-lawyering *and* sparse has always warned on that, so I've left that warning in place. Note that real wchar_t handling is still not there; at the very least, we need to decide what type will be used for that sucker (for gcc it's int on all targets we care about), fix the handling of wide string literals in initializers and evaluate_string() and stop dropping upper bits in get_string_constant(). That would probably mean not using struct string for wide ones, as well... Hell knows; I don't want to touch that right now. If anything, I'd rather wait until we get to C11 support - they've got much saner variants of wide strings there (char16_t/char32_t with u and U as token prefix as L is used for wchar_t; there's also u8"..." for UTF8 strings).
2013-02-12fix handling of -includeAl Viro1-19/+6
-include foo.h will search not only in the current directory... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2013-02-10remove weak define x86_64Christopher Li1-2/+0
This fix the regression report by Dan Carpenter. "x96_64" can be a valid variable name. Signed-off-by: Christopher Li <sparse@chrisli.org>
2012-03-23Adding default for m64/m32 handleChristopher Li1-2/+41
This is improved version of Pekka Enberg's patch "Fix including glibc headers on x86-64". To avoid setting 64 bit define in the -m32 case, the 64 bit initialization needs to delay until all arguments are handled. Signed-off-by: Christopher Li <sparse@chrisli.org>
2012-03-23Add __builtin_stpcpy, __sync_synchronize, __sync_bool_compare_and_swap to ↵Frederic Crozat1-0/+3
declare_builtin_functions Signed-off-by: Frederic Crozat <fcrozat@suse.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2011-05-31Remove set but not used variableChristopher Li1-3/+0
The new gcc complain about set but not used variable. This should make the new gcc happy. Signed-off-by: Christopher Li <sparse@chrisli.org>
2011-01-03use ARRAY_SIZE() when possibleNamhyung Kim1-4/+4
Convert (sizeof arr / sizeof arr[0]) to ARRAY_SIZE(arr). Signed-off-by: Namhyung Kim <namhyung@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2010-10-08parser: add Blackfin gcc infoMike Frysinger1-0/+9
The Blackfin port uses some custom attributes to control memory placement, and it has some custom builtins. So add the ones that the kernel actually utilizes to avoid massive build errors with sparse. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
2010-07-19skip may_alias and declare builtin_fabsMorten Welinder1-0/+1
Signed-off-by: Morten Welinder <terra@gnome.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
2010-07-13parser: define __builtin_unreachableJiri Slaby1-0/+1
Gcc 4.5 defines extern void __builtin_unreachable(void); so, add it also to sparse. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Christopher <sparse@chrisli.org>
2010-03-28New attribute designated_init: mark a struct as requiring designated initJosh Triplett1-0/+2
Some structure types provide a set of fields of which most users will only initialize the subset they care about. Users of these types should always use designated initializers, to avoid relying on the specific structure layout. Examples of this type of structure include the many *_operations structures in Linux, which contain a set of function pointers; these structures occasionally gain a new field, lose an obsolete field, or change the function signature for a field. Add a new attribute designated_init; when used on a struct, it tells Sparse to warn on any positional initialization of a field in that struct. The new flag -Wdesignated-init controls these warnings. Since these warnings only fire for structures explicitly tagged with the attribute, enable the warning by default. Includes documentation and test case. Signed-off-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
2010-03-28Rename -Wall to Wsparse-all, so it doesn't get turned on unintentionallyJosh Triplett1-1/+1
sparse's -Wall option turns on all sparse warnings, including those that many projects will not want; for instance, warnings that enforce particular stylistic choices, or behavior allowed by a standard but considered questionable or error-prone. Furthermore, using -Wall means accepting all future warnings sparse may start issuing, not just those intentionally turned on by default. Other compilers like GCC also use -Wall, and interpret it to mean "turn on a sensible set of warnings". Since sparse exists to emit warnings, it already defaults to emitting a sensible set of warnings. Many projects pass the same options to both sparse and the C compiler, including warning options like -Wall; this results in turning on excessive amounts of sparse warnings. cgcc already filtered out -Wall, but many projects invoke sparse directly rather than using cgcc. Remove that filter, now that -Wall does not change sparse's behavior. Projects almost certainly don't want to use the new -Wsparse-all option; they should choose the specific set of warnings they want, or just go with sparse's defaults. Also update cgcc to know about Wsparse-all and not pass it to GCC, and update a test case that unnecessarily used -Wall. Signed-off-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
2010-03-28Handle __builtin_ms_va_list.Michael Stefaniuc1-0/+2
For Win64 compiles Wine does #ifndef __ms_va_list # if defined(__x86_64__) && defined (__GNUC__) # define __ms_va_list __builtin_ms_va_list # define __ms_va_start(list,arg) __builtin_ms_va_start(list,arg) # define __ms_va_end(list) __builtin_ms_va_end(list) # else Wouldn't be as bad if sparse cannot handle those but it trips over WINBASEAPI DWORD WINAPI FormatMessageA(DWORD,LPCVOID,DWORD,DWORD,LPSTR,DWORD,__ms_va_list*); WINBASEAPI DWORD WINAPI FormatMessageW(DWORD,LPCVOID,DWORD,DWORD,LPWSTR,DWORD,__ms_va_list*); producing this errors for basically every file: wine/include/winbase.h:1546:96: error: Expected ) in function declarator wine/include/winbase.h:1546:96: error: got * wine/include/winbase.h:1547:97: error: Expected ) in function declarator wine/include/winbase.h:1547:97: error: got * Signed-off-by: Michael Stefaniuc <mstefaniuc@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2009-08-21sparse: Add GCC pre-defined macros for user-spacev0.4.2-rc1Pekka Enberg1-0/+8
Sparse produces a bunch of warnings like this when compiling against glibc: /usr/lib/gcc/i486-linux-gnu/4.3.2//include-fixed/limits.h:33:22: warning: undefined preprocessor identifier '__INT_MAX__' /usr/lib/gcc/i486-linux-gnu/4.3.2//include-fixed/limits.h:64:5: warning: undefined preprocessor identifier '__SHRT_MAX__' /usr/lib/gcc/i486-linux-gnu/4.3.2//include-fixed/limits.h:64:21: warning: undefined preprocessor identifier '__INT_MAX__' /usr/include/bits/xopen_lim.h:95:6: warning: undefined preprocessor identifier '__INT_MAX__' /usr/include/bits/xopen_lim.h:98:7: warning: undefined preprocessor identifier '__INT_MAX__' Fix that up by adding some add_pre_buffer() calls to create_builtin_define(). For future reference, GCC defines the builtins in the c_cpp_builtins() function in gcc/c-cppbuiltin.c. Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi> Acked-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
2009-08-03Add c{l,t}z{,l,ll}, ffsl{,l}, popcountll and floating point comparison builtins.Blue Swirl1-3/+22
Signed-off-by: Blue Swirl <blauwirbel@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2009-07-18Turn off '-Wtransparent-union' by defaultLinus Torvalds1-1/+1
It's a very annoying warning, and it's about a sparse limitation rather than a real feature, so don't do it by default. Sure, our lack of transparent union support will then make us warn about the magic calling convention hacks (eg you'll see warnings like connect.c:240:39: warning: incorrect type in argument 2 (invalid types) connect.c:240:39: expected union __CONST_SOCKADDR_ARG [usertype] __addr connect.c:240:39: got struct sockaddr *ai_addr but it still doesn't mean that we have to be so noisy about just seeing those transparent unions. One annoying warning is not an argument for doing _another_ annoying warning too (and the calling convention warnings at least only happen if you actually use them, unlike the transparent union warning that happens every time we see one, used or not). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
2009-07-17refactor handle_switch_fHannes Eder1-11/+20
This also fixes a possible source of bugs in parsing other -f<whatever> options, i.e. -ftabstop=foo would set the option -ffoo. Signed-off-by: Hannes Eder <hannes@hanneseder.net>
2009-01-02Add -ftabstop=WIDTHHannes Eder1-1/+14
Make tokenizer aware of tabstops and add the commandline option: -ftabstop=WIDTH Set the distance between tab stops. This helps sparse report correct column numbers in warnings or errors. If the value is less than 1 or greater than 100, the option is ignored. The default is 8. With simplifications suggested by Christopher Li and Junio C Hamano. Signed-off-by: Hannes Eder <hannes@hanneseder.net> Signed-off-by: Christopher Li <sparse@chrisli.org>
2008-12-18Rename dirafter to idirafter.Alexey Zaytsev1-10/+5
Dirafter was probably just a mistake. Gcc uses -idirafter. Acked-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Alexey zaytsev <alexey.zaytsev@gmail.com>
2008-12-18Set gcc include path at runtime.Alexey Zaytsev1-3/+20
You can now tell sparse where to look for the compiler headers with -gcc-base-dir <dir>. Otherwise sparse will look for headers used to build it. Also adds $GCC_BASE/include-fixed used by newer gcc versions. Signed-off-by: Alexey zaytsev <alexey.zaytsev@gmail.com>
2008-12-18Handle missing argument to -D.Alexey Zaytsev1-0/+4
Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
2008-12-18Mark handle_switch as static and don't export it from lib.hAlexey Zaytsev1-1/+1
Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
2008-12-18Handle a terminal -o option properly.Alexey Zaytsev1-4/+7
Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
2008-12-18Remove pre_bufferChristopher Li1-9/+14
This patch removes the pre_buffer completely. Instead, sparse will tokenized the buffer during add_pre_buffer(). Sparse just tracks the beginning and end of pre_buffer. Reviewed-by: Alexey Zaytsev <alexey.zaytsev@gmail.com> Signed-Off-By: Christopher Li <spase@chrisli.org>
2008-04-21Add -Wno-declaration-after-statementGeoff Johnstone1-0/+24
This adds -W[no-]declaration-after-statement, which makes warnings about declarations after statements a command-line option. (The code to implement the warning was already in there via a #define; the patch just exposes it at runtime.) Rationale: C99 allows them, C89 doesn't. Signed-off-by: Geoff Johnstone <geoff.johnstone@googlemail.com>
2008-04-05Add builtin functions for use with __FORTIFY_SOURCEGeoff Johnstone1-0/+16
__FORTIFY_SOURCE=2 converts memcpy() into __builtin___memcpy_chk() etc. The patch adds some/all? of the relevant builtin prototypes. Signed-off-by: Geoff Johnstone <geoff.johnstone@googlemail.com>
2008-04-05Add support for GCC's -std=... and -ansi command line options.Geoff Johnstone1-0/+75
This adds support for GCC's -std=... and -ansi command line options, i.e. defining __STDC_VERSION__ and __STRICT_ANSI__ appropriately. This means that code that invokes #error if __STDC_VERSION__ < 199901L will work. It will probably also affect the userland header files too. Signed-off-by: Geoff Johnstone <geoff.johnstone@googlemail.com>
2007-09-16Added a prototype for mempcpy().Tilman Sauerbeck1-0/+1
Signed-off-by: Tilman Sauerbeck <tilman@code-monkey.de>
2007-08-31Rename Wundefined_preprocessor to Wundef to match the command-line argumentJosh Triplett1-2/+2
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-08-31Rename Wcast_to_address_space to Wcast_to_as to match the command-line argumentJosh Triplett1-2/+2
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-08-30Sort warning options in lib.c and lib.hJosh Triplett1-26/+26
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-08-22add __builtin_labs()Randy Dunlap1-0/+1
2.6.23-rc3-mm1 has added a user of __builtin_labs(), so add this function to sparse lib.c to avoid the error messages. CHECK kernel/unwind.c kernel/unwind.c:1016:31: error: undefined identifier '__builtin_labs' kernel/unwind.c:1232:25: error: undefined identifier '__builtin_labs' Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
2007-07-28[PATCH] add __builtin_strlen()Al Viro1-0/+1
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2007-07-27Turn off -Wdo-while by default.Josh Triplett1-1/+1
-Wdo-while represents a style warning only, not a correctness warning. Thus, turn it off by default. Projects that want it should use -Wdo-while explicitly. Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-07-13add sparse_keep_tokens api to lib.hRob Taylor1-1/+12
Adds sparse_keep_tokens, which is the same as __sparse, but doesn't free the tokens after parsing. Useful fow ehen you want to inspect macro symbols after parsing. Signed-off-by: Rob Taylor <rob.taylor@codethink.co.uk>
2007-07-08make size_t better approximate the realityAl Viro1-1/+9
Instead of "always unsigned long" go for "unsigned int unless -m64 is given, unsigned long otherwise". Add an option (-msize-long) forcing to unsigned long regardless. Make __SIZE_TYPE__ expansion match that. The thing is, addition of checks on comparisons make for very unhappy min() on (kernel) size_t and sizeof(something) on the targets where the former is unsigned int. Which is to say, more than half of them... AFAICS, the only place needing explicit -msize-long in CHECK_FLAGS is s390 (it's using unsigned long both for 31- and 64-bit). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2007-06-26[PATCH] implement __builtin_offsetof()Al Viro1-1/+0
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2007-06-25[PATCH] warn on return <void expression>;Al Viro1-0/+2
conditional on -Wreturn-void Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2007-06-18[PATCH] rewrite of initializer handlingAl Viro1-0/+2
Remaining known problems: * size of array is still miscalculated in cases with missing braces * expand still mishandles [0 ... 1].a et.al. * expand still doesn't deal with overlaps correctly. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2007-06-13Fix -E handlingAlexey Dobriyan1-1/+2
sparse accepts -E[anything] as directive to preprocess only. On some mips targets -EL slips into command line resulting in 400-800M logs with preprocessing results :^) Accept '-E' only from now. Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
2007-06-13Turn on -Wdecl by default.Josh Triplett1-1/+1
-Wdecl warns about global, non-static symbols with no forward declarations. Normally, intentionally global functions called by other parts of a program will have forward declarations, so global symbols without such declarations often have no use outside the current file and should use static. Note that to avoid false positives, any source file that declares functions for export should always include the header file that forward-declares its own functions. This also helps for other reasons, such as obtaining any Sparse annotations declared on the function to use when analyzing calls to it from within the same source file. Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-05-22Add __builtin_strcat and __builtin_strncat.Josh Triplett1-0/+2
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-05-22Add -Wno-non-pointer-null to turn off warning about using a plain integer as ↵Josh Triplett1-0/+2
a NULL pointer Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-05-22Add -Wno-old-initializer to turn off warnings about non-C99 struct initializersJosh Triplett1-0/+2
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-05-20__DATE__ & __TIME expansionDamien Lespiau1-2/+0
Makes __DATE__expand to a character string literal of the form "Mmm dd yyyy" where the names of the months are the same as those generated by the asctime function, and the first character of dd is a space character if the value is less than 10. Makes __TIME__ expand to a a character string literal of the form "hh:mm:ss" as in the time generated by the asctime function. Signed-off-by: Damien Lespiau <damien.lespiau@gmail.com>
2007-04-20Declare do_error staticJosh Triplett1-1/+1
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-04-20Remove unused variable "include" from lib.cJosh Triplett1-1/+0
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-04-20Fix comment to reference #weak_define rather than #ifndef, matching codeJosh Triplett1-1/+1
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-03-09Fix typos in commentsJosh Triplett1-3/+3
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-02-28Disable liveness "dead" instruction by default.Christopher Li1-1/+3
The liveness instruction takes up about 10% of the bytecode bloat file. It is not very useful, it is duplicate information that can be obtained from the def/user chain. This change disables the liveness instruction by default. The caller can track_pseudo_death() if needed. Signed-Off-By: Christopher Li <sparse@chrisli.org>
2007-02-27Introduce expression_errorChristopher Li1-4/+18
Add a new function expression_error, which works just like sparse_error but also installs a bad_ctype into the expression. Signed-Off-By: Christopher Li <sparse@chrisli.org>
2007-02-25Adding debug option for showing the linearized instruction.Christopher Li1-13/+48
Signed-Off-By: Christopher Li <sparse@chrisli.org>
2007-01-27Coding style fix: in a pointer type, * goes with the name, not the type.Josh Triplett1-1/+1
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-01-27Allow more than one command line include file.Christopher Li1-20/+25
Signed-off-by: Christopher Li<sparse@chrisli.org>
2006-12-05Support -Wall flagPavel Roskin1-3/+27
If -Wall is specified, enable all warnings except those explicitly disabled by -Wno-* switches. Signed-off-by: Pavel Roskin <proski@gnu.org>
2006-12-04cleanup write to argument array hackChristopher Li1-22/+6
The sparse interface is a kind of snaky that it change the input argument array. The function sparse() does the same hack just to skip the files. This patch add the ptr list for string. So sparse_initialize will return list of file to compile. The string pointer is not aligned at word boundary. This patch introduce non taged version of the ptr list iteration function. Signed-off-by: Christopher Li <sparse@chrisli.org>
2006-12-04delay removing file scopeChristopher Li1-2/+1
Sparse only returns the used symbol. By the time it return the symbol, it already destroyed the file scope. This patch preserve the file scope. The caller can examine the unused symbols. e.g. If I want to generate ctags base on sparse, it need those unused symbols. Signed-off-by: Christopher Li <sparse@chrisli.org>
2006-11-06Add support for __builtin_strpbrk()Pavel Roskin1-0/+1
Signed-off-by: Pavel Roskin <proski@gnu.org> Signed-off-by: Josh Triplett <josh@freedesktop.org>
2006-10-24added a bunch of gcc builtinsAl Viro1-0/+10
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Josh Triplett <josh@freedesktop.org>
2006-10-16Merge branch 'Wcontext-default' into stagingJosh Triplett1-1/+1
2006-10-16merge branch 'more-warning-flags' into staging and fix conflictsJosh Triplett1-0/+2
2006-10-01Add warning message for naked do-whileLinus Torvalds1-0/+2
Does it necessarily make sense? Dunno, but it does tend to be bad practice, or at least result in code that can be hard to mentally parse. Maybe that mental parsing is just me. Or maybe it should be warned about. You decide. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-09-14Turn on -Wcontext by defaultJosh Triplett1-1/+1
Context checking currently requires explicitly passing the -Wcontext option. In a Linux build, this requires passing CF=-Wcontext. Thus, running people running sparse over Linux or other software in the default way will not see context warnings. Change this by enabling -Wcontext. While context checking does generate false positives, due to both missing annotations on kernel functions and insufficiently clever checking in sparse, the context warnings still do provide useful information and help track down real bugs. Furthermore, showing these warnings by default may incite more people to add annotations or enhance sparse. As a last resort, -Wno-context will still work. Signed-off-by: Josh Triplett <josh@freedesktop.org>
2006-09-14Add -Wno-uninitializedJosh Triplett1-0/+2
Add the ability to turn off warnings for possibly uninitialized variables using -Wno-uninitialized, helpful when attempting to track down a particular class of warnings only without losing them amongst others. Warnings for possibly uninitialized variables default to on, so this does not change the default behavior of sparse. Signed-off-by: Josh Triplett <josh@freedesktop.org>
2006-08-29[PATCH] Add -Wno-cast-truncateJosh Triplett1-0/+2
Add the ability to turn off checks for casts that truncate constant values using -Wno-cast-truncate, helpful when attempting to track down a particular class of warnings only without losing them amongst others. Checks for truncating casts default to on, so this does not change the default behavior of sparse. Signed-off-by: Josh Triplett <josh@freedesktop.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-08-29[PATCH] Add -Wno-enum-mismatchJosh Triplett1-0/+2
Add the ability to turn off enum type mismatch warnings using -Wno-enum-mismatch, helpful when attempting to track down a particular class of warnings only without losing them amongst others. Enum type mismatch checking defaults to on, so this does not change the default behavior of sparse. Signed-off-by: Josh Triplett <josh@freedesktop.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-08-29[PATCH] Add -Wno-address-spaceJosh Triplett1-0/+2
Add the ability to turn off address-space mismatch warnings using -Wno-address-space, helpful when attempting to track down a particular class of warnings only without losing them amongst others. Address space checking defaults to on, so this does not change the default behavior of sparse. Signed-off-by: Josh Triplett <josh@freedesktop.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-08-29[PATCH] sparse_error() should not silence info() after sparse_error()sJosh Triplett1-3/+10
sparse_error() sets max_warnings = 0 to silence subsequent sparse_warning()s or info()s; however, this also silences the info() after that sparse_error() and subsequent sparse_errors() which still get shown. bad_expr_type runs into this problem: it reports an error with sparse_error() and then provides further information with info(), which the user never sees. Make info() continue to print as long as the immediately preceeding warning or error does. Signed-off-by: Josh Triplett <josh@freedesktop.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-08-29[PATCH] Add support for GCC's __builtin_va_copyJosh Triplett1-0/+1
Signed-off-by: Josh Triplett <josh@freedesktop.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-08-29[PATCH] Add support for GCC's __builtin_extract_return_addr function.Josh Triplett1-0/+1
Signed-off-by: Josh Triplett <josh@freedesktop.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-07-31First cut at something that approaches a sane -WshadowLinus Torvalds1-0/+2
Let's see if it's useful. The ones it reported for git seemed reasonable, certainly more so than the gcc ones. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-12-20[PATCH] introduce __sparse() functionOleg Nesterov1-2/+9
This patch adds __sparse() function for those users which don't need evaluate.c (see the next patch). Without this patch it is not possible to link test-dissect statically, it has to redefine evaluate_symbol_list(). Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-11-25[PATCH] Made __GNUC__ et.al. weak defines, so that we could override them ↵Al Viro1-3/+3
with -D Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-11-22[PATCH] new flag - Wone-bit-signed-bitfieldAl Viro1-0/+2
Make the warnings about one-bit signed bitfields conditional; default is the old behaviour Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-11-22[PATCH] new flag - -WdeclAl Viro1-0/+2
Make "should it be static?" warnings conditional on a new flag (-Wdecl); default is to be quiet. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-11-22[PATCH] missing builtin - memcmp()Al Viro1-0/+1
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-11-16Re-name "error()" function to "sparse_error()"Linus Torvalds1-3/+3
Mitesh Shah (and others) report that broken libc's will have their own "error()" that the sparse naming clashes with. So use a sed-script to rewrite all the occurrences. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-11-02Handle symbols from "-include" file tooLinus Torvalds1-5/+7
Noted by Mitesh Shah Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-24[PATCH] handle -G x switch for mipsAtsushi Nemoto1-0/+9
When I ran make C=1 on linux-mips kernel, I got: CHECK /home/cvs/linux-mips/scripts/mod/empty.c No such file: 0 If I ran make C=1 V=1, I got: sparse -D__linux__ -D__mips__ -D_MIPS_SZLONG=32 -D__PTRDIFF_TYPE__=int -D__MIPSEL__ -nostdinc -isystem /usr/lib/gcc/mipsel-linux/3.4.4/include -Wp,-MD,scripts/mod/.empty.o.d -nostdinc -isystem /usr/lib/gcc/mipsel-linux/3.4.4/include -D__KERNEL__ -Iinclude -Iinclude2 -I/home/cvs/linux-mips/include -I/home/cvs/linux-mips/scripts/mod -Iscripts/mod -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -ffreestanding -O2 -fomit-frame-pointer -I/home/cvs/linux-mips/ -I /home/cvs/linux-mips/include/asm/gcc -G 0 -mno-abicalls ^^^^ -fno-pic -pipe -finline-limit=100000 -mabi=32 -march=r3000 -Wa,-32 -Wa,-march=r3000 -Wa,-mips1 -I/home/cvs/linux-mips/include/asm-mips/mach-dec -Iinclude/asm-mips/mach-dec -I/home/cvs/linux-mips/include/asm-mips/mach-generic -Iinclude/asm-mips/mach-generic -DKBUILD_BASENAME=empty -DKBUILD_MODNAME=empty /home/cvs/linux-mips/scripts/mod/empty.c ; No such file: 0 It seems sparse is confused by '-G 0' option. This fixes it. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-22[PATCH] replaced warnings with errors.Mitesh Shah1-3/+5
This replaceq calls to warning() with error() at places where (I think) the gcc reports an error. Also added a global variable die_if_error which is set if there is one or more errors. If someone wants to stop processing further, can check for the variable. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-15Add various declarations for more builtin functionsLinus Torvalds1-1/+10
Yeah, this is not the way to do them (we should have _real_ builtin declarations instead of parsing them to create them), but this is the simple solution to gcc-aware header files. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-15Make sure that when we define __OPTIMIZE[_SIZE]_ we define it to somethingLinus Torvalds1-2/+2
It needs to have a value, since otherwise something like #if __OPTIMIZE__ > 1 breaks.
2005-09-14[PATCH] add support for -imacrosSam Ravnborg1-0/+9
Gcc has two ways to specify on the commandline files to be read before processign normal files: "-include file" will include file in ordinary way. "-imacros file" will include file but do not generate any output gcc will include files specified with -imacros before files specified with -include. This adds some very basic support for -imacros, just duplicating the code used for -include. To obtain the real functionality we would have to build a list of filenames specified, and process all files specifed with -imacros before files specified with -include. In -mm a patch is now included that uses -imacros, so applying following patch will let us stay compatible with kernel source. The last bit deletes two references from lib.h that are there for no good reason. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-10[PATCH] sparse: add __GNUC_PATCHLEVEL__Alexey Dobriyan1-0/+3
Fix logs flooding on sparc: include/asm/bug.h:12:46: warning: undefined preprocessor identifier '__GNUC_PATCHLEVEL__'
2005-09-09[PATCH] More address space checkingviro@ZenIV.linux.org.uk1-0/+2
* generate a warning when we cast _between_ address spaces (e.g. cast from __user to __iomem). * optional (on -Wcast-to-as) warning when casting _TO_ address space (e.g. when normal pointer is cast to __iomem one - that caught a lot of crap in drivers). casts from unsigned long are still OK, so's cast from 0, so's __force cast, of course. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-08-15Add __OPTIMIZE[_SIZE]__ predefinesLinus Torvalds1-1/+21
As noted by Arnaldo Carvalho de Melo, some of the glibc header files expect these to be defined when compiling with optimization.
2005-08-03Update the calling interface to "sparse()".Linus Torvalds1-28/+40
Start off with sparse_initialize(argc, argv); which will return the number of filenames found. You can then use that, or just check if *argv is NULL in a loop like while (*argv) list = sparse(argv); where you get the declaration list for each file in turn.
2005-08-03Get closer to parsing multiple files correctly.Linus Torvalds1-24/+63
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.
2005-08-02Make "sparse()" handle multiple input files on the command lineLinus Torvalds1-48/+65
Pretty bogus right now, but at least it does more of the argument parsing, and the infrastructure is there to handle multiple files. It even works, sometimes. Mostly not, though - since it will actually use global scope for global types, and complain about redefinitions of the same struct when it sees ti in two different compilation units.
2005-08-02Start work on proper scoping with multiple filesLinus Torvalds1-0/+1
Brought on by a query from Mitesh Shah. I claimed it should be easy, let's see if I was full of sh*t (this is just some very early infrastructure, not the whole thing by any means!)
2005-07-03Add "__builtin_offsetof()" to work with newer gcc'sLinus Torvalds1-0/+1
It just expands to the normal offsetof definition
2005-06-20[PATCH] __attribute__ handling for attributes used in the userlandPeter Jones1-0/+2
Here's a patch that adds stubs for several attributes used in userland. This version of the patch includes a warning, which defaults to on, if you use gcc's "transparent_union" attribute, and has a flag (-Wno-transparent-union) to turn the warning off.
2005-06-19Default to reporting the same GNU C version as the host compilerLinus Torvalds1-2/+8
This is a bit hacky, but it tends to do what people expect most of the time.
2005-06-04[LIB] allow changing the gcc version in the definesArnaldo Carvalho de Melo1-2/+4
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2005-04-07[PATCH] static declearChristopher Li1-14/+14
This patch add static declare to make sparse happy of checking itself.
2005-04-07Move the ptrlist macros out of the sparse "lib.[ch]" files.Linus Torvalds1-212/+0
They rate their own "ptrlist" library status, since they are definitely potentially useful outside of sparse.
2005-04-07Shut up informational messages once we've hit the maximumLinus Torvalds1-8/+11
warning count. Also make errors shut up subsequent warnings.
2005-04-07[PATCH] make include path handling gcc compatibleSam Ravnborg1-11/+13
Search include paths in same order as gcc does. In other words search directories specified with -I before system directories. This fixes a bug reported by a few persons after the kernel switched over to use -isystem to specify where to find compiler specific include files. Sparse now supports the following include path relevant options: -I dir Add dir to list of directories to search for. Search dir before system dirs. Used for both <> and "" includes. -I- Split include path - previous -I dir paths only used for include "". Also disable searching same dir as input file. -isystem dir Add dir first in row of system dirs to search. -dirafter dir Add dir in end of system dirs to search. -nostdinc Discard all defined system dirs The -iwithprefix, -iprefix and -iwithprefixbefore options are not not supported and silently ignored. gcc discourage use of these options.
2005-04-07[PATCH] sparse: fails to locate stdarg.hSam Ravnborg1-0/+6
With latest change to kbuild where -isystem `gcc -print-file-name=include' is used to specify where to locate stdarg.h sparse failed to locate stdarg.h. This adds support of -isystem to sparse.
2005-04-07Add option "-Wptr-subtraction-blows" to warn about expensiveLinus Torvalds1-0/+2
pointer subtractions. Not only does it generate bad code (that can often be rewritten to not do that), it also causes gcc to go into horrible contortions, and Al Viro reports that it can make a factor of 2.5 difference in kernel build times to have just a few of these in common header file inline functions.
2005-04-07When removing/replacing pointer list entries, return the finalLinus Torvalds1-3/+6
count. The caller want to know how many got removed if they didn't specify an exact count to begin with.
2005-04-07Support tagged add_ptr_listLinus Torvalds1-1/+3
2005-04-07Beginning infrastructure for tagged lists.Linus Torvalds1-0/+3
Right now we verify that low bits are clear when inserting, and clear them on use.
2005-04-07Add "stream_name()" helper function, and use it.Linus Torvalds1-1/+1
Much prettier than "input_streams[x].name", since most users really don't want to know about the internals of how the preprocessor lays out its stream tracking.
2005-04-07Remove stat-based file identity tests.Linus Torvalds1-1/+0
Replace it with a simple pathname comparison instead. The pathname check is not only portable (no need for any compatibility helper functions), but we can do it much earlier, and thus make the check much cheaper by avoiding three extra system calls when it triggers (open/fstat/close). And the pathname test seems to match all the cases anyway.
2005-04-07Allow -vv as shorthand for "-v -v" aka "very verbose".Linus Torvalds1-1/+3
2005-04-07Fix list_ptr split operation.Linus Torvalds1-5/+8
We didn't set the back-pointer of the "next" entry properly. Not a lot of code cares, since most things just walk forward.
2005-04-07Fix pointer list "pack" operation.Linus Torvalds1-0/+1
When we packed away the first entry in the list, we didn't restart properly.
2005-04-07Add INSERT_CURRENT() macro to insert a new entry at theLinus Torvalds1-0/+14
point we are now when traversing a list. NOTE! If you traverse it forwards, the next entry you'll see is the current entry, since we do not change where in the list we are!
2005-04-07Split out the blob allocator from lib.c into allocate.c.Linus Torvalds1-144/+1
It's disgusting how intimate lib.c is with all the types, and this is slowly trying to split things up a bit. Now the intimate part is in allocate.c, but maybe we can get to the point where each allocation user just declares its own allocation strategy, and just uses the generic routines in allocate.c
2005-04-07Allow multiple levels of verbosity, and print out the _really_Linus Torvalds1-1/+1
uninteresting parts only with "-v -v". Dead blocks in particular. Also, don't even put a pseudo on the OP_RET if were a void function. That makes the liveness analysis happier.
2005-04-07Oops. Fix silly typo. Small but deadly - it broke the counted ptr replace.Linus Torvalds1-1/+1
Which explains why the flow info was all bad. Duh.
2005-04-07Remember to pack the pointer list after deleting entries from it.Linus Torvalds1-1/+3
2005-04-07Make list-ptr remove/replace take a count.Linus Torvalds1-10/+9
It will assrt if it can't find that many entries. Zero means "all the ones you can find", aka old behaviour.
2005-04-07Who says you can't do type-safe function-overloading in C?Linus Torvalds1-2/+2
You just have to be a bit crazy (*), and use "__typeof__" in creative ways. (*) Ok, a _lot_ crazy. But dammit, I want type-safety _and_ convenience, and I'm willing to do a few crazy macros to get it.
2005-04-07helper function cleanup: separate delete/replace list entries.Linus Torvalds1-6/+19
2005-04-07Add "optimize" flag, and collect the flags into lib.c.Linus Torvalds1-1/+12
Nothing uses it yet, but it's a good way to test bad ideas (call it an "optimization", and run diff on the result with and without).
2005-04-07Remove "struct phi", replace with instruction that generates a pseudo.Linus Torvalds1-2/+0
The instruction contains everything "struct phi" had, namely source bb and pseudo. And generating a new pseudo means that we not only have the pointer to the instruction that defines the phi-node (in pseudo->def), we also end up with automatic phi-node usage tracking (pseudo->users). The changes may look large, but almost all of this is just direct search-and-replace of the old phi-node usage.
2005-04-07Move all of the setup code to one single "sparse()" helper function.Linus Torvalds1-0/+89
Let's just face the fact that nobody actually wants to care about command line switches, builtins etc. Put it all in lib.c and make it easy to use.
2005-04-07Add pack_ptr_list() helper function.Linus Torvalds1-0/+37
It removes empty list blocks from the list. If you remove list entries, you should pack the list afterwards to make sure that there aren't any empty blocks that may upset the list walker functions.
2005-04-07Update copyright notices a bit.Linus Torvalds1-1/+1
2005-04-07Remove the horrid iterators.Linus Torvalds1-166/+0
Instead of having magic iterators over the last instruction of a basic block, we just add a list of "children" to each basic block. This removes all the packing logic, because it needs to be totally rewritten to work with the new iterators.
2005-04-07Since we only use the freelist for small alignedLinus Torvalds1-2/+6
entries, optimize for them. This cuts down another 10% on the test-case from hell.
2005-04-07Add support for freeing constant-sized allocations.Linus Torvalds1-0/+26
This is useful for tokens. They are nice and small and constant-sized, and there are millions and millions of them, so re-using them when we can actually matters.