Commit Graph

9577 Commits

Author SHA1 Message Date
IOBYTE 36f7585798 Fixed #8600 (false-positive/regression: confusion between copy constructors of internal classes and lack of explicit keyword) (#1266) 2018-05-27 10:53:34 +02:00
orbitcowboy 1914d5e630 Running astlye 2018-05-25 08:35:37 +02:00
rebnridgway 42a65c5160 Fix crash bug #8579 (#1238)
* Added declaration for deletePrevious function

* Added definition for deletePrevious function

* Fixed crash from deleteThis invalidating pointers

The crash was caused by deleteThis() invalidating the pointer to a constant variable usage.  This happened when a usage followed an assignment.  This fixes bug #8579.

* Added tokensFront to match tokensBack

This means deletePrevious can set the list's front if necessary.

* Initialised tokensFront in appropriate places

* Switched to using default Token constructor

* Switched to using Token default constructor

* Switched to using default constructor for Token

* Added missing argument to Token constructor

* Changed to use default constructor for Tokens

* Switched to using default constructor for Tokens

* Switched to using default constructor for Token

* Added new test for deleting front Token

Also made sure to use the correct constructor for Token in other tests.

* Syntax error

* Replaced tokensFront and tokensBack with a struct

This decreases the size of the Token class for performance purposes.

* Replaced tokensFront and tokensBack with a struct

* Added tokensFrontBack to destructor

* Reworked to use TokensBackFront struct

Also ran astyle.

* Reworked to use TokenList's TokensFrontBack member

* Reworked to use TokensFrontBack struct

* Reworked to use TokensFrontBack struct

* Reworked to work with TokensFrontBack struct

* Removed unnecessary scope operator

* Added missing parentheses

* Fixed syntax error

* Removed unnecessary constructor

* Default constructor now 0-initialises everything

This is safer for not using a temporary TokensFrontBack object, and doesn't use delegating constructors which aren't supported yet.

* Fixed unsafe null check

* Added missing explicit keyword

* Fixing stylistic nits

Removed default constructor as it has been superseded by the single-argument constructor with a default argument value.
Renamed listEnds to tokensFrontBack.
Fixed if statement that was supposed to be adding safety but would actually cause a crash if tokensFrontBack was null.

* Fixing stylistic nits

Removed default constructor and replaced it with a single-argument constructor with a default value.

* Fixing stylistic nits

Renamed _listEnds to _tokensFrontBack.

* Fixing stylistic nits

Renamed _listEnds to _tokensFrontBack.
2018-05-25 07:15:05 +02:00
orbitcowboy 9bf604c46c timer.h: Improved const correctness of local variable. 2018-05-24 17:07:40 +02:00
orbitcowboy d013cb2f0d library.h: Improved const correctness of some function arguments. 2018-05-24 17:06:20 +02:00
Daniel Marjamäki 2ffbb37cee modernize cppcheck.cpp, use range for loops 2018-05-22 23:22:46 +02:00
IOBYTE fc1d62fd45 Fixed #7406 (Tokenizer::simplifyTypedef: array typedef used as template parameter) (#1257) 2018-05-22 17:31:58 +02:00
umanamente a3b02d6ece Fixed #8262: false positive memleak (`shared_ptr` in function argument) (#1249)
* Fixed #8262.
checkleakautovar.cpp:
* added `isFunctionCall` (supports template functions)
* smart pointer check in `functionCall`
* updated test case

* Renamed "bracket" to "parenthesis"

* (#8262) Fixed broken test

* (#8262) Code review comments

* (#8262) Renamed `tokOpeningBr` to `tokOpeningPar`
2018-05-22 09:08:23 +02:00
IOBYTE 8320be203d Fixed #8258 (Incorrect diagnostics when using delegating consturctor with default values) (#1255) 2018-05-22 06:42:37 +02:00
IOBYTE 5c15cd3981 Fix DACA2 SymbolDatabase bailout; unhandled code for final class (#1253)
* Fix DACA2 SymbolDatabase bailout; unhandled code for final class

* Replace Match with simpleMatch
2018-05-21 21:23:21 +02:00
Paul Fultz II 406aa6cf1c Improve support of using a lambda as a deleter (#1246)
* Improve support of using a lambda as a deleter

* Use simple match
2018-05-21 08:22:18 +02:00
IOBYTE 42ed5a6b98 Fixed #8581 (Delegating contructor warns for unintialized variables) (#1250)
* Fixed #8581 (Delegating contructor warns for unintialized variables)

* Replace Token::Match with isStandardType
2018-05-20 22:58:05 +02:00
bwoester 9b28499412 Import BCB6 projects (#1245)
* added support for reading borland c++ builder 6 projects

* add: fetch sysdefines from project
add: start providing bcb6 predefines (WIP)

* configure all the internal defines for BCB6

* make sure define strings don't start with ';'

* improvements on bwoesters BCB6 project support

- improved `*.bpr` XML handling by reducing the number of loops
- added `const` where aplicable
- optimized compiler argument parser performance
- reformatted code with provided astyle config

* - undo looping (keep it the same as the other implementations)
- keep parsing of cflags simple and separate from the synonym cleanup (no need for micro optimization in this place)
- move input validation to FileSettings::setDefines
- re-run astyle

* use [] instead of at() when comparing characters
2018-05-20 18:19:20 +02:00
Daniel Marjamäki 2b14b71c93 Updated output when Cppcheck fails to find valid configurations 2018-05-17 10:27:05 +02:00
amai2012 7062df5d78 #8585 --check-config aborts due to unhandled simplecpp::Output exception 2018-05-17 08:59:10 +02:00
Matthias Krüger 2320034f4a fix -Winconsistent-missing-override warnings reported by clang 6.0. 2018-05-17 08:47:19 +02:00
Alexander Mai fe1b1d537e Fix compiler warning by useless semicolon 2018-05-16 21:33:26 +02:00
IOBYTE d567b878ba Fix template instantialion failure for qualified template type. (#1237) 2018-05-16 15:24:23 +02:00
IOBYTE ce50df8047 Fix override warnings. (#1234) 2018-05-15 16:37:40 +02:00
Daniel Marjamäki 6bd4bdb0f9 Updated 'noValidConfiguration' message. It should not write this message when there is no code. It should be possible to see the preprocessor errors otherwise it is hard to fix the configuration. 2018-05-15 15:42:54 +02:00
Daniel Marjamäki f7746e4fb6 Revert "Missing override specifier warning on a pure virtual function makes no sense. (#1230)"
This reverts commit 348eb1c5c9.
2018-05-15 10:48:34 +02:00
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
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
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
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
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
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
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
Daniel Marjamäki 7b6ddc50ae astyle formatting
[ci skip]
2018-05-10 17:57:16 +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
Daniel Marjamäki 129bdb2752 SymbolDatabase::createSymbolDatabaseSetTypePointers: Optimize ~90% 2018-05-09 13:48:55 +02:00