Commit Graph

798 Commits

Author SHA1 Message Date
rebnridgway 42a65c5160 Fix crash bug #8579 (#1238)
* Added declaration for deletePrevious function

* Added definition for deletePrevious function

* Fixed crash from deleteThis invalidating pointers

The crash was caused by deleteThis() invalidating the pointer to a constant variable usage.  This happened when a usage followed an assignment.  This fixes bug #8579.

* Added tokensFront to match tokensBack

This means deletePrevious can set the list's front if necessary.

* Initialised tokensFront in appropriate places

* Switched to using default Token constructor

* Switched to using Token default constructor

* Switched to using default constructor for Token

* Added missing argument to Token constructor

* Changed to use default constructor for Tokens

* Switched to using default constructor for Tokens

* Switched to using default constructor for Token

* Added new test for deleting front Token

Also made sure to use the correct constructor for Token in other tests.

* Syntax error

* Replaced tokensFront and tokensBack with a struct

This decreases the size of the Token class for performance purposes.

* Replaced tokensFront and tokensBack with a struct

* Added tokensFrontBack to destructor

* Reworked to use TokensBackFront struct

Also ran astyle.

* Reworked to use TokenList's TokensFrontBack member

* Reworked to use TokensFrontBack struct

* Reworked to use TokensFrontBack struct

* Reworked to work with TokensFrontBack struct

* Removed unnecessary scope operator

* Added missing parentheses

* Fixed syntax error

* Removed unnecessary constructor

* Default constructor now 0-initialises everything

This is safer for not using a temporary TokensFrontBack object, and doesn't use delegating constructors which aren't supported yet.

* Fixed unsafe null check

* Added missing explicit keyword

* Fixing stylistic nits

Removed default constructor as it has been superseded by the single-argument constructor with a default argument value.
Renamed listEnds to tokensFrontBack.
Fixed if statement that was supposed to be adding safety but would actually cause a crash if tokensFrontBack was null.

* Fixing stylistic nits

Removed default constructor and replaced it with a single-argument constructor with a default value.

* Fixing stylistic nits

Renamed _listEnds to _tokensFrontBack.

* Fixing stylistic nits

Renamed _listEnds to _tokensFrontBack.
2018-05-25 07:15:05 +02:00
IOBYTE ce50df8047 Fix override warnings. (#1234) 2018-05-15 16:37:40 +02:00
IOBYTE 9ee6068e20 Remove duplicate namespace aliases so they don't produce syntax errors. (#1222)
* Remove duplicate namespace aliases so they don't produce syntax errors.

DACA2 results showed new SymbolDatabase syntax errors when duplicate
namespace aliases were simplified improperly. The solution is to remove
them in the tokenizer when found.

* Add tests for deleting namespace aliases at end of token list.

* Use eraseTokens to delete multiple tokens at once.
2018-05-13 08:29:40 +02:00
IOBYTE 8b0b659965 Add support for namespace aliases and C++17 nested namespaces. (#1210)
* Add support for namespace aliases and C++17 nested namespaces.

These are implemented as tokenizer simplifications so changes are not
needed to the tokenizer and symbol database.

* Fix codacy warning.
2018-05-08 06:35:51 +02:00
Daniel Marjamäki 25599a76a7 Handle 'final' specifier better. 2018-04-27 14:57:43 +02:00
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +01:00
IOBYTE 026d8f6859 fix #8284: False positive: "Label 'class' is not used." for anonymous… (#1011)
* fix #8284: False positive: "Label 'class' is not used." for anonymous C++ class

Add support for annonymous derived structures and classes.

* Fix travis build (use findsimplematch).

* Fix bug in simplifyLabelsCaseDefault which was inserting ; in wrong place.
2017-12-05 16:50:04 +01:00
Daniel Marjamäki 71d207c034 Fixed #8226 (Tokenizer: Wrong handling of string literal u"abc") 2017-09-21 13:33:14 +02:00
Daniel Marjamäki f85e43d21f Fixed #8059 (Tokenizer::simplifyWhile0: for loop that modifies local variable) 2017-07-09 22:44:10 +02:00
Daniel Marjamäki 18adb97873 astyle formatting
[ci skip]
2017-05-28 15:56:26 +02:00
Daniel Marjamäki be6e0cbf85 Tokenizer: I dont think its safe to calculate floating point equality comparisons, changing TODO assertion to normal assertion. 2017-05-28 12:34:29 +02:00
Frank Zingsheim aa937e426d Fixed #7849 (Tokenizer: Wrong simplification of floating point equality comparison) 2017-05-28 10:53:50 +02:00
Ayaz Salikhov 28aa939d69 iwyu - include what you use 2017-05-27 04:33:47 +02:00
Daniel Marjamäki 040d2f0012 Use simplecpp lexer in test cases 2017-05-18 21:52:31 +02:00
Daniel Marjamäki bdf16b1157 Tokenizer::simplifyComma: dont simplify comma in '=(struct s){...}' 2017-04-26 20:48:08 +02:00
Simon Martin 487f76cdd1 Ticket #7916: Don't incorrectly simplify return statements involving template instantiations. 2017-02-18 21:14:50 +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
Stefan Weil 57b57428c2 Fix some typos in comments (found by codespell)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-27 11:40:42 +01:00
Daniel Marjamäki 5b377ea2e4 Fixed #7821 (segmentation fault, invalid last token) 2016-11-20 14:15:51 +01:00
Daniel Marjamäki efa3aba32a Remove Tokenizer::simplifyNull() 2016-10-18 21:44:02 +02:00
Daniel Marjamäki d09a8dde57 Improved char literal handling. In the 'normal' tokenlist these should not be simplified to integer literals. 2016-10-12 10:20:24 +02:00
Robert Reif f1b5ac30a7 Fixed 7698 (FP syntaxError with enum (1.75 regression)) 2016-08-19 19:09:52 +02:00
PKEuS 0afecd8fee Do not simplify name "CALLBACK" away on non-windows platforms (#7554) 2016-07-16 10:43:28 +02:00
PKEuS a808549af0 Support lambdas in simplifyCompoundAssignment (#7571) 2016-07-08 20:10:33 +02:00
Daniel Marjamäki 1caa79c45f Tokenizer::simplifyPointerConst: Remove simplification. Its purpose was to avoid crash for garbage code (#6900). This fixes #7485. 2016-05-08 21:32:34 +02:00
Daniel Marjamäki dc2a92263a Fixed #7426 (RFC: time to replace simplifyEnum?) 2016-04-22 06:02:54 +02:00
Daniel Marjamäki 5fef7cc050 Fixed #4973 (wrong enum simplification of shadow struct variable) 2016-02-07 15:15:20 +01:00
Daniel Marjamäki 6c1012a8d6 Fixed #4625 (wrong enum simplification in shadowed enum declaration) 2016-02-07 13:51:03 +01:00
Daniel Marjamäki f781f13997 Fixed #6806 (wrong enum simplification in initialization list) 2016-02-07 13:34:03 +01:00
PKEuS f8bf2b5776 Removed rest of variableHidingTypedef and variableHidingEnum checking 2016-02-06 20:55:41 +01:00
amai2012 d25258359a #7251 Remove checks variableHidingTypedef and variableHidingEnum 2016-02-06 15:37:58 +01:00
PKEuS cc8c498ebb Moved a few tests to testgarbage.cpp 2016-02-04 09:10:20 +01:00
Daniel Marjamäki 414bdc30a9 Fixed #7276 (VarId: Missing varId in template class constructor initialization lists) 2016-01-10 22:10:49 +01:00
Daniel Marjamäki b3208fb4b3 Fixed #7211 (False positive: Finding the same expression on both sides of an operator (enumconstant == 0)) 2016-01-10 11:21:43 +01:00
Daniel Marjamäki cd89e68f60 Fixed #6931 (noexcept and override qualifiers plus less than operator results in a syntax error) 2016-01-03 12:22:07 +01:00
Daniel Marjamäki 95009a4630 Merge pull request #745 from lanurmi/2016_ad
Update copyright year to 2007-2016.
2016-01-01 22:57:19 +01:00
Daniel Marjamäki f5715c1496 Rename Unspecified platform type to Native 2016-01-01 16:39:41 +01:00
Lauri Nurmi 996c9244d8 Update copyright year to 2007-2016. 2016-01-01 15:34:45 +02:00
Daniel Marjamäki 8171154e12 Fixed #7230 (Confusing code snippet in error message) 2015-12-31 01:15:49 +01:00
Daniel Marjamäki 15ecb26a6c Tokenizer: Moved simplifyAssignmentInFunctionCall from simplifyTokenList1 to simplifyTokenList2 2015-12-28 13:58:41 +01:00
Daniel Marjamäki 5fabe66ff7 simplifyCalculations: better handling of && and || in conditions (#4931) 2015-11-28 15:00:41 +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 4abc0b7c1f Partial fix for #4931 (Wrong calculation of constants (simplifying: +,<<,% operations)) 2015-11-20 16:09:47 +01:00
Daniel Marjamäki 0f9d90d2be Changed Copyrights. Removed my name. 2015-11-18 20:04:50 +01:00
PKEuS 3f255e7685 Use Library information in Tokenizer::sizeOfType() 2015-11-15 14:37:02 +01:00
Daniel Marjamäki f7a7a8a95c Fixed #6934 (False positive returnLocalVariable - assigning local array to function argument) 2015-11-07 15:07:26 +01:00