Zachary Blair
344d7e2f34
Fixed #3283 (False negative: array index out of bounds not found for constant string and known array index value)
2011-11-30 19:17:09 -08:00
makulik
8c04431b17
Removed int cast from undef preprocessor testcases
...
Signed-off-by: makulik <g-makulik@t-online.de>
2011-11-30 22:10:49 +01:00
makulik
31c22ca31e
Fixed preprocessor testcases
...
Signed-off-by: makulik <g-makulik@t-online.de>
2011-11-30 21:51:23 +01:00
Daniel Marjamäki
0bf17213ec
Merge pull request #65 from makulik/master
...
Solution for ticket #3353 'Allow explicit undef's for configuration'
2011-11-30 12:42:11 -08:00
Daniel Marjamäki
323019c48f
Fixed #3355 (False positive: member variable initialization (::ZeroMemory))
2011-11-30 21:28:16 +01:00
makulik
1e8fc71f8e
Solution for ticket #3353 'Allow explicit undef's for configuration'
...
Signed-off-by: makulik <g-makulik@t-online.de>
2011-11-30 20:24:01 +01:00
PKEuS
ee3e10ea97
Fixed #3364 (Crash in printf parsing)
2011-11-30 20:23:29 +01:00
Daniel Marjamäki
d0247f3a8d
Fixed #3268 (False positive: resource leak in vdr-xineliboutput)
2011-11-30 20:07:56 +01:00
Daniel Marjamäki
dcd3f4fe3d
Fixed #3267 (False positive (experimental): resource leak in vdr-xinelib)
2011-11-30 19:43:02 +01:00
Daniel Marjamäki
414e0ecc3c
Uninitvar: Reactivated the checking
2011-11-30 18:57:52 +01:00
Daniel Marjamäki
b61c01c6a4
Fixed #3356 (false positive: (warning) Comparison of a boolean with integer that is neither 1 nor 0)
2011-11-29 18:14:57 +01:00
Daniel Marjamäki
b538f49a6e
Merge pull request #61 from richq/sameexpr
...
Fix for #3317 - same expression on both side of '&&' false positives
2011-11-29 08:50:02 -08:00
PKEuS
be0acad11f
Improvements to Nullpointer dereference on function call check:
...
printf format string parser improved (similar to my recent patch
on the argument counter), frexp/modf supported (#1572 ), Code
cleanup
2011-11-28 22:32:07 +02:00
Daniel Marjamäki
39af75abb4
Fixed #3303 (false positive: memory leak (reference count))
2011-11-28 20:08:29 +01:00
Daniel Marjamäki
522da8d258
sizeof for numeric constant : disabled check. see ticket #3179
2011-11-27 18:50:21 +01:00
Marek Zmysłowski
e0b50719f4
Fixed #909 (improve check: out of bounds of memchr function and out of bounds check)
2011-11-27 07:54:52 +01:00
PKEuS
71c8669261
Fixed #3311 , #3313 and #3339 (printf format string false positives)
2011-11-27 07:29:09 +01:00
PKEuS
6b1594244e
code cleanups and refactorings
2011-11-26 21:15:16 +01:00
Daniel Marjamäki
50c320ef27
memory leaks: Made leak checking inconclusive instead of experimental
2011-11-25 14:47:45 +01:00
Marek Zmysłowski
a8f2dc1fec
Fixed #1841 (STL: false negative for invalidated iterator after erase)
2011-11-25 07:34:50 +01:00
Marek Zmysłowski
3ae96600b5
Fixed #3212 (Simplify the double pointer cast)
2011-11-25 07:23:54 +01:00
Thomas Jarosch
0722da026f
Run astyle
2011-11-24 10:08:21 +01:00
Richard Quirk
d28cf42d4c
Fix ticket #3317 (same expression false positives)
...
Add a check for function calls that have no side effects. That means
known const methods and a list including strcmp, strlen, etc.
If the function is not known to be side effect-free then no style
warning is given.
Add test cases for the duplicate expressions.
2011-11-23 21:39:03 +01:00
Richard Quirk
511ac0ab1f
Remove false positives for nested logic
2011-11-23 21:39:03 +01:00
Richard Quirk
b0574cd02e
Fix ticket #2233 (unused private static function)
2011-11-23 21:28:08 +01:00
Richard Quirk
d76657fec8
Fix false positives for null pointer on exit
2011-11-23 21:27:15 +01:00
Daniel Marjamäki
1b1fd9d39c
Fixed #3196 (False positive: member variable not initialized in constructor (union))
2011-11-22 19:26:00 +01:00
Daniel Marjamäki
add2b3706b
Fixed #3352 (False positive: member variable not initialized (3D array))
2011-11-22 18:45:25 +01:00
Daniel Marjamäki
17f891ad34
Tokenizer::setVarId: Fixed problem with class declarations with inheritance. skip them.
2011-11-21 21:18:56 +01:00
Daniel Marjamäki
9aa8a49677
Tokenizer::setVarId: fixed 'using' bug
2011-11-21 18:04:42 +01:00
Daniel Marjamäki
648fcb9e42
operator= should return reference: Made check inconclusive. See ticket #3296
2011-11-21 08:00:10 +01:00
Daniel Marjamäki
5b5ea29f23
Mismatching format string parameters. Made check experimental. See tickets #3311 , #3313 and #3339
2011-11-21 07:31:06 +01:00
Reijo Tomperi
eebd1393ff
"Internal error. Token::Match called with varid 0." didn't work when error was in a header file. Fixed that.
2011-11-21 00:41:26 +02:00
Reijo Tomperi
91e89380c2
astyle fix
2011-11-20 23:43:55 +02:00
Reijo Tomperi
e0ea4228cd
"Internal error. Token::Match called with varid 0." will now cause check to abort and write a proper error log with filename. Previously filename was empty and format was always xml.
2011-11-20 23:38:37 +02:00
Daniel Marjamäki
004dcf834b
Fixed #3281 (Tokenizer::simplifyKnownVariables : static constant value is not used)
2011-11-20 21:50:26 +01:00
Marek Zmysłowski
9a8c48b36e
Fixed #3255 (Error message for std::string::c_str() is not descriptive)
2011-11-20 19:26:07 +01:00
Edoardo Prezioso
d0d5a2fcd8
Completed ticket #3230 (Refactoring: add function to remove tokens when a label is found.) and fixed ticket #3264 (False positive: Variable is assigned a value that is never used).
2011-11-20 18:37:00 +01:00
Daniel Marjamäki
77925dc629
Class checking: made 'technically function x can be const' inconclusive
2011-11-20 16:54:06 +01:00
Daniel Marjamäki
b26811cdf5
astyle formatting
2011-11-20 16:50:41 +01:00
Richard Quirk
91713ffe84
Fix false positives for %[ in scanf
2011-11-20 16:48:54 +01:00
Daniel Marjamäki
097637a66c
Fixed #3316 (Cppcheck reporting internal errors - code compiles cleanly)
2011-11-20 16:22:21 +01:00
Daniel Marjamäki
b92959809c
Uninitvar: Made checking experimental
2011-11-20 15:19:56 +01:00
Edoardo Prezioso
11dd3c09ce
Change every 'tokAt(1)->' to 'next()->' because 'tokAt(1) == 0' is equivalent to 'next() == 0', hence the equivalent cppcheck crash.
2011-11-20 15:09:57 +01:00
Edoardo Prezioso
42e369a4b4
Change every 'tokAt(..)->link()' to 'linkAt(..)'.
2011-11-20 14:24:27 +01:00
Daniel Marjamäki
690702a742
Memory leaks: Made CheckMemoryLeakInFunction experimental
2011-11-20 14:11:22 +01:00
Daniel Marjamäki
1cf45a5cde
Fixed #3280 (False positive: assigned value that is never used)
2011-11-20 12:09:07 +01:00
Daniel Marjamäki
8c091ff968
Fixed #3340 (Internal error. Token::Match called with varid 0... union is causing problems)
2011-11-20 08:13:28 +01:00
Daniel Marjamäki
c025bf9d57
Fixed #3332 (mismatching comparison: Hard to understand)
2011-11-19 08:38:54 +01:00
Edoardo Prezioso
fa34a14d57
Add more tests for flow control simplification.
2011-11-18 21:10:56 +01:00
Edoardo Prezioso
44e348d018
Add test for the consecutive braces simplification, thanks to thomasjfox's example.
2011-11-18 21:04:24 +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
Thomas Jarosch
c317c8979c
Run astyle
2011-11-14 09:21:42 +01:00
Richard Quirk
527236b321
Fix false positives for delete of known nulls
2011-11-13 22:38:34 +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
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
Reijo Tomperi
ca70693055
Astyle fix
2011-11-10 22:32:37 +02: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
Thomas Jarosch
7202a51065
Add negative test for .c_str() unit test and TODO_ASSERT_EQUALS ( #3266 )
2011-11-09 21:08:53 +01:00
Richard Quirk
f56aa19fac
Fix varid 0 with function pointer and virtual methods
2011-11-09 21:07:55 +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
392f705b73
Oops.
2011-11-08 23:10:53 +01: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
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
8a60ceed82
Add test for Token::eraseTokens.
2011-11-08 18:59:31 +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
3abece027e
Refactoring: unify same dead code tests with a list.
2011-11-08 14:13:26 +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
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
Thomas Jarosch
1360c554ed
Extended isOp() tests to do proper negative testing against other operators
2011-11-06 21:20:13 +01:00
Thomas Jarosch
7ef1107a55
Unit test for Token::isArithmeticalOp() and Token::isStandardType()
2011-11-06 18:55:02 +01:00
Thomas Jarosch
d7ce892c06
Unit test for %varid% match
...
Also run astyle.
2011-11-06 18:37:45 +01:00
Thomas Jarosch
05c4b97bbe
Unit test for %type% and %str% matches
2011-11-06 18:30:34 +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
95851454cc
Unit test for Token::isExtendedOp() and Token::isAssignmentOp()
2011-11-06 18:19:27 +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
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
Thomas Jarosch
2a46c635f6
Test case to demonstrate #3294
2011-11-05 14:04:23 +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
PKEuS
0c469bae41
Fixed #3089 (New Check: Detect wrong usage of printf/scanf)
2011-11-05 07:29:53 +01:00
Daniel Marjamäki
b91d5e076a
Merge pull request #54 from gansb/master
...
Testcases for #3287 and #3290
2011-11-04 22:57:43 -07:00
Thomas Jarosch
4342fd254c
Fixed #3266 (False positive on dangerous usage of .c_str())
2011-11-04 19:21:19 +01:00
Benjamin Goose
54c445ca20
Add tests for various bugs.
...
False positive: uninitialized variable (ticket #3287 ).
False positive: null pointer dereference in typeid (ticket #3290 ).
2011-11-04 12:27:32 +01: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
8950b4bd72
Removed old test case for missing includes. There is better testing in TestPreprocessor::def_missingInclude
2011-11-02 20:34:57 +01:00
Daniel Marjamaki
4fe3f8f080
Preprocessor: Unit test handling of missing includes in 'normal' preprocessing
2011-11-02 20:29:14 +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
Ettl Martin
603a37b08a
added testcase for ticket #3273
2011-11-01 11:52:39 +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
a7f27a83a7
Fixed #3271 (Regression: something related to symbol database / varid)
2011-10-31 18:33:15 +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
68cb7a2731
Fix all the test failures caused by my previous commit.
2011-10-30 11:27:27 +01:00
Edoardo Prezioso
44a234f9b0
Fixed lots of test failures caused by my previous commit.
...
There are still some which I don't know how to fix.
2011-10-30 11:21:46 +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
0bb1ad8782
Little improvements with cli messages and added new '--template' mode: 'edit'.
...
This option makes it possible opening correctly some editors like 'gedit' or 'vim' by copy-pasting the filename and the line to the command sequence.
2011-10-29 23:50:09 +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
dc29d43e83
astyle formatting
2011-10-29 20:27:50 +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
acaa9c456f
Fixed #3152 (Tokenizer: template constructor is removed)
2011-10-29 19:45:47 +02:00
Thomas Jarosch
0f299aa9bf
FileLister (linux): Move absolute path determination to own function
...
Cleans up the #ifdef hell in the code.
Provide unit test for it.
2011-10-29 19:30:33 +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
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
Richard Quirk
b88d61dcb4
Make single-argument test constructors explicit
2011-10-29 18:17:25 +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
Thomas Jarosch
ad40586e96
Disable internal checks if NDEBUG is defined (release build)
2011-10-29 12:47:12 +02:00
Thomas Jarosch
3d438003ff
Add internal check that searches Token::Match() patterns for missing % end charaters
...
Example: "%type" or "foo %var bar"
2011-10-29 12:22:26 +02:00
Daniel Marjamäki
b67cb077a3
fix unit test failure
2011-10-29 12:21:22 +02:00
Daniel Marjamäki
8416768e03
Merge pull request #50 from richq/strncmp
...
Improved strncmp checks
* strings are always the same
* inconclusive: using sizeof(char *) as size parameter
2011-10-29 03:13:21 -07:00
Reijo Tomperi
5e0e2c4782
Fix #3256 (Null pointer dereference not detected)
...
http://sourceforge.net/apps/trac/cppcheck/ticket/3256
It is now detected if --inconclusive command line argument is given (the argument is unofficial currently)
2011-10-29 11:35:31 +03:00
Marek Zmysłowski
950460c0a7
Fixed #3261 (Function 'find' useless call. The variable 'str' is using function 'find' against itself)
2011-10-29 09:24:05 +02:00
Thomas Jarosch
f6e68914ea
Add check for cppcheck's internal API usage ( #3263 )
...
First checks:
- Simple pattern used inside Token::Match()
- Complex pattern used inside Token::simpleMatch()
The checks get enabled by passing "--enable=internal".
It's not included in "--enable=all".
If you see something that needs further tweaking, just go for it!
2011-10-28 22:46:07 +02:00
Thomas Jarosch
e3c67fed12
Run astyle
2011-10-28 22:43:02 +02:00
Thomas Jarosch
91a5d95bc9
Use Token::simpleMatch() / Token::findsimplematch() where possible
2011-10-28 22:31:05 +02:00
Richard Quirk
665cdfabdc
Warn when sizeof is used in strncmp ticket #2095
...
This checks for the case where the user thought sizeof(buf) gave the
size in bytes of 'buf' in code like the following:
const char *buf = "Hello World";
strncmp(buf, other, sizeof(buf));
2011-10-28 22:14:55 +02:00
Richard Quirk
90c7db15a0
Add check for comparison of identical string variables
2011-10-28 22:12:51 +02:00
Richard Quirk
4ba6ac7332
Add strncmp to the list of static string comparison functions
2011-10-28 22:12:51 +02:00
Ettl Martin
4a14672d0b
added unittest for ticket #1780
2011-10-27 23:54:03 +02:00
PKEuS
d6261debdf
Fixes false positives in test suite, adds unit test for void-simplification
2011-10-27 21:54:42 +03:00
Thomas Jarosch
43e9c1f0bd
STL check: Detect return of implict string conversion + .c_str()
...
Examples are:
std::string msg;
return ("ERROR: " + msg).c_str();
or
return ("ERROR: " + std::string("crash me")).c_str();
2011-10-26 22:14:47 +02:00
Thomas Jarosch
c4dabd61e9
STL check: Check if someone tries to return std::string(crash_me).c_str()
2011-10-26 21:45:27 +02:00
Thomas Jarosch
03fd308dbf
STL check: Look for string.c_str() / stringstream.str().c_str() "return" usage (object is destroyed on return)
2011-10-26 21:12:06 +02:00
seb777
1a6706005f
Test to close Ticket #1879
2011-10-25 22:38:23 +02:00
Daniel Marjamaki
4b57a146fb
Preprocessor: Unit test #error and missing includes. Ticket: #2131
2011-10-25 19:55:47 +02:00
Marek Zmysłowski
190139f441
Fixed #3174 (New check: Useless calls of STL functions)
2011-10-24 23:25:23 +02:00
Daniel Marjamäki
f0d8fd7235
Preprocessor: updated tests
2011-10-24 21:56:43 +02:00
Thomas Jarosch
3413ffef3e
Refactor readlink() buffer check to also handle readlinkat()
2011-10-24 21:23:18 +02:00
Daniel Marjamaki
0eb4e3032a
Preprocessor: handle '#undef' better. Ticket: #2131
2011-10-24 19:51:00 +02:00
Daniel Marjamaki
08ba378730
Preprocessor: Improved 'normal' preprocessing. better handling of multiple #elif and #else blocks
2011-10-24 08:11:44 +02:00
Daniel Marjamaki
3de70a7244
Preprocessor: Better 'normal' preprocessing. Simple handling of '#elif'
2011-10-24 07:37:47 +02:00
Reijo Tomperi
36ef8e771f
Improve null pointer dereference test coverage
2011-10-24 00:36:57 +03:00
Thomas Jarosch
1ccb57e595
Document and test Token::concatStr()
2011-10-23 21:21:42 +02:00
Thomas Jarosch
5b97cc1440
Bugfix: Update token properties on string changes
2011-10-23 21:06:56 +02:00
Daniel Marjamaki
9e50b7cb68
Preprocessor: updates to 'normal' preprocessing
2011-10-23 19:17:29 +02:00
Daniel Marjamäki
1a5aba062c
test/test.pro: indentation update
2011-10-23 15:45:56 +02:00
Daniel Marjamaki
605bd23517
Visual Studio: auto generated new visual studio project files
2011-10-23 15:42:02 +02:00
Thomas Jarosch
db8c7deb30
Fixed #3232 (Check if container is modified inside BOOST_FOREACH)
2011-10-23 13:07:43 +02:00
Thomas Jarosch
9a1b195d79
Fixed #3187 (Remove code duplication in 'other' unit test)
2011-10-23 12:20:43 +02:00
PKEuS
54b3d72ee3
Added Token::nextArgument()
2011-10-23 11:23:48 +02:00
Erik Lax
b7ab1e7d7e
Fixed #3237 (Bug in parser of class operator functions)
2011-10-23 10:25:14 +02:00
Daniel Marjamäki
65380d16d6
Test: Fixed testing
2011-10-23 10:22:10 +02:00
Daniel Marjamäki
8579270582
astyle formatting
2011-10-23 10:11:43 +02:00
Daniel Marjamäki
a381581a8b
Merge pull request #43 from makulik/master
...
#3244 'Get include pathes from file'
2011-10-23 01:04:31 -07:00
Reijo Tomperi
3568b5a841
Improved memset with 0 bytes check. TODO done (unit test).
...
Patch from: PKEuS <philipp.kloke@web.de>
2011-10-22 23:34:10 +03:00
unknown
597a37cc32
#3244 'Get include pathes from file'
...
Signed-off-by: Günther Makulik <g-makulik@t-online.de>
2011-10-22 21:24:23 +02:00
Edoardo Prezioso
91c6608175
Improve fix of #934 (be careful of macros code).
2011-10-22 20:43:42 +02:00
PKEuS
20179673ce
Fixed #934 (new check: missuse of std::cout)
2011-10-22 17:12:52 +02:00
Johan Samuelson
3d8fa2f76e
Fixed #3123 ([False Positive] Shadowed enum)
2011-10-22 13:43:53 +02:00
Erik Lax
2b54f00c87
Fixed #3238 (Crash in obsolete functions check.)
2011-10-22 12:36:45 +02:00
Thomas Jarosch
55d9f0873a
Fix #3243 (Improve non reentrant function check)
...
- Use std::map instead of linear std::list walk
and run fast tests like tok->isName() first.
Global speed up is 4.8% (profiled with google-perftools)
- Catch function invocations in global namespace
and ignore other namespaces except "std".
std::localtime() and others are also non-thread safe on POSIX.
Note: The check matches f.e. also on "std::getrpcbyname()",
but that would result in a compile error anyway.
No need to have an extra "std::xxxxx" whitelist.
- Remove double listed "rand" and "getrpcbyname" function names
2011-10-22 11:54:52 +02:00
Daniel Marjamäki
a9d2d45fbc
astyle formatting
2011-10-22 11:11:54 +02:00
Daniel Marjamäki
ab827e3631
Merge pull request #40 from joshbeck/master
...
Added option to set #ifdef configuration check limit
2011-10-22 00:51:05 -07:00
Marek Zmysłowski
b332ea8222
Fixed #3204 (Refactor standards support in Settings)
2011-10-22 09:45:48 +02:00
Edoardo Prezioso
9e5beab4a8
Nitpicky fix of the missing ';' after the memset command inside the test case.
2011-10-20 21:46:34 +02:00
seb777
41d9daa03d
Fixed ticket #3133 (Improve Check: Found obsolete function)
...
- add check for std::gets
- improve check when multiple obsolete functions are used
- remove false positive (declared functions)
2011-10-19 20:21:50 +02:00
Edoardo Prezioso
9257e82475
Improve tokenizer: don't confuse between a label and the case/default statements.
2011-10-19 18:49:02 +02:00
Edoardo Prezioso
882b0c15a0
Improve tokenizing of "do{ ... } while(0)".
...
The simplification will be the same for every combination, except for the 'continue' and the 'break'. In that case, keep the block braces.
2011-10-19 18:20:29 +02:00
Edoardo Prezioso
73f0e2c5b9
Fixed ticket #3227 (Improve tokenizer: labels are not handled correctly after a case or another label instruction)
...
Moved the labels simplification after combining the tokens and moved the case/default simplification inside the labels.
2011-10-19 14:20:09 +02:00
Joshua Beck
56561835f8
Add option to set #ifdef configuration check limit
2011-10-18 19:52:55 -05:00
Edoardo Prezioso
f4cdf57955
Fixed ticket #3229 (Segfault with goto):
...
Don't handle labels, gotos, returns and indentations inside the round braces. This is applied not only for simplifyGoto, but also to simplifyFlowControl.
Rewrite enum badly handled by astyle inside mathlib.cpp and move simplifyFlowControl at the end of the simplifyTokenList in order to catch more dead code, not related to the ticket.
2011-10-18 23:56:35 +02:00
PKEuS
dc15641954
Fixed #3223 (Improve check: Check more STL algorithms for missmatching containers check)
2011-10-18 21:55:41 +02:00
PKEuS
ea02bd905a
Fixed #3225 (Boolean comparison with string literals)
2011-10-18 21:37:03 +02:00
Daniel Marjamäki
3d18fdfa3f
Fixed #3220 (False positive: possible null pointer dereference: 'SwDoc *pDoc = NULL; pDoc->do_something();')
2011-10-18 19:34:14 +02:00
Daniel Marjamaki
bf0386c938
Preprocessor: Started working on new preprocessing that uses -D information better. Ticket: #2131
2011-10-17 20:12:46 +02:00
Edoardo Prezioso
c3caade3ca
- Fixed mispelled function name;
...
changed variable name inside simplifyFlowControl for consistency;
improved simplifyFlowControl to handle better this kind of code:
"return; { { } { label : ; ok ( ) ; } }"->"return ; { { label: ok ( ) ; } }".
2011-10-17 02:16:49 +02:00
Edoardo Prezioso
6f80c5ff64
Removed redundant test, which was related to the Tokenizer, not to the memory leak checker.
2011-10-16 21:19:18 +02:00
PKEuS
f8074b71d2
Fixed #2470 (False negative: Possible null pointer dereference (C++0x keyword 'nullptr'))
2011-10-16 12:54:58 +02:00
Thomas Jarosch
a52b73f9f9
Fix #3208 (Simplify pointer to standard type, C only)
...
The symbol database is unavailable during token simplification
and &data[0] might return something completely different for C++.
Moved code_is_c() from checkOther to Tokenizer.
2011-10-16 08:09:57 +02:00