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