1511 Commits

Author SHA1 Message Date
Daniel Marjamäki
70ab30e3c6 AST; Fixed problem with initializer list and cleanup of compileScope 2021-05-03 20:22:08 +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
dummyunit
da27159d7c
Fixed #9728 (Support function level try blocks) 2021-05-02 09:05:12 +02:00
Daniel Marjamäki
07c1f28035 astyle formatting 2021-05-01 07:35:03 +02:00
DGarry82
d3035c246f
Attribute lists support (#3239) 2021-05-01 07:33:55 +02:00
Daniel Marjamäki
b798b99777 Parser; do not remove alignof and alignas in the same way 2021-04-26 11:44:08 +02:00
Daniel Marjamäki
28a7bb63ec Parser; simplify (break out) init expression from if/switch/range-for 2021-04-25 14:37:27 +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
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
56773b82c4 Simple handling of coroutines 2021-04-18 19:42:22 +02:00
Daniel Marjamäki
fe87afb2f9 TestTokenizer: Align function pointer test case names 2021-04-18 12:33:04 +02:00
Daniel Marjamäki
c98afa83fd Tokenizer; Add test for c++14 lambda expression 'lambda=[value=1]{...}' 2021-04-16 15:18:02 +02:00
Daniel Marjamäki
11f828a669 Fixed #9415 (C++11: alignas not handled -> wrong code -> false negatives) 2021-04-15 20:26:53 +02:00
Daniel Marjamäki
73e698b84d Fixed #9214 (Tests are run on simplified token list) 2021-04-06 21:21:53 +02:00
Lars Even Almaas
9786f1c34b
Suggested implementation for rule 8.2 (#3169) 2021-03-25 08:25:43 +01:00
Daniel Marjamäki
42437277dc Update Copyright year 2021-03-21 20:58:32 +01:00
Tetrix
9b7f1f6280
simplifyCPPAttribute tokenizer strips alignas (#3171) 2021-03-20 10:38:47 +01:00
Rikard Falkeborn
103e52f394
Fix tokenizing of x[i](0) (Fixes #8875) (#3167)
Fix faulty removal of parenthesis when "]" is followed by parenthesis
with a number inside, for example when calling a function pointer in
an array or (perhaps more common) in c++, calling operator ( on an
element in an array.

Fixes #8875 where such wrong simplification lead to a FP with too many
bits shifted due to "<<" was interpreted like a shift operator rather
than a stream output.
2021-03-11 08:16:25 +01:00
Daniel Marjamäki
7106e1f48f Moved TestTokenizer::simplifyCasts tests to TestSimplifyTokens 2021-02-27 04:19:54 +01:00
Daniel Marjamäki
81c7fa0348 Moved TestTokenizer::tokenize6 to TestSimplifyTokens 2021-02-27 04:07:33 +01:00
Daniel Marjamäki
1adea5c3b0 Move simplifyKnownVariables tests to TestSimplifyTokens 2021-02-25 21:32:56 +01:00
PKEuS
cf1937294a Refactorization: Removed unnecessary \n and spaces in strings
Merged from LCppC.
2021-02-20 12:58:42 +01:00
Daniel Marjamäki
f08dde1140 Fixed #10013 (Tokenizer: Code with 'not' is not handled) 2021-02-13 20:32:49 +01:00
Daniel Marjamäki
a5babf25a7 Fixed #10080 (syntax error: operator) 2021-01-14 20:56:11 +01:00
Daniel Marjamäki
5f21d9d97b Fixed #8975 (Syntax error for valid C code) 2021-01-12 21:28:07 +01:00
IOBYTE
e7bdf5f71c
remove cleanupAfterSimplify from the template simplifier (#2998)
The template simplifier works well enough now so cleanupAfterSimplify is
no longer necessary.  In fact cleanupAfterSimplify was introducing a bug
which improperly simplified C++ style casts.

Bugs should be exposed and fixed properly rather than just hiding them.

Co-authored-by: Robert Reif <reif@FX6840>
2020-12-31 09:33:23 +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
Daniel Marjamäki
37a5ec8cd5 Summaries: Moved to its own files 2020-12-20 19:53:58 +01:00
Daniel Marjamäki
96caaedbd5 Generate basic function summaries 2020-12-19 19:02:42 +01:00
IOBYTE
8161baf1e9
fix template debug output line numbers (#2938) 2020-12-08 10:35:13 +01:00
Daniel Marjamäki
cbb388d458 Tokenizer: Avoid wrong simplification of template right angle bracket 2020-12-02 20:21:32 +01:00
Daniel Marjamäki
c69bfbf495 AST: Fixed ast for multidimensional array initialisation 2020-12-02 07:38:21 +01:00
Daniel Marjamäki
8a1c16a560 Tokenizer: add daca debug messages when right angle brackets in templates are not handled well 2020-11-29 16:07:56 +01:00
Daniel Marjamäki
7112f69d7b Fixed bug in fixAngleBrackets 2020-11-29 12:56:13 +01:00
Daniel Marjamäki
fd75837494 Tokenizer: Remove extra 'template' keywords 2020-11-28 21:57:06 +01:00
Daniel Marjamäki
af26697ceb AST: Generate proper AST for 'f = []() -> foo&& {}' 2020-11-28 06:53:46 +01:00
IOBYTE
1ea89bcad8
add support for template constructors (#2911) 2020-11-24 07:21:37 +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
2cd8ea83a7 Fixed #9860 (unused template not removed properly by default) 2020-11-22 16:43:36 +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
Daniel Marjamäki
54a93c4374 Fixed #9452 (FP syntaxError - _Pragma before struct with two constructors) 2020-11-15 15:03:47 +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
bfa8c6fb98 Fixed cppcheck warning and corrected checkHeaders test 2020-11-11 15:28:32 +01:00
Daniel Marjamäki
c95b0d2a51 Fixed #9977 (Template simplifier does not simplify in header) 2020-11-11 09:50:51 +01:00
Daniel Marjamäki
26e6eed189 Revert "AST: Adjust AST for variable declaration 'char var[] = str;'"
This reverts commit 376860f7962190ba0e65649beafbc4a8881bcef7.
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
3876b601d5 Fixed #9476 (Tokenizer: report unknown macro) 2020-10-24 22:12:10 +02:00