Commit Graph

484 Commits

Author SHA1 Message Date
chrchr-github 7e0f64688f
Fix #11275 internalAstError on C++20 templated lambda / Fix #11400 internalAstError on nested lambda (#5134)
* Fix #11275 internalAstError on C++20 templated lambda

* Fix #11400 internalAstError on nested lambda passed as argument
2023-06-10 07:42:10 +02:00
chrchr-github d4705ca8ab
Fix #10809 cppcheckError Cyclic reverse analysis (#5137)
* Fix #10809 cppcheckError Cyclic reverse analysis

* Handle fixed AST in ValueFlow, fix FN

* Remove
2023-06-10 07:41:52 +02:00
Daniel Marjamäki 22e67d3534
Fixed #10442 (AST: wrong ast of ({}) in struct initialization) (#5135) 2023-06-09 22:31:14 +02:00
chrchr-github 3ff8ce316c
Fix AST for parameter pack (#10199, #10492, #11103) (#5125)
* Fix AST for parameter pack (#10199, #10492, #11103)

* Skip ... after )
2023-06-07 20:46:14 +02:00
Daniel Marjamäki 5976faaaf5
Fixed #11745 (Fix AST for 'new type..[..]{..}') (#5118) 2023-06-05 20:43:17 +02:00
chrchr-github 100d17df4f
Fix #11681 FN constParameterPointer with std::vector (#5000) 2023-05-04 11:10:58 +02:00
Paul Fultz II 9d21379c7d
Add non-const overloads for next(), previous(), and link() (#5002)
* Add non-const overloads for next(), previous(), and link()

* Format

* Add CPPCHECKLIB
2023-05-02 06:55:31 +02:00
Oliver Stöneberg 5be8eee943
iwyu.yml: use a distro which has the latest `include-what-you-use` / enabled Qt mappings / cleaned up includes (#4885) 2023-04-08 16:08:47 +02:00
chrchr-github 3ccd0505cd
Enable and mitigate readability-simplify-boolean-expr (#4897) 2023-03-17 13:51:55 +01:00
chrchr-github 322a1a5e8c
Partial fix for #11378 internalAstError regressions (iscpp11init) (#4889) 2023-03-13 16:30:27 +01:00
chrchr-github 980c92d19d
Partial fix for #11378 internalAstError regressions (iscpp11init) (#4884) 2023-03-12 15:39:02 +01:00
chrchr-github 6e1cc11eff
Fix #11606 internalAstError with empty initializer list (#4875) 2023-03-09 20:01:06 +01:00
Daniel Marjamäki 350a1f2dfc AST: do not produce AST for function pointer declaration 'void *(*var[2])(int)' 2023-03-04 11:09:55 +01:00
Oliver Stöneberg 50eb0641b9
iwyu.yml: added `clang-include-cleaner` job / cleaned up includes based on `include-what-you-use` (#4844) 2023-03-04 08:53:19 +01:00
Oliver Stöneberg 5af6ca6637
made `Platform` a member of `Settings` instead of inheriting from it / cleanups (#4791) 2023-03-03 18:36:27 +01:00
Oliver Stöneberg 8023eff7c0
removed `TokenList::getSettings()` and replaced usage in ValueFlow with provided settings (#4843) 2023-03-03 18:31:38 +01:00
Daniel Marjamäki cfba046408 Fixed #11593 (function pointer => false negatives (ast? valueflow?)) 2023-03-02 20:08:22 +01:00
Oliver Stöneberg 674231ae52
added clean C/C++ keyword lists and use them in `TokenList` (#3774) 2023-02-24 21:43:27 +01:00
chrchr-github 103ff907b6
Fix #11572 Broken AST with brace-init and bitwise and (#4812) 2023-02-24 06:31:20 +01:00
chrchr-github 33a03f2c35
Don't throw internalAstError for parameter pack in template argument list (#4773) 2023-02-15 19:43:18 +01:00
Oliver Stöneberg f7a415dbf3
Token: do not return non-`const` pointer from `const` methods - part 1 (#4761) 2023-02-08 21:07:16 +01:00
chrchr-github 1fcea5fb03
Don't crash on C++23 code (#4771) 2023-02-07 22:36:42 +01:00
Daniel Marjamäki 464fbe8d53 Update copyright year 2023-01-28 10:16:34 +01:00
chrchr-github ca0c13e27d
Fix crash in iscpp11init_impl() (#4743) 2023-01-26 22:25:49 +01:00
chrchr-github 84fdc08853
Fix #11515 internalAstError with chain of ternary operators (#4742) 2023-01-26 20:12:39 +01:00
chrchr-github c50339804b
Fix internalAstError with switch/case (#4739) 2023-01-26 20:11:45 +01:00
chrchr-github dfd3e8ac55
Partial fix for #11378: No implicit int in C++ mode (#4696) 2023-01-18 20:37:00 +01:00
chrchr-github c4784a1552
Partial fix for #11378 internalAstError regressions (iscpp11init) (#4700) 2023-01-18 17:09:55 +01:00
Oliver Stöneberg 1cfe49e340
use `const_iterator` where possible (#4662) 2022-12-30 15:13:47 +01:00
chrchr-github 76c28073aa
Revert fix for #10831 (#4631) 2022-12-18 16:55:55 +01:00
chrchr-github 4c8aa56d8b
Partial fix for #11378 internalAstError regressions (iscpp11init) (#4629)
* Partial fix for #11378 internalAstError regressions (iscpp11init)

* Use %cop%

* Add test for #11229

* Format

* Format
2022-12-16 10:46:15 +01:00
chrchr-github 428f5016d4
Partial fix for #11378 (iscpp11init) (#4595)
* Partial fix for #11378 (iscpp11init)

* Improve fix

* Add fix
2022-11-27 09:26:46 +01:00
Daniel Marjamäki ad8c1e26f0 dump: output language to dumpfile 2022-11-20 12:30:09 +01:00
chrchr-github 701d381895
Fix #11383 FP selfAssignment: lambda capture / #11380 FP operatorEqRetRefThis (#4581)
* Fix  #11383 FP selfAssignment: lambda capture /  #11380
FP operatorEqRetRefThis

* Format
2022-11-13 21:20:44 +01:00
chrchr-github e8b37235d6
Fix #11378 internalAstError regressions (iscpp11init) (#4580) 2022-11-12 22:25:05 +01:00
chrchr-github ffc0c57562
Fix crashes on nullptr (#4575) 2022-11-09 21:56:16 +01:00
gerboengels bd95efc987
Fix internal error "Unexpected tokens in initializer" with anonymous namespace (#4577)
Co-authored-by: Gerbo Engels <gerbo.engels@ortec-finance.com>
2022-11-05 22:41:13 +01:00
chrchr-github ccf2176664
Fix #11370 FP constStatement with lambda (#4570)
* Update tokenlist.cpp

* Update testincompletestatement.cpp

* Fix #11370 FP constStatement with lambda

* Format
2022-11-01 11:50:08 +01:00
chrchr-github 6df8573e15
Fix #11369 Syntax error. Unexpected tokens in initializer. (#4568) 2022-10-29 21:24:50 +02:00
chrchr-github b4e78e8ac5
Fix #11357 new internalAstError (#4564)
* Fix #11357 new internalAstError

* Format

* Handle scope operator

* Format

* Format
2022-10-25 21:50:37 +02:00
gerboengels 6a01fa9b70
#11134 Fix broken AST with (designated) initializers (#4550)
* Make control flow a bit easier, and more similar to previous code

Made similar to around line 790

* In a cpp11init, always parse only the corresponding } (#11134)

- _always_, because in some cases this was omitted (around line 790) or too strict (around line 860)
- _only_, and not following tokens which happen to be } as well (around line 1030)

* Fix unit tests: AST was incorrect, now is fixed

auto var{ {{},{}}, {} };

Old AST:
```
{
|-var
`-{
  `-,
    |-,
    | |-{
    | `-{
    `-{
```
New AST:
```
{
|-var
`-,
  |-{
  | `-,
  | | |-{
  | | `-{
  `-{
```
Compare the same example, but with `X{}` instead of just `{}`:
`auto var{ a{b{},c{}}, d{} };`
```
{
|-var
`-,
  |-{
  | |-a
  | `-,
  | | |-{
  | | | `-b
  | | `-{
  | | | `-c
  `-{
    `-d
```
This structure is similar to that of the new AST, not the old AST

* Fix unit tests: another AST was incorrect, now is fixed

Code: `auto var{{1,a::b{2,3}}, {4,a::b{5,6}}};`

Old AST:
```
{
|-var
`-{
  `-,
    |-,
    | |-1 'signed int'
    | `-{
    | | |-::
    | | | |-a
    | | | `-b
    | | `-,
    | | | |-2 'signed int'
    | | | `-3 'signed int'
    `-{
      `-,
        |-4 'signed int'
        `-{
          |-::
          | |-a
          | `-b
          `-,
            |-5 'signed int'
            `-6 'signed int'
```
New AST:
```
{
|-var
`-,
  |-{
  | `-,
  | | |-1 'signed int'
  | | `-{
  | | | |-::
  | | | | |-a
  | | | | `-b
  | | | `-,
  | | | | |-2 'signed int'
  | | | | `-3 'signed int'
  `-{
    `-,
      |-4 'signed int'
      `-{
        |-::
        | |-a
        | `-b
        `-,
          |-5 'signed int'
          `-6 'signed int'
```

* Fix unit tests: missing ; after class, resulting in incorrectly being marked as cpp11init

Because of the missing `;` after the class declaration, it was marked as a cpp11init block.
Which it isn't, and which now throws an exception

* Fix cpp11init to let unit tests pass again

The following unit tests failed on the newly introduced throws, because the code for these tests incorrectly marked some tokens as cpp11init:
TestVarID::varid_cpp11initialization
TestTokenizer::checkRefQualifiers

* Fix typo

* Improve check for void trailing return type

Observation: the only function body _not_ containing a semicolon, is a void function: something like
   auto make_zero(ini& i) -> void {
     while(--i > 0) {}
   }
Non-void function? Then it must return a value, and thus contain a semicolon, which is checked for a few lines later.

* Fix cpp11init with templated trailing return type

In the following example, vector was marked as cpp11init due to the mismatch of `%any% {`
auto f() -> std::vector<int> { return {}; }

I made the assumption that whenever "%any% {" matches, endtok must be set too.
If this assumtion doesn't hold (so "%any% {" matches, but endtok == nullptr), then the for-loop would search all the way to the end of stream. Which I guess was not the intention.

* Remove comments

Co-authored-by: Gerbo Engels <gerbo.engels@ortec-finance.com>
2022-10-19 07:25:15 +02:00
Daniel Marjamäki 584a428025 Fixed #10831 ("Analysis failed (lambda not recognized)" with lamba default parameter in lambda signature) 2022-10-10 21:05:48 +02:00
gerboengels ed06e29f7a
Fix defaulted and deleted functions (#4540)
* Fix 9392, but for destructors: out-of-line defaulted destructors skipped everything after

Context:
```
struct S {
    ~S();
};

S::~S() = default;

void g() {
    int j;
    ++j;
}
```
Everything after `S::~S() = default;` was skipped, so the uninitialized variables in g() weren't found.

Out-of-line destructors are useful e.g. when you have a forward declared unique_ptr in the .h,
and `= default` the destructor in the .cpp, so only the cpp needs to know the header for destructing
your unique_ptr (like in the pImpl-idiom)

* Fix unit test, by correctly fixing 10789

Previous commit broke this test, but also provided the tools for a cleaner fix

* Document current behaviour

* Rewrite control flow

* Fix deleted functions, which skipped everything after

`a::b f() = delete` triggered the final else in SymbolDatabase::addNewFunction,
which sets tok to nullptr, effectively skipping to the end of the stream.

* Remove troublesome nullptr, which skips every analysis afterwards

It was introduced in 0746c241 to fix a memory leak.
But setting tok to nullptr, effectively skipping to the end, seems not needed.

Previous commits fixes prevented some cases where you could enter the `else`.
This commit is more of a fall back.

* fixup! Fix deleted functions, which skipped everything after

`a::b f() = delete` triggered the final else in SymbolDatabase::addNewFunction,
which sets tok to nullptr, effectively skipping to the end of the stream.

* fixup! Fix deleted functions, which skipped everything after

`a::b f() = delete` triggered the final else in SymbolDatabase::addNewFunction,
which sets tok to nullptr, effectively skipping to the end of the stream.

* Make it heard when encountering unexpected syntax/tokens

Co-authored-by: Gerbo Engels <gerbo.engels@ortec-finance.com>
2022-10-10 20:17:33 +02:00
chrchr-github 260a757791
Fix #10839 internalAstError with function returning a function (#4514) 2022-09-29 21:56:26 +02:00
chrchr-github b8b6b41833
Fix #10802 Broken AST lambda inside for loop (#4520)
* Fix #10802 Broken AST lambda inside for loop

* Add some boost and wxwidget defines (on behalf of "david ingamells")
2022-09-29 13:29:50 +02:00
chrchr-github cab4997b0b
Fix #11039 Empty AST with delete new / #11327 FP leakReturnValNotUsed with new and offset (#4513)
* Fix internalAstError with new

* Format

* nullptr check

* Add test for #11039

* Fix #11039 Empty AST with delete new / #11327 FP leakReturnValNotUsed with new and offset
2022-09-27 18:12:58 +02:00
chrchr-github 0f79f8bd70
Fix internalAstError with new (#4508)
* Fix internalAstError with new

* Format

* nullptr check
2022-09-26 22:05:58 +02:00
Oliver Stöneberg b3ec225480
iwyu.yml: use `debian:unstable` to always get latest include-what-you-use / cleaned up includes (#4466)
* iwyu.yml: use debian:unstable to always get latest include-what-you-use

* cleaned up includes based on include-what-you-use

* mitigated include-what-you-use false positives
2022-09-16 07:15:49 +02:00
Oliver Stöneberg d46ea7ba86
avoid unnecessary copies with `push_back()` and `push_front()` (#4451) 2022-09-08 09:21:35 +02:00
Oliver Stöneberg 4bf5dcd29f
cleaned up includes based on include-what-you-use (#4358)
* cleaned up includes based on include-what-you-use

* testlibrary.cpp: no need for `empyString` optimization
2022-08-14 12:44:19 +02:00