Commit Graph

312 Commits

Author SHA1 Message Date
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
Daniel Marjamäki 5d7518aa57 simplifyCalculations: Improved handling of casts (#4899) 2013-09-03 06:27:11 +02:00
Daniel Marjamäki 2a78db4c06 Refactoring Token::findClosingBracket. 2013-07-31 10:30:20 +02:00
Simon Martin eb3bf571be Avoid divisions by zero when simplifying numeric calculations. 2013-07-28 12:32:18 +02:00
Daniel Marjamäki 722bfe7197 Fixed #4553 (Wrong calculation of known values) 2013-06-14 18:51:52 +02:00
PKEuS 876e9c0039 Fixed issue on C++11 right angle brackets (#4832) 2013-06-12 13:43:29 -07:00
Frank Zingsheim 42068a3d60 Fixed #4767 (segmentation fault in expand template) 2013-05-01 13:28:01 +02:00
Daniel Marjamäki c3d1274db3 Reverted 'simplify NOT' since there are problems related to signedness of numeric values. 2013-04-24 06:32:34 +02:00
Ettl Martin cb343bd718 fixed typo in reporting Error 2013-04-16 11:25:45 +02:00
Daniel Marjamäki 9ad39ca4c0 Fixed #4544 (Crash with this line : class CD : public CC< class CB< CA > >) 2013-04-12 16:38:12 +02:00
Daniel Marjamäki e8fbd39efd Templates: better handling of 'X<class Y>' template instantiations. Ticket: #4544 2013-04-11 18:58:39 +02:00
Ettl Martin 33cfc1a52e fixed #4726: simplify bitwise Not (~ %num%) 2013-04-11 09:16:40 +02:00
Daniel Marjamäki 4abe1c0bac Fix Cppcheck message 2013-04-07 19:33:46 +02:00
Daniel Marjamki cd770fb106 Fixed #4310 (False positive 'boolean result in bitwise' message in template class (was #3818)) 2013-04-07 16:48:42 +02:00
Daniel Marjamäki 369e80b021 Fixed #4465 (syntax error on valid C++ source file) 2013-03-14 18:52:22 +01:00
PKEuS 0105f8223c Simplified several Token::Match/simpleMatch calls when match string consists of a single pattern
Fixed two CheckInternal error messages
2013-03-01 03:42:04 -08:00
PKEuS f899e6ca30 Changed behaviour of %op% pattern accordingly to changes to Token::isOp(). Added %cop% as replacement for old %op% 2013-03-01 02:43:59 -08:00
PKEuS 670c4de8a9 Changed behaviour of Token::is*Op() functions:
- Rename Token::isOp() to Token::isConstOp() (indicating that the operator does _not_ modify the input variables)
- Create new Token::isOp(), returning true also for ++, -- and assignment operators
- Make Token::isExtendedOp() returning also true for all assignment and ++/-- operators
2013-02-28 12:50:29 -08:00
Daniel Marjamki 2a660fa3b4 Tokenizer: Fixed removeCast bug. Don't simplify (A)&b to A&b if A might be a type. Related with ticket: #4439 2013-02-16 16:58:36 +01:00
Andrew C. Martin bd0d9b9639 fix misspellings & gcc v3.4.6 warnings
1.  fix typos / misspellings
 - Fix misspelling within comments, variable/function names, stdout messages
 - changes the name of an error code: ```stlBoundries``` changed to ```stlBoundaries```.  Alias old name (```stlBoundries```) to the new one.

2.  fix gcc v3.4.6 32bit & 64bit warnings

 - fixes gcc v3.4.6 warnings, except for those in tinyxml and "-Wmissing-declarations" makefile warnings
 - in Preprocessor::handleIncludes(), replace a ```vector <bool>``` with ```stack<bool>``` (see ```vector<bool>``` warning below).
   - this is the only ```vector<bool>``` in the codebase
 - ```vector <bool>``` is actually a case of template specialization, and is not recommended, according to the following links:

http://stackoverflow.com/q/6461487
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2160.html
http://stackoverflow.com/q/670308

 - in the codebase before and after this change, testrunner SEGVs in a number of places on gcc v3.4.6, including ```Check::~Check()```, among others
   - fc42fc95 fixes this particular runtime issue for DJGPP & __sun
2013-02-09 23:43:09 -07:00
Andrew C. Martin 4a73c93750 Fix compiler warnings and comment/string typos
- fix g++ warning:

> lib/checkother.cpp:3779: warning: comparison between signed and unsigned integer expressions

 - fix suncc warning (see [everything2](http://everything2.com/title/C%252B%252B%253A+static+extern+%2522C%2522)):

> "lib/checkmemoryleak.cpp", line 578: Warning (Anachronism): Formal argument __compar of type extern "C" int(*)(const void*,const void*) in call to bsearch(const void*, const void*, unsigned long, unsigned long, extern "C" int(*)(const void*,const void*)) is being passed int(*)(const void*,const void*).

- prefer empty() / isEmpty() over "size() > 0" (cases not caught by stlSize)

- fix word misspellings (mostly comments, a few output lines)

  - Parenthesis => Parentheses (both variations were used in the codebase)

  - fix typo and wording ("never alwayw") in gui/test/data/benchmark/simple.cpp's CheckOther::unsignedPositive():

```
-  "An unsigned variable will never alwayw be positive so it is either pointless or "
+  "An unsigned variable can't be negative so it is either pointless or "
```
2013-01-16 07:37:07 -07:00
Thomas Jarosch 33619de072 Revert "Change location of %op% operator in multicompare"
It's no longer needed with the proper fix for Token::Match().

This reverts commit 8b2adf1391.
2013-01-09 17:06:04 +01:00
Thomas Jarosch 8b2adf1391 Change location of %op% operator in multicompare
When the %op% operator is the first element
of a multicompare, it properly executes Token::isOp().
Otherwise it uses it's "internal implementation".

Workaround inspired by Edoardo Prezioso.
2013-01-08 20:26:48 +01:00
Daniel Marjamäki 70059c06de Fixed #4456 (std::string::compare(char const*) crash) 2013-01-03 08:44:32 +01:00
Reijo Tomperi 5d5f7085bf Updating year 2012 -> 2013 to .cpp and .h files and man page. 2013-01-01 18:29:08 +02:00
Edoardo Prezioso 5101f3c029 Use the new pattern: '%comp%' where possible.
Change also the description comment of the Token::Match by adding the new pattern and the forgotten '%op%'.
2012-12-01 01:31:35 +01:00
Edoardo Prezioso 9556634ee7 Revert 1c0617c504. 2012-11-07 18:34:25 +01:00
Edoardo Prezioso 1c0617c504 change some Token::Match patterns used in code:
replace '||' with '%oror%', where possible.
2012-11-07 02:23:09 +01:00
PKEuS e44ee280bc Fixed handling of pointers to functions in namespace as template parameters (#4172) 2012-11-04 11:15:03 +01:00
PKEuS 9cb9388e49 Fixed handling of pointers in templates (#4319) 2012-11-04 10:49:25 +01:00
Edoardo Prezioso 99777671e5 Related to commit 11b00470637ed119140fb6257a5552f13f010d85: fix copy-paste mistake. 2012-10-24 03:27:15 +02:00
Edoardo Prezioso 11b0047063 Fix some clang analyzer messages.
CheckMemoryLeak: two redundant assignments, should be clarified;
TemplateSimplifier: same;
Tokenizer: same.
2012-10-24 03:17:56 +02:00
Daniel Marjamäki be174d6266 TemplateSimplifier: Fixed bad pattern that was detected by CheckInternal and pointed out by edward-san. The handling of recursive templates is better now. 2012-10-14 19:48:53 +02:00
Daniel Marjamäki 0ff8105c71 Fixed #4074 (Internal error. Token::Match called with varid 0) 2012-09-24 06:44:51 +02:00
Edoardo Prezioso 406483b618 Fixed valgrind error in #3953 , but there's still the bad enum problem. 2012-09-20 21:07:37 +02:00
Daniel Marjamäki c3cb6202ed Fixed #4172 (TemplateSimplifier: Handle 'A<&f> x' template instantiation) 2012-09-19 16:10:13 +02:00
Ettl Martin 3905f4ad7d fixed #4169 semgentation fault (invalid code); Applied patch from amai and added a unittest. 2012-09-19 11:03:40 +02:00
PKEuS e136b59f21 Removed redundant "simplifyTemplates" prefix (information already in class name) from function names in TemplateSimplifier. 2012-09-12 20:46:56 +02:00
PKEuS d28ceff449 Simplified code in templatesimplifier.cpp 2012-09-12 20:41:10 +02:00
Daniel Marjamäki 64faa780fe Fixed #4087 (div by zero check is invalid for floats) 2012-09-11 16:50:42 +02:00
Daniel Marjamäki 7acb04b44c Tokenizer: improved simplification of numeric calculations 2012-09-09 16:22:39 +02:00
PKEuS a4b5824dec New internal check: checkRedundantNextPrevious().
Fixed findings by new internal check
2012-09-07 12:36:40 +02:00
PKEuS e2bc381550 Don't shift by a negative value in TemplateSimplifier::simplifyNumericCalculations() 2012-09-06 17:02:20 +02:00
PKEuS 9fa7e15fb4 Fixed setVarId for nested templates (#3976, #3769) and support C++11 right angle brackets in TemplateSimplifier::templateParameters() 2012-08-26 09:49:38 +02:00
Daniel Marjamäki 9ffc7f4c2d Fixed #3964 (False positive: Expressions in array declarations are not simplified 'char mac[17+1];') 2012-08-20 18:10:32 +02:00
Daniel Marjamäki e534ee0426 Fixed #3706 (cppcheck 1.53 hangs when processing a certain template with specializations) 2012-08-13 16:17:33 +02:00
PKEuS 2ac2674f67 Fixed #4000, added support for function prototypes to TemplateSimplifier::templateParameters() 2012-08-12 05:19:56 -07:00
Daniel Marjamäki 6ff1760c72 TemplateSimplifier: Improved handling of unknown inner template instantiation inside template instantiation (#3818) 2012-08-09 17:19:36 +02:00
Daniel Marjamäki 4ec12209dc TemplateSimplifier: Fixed wrong match when inner template parameters are wrongly counted (#3818) 2012-08-08 06:43:41 +02:00
Daniel Marjamäki 445fd4e6aa Fixed #4010 (error (cppcheckError): Internal error. Token::Match called with varid 0) 2012-08-05 17:11:39 +02:00
Daniel Marjamäki 2c10e9a6ca TemplateSimplifier: Removed unused function 2012-07-29 16:14:26 +02:00
Daniel Marjamäki 435340b463 Fixed #3814 (false positive: missing constructor) 2012-07-29 16:01:05 +02:00
PKEuS f5e5d59562 Refactorizations:
- Removed redundant newlines at the end of test cases
- Make use of STL algorithms instead of own implementations of std::replace and std::remove+string::erase
- Removed unused variable (found by cppcheck)
- Prefer postfix increment (found by cppcheck)
2012-07-24 12:21:05 -07:00
Edoardo Prezioso fae40c4782 Change every C version of 'size_t' to C++ 'std::size_t'. 2012-07-09 13:30:18 +02:00
Daniel Marjamäki 5174f7ff5e Fixed #3723 (Preprocessor evaluation order) 2012-06-14 21:47:03 +02:00
Daniel Marjamäki 0bb0fdedc2 Fixed #3747 (False 'boolean result in bitwise' message with 'mask' enums) 2012-05-16 18:48:33 +02:00
PKEuS 28f6e2f4a9 Resolved cyclic dependency between Tokenizer and TemplateSimplifier 2012-05-06 01:38:55 -07:00
PKEuS 1a5fbd61d2 Splitted class TokenList from Tokenizer 2012-05-05 09:33:26 -07:00
Edoardo Prezioso 6fd6f0998b Improvement to 5b8840c6b02bd648dc2b75e60145474ae12f8e67: handle also 'const struct|union' types as template parameters. 2012-04-27 20:51:55 +02:00
Daniel Marjamäki 5b8840c6b0 Fixed #3764 (Tokenizer::setVarId: no varid for templated variables with const/struct/union types) 2012-04-27 18:02:07 +02:00
PKEuS 30e8e389a7 Fixed #2980 2012-04-26 10:58:35 +02:00
PKEuS dd5e9aa454 Make use of recently implemented Token::type() functionality 2012-04-25 09:56:07 +02:00
PKEuS 8cbed66089 Changed relationship between templatesimplifier and tokenizer:
- Pass a tokenizer to templatesimplifier to reduce code duplication (Make use of Tokenizer::reportError; remove redundant TemplateSimplifier::addtoken2) and amount of arguments passed to functions

Removed ctor and dtor implementation from TemplateSimplifier: This class shouldn't be instanciated.
2012-04-23 20:45:36 +02:00
PKEuS cb7537418a Make use of Token::findClosingBracket in templatesimplifier.cpp 2012-04-18 16:16:06 +02:00
Daniel Marjamäki ea148173bb TemplateSimplifier: Allow that template parameter starts with :: 2012-04-15 18:15:36 +02:00
Daniel Marjamäki 7669abb170 Tokenizer::setVarId : Starting to rewrite Tokenizer::setVarId. The purpose of the rewrite is to make this function faster. 2012-04-15 11:47:22 +02:00
PKEuS 62d5069387 Fixed #3722: Handle associative law correctly for operator* 2012-04-13 11:55:09 +02:00
PKEuS 05a6638468 Removed code that became unnecessary after 7be01da8e9.
Fixed wrong comment in cli/pathmatch.h (doxygen warning)
2012-04-13 11:08:46 +02:00
Daniel Marjamäki 68e6511c87 Fixed #3532 (false positive : missing constructor) 2012-03-31 11:30:26 +02:00
PKEuS 4f1f6e1824 Improved simplification of calculations:
- Use more generic patterns
- Look on operator precedence more consequently
-> Made a TODO test case from a test case that worked previously, because the calculation is simplified so that the problem isn't detected any more.
Changed comment "Coding style checks" to "Checks", because it didn't fit
2012-03-27 21:29:50 +02:00
August Sodora e0bee0e037 Fixed #3567 (False positives in boolean expressions) 2012-03-07 20:31:23 +01:00
Daniel Marjamäki bfb4dd6425 Fixed #3529 (False 'Boolean result is used in bitwise operation' in a template) 2012-02-18 08:51:09 +01:00
PKEuS 36479499e7 - Solved FIXME: Made detection of code that is no pointer-dereference more robust, uncommented code (checknullpointer.cpp)
- Removed more indendation level counters
- Make use of symbol database more often
- Other refactorizations
2012-01-21 19:55:32 +01:00
PKEuS 96ae010e48 - Correctly set Scope::function variable in symboldatabase
- Refactorizations
- Fixed some cppcheck warnings
2012-01-21 10:08:09 +01:00
Daniel Marjamäki a6d96f5b72 Fixed #3496 (false positive: syntax error) 2012-01-15 14:33:53 +01:00
Daniel Marjamäki d891d1ce5d Fixed segfault in TestTokenizer::cpp0xtemplate3 2012-01-15 12:14:47 +01:00
Daniel Marjamäki 7e3735988d TemplateSimplifier : Fixed bug in recent commit. 2012-01-15 11:58:07 +01:00
Edoardo Prezioso 6a248c35b5 Fixed ticket #3512 (segmentation fault of cppcheck ( 1 *p = const)) 2012-01-14 00:43:58 +01:00
Daniel Marjamäki 0648b3ed5e Fixed #3504 (segmentation fault of cppcheck) 2012-01-13 07:57:12 +01:00
Reijo Tomperi be7691c7b4 Refactoring: Move rest of the template simplification into TemplateSimplifier
simplifyCalculations() was temporarily moved into TemplateSimplifier also, it should be moved to a better place.
2012-01-09 21:33:11 +02:00
Reijo Tomperi eda04ad906 Refactoring: Move template code into templatesimplifier: simplifyTemplatesExpandTemplate() 2012-01-05 22:45:19 +02:00
Reijo Tomperi 0369681a2c Refactoring: Move template code into templatesimplifier: simplifyTemplatesGetTemplateNamePosition() 2012-01-03 23:49:50 +02:00
Reijo Tomperi ac290b1a8a Refactoring: Move template code into templatesimplifier: simplifyTemplatesUseDefaultArgumentValues(), simplifyTemplatesInstantiateMatch() 2012-01-03 23:35:06 +02:00
Reijo Tomperi 16fb1801e1 Refactoring: Move template code into templatesimplifier: simplifyTemplatesGetTemplateDeclarations(), simplifyTemplatesGetTemplateInstantiations() 2012-01-02 23:05:27 +02:00
Reijo Tomperi 37269d0c28 Refactoring: Move template code into templatesimplifier: simplifyTemplatesExpandSpecialized() 2012-01-02 22:53:13 +02:00
Reijo Tomperi 8084bc80fc Refactoring: Move template code into templatesimplifier: removeTemplates() 2012-01-02 22:46:43 +02:00
Reijo Tomperi e9071a8bb6 Refactoring: Move code into templatesimplifier: templateParameters() 2012-01-02 22:43:38 +02:00
Reijo Tomperi d26bcfe8d5 Refactoring: Move code into templatesimplifier 2012-01-02 22:37:32 +02:00
Reijo Tomperi aa927d5aa3 Refactoring: Add new file lib/templatesimplifier.cpp
The plan is to move template simplification into this new class to take some lines from 10 000 line tokenizer.
2012-01-01 22:55:05 +02:00