Commit Graph

9992 Commits

Author SHA1 Message Date
Daniel Marjamäki 15160f1691 Fixed #8788 (AST Broken error from assigning lambda to variable) 2018-10-22 17:25:01 +02:00
Daniel Marjamäki 749699c632 Remove FIXME 2018-10-22 12:45:34 +02:00
Daniel Marjamäki dc38681a56 Remove FIXME in AST validation. Ticket #8749 2018-10-22 11:37:24 +02:00
Daniel Marjamäki c483bcb12b Fixed testrunner 2018-10-22 00:28:09 +02:00
Daniel Marjamäki f9b132e831 Tokenizer::simplifyTypedef: Fix bug with arrays 2018-10-21 21:15:34 +02:00
Daniel Marjamäki 64fbffc90d astyle formatting
[ci skip]
2018-10-21 20:28:46 +02:00
Paul Fultz II edde0eedaa Fix FP issue 8801: Condition 'a+b' is always true (#1444) 2018-10-21 08:04:00 +02:00
Paul Fultz II 2989c44f59 Enable checking duplicate expressions across associative operators (#1445)
* Enable checking duplicate expressions across associative operators

* Remove bitshift operators and check for streamRead
2018-10-21 07:09:20 +02:00
Daniel Marjamäki 14afc3fd3a Fixed #8796 (Tokenizer::simplifyCompoundAssignment: Wrong simplification of return) 2018-10-20 21:33:43 +02:00
Daniel Marjamäki 277e0f1a8f Fix Cppcheck error message 2018-10-20 15:28:34 +02:00
Daniel Marjamäki 29feaa5a51 Tokenizer: Avoid constant folding 2018-10-20 10:51:50 +02:00
Daniel Marjamäki d265a0d6ab Fixed #8798 (SymbolDatabase: Inner unnamed union) 2018-10-20 09:43:08 +02:00
Daniel Marjamäki e2ea8bc2b0 astyle formatting
[ci skip]
2018-10-20 09:28:28 +02:00
orbitcowboy 0858488825
insecureCmdLineArgs: Fixed FN in case strdup() copies argv[]. (#1438)
* insecureCmdLineArgs: Fixed FN in case strdup() copies argv[].

* Formatted the code. There are no functional changes intended.

* Changes due to review comments from Daniel.
2018-10-19 11:04:15 +02:00
rikardfalkeborn 402d0c565f Fix false positive: Invalid string argument with array (#1439) 2018-10-19 07:48:47 +02:00
Paul Fultz II 40cb9cb1bc Check conditions in return statements (#1411)
* Identify return conditions in multiconditions

* Improve error messages

* Check return statements are always true or false

* Add more tests for FPs

* Fix FP when returning const like variables

* Fix FP when returning pointers or classes

* Fix FP with member variable access

* Check non-local variables

* Use simplematch

* Check for null
2018-10-18 21:01:47 +02:00
Daniel Marjamäki 465db2dff7 Fixed #8786 (internalAstError on valid code with C style cast) 2018-10-18 20:17:23 +02:00
Daniel Marjamäki 4983a6a5dc astyle formatting 2018-10-18 20:08:32 +02:00
Daniel Marjamäki 58b21e3071 Refactoring: Reuse Token::expressionString() logic for finding right-most leaf in tree 2018-10-18 12:09:55 +02:00
Paul Fultz II 16c62281d0 Use followVar in checking duplicateBranch (#1423)
* Use isSameExpression for duplicate branches

* Add errorPath

* Add another test
2018-10-18 11:56:23 +02:00
Paul Fultz II 58d1de5814 Expand the duplicate variable assignment warnings when the inconclusive flag is used (#1433)
* Warn for more duplicate var expressions when inconclusive is set

* Fix issue with missing function name
2018-10-17 06:57:33 +02:00
Igor 0a9be3e734 Improve STL iterators checking (#1380)
* Improve STL interators checking

* Improve error messages for container iterators from different scopes

* Mini refactoring

* Replace hardcoded pattern to ValueType::Type::ITERATOR

* Error messages improvements, more tests and refactoring

* Refactoring after code review

* Put getting operand data into separate function

* Update getErrorMessages and iterator errors ids

* Refactoring

* Fix error

* Refactoring, early return implementation

* Delete redundant code

* Tiny changes in comments
2018-10-17 06:36:51 +02:00
Daniel Marjamäki 1245a036f7 Add check for shadow variables 2018-10-16 20:17:27 +02:00
rikardfalkeborn f1074ea1ab Fix false positive: Invalid string argument with pointer to pointer (#1427)
If the address is taken inside an array, the address is not of a single
character, so do not warn about this.
2018-10-16 06:54:25 +02:00
IOBYTE 290563b964 Fix specialized template regression. (#1425)
* Fix specialized template regression.

Only check for instantiation of template being processed rather than
count of all instantiations.

* Add 2 more tests.
2018-10-15 19:35:26 +02:00
orbitcowboy a6e8270474
insecureCmdLineArgs: Fixed false negatives in case arguments are const. (#1419)
* insecureCmdLineArgs: Fixed false negatives in case arguments are const.

* Formatted the code, there are functional changes.

* Simplified matching as suggested by Daniel.
2018-10-15 10:05:43 +02:00
rikardfalkeborn 613dc19b68 #4241: Check for address of single character passed as string (#1381)
* #4241: Check for address of single character passed as string

Add a check that address of a single character is not passed as argument
to argument marked as strings (using strz). The check does not warn if
the address of a character with known value '\0'.

Since ValueFlow currently does not handle global constants (see #7597),
do not warn if the variable is global to avoid FPs when the address of
a global variable assigned to '\0' is passed to a function expecting a
string.

Remove comment in docs saying strz is unused.

* Change asdf to Hello world

* Add test of address to first element in string

* Add error reporting function to getErrorMessages

* Fix strings in test
2018-10-14 18:49:34 +02:00
IOBYTE 0a30768b59 Fixed #8693 (Template specialization: Constructor detected as normal … (#1418)
* Fixed #8693 (Template specialization: Constructor detected as normal function (functionStatic error))

Refactor template simplifier to remove the existing full specialization
function expandSpecialized and allow full specializations to use the
existing function expandTemplate.  The function expandTemplate was
modified to either expand the template like it originally did by copying
it or to modify the template in place.  Both instantiated and
uninstantiated full specializations are modified in place.  This also
fixes #8692 and probably other related tickets as well.

The function simplifyTemplates now tries twice to simplify templates so
more templates can be simplified.  We should try as many times as
necessary to find all possible templates.  We can't do that now because
uninstantiated templates are left unchanged.  It is relatively straight
forward to have the new code also expand in place uninstantiated
templates with their symbolic types but namespaces are not handled
properly (ticket #8671) and it would introduce regressions.

* Fix travis warnings.
2018-10-14 16:57:07 +02:00
Daniel Marjamäki 895772711a 1.85: Set version 2018-10-13 18:55:19 +02:00
Paul Fultz II 9cf092657c Skip some ast errors to avoid regressions (#1422)
* Skip some ast errors to avoid regressions

* Use simpleMatch

* Skip operator functions

* Add a test for issue 8788
2018-10-13 18:38:44 +02:00
Daniel Marjamäki 7833ade128 Updated copyright year 2018-10-13 18:20:31 +02:00
Daniel Marjamäki 936c627307 Fix --doc output. * must be escaped. 2018-10-11 13:59:21 +02:00
Daniel Marjamäki 7eb5ebe17e Fixed #7887 (User function 'search' is wrongly mixed with std function) 2018-10-10 17:35:53 +02:00
Daniel Marjamäki 25cbfe27cf Partial fix for #7887, Improved tokenizer simplification of 'using namespace std;' - do not simplify user functions 2018-10-10 14:28:53 +02:00
Daniel Marjamäki 053b0d1654 STL: enable inconclusive warnings with --inconclusive 2018-10-09 20:10:43 +02:00
alex babafd75e3 Added support for -U option to the GUI. 2018-10-09 15:05:05 +02:00
rikardfalkeborn 75caf8e4de Fix #8230: FP unknown evaluation order on comma expression in while clause (#1415)
The while part of a do-while loop looks almost like a function call, so
extend the check for function calls to ignore while-statements.

Note that there was only an FP when checking c-code, since the check is
disabled for c++-code. Therefore, make sure the test cases are run on a
c-file.
2018-10-09 14:44:01 +02:00
Daniel Marjamäki 20121b34d8 Fixed #7718 (False positive: out of bounds of already resized std::string) 2018-10-09 06:53:26 +02:00
Daniel Marjamäki aa58f41e6d Fixed #7152 (False positive for redundantAssignment after calling a lambda function) 2018-10-08 21:07:21 +02:00
PKEuS 86a1b84b0c Fixed handling of macros with known value defined in header file in configuration splitting (#8404)
Added proper unit test for configuration validation to ensure that it actually works when cppcheck is executed
2018-10-08 16:38:47 +02:00
orbitcowboy c312bbad78 Fixed a typo. There are no functional changes intended. 2018-10-08 13:58:21 +02:00
Daniel Marjamäki c3e6e7c338 Fixed #8664 (setVarId: Wrongly set varid for lambda argument) 2018-10-07 20:40:59 +02:00
Daniel Marjamäki f961324d45 Fixed #8735 (FP oppositeInnerCondition - regression) 2018-10-07 18:30:29 +02:00
Carlo Marcelo Arenas Belon d66c92edc3 Remove unused parameters for CheckOther::oppositeExpressionError (#1412) 2018-10-05 08:36:49 +02:00
Paul Fultz II 26a8435d76 Use knownConditionTrueFalse when is duplicate expression is true or false (#1410) 2018-10-05 06:00:24 +02:00
Paul Fultz II e170a45230 Enable followVar for opposite expressions (#1404)
Enable followVar for opposite expressions
2018-10-04 21:17:47 +02:00
orbitcowboy c98c7a2ebf suppressions: Avoid duplicate comparison. 2018-10-04 17:13:11 +02:00
Daniel Marjamäki a31db92918 Fixed #8669 (operator>> causes wrong style message) 2018-10-03 13:00:11 +02:00
Daniel Marjamäki de621eab99 Refactoring; use range for loop 2018-10-03 12:54:59 +02:00
Paul Fultz II 1fe1ec09a8 Reenable follow var for logical conjunction (#1400) 2018-10-01 14:40:03 +02:00