Commit Graph

312 Commits

Author SHA1 Message Date
Edoardo Prezioso 767413adad 1)internal check found a 'findmatch' with simple string argument;
2)Style: uniform 'while (...)' when inside it there's an assignment;
3)Replace '0' with 'NULL' where there's comparison with a pointer.
2011-12-01 12:04:47 +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 6b6f780057 code cleanups and refactorings 2011-11-26 21:02:04 +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
Stefan Weil 68a1b69d32 Preprocessor: Fix comments (backspace -> backslash)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2011-11-15 19:30:43 +01:00
Daniel Marjamäki 73f3b2074b Fixed #3285 (wrong #elif behaviour) 2011-11-03 19:05:48 +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 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
Richard Quirk a0a5b36667 Ensure single-argument constructors are explicit 2011-10-29 18:24:30 +02:00
Thomas Jarosch 434fb933a8 Implement Token::findsimplematch und use it for simple patterns 2011-10-27 15:59:22 +02:00
Daniel Marjamaki 4b57a146fb Preprocessor: Unit test #error and missing includes. Ticket: #2131 2011-10-25 19:55:47 +02:00
Daniel Marjamaki 40dcab0b6b Preprocessor: Report missing includes during 'normal' preprocessing. Ticket: #2131 2011-10-25 18:16:03 +02:00
Daniel Marjamaki 7fa58b455b Preprocessor: Make it possible to use the 'normal' preprocessor by using special command -DCPPCHECK-TEST. Ticket: #2131 2011-10-24 20:59:46 +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
Daniel Marjamaki 9e50b7cb68 Preprocessor: updates to 'normal' preprocessing 2011-10-23 19:17:29 +02:00
Thomas Jarosch db8c7deb30 Fixed #3232 (Check if container is modified inside BOOST_FOREACH) 2011-10-23 13:07:43 +02:00
Daniel Marjamäki 03ff25f152 gcc: fixed compiler warnings/errors 2011-10-17 20:32:59 +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
Daniel Marjamäki 1ec32e27db Borland: Fixed compiler errors 2011-10-16 07:52:54 +02:00
Daniel Marjamäki 6f8e42a5af changed the astyle formatting flags 2011-10-13 20:53:06 +02:00
Daniel Marjamäki d5bf5b7ad2 Preprocessor: allow that 'missingInclude' messages are suppressed with '--suppress=missingInclude' 2011-08-20 11:23:59 +02:00
Daniel Marjamäki 961b6e7752 Preprocessor: Added safety checks in case the code is corrupt. Related to ticket #2998 2011-08-14 18:35:34 +02:00
Kimmo Varis cfcfa3f000 Use "enabled" list for the style checking.
Settings-class currently enables style checking via dedicated
boolean attribute. All other CLI's enable-options are handled
through the enable-list. This commit moves style-check enabling
to use the enable-list.

Main advantage is the consistency how options are handled/stored
in the Settings class. Which also unifies using them for the other
code. You need to enable certain type of checks? Use the
addEnabled()-method. You want to check if certain type of checks
are enabled? Use the isEnabled()-method.
2011-08-07 10:28:52 +03:00
Daniel Marjamäki e82df7292f Fixed #2919 (Wrong file name reported with #error in header) 2011-08-03 07:28:37 +02:00
Reijo Tomperi ee7b8d53c6 Fix: #2942 (segmentation fault of cppcheck ( #elif (){ ))
http://sourceforge.net/apps/trac/cppcheck/ticket/2942
2011-08-02 22:06:27 +03:00
Simon Martin fc0f75fe6a Preprocessor: Fix #if0 #elif todo test case. Ticket: #2619 2011-07-24 08:54:24 +02:00
Daniel Marjamäki b66e6e73db Fixed #2917 (Problem with || in #if) 2011-07-18 21:44:23 +02:00
Daniel Marjamäki c55b0ff651 Fixed #2871 (Define in source not set when -D is used) 2011-07-16 16:59:06 +02:00
Daniel Marjamäki c299d02dba astyle formatting 2011-07-16 09:32:35 +02:00
Daniel Marjamäki 07a1222ac6 Preprocessor: fix handling of (1&&2) condition 2011-07-16 09:24:27 +02:00
Daniel Marjamäki b6dcdd7b79 Preprocessor: Don't report that there are missing system includes unless --debug-warnings has been given. 2011-05-15 09:38:13 +02:00
Daniel Marjamäki be9e66efff Fixed #2782 (Segfault with #asm) 2011-05-11 19:27:19 +02:00
Daniel Marjamäki d998477c69 renamed --check-includes to --check-config 2011-05-02 21:28:33 +02:00
Daniel Marjamäki 8603919b2d Missing includes - normally just report that there are missing includes. The --check-includes can then be used to check what missing includes there are. Ticket: #2719 2011-05-02 14:58:16 +02:00
Daniel Marjamäki cc8a5fd23e reverted 761dd419 - reporting excessive missing include messages 2011-05-02 14:02:49 +02:00
Daniel Marjamäki 761dd419af Fixed #2719 (Fix excessive false positives in include-file handling) 2011-05-01 12:59:08 +02:00
Greg Hewgill d8a4383f5f Use tolowerWrapper wherever appropriate 2011-04-27 21:13:05 +12:00
Daniel Marjamäki 6fc59b0257 Fixed #2740 (inline cmd // cppcheck-suppress does not work anymore for 1.48) 2011-04-22 20:25:17 +02:00
Martin Exner 2b08744b97 Fixed #2676 (setVarId: variables with global scope qualification :: don't get varids) 2011-04-18 06:56:39 +02:00
Daniel Marjamäki 58dbbb0cab Inconclusive checking: Report inconclusive errors with reportInconclusiveError. It takes the same parameters as reportError. 2011-04-14 18:02:01 +02:00
Daniel Marjamäki e5d43d4ed2 Renamed Settings::stupid to Settings::experimental 2011-04-10 15:55:08 +02:00
Daniel Marjamäki 30ee9ba6e4 Added Settings::stupid flag that can be used to hide checking that generates false positives. 2011-04-10 13:23:45 +02:00
Daniel Marjamäki 76679255a3 Preprocessor: Use %oror% in multiCompare pattern 2011-04-10 11:50:19 +02:00
Daniel Marjamäki e94e3eca82 Preprocessor: Use %oror% in multiCompare pattern 2011-04-10 11:47:49 +02:00
Daniel Marjamaki fbc8223a6b Preprocessor: Fixed expandMacros problem. Ticket: #2707 2011-04-07 16:53:42 +02:00
Daniel Marjamäki b5bdb9eeae fixed gcc compiler warning 2011-04-06 21:40:50 +02:00
Daniel Marjamaki cb473a48b7 Preprocessor: Use Settings::debugwarnings instead of NDEBUG to determine if 'missing system include' should be reported or not 2011-04-06 19:49:04 +02:00
Stefan Weil 675e63b6a7 Spell checks 2011-03-30 16:45:31 +02:00
Daniel Marjamäki a177fc4b24 Preprocessor: made sure string::iterator is valid after string::erase 2011-03-07 22:00:30 +01:00
Daniel Marjamäki 80235b0d53 astyle formatting 2011-03-06 21:15:58 +01:00
Greg Hewgill 7daa6b9370 Always pass unsigned char to ::isspace to prevent runtime error in MSVC 2011-03-07 07:58:44 +13:00
Greg Hewgill b9df7735c5 switchCaseFallThrough is now an inconclusive check 2011-03-06 13:06:30 +13:00
Greg Hewgill c8394909c0 Relax detection of 'fall through' comment so it only adds a suppression if it immediately precedes 'case' or 'default' 2011-03-06 12:14:10 +13:00
Greg Hewgill 8c245cfd2f switchCaseFallThrough is now a coding style check (ticket #2623) 2011-03-06 09:43:27 +13:00
Greg Hewgill e12ae654a8 Support a few more common styles of "fall through" comment 2011-03-05 18:02:38 +13:00
Greg Hewgill cc7e05a5b0 fix case where fall through comment precedes preprocessor line 2011-03-05 00:45:58 +13:00
Greg Hewgill 1a606a57fd slightly more flexible detection of 'fall through' comment 2011-03-05 00:45:58 +13:00
Greg Hewgill 610d2efaea recognise fall through in c style comments 2011-03-05 00:45:58 +13:00
Greg Hewgill 93ea774484 initial simplistic implementation of switchCaseFallThrough 2011-03-05 00:45:57 +13:00
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
Daniel Marjamäki 96c85104ab astyle formatting 2011-02-26 20:09:14 +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 9983aa5721 Fixed #2605 (cppcheck hangs with 100% cpu load ( #define = )) 2011-02-22 19:55:02 +01:00
Daniel Marjamäki c52704e636 astyle formatting 2011-02-20 21:00:03 +01:00
Daniel Marjamäki c3fba356c0 Fixed #2563 (#if equality testing does not ignore parentheses) 2011-02-20 20:57:28 +01:00
Greg Hewgill 98ab34b2b5 Support cppcheck-suppression in C style comments 2011-02-20 11:44:42 +13:00
Ettl Martin d2a1d3f14a fixed pre/post increment warings, found during selfcheck 2011-02-13 23:57:07 +01:00
Daniel Marjamäki 227a6100f7 astyle formatting 2011-02-11 19:31:37 +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
Erik Lax b3e8ef9d48 Fixed #2559 (Refactoring Preprocessor::read) 2011-02-11 06:30:42 +01: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
Raphael Geissert 8d5863133c Use Token::simpleMatch where no patterns are used 2011-02-02 13:27:01 -06:00
Raphael Geissert 386de53ff7 Formatting, sorry 2011-01-30 20:37:37 -06:00
Raphael Geissert 29ca5fbe1e Minor optimisations to the preprocessor 2011-01-30 18:47:49 -06:00
Raphael Geissert b4a249f26e Reduce std::string::find() abuse 2011-01-30 18:40:59 -06: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
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
Pete Johns 9c300813a4 Fixed gcc warning. 2011-01-17 08:52:26 +11: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
Reijo Tomperi 226b605774 Change year 2010 -> 2011 in license texts. 2011-01-09 21:33:36 +02:00
Daniel Marjamäki d27b6a1598 astyle formatting 2011-01-07 20:48:02 +01:00
Daniel Marjamäki 989e0e7ccb Preprocessor: fix bug when determining location when there is a missing include. ticket: #2326 2011-01-07 19:48:51 +01:00
Daniel Marjamäki a7835c4054 Preprocessor: Reverted fix for #2131, it didn't work well so a better fix is needed 2011-01-06 20:01:09 +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 38e7209d26 Fixed #2373 (Using XML2 in --errorlist output) 2010-12-29 12:43:29 +01:00
Daniel Marjamäki 4fd8d2e056 Fixed #2326 (Preprocessor: inline-suppr does not work for id=missingInclude) 2010-12-26 11:14:57 +01:00
Daniel Marjamäki be46d453c4 Information: Added new severity 2010-12-22 19:53:17 +01:00
Daniel Marjamäki 79ea453913 Preprocessor: Report 'missing system include' with debug severity. temporary solution until the handling of system includes is better. 2010-12-18 14:45:53 +01:00
vBm 46a11183a5 Fixed some spelling mistakes 2010-12-15 18:45:53 +01:00
Daniel Marjamäki 1f1df0645b Merge branch 'xml2' of github.com:danmar/cppcheck 2010-12-04 14:06:57 +01:00
Daniel Marjamäki 66f0948395 Preprocessor: Don't include system headers twice. 2010-12-02 18:07:32 +01:00
Daniel Marjamäki af80384ae7 xml2: replace --xml2 with --xmlver=2. Ticket: #2106 2010-12-02 17:32:51 +01:00
Daniel Marjamäki 12c8eeff2c xml2: Added experimental --xml2 result format. Ticket: #2106 2010-12-01 21:24:17 +01:00
Robert Reif f12c0c7ada Tokenizer: add assert(_settings) to Tokenizer to insure the tokenizer always has settings. Ticket: #2219 2010-12-01 18:00:55 +01:00
Daniel Marjamäki 3068dbf22e Preprocessor: Temporarily skip 'missing include' warnings for system headers in release mode. When the handling works better these messages should not be skipped. Ticket: #1937 2010-11-28 12:38:06 +01:00
Daniel Marjamäki 71ea6213d0 Fixed #2131 (Preprocessor: incorrect include file loading) 2010-11-14 08:35:32 +01:00
Daniel Marjamäki 6836198a5c system headers: merged the systemheaders branch into master. it works pretty well. Ticket: #1937 2010-11-13 13:06:58 +01:00
Daniel Marjamäki ba7a3b376e Fixed #2167 (Drop linefeeds from error messages) 2010-11-11 19:54:43 +01:00
Kimmo Varis 9627b667a1 Move simplifyPath method from FileLister to Path class.
simplifyPath() "fits" better to Path class conceptually. It handles
paths, not lists them. Also this way we get rid of few unneeded
dependencies to FileLister class.
2010-10-29 22:21:27 +03:00
Daniel Marjamäki 86e517c5d3 Fixed #1951 (Preprocessor: Compound macro statements not handled correctly) 2010-09-24 21:38:11 +02:00
Daniel Marjamäki a6ff3681bb Fixed #1802 (Preprocessor: macros are expanded wrong) 2010-09-18 22:20:01 +02:00
Daniel Marjamäki ebf13acfbd Fixed #2032 (inline suppressions fail with comment on the same line as function) 2010-09-15 21:10:54 +02:00
Daniel Marjamäki de3b9f610a Fixed #2033 (all inline suppressions fail with relative paths) 2010-09-15 21:03:21 +02:00
Daniel Marjamäki 42d0ad8262 Fixed #2048 (Preprocessor: ifndef incorrectly simplified) 2010-09-14 17:45:37 +02:00
Robert Reif f2a3267ac7 Preprocessor: Report #error configuration when -D is used. Ticket: #2042 2010-09-14 07:21:19 +02:00
Daniel Marjamäki b0bb71ee20 Preprocessor: Handle C++0x rawstrings by replacing them with normal strings. Ticket: #2022 2010-09-13 19:36:40 +02:00
Daniel Marjamäki b1d74ed6b8 Revert "Preprocessor: Report #error configuration when -D is used. Ticket: #2042"
This reverts commit 674644cb29.
2010-09-13 16:59:43 +02:00
Robert Reif 674644cb29 Preprocessor: Report #error configuration when -D is used. Ticket: #2042 2010-09-13 16:55:40 +02:00
Robert Reif aae2986361 Fixed #2042 (#error messages should be displayed when user defines are used) 2010-09-12 21:30:47 +02:00
Daniel Marjamäki f490ebcf88 Fixed #1872 (Confused -v switch) 2010-09-03 13:30:49 +02:00
Daniel Marjamäki 427c0f4bfd Fixed #1975 (segmentation fault of cppcheck) 2010-09-02 23:01:12 +02:00
Daniel Marjamäki d45186d645 Added --debug-warnings that we can use to enable various debug warnings 2010-08-27 20:28:00 +02:00
Daniel Marjamäki 1d9e484053 Fixed #1951 (Preprocessor: Compound macro statements not handled correctly) 2010-08-26 21:33:45 +02:00
Ettl Martin a6be941006 actived Wconversion flag in Makefile and fixed almost all Warnings from gcc-4.4 2010-08-12 19:39:19 +02:00
Daniel Marjamäki dcf54621d4 visual studio: fixed a few compiler warnings (when saving istream::get result in a char) 2010-08-07 20:33:24 +02:00
Daniel Marjamäki adc47f1820 Fixed #1487 (fix gcc compiler warnings) 2010-08-06 21:02:43 +02:00
Daniel Marjamäki 290d02780f gcc: Fixed some compiler warnings when using -Wsign-conversion. Ticket: #1487 2010-08-06 19:38:21 +02:00
Daniel Marjamäki 567f1da4b4 Preprocessor: Compiler dependent parsing of '<backspace><space><newline>'. Maybe it should be possible to control it from the commandline instead. Ticket: #640 2010-08-06 08:50:31 +02:00
Daniel Marjamäki 9edecd4a3f Added ErrorLogger::reportProgress and removed ErrorLogger::ReportProgress. This will make it easier for GUI and other clients to display progress information. 2010-08-03 16:36:21 +02:00
Daniel Marjamäki 81d7a37b68 Fixed #1864 (Relative Path of #include-File doesn't work) 2010-07-27 18:07:30 +02:00
Daniel Marjamäki 7c5219324e Refactoring: Cleanup include that checkheaders reported as not needed 2010-07-26 22:05:51 +02:00
Daniel Marjamäki e358af9018 Refactoring: Report progress when checking takes a long time. Ticket: #1868 2010-07-25 18:19:37 +02:00
Daniel Marjamäki 29b2be19ab Fixed #1383 (Preprocessor: define - ifndef problem) 2010-07-25 15:19:25 +02:00
Daniel Marjamäki 0c65796984 Refactoring: Cleanup headers using checkheaders 2010-07-24 22:12:56 +02:00
Daniel Marjamäki 3ad8f98c61 Refactoring: Settings::addSuppression return error message and callers make sure it's reported properly. Ticket: #1839 2010-07-23 23:12:56 +02:00
Daniel Marjamäki 5e0a4a173a Refactoring: The preprocessor will report errors instead of throwing exceptions. Ticket: #1866 2010-07-23 13:54:52 +02:00
Kimmo Varis b4d55d8e65 Fix path separators for missing include files-message. 2010-07-21 17:00:12 +03:00
Kimmo Varis 618076a65f Better fix for #1371.
Now handles also system includes. And have couple of tests.
2010-07-21 14:16:42 +03:00
Kimmo Varis 9d29ee6edd Use enum for header file types 2010-07-21 12:58:30 +03:00
Daniel Marjamäki 3c376047ba pulled changes from kimmov (filelocation-refactor) 2010-07-19 18:06:49 +02:00
Kimmo Varis b384aabc52 Fixed #1371 (#include "foo\file.h" -> #include "foo/file.h" should be handled automatically on linux)
Linux can't open file paths with / separator. So we'll need to fix
such include file paths (in source files) first.
2010-07-18 20:02:18 +03:00
Kimmo Varis 6db365e6f7 Improve path name handling in ErrorLogger.
This commit adds setfile() method to FileLocation class. The setfile
method converts in Windows path separators to internally used Unix
separators. And getfile() converts path separators back to Windows
separators. This fixes bugs that error reports had mixed path
separators in paths.
2010-07-17 01:27:40 +03:00
Kimmo Varis ad0394939a Refactor ErrorMessage constructor to take Severity::SeverityType.
This removes lots of unneeded casting as everybody now uses the
Severity::SeverityType.
2010-07-14 23:11:32 +03:00
Kimmo Varis 5f8af2e1e8 Refactor ErrorMessage's severity to Severity::SeverityType. 2010-07-14 21:12:39 +03:00
Daniel Marjamäki 54b8e79cae Preprocessor: Reduce copy/pasted code 2010-06-20 18:41:45 +02:00
Nicolás Alvarez c76a9525c1 Change size-t to std::string::size_type. 2010-06-19 17:24:10 -03:00
Nicolás Alvarez 12d6947334 Fix build error on 64-bit systems. 2010-06-19 17:16:14 -03:00
Daniel Marjamäki a402b6bb98 Fixed #1802 (Preprocessor: macros are expanded wrong) 2010-06-19 12:03:39 +02:00
Daniel Marjamäki 38c3de7343 Preprocessor: Refactoring. Broke out code that parses out the parameters from code. 2010-06-19 09:09:47 +02:00
Robert Reif a8921afcd7 Fixed #1698 (Add define support to GUI) 2010-05-21 09:49:57 +02:00
firewave 43dd749cc6 Fix #1585 (--append doesn't work with TAB formating) 2010-04-15 22:45:38 +02:00
Reijo Tomperi 15e4b8dbd5 Fix #1595 (case marks improperly tokenized with macro)
http://sourceforge.net/apps/trac/cppcheck/ticket/1595
2010-04-15 23:21:00 +03:00