Commit Graph

3094 Commits

Author SHA1 Message Date
Edoardo Prezioso 2aceb623ae 1)Add 'Token' function 'linkAt', which simplifies the writing 'tokAt(i)->link()' to 'linkAt(i)'.
It's still unused, though.
2)Fix one grammatical mistake inside token.h
3)Style change to token.cpp: remove the whitespace between '!' and 'begin'.
2011-11-11 21:55:37 +01:00
Thomas Jarosch 283c2e508e Remove check for "this" inside Token class
The check hides real memory problems and is
also useless in most cases.
2011-11-11 17:19:08 +01:00
Daniel Marjamäki 5a35beebf7 added todo comment 2011-11-11 11:07:03 +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
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
Richard Quirk f56aa19fac Fix varid 0 with function pointer and virtual methods 2011-11-09 21:07:55 +01:00
Thomas Jarosch c010ca33a5 Run astyle 2011-11-09 20:34:58 +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 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 d5c7c5d098 Remove duplicate expressions on both sides of || 2011-11-08 21:56:54 +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 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 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
Edoardo Prezioso 5cf7cb9ff5 Conforming style: always use 'std::' namespace where needed. This removes the mixing style inside the code. 2011-11-07 00:54:00 +01: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
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 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 9903c8c0d9 astyle formatting 2011-11-05 20:00:18 +01:00
Daniel Marjamäki 2f32965bdf Token: assert that multicompare patterns don't begin with some %% command 2011-11-05 19:59:48 +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
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
Daniel Marjamäki d3b27c40fc fixed --doc output 2011-11-05 07:45:30 +01:00
PKEuS 0c469bae41 Fixed #3089 (New Check: Detect wrong usage of printf/scanf) 2011-11-05 07:29:53 +01:00
Thomas Jarosch 4342fd254c Fixed #3266 (False positive on dangerous usage of .c_str()) 2011-11-04 19:21:19 +01:00
Reijo Tomperi 682aae3196 Improve internal error print out, print line number with the error message. 2011-11-03 22:43:13 +02: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 dfcbc38466 Preprocessor: Don't warn about missing system headers during 'normal' preprocessing 2011-11-02 18:40:56 +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
Edoardo Prezioso 9dd3360cd6 Fix some complainted choices made in my older commits.
Note: probably you should do 'make clean' before using 'make' to rebuild it again. Maybe it's me but 'make' reports various errors when linking.
2011-11-01 13:23:47 +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 7d7a54d89c Merge pull request #53 from gansb/master
Add missing newline
2011-10-31 11:53:33 -07:00
Daniel Marjamäki a7f27a83a7 Fixed #3271 (Regression: something related to symbol database / varid) 2011-10-31 18:33:15 +01:00
Benjamin Goose f22f9fcc0e Add newline at end of file! 2011-10-31 15:12:29 +01:00
Edoardo Prezioso 4295439e53 Fixed ticket #3269 (Regression, I think it's somehow related to symbol database) 2011-10-31 15:05:52 +01:00
Edoardo Prezioso ba5909ef1d General code tweaking, nothing strange. 2011-10-31 02:24:59 +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
Edoardo Prezioso 433f4640a9 Fix some GCC warnings regarding the sign conversion. 2011-10-30 18:34:49 +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 4fc7e86d7d Fixed: with checkConst and checkVariableScope wanted still required "information" settings instead of "style". 2011-10-30 10:58:15 +01:00
Daniel Marjamaki 132f0e12d1 CheckClass: Added classInfo about explicit checking 2011-10-30 09:54:02 +01:00
Daniel Marjamaki 8514466c68 Visual Studio: Fixed compiler error 2011-10-30 09:53:14 +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 42fd4e2f52 Tokenizer: Change 'var++|--;' into '++|--var;' and remove redundant 'tokAt(0)'. 2011-10-29 22:25:49 +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 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 a809bb3471 astyle formatting 2011-10-29 19:51:11 +02:00
Daniel Marjamäki acaa9c456f Fixed #3152 (Tokenizer: template constructor is removed) 2011-10-29 19:45:47 +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 a0a5b36667 Ensure single-argument constructors are explicit 2011-10-29 18:24:30 +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
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
Daniel Marjamäki 3c509589b5 use reportInconclusiveError instead of reportError if checking is inconclusive 2011-10-29 15:16:27 +02:00
Reijo Tomperi 12a10a7297 Fix related to previously fixed #3256 (Null pointer dereference not detected)
Use reportInconclusiveError() instead of reportError().
2011-10-29 15:55:52 +03:00
Daniel Marjamäki a79b5a5c36 astyle formatting 2011-10-29 12:53:08 +02:00
Daniel Marjamäki f04210ad9f updated comment. removed a inconclusive condition, I don't think it's needed. 2011-10-29 12:52:46 +02:00
Thomas Jarosch ad40586e96 Disable internal checks if NDEBUG is defined (release build) 2011-10-29 12:47:12 +02:00
Daniel Marjamäki 6c02de151f strncmp sizeof: tweaked the check. 2011-10-29 12:27:19 +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 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
Thomas Jarosch 2b8da1241b Add missing percent end character 2011-10-29 12:08:36 +02:00
Richard Quirk 45d0709ed5 Only run sizeof(char*) check if inconclusive is set 2011-10-29 11:59:24 +02:00
Richard Quirk c2d7824130 Move string comparison out of the report function 2011-10-29 11:52:19 +02: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
Edoardo Prezioso 5d868766c7 Tokenizer time improvements (time says real: -1 second)
1)change tokAt(1|-1) with next()|previous() with conditions where necessary;
2)change strAt(1|-1) with next()|previous()->str() with conditions where necessary;
3)change tokAt(n)->str(), with n != -1,1, to strat(n);
4)change simplifyFuncInWhile implementation because it was too slow and stupid.
2011-10-29 01:57:53 +02:00
Edoardo Prezioso dd719b41bf Definitely check correctly 'sizeof %num%' when '%num%' has '-' sign. 2011-10-29 00:11:38 +02:00
Thomas Jarosch dee03a09e4 Fix logic glitch
Reported by Pc-Lint 9.x :o)

The code was working before as the AND operation
also matched in that specific case.

I verified that code is in use by commenting
it out and checked how many tests failed.
2011-10-28 23:36:30 +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
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
Edoardo Prezioso 979f3b051c Improve nextArgument by returning 0 if there's an unexpected ';'. 2011-10-28 18:57:10 +02:00
Thomas Jarosch ef8f49bbf3 Use new findsimplematch API for simple patterns 2011-10-28 12:49:03 +02:00
Edoardo Prezioso bab740289c Complete todo: convert 'for' into 'while'.
It's not possible to enable this code because of the disaster it will be created for all the checks with the 'for' pattern.
2011-10-28 00:50:54 +02:00
PKEuS 49fd057e17 Tokenizer: Simplify 'foo(void)' to 'foo()' 2011-10-27 19:56:59 +02:00
PKEuS 845e5d259a Improved isJavaOrCSharp, isC and isCPP. Fixed isC for files with includes. 2011-10-27 19:18:54 +02:00
Thomas Jarosch 22251d50bb Bugfix: Use Token::Match instead of Token::simpleMatch because it's a complex pattern
This bug was in here before my recent refactoring.

(And yes, I wrote a check for cppcheck's Token::Match invocation ;))
2011-10-27 16:43:04 +02:00
Thomas Jarosch 434fb933a8 Implement Token::findsimplematch und use it for simple patterns 2011-10-27 15:59:22 +02:00
Thomas Jarosch 54adb910ec Use Token::simpleMatch instead of Token::Match for simple patterns 2011-10-27 15:59:22 +02:00
Daniel Marjamaki 5f4c882b08 minor formatting updates of --doc output 2011-10-27 10:50:40 +02:00
Edoardo Prezioso 9bb1a1b7a5 Added code for simplification of 'for ( a; b; c;); -> '{ a; for (; b; c;) ; }'.
It's not enabled because it fails many tests with testrunner.
2011-10-27 02:59:50 +02:00
Edoardo Prezioso 1be1af4afb Move the simplification of 'strlen' in simplifyTokenList.
This way it's possible to omit the call to simplifyKnownVariables before 'strlen'.
2011-10-27 01:24:35 +02:00
seb777 aa74761e8d fix isC method (.C files are C code files) 2011-10-26 22:54:00 +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 84a763d3b0 Run astyle 2011-10-26 21:15:44 +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 de71c41379 Fixed Ticket 2144 (false negatives: Old Style Pointer Cast apply only on .cpp files) 2011-10-26 21:17:27 +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
Marek Zmysłowski 190139f441 Fixed #3174 (New check: Useless calls of STL functions) 2011-10-24 23:25:23 +02:00
Daniel Marjamäki a076b24dc6 astyle formatting 2011-10-24 21:57:49 +02:00
Thomas Jarosch 3413ffef3e Refactor readlink() buffer check to also handle readlinkat() 2011-10-24 21:23:18 +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
Edoardo Prezioso df5d26901c Add new warning option to check for dead code and change the order of some struct members to reduce structure padding. 2011-10-24 03:02:00 +02:00
Thomas Jarosch 55a079a7c4 Clarify Token::concatStr() documentation 2011-10-23 22:47:49 +02: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
PKEuS cdfe0d74e4 Make checkSprintfCall using nextArguments() 2011-10-23 17:47:48 +02:00
PKEuS dfedeeb5c1 Bugfix: checknullpointer worked incorrect for complex first 2011-10-23 15:23:36 +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 6047a28902 Fixed #3185 (Add three more exit functions) 2011-10-23 12:23:53 +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
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
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
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
Edoardo Prezioso 12f6ce46f8 Add more warnings and fix the ones reported by them. 2011-10-22 15:05:43 +02:00
Johan Samuelson 3d8fa2f76e Fixed #3123 ([False Positive] Shadowed enum) 2011-10-22 13:43:53 +02:00
Daniel Marjamäki 32e20d4e31 made 'variableHidingTypedef' inconclusive. See ticket #3199 2011-10-22 13:26:33 +02:00
Erik Lax 2b54f00c87 Fixed #3238 (Crash in obsolete functions check.) 2011-10-22 12:36:45 +02:00
PKEuS ccf087d2ea checkMathFunctions: Refactoring the check 2011-10-22 12:31:47 +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
Marek Zmysłowski 8157799e10 Fixed #3204 (Refactor standards support in Settings) 2011-10-22 10:34:04 +02:00
Daniel Marjamäki cde95d09a3 Merge pull request #41 from gansb/master
std::istream used but not declared.
2011-10-22 00:54:04 -07: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
Benjamin Goose 3f25bd9530 Qualify fill_n properly.
Relying on ADL isn't a good idea as it's not always well implemented.
2011-10-20 09:02:20 +02:00
Benjamin Goose 463b105d98 Add condition for HP-UX. 2011-10-20 09:01:58 +02:00
Benjamin Goose 7d6b76e1d1 Include <iosfwd> for std::istream. 2011-10-20 08:46:29 +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 c9ee19c654 Complete 'disable the rules by default' for other platforms. 2011-10-19 15:14:39 +02:00
Edoardo Prezioso 4f256ef314 Runastyle + removal of useless conditions after previous commit. 2011-10-19 14:48:08 +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 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
Edoardo Prezioso de8eb48a5c Remove redundant function findmatch inside tokenize.cpp.
There's Token::findmatch which is already used inside other Tokenizer functions.
2011-10-17 13:46:27 +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
Daniel Marjamäki 4705026242 fixed a few doxygen warnings 2011-10-16 17:16:07 +02:00
Ettl Martin 1a710e5761 fixed regression on linux due to missing include 2011-10-16 14:16:35 +02:00
PKEuS f8074b71d2 Fixed #2470 (False negative: Possible null pointer dereference (C++0x keyword 'nullptr')) 2011-10-16 12:54:58 +02:00
Daniel Marjamäki 32496fb009 Token: Updated comments 2011-10-16 08:25:11 +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
Daniel Marjamäki 1ec32e27db Borland: Fixed compiler errors 2011-10-16 07:52:54 +02:00
Daniel Marjamäki d5883ef0c4 astyle formatting 2011-10-16 07:50:34 +02:00
PKEuS 71a1d98693 Fixed ##3211 (Crash in gitHEAD when arglist count is smaller than format string) 2011-10-16 07:06:18 +02:00
Edoardo Prezioso 8afc1b6f2d Changed the name of the removal of dead code after flow control statements for consistency (simplifyDeadCode is too generalized as name) 2011-10-15 12:45:48 +02:00
Edoardo Prezioso 57ead6988e Fixed ticket #3138 (Tokenizer: remove unreachable code below goto inside a namespace|class|struct block) 2011-10-15 11:35:45 +02:00
Edoardo Prezioso f95b692a69 Fixed ticket #3113 (complete simplification of dead code after control flow statements) 2011-10-15 01:34:07 +02:00
Thomas Jarosch 7824e5c0f5 Fixed #3210 (STL check: Add support for reverse iterator) 2011-10-14 19:54:20 +02:00
Thomas Jarosch 7ae39f13cc Fixed #3198 (Add check for readlink()) 2011-10-14 19:45:51 +02:00
Jonathan Neuschäfer 4fb7865f49 fix typos using codespell
Codespell is available at http://git.profusion.mobi/cgit.cgi/lucas/codespell/.
2011-10-13 22:04:41 +02:00
Daniel Marjamäki 6f8e42a5af changed the astyle formatting flags 2011-10-13 20:53:06 +02:00
Edoardo Prezioso b792efb761 Fix ticket 3140 and 3137 (Improve Tokenizer: Remove dead for loop - simplify while(0) better.
Note: it doesn't remove dead code if there's a label inside. Will be improved in another ticket.
2011-10-13 13:01:24 +02:00
Edoardo Prezioso 16506f0a8c Remove redundant simplifyDeadCode call inside the Tokenizer::tokenize and move the relative tests in the file 'testsimplifytokens.cpp'. 2011-10-13 12:26:27 +02:00
Zachary Blair 82366918ff Fixed #2627 (switch case fall through: redundant strcpy) 2011-10-13 01:27:22 -07:00
PKEuS 91d7621994 Fixed #3180 (New check: Detect nullpointers given to printf via variable argument list) 2011-10-12 22:11:27 +02:00
Daniel Marjamäki 74c0468a18 astyle formatting 2011-10-12 22:06:19 +02:00
Daniel Marjamäki b73896bcc5 Fixed #3163 (Out of bounds pointer arithmetic not reset) 2011-10-12 20:54:39 +02:00
Daniel Marjamäki 371871b0b7 Tokenizer::removeMacrosInGlobalScope: Don't remove C/C++ keywords namespace/struct/etc. Ticket: #3193 2011-10-12 19:23:39 +02:00
Daniel Marjamäki cf39ece8da Fixed #3150 (Invalid warning when pointer difference is not adjacent) 2011-10-12 19:01:44 +02:00
Robert Reif ee04c1bfb7 fix #3194 (Parsing glitch causes false 'can be const' error for an 'if' statement) 2011-10-12 09:10:34 -04:00
Robert Reif af6a6f9c2d run astyle 2011-10-12 09:08:54 -04:00
Marek Zmysłowski 07d8cd0a12 improved realloc checking '*p = realloc(*p,..'. Ticket: #1791 2011-10-11 22:07:14 +02:00
Thomas Jarosch 849bee8437 [PATCH] Detect suspicious use of semicolon after 'if/for/while'
statements if they are followed by a {..} block.

Examples are:

for (int i = 0; i < 10; ++i);
{
   printf("i)";
}

or

if (i == 100);
{
   die("Wrong argument");
}

This new check is active if you enable inconclusive checks.
2011-10-11 08:41:39 +02:00