Commit Graph

290 Commits

Author SHA1 Message Date
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