Commit Graph

2954 Commits

Author SHA1 Message Date
Stefan Weil 00ead7fb2e support any number of --append=<file> options
If one or more append files are given on the command line,
they are simply concatenated.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2011-11-15 19:27:36 +01:00
Stefan Weil 785bc3d04b Optimize handling of --append=<file> option (execution time, memory)
Whitespace was removed from the append data for every configuration
and every file: n(configuration) * n(files).

Removing whitespace immediately after the append data was read can
significantly reduce the execution time and memory usage.
It also allows further improvement because copies to the temporary
object appendCode are no longer needed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2011-11-15 19:27:36 +01:00
Stefan Weil d11f18b5df cmdlineparser: terminate with error message if --append=<filename> fails
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2011-11-15 19:27:36 +01:00
Thomas Jarosch c317c8979c Run astyle 2011-11-14 09:21:42 +01:00
Thomas Jarosch a645235d5a Adapt Token::strAt() to return a const reference like Token::str() does
Saves us a complete conversion from string.c_str() back to std::string.
2011-11-14 09:19:46 +01:00
Richard Quirk 527236b321 Fix false positives for delete of known nulls 2011-11-13 22:38:34 +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
Edoardo Prezioso ed6a0e14c4 Add simplification of the consecutive braces before the end of 'tokenize()' function. 2011-11-12 16:59:20 +01:00
Edoardo Prezioso 5cbfbe31c1 Add removal of consecutive braces, i.e.: '{ { ... } }'->'{ ... }'.
Changed a little bit the dead code tests.
2011-11-12 12:07:10 +01:00
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