cppcheck/lib
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
..
CMakeLists.txt
analyzerinfo.cpp Refactorization: pass std::string directly to std::*fstream 2018-04-11 09:50:42 +02:00
analyzerinfo.h Updated copyright year 2018-01-14 15:37:52 +01:00
astutils.cpp astyle formatting 2018-05-11 14:49:31 +02:00
astutils.h Improve checking of opposite expressions (#1199) 2018-05-02 06:32:33 +02:00
check.cpp Updated copyright year 2018-01-14 15:37:52 +01:00
check.h CLI: Added more fields for --template and added a new --template-location. The gcc predefined template now matches latest gcc better. 2018-04-23 12:21:18 +02:00
check64bit.cpp Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +02:00
check64bit.h Updated copyright year 2018-01-14 15:37:52 +01:00
checkassert.cpp Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +02:00
checkassert.h Updated copyright year 2018-01-14 15:37:52 +01:00
checkautovariables.cpp Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +02:00
checkautovariables.h Updated copyright year 2018-03-31 20:59:09 +02:00
checkbool.cpp Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +02:00
checkbool.h Updated copyright year 2018-01-14 15:37:52 +01:00
checkboost.cpp Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +02:00
checkboost.h Updated copyright year 2018-01-14 15:37:52 +01:00
checkbufferoverrun.cpp SymbolDatabase: Refactor SymbolDatabase: variable list 2018-04-28 09:38:33 +02:00
checkbufferoverrun.h Updated copyright year 2018-01-14 15:37:52 +01:00
checkclass.cpp Fixed crashes in daca 2018-05-06 09:52:04 +02:00
checkclass.h Fixed #8542 (False positive: noOperatorEq) 2018-05-05 07:46:58 +02:00
checkcondition.cpp Fix false positive with inner conditions when using pointers (#1195) 2018-04-28 18:56:13 +02:00
checkcondition.h Add a check for identical inner conditions (#1156) 2018-04-08 08:13:44 +02:00
checkexceptionsafety.cpp Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +02:00
checkexceptionsafety.h Replaced make_container by C++11 initializer lists 2018-04-08 23:03:44 +02:00
checkfunctions.cpp Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +02:00
checkfunctions.h Updated copyright year 2018-01-14 15:37:52 +01:00
checkinternal.cpp Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +02:00
checkinternal.h chmod 644 checkinternal.* 2018-04-14 19:45:42 +02:00
checkio.cpp SymbolDatabase: Refactor SymbolDatabase: variable list 2018-04-28 09:38:33 +02:00
checkio.h Updated copyright year 2018-01-14 15:37:52 +01:00
checkleakautovar.cpp astyle formatting 2018-05-06 09:50:53 +02:00
checkleakautovar.h astyle formatting 2018-04-16 12:55:37 +02:00
checkmemoryleak.cpp SymbolDatabase: Refactor SymbolDatabase: variable list 2018-04-28 09:38:33 +02:00
checkmemoryleak.h Improve constness 2018-04-04 21:51:31 +02:00
checknullpointer.cpp astyle formatting 2018-05-10 17:57:16 +02:00
checknullpointer.h Remove whole program analysis from 'uninitialized variables' and 'null pointer dereference' checkers. I think this logic can more or less be added in ValueFlow instead and then all ValueFlow checkers should get whole program analysis. 2018-02-06 14:56:17 +01:00
checkother.cpp Don't remove the volatile keyword so we can properly overload functions. (#1218) 2018-05-10 07:40:01 +02:00
checkother.h Report opposite expressions (#1182) 2018-04-21 11:28:21 +02:00
checkpostfixoperator.cpp Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +02:00
checkpostfixoperator.h Updated copyright year 2018-03-31 20:59:09 +02:00
checksizeof.cpp Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +02:00
checksizeof.h Updated copyright year 2018-03-31 20:59:09 +02:00
checkstl.cpp SymbolDatabase: Refactor SymbolDatabase: variable list 2018-04-28 09:38:33 +02:00
checkstl.h Updated copyright year 2018-01-14 15:37:52 +01:00
checkstring.cpp Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +02:00
checkstring.h Updated copyright year 2018-03-31 20:59:09 +02:00
checktype.cpp Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +02:00
checktype.h Updated copyright year 2018-01-14 15:37:52 +01:00
checkuninitvar.cpp Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +02:00
checkuninitvar.h Updated copyright year 2018-03-31 20:59:09 +02:00
checkunusedfunctions.cpp checkunusedfunctions.cpp: Fix files.txt parsing (#1197) 2018-05-01 08:09:11 +02:00
checkunusedfunctions.h Fix testrunner in cygwin 2018-02-10 15:34:49 +01:00
checkunusedvar.cpp SymbolDatabase: Refactor SymbolDatabase: variable list 2018-04-28 09:38:33 +02:00
checkunusedvar.h Updated copyright year 2018-01-14 15:37:52 +01:00
checkvaarg.cpp SymbolDatabase: Refactor SymbolDatabase: variable list 2018-04-28 09:38:33 +02:00
checkvaarg.h Updated copyright year 2018-01-14 15:37:52 +01:00
config.h
cppcheck.cpp Fixed #8515 (Wrong info message about unmatched suppression) 2018-05-11 09:01:24 +02:00
cppcheck.h Rename CppCheck::processFile to CppCheck::checkFile 2018-04-21 13:28:26 +02:00
cppcheck.natvis
cppcheck.vcxproj Copy platforms/ directory to bin/ 2018-02-27 09:09:12 +01:00
cppcheck.vcxproj.filters
errorlogger.cpp errorlogger: fix handling of {inconclusive} 2018-04-24 11:10:41 +02:00
errorlogger.h CLI: Added more fields for --template and added a new --template-location. The gcc predefined template now matches latest gcc better. 2018-04-23 12:21:18 +02:00
importproject.cpp Refactorizations: 2018-04-11 09:44:35 +02:00
importproject.h Updated copyright year 2018-01-14 15:37:52 +01:00
lib.pri
library.cpp Check for double frees when using smart pointers (#1172) 2018-04-16 11:11:13 +02:00
library.h Improve constness 2018-04-04 21:51:31 +02:00
matchcompiler.h
mathlib.cpp Improve constness 2018-04-04 21:51:31 +02:00
mathlib.h Updated copyright year 2018-01-14 15:37:52 +01:00
path.cpp Refactor Path::getRelativePath() 2018-04-18 22:23:38 +02:00
path.h Updated copyright year 2018-01-14 15:37:52 +01:00
pathmatch.cpp Updated copyright year 2018-01-14 15:37:52 +01:00
pathmatch.h Updated copyright year 2018-01-14 15:37:52 +01:00
pcrerules.pri
platform.cpp Updated copyright year 2018-03-31 20:59:09 +02:00
platform.h Updated copyright year 2018-03-31 20:59:09 +02:00
preprocessor.cpp Escaped filename, which can contain invalid xml (#1192) 2018-04-25 18:28:04 +02:00
preprocessor.h Updated copyright year 2018-01-14 15:37:52 +01:00
settings.cpp Updated copyright year 2018-01-14 15:37:52 +01:00
settings.h CLI: Added more fields for --template and added a new --template-location. The gcc predefined template now matches latest gcc better. 2018-04-23 12:21:18 +02:00
standards.h Updated copyright year 2018-01-14 15:37:52 +01:00
suppressions.cpp Fixed #8515 (Wrong info message about unmatched suppression) 2018-05-11 09:01:24 +02:00
suppressions.h Fixed #8515 (Wrong info message about unmatched suppression) 2018-05-11 09:01:24 +02:00
symboldatabase.cpp Don't remove the volatile keyword so we can properly overload functions. (#1218) 2018-05-10 07:40:01 +02:00
symboldatabase.h Don't remove the volatile keyword so we can properly overload functions. (#1218) 2018-05-10 07:40:01 +02:00
templatesimplifier.cpp Optimize usage of TemplateSimplifier::simplifyCalculations 2018-05-11 14:48:59 +02:00
templatesimplifier.h Optimize usage of TemplateSimplifier::simplifyCalculations 2018-05-11 14:48:59 +02:00
timer.cpp Improve constness 2018-04-04 21:51:31 +02:00
timer.h Updated copyright year 2018-01-14 15:37:52 +01:00
token.cpp Save bitfield bit counts 2018-05-02 20:55:11 +02:00
token.h Save bitfield bit counts 2018-05-02 20:55:11 +02:00
tokenize.cpp Optimised simplifyKnownVariables (#1205) 2018-05-11 21:14:04 +02:00
tokenize.h Add support for namespace aliases and C++17 nested namespaces. (#1210) 2018-05-08 06:35:51 +02:00
tokenlist.cpp TokenList::validateAst: optimised ~25% 2018-05-09 12:36:58 +02:00
tokenlist.h Updated copyright year 2018-01-14 15:37:52 +01:00
utils.h Replaced make_container by C++11 initializer lists 2018-04-08 23:03:44 +02:00
valueflow.cpp Fix comment 2018-05-07 22:06:23 +02:00
valueflow.h Updated copyright year 2018-01-14 15:37:52 +01:00
version.h Set version to 1.83.99/1.84 dev 2018-04-02 15:21:37 +02:00
version.rc