Edoardo Prezioso
c3b54066bd
Merge branch 'master' of github.com:danmar/cppcheck
2011-11-19 13:36:05 +01:00
Edoardo Prezioso
ccdb18f213
Add a sanity check and an error message to linkAt when the index is outside the tokens range.
2011-11-19 13:34:36 +01:00
Daniel Marjamäki
c025bf9d57
Fixed #3332 (mismatching comparison: Hard to understand)
2011-11-19 08:38:54 +01:00
Daniel Marjamäki
033fef36da
improved error message 'mismatching comparison'
2011-11-18 20:07:42 +01:00
Daniel Marjamäki
e78131f9e6
Preprocessor: better handling of #define A 0 => #if A==0. ticket #3331
2011-11-17 19:19:43 +01:00
Marek Zmysłowski
994f08fdf0
Fixed #886 (new check: wrong value passed to isgraph function)
2011-11-17 16:31:16 +01:00
Stefan Weil
68a1b69d32
Preprocessor: Fix comments (backspace -> backslash)
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2011-11-15 19:30:43 +01:00
Stefan Weil
00ead7fb2e
support any number of --append=<file> options
...
If one or more append files are given on the command line,
they are simply concatenated.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2011-11-15 19:27:36 +01:00
Stefan Weil
785bc3d04b
Optimize handling of --append=<file> option (execution time, memory)
...
Whitespace was removed from the append data for every configuration
and every file: n(configuration) * n(files).
Removing whitespace immediately after the append data was read can
significantly reduce the execution time and memory usage.
It also allows further improvement because copies to the temporary
object appendCode are no longer needed.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2011-11-15 19:27:36 +01:00
Stefan Weil
d11f18b5df
cmdlineparser: terminate with error message if --append=<filename> fails
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2011-11-15 19:27:36 +01:00
Thomas Jarosch
c317c8979c
Run astyle
2011-11-14 09:21:42 +01:00
Thomas Jarosch
a645235d5a
Adapt Token::strAt() to return a const reference like Token::str() does
...
Saves us a complete conversion from string.c_str() back to std::string.
2011-11-14 09:19:46 +01:00
Richard Quirk
527236b321
Fix false positives for delete of known nulls
2011-11-13 22:38:34 +01:00
Edoardo Prezioso
2c64d299ca
Change every 'tokAt(...)->str()' to 'strAt(...)'.
2011-11-13 13:10:59 +01:00
Edoardo Prezioso
b28a44dc3b
Change: 'next()->next()'->'tokAt(2)', 'previous()->previous()'->'tokAt(-2)'.
2011-11-12 22:33:03 +01:00
Edoardo Prezioso
ed6a0e14c4
Add simplification of the consecutive braces before the end of 'tokenize()' function.
2011-11-12 16:59:20 +01:00
Edoardo Prezioso
5cbfbe31c1
Add removal of consecutive braces, i.e.: '{ { ... } }'->'{ ... }'.
...
Changed a little bit the dead code tests.
2011-11-12 12:07:10 +01:00
Edoardo Prezioso
2aceb623ae
1)Add 'Token' function 'linkAt', which simplifies the writing 'tokAt(i)->link()' to 'linkAt(i)'.
...
It's still unused, though.
2)Fix one grammatical mistake inside token.h
3)Style change to token.cpp: remove the whitespace between '!' and 'begin'.
2011-11-11 21:55:37 +01:00
Thomas Jarosch
283c2e508e
Remove check for "this" inside Token class
...
The check hides real memory problems and is
also useless in most cases.
2011-11-11 17:19:08 +01:00
Daniel Marjamäki
5a35beebf7
added todo comment
2011-11-11 11:07:03 +01:00
Daniel Marjamäki
34e40502c6
Fixed #3314 (cppcheck incorrectly reporting Syntax error.)
2011-11-11 10:53:49 +01:00
Daniel Marjamäki
8bbd535267
Fixed #3290 (False positive: Null pointer dereference (typeid))
2011-11-11 09:58:17 +01:00
Daniel Marjamäki
688e290332
Memory leaks: Fixed false positive for 'char *p = strcpy(malloc(10),str);'
2011-11-11 09:07:02 +01:00
Daniel Marjamäki
410b11c00f
Merge pull request #60 from richq/varid0
...
Fix varid 0 with function pointer and virtual methods
2011-11-09 14:28:54 -08:00
Thomas Jarosch
1a454256dc
Cache result of tok->isStandardType()
...
Also contains test order improvements from Johan Samuelson (#3116 ).
Run time went down from 15.15s to 14.95s for the case below.
Benchmarked using these settings:
- CXXFLAGS="-O2 -g -NDEBUG"
- time -p cppcheck.git -q --std=posix --enable=all --inconclusive -Dfoo .
on the "rpm" codebase.
2011-11-09 21:56:30 +01:00
Richard Quirk
f56aa19fac
Fix varid 0 with function pointer and virtual methods
2011-11-09 21:07:55 +01:00
Thomas Jarosch
c010ca33a5
Run astyle
2011-11-09 20:34:58 +01:00
Daniel Marjamäki
2d00cabee1
Fixed #3279 (Token::Match called with varid 0)
2011-11-09 18:49:17 +01:00
Daniel Marjamäki
b7cc9779c4
Merge pull request #59 from richq/sameexpr
...
Improved same expression check for ticket #3274
2011-11-08 23:56:36 -08:00
Daniel Marjamäki
3b11ae3fac
Merge pull request #58 from richq/autoptr
...
Fix namespaced types for auto_ptr new[] errors
2011-11-08 23:49:59 -08:00
Reijo Tomperi
7a294c1f79
Fix #3307 (Invalid format string/parameter mismatch warning)
...
http://sourceforge.net/apps/trac/cppcheck/ticket/3307
2011-11-09 00:16:37 +02:00
Edoardo Prezioso
0569953753
Fixed ticket #3309 (false positive: (style) Boolean result is used in bitwise operation. Clarify expression with parentheses)
2011-11-08 22:48:14 +01:00
Richard Quirk
d5c7c5d098
Remove duplicate expressions on both sides of ||
2011-11-08 21:56:54 +01:00
Richard Quirk
d1bc8819f9
Fix for same expression separated by commas
...
The code branch tested by the previous check for && is now different, so
I've changed the test to use == instead. There was also a missing case
when the expression was followed by a comma instead of being preceded by
one.
2011-11-08 21:56:54 +01:00
Richard Quirk
d5664dd6cf
Improved %or% and & checks
2011-11-08 21:56:54 +01:00
Richard Quirk
4cb97edbaf
Improved same expression check for ticket #3274
...
Expand the logic for the check for the same expression on both sides of
the || and && operators. Now expressions can be more complex, with the
"alt" variable helping to fudge operator precedence to avoid false
positives.
2011-11-08 21:54:42 +01:00
Edoardo Prezioso
3cc9a333c9
Fixed tokenizer: don't change '*(str+num)' if '*' means a product with a previous variable or number.
...
Ditto for '&str[num]' (still commented).
2011-11-08 18:14:43 +01:00
Edoardo Prezioso
a546fc6e9d
Fixed ticket #3310 (segmentation fault of cppcheck)
2011-11-08 17:37:24 +01:00
Edoardo Prezioso
aaa77c4709
Improve tokenizer: remove more redundant parenthesis and add a prototype code for: '&str[num]'=>'(str+num)' with reporting non obvious test failures.
2011-11-07 23:40:06 +01:00
Marek Zmysłowski
fed875f4a4
Fix #70 (Locate memory leaks when alloc happens in function parameter)
...
http://sourceforge.net/apps/trac/cppcheck/ticket/70
2011-11-07 23:50:57 +02:00
Reijo Tomperi
7b7e072b88
Fix #3278 (FP: Possible null pointer dereference with for loop)
...
http://sourceforge.net/apps/trac/cppcheck/ticket/3278
Bail out if token "for" is encountered.
2011-11-07 22:10:21 +02:00
Edoardo Prezioso
5cf7cb9ff5
Conforming style: always use 'std::' namespace where needed. This removes the mixing style inside the code.
2011-11-07 00:54:00 +01:00
Thomas Jarosch
a83c47d9cf
Fix false positive of %or% match in alternative pattern match code
...
%or% triggered on code using "|=" or "||".
2011-11-06 22:12:31 +01:00
Richard Quirk
7f88b66842
Fix namespaced types for auto_ptr new[] errors
...
This fixes false negatives for code such as:
std::auto_ptr<foo::bar> p(new foo::bar[10]);
The idea is to find a "new", search for the end token ";", then see if
the declaration ends in a closing square bracket. Also fixes other cases
that checked for "new %type% [" so that they work with namespaces.
2011-11-06 21:20:24 +01:00
Daniel Marjamäki
fa076598ad
Fixed #3233 (false positive: (style) Checking if unsigned variable 'i' is less than zero.)
2011-11-06 18:24:37 +01:00
Thomas Jarosch
19c9c97608
Fix single %op% operator not working at all
...
When parsing the Token::Match pattern, we accesed
the wrong character in the pattern and never
executed the %op% check.
In addition the unit test function for %op%
wasn't registered in the test suite. Ups.
All fixed now and also provide a complete
check for all operators %op% supports.
2011-11-06 18:02:18 +01:00
Edoardo Prezioso
6e2f2816de
Improve same expression check: remove '%op%' pattern and add ',' for the same expressions as an argument inside a function.
...
Improve compound assignment simplification: use already defined 'isAssignmentOp' and extend the adding parenthesis to a generic operator, not only to the arithmetical ones. See: http://en.cppreference.com/w/cpp/language/operator_precedence
2011-11-06 14:35:53 +01:00
Daniel Marjamäki
f092779a4d
Fixed #3282 (Invalid report that an array index is of type char.)
2011-11-06 11:26:28 +01:00
Daniel Marjamäki
ed97b62610
Fixed #3275 (Missing includes always reported)
2011-11-06 08:59:07 +01:00
Daniel Marjamäki
e11c1f7975
Fixed #3265 (false positive: comparison of bool with nonzero integer)
2011-11-06 08:21:34 +01:00
Edoardo Prezioso
99463d3368
Improve same expression check: take count of operations and assignments before the same expression and add missing 'return' pattern to the struct member variable part of the check.
2011-11-05 22:25:01 +01:00
Daniel Marjamäki
d4a8184339
Fixed #3251 (Redundant code: Found a statement that begins with numeric constant)
2011-11-05 20:28:52 +01:00
Daniel Marjamäki
9903c8c0d9
astyle formatting
2011-11-05 20:00:18 +01:00
Daniel Marjamäki
2f32965bdf
Token: assert that multicompare patterns don't begin with some %% command
2011-11-05 19:59:48 +01:00
Daniel Marjamäki
5edf153602
Fixed #3294 (Token::Match multi compare false negative)
2011-11-05 19:24:21 +01:00
Daniel Marjamäki
580fef6951
Merge pull request #55 from richq/sameexpr
...
Improve for same expression on both sides of operator
2011-11-05 10:28:14 -07:00
Richard Quirk
a3f2c1e651
Improve for same expression on both sides of operator
2011-11-05 15:46:11 +01:00
Richard Quirk
68202d8ffb
Extra check for auto_ptr new[]
...
This fixes cases like this:
auto_ptr<foo> bar(new foo[10]);
which previously did not work correctly.
2011-11-05 15:45:59 +01:00
Daniel Marjamaki
b96ab6ba26
Fixed #3188 (Function parser false positive)
2011-11-05 12:23:05 +01:00
Daniel Marjamäki
085a6285fa
Fixed #3117 (Tokenizer::simplifyKnownVariables : Don't simplify static variable that is changed)
2011-11-05 08:30:11 +01:00
Daniel Marjamäki
d3b27c40fc
fixed --doc output
2011-11-05 07:45:30 +01:00
PKEuS
0c469bae41
Fixed #3089 (New Check: Detect wrong usage of printf/scanf)
2011-11-05 07:29:53 +01:00
Thomas Jarosch
4342fd254c
Fixed #3266 (False positive on dangerous usage of .c_str())
2011-11-04 19:21:19 +01:00
Reijo Tomperi
682aae3196
Improve internal error print out, print line number with the error message.
2011-11-03 22:43:13 +02:00
Daniel Marjamäki
9b8ffe7219
Fixed #3248 (Tokenizer: better handling of char constants that are compared with numeric constants)
2011-11-03 20:03:31 +01:00
Daniel Marjamäki
73f3b2074b
Fixed #3285 (wrong #elif behaviour)
2011-11-03 19:05:48 +01:00
Daniel Marjamaki
b6b5416b42
Tokenizer: Fixed failed unit test
2011-11-02 20:42:38 +01:00
Daniel Marjamaki
dfcbc38466
Preprocessor: Don't warn about missing system headers during 'normal' preprocessing
2011-11-02 18:40:56 +01:00
Daniel Marjamaki
0884204c2f
Fixed #3279 (Token::Match called with varid 0)
2011-11-02 18:31:13 +01:00
Daniel Marjamäki
af7bf5c805
removed 'explicit constructors' check. see comments in pull request #51 for the reasons.
2011-11-02 17:12:46 +01:00
Daniel Marjamaki
937a4497ca
Fixed #3272 (Internal error)
2011-11-01 18:03:32 +01:00
Edoardo Prezioso
9dd3360cd6
Fix some complainted choices made in my older commits.
...
Note: probably you should do 'make clean' before using 'make' to rebuild it again. Maybe it's me but 'make' reports various errors when linking.
2011-11-01 13:23:47 +01:00
Daniel Marjamäki
b18778129c
STL: updated error messages for 'useless call to find/swap/substr'. Ticket: #3258
2011-10-31 21:32:30 +01:00
Daniel Marjamäki
7d7a54d89c
Merge pull request #53 from gansb/master
...
Add missing newline
2011-10-31 11:53:33 -07:00
Daniel Marjamäki
a7f27a83a7
Fixed #3271 (Regression: something related to symbol database / varid)
2011-10-31 18:33:15 +01:00
Benjamin Goose
f22f9fcc0e
Add newline at end of file!
2011-10-31 15:12:29 +01:00
Edoardo Prezioso
4295439e53
Fixed ticket #3269 (Regression, I think it's somehow related to symbol database)
2011-10-31 15:05:52 +01:00
Edoardo Prezioso
ba5909ef1d
General code tweaking, nothing strange.
2011-10-31 02:24:59 +01:00
Daniel Marjamaki
f2199adc3f
Preprocessor: Bailout #include if it is recursive
2011-10-30 19:00:11 +01:00
Daniel Marjamäki
278ba0ab3a
Preprocessor: Enable 'normal' preprocessing whenever any defines are given. The special define CPPCHECK-TEST isn't needed anymore.
2011-10-30 18:40:59 +01:00
Edoardo Prezioso
433f4640a9
Fix some GCC warnings regarding the sign conversion.
2011-10-30 18:34:49 +01:00
Daniel Marjamäki
f7fe665b00
Fixed #3231 (False positive: uninitialized variable '({...})')
2011-10-30 18:19:09 +01:00
Daniel Marjamäki
63937f592e
Fixed #3228 (false positive: possible null pointer dereference)
2011-10-30 17:59:38 +01:00
Daniel Marjamäki
7035d4cdd2
astyle formatting
2011-10-30 17:41:05 +01:00
Daniel Marjamaki
71f08d0a66
Fixed #3222 (false positive: Uninitialized variable with function pointer)
2011-10-30 17:22:30 +01:00
Edoardo Prezioso
4fc7e86d7d
Fixed: with checkConst and checkVariableScope wanted still required "information" settings instead of "style".
2011-10-30 10:58:15 +01:00
Daniel Marjamaki
132f0e12d1
CheckClass: Added classInfo about explicit checking
2011-10-30 09:54:02 +01:00
Daniel Marjamaki
8514466c68
Visual Studio: Fixed compiler error
2011-10-30 09:53:14 +01:00
Daniel Marjamäki
0d1046eeeb
Merge pull request #51 from richq/explicit
...
Explicit constructors
2011-10-30 01:38:26 -07:00
Edoardo Prezioso
42fd4e2f52
Tokenizer: Change 'var++|--;' into '++|--var;' and remove redundant 'tokAt(0)'.
2011-10-29 22:25:49 +02:00
Daniel Marjamäki
92333b585a
Fixed #3092 (Tokenizer::setVarId : shadow variable in member function gets the wrong varid)
2011-10-29 21:25:58 +02:00
Daniel Marjamäki
d7be62a6f9
Fixed #3221 (FP: Array 'arr[2147483648]' index 0 out of bounds in loop when size unknown to cppcheck)
2011-10-29 20:26:24 +02:00
Daniel Marjamäki
24a2b6e6ba
Fixed #3195 (operator() from a functor-struct is never used)
2011-10-29 20:04:43 +02:00
Daniel Marjamäki
a809bb3471
astyle formatting
2011-10-29 19:51:11 +02:00
Daniel Marjamäki
acaa9c456f
Fixed #3152 (Tokenizer: template constructor is removed)
2011-10-29 19:45:47 +02:00
Daniel Marjamäki
316aa920eb
Fixed #3245 (False positive: Dangerous usage of 'string' (strncpy doesn't always 0-terminate it))
2011-10-29 19:11:42 +02:00
Richard Quirk
a0a5b36667
Ensure single-argument constructors are explicit
2011-10-29 18:24:30 +02:00
Richard Quirk
2ca932a3ae
Add checks for explicit constructors
...
Single-argument constructors should be explicit. Constructors with
multiple arguments should not be marked explicit.
2011-10-29 18:24:16 +02:00
Daniel Marjamäki
8f49eb6a7e
Tokenizer: Make sure that friend classes don't get varid. Ticket: #2962
2011-10-29 18:22:58 +02:00
Daniel Marjamäki
d75ef01d2b
Null pointer: Added inconclusive error message when calling member function of NULL object.
2011-10-29 15:48:54 +02:00