Commit Graph

2809 Commits

Author SHA1 Message Date
Greg Hewgill 2efb2efaca refactor #if 0 handling to leave preprocessor statements alone 2011-03-01 20:04:11 +13:00
Greg Hewgill a331516735 handle #if (0) after removing parentheses 2011-03-01 19:50:17 +13:00
Greg Hewgill 31c56d7353 handle embedded whitespace in #if 0 processing 2011-03-01 19:32:47 +13:00
Greg Hewgill 87fd55b155 test case for #if 0 exclusion 2011-03-01 19:30:42 +13:00
Robert Reif 92efbd748e fix #2595 bitfield fix for case x: break; and default: break; 2011-02-28 19:35:00 -05:00
Daniel Marjamäki 893b84a87c Fixed #2615 (Segmentation fault in cppcheck 1.47) 2011-02-28 20:29:34 +01:00
Zachary Blair e1b2569b81 Fixed #432 (New check: wrong usage of ! operator in conditions) 2011-02-27 12:30:22 -08:00
Robert Reif 962183f964 add an array flag to symbol database Variable class 2011-02-27 10:21:14 -05:00
Daniel Marjamäki c1c9b96bb6 Fixed #2031 (Tokenizer: simplify known value (string has known value after strcpy)) 2011-02-26 21:11:56 +01:00
Daniel Marjamäki 92ab1ef8e7 fix 2011-02-26 20:08:37 +01:00
Daniel Marjamäki ab2bf0ee0c Fixed #2575 (false positive: Preprocessor does not ignore #include within #if 0 block) 2011-02-26 10:04:38 -08:00
Daniel Marjamäki 32a49235e3 Fixed #2578 (Preprocessor does not correctly handle #define A 0 / #if A) 2011-02-23 13:08:24 -08:00
Daniel Marjamäki daf0e7c37d Fixed #2604 (Segmentation fault of cppcheck ( sizeof <= A )) 2011-02-23 20:44:14 +01:00
Greg Hewgill b26777c962 Merge branch 'cmdline-suppress' 2011-02-23 21:34:09 +13:00
Greg Hewgill 22210e0255 add --suppress= command line option 2011-02-23 20:10:32 +13:00
Robert Reif d1f7a8aca4 fix #2403 (simplifyTypedef: array of function pointers) Internal error message 2011-02-22 22:11:17 -05:00
Reijo Tomperi 7f9dc42ff1 Fix test array_index_24() to share code with environments where plain char is either signed or unsigned.
This was done, because that particular test has been already fixed a couple of times and it is still broken in some systems.
2011-02-22 21:46:12 +02:00
Daniel Marjamäki 9983aa5721 Fixed #2605 (cppcheck hangs with 100% cpu load ( #define = )) 2011-02-22 19:55:02 +01:00
Robert Reif dd12fc177f fix #2603 (segmentation fault of cppcheck ( typedef constexpr)) 2011-02-22 07:48:34 -05:00
Robert Reif 703448171a fix #2601 (segmentation fault of cppcheck) 2011-02-22 07:02:15 -05:00
Robert Reif ba6c2ca310 fix #2602 (segmentation fault of cppcheck ( class A {A& operator=(const A&); }; )) 2011-02-22 06:47:28 -05:00
Robert Reif 4e1ce93104 fix #2600 (segmentation fault of cppcheck ( enum{const} )) 2011-02-21 19:30:40 -05:00
Robert Reif 999646fca6 fix #2599 (segmentation fault of cppcheck ( sizeof )) 2011-02-21 17:49:30 -05:00
Robert Reif 5f84272a52 fix segfault: #2591 (cppcheck hangs with 100% cpu load ( class A : )) 2011-02-21 14:25:35 -05:00
Robert Reif 5984b6b53f fix #2595 (False positive Technically the member function 'A::foo' can be const) 2011-02-20 20:01:54 -05:00
Robert Reif 763763fa9b fix bitfields to support non-numeric bitfield width 2011-02-20 18:22:49 -05:00
Daniel Marjamäki bfe28d3b26 Fixed #2597 (False positive: Buffer access out-of-bounds for u_char, uint*_t, ...) 2011-02-20 21:24:57 +01:00
Daniel Marjamäki c3fba356c0 Fixed #2563 (#if equality testing does not ignore parentheses) 2011-02-20 20:57:28 +01:00
Daniel Marjamäki f6e6fa685e Preprocessor: Added TODO test case for #2563 2011-02-20 20:11:51 +01:00
Daniel Marjamäki 7f67438d99 Null pointer: Added TODO test case. Ticket: #2379 2011-02-20 19:45:34 +01:00
Daniel Marjamäki 63c003f92e Tokenizer: fixed so that 'p=&x; if(p)' is simplified to 'p=&x;if(&x)'. Ticket: #2596 2011-02-20 18:18:27 +01:00
Daniel Marjamäki 7894d86132 Null pointers: Fixed false negative for such code: 'if (p && *p) {} else { *p=0; }'. Ticket: #2379 2011-02-20 14:38:49 +01:00
Daniel Marjamäki 1cfb18be08 astyle formatting 2011-02-20 12:22:01 +01:00
Daniel Marjamäki 46f4e46d30 Tokenizer::simplifyTemplates: Better handling for multi-token template arguments such as 'Foo<std::string>' 2011-02-20 12:17:05 +01:00
Robert Reif fef1142997 fix #2592 (False positive: 'operator=' should return reference to self) 2011-02-19 20:02:16 -05:00
Greg Hewgill d20987c3da Merge branch 'inline-suppression-c-style' 2011-02-20 13:26:35 +13:00
Greg Hewgill 98ab34b2b5 Support cppcheck-suppression in C style comments 2011-02-20 11:44:42 +13:00
Daniel Marjamäki 5f0206725b Null pointers: Fixed false negative for such code 'if (p && *p==0) {} *p = 0;'. Ticket: #2379 2011-02-19 21:28:18 +01:00
Daniel Marjamäki 29d05cf5f2 Null pointers: Fixed false negative for such code: 'abc->a = 0; if (abc && ..'. Ticket: #2379 2011-02-19 21:10:31 +01:00
Daniel Marjamäki e7ef1b3627 Null pointer: fixed false negative when dereferencing struct and then checking if it's null. Ticket: #2379 2011-02-19 21:01:38 +01:00
Robert Reif e6eb160395 fix [B#2589 (segmentation fault of cppcheck (struct B : A)) 2011-02-19 14:38:00 -05:00
Daniel Marjamäki caca6e94e6 Fixed #2231 (uninitialized variable: undetected when initialization in for loop) 2011-02-19 20:19:46 +01:00
Robert Reif 77fe9858e2 fix #2587 (Spurious warning about struct hiding typedef) 2011-02-19 14:18:37 -05:00
Daniel Marjamäki 9a760b9654 Fixed #2582 (segmentation fault of cppcheck ( if() )) 2011-02-18 20:05:44 +01:00
Daniel Marjamäki dfba4b7332 Fixed #2585 (segmentation fault of cppcheck (CheckOther::clarifyCalculation)) 2011-02-17 21:30:59 +01:00
Daniel Marjamäki cf2a04377e Fixed #2586 (segmentation fault of cppcheck (template<>)) 2011-02-17 21:15:17 +01:00
Daniel Marjamäki 96c3ab87f2 astyle formatting 2011-02-17 21:07:45 +01:00
Greg Hewgill e2581da30c Merge branch 'unmatched-suppressions' 2011-02-17 21:46:43 +13:00
Greg Hewgill a4de6a3455 be sure to list unmatched suppressions only for the currently processed file 2011-02-17 21:46:14 +13:00
Daniel Marjamäki 53aaf22633 CheckClass::noMemset: Added TODO test case 2011-02-16 21:31:35 +01:00
Daniel Marjamäki 54e0b60cc5 Fixed #2584 (false positive 'variable n is never used') 2011-02-16 20:33:24 +01:00
Greg Hewgill 5d74325015 implement unmatchedSuppression information message 2011-02-16 23:02:37 +13:00
Raphael Geissert 5998ec4af9 Really fix the build failure this time 2011-02-15 14:10:56 -06:00
Robert Reif 218464df89 fix #2580 (false postive with Unused private function) 2011-02-14 19:50:13 -05:00
Daniel Marjamäki 0ed0d07714 Tokenizer::simplifyCalculations: basic handling of bitwise operators 2011-02-14 20:43:26 +01:00
Robert Reif cdd8d3f785 Really fix #2348 perl-tk 2011-02-13 19:02:57 -05:00
Daniel Marjamäki aacb94c427 Revert "Buffer overruns: Removed TODO test case. We intentionally don't check struct/class arrays fully to avoid false positives"
This reverts commit 87cc42e6f0.
2011-02-13 22:48:26 +01:00
Daniel Marjamäki 0d2d0c864a Tokenizer::simplifyKnownVariables: Fixed TODO testcases (better handling of comparisons) 2011-02-13 22:24:45 +01:00
Daniel Marjamäki 2182ede486 Tokenizer::simplifyKnownVariables: Fixed TODO testcase (better handling of ^) 2011-02-13 22:13:19 +01:00
Daniel Marjamäki 472d8154ca Tokenizer::simplifyKnownVariables: Fixed TODO testcase (better handling of |) 2011-02-13 22:09:04 +01:00
Daniel Marjamäki 467c984cd1 Tokenizer::simplifyKnownVariables: Fixed TODO testcase (better handling of %) 2011-02-13 22:03:46 +01:00
Daniel Marjamäki 87cf0949f2 Buffer overruns: Removed TODO test case. We intentionally don't check struct/class arrays fully to avoid false positives 2011-02-13 21:48:13 +01:00
Daniel Marjamäki 87cc42e6f0 Buffer overruns: Removed TODO test case. We intentionally don't check struct/class arrays fully to avoid false positives 2011-02-13 21:42:35 +01:00
Robert Reif c03ace7378 Fix #2579 (segmentation fault of cppcheck) 2011-02-13 14:11:22 -05:00
Daniel Marjamäki d8da1ac390 Merge branch 'suppress-glob' of https://github.com/ghewgill/cppcheck into ghewgill-suppress-glob 2011-02-13 18:17:44 +01:00
Daniel Marjamäki 8c5ec0df7d Merge branch 'preprocessor' of https://github.com/ghewgill/cppcheck into ghewgill-preprocessor 2011-02-13 18:13:35 +01:00
Greg Hewgill a4fd5e873e change failing tests into TODO_ASSERT_EQUALS 2011-02-13 20:45:04 +13:00
Robert Reif 2aefa5deb5 fix #2577 (segmentation fault of cppcheck) 2011-02-12 15:35:48 -05:00
Daniel Marjamäki 518a495334 Fixed #2576 (False positive: (error) Buffer access out-of-bounds) 2011-02-12 18:34:12 +01:00
Daniel Marjamäki 07e8325e50 Fixed #2549 (segmentation fault of cppcheck) 2011-02-12 16:51:59 +01:00
Daniel Marjamäki 7507f64ee7 Fixed #2558 (false positive: (error) Returning reference to auto variable) 2011-02-12 15:39:26 +01:00
Daniel Marjamäki 2657d36d03 Fixed #2502 (False positive: redundant assingment of object to itself) 2011-02-12 14:27:07 +01:00
Daniel Marjamäki ee0f5ff7b3 Uninitialized variables: Added TODO test case 2011-02-12 12:42:16 +01:00
Daniel Marjamäki 318f2e8a57 Fixed #2561 (False positive on array index when using conditional operator) 2011-02-12 11:31:10 +01:00
Raphael Geissert d8119cd57a Fix test for architectures where char is unsigned 2011-02-12 02:42:31 -06:00
Robert Reif 78b5361ec8 fix #2568 (False positive: (style) Union 'A_t' hides typedef with same name (forward declaration)) 2011-02-11 19:09:24 -05:00
Sébastien Debrard f5ed52b84b fix #2569 check postfix increment on boolean 2011-02-11 23:38:23 +01:00
Erik Lax c7821675dd Preprocessor: Test handling of strings with multiple spaces (Ticket: #2548) 2011-02-11 18:57:58 +01:00
Greg Hewgill f2f2d1f885 Fixed #2571 (Preprocessor: better handling for #undef) 2011-02-11 18:51:22 +01:00
Greg Hewgill 751f8d46e5 Fixed #2570 (Preprocessor: #define parsing when there is no whitespace between a macro symbol and its double-quoted string expansion) 2011-02-11 18:01:27 +01:00
Robert Reif b8c5426bb8 fix #2567 Unused private function when implemented in different file 2011-02-11 08:00:41 -05:00
Erik Lax b3e8ef9d48 Fixed #2559 (Refactoring Preprocessor::read) 2011-02-11 06:30:42 +01:00
Daniel Marjamäki 90bf801c83 Visual Studio 2010: Updated project files for cli and test 2011-02-10 22:10:45 +01:00
Daniel Marjamäki ce9f9ee6c6 Visual Studio 2008: Updated project files for cli and test 2011-02-10 22:08:10 +01:00
Reijo Tomperi a71204b8e3 Change "tinyxml/tinyxml.h" includes into <tinyxml.h> and modify dmake to work with it.
This should allow usage of libtinyxml-dev or such libraries without modifications to code or makefile.
2011-02-10 22:35:48 +02:00
Robert Reif 2900d44ff0 #2560 (False positive: The class 'Altren' does not have a constructor, because base class is in namespace.) 2011-02-10 07:37:55 -05:00
Daniel Marjamäki 5175e4ff3f Fixed #2535 (false positive: (style) Variable 'A' is not assigned a value) 2011-02-09 19:20:44 +01:00
Robert Reif 7502cea4d3 Fixed #2554 (simplifyTypedef: wrong simplification for sizeof(array)) 2011-02-08 19:47:14 -05:00
Daniel Marjamäki 56ae77ba87 Fixed #2555 (Cppcheck 1.47 - Crash on WinMerge-Trunk (Win7 x64)) 2011-02-08 20:18:15 +01:00
Erik Lax aeae5a867d Fixed #2550 (Bad substr/strncmp comparison) 2011-02-08 19:49:29 +01:00
Greg Hewgill 7a219b1fb8 support wildcard characters * and ? in suppression list 2011-02-09 00:19:57 +13:00
Greg Hewgill 38986302e9 failing test for suppression glob 2011-02-09 00:19:56 +13:00
Greg Hewgill c0d3e002a9 preprocessor check for #define A 0 2011-02-08 21:02:15 +13:00
Robert Reif 1e0d538273 checkautovariables: refactor to use the symbol database 2011-02-07 19:26:34 -05:00
Daniel Marjamäki 7c9e52546d Fixed #2552 (preprocessor check XX is already guaranteed to be defined -- too eager?) 2011-02-07 20:26:29 +01:00
Zachary Blair daa04872a0 Merge branch 'master' of github.com:danmar/cppcheck 2011-02-06 01:31:09 -08:00
Daniel Marjamäki 26f017e9c6 scripts: added tabs.pl - in my opinion it is bad to use tabs inside string constants. spaces or \t should be used instead. 2011-02-05 12:53:28 +01:00
Zachary Blair 8a494cf8bb Fixed #2388 (Use throw without argument to rethrow exceptions) 2011-02-05 01:11:09 -08:00
Robert Reif 95e917b27f Tokenizer: Replace __null with 0 (gcc constant) 2011-02-05 09:03:31 +01:00
Robert Reif c592ccd35d Fixed #2547 (segmentation fault of cppcheck) 2011-02-05 08:59:59 +01:00
Daniel Marjamäki 5640845a17 Fixed #2498 (False positive: redundant assignment) 2011-02-04 21:08:42 +01:00
Daniel Marjamäki dbc5929fa2 Fixed #2503 (false positive: memory leak (struct member, address is taken)) 2011-02-04 20:41:35 +01:00
Robert Reif f87056fca3 Fixed #2539 (segmentation fault of cppcheck) 2011-02-04 20:19:49 +01:00
Daniel Marjamäki 447d29938e Fixed #2544 (XML output does not specify encoding used) 2011-02-04 20:14:19 +01:00
Daniel Marjamäki 39c68e12ce Fixed #2533 (false positive: (error) Uninitialized variable: cBuffer) 2011-02-03 22:29:32 +01:00
Daniel Marjamäki 398190460f astyle formatting 2011-02-03 22:20:59 +01:00
Kimmo Varis 85187dca07 Update VS 2008/2010 project files for tests. 2011-02-03 17:53:50 +02:00
Kimmo Varis 2d6d8580d7 Allow to exclude filenames (with paths).
This expands the CLI exclude feature to also allow excluding
filenames (with paths). When filename with recognized extension
is given to -i option then matching filenames (with paths) are
ignored when checking.

Ticket #2538 (Allow excluding files from the checking)
2011-02-03 14:43:42 +02:00
Kimmo Varis 9b9b9c99f5 Add test for XML format version 2. 2011-02-03 09:44:23 +02:00
Kimmo Varis f65fa338a5 Tighten the directory name mathing with -i.
Only match full directory names as parts of whole paths. So -isrc
matches src/file.cpp and proj/src/file.cpp. But does not match
mysrc/file.cpp or proj/srcfiles/file.cpp.
2011-02-03 09:01:43 +02:00
Robert Reif e9ec4bc3e4 Fixed #2536 (cppcheck hangs with 100% cpu load) 2011-02-03 07:58:49 +01:00
Robert Reif 8288c28b3f Fixed #2537 (segmentation fault of cppcheck) 2011-02-03 07:57:10 +01:00
Kimmo Varis bacb234534 Add testsymboldatabase.cpp to test.pro.
Also add comment explaining omitting testfilelister_unix.cpp.
2011-02-02 22:52:47 +02:00
Kimmo Varis ffc4bb481b Merge branch 'ignore-paths-cli' 2011-02-02 21:09:22 +02:00
Raphael Geissert d592250284 Fix sizeof sizeof check to handle sizeof(sizeof type) 2011-02-02 11:49:32 -06:00
Daniel Marjamäki 9a383388be xml2: added <errors> element 2011-02-02 18:46:07 +01:00
Daniel Marjamäki 26b21a5ae0 Merge branch 'sorted-instances' 2011-02-02 18:35:42 +01:00
Kimmo Varis 84a988ec50 Update VS2008/VS2010 project files. 2011-02-02 14:37:48 +02:00
Kimmo Varis 3fc0d0f03e Run dmake to update Makefile. 2011-02-02 14:36:45 +02:00
Kimmo Varis 6401271ceb Add CLI support for ignoring paths.
Add support for giving list of ignored paths from CLI. This way
user can define paths one doesn't want to check (like generated
code). This first simple implementation only does exact matching,
no support for wildcards etc. And matching is always agains dir
names.

If the filtered dir name is part of the checked filename then the
file is ignored.

Ticket #1690 (Ability to exclude files and directories from checks)
2011-02-02 14:34:04 +02:00
Kimmo Varis 1da88de932 Imrove --xml-version option parsing.
Allow --xml-version parsing to recognize also version 1 and print
errors about invalid values.
2011-02-02 14:04:50 +02:00
Kimmo Varis 1118b132b9 Add couple of tests for xml-version cmd line option. 2011-02-02 13:33:57 +02:00
Greg Hewgill c3ad3f78e9 test case to check whether instances are sorted 2011-02-02 22:58:24 +13:00
Robert Reif 8eb92001b3 Fixed #2530 (Tokenizer: Remove redundant 'MyClass::' inside MyClass class declaration) 2011-02-02 07:40:08 +01:00
Daniel Marjamäki defeded4b5 Fixed #2529 (False positive: array 'req[3]' index 4 out of bounds) 2011-02-01 21:46:07 +01:00
Pete Johns 2d1ccad44e Turned failing ASSERT_EQUALS into TODO_ASSERT_EQUALS. 2011-02-01 19:55:39 +11:00
Pete Johns d2b6dc210b Merge https://github.com/ghewgill/cppcheck 2011-02-01 19:52:44 +11:00
Greg Hewgill dcc0f28f34 check that misused scope object does not pick nested class 2011-02-01 08:07:41 +13:00
Daniel Marjamäki 202c8eb4a0 Fixed #2525 (False positive 'Possible null pointer dereference') 2011-01-31 17:30:27 +01:00
Daniel Marjamäki 757c840633 astyle formatting 2011-01-31 17:26:07 +01:00
Ettl Martin f3111b541e #2528 added todo-testcase 2011-01-31 13:46:51 +01:00
Raphael Geissert 66253af1e5 Handle "#endif !defined" conditionals 2011-01-30 17:33:44 -06:00
Raphael Geissert b944168bdc Check for cpp conditionals where a define is already guaranteed 2011-01-30 12:47:17 -06:00
Pete Johns 098f0bf3e6 Fixed #2526 (Make TODO_ASSERT_EQUALS take three arguments (value, to_be, as_is)?...
Removed replaced EXPECTED with...

WANTED (to-be):     The future expected value.
CURRENT (as-is):    Documenting how cppcheck behaves now.

This removes the need for an ASSERT_EQUALS but enforces the check for every TODO_ASSERT_EQUALS.
2011-01-30 23:20:11 +11:00
Raphael Geissert 49848fd752 Remove duplicated defines
After simplifying define(A) conditionals, the final list of
configurations could end up containing duplicate items.

Ticket #1468
2011-01-30 02:13:32 -06:00
Robert Reif 09998d9e18 Memory leaks: less conservative checking of classes. ticket: #2517 2011-01-30 08:38:20 +01:00
Daniel Marjamäki 49fc53165c Tokenizer: remove some unhandled macros in the global scope. ticket: #2523 2011-01-30 08:34:58 +01:00
Kimmo Varis b9a0e10b9a Several fixes to cmd line tests.
There were several tests handling two parameters as one string.
Eg. "-I path" which doesn't work correctly. Fixed these
problematic tests.
2011-01-29 19:18:47 +02:00
Kimmo Varis d334a02801 Make --exitcode-suppressions option consistent.
The --exitcode-suppressions option was inconsistent with other
long options by taking the filename as separate argument. Now
it expects format --exitcode-suppressions=filename.txt like
other long options.

Ticket: #1837 (--suppresions file.txt inconsistent)
2011-01-29 19:18:47 +02:00
Daniel Marjamäki a299411a82 Tokenizer: Better simplifications of static constants 2011-01-29 16:14:09 +01:00
Kimmo Varis 081e364298 Rename --suppressions-list CLI option.
The option --suppressions-list was inconsistent with other options
so renaming it to --suppressions-list.

Ticket: #1837 (--suppresions file.txt inconsistent)
2011-01-28 13:26:43 +02:00
Daniel Marjamäki 83625d8055 Fixed #2505 (Check processing of a preprocessor macro 'FREE') 2011-01-28 09:19:30 +01:00
Robert Reif 79862573ba Symbol database: better unit testing. ticket: #2468 2011-01-28 08:33:02 +01:00
Daniel Marjamäki 88abeeebba Fixed #2518 (Crash when checking rockbox's firmwire) 2011-01-27 21:16:25 +01:00
Daniel Marjamäki 524498e439 Tokenizer: collapse operator function names into a single token. ticket: #2519 2011-01-27 18:44:20 +01:00
Kimmo Varis 090436ea95 Add cmd line parser tests for XML ver 2 options. 2011-01-27 14:25:10 +02:00
Kimmo Varis a794edd934 Don't stop processing cmd line after --errorlist.
Ticket #2441 (Parsing of command line arguments breaks after --errorlist)

Instead of stopping processing command line options after
--errorlist process them all. This way e.g. --verbose can be given
also after the --errorlist.
2011-01-27 11:14:08 +02:00
Sébastien Debrard 3e7f29d6f9 fix #2510 Improve check 'sizeof for array given as function argument' 2011-01-26 20:08:06 +01:00
Sébastien Debrard e82c190429 Merge branch 'master' of https://github.com/danmar/cppcheck
Conflicts:
	test/testother.cpp
2011-01-25 10:05:03 +01:00
Sébastien Debrard 4cf56dac2b Fix 2495 incorrect sizeof error message 2011-01-25 09:57:58 +01:00
Daniel Marjamäki a596a7a8fe Fixed #2494 (New check: clarify calculation when using ?: operator) 2011-01-24 21:40:49 +01:00
Sébastien Debrard c7b8bd543f fix ticket 155 - char array 2011-01-24 19:04:56 +01:00
Daniel Marjamäki c04107131b when using TODO_ASSERT_EQUALS it's a good idea to pair it with a ASSERT_EQUALS 2011-01-23 14:34:26 +01:00
Daniel Marjamäki b10f0aabd6 Fixed #2376 (simplifyTypedef: upx-ucl) 2011-01-23 09:04:34 +01:00
Daniel Marjamäki 86e6822264 Fixed #2493 (false positive: (error) Possible null pointer dereference: pExpr) 2011-01-23 08:38:09 +01:00
Daniel Marjamäki 9d3b242cd8 Fixed #1952 (false negative: buffer acces out of bounds with memcpy) 2011-01-22 21:31:26 +01:00
Debrard Sébastien 27dce075e0 Fixed #155 (check size of a variable whose type is a sized array) 2011-01-22 19:21:56 +01:00
Robert Reif 8abae6f1e5 Symbol database: match copy-constructor better. ticket: #2484 2011-01-22 17:43:36 +01:00
Daniel Marjamäki f947955c63 Fixed #2492 (False positive: memory leak 'return &self->foo;') 2011-01-22 13:40:19 +01:00
Daniel Marjamäki 9551332321 Fixed #2459 (False positive with unused private function and friend) 2011-01-22 13:00:03 +01:00
Daniel Marjamäki bc31f317bc Fixed #2491 (Tokenizer::setVarId : wrong handling of function call: 'a(b * c, 1);') 2011-01-22 09:27:16 +01:00
Ettl Martin a83aced2ec fixed uninitialized members in tests 2011-01-21 23:48:42 +01:00
Robert Reif 767e01e24a Fixed #2478 (Crash when trying to analyze files (CheckClass::checkReturnPtrThis)) 2011-01-21 19:54:41 +01:00
Daniel Marjamäki 87e3e9e703 Fixed #2488 (false positive with updating iterator in a for loop) 2011-01-20 20:48:35 +01:00
Daniel Marjamäki a21f8eec7c Fixed #2481 (false positive with break: After insert, the iterator '*' may be invalid) 2011-01-20 19:26:52 +01:00
Daniel Marjamäki 70eadb37bd Fixed #2481 (false positive with 'break;': After insert, the iterator '*' may be invalid) 2011-01-19 21:00:46 +01:00
Daniel Marjamäki b1b8ea6457 added unit test for #2482 2011-01-19 20:41:46 +01:00
Daniel Marjamäki ecac93ebed Fixed #2462 (false positive: (warning) Redundant code: Found a statement that begins with numeric constant) 2011-01-19 18:37:33 +01:00
Pete Johns 94aafa482c Fixed #2480 (false positive on unused private function) 2011-01-19 20:32:08 +11:00
Kimmo Varis 0cacc7fe4d Update Visual Studio project files.
Update Visual Studio 2008/2010 project files after moving filelister*
files from lib/ to cli/.
2011-01-18 20:55:17 +02:00
Kimmo Varis b8b2e3fae9 Move filelister* to cli.
Ticket #2445 (Move FileLister classes from LIB to CLI).
2011-01-18 19:58:49 +02:00
Pete Johns 75767705c7 Added testDoesNotIdentifyCallback for #2480
TODO
2011-01-18 21:50:22 +11:00
Pete Johns 0e1bab6dc3 Merge branch 'multi_indirection_templates' 2011-01-18 21:08:04 +11:00
Pete Johns abfd907763 Made isVariableDeclarationIdentifiesTemplatedPointerToPointerVariable() pass.
And added isVariableDeclarationIdentifiesTemplatedArrayVariable() (passing) into the bargain.
2011-01-18 20:14:12 +11:00
Pete Johns 69d4db714e Added TODO test cases for template variables with multiple levels of pointer indirection
Following email from Robert Reif
2011-01-18 18:29:42 +11:00
Robert Reif 8631ee65a3 Fixed #2474 (false positive: Member variable 'A::m_SemVar' is not initialised in the constructor.) 2011-01-18 07:34:11 +01:00
Daniel Marjamäki 965c1a94fd Fixed #2475 (False positive in structure initialisation: The scope of the variable bits can be reduced) 2011-01-17 20:51:15 +01:00
Kimmo Varis bd5e9e5309 Improve checking -D arguments for command line. 2011-01-17 21:19:27 +02:00
Kimmo Varis 6dd16d3919 Fix crash when giving -D without argument.
Fixes ticket #2476 (Crash when -D used without parameters.)
2011-01-17 21:03:22 +02:00
Daniel Marjamäki b5020468f6 Fixed #2467 (false positive: possible nullptr dereference) 2011-01-17 19:23:00 +01:00
Daniel Marjamäki 065e2e277e Fixed #2473 (False positive: Memory leak when there is local struct) 2011-01-17 19:00:21 +01:00
Robert Reif 959e10cee5 Symbol database: renamed classes. ticket: #2468 2011-01-17 18:29:19 +01:00
Robert Reif bf9528558e Symbol database: pulled out classes into global scope. ticket: #2468 2011-01-17 07:21:59 +01:00
Pete Johns 7918c4b804 isVariableDeclaration() now detects template variables. 2011-01-17 08:36:53 +11:00
Pete Johns 38c37ad2d8 Moved array declaration detection into isVariableDeclaration() 2011-01-17 08:36:52 +11:00
Daniel Marjamäki e6a1efa13b Fixed #2302 (Duplicate id 'unusedVariable') 2011-01-16 18:45:05 +01:00
Daniel Marjamäki 61aa86f201 testcppcheck: check that Cppcheck::getErrorMessages output is not empty 2011-01-16 17:07:12 +01:00
Daniel Marjamäki f50971a65a testcppcheck: test Cppcheck::getErrorMessages 2011-01-16 17:06:07 +01:00
Daniel Marjamäki 615c92c83b testcppcheck: cleanup 2011-01-16 16:45:00 +01:00
Daniel Marjamäki 483e50d5bc testcppcheck: removed 'parseArgsAndCheck' and 'parseOutputtingArgs'. Such tests belong to testcmdlineparser 2011-01-16 16:34:29 +01:00
Daniel Marjamäki 206565c837 testcppcheck: removed nonexistingpath and include tests. The Cppcheck class doesn't handle this. 2011-01-16 16:32:05 +01:00
Daniel Marjamäki f862b37c71 testcppcheck: the xml and template output is tested in testerrorlogger instead 2011-01-16 16:26:33 +01:00
Daniel Marjamäki e3e32de22e testcppcheck: the testcmdlineparser tests invalid command line arguments 2011-01-16 16:22:46 +01:00
Daniel Marjamäki 4661e38c65 testcppcheck: linenumbers are tested in the other tests 2011-01-16 16:21:34 +01:00
Daniel Marjamäki c841908149 testcppcheck: command line parsing of -D is tested in testcmdlineparser.cpp 2011-01-16 16:19:40 +01:00
Daniel Marjamäki 03ddfcb5b3 testcppcheck: parsing templates is tested in testcmdlineparser.cpp 2011-01-16 16:17:53 +01:00
Daniel Marjamäki a97e28491f Fixed #2407 (False positive: unused private function) 2011-01-16 12:16:31 +01:00
Daniel Marjamäki f72fd6960e Fixed #2449 (segfault in tokenize.cpp, incorrect parsing) 2011-01-16 11:54:28 +01:00
Raphael Geissert da998fec68 Tokenizer: simplify restrict 2011-01-16 11:37:03 +01:00
Robert Reif beb2db82a2 Fixed #980 (false negative: division by zero when using enum) 2011-01-16 11:24:58 +01:00
Robert Reif 0f6644e1ea Symbol database: Refactorings 2011-01-16 11:18:12 +01:00
Daniel Marjamäki 6edf35ebf5 Fixed #2463 (false positive: possible nullpointer dereference) 2011-01-15 12:09:36 +01:00
Daniel Marjamäki 97d0755750 Fixed #2454 (Tokenizer::simplifyKnownVariables: problem with float/double variables) 2011-01-15 08:48:42 +01:00
Daniel Marjamäki cf32016444 removed old comment 2011-01-15 08:30:54 +01:00
Daniel Marjamäki 5920dbb7e7 Fixed #2466 (Tokenizer: simplification of enum) 2011-01-15 08:21:06 +01:00
Robert Reif 8ecba0af90 Fixed #2464 (False positive: not initialised/not assigned Static variable in copy constructors.) 2011-01-15 08:04:50 +01:00
Robert Reif 79b9939610 Fixed #2465 (False positive: not initialised variable, but there is default constructor for it.) 2011-01-15 07:59:37 +01:00
Daniel Marjamäki 00b49a51da Fixed #2451 (False positive when incrementing map value via iterator) 2011-01-14 19:50:07 +01:00
Robert Reif 708a75e363 Fixed #2452 (syntax error when 'void f(typedef int x)' is used. causes segmentation fault.) 2011-01-14 07:41:22 +01:00
Daniel Marjamäki b247d7d56e Fixed #2450 (False positive when iterator reused) 2011-01-13 20:57:44 +01:00
Daniel Marjamäki 36c1807228 Fixed #2458 (false positive: (warning) Redundant code: Found a statement that begins with numeric constant) 2011-01-13 20:12:57 +01:00
Zachary Blair 38be7056b0 Fixed #2434 (FP memleakOnRealloc) 2011-01-12 22:33:46 -08:00
Daniel Marjamäki 09f900ce79 Fixed #2440 (False negative: basic memory leak) 2011-01-11 20:14:15 +01:00
Kimmo Varis 846d3dae99 Accept include paths ending with backslash.
Convert include path to use internal path separators when parsing
command line. Convert back to native separators when using paths.

Ticket #2448 (Error in handling -I command line parameter)
2011-01-11 21:04:21 +02:00
Daniel Marjamäki 79e52a8c45 Fixed #2296 (Tokenizer: simplifyKnownVariable doesn't simplify pointer properly 'delete [] p;') 2011-01-11 19:34:35 +01:00
Daniel Marjamäki 9658e2299d Fixed #2443 (Possible null pointer dereference: xxx - otherwise it is redundant to check if xxx is null at line) 2011-01-10 19:57:26 +01:00
Daniel Marjamäki 2d92f1ff6a Fixed #2442 (False positive: Memory leak when function returns in 'if' instead of 'else if') 2011-01-10 19:35:06 +01:00
Reijo Tomperi 226b605774 Change year 2010 -> 2011 in license texts. 2011-01-09 21:33:36 +02:00
Daniel Marjamäki 2848abbf36 Fixed #1219 (improve check: null pointer not detected 'if (p) return; *p = 0;') 2011-01-09 20:16:16 +01:00
Daniel Marjamäki 79ef02812d Fixed #2211 (false negative: buffer access out of bounds for(int i=0; i !=6;i++)) 2011-01-09 18:51:28 +01:00
Daniel Marjamäki 0b0c46e373 astyle formatting 2011-01-09 18:39:59 +01:00
Daniel Marjamäki 88abb32ddf Fixed #2429 (Tokenizer: Wrong simplification of 'sizeof .1250E+04') 2011-01-09 10:09:54 +01:00
Daniel Marjamäki 68beffca04 Fixed #2437 (false positive: possible null pointer dereference: tok2) 2011-01-08 17:16:52 +01:00
Daniel Marjamäki 67a1c6817b Error message: Replace &quot; with ' around variable name 2011-01-08 14:35:18 +01:00
Daniel Marjamäki 14cbaebfe2 Fixed #2428 (false alarm with code containing a throw clause) 2011-01-07 20:45:33 +01:00
Robert Reif 5f078da7ad Fixed #2425 (segmentation fault of cppcheck) 2011-01-07 18:58:14 +01:00
Ettl Martin 9b66f7a754 #ticket 2429: added a test to the mathlib to ensure the used floating point number is recognized correctly 2011-01-07 12:27:12 +01:00
Robert Reif bfc95e01c1 Fixed #2426 (### Internal error in Cppcheck. Please report it.) 2011-01-07 08:02:47 +01:00
Daniel Marjamäki 1b3a5ed0be Tokenizer: simplify NULL to 0 in the normal token list 2011-01-06 20:16:14 +01:00
Daniel Marjamäki 37b1f7c296 memsetZeroBytes: improved error message. ticket: #2421 2011-01-06 16:27:22 +01:00
Daniel Marjamäki ed71c57f1f astyle formatting 2011-01-06 12:07:18 +01:00
Raphael Geissert 6ec4497919 [PATCH] Check for calls to memset() where 0 bytes are to be filled
Inspired by Silvio Cesare's work
2011-01-06 11:31:58 +01:00
Daniel Marjamäki d1854e330b Fixed #2413 (fflush() with NULL argument is valid.) 2011-01-06 08:12:34 +01:00
Robert Reif 03a484554c Fixed #2415 (false positive: Member variable not initialized in constructor calling assignment operator) 2011-01-06 07:56:34 +01:00
Robert Reif d7e170b3ca typedef: fixed problem. ticket: #2414 2011-01-06 07:52:59 +01:00
Daniel Marjamäki c74b2e3cbf Fixed #2411 (possible null pointer dereference (aborting via function pointer not detected)) 2011-01-05 21:48:26 +01:00
Daniel Marjamäki 033e759c39 command line: added 'information' id to enable 2011-01-05 21:20:21 +01:00
Daniel Marjamäki 21af64049c Fixed #2401 (false positive: Uninitialized variable: result) 2011-01-05 20:44:04 +01:00
Daniel Marjamäki 68de938d23 Uninitialized variables. Fixed false positive when there are multiple related conditions. ticket: #2399 2011-01-05 19:54:56 +01:00
Robert Reif 157498e694 Fixed #2412 (typedef: struct with inheritance) 2011-01-05 17:42:55 +01:00
Kimmo Varis bb719774b1 Improve suspicious condition (string::find) message.
See forum thread:
https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192
2011-01-04 23:19:23 +02:00
Kimmo Varis 66e8b7bc1e Improve dangerous iterator usage (after erase()) message.
See forum thread:
https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192
2011-01-04 23:18:48 +02:00
Kimmo Varis b750a52f6d Improve strncat 3rd parameter usage warning message.
See forum thread:
https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192
2011-01-04 23:17:44 +02:00
Daniel Marjamäki d700f25518 Fixed #2399 (Tokenizer::simplifyKnownVariables: variables in conditions) 2011-01-04 21:35:35 +01:00
Daniel Marjamäki 63c1ee375e Fixed #2398 (false positive: Uninitialized variable) 2011-01-04 19:36:29 +01:00
Daniel Marjamäki 2c6421d162 Merge branch 'master' of https://github.com/rgeissert/cppcheck into rgeissert-realloc 2011-01-04 18:21:18 +01:00
Robert Reif 63208e87d3 typedef: delete unhandled typedefs. ticket: #2348 2011-01-04 07:43:40 +01:00
Robert Reif a782d3ddf7 typedef: fix testcase 4. ticket: #2375 2011-01-04 07:39:41 +01:00
Markus Elfring e459ed1de3 Fixed #2389 (mistakable warning from 'CheckClass::uninitVarError') 2011-01-03 19:03:42 +01:00
Markus Elfring 3fc0317997 Bug #2390: Enclose the output of a variable name with quotes in "CheckOther::variableScopeError"
The variable name output was enclosed by quotation marks in the member
function "CheckOther::variableScopeError" and corresponding test functions.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
2011-01-03 05:15:20 +01:00
Raphael Geissert 3d9550b0bf Simplify "x = realloc (0, n);" to "x = malloc(n);" 2011-01-02 17:46:10 -06:00
Daniel Marjamäki d2714fefda typedef: Fixed testcase. ticket: #2375 2011-01-02 17:28:47 +01:00
Daniel Marjamäki 2e7e118cb8 Fixed #2392 (Preprocessor: Wrong simplification of __VA_ARGS__) 2011-01-02 11:19:37 +01:00
Daniel Marjamäki 571704f118 Added TODO testcase for ticket #2392 (Preprocessor: Wrong simplification of __VA_ARGS__) 2011-01-02 10:09:50 +01:00
Daniel Marjamäki b5876f00ff Fixed #2391 (cstdlib file and memory function check misbehavior) 2011-01-02 08:32:51 +01:00
Daniel Marjamäki 320604f073 typedef: added more tests. ticket: #2375 2011-01-02 07:42:47 +01:00
Daniel Marjamäki 4ec9d418ff Fixed #2215 (Improve check: Writing outside malloc bounds not detected) 2011-01-01 20:56:21 +01:00
Daniel Marjamäki 2a77dd3df1 Fixed #2246 (Improve check: Memory leak, function is not noreturn if return value is taken) 2011-01-01 20:14:01 +01:00
Daniel Marjamäki 3c238882a2 Fixed TODO testcase. Use symbol database instead of token list. Ticket: #2375 2011-01-01 17:54:37 +01:00
Daniel Marjamäki a9aa6375b7 gcc: disabled -Wconversion again - too many warnings 2011-01-01 09:16:31 +01:00
Daniel Marjamäki 2da3fea1b8 Fixed #2386 (segmentation fault occurs in the checking when typedef has same name as an enum constant) 2010-12-31 20:55:28 +01:00
Daniel Marjamäki 04eb9cf305 Fixed #2378 (Refactoring: create utility function that skips redundant if/for/while) 2010-12-31 18:07:46 +01:00
Daniel Marjamäki ed6c76ce04 Fixed #2385 (False positive: array index out of bounds) 2010-12-31 17:43:38 +01:00
Pete Johns 502cfe7243 Fixed #2384 ("The function 's::f' can be const" reported for pointer-to-pointer)
Moved check for pointer variables into isVariableDeclaration()

Can now handle multiple scopes and multiple levels of indirection. Simplified check for strucs and unions, too, reducing the size of getVarList().

skipScopeIdentifiers() and skipPointers() should probably be methods on class Token.
2010-12-31 22:12:32 +11:00
Zachary Blair d11b5163b7 Fixed #2382 (Catching exceptions by value instead of reference) 2010-12-31 03:01:38 -08:00
Daniel Marjamäki eb59bd5fd6 Added -Wconversion compiler flag. The ASSERT_EQUALS_DOUBLE was added that can be used when comparing double values. 2010-12-30 22:56:53 +01:00
Daniel Marjamäki 8bdb05da6e Uninitialized variables: typeof doesn't dereference. Ticket: #2367 2010-12-30 21:30:46 +01:00
Daniel Marjamäki 307178d3c2 Tokenizer: Better handling of duplicate enums. Ticket: #2381 2010-12-30 20:55:23 +01:00
Daniel Marjamäki 7ec169f66a Fixed #2321 (false positive: (performance) Prefer prefix ++/-- operators for non-primitive types.) 2010-12-30 14:27:32 +01:00
Pete Johns 2e61736c73 Refactoring following #2377 (Technically the member function xxx can be const)
symboldatabase now recognises variables with arbitrarily many scopes.

Extracted method isVariableDeclaration()

Added unit tests for isVariableDeclaration in new file testsymboldatabase.cpp

Extracted givenACodeSampleToTokenize helper class into testutils.h to reduce duplication.
2010-12-30 19:46:44 +11:00
Pete Johns 5d0ace3a50 Fixed #2377 (Technically the member function xxx can be const)
TODO: Add unit test for getVarList() and refactor variable check.

[Removed my testcase for #2377 and removed two TODOs.]
2010-12-30 17:56:28 +11:00
Ettl Martin ac42c0ba3b const correctness: added further testcases for increment/decrement member functions 2010-12-30 02:05:44 +01:00
Ettl Martin 7b92378c3a ticket 2377: added further testcases 2010-12-30 01:44:46 +01:00
Ettl Martin c29824fc49 added todo testcase for ticket 2377 Technically the member function xxx can be const 2010-12-30 01:29:09 +01:00
Daniel Marjamäki 3d3593e6e7 Fixed #2374 (False 'memory leak' report (assigning to map in subfunction)) 2010-12-29 22:18:23 +01:00
Robert Reif 3900ac731e simplifyTypedef: Better handling of 'typedef int RexxFunctionHandler();'. Ticket: #2348 2010-12-29 20:25:47 +01:00
Robert Reif 3f1f50e970 simplifyTypedef: operator typedef. Ticket: #2375 2010-12-29 20:22:06 +01:00
Daniel Marjamäki 38e7209d26 Fixed #2373 (Using XML2 in --errorlist output) 2010-12-29 12:43:29 +01:00
Robert Reif 137d0e2ba7 typedef: fixed problem with 'typedef int pread_f(int);'. ticket: #2348 2010-12-29 09:18:41 +01:00
Robert Reif e82b1f8946 typedef: fix typedef simplification. ticket: #2348 2010-12-28 21:21:13 +01:00
Daniel Marjamäki bdf0cb7115 Fixed #2370 (false negative: Buffer access out-of-bounds (for with if, no break)) 2010-12-28 20:46:31 +01:00
Daniel Marjamäki 0667fcf53c Fixed #2355 (simplifyTypedef: wrong simplification of 'typedef FMAC1 void (*a)();') 2010-12-28 14:04:44 +01:00
Robert Reif 1b92eeae1e Fixed #2354 (simplifyTypedef: function pointers are not simplified into valid code) 2010-12-28 08:01:32 +01:00
Pete Johns 58ddb3b0ab Fixed #2360 (testrunner fails to build in Mac OS X Leopard (10.5) - assert macro vs assert method)
Renamed assert to assert_.

Tested with gcc v4.0.1 on Snow Leopard.
2010-12-28 09:32:36 +11:00
Daniel Marjamäki d4e3e7e201 Fixed #2367 (false positive: (error) Uninitialized variable: s) 2010-12-27 21:19:10 +01:00
Daniel Marjamäki 448c03c6e6 Fixed #2367 (false positive: (error) Uninitialized variable: s) 2010-12-27 21:05:33 +01:00
Daniel Marjamäki 92acca3d0c Fixed #2368 (assigned a value that is never used) 2010-12-27 20:49:07 +01:00
Kimmo Varis e8b81f909d Change 'Scope of variable'-message to information message. 2010-12-27 16:48:03 +02:00
Ettl Martin ccde32b210 Created to testcase (#2368) for assigned a value that is never used false positive 2010-12-27 15:12:17 +01:00
Daniel Marjamäki 3853f93b34 TestClass: addon for 12f28507, fix a few more error messages. 2010-12-27 08:22:21 +01:00
Daniel Marjamäki 2367cfcf1e Fixed #2361 (false positive on t[0X10]) 2010-12-27 08:09:05 +01:00
Kimmo Varis 12f2850777 Improve the message about const function.
See discussion thread:
https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192
2010-12-26 23:44:03 +02:00
Kimmo Varis f5f2a2ce2a Improve message for container type range check.
See thread:
https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192&start=0
2010-12-26 23:44:02 +02:00
Kimmo Varis ad89a84796 Improve error message about overlapping buffers for s[n]printf().
See forum thread:
https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192&start=0
2010-12-26 23:44:01 +02:00
Daniel Marjamäki 6aa400fd80 Buffer overrun: UB when pointer arithmetic result points out of bounds. Ticket #1774 2010-12-26 21:23:28 +01:00
Daniel Marjamäki 6178459c15 Fixed #2304 (Tokenizer::simplifyKnownVariables: known strcpy parameter) 2010-12-26 20:34:07 +01:00
Daniel Marjamäki 5f3d2a7e35 Fixed #2090 (False negative: null pointer dereference 's=0; strcpy(s,p);') 2010-12-26 19:29:58 +01:00
Daniel Marjamäki f4581d833d Tokenizer: Bailout if @ is encountered in the code 2010-12-26 15:07:14 +01:00
Daniel Marjamäki 243a524909 Fixed #2350 (false positive: possible null pointer dereference) 2010-12-26 13:38:16 +01:00
Daniel Marjamäki f7a83b4d90 astyle formatting 2010-12-26 13:18:23 +01:00