IOBYTE
d88ee2d6a2
Fixed #9070 (Segmentation fault in TemplateSimplifier::simplifyTemplateAliases (scram package)) ( #1771 )
...
This only fixes the crash. It does not fix the underlying problem of
template using with templates of templates causing the use of deleted
instantiations.
2019-03-30 06:53:17 +01:00
IOBYTE
5b72e1f568
Fixed #9040 (Type alias 'BOOL' declared with 'using' keyword breaks type detection) ( #1759 )
...
Moved simplifyUsing from TemplateSimplifier to Tokenizer.
2019-03-26 07:09:56 +01:00
IOBYTE
10fcf731d9
Fixed #9021 (template simplifier: crash in simplifyCalculations) ( #1757 )
2019-03-25 14:56:51 +01:00
Pavol Misik
7c7ee66cf9
Fix crash in TemplateSimplifier::TokenAndName::TokenAndName in case of template constexpr ( #1748 )
...
This is not propper solution. This change just eliminates crash and logs error.
https://trac.cppcheck.net/ticket/9046
2019-03-23 10:42:41 +01:00
IOBYTE
40d7d5a3d0
template simplifier: fix return type of out of line member function when it is a template parameter ( #1723 )
2019-03-03 19:42:46 +01:00
IOBYTE
b222953bae
template simplifier: only constant fold template instantiation arguments ( #1721 )
...
* template simplifier: only constant fold template instantiation arguments
* Fix travis build.
2019-03-03 07:40:55 +01:00
IOBYTE
b78b3c6ab1
Fixed #9005 (Syntax error on valid C++) ( #1716 )
2019-03-01 08:18:53 +01:00
IOBYTE
98bf112352
template simplifier: fix recursive variable templates ( #1711 )
2019-02-28 08:30:04 +01:00
IOBYTE
bf85767829
template simplifier: make sure all instantiations are found and expan… ( #1696 )
...
* template simplifier: make sure all instantiations are found and expanded in #5097
* template simplifier: check output on another test
* template simplifier: add output to another test
2019-02-26 06:41:04 +01:00
IOBYTE
3f257d6310
template simplifier: instantiate template class when something inside… ( #1695 )
...
* template simplifier: instantiate template class when something inside class instantiated.
* template simplifier: add output to another test that now works
2019-02-25 21:01:34 +01:00
IOBYTE
8bd5b3eccf
Fixed #8962 ("(debug) Unknown type 'T'" with template typename parame… ( #1671 )
...
* Fixed #8962 ("(debug) Unknown type 'T'" with template typename parameter)
Only simple one parameter template functions with one function parameter
are supported.
* Added TODO test case for FIXME.
2019-02-14 11:48:59 +01:00
IOBYTE
9dc5dbe1ab
Fixed #8976 (Crash on `using mystring = std::string;`) ( #1663 )
...
* Fixed #8976 (Crash on `using mystring = std::string;`)
* templateSimplifier: move test case to correct file.
2019-02-12 09:39:01 +01:00
IOBYTE
9490d0db8c
token simplifier: fix crashes related to #8972 ( #1659 )
2019-02-11 07:45:03 +01:00
IOBYTE
155e4ce912
Fixed #8971 ("(debug) Unknown type 'x'." using alias in class members) ( #1653 )
...
* Fixed #8971 ("(debug) Unknown type 'x'." using alias in class members)
* template simplifier: partial fix for #8972
Add support for multi-token default template parameters.
* template simplifier: fix for #8971
Remove typename outside of templates.
2019-02-09 08:34:59 +01:00
Daniel Marjamäki
bd7790fd8c
Update copyright year
2019-02-09 07:24:06 +01:00
IOBYTE
1faae52d06
Fixed #8960 ("(debug) Unknown type 'x'." with alias in template class alias) ( #1643 )
...
* Fixed #8960 ("(debug) Unknown type 'x'." with alias in template class alias)
This commit adds non-template type alias support to the template
simplifier. Only relatively simple type aliases are supported at this
time. More complex types will be added later.
--debug-warnings will show unsupported type aliases.
Type alias support will be removed from the symbol database in the
future. Type alias tests have been removed from the symbol database
tests.
* Add the changes.
* Fix codacy warning.
* Fix travis warnings.
2019-02-05 08:52:23 +01:00
IOBYTE
d08aa666f6
template simplifier: fix crash on windows ( #1639 )
...
* template simplifier: fix crash on windows
Use right token when searching for template type alias to delete.
* template simplifier: fix a cppcheck warning
2019-02-01 06:59:49 +01:00
IOBYTE
98fc6d1d32
Fixed #8959 ("(debug) Unknown type 'x'" with using/alias) ( #1635 )
...
* Fixed #8959 ("(debug) Unknown type 'x'" with using/alias)
* fix cppcheck warning
2019-01-31 23:57:37 +01:00
IOBYTE
606ba4fc1a
template simplifier: add forward declaration map to debug output ( #1629 )
...
* template simplifier: add forward declaration map to debug output
* template simplifier: add partial specialization flag
* template simplifier: add specialization map and partial specialization map to debug output
2019-01-27 07:46:27 +01:00
IOBYTE
68bbe15116
template simplifier: fix missing instantiation ( #1627 )
2019-01-26 07:08:54 +01:00
IOBYTE
cb1a1df0fa
template simplifier: fix out of line member function scope and use more full name matching ( #1617 )
2019-01-24 07:21:22 +01:00
IOBYTE
ec8bc785a2
template simplifier: add support for using namespace when instantiating templates ( #1615 )
2019-01-23 08:53:01 +01:00
IOBYTE
1acbdde302
Fixed #7417 ("syntax error" in valid code containing explicitly specialised variable template) ( #1604 )
2019-01-18 21:12:39 +01:00
Robert Reif
6ef8dad459
template simplifier: improve namespace matching
...
* out of line member functions are a namespace
* template<...> and *_cast<> can't be instantiations
* refactor code to use less function parameters
* fix instantiation scopes
* use full name with namespace when available
* fallback to just matching names when full name doesn't match
2019-01-14 21:32:58 +01:00
IOBYTE
f0cfe03f7b
template simplifier: add cli --debug-template option to print the parsed template information ( #1598 )
2019-01-14 08:29:32 +01:00
Daniel Marjamäki
d40314b825
Replace Token::Match with Token::simpleMatch for simple patterns
...
[ci skip]
2019-01-12 18:44:48 +01:00
IOBYTE
07da4b4d37
template simplifier: Add flag variable to cache information about dec… ( #1569 )
...
* template simplifier: Add flag variable to cache information about declarations.
Also fix some cppcheck warnings.
* Make variable const.
2019-01-07 06:55:22 +01:00
IOBYTE
32a5d66e5b
Fixed #8927 (SIGSEGV below TemplateSimplifier::expandTemplate) ( #1564 )
2019-01-05 11:14:09 +01:00
IOBYTE
3b9828a132
template simplifier: fix crash on daca c++-annotations project ( #1556 )
...
Fix scope info bug on derived template class which caused a use after
free crash when deleting a template forward declaration in a different
scope.
2019-01-02 07:15:45 +01:00
IOBYTE
c37b807613
template simplifier: also check if instantiated template is not specialized ( #1551 )
2018-12-31 21:29:53 +01:00
IOBYTE
9dc8faa3b6
template simplifier: fix location of forward declaration for explicit specializations ( #1550 )
2018-12-31 17:19:34 +01:00
IOBYTE
36dfa0f27a
template simplifier: refactor to use cached information ( #1548 )
...
* use already cached name token rather than recalculating it
multiple times
* cache end of template parameters token and use it rather than
recalculating it multiple times
* remove unnecessary end of template token and name token checks
* remove function parameter that is already contained in another
parameter
2018-12-30 21:16:11 +01:00
Carlo Marcelo Arenas Belón
5ae6861a0f
clang warnings ( #1547 )
...
* valueflow: remove unused variable known
since e4677ae640
will trigger :
lib/valueflow.cpp:506:20: warning: unused variable 'known' [-Wunused-variable]
const bool known = (parent->astOperand1()->hasKnownValue() ||
* templatesimplifier: cleanup
since 48c960f56c
showing:
lib/templatesimplifier.h:279:16: warning: private field 'mTokenizer' is not used
[-Wunused-private-field]
Tokenizer *mTokenizer;
2018-12-30 11:32:48 +01:00
IOBYTE
da91ce2016
Fixed #6183 (TemplateSimplifier: Does not handle methods) ( #1546 )
...
* Fixed #6183 (TemplateSimplifier: Does not handle methods)
* Fix function lookup.
2018-12-29 11:19:53 +01:00
Daniel Marjamäki
162576146e
Revert "Fixed #6183 (TemplateSimplifier: Does not handle methods) ( #1540 )"
...
This reverts commit 7875555b03
.
2018-12-24 20:10:00 +01:00
IOBYTE
7875555b03
Fixed #6183 (TemplateSimplifier: Does not handle methods) ( #1540 )
2018-12-24 07:25:11 +01:00
IOBYTE
48c960f56c
template simplifier: better detection of template functions ( #1539 )
...
* template simplifier: better detection of template functions
* fix comment
2018-12-22 10:05:10 +01:00
Daniel Marjamäki
b97b3b7ef8
astyle formatting
...
[ci skip]
2018-12-21 13:54:59 +01:00
rebnridgway
431d068339
Several fairly significant optimisations ( #1518 )
...
* Code changes for Token::mImpl optimisation
* Added new TokenImpl optimisation
Moving members to the TokenImpl struct reduces the size of the Token class, which is a fairly significant optimisation. In my testing on Windows with 32-bit Release-PCRE, this change reduced the size of the Token class from 108 bits to 52 bits and reduced run-time of my test case by around 20%.
* Several optimisations
Deleted some code that ran very slowly and did nothing, as there is no need to change a Token's string to null if you are about to delete it.
Added a frontToken to simplifyCalculations to reduce the amount of work it has to do on already-simplified calculations.
Moved template removal to the end of the list as this reduces redundant iteration and saves time.
* Added tok argument to simplifyCalculations
This means callers can avoid unnecessary work if they know which tokens have already been simplified. Passing nullptr indicates the original behaviour (starting from the front of the list).
* Removed mention of member from another change
* Re-added and optimised some code deleted in error
Changing mTemplateInstantiations to a vector avoids the high cost of doing repeated linear searches. Changing how the code iterates through the array was necessary because the vector can be resized at several points during the loop, which breaks existing references and iterators.
* Changed mTemplateInstantiations to a vector
This is an optimisation that makes repeated linear searches of this collection significantly faster.
Also added a copy constructor to TokenAndName so code can make copies of these objects to keep a reference if a vector gets resized.
* A cleaner optimisation to removing template tokens
This reverts the previous change to made mInstantiatedTemplates a vector and the iterator changes to support this, and makes mTypesUsedInTemplateInstantiation so the eraseTokens logic can be unified.
* Reverted vector to list
Also made mTypesUsedInTemplateInstantiation a vector of TokenAndName objects so it can share the same logic as the other members.
* Added member for template simplifier pointer
This can be used more efficiently than marking Tokens with a flag and then searching through all templates to find the one that matches.
* Turned loop inside out
This means we only have to iterate through the std::list once. std::list is very expensive to iterate through.
* Latest code from danmar and fixed optimisations
In particular I have optimised simplifying template instantiation names as this was incredibly slow because of the number of times it had to iterate through the template instantiation list. Previous optimisations to this weren't very effective and broke some edge cases.
* Added changes from danmar
Made mExplicitInstantiationsToDelete a vector of TokenAndName to be consistent with the rest of the members, which are cleaned up very efficiently.
* Tokens can have many templateSimplifierPointers
* templateSimplifierPointers must be kept in sync
2018-12-21 13:51:45 +01:00
IOBYTE
d528934139
template simplifier: also remove forward declarations when removing expanded templates ( #1536 )
2018-12-20 20:55:27 +01:00
IOBYTE
c31331d085
template simplifier: fix explicit instantiation with types starting with const and ending in * and &. ( #1530 )
2018-12-19 21:59:59 +01:00
IOBYTE
2090866cd0
template simplifier: remove explicit instantiations after instantiation ( #1523 )
...
* template simplifier: remove explicit instantiations after instantiation
* Fix use after free crash in clang test suite.
2018-12-17 05:58:48 +01:00
IOBYTE
a1c275436f
Fix #8902 (Crash in TemplateSimplifier) ( #1521 )
2018-12-15 07:52:47 +01:00
IOBYTE
a90c56ad76
Fixed #8880 (Regression: syntax error for valid C++ template code) ( #1509 )
2018-12-06 21:47:48 +01:00
IOBYTE
3d024f3f6d
template simplifier: fix function forward declaration bug for constructor with initializer list. ( #1497 )
2018-11-29 06:24:28 +01:00
IOBYTE
f2660ed203
template simplifier: fix instantiated template names in forward declarations ( #1495 )
...
This now handles the revised example code in #8603 .
2018-11-27 06:17:04 +01:00
IOBYTE
e20079a5d9
template simplifier: fix 3 function forward declaration bugs ( #1493 )
...
* fix support for multi token types
* fix support for const member functions
* fix duplicate template parameters sometimes being inserted
2018-11-26 06:23:12 +01:00
IOBYTE
358f0c473d
Modify template simplifier to add forward declarations of some templa… ( #1489 )
...
* Modify template simplifier to add forward declarations of some template functions so symbol database can make sense of the expanded templates.
* Fix travis.
2018-11-23 11:36:09 +01:00
IOBYTE
69e6e11844
Fix a template simplifier namespace bug in #7145 ( #1473 )
...
* Fix a template simplifier namespace bug in #7145
* Refactor template simplifier to only call getTemplateDeclarations once per loop.
2018-11-10 16:41:14 +01:00
IOBYTE
17a8a4898d
Fix another template simplifier namespace bug. ( #1467 )
...
* Fix another template simplifier namespace bug.
* Add missing forward declarations caused by token bug.
2018-11-07 21:25:42 +01:00
IOBYTE
9b67e680ae
Fix template simplifier namespace support. ( #1464 )
2018-11-05 19:55:21 +01:00
Daniel Marjamäki
3798feecad
TemplateSimplifier : Remove 'class|struct' in template arguments
2018-11-02 14:49:40 +01:00
Daniel Marjamäki
8beb42cc90
astyle formatting
...
[ci skip]
2018-10-28 17:37:19 +01:00
Paul Fultz II
f5811c6818
Fix issue 8732: Syntax error when using enable_if ( #1453 )
...
* Fix issue 8732: Syntax error when using enable_if
* Fix FPs
* Use simpleMatch
2018-10-28 17:16:31 +01:00
IOBYTE
adbbadec7f
Fixed #8798 (template simplifier: wrong simpifications for namespaces) ( #1452 )
2018-10-26 14:20:13 +02:00
IOBYTE
ea4e6a60f7
Fix template simplifier from deleting the same declaration multiple times ( #1449 )
...
Found by running valgrind on testrunner. May fix #8808 .
2018-10-24 19:32:37 +02:00
IOBYTE
0763fdbfad
Copy template default argument values from forward declaration to declaration. ( #1447 )
...
It is possible to define default template parameter values in forward
declarations and not define any in the actual declaration. Cppcheck
ignores forward declarations and only uses the default values in the
actual declaration so default values in forward declarations are copied
to the actual declaration when necessary.
2018-10-24 14:38:59 +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
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
IOBYTE
33b74a04ab
Add union support to template simplifier. ( #1398 )
2018-09-26 06:23:12 +02:00
orbitcowboy
d08b39c915
Improved const correctness of local variables. There are no functional changes intended. ( #1392 )
2018-09-23 20:24:51 +02:00
IOBYTE
e9a44f70b2
Remove out of line member functions of instantiated template classes. ( #1377 )
...
* Remove out of line member functions of instantiated template classes.
2018-09-14 14:16:34 +02:00
IOBYTE
7224ee27d9
Fixed #8122 (simplifyTemplates: constructor outside template class not simplified properly) ( #1361 )
2018-09-02 17:49:13 +02:00
IOBYTE
341dee4a07
Fixed #8725 (Template out of line function return type missing when instantiated.) ( #1360 )
2018-09-02 08:35:05 +02:00
IOBYTE
508e8c234b
Fixed #8683 (Using deleted token with multiple template instantiations.) ( #1353 )
...
* Fixed #8683 (Using deleted token with multiple template instantiations.)
* Fixed #8321 (heap use after free: templatesimplifier)
* Add a flag to Token indicating that it has a pointer to it.
* Run dmake
* Fix one source of list pointers to deleted tokens.
Refactor TemplateSimplifier class to get access to template lists.
Remove many function parameters now that they are class variables.
Fix one source of list pointers to deleted tokens.
Add tests with no output to catch crashes.
* Run dmake again.
* Make 2 more functions private.
* Make requested changes.
* Missed one change request.
* Use TokenList rather than Tokenizer.
* Move TokenAndName constructor to cpp file so token.h is not needed in header file.
2018-09-01 11:26:10 +02:00
Daniel Marjamäki
faea8e1c02
Refactoring: Use range for loops
2018-07-15 14:45:15 +02:00
Daniel Marjamäki
9717a5afad
Rename private member variables
2018-06-17 19:24:40 +02:00
Daniel Marjamäki
ef534c2d0d
Renamed _codeWithTemplates
2018-06-16 22:03:04 +02:00
Daniel Marjamäki
79ffe1d4fc
Rename _tokenizer, _settings, _errorLogger
2018-06-16 16:10:28 +02:00
rebnridgway
d3b231214d
TemplateSimplifier optimisation. measured time improvement for cryptopp/test.cpp is ~8.4s => ~8.35s
2018-06-02 13:49:14 +02:00
Daniel Marjamäki
7163210f72
Fixed #8605 (Segmentation fault below TemplateSimplifier::simplifyCalculations)
2018-06-01 23:03:53 +02:00
Daniel Marjamäki
02f9ab38b4
simplifyCalculations: Made this function ~30% faster when analysing lib/tokenize.cpp
2018-05-31 06:36:59 +02:00
amai2012
8d55d361ae
#8602 Template default parameter without name yields syntax error
2018-05-30 17:09:31 +02:00
Daniel Marjamäki
4c9bde277a
Refactoring: Use ranged for in TemplateSimplifier
2018-05-30 14:40:38 +02:00
Daniel Marjamäki
f7148cbaa9
Refactoring: Renamed iterator
2018-05-30 14:33:55 +02:00
Daniel Marjamäki
cc77a6aa62
Code refactoring
2018-05-29 22:41:37 +02:00
orbitcowboy
5861a3844a
Running astyle [ci skip].
2018-05-29 17:32:55 +02:00
orbitcowboy
de66eedd54
Improved const correctness of local variables.
2018-05-29 17:33:43 +02:00
IOBYTE
d567b878ba
Fix template instantialion failure for qualified template type. ( #1237 )
2018-05-16 15:24:23 +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
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
3044612fe9
Optimize usage of TemplateSimplifier::simplifyCalculations
2018-05-11 14:48:59 +02:00
Daniel Marjamäki
f336c2efe7
Refactoring; Renamed Scope::classStart and Scope::classEnd
2018-04-27 22:36:30 +02:00
PKEuS
d2146844dd
Refactorizations:
...
- Replace several push_back-calls by emplace_back
- Replace some x = x.substr(0, y) calls by x.erase(y)
2018-04-11 09:44:35 +02:00
jrp2014
b6504c70ca
Improve constness
2018-04-04 21:51:31 +02:00
orbitcowboy
ec0cc4e29c
templatesimplifier: Removed redundant local string variable. ( #1041 )
2018-01-20 22:26:48 +01:00
Daniel Marjamäki
b08c1868bc
Fixed Cppcheck warning
2018-01-15 22:03:23 +01:00
Daniel Marjamäki
c4caee6b18
Updated copyright year
2018-01-14 15:37:52 +01:00
Daniel Marjamäki
bbeff99cc3
Fixed #6930 (Token: need function that says if the token comes from instantiated template argument)
2018-01-11 09:41:22 +01:00
Daniel Marjamäki
8c33a95b49
Refactoring: moved method from Tokenizer to TokenList
2018-01-07 14:07:34 +01:00
Daniel Marjamäki
98b45ffbc0
Fixed #8314 (TemplateSimplifer crash)
2018-01-06 15:16:03 +01:00
Daniel Marjamäki
943693acfb
TemplateSimplifier: Improved code for template aliases
2018-01-06 08:40:06 +01:00
Martin Ettl
e33fe91b1a
Micro optimize std::string::find() calls searching for a single space.
2018-01-05 22:24:28 +01:00
Daniel Marjamäki
d6dae27803
Fixed Cppcheck postincrement warnings
2018-01-05 17:29:40 +01:00
Daniel Marjamäki
2c5225af43
Fixed use-after-free found by asan
2018-01-05 17:06:02 +01:00
Daniel Marjamäki
04c57381ea
Fixed #8315 (heap use after free: templatesimplifier)
2018-01-05 16:10:13 +01:00
Matthias Krüger
94790620d6
templatesimplifier: fix two warnings about nonexplicit constructors.
...
Was:
[lib/templatesimplifier.cpp:37]: (style) Class 'FindToken' has a constructor with 1 argument that is not explicit.
[lib/templatesimplifier.cpp:47]: (style) Class 'FindName' has a constructor with 1 argument that is not explicit.
2018-01-05 15:53:13 +01:00
Daniel Marjamäki
f74c19bbed
Refactoring lookups in TemplateSimplifier
2018-01-05 15:27:43 +01:00
Daniel Marjamäki
a95108ebe3
TemplateSimplifier: Fix incorrect recursion when template is reused inside itself
2018-01-03 23:05:57 +01:00
Dmitry-Me
70817b3d4e
Remove redundant check
2018-01-01 03:06:17 +03:00
Daniel Marjamäki
1cbeec26c6
Replace Token::Match with Token::simpleMatch
2017-12-30 22:43:44 +01:00
Daniel Marjamäki
f6fcf01cc6
Fixed #7868 (TemplateSimplifier: template specialization fails)
2017-12-30 22:14:48 +01:00
Daniel Marjamäki
03a4c84fec
Rename variables
2017-12-30 12:27:55 +01:00
Daniel Marjamäki
a8f73055ad
Templates: Fixed scope problem
2017-12-30 09:00:19 +01:00
Daniel Marjamäki
fc1ac180e6
Fixed #6218 (Template type aliasing misdetection)
2017-12-29 22:47:07 +01:00
Daniel Marjamäki
caf9f22015
Rename method TemplateParametersInDeclaration => getTemplateParametersInDeclaration
2017-12-28 22:10:10 +01:00
Daniel Marjamäki
42bcb6d417
use early continue
2017-12-27 22:29:45 +01:00
Daniel Marjamäki
469cb7e6df
TemplateSimplifier: Fix instantiations when template parameter is a template
2017-12-26 22:34:39 +01:00
Daniel Marjamäki
84bdabacf8
TemplateSimplifier: Remove not needed variable indentlevel
2017-12-26 13:27:02 +01:00
Daniel Marjamäki
2c69f2b226
TemplateSimplifier: Improved handling of scopes
2017-12-26 10:55:18 +01:00
Daniel Marjamäki
a80760cb6f
TemplateSimplifier: Fix in expandTemplate
2017-12-25 08:19:46 +01:00
Daniel Marjamäki
1eb2df34ad
Revert improved scope handling in TemplateSimplifier
2017-12-23 22:11:30 +01:00
Daniel Marjamäki
d237d36d46
TemplateSimplifier: Fix crash seen in Travis
2017-12-23 17:29:28 +01:00
Daniel Marjamäki
2d7fedbb49
Try to fix Travis
2017-12-23 15:41:32 +01:00
Daniel Marjamäki
5ed2dbd5ef
Fix Cppcheck warning
2017-12-23 10:16:17 +01:00
Daniel Marjamäki
326765c632
TemplateSimplifier: Better handling of scopes
2017-12-23 08:20:24 +01:00
Simon Martin
1b14380007
Ticket #8175 : Fix bug in TemplateSimplifier::instantiateMatch with template parameters involving sizeof or namespace.
2017-12-02 19:18:36 +01:00
Daniel Marjamäki
324257ef52
Fixed #7823 (No varid for member variable of type std::bitset< static_cast<int>(2) >)
2017-11-05 17:59:34 +01:00
Ayaz Salikhov
be2c65eb58
Simplify int vs bool
2017-10-08 07:54:39 +02:00
Ayaz Salikhov
b8cd7dbb5c
Use nullptr instead of 0 or NULL ( #936 )
2017-08-09 20:00:26 +02:00
Daniel Marjamäki
6cc7f46696
Fix issue detected by Coverity, ternary condition is always true
2017-08-01 11:25:28 +02:00
Daniel Marjamäki
b97f5d909e
Fixed #6570 (False positive unusedFunction - function called from within template function)
2017-06-30 14:34:28 +02:00
Daniel Marjamäki
da87fdbb90
Refactoring TemplateSimplifier::simplifyCalculations, Token::Match patterns
2017-06-08 08:18:40 +02:00
Daniel Marjamäki
c1ea873e1c
TemplateSimplifier::simplifyCalculations: Add some more tests and make sure they pass
2017-06-08 08:15:05 +02:00
Daniel Marjamäki
cb48e63f92
TemplateSimplifier: Fixed bug in simplifyCalculations. Now template58 test case does not throw InternalError
2017-06-08 00:49:46 +02:00
Daniel Marjamäki
d2e7df2c04
TemplateSimplifier: Broke out code into separate function
2017-06-08 00:16:43 +02:00
Daniel Marjamäki
2740736136
Avoid 'deleteThis' in TemplateSimplifier::simplifyCalculations as it can cause 'use after free' see #6021
2017-06-07 20:09:06 +02:00
Daniel Marjamäki
d335412858
Avoid 'deleteThis' in TemplateSimplifier::simplifyCalculations as it can cause 'use after free' see #6021
2017-06-07 19:46:02 +02:00
Daniel Marjamäki
18abe4a142
Fixed #6021 (TemplateSimplifier::simplifyCalculations causes heap corruption on invalid code)
2017-06-07 19:32:56 +02:00
Daniel Marjamäki
60e36492e2
Refactoring, renamed local variable
2017-06-07 12:37:44 +02:00
Ayaz Salikhov
28aa939d69
iwyu - include what you use
2017-05-27 04:33:47 +02:00
Matthias Krüger
a28f57344c
templatesimplifier: mark getTemplateNamePositionTemplateMember() static.
...
Fixes gcc 7-dev warning:
lib/templatesimplifier.cpp: In function ‘bool getTemplateNamePositionTemplateMember(const Token*, int&)’:
lib/templatesimplifier.cpp:715:6: warning: no previous declaration for ‘bool getTemplateNamePositionTemplateMember(const Token*, int&)’ [-Wmissing-declarations]
bool getTemplateNamePositionTemplateMember(const Token *tok, int &namepos)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-05-03 08:45:48 +02:00
Simon Martin
28960a8bba
Remove bailout and fix varid for template class member initialized in out-of-line constructor ( #8031 )
2017-04-30 08:59:47 +02:00
Simon Martin
5fd686c878
Ticket #4544 : Also handle Foo<struct Bar> constructs.
2017-04-17 11:24:28 +02:00
Simon Martin
ee05fe7d77
Ticket #7942 : Don't generate invalid syntax for out of line template class constructors during instantiation.
2017-04-09 16:12:59 +02:00
orbitcowboy
a7f1188151
Astyle run.
2017-03-21 14:22:28 +01:00
Simon Martin
fb2b29dc7d
Update TemplateSimplifier::getTemplateNamePosition to handle out-of-line template methods.
...
Add an optional extended description…
2017-03-19 20:44:20 +01:00
Simon Martin
326d152aa2
Ticket #7914 : Properly recognize template parameters that contains operators. ( #870 )
2017-02-11 10:13:41 +01:00
Simon Martin
0943b2145b
Ticket #7891 : Do not remove spaces in the internal representation for template instantiations.
2017-02-05 17:35:29 +01:00
Matthias Krüger
92d9e810f3
templatesimplifier: remove redundant assignments inside switchcase. They will always be overwritten by an assignment outside of the switch near the end of the function. Found by clang analyzer.
2017-01-30 22:26:54 +01:00
umanamente
a012e5b5fb
( Fixed #7846 ) Syntax error when using C++11 braced-initializer in function last argument
...
Add an optional extended description…
2017-01-23 12:50:36 +01:00
Simon Martin
417c7e36c0
Ticket #7548 : Properly detect the end of template parameter default values during instantiation.
2017-01-08 09:38:29 +01:00
Matthias Krüger
b3ace258ab
there is no need to have "if(tok && Token::Match(tok,..." since Token::Match checks "tok" by itselfs already.
2016-11-26 17:22:30 +01:00
orbitcowboy
4e3fdedff9
templatesimplifier: Improved const correctness. There are no functional changes.
2016-10-31 17:24:15 +01:00
Dmitry-Me
667038a402
Merge overlapping patterns
2016-08-24 15:10:39 +03:00
Daniel Marjamäki
45ee29d5dc
Fixed #7604 (simplifyCalculation: expression '0 && x[2]' is not simplified properly)
2016-07-17 15:52:53 +02:00
Daniel Marjamäki
ac8341e3de
keep type suffixes after constant folding using bit operations
2016-03-21 21:20:02 +01:00
Daniel Marjamäki
072120d19f
TemplateSimplifier::templateParameters: Handling r-value arguments
2016-03-18 11:09:41 +01:00
Daniel Marjamäki
6c324013e7
Use MAXTIME in templatesimplifier
2016-02-12 12:05:32 +01:00
Daniel Marjamäki
07f3930923
report progress in TemplateSimplifier::simplifyTemplateInstantiations, as far as I see it can be very slow
2016-02-05 07:59:29 +01:00
Daniel Marjamäki
f3f9ea2d09
TemplateSimplifier: One more fix for #3130 . Restored max recursion count to 100 and improve pattern for reference template instantiations instead.
2016-01-30 11:22:44 +01:00
Daniel Marjamäki
f116de678e
Fixed #3130 (Tokenizer: Doesn't instantiate recursive template correctly)
2016-01-30 10:33:25 +01:00
Daniel Marjamäki
8e79e5c1d3
Fixed #7147 (TemplateSimplifier: specialized template class with inheritance)
2016-01-11 18:45:12 +01:00
Daniel Marjamäki
036306d7c2
Refactoring Tokenizer::startOfExecutableScope(). Improve and reuse Tokenizer::isFunctionHead().
2016-01-03 22:52:24 +01:00
Lauri Nurmi
996c9244d8
Update copyright year to 2007-2016.
2016-01-01 15:34:45 +02:00
Alexander Mai
5b6758b03b
Add some debugging code (inspired by #6021 )
2015-12-27 17:38:15 +01:00
PKEuS
32e2fb2f78
Refactorization: Prefer Token::simpleMatch over Token::Match also for non-const patterns.
2015-12-03 13:04:55 +01:00
Daniel Marjamäki
5fabe66ff7
simplifyCalculations: better handling of && and || in conditions ( #4931 )
2015-11-28 15:00:41 +01:00
PKEuS
93c02ce826
Fixed compiler error introduced in previous commit and several MSVC warnings
2015-11-28 10:49:08 +01:00
Daniel Marjamäki
8689693d6c
Fix Travis
2015-11-28 09:26:44 +01:00
Daniel Marjamäki
c0da6c1541
simplifyCalculations: handle '(4%1<<1&4!=1)' better. must combine '!' '=' before constant folding. fixed the operator precedence for comparison operators. ( #4931 )
2015-11-28 09:04:22 +01:00
Daniel Marjamäki
1bf547c716
Fixed #4931 (Wrong calculation for '2|0*0&2>>1+0%2*1')
2015-11-27 15:02:49 +01:00
Daniel Marjamäki
1977a18a1e
simplifyNumericCalculations: Don't fold negative constants in shift/bitmask calculation. Behaviour is not well defined.
2015-11-27 14:16:49 +01:00
Daniel Marjamäki
2737f63f71
Wrong calculation of constants (simplifying: +,<<,% operations)
2015-11-25 16:46:39 +01:00
Daniel Marjamäki
0022ce8075
Refactor handling of char constants
2015-11-20 10:10:38 +01:00
Daniel Marjamäki
0f9d90d2be
Changed Copyrights. Removed my name.
2015-11-18 20:04:50 +01:00
Alexander Mai
3b1d849476
Correct template syntax check which got introduced by an attempt fix #6865 . Disable test for #6865 , adjust some modified tests and add new regression tests
2015-10-19 20:03:33 +02:00
Alexander Mai
7112725d38
Simplify code (repair travis build)
2015-10-18 16:04:49 +02:00
Alexander Mai
21efa992e3
#6865 TemplateSimplifier::expandTemplate doesn't terminate on invalid code. Add some another syntax check on templates to avoid problems later on.
2015-10-18 15:47:37 +02:00
Daniel Marjamäki
ec87b09d89
Fixed #7056 (iscast does not handle '(ulong)~0' properly, Tokenizer::simplifyCalculations wrongly simplifies '(ulong)~0' to 'ulong~0')
2015-10-17 18:58:13 +02:00
Martin Ettl
8936985c5c
#7001 : Fixed templatesimplifier.cpp: Remove double include.
2015-09-18 12:20:41 +02:00
PKEuS
a720153e1e
Refactorization: Removed redundant code for syntax error handling in templatesimplifier.cpp and symboldatabase.cpp
2015-08-19 19:29:48 +02:00
PKEuS
1627b19dd6
Refactorizations:
...
- Call std::string::find() with char instead of char* where possible
- Avoid string copying
- Optimized several Token::tokAt/strAt calls
2015-08-16 10:33:51 +02:00
PKEuS
ee4a5843bb
Some small refactorizations
2015-08-15 19:46:31 +02:00
PKEuS
4d80df2f4a
Added pointer to Type to Token (similar to Token::Variable() and Token::function()):
...
- Accessible via Token::type()
- Renamed former Token::type() to Token::tokType()
- Removed SymbolDatabase::isClassOrStruct()
2015-08-15 11:19:21 +02:00
Simon Martin
af1b0cfddf
Ticket #6835 : Don't get confused by parentheses while detecting template parameter default values.
2015-07-17 21:30:34 +02:00
Alexander Mai
e75662aaf1
#6792 segmentation fault (invalid code) in TemplateSimplifier::templateParameters. Avoid null pointer access
2015-06-25 20:48:05 +02:00
Alexander Mai
f806d945a1
Refactoring: Allow TemplateSimplifier to throw InternalErrors by itself.
2015-06-23 20:53:57 +02:00
Martin Ettl
9236ea4a20
Running astyle, no functional changes.
2015-05-29 19:15:41 +02:00
amai2012
e41beb4f8d
Fix #6718 and #6719 (crashes on garbage code).
...
Local fixes avoiding access to NULL-token. Also minor correction to
TemplateSimplifier::hasComplicatedSyntaxErrorsInTemplates()
2015-05-29 18:34:00 +02:00
Alexander Mai
098391ee32
#6715 segmentation fault (invalid code) in TemplateSimplifier::hasComplicatedSyntaxErrorsInTemplates. Harden TemplateSimplifier::hasComplicatedSyntaxErrorsInTemplates()
2015-05-28 21:38:20 +02:00
Alexander Mai
6f96634759
#6276 clang: -fsanitize=integer warnings. Fix unwanted integer overflow in TemplateSimplifier::useDefaultArgumentValues() and Tokenizer::simplifyQtSignalsSlots()
2015-05-03 15:21:58 +02:00
Frank Zingsheim
4ceed51bfb
Fixed #6607 (Crash triggered by TemplateSimplifier::useDefaultArgumentValues)
2015-05-01 17:13:02 +02:00
PKEuS
b6709294a8
Fixed ...... in template instantiations (similar to constconst from #6604 )
2015-04-13 17:03:06 +02:00
Matthias Krüger
42f0955e3f
Move more setting checks out of loops and use const bools instead. Reorder a few related checks.
...
Follow up to eedcb6abcb
.
2015-04-10 14:31:19 +02:00
Simon Martin
0f7f08644c
Show template instantiation and not definition location in template instantiation debug message.
2015-04-05 14:54:24 +02:00
Daniel Marjamäki
aacd9b9f6b
Fixed #6586 (Tokenizer: '>>' is wrongly tokenized as '> >' - if (n1 < len>>1))
2015-04-03 20:25:49 +02:00
PKEuS
0d37c4df04
Fixed three unique crashs on garbage code ( #6613 ).
...
Removed redundant copy of string in templatesimplifier.cpp
2015-04-01 12:43:24 +02:00
PKEuS
19f770e41b
Fixed #6604 - don't create template instanciations with "const const const const..." patterns.
2015-03-22 11:20:47 +01:00
Daniel Marjamäki
a200e5b32f
Merge pull request #551 from simartin/ticket_4335
...
Ticket #4335 : Properly detect and handle template class specialisations
2015-03-15 07:59:11 +01:00
Simon Martin
520314f9a0
Ticket #4335 : Properly detect and handle template class specializations.
2015-03-15 00:28:33 +01:00
Simon Martin
32a7a178e8
Code simplification now that ">>" is turned into "> >" when it closes template argument lists.
2015-03-14 23:02:10 +01:00
Simon Martin
4c916641cc
Ticket #6347 : Fix use after delete when simplifying template instantiations.
2015-03-14 18:46:17 +01:00
Simon Martin
1d973b882d
Ticket #6567 : Handle member functions in TemplateSimplifier::getTemplateNamePosition.
2015-03-07 21:52:12 +01:00
Daniel Marjamäki
925f077b8a
Fixed #6110 (TemplateSimplifier::simplifyCalculations: wrong simplification of 'if (VG_(strlen)(s)>=3)')
2015-03-02 16:27:00 +01:00
Simon Martin
c4c46be972
Revert fix for #6181 , that caused #6354 and #6414 .
2015-02-14 12:29:05 +01:00
PKEuS
b2835051df
Refactorization: Renamed Token::Match pattern %var% to %name%, implement new pattern %var% which is true if varId > 0.
2015-01-31 12:32:04 +01:00
Thomas Jarosch
cd4c297dce
Fix segfault in template simplifier
...
When something parsing the template syntax
went wrong, "tok2" was NULL and resulted
in deleting all remaining tokens. Whoops.
Triggered by gcc test suite:
gcc/testsuite/g++.dg/cpp0x/variadic87.C
Tracked down the source of the bug with
valgrind's "--track-origins=yes" switch.
2015-01-18 01:43:43 +01:00
Daniel Marjamäki
ff11ba9847
Updated copyright year to 2015
2015-01-03 12:14:58 +01:00
PKEuS
e03f49360f
Merge pull request #484 from simartin/ticket_6181
...
Ticket #6181 : Properly handle >> terminating template parameter lists.
2014-12-21 12:21:17 +01:00
Simon Martin
4c7a8c5497
Ticket #6181 : Properly handle >> terminating template parameter lists.
2014-12-14 15:14:27 +01:00
Simon Martin
859c6381cc
Ticket #6172 : Properly grok %type%... template parameters.
2014-12-14 14:33:37 +01:00
Simon Martin
cc6b51f2d9
Ticket #6059 : Properly handle class... in parameter lists.
2014-11-07 23:08:54 +01:00
Frank Zingsheim
0e4c508d7b
Fixed #4272 and #6237 (Crash from running out of memory with many templates)
2014-11-01 22:07:24 +01:00
Daniel Marjamäki
d0d2a0faf8
simplifyCalculations: Fix simplification of '( %num% )' when parentheses must be kept
2014-10-10 13:19:25 +02:00
Simon Martin
9ddf857dc7
Ticket #5625 : Simplify constant ternary operator in template parameters.
2014-10-04 20:49:57 +02:00
Dmitry-Me
32f7a789df
Merge overlapping patterns, move declarations
2014-09-17 10:54:53 +04:00
Daniel Marjamäki
29a49d0641
removed some redundant null pointer checks before calling Token::Match
2014-09-14 11:35:04 +02:00
Simon Martin
53b58f0ed9
Refactoring. Use Token::Match instead of hardcoded patterns to increase readability.
2014-09-14 11:26:16 +02:00
Simon Martin
01cf008792
Ticket #6134 : Improve the mechanism differentiating template declarations from template definitions.
2014-09-13 16:44:05 +02:00
Simon Martin
6e10603227
Ticket #6023 : Properly handle template'd default template parameter values.
2014-09-06 20:39:04 +02:00
Daniel Marjamäki
d41ef3a6d0
TemplateSimplifier: Fixed crash caused by null pointer dereference. I don't have a testcase. But the code is suspicious, in the loop we check if tok3 is null and then in the loop head we call tok3->next().
2014-07-15 21:28:52 +02:00
amai2012
9b38ae73c1
Attempt to fix 2 Coverity messages.
...
Replace a few unsigned int by std::size_t
2014-07-07 21:25:30 +02:00
Daniel Marjamäki
d40b77dce2
Removed special 'else if' handling. this is redundant since these are simplified.
2014-07-02 16:16:19 +02:00
orbitcowboy
76f3f67bcf
Fixed fsanitize=undefined: left shift of negative value -10000 in lib/templatesimplifier.cpp.
2014-06-16 10:58:41 +02:00
PKEuS
a04036337d
Fixed #5860 : Don't show returnTempReference for calculations on unknown types
2014-05-24 12:50:04 +02:00
PKEuS
adf38fcfd0
Further include cleanup
2014-05-24 12:50:04 +02:00
Simon Martin
2b809800b6
Ticket #5823 : Properly count template parameters in TemplateSimplifier::useDefaultArgumentValues and handle casts in template parameters' default values.
2014-05-23 23:38:40 +02:00
orbitcowboy
90c1016c74
Fixed #5842 : remove C99 static keyword between [] in tokenizer.
2014-05-13 16:28:28 +02:00
Alexander Mai
be9a566d48
Refactoring/small corrections to fix warnings from clang -fsanitize=undefined 'member call on null pointer'
2014-05-20 21:55:08 +02:00
Mark de Wever
d6db261213
Fixed #5827 (Invalid token match patterns)
2014-05-19 06:31:38 +02:00
PKEuS
5fbd58d98d
Fixed messages of CheckInternal, fixed a false positive.
2014-05-18 20:39:52 +02:00
Simon Martin
e61e1cb13d
Ticket #5786 : Properly handle cv-qualified member pointers as template parameter.
2014-05-14 22:27:31 +02:00
Daniel Marjamäki
4e2c0617d3
Merge pull request #303 from simartin/ticket_5297
...
Ticket #5297 : simplifyCalculations should pass once more on simplified tokens
2014-05-10 10:18:29 +02:00
Simon Martin
1e4902cb65
Ticket #5297 : simplifyCalculations should pass once more on tokens being simplified.
2014-05-10 09:37:56 +02:00
Simon Martin
46d8d81176
Ticket #5774 : Properly handle "typename..." in template parameter list.
2014-05-09 22:20:22 +02:00
Simon Martin
2a6acdf357
Ticket #5605 : Don't consider '>' as a default template parameter value. Don't choke on template parameters with erroneous default values.
...
Ticket #5759 : Properly handle pointers to class members in template parameter lists.
Ticket #5762 : Handle template specialization tokens.
2014-05-08 13:54:56 +02:00
Daniel Marjamäki
6e25280c90
Reverted fix for #5605 since it cause this crash: #5759
2014-05-05 21:11:47 +02:00
Daniel Marjamäki
2f3f42d7f1
astyle formatting
...
[ci skip]
2014-05-03 18:10:49 +02:00
Simon Martin
ffe6a0be2b
Ticket #5605 : Don't consider '>' as a default template parameter value. Don't choke on template parameters with erroneous default values.
2014-05-03 16:26:14 +02:00
Robert Reif
ca9386859b
Tokenizer: replace ') const| {' pattern to detect function start
2014-04-26 18:31:56 +02:00
Daniel Marjamäki
28751c8ad0
astyle formatting
...
[ci skip]
2014-04-15 06:32:25 +02:00
Alexander Mai
ac24635056
Convert MathLib::toLongNumber() from template member function to toLongNumber() and toULongNumber() to avoid various problems compiling with Visual Studio
2014-04-14 20:30:38 +02:00
Alexander Mai
718e42f5ca
Fix some clang warnings about type conversions
2014-04-11 23:35:53 +02:00
Alexander Mai
e19129a409
Fix #4724 (Error in calculation shift operation: wrong sign: 1UL << 63)
2014-04-10 19:22:14 +02:00
Daniel Marjamäki
5698f7b337
astyle formatting
2014-03-14 05:36:44 +01:00
Daniel Marjamäki
61eb262244
Fixed #5215 (segmentation fault (invalid code) in TemplateSimplifier::useDefaultArgumentValues)
2014-03-12 19:36:22 +01:00
Frank Zingsheim
b1dc51ba9c
Fixed #4796 (Missing semicolon after simplified template class)
2014-03-12 06:09:45 +01:00
Frank Zingsheim
5e0a575091
Optimization: tokenlist::addtoken
2014-03-09 17:54:49 +01:00
Simon Martin
3518e02d23
Ticket #5506 : Skip template parameters when determining whether a template is a declaration or a definition.
2014-03-01 14:58:47 +01:00
Daniel Marjamäki
23efc68dd7
use nullptr
2014-02-16 10:32:10 +01:00
Daniel Marjamäki
fd3a8a2a18
Update copyright
2014-02-15 07:45:39 +01:00
Graham Whitted
86201c13cb
Fixed #5097 (TemplateSimplifier::expandTemplate assertion failure)
2014-01-05 19:19:52 +01:00
PKEuS
621cf6e777
Support arrays as template parameters in TemplateSimplifier::templateParameters
2013-12-31 13:59:32 +01:00
Daniel Marjamäki
8cca41774d
Fixed #4446 (Crash on complex C++ template)
2013-11-21 20:27:24 +01:00
Daniel Marjamäki
f8cf64afef
Fixed #4710 (Template parser bug: const in constructor changes template names)
2013-11-19 06:07:25 +01:00
Daniel Marjamäki
1c513f330a
Fixed #5055 (False negatives when using -I (external source code))
2013-09-29 18:59:27 +02:00
Robert Reif
2de3ebcb1e
CheckIO: fixed some more false negatives. Ticket: #4964
2013-09-24 06:43:03 +02:00
Simon Martin
894f537eba
Remove warnings emitted by clang's -Wsign-conversion
2013-09-22 13:22:52 +02:00