Commit Graph

490 Commits

Author SHA1 Message Date
Daniel Marjamäki cb8ee825fd AST; remove special handling of semicolon in if|switch as Tokenizer will simplify the code instead 2021-05-03 10:43:14 +02:00
dummyunit ac505afe69
Fixed #9729 (AST broken: lambda with noexcept keyword) (#3243)
The previous fix for the issue (43b58dbc9e) didn't seem to actually fix
it because it added a check for noexcept without a condition, but when
AST is created noexcept always has a condition due to simplification
from "noexcept" to "noexcept(true)" in Tokenizer::simplifyKeyword().
The issue from the ticket couldn't be reproduced neither on 43b58dbc9e
nor on the previous commit, so it is hard to tell whether the fix was
effective or not.

The issue appeared again after a refactoring of AST code in ac67049661.
Test added with the original fix was unable to catch that because it
used testAst() helper function which skips most simplification steps.

To fix the issue we now check for noexcept with a condition and add a
proper regression test that:
1. Uses tokenizeAndStringify() to ensure that all simplifications are
   performed before AST is created.
2. Parses the code snippet from the ticket, as having "if (cond)" is
   crucial to reproducing the original issue (internalAstError).

Also fix AST creation for lambdas that have both constexpr and mutable
keywords.
2021-05-02 21:34:28 +02:00
Daniel Marjamäki d2d2124238 Revert "Clang import; This experimental feature didn't "take off" much. After a lot of work we are still far fram the goal. I remove it now but don't rule out completely that it could ever be added again."
This reverts commit 207361b174.
2021-04-30 16:47:02 +02:00
Daniel Marjamäki 4f43dbf954 Parser; fixed ast and auto type deduction for c++17 braced init lists 2021-04-25 10:38:33 +02:00
Daniel Marjamäki a41d8b436e Fix testrunner 2021-04-24 14:07:26 +02:00
Daniel Marjamäki c9dc92c266 Parser; C++20 for loop with initialization expression 2021-04-24 11:47:51 +02:00
Daniel Marjamäki 26c0945309 Handle c++20 spaceship operator 2021-04-22 19:15:22 +02:00
Daniel Marjamäki 207361b174 Clang import; This experimental feature didn't "take off" much. After a lot of work we are still far fram the goal. I remove it now but don't rule out completely that it could ever be added again. 2021-04-21 18:59:48 +02:00
Daniel Marjamäki 42437277dc Update Copyright year 2021-03-21 20:58:32 +01:00
Oliver Stöneberg ac7647fcd8
some self-check suppression cleanups (#3032) 2021-01-09 20:32:38 +01:00
orbitcowboy f1688667a5 Running astyle [ci skip] 2020-12-27 12:38:21 +01:00
Daniel Marjamäki d024eb3ee0 Fixed #10051 (AST: Wrong ast for function call with initializer list) 2020-12-26 18:33:54 +01:00
IOBYTE 6103da59be
add column number to TokenList::addtoken (#2939) 2020-12-08 10:34:23 +01:00
Daniel Marjamäki 58af3c7ad7 Suppress Cppcheck false positive 2020-12-04 19:37:58 +01:00
Daniel Marjamäki c69bfbf495 AST: Fixed ast for multidimensional array initialisation 2020-12-02 07:38:21 +01:00
Daniel Marjamäki af26697ceb AST: Generate proper AST for 'f = []() -> foo&& {}' 2020-11-28 06:53:46 +01:00
Daniel Marjamäki b4db52bf61 Fixed #9860 (wrong ast for placement new 'new ( uBAR ? uBAR : sizeof ( T ) ) T') 2020-11-23 22:03:50 +01:00
Daniel Marjamäki 22d6160624 Improve handling of decltype 2020-11-16 20:11:26 +01:00
Daniel Marjamäki 7878eb2512 AST: Do not generate AST for decltype 2020-11-15 16:47:36 +01:00
Ken-Patrick Lehrmann 7c3afa0b36
9955: Fix ast when throwing a cast (#2900)
```
throw (std::string)"Error: " + strerror(errnum);
```
would result in a broken ast:
```
throw
`-::
  |-std
  `-string
```
instead of
```
throw
`-+ 'signed char *'
  |-( 'container(std :: string|wstring|u16string|u32string)'
  | `-"Error: " 'const char *'
  `-( 'signed char *'
    |-strerror
    `-errnum 'signed int'
```
2020-11-15 10:37:29 +01:00
Daniel Marjamäki 26e6eed189 Revert "AST: Adjust AST for variable declaration 'char var[] = str;'"
This reverts commit 376860f796.
2020-11-01 11:41:41 +01:00
Daniel Marjamäki 376860f796 AST: Adjust AST for variable declaration 'char var[] = str;' 2020-10-31 17:05:42 +01:00
Daniel Marjamäki 4eb829933e Tokenizer: Fixed unwanted unknownMacro warning for decltype 2020-10-27 09:08:13 +01:00
Daniel Marjamäki c3517924d0 Clang import testing: Compare AST 2020-10-04 11:27:31 +02:00
Daniel Marjamäki 2748201d73 Fixed #9782 (Segmentation fault due to broken AST) 2020-09-27 20:41:09 +02:00
Daniel Marjamäki 0ec77879ea Fix crash in createAST when checking wiggle in daca@home 2020-09-26 19:22:24 +02:00
Daniel Marjamäki c563944fdd astyle formatting 2020-09-20 20:14:30 +02:00
shaneasd 53a0760fdf
Improve ast generation for templated function parameters (#2803) 2020-09-14 18:44:50 +02:00
Paul Fultz II ac67049661
Fix issue 9858: Token::astOperand1() cyclic dependency on valid C++ code (#2784) 2020-09-07 10:54:32 +02:00
Paul Fultz II cc2bc74084
Track lifetime for lambdas with explicit capture (#2776) 2020-09-05 07:56:01 +02:00
Daniel Marjamäki 2bb73840fc astyle formatting 2020-08-23 17:17:33 +02:00
Daniel Friedrich f413c9cad8 Improve handling of decltype( in for loops
Simplify pattern macht and token selection

Improve handling of decltype( in for loops
2020-08-17 20:52:14 +02:00
Daniel Marjamäki 7e65b561f0 AST: Fix ast for 'for ((..initexpr..);;)' 2020-07-19 11:10:38 +02:00
Daniel Marjamäki 9b5986505e AST; Improved ast for variable declaration with assignment 2020-06-22 08:34:31 +02:00
Ken-Patrick Lehrmann 7ddb7aef7d 8526: Fix ast construction for ternary operator
This tries to decide a bit more properly when ':' can be part of a
ternary operator. More precisely, there are some times when we want to
delay the construction of the ast for ':', so that it is place
accordingly to the matching '?'.

Typically, this fixes an issue with
`return val < 0 ? throw 1 : val;`,
where the ast for ':' would be constructed during as part of the
`throw`, and the ast for `?` would be invalid.

This patch is a bit of a hardcode, stating that we don't expect ':'
inside a throw, unless there is a complete ternary operator in there
(there can't be a range based for loop, a case in a switch). When we
reach ':', we know we are and the end of the `throw`.
2020-06-14 18:57:18 +02:00
Ken-Patrick Lehrmann 4023a487ff 9768: Fix ast with throw in the middle of return
```
int f(bool x)
{
    return x ? 0 : throw 0;
}
```

The `throw` part was not included in the ast, leading to an invalid
ternary operator.
2020-06-14 14:49:10 +02:00
Daniel Marjamäki d31d778bf4 Fixed #9533 (Syntax Error: AST broken, 'for' doesn't have two operands incrementing pointer in initializer) 2020-06-09 20:57:00 +02:00
Ken-Patrick Lehrmann 084529575f
Skip ast validation inside template (#2661) 2020-05-23 21:11:08 +02:00
Oliver Stöneberg 37bc0483a4
made check.h less heavy (#2633) 2020-05-23 07:16:49 +02:00
Daniel Marjamäki 43b58dbc9e Fixed #9729 (AST: lambda with noexcept) 2020-05-22 11:29:10 +02:00
Daniel Marjamäki ac1ceb85b6 AST: improved AST when expression starts with %char% or %str% 2020-05-22 09:35:55 +02:00
Daniel Marjamäki ffdf13fcdb AST: A little code cleanup 2020-05-22 08:48:06 +02:00
PKEuS f6788c0472 Fixed Token::isKeyword: Actually set this flag to a reasonable value in all code paths 2020-05-19 13:47:25 +02:00
PKEuS c9d8f607df Optimization: Reduced peak memory usage (30% in my test case) by immediately deleting simplecpp::TokenList while creating the cppcheck TokenList. 2020-05-19 12:08:17 +02:00
Daniel Marjamäki 259724d6e3 astyle formatting
[ci skip]
2020-05-18 19:53:35 +02:00
shaneasd 7bfd686f04
Fix #9700 duplicateBranch false positive from missing scope operator :: in ast (#2646) 2020-05-18 19:31:13 +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
Zorgovskiy 08fc956990
Fixes issue #9664 (#2614) 2020-04-20 08:59:35 +02:00
Daniel Marjamäki 3c56ccc33f Fixed #9531 (Syntax Error: AST broken, 'for' doesn't have two operands.) 2020-04-19 17:00:22 +02:00
Oliver Stöneberg 2c1e36e63e
cleaned up includes based on include-what-you-use (#2600)
* cleaned up includes based on include-what-you-use

* check.h: trying to work around Visual Studio 2012 bug

* fixed Visual Studio compilation
2020-04-13 13:44:48 +02:00
Daniel Marjamäki e0c8118c02 Fixed crash in AST 2020-04-09 17:42:51 +02:00
Paul Fultz II 40e1e82a65
Fix issue 9644: Token::astOperand1() cyclic dependency on valid C++ code (#2590)
* Remove check for lambda

* Add test case
2020-04-04 10:55:31 +02:00
Paul Fultz II 58e3f19ed8
Fix issue 9662: AST broken, ternary operator missing operand(s) on valid C++ code (#2589)
* Fix issue 9662: AST broken, ternary operator missing operand(s) on valid C++ code

* Add test for issue 9537
2020-04-03 10:04:10 +02:00
Daniel Marjamäki 1008868506 AST: Better handling of '(type){..}' 2020-03-08 16:46:06 +01:00
Daniel Marjamäki cdee62c032 AST: Fixed AST for struct cast '(struct T){...}' 2020-03-08 16:21:22 +01:00
Daniel Marjamäki 5376ba1701 AST: Throw validation exception if ternary operator is missing operands 2020-03-07 21:46:38 +01:00
Daniel Marjamäki baa4cee70c Travis: Fixed Cppcheck warning 2020-02-27 10:51:34 +01:00
Daniel Marjamäki 38b570138f AST: Try to handle c++17 for properly 'for (auto [a,b]:c)' 2020-02-27 09:58:53 +01:00
Daniel Marjamäki e4937ed621 AST: Fixed wrong AST for cast '(std::vector<int>&&)s->second' 2020-02-25 21:05:49 +01:00
Daniel Marjamäki ef26b55737 AST: Fix wrong handling for '{scope} (expr)' 2020-02-23 15:01:06 +01:00
Daniel Marjamäki f07a71e3e1 Report unknown macros for pattern '%name% %num%' 2020-02-22 11:57:36 +01:00
Daniel Marjamäki cf10b1a220 fix ast for expression that starts with number 2020-02-21 21:11:32 +01:00
Daniel Marjamäki 388b5118df Fixed bad ast (wrong result from iscast()) 2020-02-21 17:15:33 +01:00
Rikard Falkeborn f6e7fb4bd9
Bugfix valuetype for some integer constants (#2545) 2020-02-19 07:51:39 +01:00
Daniel Marjamäki 89cb0187d0 Travis: Use simpleMatch for simple pattern 2020-02-16 21:47:46 +01:00
Paul Fultz II 921887a281
Use valueFlowGeneric for valueFlowForwardExpression (#2537) 2020-02-16 16:02:22 +01:00
Daniel Marjamäki a350ed9bc2 Fixed #9023 (AST: wrong lhs for a = b + foo(A::Hash{}(""))) 2020-02-16 13:58:43 +01:00
Paul Fultz II e55ddacd18
Fix issue 9597: False positive: Reference to temporary returned if explicitly casted to base class (#2531) 2020-02-11 11:41:41 +01:00
Daniel Marjamäki b03bdfaf72 Import Clang ast dump (experimental) 2020-01-05 15:12:53 +01:00
Paul Fultz II e07801a891 Fix issue 9563: new daca crash: findLambdaEndToken not finding end token (#2472) 2020-01-04 10:45:24 +01:00
Paul Fultz II ad352daa08 Fix issue 9535: Syntax Error: AST broken, 'if' doesn't have two operands. (#2450) 2019-12-16 12:17:01 +01:00
orbitcowboy f89adef1c1 Running astyle [ci skip] 2019-12-11 15:01:21 +01:00
Paul Fultz II ad2f71338c Fix issue 9525: Syntax Error: AST broken, 'if' doesn't have two operands inside lambda (#2433)
* Fix issue 9525: Syntax Error: AST broken, 'if' doesn't have two operands inside lambda

* Fix incorrect matchers
2019-12-10 21:21:07 +01:00
Paul Fultz II ea2916a3e4 Fix issue 9514: Syntax Error: AST broken, 'for' doesn't have two operands. (#2429)
* Fix issue 9514: Syntax Error: AST broken, 'for' doesn't have two operands.

* Fix typo
2019-12-07 21:16:25 +01:00
Paul Fultz II 56e17fb228 Fix issue 9524: Syntax Error: AST broken, 'if' doesn't have two operands. (#2432) 2019-12-07 21:06:45 +01:00
Paul Fultz II 2978c67e6f Fix issue 9511: Syntax Error: AST broken, 'if' doesn't have two operands. (#2428) 2019-12-06 04:19:46 +01:00
amai2012 0e8a145d6c Run astyle 2019-12-02 22:04:22 +01:00
Paul Fultz II f77347d7b4 Fix crash 9492: Crash in FwdAnalysis::checkRecursive() (condTok is nullptr) (#2411)
* Fix crash 9492: Crash in FwdAnalysis::checkRecursive() (condTok is nullptr)

* Formatting
2019-12-01 14:53:03 +01:00
Daniel Marjamäki 937c82efbe AST: initializer list with lambda 2019-11-27 06:44:58 +01:00
Daniel Marjamäki ab2274b8ad AST: lambdas and scopes in expressions 2019-11-23 21:36:36 +01:00
Sebastian c990d10ffa
Check for JSON error when parsing addon .json files + fixes (#2374)
* cppcheck.cpp: Check for JSON error when parsing addon .json files

This fixes that errors in JSON files given via `--addon=*.json` are
silently ignored and maybe only a part of the JSON file is used.
Now the error message which picojson can return is checked and a
corresponding error message is returned again by getAddonInfo().

* naming.json: Fix missing comma

* CLI: Fix naming violations detected by addon naming.py via naming.json

* Addon naming: Add argument for validating names of constants

* LIB: Rename functions/variables so they are valid, loosen naming rules

* GUI: Fix naming violations
2019-11-20 15:37:09 +01:00
Paul Fultz II 479fbb85a2 Fix issue 9443: Internal error: Token::astOperand2() cyclic dependency. (#2376)
* Improve nested init lists

* Fix issue 9443: Internal error: Token::astOperand2() cyclic dependency.
2019-11-19 11:38:03 +01:00
Daniel Marjamäki 03ae0ccef3 AST: Do not hang for code 'foo({ for (a;b;c) {} });' 2019-11-03 11:02:59 +01:00
Daniel Marjamäki 35d04cd2d3 AST: non-standard handling of ; in argument list for unknown macro 2019-11-01 09:05:45 +01:00
Daniel Marjamäki 277c59e5f3 AST: Fixed AST for lambda that returns template type 2019-10-30 16:05:34 +01:00
Daniel Marjamäki 2c1905cc2b AST: Somewhat better handling of '{x}' function parameters 2019-10-27 12:00:08 +01:00
Daniel Marjamäki f03945a9e2 AST: better handling when returning list of lambdas 2019-10-26 19:19:20 +02:00
Daniel Marjamäki cf1dd2e6f6 AST: Fix AST when returning list of lambda functions 2019-10-22 18:39:59 +02:00
Daniel Marjamäki b97436e8f8 Fixed #9382 (Hang: CheckLeakAutoVar pellepl/spiffs/src/spiffs_hydrogen.c) 2019-10-06 09:52:05 +02: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
Oliver Stöneberg de9f489b08 use range loops / constness (#2181)
* use range loops / constness

* platform.cpp: avoid shadowed variable
2019-09-19 20:29:33 +02:00
Paul Fultz II 9753e18ebd Fix issue 9340: AST broken: endless recursion from '{' (#2161) 2019-09-09 21:35:49 +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
Daniel Marjamäki af449779f0 astyle formatting
[ci skip]
2019-09-03 06:43:08 +02:00
Ken-Patrick Lehrmann 5c172bb55a Fix issue 8897: Huge array initializations (#2135)
* Fix issue 8897: Huge array initializations

iscpp11init would take a lot of time when parsing huge arrays.
This patch add memoization to keeps track that we are parsing an array,
and allows to propagate the result without re-parsing the array for each
of its members.

* Use enum class instead of enum
2019-09-02 20:31:01 +02:00
Daniel Marjamäki 6815e38879 TokenList::insertTokens: copy column also 2019-08-20 20:53:44 +02:00
Daniel Marjamäki 2d9a131817 Refactoring: Rename variables. Do not use leading _. Renamed 'col' to 'column' 2019-08-18 12:19:05 +02:00
IOBYTE 04bb6c0d1f template simplifier: fix new daca crashes (#2093) 2019-08-17 07:38:07 +02:00
Daniel Marjamäki e9b12b1fe0 Replace 'unsigned' with 'nonneg' 2019-07-17 10:14:25 +02:00
Ken-Patrick 66ebc187f6 Cleanup some const_cast of Token* (#1886)
* Add non const version of some methods of Token

The aim is to reduce the (ab)use of const_cast.

* Cleanup some more const_cast in valueflow

* Remove useless const_cast

* Remove some const_cast from templatesimplifier

* Remove some const_cast from valueflow
2019-06-16 10:09:38 +02:00
Paul Fultz II 169510bd3a Fix issue 9171: Endless recursion (#1877) 2019-06-10 08:22:48 +02:00
Daniel Marjamäki 9f00149674 Fixed #9127 (ast: wrong ast after using and template instantiation) 2019-05-12 17:24:42 +02:00
Daniel Marjamäki 1e2f1bac1f Fixed #8921 (Broken AST - mem = (void*)(new char)) 2019-05-11 15:50:30 +02:00
Daniel Marjamäki 45a343ac2d Fixed #8795 (Syntax Error: AST broken, binary operator '||' doesn't have two operands) 2019-05-04 19:05:03 +02:00
Daniel Marjamäki 604a13a22b rename parameter 2019-05-04 10:36:49 +02:00
Paul Fultz II ae8a3aae8d Fix FP with unused variable (#1814) 2019-04-29 11:50:19 +02:00
Paul Fultz II a90caa7e5a Fix issue 9006: False positive: Return value of function std::move() is not used.
This is trying to fix the issue by fixing the ast and symbol database. First, the ast nodes will be created for the init list and the symbol database will not mark it as a scope. I am not sure if this is the correct approach as I dont really understand how the AST part works.

It did change the AST for `try {} catch (...) {}` but that is because it incorrectly treats `try {}` as an initializer list.
2019-04-15 06:37:27 +02:00
Daniel Marjamäki 1393c1c3a0 AST: Try to handle C++17 syntax 'if (init;expr)' 2019-04-12 17:35:06 +02:00
Daniel Marjamäki e17ddfd964 Changed AST for variable declarations with initializations 2019-03-09 19:09:15 +01:00
rikardfalkeborn dc4e7cef88 Run simplifyPlatformTypes on library return types (#1672)
Add a call to simplifyPlatformTypes() in
SymbolDatabase::setValueTypeInTokenList() to simplify return types of
library configured functions. This fixes the FN in #8141. Regression
tests are added, both for the original issue and another FN in the comments.

In order to do that, move simplifyPlatformTypes() to TokenList from Tokenizer.
This is a pure refactoring and does not change any behaviour. The code was
literally copy-pasted from one file to another and in two places
'list.front()' was changed to 'front()'.

When adding the call to simplifyPlatformTypes(), the original type of
v.size() where v is a container is changed from 'size_t' to 'std::size_t'.
Tests are updated accordingly. It can be noted that if v is declared as
'class fred : public std::vector<int> {} v', the original type of 'v.size()'
is still 'size_t' and not 'std::size_t'.
2019-02-15 13:29:52 +01:00
Daniel Marjamäki 6ca1aba4a7 UninitVar: Fix --experimental-fast issues 2019-02-10 19:00:01 +01:00
Daniel Marjamäki bd7790fd8c Update copyright year 2019-02-09 07:24:06 +01:00
PKEuS 34874dd94f Optimization: Removed unnecessary calls to simplifyPath(). The Caller should do this, and our callers (mainly the test suite) more or less do so, as they all supply just dummy paths ("test.cpp") 2018-12-18 20:33:45 +01:00
Daniel Marjamäki e0b64ec7a9 Fixed #8884 (AST: handle xs... template argument) 2018-12-12 19:00:14 +01:00
Daniel Marjamäki 982f7dc2b3 relative paths: show {code} properly when there are relative paths 2018-11-18 16:08:08 +01:00
Daniel Marjamäki 5d086d60ad Fixed #8844 (snd: Wrong varid and ast) 2018-11-14 21:05:09 +01:00
Daniel Marjamäki 8327aab127 Fixed #8628 (Wrong AST in case) 2018-11-10 21:32:06 +01:00
Daniel Marjamäki f8b0584f6a replace 'constexpr' with 'const' 2018-11-03 19:22:51 +01:00
Armin Müller acf2035a53 Typos found by running "codespell" (#1461) 2018-11-03 07:34:27 +01:00
rikardfalkeborn 88008fedb1 findLambdaEndToken handle explicit type (#1458)
* findLambdaEndToken: Add tests

* Add handling of explicit return in findLambdaEndToken()

* Use AST in findLambdaEndToken()

* Fix ast when lambda is mutable
2018-10-31 12:36:08 +01:00
Daniel Marjamäki 2e4f317c0b Revert "Remove FIXME"
This reverts commit 749699c632.
2018-10-22 21:03:30 +02:00
Daniel Marjamäki 15160f1691 Fixed #8788 (AST Broken error from assigning lambda to variable) 2018-10-22 17:25:01 +02:00
Daniel Marjamäki 749699c632 Remove FIXME 2018-10-22 12:45:34 +02:00
Daniel Marjamäki dc38681a56 Remove FIXME in AST validation. Ticket #8749 2018-10-22 11:37:24 +02:00
Daniel Marjamäki 465db2dff7 Fixed #8786 (internalAstError on valid code with C style cast) 2018-10-18 20:17:23 +02:00
Paul Fultz II 9cf092657c Skip some ast errors to avoid regressions (#1422)
* Skip some ast errors to avoid regressions

* Use simpleMatch

* Skip operator functions

* Add a test for issue 8788
2018-10-13 18:38:44 +02:00
Daniel Marjamäki 9dccc4037b Fixed #8747 (Syntax error, AST broken (a = --*b)) 2018-09-27 19:26:08 +02:00
orbitcowboy d08b39c915
Improved const correctness of local variables. There are no functional changes intended. (#1392) 2018-09-23 20:24:51 +02:00
amai2012 9f5e648b9f Enhance debug output for AST syntax error (inspired by #8747) 2018-09-10 08:55:46 +02:00
Paul Fultz II fa40b821e6 Fix issue 8740: Add a pass to check for valid operators (#1372) 2018-09-08 21:10:34 +02:00
Daniel Marjamäki 3a8bdad20a Fixed #8232 (segmentation fault on valid C++ code in isOppositeCond()) 2018-09-04 18:10:31 +02:00
Daniel Marjamäki 807fbfd318 Renamed _isC and _isCPP 2018-06-16 16:28:03 +02:00
Daniel Marjamäki d08b6e02b7 renamed _files to mFiles 2018-06-16 16:23:55 +02:00
Daniel Marjamäki cc521bef99 renamed _tokensFrontBack to mTokensFrontBack 2018-06-16 16:22:35 +02:00
Daniel Marjamäki 79ffe1d4fc Rename _tokenizer, _settings, _errorLogger 2018-06-16 16:10:28 +02:00
Matthias Krüger 0771a81969 Revert "tokenlist::iscast(): save a few pointer dereferences."
This reverts commit e187fdb696.
2018-06-02 15:57:56 +02:00
Matthias Krüger e187fdb696 tokenlist::iscast(): save a few pointer dereferences. 2018-06-02 13:19:22 +02:00
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
PKEuS 3d860e6f36 Bump simplecpp 2018-05-14 13:00:22 +02:00
Daniel Marjamäki ab6167e3e6 TokenList::validateAst: optimised ~25% 2018-05-09 12:36:58 +02:00
Simon Martin a451a5b598 Ticket #8436: Handle C++11 initializations within ternary operator. (#1174) 2018-04-21 11:30:07 +02:00
Daniel Marjamäki 210b921062 Fixed #8462 (AST: no ast created for 'e = { std::move(address),httpPort, (httpsPort) };') 2018-03-27 13:44:28 +02:00
Daniel Marjamäki 380ecc408f Fixed #8418 (AST: wrong ast for throw expression) 2018-03-10 22:30:21 +01:00
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +01:00
Daniel Marjamäki 8c33a95b49 Refactoring: moved method from Tokenizer to TokenList 2018-01-07 14:07:34 +01:00
Alexey Eryomenko 22483baf72 missed simplification in parsing of std function declaration resulted in (#967)
wrong type detection
2017-10-03 22:10:13 +02:00
Daniel Marjamäki b9b47809f9 Fixed #8197 (iscast: '(b)&1' is not a cast) 2017-09-08 22:52:16 +02:00
Matthias Krüger 58a64702b7 add "internalAstError" id so we can easily track ast errors on daca. 2017-09-05 22:49:16 +02:00