Commit Graph

18014 Commits

Author SHA1 Message Date
IOBYTE 348eb1c5c9 Missing override specifier warning on a pure virtual function makes no sense. (#1230)
This fixes a large number of false positives for cppcheck source code.
2018-05-14 23:08:40 +02:00
Daniel Marjamäki d8622ea5f8 simplifyCalculations: Removed redundant goback variable 2018-05-14 23:06:10 +02:00
Daniel Marjamäki 29dc42ff67 Removed unreachable code 2018-05-14 22:50:30 +02:00
Daniel Marjamäki 66599b4ade astyle formatting
[ci skip]
2018-05-14 22:48:37 +02:00
PKEuS e8bc955023 Optimized Tokenizer::simplifyFunctionReturn(): Replaced nested loops by two consecutive loops; execute second one only if necessary. 2018-05-14 20:51:09 +02:00
PKEuS 20b2574da8 Fixed false positive unusedPrivateFunction caused by recent commit 2018-05-14 16:20:46 +02:00
PKEuS 0090ae5cf2 Optimization in CheckUninitVar::checkStruct(): Replaced expensive inner loop on all scopes by loop on child scopes for faster lookup for inner unions.
This speeds up checking of very large code files; for example, it reduces checking time for SQLite amalgamation by more than 20%
2018-05-14 15:48:57 +02:00
PKEuS c4b6beac4d Fixed calculation precedence warning introduced in recent commit 2018-05-14 15:24:32 +02:00
Matthias Krüger 4c8bb9ac6f fix a few typos 2018-05-14 13:11:59 +02:00
Swasti Shrivastava 4b873ed573 Rule 5.3 modified along with test suite (#1227)
* Added rule 5.2

* updated 5.2

request-checks: true

* Added rule 5.3

* Changed rule 5.4, 5.5

* Updated test suite for Rule 5.2

* Changes in Rule 5.4 and 5.5

* Change in function name in test suite and removed type from class token in cppcheck

* Changed the name of function in misra-test.c

* Modified rule 5.3

* Modified misra-test.c for rule 5.3
2018-05-14 13:09:38 +02:00
umanamente d2d1bf900b (#8262) Added TODO test for "False positive: memory leak with shared_ptr stored in container" (#1228) 2018-05-14 13:08:33 +02:00
PKEuS 3d860e6f36 Bump simplecpp 2018-05-14 13:00:22 +02:00
PKEuS 090a178ed6 Refactorization in SymbolDatabase: Do not redundantly store name in FriendInfo, and store FriendInfo in vector instead of list 2018-05-14 12:18:59 +02:00
PKEuS 4d549553b0 Small optimization in checkmemoryleak.cpp: Allow passing literals to addtoken()
Ran AStyle
2018-05-14 10:15:50 +02:00
Paul Fultz II 7ef714b0c6 Fix FP with duplicate assignments by checking if the expression is unique (#1223)
* Fix FP with duplicate assignments by checking if the expression is unique

* Use array of pointers

* Reorder scope condition
2018-05-13 20:20:55 +02:00
IOBYTE 5c06d08bfb Fix many DACA2 SymbolDatabase bailout; unhandled code false positives (#1225) 2018-05-13 19:00:42 +02:00
Matthias Krüger 9949768d7c travis: install wx-common which is used in test/cfg/runtests.sh 2018-05-13 12:32:19 +02:00
Matthias Krüger 547934b5a5 travis: use $CPPCHECK global containing absolute path to cppcheck executable 2018-05-13 12:32:14 +02:00
PKEuS 513cdc144c Optimization: Save up to 2 of 3 token list iterations in Tokenizer::simplifyKeyword() 2018-05-13 10:12:50 +02:00
IOBYTE 9ee6068e20 Remove duplicate namespace aliases so they don't produce syntax errors. (#1222)
* Remove duplicate namespace aliases so they don't produce syntax errors.

DACA2 results showed new SymbolDatabase syntax errors when duplicate
namespace aliases were simplified improperly. The solution is to remove
them in the tokenizer when found.

* Add tests for deleting namespace aliases at end of token list.

* Use eraseTokens to delete multiple tokens at once.
2018-05-13 08:29:40 +02:00
PKEuS 723bacbf09 Fixed hang introduced in previous commit and further optimized Tokenizer::simplifyStaticConst(): Avoid redundant Token swapping 2018-05-12 21:35:54 +02:00
PKEuS a16e99c710 Optimization: Save 2 of 3 token list iterations in Tokenizer::simplifyStaticConst() 2018-05-12 19:19:48 +02:00
Simon Martin 16e1e1d8f9 Ticket #8550: Properly simplify "typedef class A B;". (#1224) 2018-05-12 10:20:33 +02:00
Matthias Krüger d4fa8c6e95 travis: remove redundant suppressions 2018-05-12 03:20:23 +02:00
Matthias Krüger 1a1bb10511 travis: add misra tests to ci 2018-05-12 00:50:05 +02:00
Daniel Marjamäki 98e3f373e9 Revert "Optimize usage of TemplateSimplifier::simplifyCalculations"
This reverts commit 3044612fe9.

I got a report about a significant slowdown for a code.
2018-05-11 21:26:28 +02:00
Daniel Marjamäki a3f1d28fa5 astyle formatting
[ci skip]
2018-05-11 21:25:41 +02:00
rebnridgway cf6e72b150 Optimised simplifyKnownVariables (#1205)
* Optimised simplifyKnownVariables

Changed the check for references to constant variables so instead of iterating through all tokens looking for references (which is very slow for large files), usages of each known variable are recorded so each usage can be checked for whether or not it is a reference.  Just checking known usages is a lot quicker than checking through all tokens.

* Fixed test error caused by incorrect code

* Fixes to constant variable simplification optimisation

Indexing variables by varId is easier than by Token pointer, but means we also have to store a reference to the constant variable Token in another collection.
Switched to using unordered_map over map as it has slightly better find performance.

* Fixed incorrect simplification behaviour

This should remove constant variables correctly and efficiently.  Requires additional functions, Token::deleteThisInPlace() and TokenList::front(Token*).

* Added setter for TokenList::first

This allows code that adds and removes Tokens from the list to do so without copying nodes into other nodes, which sometimes create difficulties.

* Added deleteThisInPlace function

This allows a token to delete itself without invalidating pointers to the node after it.  If this token is the first or last in a list the calling code will have to remember to change the list's front or back.

* Added declaration for deleteThisInPlace()

* Removed premature MatchCompiler optimisation

* Added and removed some functions

Added declaration for deleteToken(Token*) which deletes a single token from the list
Removed public front(Token*) because it broke encapsulation

* Implemented deleteToken(Token*) function

* Removed 'delete this' from deleteThisInPlace

* Switched to using safer function

TokenList::deleteToken is better than calling straight into Token::deleteThisInPlace because it doesn't call delete this and doesn't break the TokenList's encapsulation.

* Replace constant variables in reverse order

This fixes the problem where you have two constant value assignment statements in a row.  Replacing and deleting them in reverse order means we avoid the problem of deleteThis() potentially invalidating the pointer to the start of the next assignment statement

* Removed unneeded and unsafe deleteThisInPlace

* Removed unneeded and unsafe deleteThisInPlace

* Removed unneeded deleteToken

* Removed unneeded deleteToken

* Removed extra whitespace
2018-05-11 21:14:04 +02:00
swasti16 4956b89506 Changes in misra c rule 5.4 and 5.5 (#1219)
* Added rule 5.2

* updated 5.2

request-checks: true

* Added rule 5.3

* Changed rule 5.4, 5.5

* Updated test suite for Rule 5.2

* Changes in Rule 5.4 and 5.5

* Change in function name in test suite and removed type from class token in cppcheck

* Changed the name of function in misra-test.c
2018-05-11 14:57:08 +02:00
Daniel Marjamäki ce30a3ca71 astyle formatting
[ci skip]
2018-05-11 14:49:31 +02:00
Daniel Marjamäki 3044612fe9 Optimize usage of TemplateSimplifier::simplifyCalculations 2018-05-11 14:48:59 +02:00
Daniel Marjamäki 307f992c2c benchmarks.txt: suggest that cryptopp is used (c++ code with plenty of templates) 2018-05-11 13:43:52 +02:00
Daniel Marjamäki b0077a75c3 Added benchmarks.txt 2018-05-11 12:35:59 +02:00
Paul Fultz II c520735009 Improve checking of size condition against empty to avoid FPs (#1213)
* Improve checking of size condition against empty to avoid FPs

* Add const and todo for reverse conditions
2018-05-11 10:22:06 +02:00
Daniel Marjamäki 1e7c1841f7 Fixed #8515 (Wrong info message about unmatched suppression) 2018-05-11 09:01:24 +02:00
IOBYTE 9d30496ea1 Extend symbol database test for const volatile member function. (#1220) 2018-05-11 08:15:46 +02:00
Daniel Marjamäki 7b6ddc50ae astyle formatting
[ci skip]
2018-05-10 17:57:16 +02:00
Matthias Krüger 73a9f05a73 travis: update commits of the clang/llvm repo we are checking during CI
I had to reduce cppchecks stdout amount a bit and suppress unreadVariable warnings to not hit the 4MB log file limit on travis while checking llvm/clang.
2018-05-10 14:46:09 +02:00
Matthias Krüger cc74d64c1e run dmake 2018-05-10 12:28:03 +02:00
IOBYTE 184537884f Don't remove the volatile keyword so we can properly overload functions. (#1218)
* Don't remove the volatile keyword so we can properly overload functions.

I fixed all the checks that had tests that use volatile.  There will
probably be more changes needed due to lack of test coverage for
volatile in some checks.

* Fix unused private function warning.
2018-05-10 07:40:01 +02:00
IOBYTE 5452c4dc4a Fixed #8560 (Symboldatabase lacks entry for C++11 overloaded member function) (#1217) 2018-05-09 20:16:08 +02:00
Sebastian 50aa3620da
posix.cfg: Add minsize to readlink[at] function configurations (#1216) 2018-05-09 18:20:45 +02:00
orbitcowboy c39e3467a4 misra.py: Rule 21.8, added missing exit() function. 2018-05-09 16:48:49 +02:00
orbitcowboy bcae3ce9d4 misra.py: State that Cppcheck already covers rule 22.4 with error-id: 'writeReadOnlyFile'. 2018-05-09 13:51:14 +02:00
Daniel Marjamäki 129bdb2752 SymbolDatabase::createSymbolDatabaseSetTypePointers: Optimize ~90% 2018-05-09 13:48:55 +02:00
Daniel Marjamäki ab6167e3e6 TokenList::validateAst: optimised ~25% 2018-05-09 12:36:58 +02:00
Daniel Marjamäki ecccce0608 Tokenizer::setVarId: Made it ~5% faster 2018-05-09 10:25:29 +02:00
Paul Fultz II 0197343e0c Fix false positive when using null arithmetic with class type (#1214) 2018-05-09 09:06:49 +02:00
Paul Fultz II f5dbfce8ff Fix false positive with oppositeExpression when using binary op (#1211)
* Fix false positive with oppositeExpression when using binary op

* Simplify conditional
2018-05-08 20:43:57 +02:00
swasti16 d934065d21 Added rule 5.2 (#1212)
* Added rule 5.2

* updated 5.2

request-checks: true

* Updated test suite for Rule 5.2
2018-05-08 20:41:45 +02:00