Commit Graph

277 Commits

Author SHA1 Message Date
IOBYTE 2482873029
fix location of forward declaration of specialized template (#3031) 2021-01-09 20:00:35 +01:00
IOBYTE 503a5dd441
fix #10081 (Hang: TemplateSimplifier::useDefaultArgumentValues) (#3021) 2021-01-06 23:06:50 +01:00
IOBYTE e7bdf5f71c
remove cleanupAfterSimplify from the template simplifier (#2998)
The template simplifier works well enough now so cleanupAfterSimplify is
no longer necessary.  In fact cleanupAfterSimplify was introducing a bug
which improperly simplified C++ style casts.

Bugs should be exposed and fixed properly rather than just hiding them.

Co-authored-by: Robert Reif <reif@FX6840>
2020-12-31 09:33:23 +01:00
IOBYTE 277da763aa
fix #10054 (debug: Executable scope 'x' with unknown function.) (#2994) 2020-12-30 08:09:34 +01:00
IOBYTE 7fc03c6030
fix #10032 (Syntax error if first function in a struct is a template function) (#2940)
Co-authored-by: Robert Reif <reif@FX6840>
2020-12-11 07:01:20 +01:00
IOBYTE 8d9f0b3528
fix #9394 ("debug: Executable scope 'x' with unknown function." with … (#2935) 2020-12-06 22:08:42 +01:00
IOBYTE ab16603666
fix #9685 (Handle 'extern "C++"') (#2933) 2020-12-05 09:26:11 +01:00
IOBYTE 9c51d4c12d
instantiate nested templates in the proper order (#2930) 2020-12-04 08:04:16 +01:00
IOBYTE 2bbc7abedc
fix overloaded function lookup for explicit instantiations (#2929) 2020-12-01 09:43:16 +01:00
Daniel Marjamäki 9aa69661b5 More robust Token::findClosingBracket 2020-11-30 19:26:28 +01:00
Daniel Marjamäki 8a1c16a560 Tokenizer: add daca debug messages when right angle brackets in templates are not handled well 2020-11-29 16:07:56 +01:00
Daniel Marjamäki e2debac882 Fix testcases 2020-11-29 08:46:42 +01:00
IOBYTE 1ea89bcad8
add support for template constructors (#2911) 2020-11-24 07:21:37 +01:00
Daniel Marjamäki 4a2e082d85 Revert "GUI: restore default tab in ProjectFileDialog"
This reverts commit 39564c9e6c.
2020-11-23 20:18:06 +01:00
Daniel Marjamäki 39564c9e6c GUI: restore default tab in ProjectFileDialog 2020-11-23 19:27:14 +01:00
Daniel Marjamäki 2cd8ea83a7 Fixed #9860 (unused template not removed properly by default) 2020-11-22 16:43:36 +01:00
IOBYTE c4b3d4cd77
fix #9983 (TemplateSimplifier: template not simplified : f(0,0);) (#2905)
Currently template type deduction for functions only works for single
template argument single function argument functions with a literal
argument.

This patch starts to add support for single template argument multiple
function argument functions.  It correctly handles functions with
multiple arguments of the same type. It also handles a mix of template
and non-template arguments.

It does not add support for overloading non-template arguments.
It does not add support for multiple parameter template functions.
It does not add support for type deduction from variable arguments.

Co-authored-by: Robert Reif <reif@FX6840>
2020-11-17 06:51:32 +01:00
IOBYTE e785885b4d
fix #9975 (Template method not simplified) (#2894) 2020-11-10 21:19:04 +01:00
Robert Reif a52ce7379a fix #9886 (Hang in TemplateSimplifier (gcc/gcc/testsuite/g++.dg/cpp0x/decltype34.C)) 2020-09-10 14:47:59 -04:00
IOBYTE 2106e30304
fix template namespace bug (#2780)
Co-authored-by: Robert Reif <reif@FX6840>
2020-09-07 17:45:19 +02:00
IOBYTE 2db0d2878b
fix daca crash in TemplateSimplifier::getNewName (#2772)
Don't add the same template instantiation multiple times.

Co-authored-by: Robert Reif <reif@FX6840>
2020-09-04 07:08:28 +02:00
Daniel Marjamäki bb5cad42cd astyle formatting
[ci skip]
2020-08-26 10:15:09 +02:00
IOBYTE 7cf3909275
fix #9854 (Syntax error on valid C++ code) (#2756) 2020-08-26 07:00:58 +02:00
shaneasd 45fc6a0eeb
Test for syntax error in nested templates (#2746) 2020-08-25 07:14:44 +02:00
Ken-Patrick Lehrmann 5c1a2db434 Fix handling of c++ casts in template expansion
Cast were not expanded properly: the `<` was not taken into account in
typeindentlevel, so we would then miss a `>`, resulting in syntaxError.
2020-06-16 19:36:04 +02:00
Oliver Stöneberg 4f68d85633
optimized non-matchcompiled Token::simpleMatch() a bit (#2640) 2020-05-26 20:13:56 +02:00
Daniel Marjamäki 08ddd84780 Update copyright year 2020-05-10 11:16:32 +02:00
Daniel Marjamäki 3e0218299b Revert "Update copyright year"
This reverts commit 6eec6c4bd5.
2020-05-10 11:13:05 +02:00
Daniel Marjamäki 6eec6c4bd5 Update copyright year 2020-05-10 11:11:34 +02:00
Daniel Marjamäki 97b04ba9a7 Syntax check: Using keyword in global scope 2020-04-11 17:36:22 +02:00
Daniel Marjamäki 8dd0a9241c TemplateSimplifier: Simplification of const types 2020-04-05 13:51:58 +02:00
IOBYTE 4d58d9fc87
fix daca chromium crash (#2527) 2020-02-09 11:19:36 +01:00
Dmitry-Me 84f65c40a7 Improve test coverage for templates with comparison in default value 2020-02-03 18:36:51 +03:00
IOBYTE 0e4efea530 fix #9539 (Syntax error for valid C++14 code) (#2446) 2019-12-12 20:50:20 +01:00
IOBYTE f554a71dea fix #9495 (Crash when parsing angle brackets in template with type traits (assertion failure)) (#2407) 2019-11-29 09:44:27 +01:00
IOBYTE 590aeea8f8 Fix #9483 (Assertion `tok && tok->str() == ">"' failed) (#2381) 2019-11-20 07:02:25 +01:00
IOBYTE f88ae21d8f Fix #9467 (False positive on local variable when template specialization is used) (#2357) 2019-11-13 21:34:27 +01:00
IOBYTE 02e7f4f61c Fix template templates where the template template parameter is not the first parameter. (#2309) 2019-10-30 12:12:47 +01:00
IOBYTE c32a568c1f fix #8965 ("(debug) Executable scope 'x' with unknown function." with rvalue parameter in method) (#2237)
I fixed the AST enough to pass testrunner but I don't believe it is
correct.

This code:

void Foo4(int&&b);

has this AST:

( 'void'
|-Foo4
`-&& 'bool'
  |-int
  `-b 'signed int'

but I don't believe && should have `bool`.
2019-10-04 12:30:11 +02:00
IOBYTE 3e17c24dd8 fix syntax error on template operator (#2225) 2019-10-03 12:26:45 +02:00
IOBYTE d0968a1377 Warn about unknown macro causing template syntax error (#2222) 2019-09-26 16:01:01 +02:00
IOBYTE 4475c4c7e2 template simplifier: fix syntax error (#2218) 2019-09-26 10:31:19 +02:00
IOBYTE 12f93b63a8 template simplifier: fix simplification of "< %num% %comp% %num% >" (#2214)
* template simplifier: fix simplification of "< %num% %comp% %num% >"

* fix test to not fail on 32 bit platforms
2019-09-25 12:06:29 +02:00
Oliver Stöneberg 9028b4a81d do not access static methods through instance (#2189) 2019-09-20 21:54:30 +02:00
IOBYTE 8c5cf8c029 Fixed #9046 syntaxError (#2180)
* Fixed #9046 syntaxError

* fix another syntax error

* fix some more syntax errors
2019-09-20 12:35:01 +02:00
IOBYTE 4e222afa2c template simplifier: ignore alias template definitions with syntax errors (#2169)
Is not allowed to define a type in an alias template definition.

This code:

template<int N>
using A1 = struct B1 { static auto constexpr value = N; };
A1<0> a1;

produces this output:

2: } ;
3: struct B1 { static const auto value = 0 a1 ;

test.cpp:2:57: error: Analysis failed. If the code is valid then please
report this failure. [cppcheckError]
using A1 = struct B1 { static auto constexpr value = N; };
                                                        ^

because it tries to instantiate the invalid alias template definition
and generates garbage code.
2019-09-11 19:31:15 +02:00
IOBYTE 639c29eb5c Fix #9338 (Regression: Syntax error on valid C++) (#2156)
* Fix #9338 (Regression: Syntax error on valid C++)

* fix cppcheck warning
2019-09-09 21:46:21 +02:00
IOBYTE 59fdbd8435 Fix #9337 (Syntax error on valid C++) (#2152) 2019-09-07 09:09:04 +02:00
IOBYTE e5220bdf0c make ellipsis ... a single token (#2143)
* make ellipsis ... a single token

Using cppcheck -E to preprocess code with ellipsis produces output that
can't be compiled because ... is split into 3 tokens.

* try to fix addon
2019-09-04 08:07:30 +02:00
IOBYTE fd403bf7e6 template simplifier: only add recursive instantiation if its arguments are a constant expression (#2138) 2019-09-02 06:51:19 +02:00
IOBYTE 3a1aec8850 template simplifier: ignore friend templates (#2122)
* template simplifier: ignore friend templates

friend templates were interpreted as variable templates

* fix cppcheck warning
2019-09-01 09:56:33 +02:00
IOBYTE 28a95802a2 template simplifier: fix syntax error false positive (an expression can't be a template) (#2115)
https://stackoverflow.com/questions/57590411/cppcheck-syntax-error-with-using-typedef
2019-08-27 06:37:58 +02:00
IOBYTE 4b231c53a4 Fixed #9287 and #9288 (Syntax error on valid C++ code) (#2104) 2019-08-20 20:25:18 +02:00
IOBYTE 04bb6c0d1f template simplifier: fix new daca crashes (#2093) 2019-08-17 07:38:07 +02:00
IOBYTE c6c50567cf Fix #9250 (Regression: crash in gcc testsuite) (#2067)
* Fix #9250 (Regression: crash in gcc testsuite)

* fix cppcheck warning
2019-08-07 08:05:02 +02:00
IOBYTE 7ebc9d1b5f Fix #9249 (Syntax error on valid C++) (#2062) 2019-08-04 10:24:44 +02:00
IOBYTE 2da83df37b Fix #9246 (Syntax error on C++ code) (#2061) 2019-08-03 08:15:06 +02:00
IOBYTE 0d1685cd29 Fix #9178 example with instantiation (#2059) 2019-08-02 07:53:39 +02:00
IOBYTE 9436f72a94 Fix daca dnsdist crash (#2053) 2019-07-31 09:18:43 +02:00
IOBYTE 07ac6c5f08 Fix ternary operator simplification to accept template parameters. (#2048)
Also simplify decltype of bool and numeric literals in template
arguments.
2019-07-28 21:52:52 +02:00
IOBYTE badc573b80 Fix #9224 (Performance regression in template parsing: 250x - 1200x slower) (#2046) 2019-07-28 09:25:18 +02:00
IOBYTE 999d2f797c Fix #9225 (Crash on valid C++14 code) (#2031)
* Fix #9225 (Crash on valid C++14 code)

This only fixes the crash. Specialization of nested templates is still
broken.

* fix cppcheck warnings

* fixed another cppcheck warning
2019-07-24 19:20:19 +02:00
IOBYTE 5ad5cfcc29 Fix #9217 (Regression: Memory explodes in simplifyTemplateAliases) (#2021)
* Fix #9217 (Regression: Memory explodes in simplifyTemplateAliases)

* fix use after free when nothing was copied
2019-07-23 21:28:24 +02:00
IOBYTE 6d6bb31926 fix crash in daca gcc-avr from intentional bad instantiation test (#1994)
* fix crash in daca gcc-avr from intentional bad instantiation test

* fix cppcheck warning
2019-07-15 12:41:06 +02:00
IOBYTE e551057f59 Refactor Tokenizer::simplifyUsing to use continue to reduce indentation (#1967)
* Refactor Tokenizer::simplifyUsing to use continue to reduce indentation

added function findTemplateDeclarationEnd to skip template declarations
to reduce duplicate code

* fix travis build
2019-07-07 18:33:33 +02:00
IOBYTE c902c5f688 Fix #9197 (Template name cache: Assertion `tok && tok->str() == ">"' failed.) (#1964) 2019-07-07 10:20:43 +02:00
IOBYTE c4933acb5a Fixed #9147(SymbolDatabase bailout: unhandled code) (#1948)
* Fixed #9147(SymbolDatabase bailout: unhandled code)

* add test for #9183
2019-07-03 08:35:48 +02:00
IOBYTE 5642778206 Fixed #9193 (functionStatic false positive (inconclusive)) (#1943) 2019-07-02 11:40:57 +02:00
IOBYTE bf4e1ef790 template simplifier: consistently handle templates with no arguments (#1939)
this fixes daca boost1.67 crashes
2019-07-01 07:01:14 +02:00
Scott Furry a195477470 Correct Zero/Null as pointer constant (#1938)
Building with enhanced clang warnings indicated a large number of
instances with the warning:

`warning: zero as null pointer constant`

Recommended practice in C++11 is to use `nullptr` as value for
a NULL or empty pointer value. All instances where this warning
was encountered were corrected in this commit.

Where warning was encountered in dependency code (i.e. external library)
no chnages were made. Patching will be offered upstream.
2019-06-30 21:39:22 +02:00
IOBYTE 16788df055 template simplifier: various small fixes (#1916)
* fix adding instantiation of first argument to an instantiation

* add support for function pointer template variables

* fix more cases where templates ending in ">>" are changed to end in "> >"

* fix travis build

* standard types can't be a template parameter name

* remove redundant level == 0 checks

* fix lambda in template variable

* fix a test
2019-06-28 11:14:20 +02:00
IOBYTE 246576fceb Fixed #9178 (Assertion `brackets1.empty() == false' failed on valid C++ code) (#1905)
This fixes a nasty intrinsics related bug causing instantiations that
shouldn't happen.
2019-06-17 21:18:27 +02:00
Paul Fultz II b466415bb4 Fix syntax error in issue 9155 (#1885) 2019-06-15 09:48:22 +02:00
IOBYTE 75720528b0 template simplifier: add 2 new template parameter simplifications (#1884)
* template simplifier: add 2 new template parameter simplifications

int{} -> 0
decltype(int{}) -> int

This fixes reduced test cases like #9153.  I'm not sure they will help
real world code that much.

It was necessary to increase the pass count to 4 to get #9153 completly
simplified.

* relax decltype(type{}) simplification to any type
2019-06-15 09:46:32 +02:00
IOBYTE 2a4b28c267 Fixed #9155 (Syntax error on valid C++ code) (#1880)
Refactored simplifyTemplateAliases to iterate over template type aliases
rather than instantiations. This fixed template type aliases that were
not templates.

Don't instantiate templates in template type aliases. They will get
instantiated once the type alias is instantiated. This required
increasing the template simplifier pass count to 3 so one of the
existing tests continued to work.
2019-06-12 07:44:48 +02:00
IOBYTE 5af8beecf6 template simplifier: specialized member class not recognized causing wrong instantiation (#1876)
Specialized member classes declared outsize the class were not
recognized. This caused the the member class to be instantiated rather
than the specialized class. We already had a test for this but it was
wrong so it went unnoticed.
2019-06-09 08:11:59 +02:00
IOBYTE 7a87786cbc template simplifier: class or typename can't be a name (#1875)
* template simplifier: class or typename can't be a name

* struct can't be a name
2019-06-08 07:27:53 +02:00
IOBYTE ce9fdd181d Add regression test for #9146 (Syntax error on valid C++ code) (#1867) 2019-06-02 10:23:47 +02:00
IOBYTE bee248b2de token simplifier: fix namespace, token link and syntax error support for template type aliases (#1863) 2019-06-01 10:52:29 +02:00
IOBYTE 1e7f5010eb template simplifier: fix expansion of template arguments in default parameter instantiation (#1857) 2019-05-28 21:32:37 +02:00
IOBYTE e8692b012f template simplifier: partial fix for instantiation of templates with type trait parameters (#1855) 2019-05-27 20:51:52 +02:00
Paul Fultz II 312fdf157b Fix issue 9144: Syntax error with type intrinsics (#1852)
* Fix issue 9144: Syntax error with type intrinsics

* Only run when using cpp
2019-05-27 06:54:21 +02:00
Paul Fultz II cb7f925f5e Fix issue 9109: Syntax error for valid C++ code 2019-05-24 10:44:08 +02:00
IOBYTE 5efb23ffff template simplifier: fix instantiation of variadic template with no arguments (#1848)
* template simplifier: fix instantiation of variadic template with no arguments

* fix white space change

* add support for <class...>

* add variadic template flag
2019-05-23 20:53:26 +02:00
IOBYTE 592ff56b90 template simplifier: fix single parameter template with default value (#1842)
* template simplifier: fix single parameter template with default value

* fix derived class with single default argument
2019-05-19 19:19:57 +02:00
Daniel Marjamäki 57c6628732 Revert 'Cleaning up unsimplified templates'. This fix caused problems. 2019-05-16 21:11:04 +02:00
Daniel Marjamäki d58d4273f9 Cleaning up unsimplified templates 2019-05-11 13:00:03 +02:00
IOBYTE baeae95bac template simplifier: fix a template alias TODO test (#1823) 2019-05-06 19:06:46 +02:00
Daniel Marjamäki f6527fcd9b fixed tests, unused templates are removed by default 2019-05-05 19:40:58 +02:00
IOBYTE e786c6b7d4 partial fix for #8663 (Stack overflow with template disambiguator) (#1801)
This fixes simplifyUsing to remove 'typename' and 'template' from type
aliases of the form: using T3 = typename T1::template T3<T2>;

This lets the template simplifier instantiate the type alias which will
then remove the using type alias.

The crash will still happen if there is no instantiation because the
type alias will not be removed.  The type alias is what cppcheck is
crashing on after the template simplifier and that still needs fixing.
2019-04-21 06:46:16 +02:00
amai2012 361fc44005 Adjust more test results for invalid code 2019-04-19 20:53:07 +02:00
IOBYTE 5cdde701ba template simplifier: add minimal template template support (#1779) 2019-04-04 06:07:49 +02:00
IOBYTE 9f3ecdde31 Fixed #9076 (Template Simplifier : template < template <typename> T >) (#1777)
This does not add support for template templates.  It only skips the
template template parameter.
2019-04-03 06:02:38 +02:00
Daniel Marjamäki fbc769266c Fixed #9060 (TemplateSimplifier::templateParameters : var <...>) 2019-03-31 16:29:28 +02:00
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 10fcf731d9 Fixed #9021 (template simplifier: crash in simplifyCalculations) (#1757) 2019-03-25 14:56:51 +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
Armin Müller f4b5b156d7 Typos found by running "codespell" (#1715) 2019-03-01 01:01:39 +01:00