Commit Graph

120 Commits

Author SHA1 Message Date
PKEuS 167a7e3e51 Various code cleanups 2011-12-08 21:28:34 +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 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
Edoardo Prezioso 2c64d299ca Change every 'tokAt(...)->str()' to 'strAt(...)'. 2011-11-13 13:10:59 +01:00
Edoardo Prezioso b28a44dc3b Change: 'next()->next()'->'tokAt(2)', 'previous()->previous()'->'tokAt(-2)'. 2011-11-12 22:33:03 +01:00
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
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 4342fd254c Fixed #3266 (False positive on dangerous usage of .c_str()) 2011-11-04 19:21:19 +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
Edoardo Prezioso 433f4640a9 Fix some GCC warnings regarding the sign conversion. 2011-10-30 18:34:49 +01: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 54adb910ec Use Token::simpleMatch instead of Token::Match for simple patterns 2011-10-27 15:59:22 +02: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
Marek Zmysłowski 190139f441 Fixed #3174 (New check: Useless calls of STL functions) 2011-10-24 23:25:23 +02:00
Reijo Tomperi bf2759118b Added support for C++11's cend/crend/cbegin/crbegin functions in some STL checks
Patch from: PKEuS <philipp.kloke@web.de>
2011-10-22 23:38:03 +03:00
PKEuS dc15641954 Fixed #3223 (Improve check: Check more STL algorithms for missmatching containers check) 2011-10-18 21:55:41 +02:00
Thomas Jarosch 7824e5c0f5 Fixed #3210 (STL check: Add support for reverse iterator) 2011-10-14 19:54:20 +02:00
Daniel Marjamäki 6f8e42a5af changed the astyle formatting flags 2011-10-13 20:53:06 +02:00
Daniel Marjamäki d23c58d387 enable: break out 'performance' and 'portability' from the 'style' id. Ticket: #3074 2011-09-03 15:30:30 +02:00
Robert Reif 9a70ec87a8 convert CheckStl::if_find() to use the symbol database 2011-08-14 10:46:35 -04: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
Robert Reif fa82d43562 fix #2967 (segmentation fault of cppcheck ( auto_ptr< x >)) 2011-08-05 18:18:30 -04:00
Robert Reif 2516aad31d fix #2887 (infinit loop with ( A::A(std::auto_ptr<X> e){} )) 2011-08-04 19:50:18 -04:00
Daniel Marjamäki dc629b4c39 Fixed 'possible null pointer dereference' warning messages 2011-07-28 08:12:21 +02:00
Benjamin Wolsey e6d8f3fb73 Fix tested auto_ptr false positive. 2011-07-20 19:17:59 +02:00
seb777 172903cde4 fix 2846 (false positive for auto_ptr check with container element) 2011-06-20 23:02:05 +02:00
seb777 20de3f90ef fix 2838 (Token::Match called with varid 0 on auto_ptr check) cleanup code and better check varid 2011-06-17 21:09:27 +02:00
seb777 5b940c0c7f fix #747 and #748 (incorrect use of auto_ptr - new check) 2011-06-16 20:26:00 +02:00
Lauri Nurmi be57aa5ad5 Fixed #2836 ([PATCH] FP: Dereferenced iterator has been erased) 2011-06-14 07:26:59 +02:00
Daniel Marjamäki 1c841535ee Fixed #2798 (False positive: Invalid iterator check doesn't respect code paths) 2011-05-22 17:17:24 +02:00
Daniel Marjamäki 9e97da8a57 Reverted fix for string::size. Ticket: #2756 2011-05-05 20:57:17 +02:00
Robert Reif a2938b7212 fix 2011-04-28 19:08:18 -04:00
Stefan Weil 675e63b6a7 Spell checks 2011-03-30 16:45:31 +02:00
Robert Reif 1aca09a8bf add support for checking struct/class member container in CheckStl::size() 2011-03-28 19:31:23 -04:00
Daniel Marjamäki 384729204f Refactoring: Use SymbolDatabase to determine if variable is a iterator 2011-03-13 09:48:53 +01:00
Daniel Marjamäki 85daa26fdf Refactoring: Use symbol database to get variable type 2011-03-13 08:48:38 +01:00
Daniel Marjamäki 6bd56dbe20 Fixed #2643 (False positive: iterator increment and insert) 2011-03-12 20:29:54 +01:00
Robert Reif e305a155af convert CheckStl::size() to use symbol database, fix false positives, and remove inconclusive 2011-03-07 19:49:43 -05:00
Kimmo Varis 7d73b523be Clarify few verbose messages.
Dan pointed out to me earlier that he wants both short- and
verbose messages to be independently understandable. So modifying
some verbose messages to be easier to understand without the short
message.
2011-02-04 11:10:24 +02:00
Raphael Geissert f8e2d50e6f Use Token::simpleMatch where no special patterns are needed 2011-02-02 13:27:02 -06:00
Raphael Geissert 8d5863133c Use Token::simpleMatch where no patterns are used 2011-02-02 13:27:01 -06:00
Raphael Geissert cf2b6f7bc1 Remove useless spacing at the end of *Match strings 2011-02-02 13:27:01 -06: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 433ae8abf4 STL: Optimised checking 2011-01-15 22:38:05 +01:00
Daniel Marjamäki 00b49a51da Fixed #2451 (False positive when incrementing map value via iterator) 2011-01-14 19:50:07 +01:00