Commit Graph

392 Commits

Author SHA1 Message Date
Daniel Marjamäki f0ce26a2aa Preprocessor: Let the Tokenizer handle NULL 2013-01-13 15:01:31 +01:00
Reijo Tomperi 5d5f7085bf Updating year 2012 -> 2013 to .cpp and .h files and man page. 2013-01-01 18:29:08 +02:00
Simon Kagstrom 95b51d02c9 path: Add getPathFromFilename (returns the path part of a filename)
E.g.,

  /tmp/a.h -> /tmp/
  a.h ->

etc.
2012-12-28 12:44:26 +01:00
Simon Kagstrom 350f86fb6a preprocessor: Kill commented out code 2012-12-28 12:43:43 +01:00
Simon Kagstrom 1e4288fe2e preprocessor: Don't access empty lists
libc aborts with:

/usr/include/c++/4.4/debug/list:256:error: attempt to access an element in
    an empty container.

Objects involved in the operation:
sequence "this" @ 0x0xbfffe5f0 {
  type = NSt7__debug4listISsSaISsEEE;
}

otherwise.
2012-12-28 12:43:43 +01:00
Daniel Marjamäki 7368079949 Fixed Cppcheck self-check message 2012-12-27 17:11:22 +01:00
Daniel Marjamäki 57488db9da Preprocessor: Reduce variable scope 2012-12-27 17:00:59 +01:00
Daniel Marjamäki 0585588fc7 astyle formatting 2012-12-27 16:59:30 +01:00
Simon Kagstrom ef28bde3e4 Fixed #4408 (Force inclusion of files (a la -include /.../ in GCC)) 2012-12-27 16:52:31 +01:00
Daniel Marjamäki b08ba5b575 Preprocessor: Refactoring previous fix 2012-12-02 20:17:25 +01:00
Daniel Marjamäki cb06d07ae7 Fixed #4351 (Escaped whitespace gives wrong error) 2012-12-02 18:04:19 +01:00
Edoardo Prezioso f42ab9871d Fix build breakage in recent commits. 2012-12-01 02:02:45 +01:00
Daniel Marjamäki 45b77554ea Fixed #4308 (C++11 raw string literals not parsed correctly) 2012-11-30 13:46:46 +01:00
Daniel Marjamäki 7d94230329 Fixed #4079 (#if condition does not evaluate numbers with sign) 2012-11-28 07:33:24 +01:00
PKEuS 4cd96158ae Fixed parsing of "__asm__ volatile {""};" 2012-11-04 12:21:34 +01:00
Daniel Marjamäki 24e71c479c Fixed #4301 (htmlreport broken) 2012-11-03 11:25:40 +01:00
Edoardo Prezioso b50e1f4451 Attempt to fix all doxygen warnings. 2012-10-24 01:32:07 +02:00
Daniel Marjamäki c65ac603e9 Fixed #3837 (False positive: national locale inline asm comments are reported as unsupported) 2012-09-30 09:35:32 +02:00
PKEuS 547d3e94b2 Fixed some sign conversion messages from clang. 2012-09-16 16:41:15 +02:00
Daniel Marjamäki bd734a9610 Fixed #3684 (Preprocessor: #include handling is searching directories in the wrong order) 2012-09-15 12:53:11 +02:00
Kamil Dudka b4d78e3d05 Fixed #3651 (Preprocessor: Wrong handling of #elif) 2012-09-15 09:34:41 +02:00
Daniel Marjamäki 329f672334 Preprocessor: Added TODO in code. How can userDefines be empty? It is an inner condition and the outer condition checks that it's not empty. 2012-09-15 08:13:52 +02:00
Daniel Marjamäki 6ebfbf42e1 Fixed #4191 (wrong syntax error if 'error' substring of stringification) 2012-09-12 16:10:45 +02:00
PKEuS 50f9dd52ab Used enum instead of string in implementation for '--language='. 2012-09-11 08:53:27 +02:00
PKEuS 87131f6105 Added new cmdline option --language= (alias of GCC-like -x) to enforce a specific language. Valid values: c, c++, java, c#. (#3994) 2012-09-10 18:51:32 +02:00
PKEuS 8c70778b70 Refactorization: Fixed several messages when self-checking cppcheck 2012-09-04 15:29:51 +02:00
Daniel Marjamäki 769cd4503d Preprocessor: Made function static after self-check suggestion 2012-09-01 10:32:27 +02:00
Daniel Marjamäki 41797d409d Fixed #4036 (cppcheck hangs with 100% cpu load) 2012-08-25 13:24:17 +02:00
PKEuS f238f3fad5 Support sizeof in preprocessor directives
Applied "patch" provided by michaeln123 in #4071
2012-08-22 17:28:06 +02:00
Daniel Marjamäki 79c84029fb Preprocessor: Reduce simplifyVarMap usage to make Cppcheck a bit faster 2012-07-27 12:30:43 +02:00
PKEuS f5e5d59562 Refactorizations:
- Removed redundant newlines at the end of test cases
- Make use of STL algorithms instead of own implementations of std::replace and std::remove+string::erase
- Removed unused variable (found by cppcheck)
- Prefer postfix increment (found by cppcheck)
2012-07-24 12:21:05 -07:00
Daniel Marjamäki dc6c3228d7 Fixed #3834 (Preprocessor: -U doesn't work) 2012-07-18 20:57:00 +02:00
Daniel Marjamäki 5645269bbf Preprocessor: Made proper fix for #3690 2012-07-13 11:36:02 +02:00
Daniel Marjamäki e4ad193b40 Fixed #3690 (CppCheck is stuck on evaluating false preprocessor expression( = 0)) 2012-07-13 11:28:45 +02:00
Daniel Marjamäki 8dd5270be3 Preprocessor: skip preprocessor directives in the Preprocessor::validateCfg function 2012-07-11 21:20:31 +02:00
Daniel Marjamäki 4f4be79f20 Preprocessor: Fixed bugs in my #3643 fix 2012-07-11 18:29:33 +02:00
Daniel Marjamäki 17cf24ed34 Fixed #3643 (Preprocessor: Invalid configuration (macro is used in code)) 2012-07-10 20:29:04 +02:00
Edoardo Prezioso fae40c4782 Change every C version of 'size_t' to C++ 'std::size_t'. 2012-07-09 13:30:18 +02:00
Edoardo Prezioso 3c4ce7b43a Fixed (for real) the preprocessor.cpp(1166) warning in #2123. 2012-07-06 13:17:08 +02:00
Edoardo Prezioso 1ad56a25c6 Fixed the preprocessor.cpp(1166) warning in #2123. 2012-06-26 12:28:52 +02:00
Daniel Marjamäki 956a37a382 Fixed compiler errors 2012-06-20 17:39:31 +02:00
Kimmo Varis 68c52ddd69 Refactoring information messages.
Currently the information severity messages are outputted as error
messages with Severity::Information. This causes constant confusion
as people think it as mildest error severity (and rightfully so).
When it was meant to be for printing messages about the checking
procedure itself (like missing header files etc).

So I'm adding a new function for the ErrorLogger for printing these
informative messages. This makes clear the distinction of errors
found from the code and messages related to the checking itself.
It also makes it easier for clients to handle these separately.
2012-06-19 00:16:20 +03:00
Daniel Marjamäki 171f570639 Handle UTF-16 files. Partial fix for ticket #2083 2012-06-10 11:00:27 +02:00
PKEuS 279b0c59bb Don't set Preprocessor::missingIncludeFlag if missingInclude warning is suppressed (#3487). 2012-05-16 02:59:45 -07:00
Edoardo Prezioso eacf74be8d Changed the order of some structures in order to improve, even if for a bit, their padding. 2012-05-14 20:49:03 +02:00
Daniel Marjamäki dad2fb6db1 Fixed #3737 (Preprocessor: __cplusplus always defined for c++ code) 2012-05-08 11:49:43 -07:00
PKEuS 1a5fbd61d2 Splitted class TokenList from Tokenizer 2012-05-05 09:33:26 -07:00
Daniel Marjamäki 005ce81689 Fixed #3640 (False positive: statement begins with numeric code) 2012-05-04 17:53:47 +02:00
Ahti Legonkov 79af6f65d7 Fixed #3699 (cppcheck hangs with 100% cpu load on parsing preprocessor code) 2012-04-22 06:49:42 +02:00
PKEuS 25167b58a9 Implemented #2990: Print relative paths if -rp or --relative-paths is given 2012-04-06 10:49:21 +02:00
Daniel Marjamäki 01ddfb6f80 Fixed #3534 (Broken support for dollar signs in identifiers) 2012-03-27 19:35:41 +02:00
Ahti Legonkov 780481e82a Fixed ticket #3675. 2012-03-23 01:45:47 +02:00
Daniel Marjamäki fc84f55f80 Fixed #3536 (Preprocessor #if fails to correctly compare two #defined values) 2012-03-15 20:04:34 +01:00
Daniel Marjamäki db1205cdb3 Preprocessor: better handling of '#if A==1' 2012-02-29 19:08:01 +01:00
Daniel Marjamaki fbb5ebe3c6 Fixed #3577 (Preprocessor: Defines given on command line are not used in the code) 2012-02-05 20:48:28 +01:00
Daniel Marjamäki 8e2c40b4b3 Fixed #3323 (#undef needs different handling) 2012-01-24 07:43:26 +01:00
Ahti Legonkov 78461093f0 Fixed #3531 (When macro definition contains parenthesis, the #defined symbol does not get #defined.) 2012-01-21 12:51:54 +01:00
seb777 9be2d1cc62 It is a good practice to clear container after deleted all the items 2012-01-19 12:41:14 +01:00
Daniel Marjamäki bd8c21fc6b Refactoring: Made Preprocessor::simplifyCondition nonstatic 2012-01-06 08:42:07 +01:00
Daniel Marjamäki e4875178fa Refactoring: Removed redundant settings parameter for Preprocessor::removeComments 2012-01-06 08:09:53 +01:00
Daniel Marjamäki 94d220e370 Refactoring: Made Preprocessor::getcode nonstatic 2012-01-06 08:01:50 +01:00
Daniel Marjamäki 07776e90ad Preprocessor: cleanup 2012-01-05 18:37:15 +01:00
PKEuS 9c423b82c1 Refactorizations in preprocessor.cpp 2012-01-02 15:52:19 +01:00
PKEuS 38ddcde7b0 - Refactorizations in preprocessor.cpp and tokenizer.cpp
- Bugfix: tok->stringify(tok) returns now "".
- Removed most of the inline-asm handling in preprocessor; improved the remaining handling of #asm/#endasm: Simplified to "asm(...);" statement
2012-01-02 12:58:34 +01:00
PKEuS 064e0ea0d0 Revert "- Refactorizations in preprocessor.cpp and tokenizer.cpp"
Committing with subversion seems to have issues. Sorry for that. I'll the changes again, now using git.

This reverts commit 69498de6ca.
2012-01-02 12:10:53 +01:00
Philipp K 69498de6ca - Refactorizations in preprocessor.cpp and tokenizer.cpp
- Bugfix: tok->stringify(tok) returns now "".
- Removed most of the inline-asm handling in preprocessor; improved the remaining handling of #asm/#endasm: Simplified to "asm(...);" statement
2012-01-02 03:15:02 -08:00
Reijo Tomperi 8cae17fda8 Update year to 2012 2012-01-01 01:05:37 +02:00
PKEuS dca03c3ce2 Remove unnecessary includes
Also add a unit test related to #3427
Also improve the description text in checkclass and remove unused variable.
2011-12-23 23:31:48 +02:00
Daniel Marjamäki 2bb5de4c89 Fixed #3425 (False positive: Null pointer dereference (pointer is checked in macro)) 2011-12-18 13:33:23 +01:00
Daniel Marjamäki 322f46c761 Fixed #3426 ((error) Invalid number of character ({) when these macros are defined:) 2011-12-17 15:23:55 +01:00
Daniel Marjamäki fd78816181 Fixed #3418 (preprocessor define assignment not propagated) 2011-12-15 18:49:35 +01:00
Daniel Marjamäki 34fba9e1ea Fixed #3405 ((error) Invalid number of character ({) when these macros are def ined: 'WIN32'.) 2011-12-13 21:14:41 +01:00
Daniel Marjamäki c8f497a9b3 Fixed #3405 ((error) Invalid number of character ({) when these macros are def ined: 'WIN32'.) 2011-12-12 19:35:25 +01:00
Daniel Marjamäki 8624c0b9fd Merge pull request #67 from makulik/master
Fixed ticket #3389 '-U option doesn't supress include file handling for #include statements inside #ifdef code paths'
2011-12-10 02:44:01 -08:00
makulik 0a777dcb52 Fixed ticket #3389 '-U option doesn't supress include file handling for #include statements inside #ifdef code paths'
Signed-off-by: makulik <g-makulik@t-online.de>
2011-12-09 21:57:06 +01:00
Daniel Marjamäki b383bae4ab C++ Builder: Fixed compiler errors 2011-12-08 22:17:50 +01:00
Daniel Marjamäki 6029e23189 Preprocessor: Use const_iterator instead of iterator where possible 2011-12-08 22:14:11 +01:00
PKEuS 167a7e3e51 Various code cleanups 2011-12-08 21:28:34 +01:00
Edoardo Prezioso 4de5d87078 1)Remove newly copy of 'eraseTokens' and replace every occurrence with 'deleteNext' with right parameter.
2)General improvements to code.
2011-12-08 01:44:18 +01:00
Edoardo Prezioso 612b3c59ca 1)Implement another declaration of 'Token::eraseTokens' with parameters: the starting token and the number of times needed to call 'deleteNext'.
2)Use the overloaded 'eraseTokens' where needed instead of using consecutively 'deleteNext'.
3)Tokenizer: general optimizations about the deletion of some tokens.
4)Run astyle.
2011-12-07 02:29:03 +01:00
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