Commit Graph

2448 Commits

Author SHA1 Message Date
Paul Fultz II 65af02f0cf Fix crash with lambda capture (#1960) 2019-07-06 10:46:17 +02:00
versat 57d44f1362 astyle formatting
[ci skip]
2019-07-05 14:00:59 +02:00
Paul Fultz II 5801fb26f0 Fix syntax error with lambda captures (#1954)
* Fix syntax error with lambda captures

* Fix issue when using initializer in lambdas
2019-07-05 12:26:01 +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
Daniel Marjamäki f84dcc4738 astyle formatting
[ci skip]
2019-07-03 08:29:47 +02:00
Paul Fultz II 8f4cb36e1e Check for more garbage code (#1949)
* Check for garbage commas

* Find garbage dot operator
2019-07-03 08:28:24 +02:00
Daniel Marjamäki 4d81b77249 Fixed Cppcheck warning, condition is always false 2019-06-30 18:43:55 +02:00
Daniel Marjamäki d9a9743b8a Revert "Calculate token scopes in advance rather than as the tokenlist is iterated (#1882)"
This reverts commit 0d7836f3a0.
2019-06-30 09:12:18 +02:00
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
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
Daniel Marjamäki beea7fa8d2 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
Daniel Marjamäki d636a83f8b Tokenizer: Assign Token 'progressValue' before returning so they are set properly when the checks are run 2019-06-21 08:43:19 +02:00
IOBYTE c0d8990e8b Fix up a few more cases where templates ending in ">>" should be changed to end in "> >". (#1883) 2019-06-13 13:37:55 +02:00
IOBYTE f02e45bf3d fix syntax error for std::literals::complex_literals::operator""if (#1870) 2019-06-05 10:15:22 +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
Paul Fultz II 33130bdff6 Fix issue 9145: Syntax error on valid C++14 code (#1860) 2019-05-31 08:05:01 +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 61935802d1 Fix issue 9141: Syntax error (#1853) 2019-05-27 06:50:43 +02:00
Daniel Marjamäki de4a33167d astyle formatting
[ci skip]
2019-05-21 10:43:33 +02:00
Paul Fultz II 9949ae1b4f Fix issue 8995: False Positive: Redundant code with initializer-list created object (#1844) 2019-05-21 10:40:36 +02:00
Paul Fultz II 9055682fdc Fix synax error in issue 9057 and 9138 (#1843) 2019-05-21 08:47:10 +02:00
Paul Fultz II ce96ec2773 Fix issue 9136: Syntax error on valid C++14 code: createLinks2() failed 2019-05-19 19:06:12 +02:00
Paul Fultz II 8cbd9b03aa Fix issue 8890: AST broken calling member function from templated base class (#1836)
* Fix issue 8890: AST broken calling member function from templated base class

* Format

* Check for double bracket

* Add test to createLinks2

* Remove extra test

* Reduce test case for links
2019-05-19 10:05:34 +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 34cf62452e Change approach for Tokenizer::createLinks2: assume that <> should be linked 2019-05-16 20:50:56 +02:00
Daniel Marjamäki 0144db2490 Fixed 'Syntax Error' when < link is not set properly 2019-05-15 21:34:56 +02:00
Daniel Marjamäki 21ec78d8a1 Fix typo: %stype% => %type% 2019-05-15 09:06:27 +02:00
Daniel Marjamäki 79bb22f038 Fixed #9131 (Tokenizer::createLinks2; using std::list; list<config_option*> stack;) 2019-05-14 20:30:02 +02:00
Daniel Marjamäki 27fad38e00 Fixed #9084 (Tokenizer::setVarId: Same varid for member variable and argument, unknown template type) 2019-05-12 09:10:37 +02:00
Daniel Marjamäki 4d9b1e6c3d Fixed #9094 (Tokenizer::createLinks2 problem with 'x%x<--a==x>x') 2019-05-11 19:11:40 +02:00
Daniel Marjamäki d58d4273f9 Cleaning up unsimplified templates 2019-05-11 13:00:03 +02:00
IOBYTE eade2bb2c2 Add support for simplifying user defined literal operator. (#1827) 2019-05-09 09:52:18 +02:00
Daniel Marjamäki f6527fcd9b fixed tests, unused templates are removed by default 2019-05-05 19:40:58 +02:00
IOBYTE 505b7f7ebd Fixed #9110 (Syntax error on valid C++ code) (#1813) 2019-04-29 15:17:37 +02:00
Daniel Marjamäki aaf1af6736 Fix Cppcheck passedByValue warning 2019-04-28 07:58:47 +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 28bc3cad92 #8913 SIGSEGV in CheckUnusedVar::checkFunctionVariableUsage - C++/CLI code 2019-04-19 13:55:25 +02:00
IOBYTE 7799ed4243 Fixed #8889 (varid on function when using trailing return type.) (#1800)
* Fixed #8889 (varid on function when using trailing return type.)

Don't set varid for trailing return type.

* Add a test for #9066 (Tokenizer::setVarId: varid set for trailing return type)
2019-04-18 20:22:39 +02:00
Daniel Marjamäki b1b5b27b4e addons: write column in error message(s) 2019-04-13 10:22:13 +02:00
Daniel Marjamäki b04d1815ed Add -std=c++17 and allow semicolon in 'if ()' 2019-04-12 09:10:25 +02:00
Daniel Marjamäki f6b410b469 GUI: add setting for 'checkHeaders', 'checkUnusedTemplates' and 'maxCtuDepth' to project 2019-04-10 16:49:24 +02:00
Daniel Marjamäki 7610513c49 Fixed #9090 (Do not simplify standard functions) 2019-04-08 19:00:46 +02:00
Daniel Marjamäki 83106d5827 Unused templates: Remove unused template function with variadic arguments 2019-04-07 08:37:04 +02:00
Rikard Falkeborn d23e987941 Fix CheckInternal warnings (#1790) 2019-04-06 06:55:46 +02:00
Daniel Marjamäki 73433c2961 Syntax error: Clarify a syntax error in audacity 2019-03-31 10:46:59 +02:00
Daniel Marjamäki b30d463baf Fix wrong syntax error 2019-03-31 09:34:19 +02:00
IOBYTE 22f01f035c Fixed #9042 (Another `using BOOL` type breach) (#1765) 2019-03-27 21:42:50 +01:00
Daniel Marjamäki 0f6a90c595 Fixed #9069 (crash on invalid code: ' x= y{ } name5 ')
Credit to OSS-Fuzz for reporting this!
2019-03-27 18:17:11 +01:00
Frank Zingsheim 574b77cf1f Fixed: FP return reference to thread_local variable (#1758) 2019-03-27 12:22:53 +01:00
Daniel Marjamäki c77f31319d Fix crash when checking re2c textfile 2019-03-26 20:51:41 +01:00