cppcheck/lib
rebnridgway 0d7836f3a0 Calculate token scopes in advance rather than as the tokenlist is iterated (#1882)
* Added scopeinfo member to token class

Moved ScopeInfo2 declaration here as well because that's where it needs to be now.

* Added scopeinfo accessors and declaration to class

* Add new method for calculating scopes

This replaces the methods in the TemplateSimplifier which calculate the current scope as the token list is iterated.  The old method required checking if the scope had changed for every token multiple times (for multiple iterations), which was surprisingly costly.  Calculating scopes in advance like this decreases runtime on a worst-case file by around thirty percent.
ScopeInfo objects are disposed of when the TemplateSimplification is done as they are not used later.

* Add calculateScopes method to header

* Removed code that calculated current scope

This has been replaced by code that calculates the scopes up front and stores them with each token, which is much faster.

* Fixed compile errors from extra parentheses

* Added missing code to fix memory leak

* Added code to actually clean up ScopeInfo structs

* Tidy up a dodgy for loop

* Convert argument to const ref

* Calculate missing scopes

As the templatesimplificator expands templates and does multiple passes it needs to make sure all scopes are calculated.

* Remove copying the scope to the next token

This is now done properly when scopes are calculated.

* Remove call to calculateScopes

This is now done by the TemplateSimplifier.

* Recalculate scopes for every pass of simplifyTemplates

* Add code to calculate extra scopes as they are added

I thought that this might be useful for calculating scopes when Tokens are created, but as there are several ways of creating Tokens that don't guarantee that they are placed in a list it is easier to just calculate scopes when you know you have a list and when you know you're adding to a list.

* Fix several bugs and poorly designed code

Remove the global scopes collection, and clean them up instead by iterating through the tokenlist to find them.  This means scopes can be calculated by functions in the Token class as well as in the Tokenizer class without leaking the scope object.
Fix a couple of bugs in the calculateScopes method and make it more efficient.

* Remove unnecessary calls to calculateScopes

* Move brace to correct position

Calculating scopes during insertToken only needs to happen if we created a new Token.

* Handle 'using namespace' declarations separately

This fixes a bug caused by a statement matching 'struct B < 0 > ;'

* Fix argument name mismatch

* Actually use newScopeInfo when inserting Token

* Switch to using shared_ptr to hold scopeInfos

This means ScopeInfo2 objects get properly cleaned up when they are no longer needed.

* Change ScopeInfo member to be a shared_ptr

* Update code to use shared_ptr

* Add missing include for shared_ptr

* Remove unnecessary cleanup code

This has been replaced by shared_ptr for ScopeInfo2 objects
2019-06-29 14:34:22 +02:00
..
CMakeLists.txt CMake: Find header in externals, e.g. externals/picojson.h 2019-04-22 18:52:02 +02:00
analyzerinfo.cpp Update Copyright 2019-06-29 07:49:14 +02:00
analyzerinfo.h Updated copyright year 2018-10-13 18:20:31 +02:00
astutils.cpp Token::index(): Created Token member that indicates the Token position in the token list. It can be used to quickly check if tok1 precedes tok2. 2019-06-21 22:16:23 +02:00
astutils.h Fixed Cppcheck warning 2019-06-29 07:46:25 +02:00
check.cpp Updated copyright year 2018-10-13 18:20:31 +02:00
check.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
check64bit.cpp Rename _tokenizer, _settings, _errorLogger 2018-06-16 16:10:28 +02:00
check64bit.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkassert.cpp Update copyright year 2019-02-09 07:24:06 +01:00
checkassert.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkautovariables.cpp Fix FP with non-local variable referencing a non-local variable (#1864) 2019-06-02 10:21:26 +02:00
checkautovariables.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkbool.cpp Update Copyright 2019-06-29 07:49:14 +02:00
checkbool.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkboost.cpp Rename _tokenizer, _settings, _errorLogger 2018-06-16 16:10:28 +02:00
checkboost.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkbufferoverrun.cpp Fix issue 6821: New check: access heap/stack data using address of variable 2019-05-31 12:24:31 +02:00
checkbufferoverrun.h Fix Cppcheck warnings 2019-06-15 13:01:45 +02:00
checkclass.cpp Tweak bailout so it's only used in unused template classes 2019-06-20 14:00:44 +02:00
checkclass.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkcondition.cpp Revert "Fixed #8938 (FP identicalInnerCondition)" 2019-06-22 21:57:19 +02:00
checkcondition.h astyle formatting 2019-04-18 20:21:00 +02:00
checkexceptionsafety.cpp Refactoring; Use range for loops 2018-07-14 09:49:03 +02:00
checkexceptionsafety.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkfunctions.cpp Update Copyright 2019-06-29 07:49:14 +02:00
checkfunctions.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkinternal.cpp CheckInternal: Extend redundant null pointer check before Token::Match() (#1789) 2019-04-06 07:44:44 +02:00
checkinternal.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkio.cpp Set wchar_t type (#1807) 2019-05-01 16:34:28 +02:00
checkio.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkleakautovar.cpp CheckLeakAutoVar: Fixed FP seen in daca@home 2019-06-02 15:25:54 +02:00
checkleakautovar.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkmemoryleak.cpp Fixed #8848 (False positive memory leak if locally defined type returns a new pointer) 2019-04-22 17:37:41 +02:00
checkmemoryleak.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checknullpointer.cpp Improve diagnostics with null smart pointers (#1805) 2019-04-26 11:30:09 +02:00
checknullpointer.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkother.cpp Try to improve 'clarifyStatement' warning message 2019-06-22 08:44:41 +02:00
checkother.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkpostfixoperator.cpp Refactoring: Use ranged for loop 2018-07-13 16:50:12 +02:00
checkpostfixoperator.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checksizeof.cpp Update Copyright 2019-06-29 07:49:14 +02:00
checksizeof.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkstl.cpp CheckStl: Modernize the recommendations. string::starts_with is more intuitive than string::compare 2019-05-05 10:35:44 +02:00
checkstl.h Fix Cppcheck warnings 2019-06-15 13:05:17 +02:00
checkstring.cpp Update Copyright 2019-06-29 07:49:14 +02:00
checkstring.h Checkstring fixes (#1783) 2019-04-06 06:54:38 +02:00
checktype.cpp Set wchar_t type (#1807) 2019-05-01 16:34:28 +02:00
checktype.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkuninitvar.cpp uninitStructMember: Fixed FP shown in daca@home 2019-06-02 20:19:53 +02:00
checkuninitvar.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkunusedfunctions.cpp Fixed #8580 (False positive: unused function (lambda)) 2019-04-27 17:17:51 +02:00
checkunusedfunctions.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkunusedvar.cpp Unused struct member: Fix FPs seen in daca@home results for template structs 2019-03-06 20:51:48 +01:00
checkunusedvar.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkvaarg.cpp Update copyright year 2019-02-09 07:24:06 +01:00
checkvaarg.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
config.h sync (#1835) 2019-05-17 09:31:41 +02:00
cppcheck.cpp Fixed Cppcheck warning; ::AddonInfo::getFullPath can be static 2019-06-29 07:59:55 +02:00
cppcheck.h test/cli: execute addon 2019-04-14 15:00:03 +02:00
cppcheck.natvis Fixed Visual Studio Natvis file after recent refactoring (#1299) 2018-07-09 08:27:26 +02:00
cppcheck.vcxproj Add ctu sources to VS projects 2018-12-27 22:11:40 +01:00
cppcheck.vcxproj.filters Add ctu sources to VS projects 2018-12-27 22:11:40 +01:00
ctu.cpp Fix Cppcheck warnings 2019-06-15 13:28:01 +02:00
ctu.h CheckBufferOverrun: Add CTU analysis 2019-03-23 08:36:10 +01:00
errorlogger.cpp Add missing line feed to the generated plist output (#1792) 2019-04-08 18:09:18 +02:00
errorlogger.h Update copyright year 2019-02-09 07:24:06 +01:00
importproject.cpp --addon: Use json for addon output 2019-06-24 19:29:43 +02:00
importproject.h analyzing one vs config (first debug config that matches platform) 2019-04-13 20:01:40 +02:00
lib.pri CTU: Refactoring 2018-12-25 21:11:23 +01:00
library.cpp Add check for unnecessary search before insertion 2019-05-02 11:04:23 +02:00
library.h Update Copyright 2019-06-29 07:49:14 +02:00
matchcompiler.h
mathlib.cpp Running astyle [ci skip] 2019-05-28 08:49:59 +02:00
mathlib.h Update copyright year 2019-02-09 07:24:06 +01:00
path.cpp Fixed #error in self check when __CPPCHECK__ is defined 2019-04-30 20:31:46 +02:00
path.h Update copyright year 2019-02-09 07:24:06 +01:00
pathmatch.cpp Updated copyright year 2018-10-13 18:20:31 +02:00
pathmatch.h Updated copyright year 2018-10-13 18:20:31 +02:00
pcrerules.pri
platform.cpp Updated copyright year 2018-03-31 20:59:09 +02:00
platform.h Fix Cppcheck error message 2018-10-20 15:28:34 +02:00
preprocessor.cpp Add missing include 2019-05-09 06:55:36 +02:00
preprocessor.h Renamed private member file0 2018-06-17 09:06:16 +02:00
settings.cpp Only check unused templates if that is configured 2019-05-05 14:40:30 +02:00
settings.h test/cli: execute addon 2019-04-14 15:00:03 +02:00
standards.h Update Copyright 2019-06-29 07:49:14 +02:00
suppressions.cpp Fix Cppcheck warning: Suppressions::dump can be const 2019-06-29 07:53:32 +02:00
suppressions.h Fix Cppcheck warning: Suppressions::dump can be const 2019-06-29 07:53:32 +02:00
symboldatabase.cpp Fixed #8663 (Stack overflow with template disambiguator) (#1932) 2019-06-28 22:07:21 +02:00
symboldatabase.h Add check for unnecessary search before insertion 2019-05-02 11:04:23 +02:00
templatesimplifier.cpp Calculate token scopes in advance rather than as the tokenlist is iterated (#1882) 2019-06-29 14:34:22 +02:00
templatesimplifier.h template simplifier: various small fixes (#1916) 2019-06-28 11:14:20 +02:00
timer.cpp Rename private member variables 2018-06-17 17:20:16 +02:00
timer.h Update copyright year 2019-02-09 07:24:06 +01:00
token.cpp Calculate token scopes in advance rather than as the tokenlist is iterated (#1882) 2019-06-29 14:34:22 +02:00
token.h Calculate token scopes in advance rather than as the tokenlist is iterated (#1882) 2019-06-29 14:34:22 +02:00
tokenize.cpp Calculate token scopes in advance rather than as the tokenlist is iterated (#1882) 2019-06-29 14:34:22 +02:00
tokenize.h Calculate token scopes in advance rather than as the tokenlist is iterated (#1882) 2019-06-29 14:34:22 +02:00
tokenlist.cpp Cleanup some const_cast of Token* (#1886) 2019-06-16 10:09:38 +02:00
tokenlist.h Update Copyright 2019-06-29 07:49:14 +02:00
utils.h Revert "Refactoring endsWith utility function" 2018-07-25 16:14:43 +02:00
valueflow.cpp Valueflow: support global static const variables (#1861) 2019-06-29 14:33:55 +02:00
valueflow.h Cleanup some const_cast of Token* (#1886) 2019-06-16 10:09:38 +02:00
version.h Set version 1.88 2019-06-29 08:38:13 +02:00
version.rc