Commit Graph

1634 Commits

Author SHA1 Message Date
Oliver Stöneberg bd1ae69b00
cleaned up includes based on `include-what-you-use` (#4599) 2023-03-02 21:50:14 +01:00
Oliver Stöneberg 3ec4da0f8a
improved library loading in tests (#4806) 2023-03-02 21:10:51 +01:00
Daniel Marjamäki cfba046408 Fixed #11593 (function pointer => false negatives (ast? valueflow?)) 2023-03-02 20:08:22 +01:00
Daniel Marjamäki 65fc31cba9 Tokenizer: tweaked simplification of function pointers. Argument types are kept. 2023-02-26 18:03:24 +01:00
chrchr-github a0cc35e3fa
Remove simplifyQtSignalsSlots(), update qt.cfg (#4807) 2023-02-25 15:58:57 +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 132a5a31cf
improved setting of platform in tests / also improved platform tests (#4787)
* fixture.h: added TODO

* TestPlatform: improved tests for built-in platforms

* TestPlatform: changed tests to TODO asserts

* testfilelister.cpp: added TODO

* fixture.h: added `PLATFORM` macro to load platform / use `PLATFORM` in tests

* platform.h: corrected capitalization in `Platform::platformString(PlatformType)` and bail on unknown type

* fixture.h: fixed `readability-redundant-string-cstr` clang-tidy warning

* testplatform.cpp: fixed `functionConst` selfcheck warnings
2023-02-11 10:44:56 +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
Oliver Stöneberg 1d3955bd92
renamed some files in the `test` folder (#4705) 2023-01-27 08:18:32 +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
chrchr-github 9cf934c10d
Improve handling of 'final' in class declaration (#4706) 2023-01-18 17:08:43 +01:00
chrchr-github 98b3d66684
Add test for #11128 (#4649) 2022-12-18 16:57:25 +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 c779cefa61
Fix #11422 debug: Missing variable class for variable with varid (#4616) 2022-12-08 20:17:06 +01:00
chrchr-github 0854fda28a
Get type from smartpointer (#4608)
* Fix #11223 checkLibraryFunction treats "auto" as type

* Use utility function

* Get type from 'auto p = new ...'

* Fix merge

* Add test for recent fix

* Format

* Get type from smartpointer
2022-12-03 07:50:21 +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
Stefan van Kessel a5c16af16d
Fix lambda capture template syntax error (#4593) 2022-11-23 20:15:10 +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
chrchr-github 192c30ab1d
Fix crash in arraySize() (#4556)
* Fix  #11355 FN: arrayIndexOutOfBounds

* Fix

* Fix crash in arraySize()
2022-10-19 19:19:01 +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
gerboengels 221873e69f
Fix #11319 (#4549)
In this example:
```
//template<std::same_as<int> T> // <= works
template<same_as<int> T>        // <= didn't work
void f()
{}
```
the changed line used to match to `< same_as <`, therefore skip creating links.
The `%op% %name% <` already feels a bit like a workaround. So adding the condition that $op$ shouldn't be a comparison operator, but part of the template, seemed reasonable to me

Co-authored-by: Gerbo Engels <gerbo.engels@ortec-finance.com>
2022-10-16 19:33:44 +02:00
chrchr-github c51fb3864a
Add test for #10801 (#4544) 2022-10-11 07:23:28 +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
Oliver Stöneberg cff1cd9cda
applied clang-tidy `misc-const-correctness` fixes for POD types, iterators and references (#4529)
* applied `misc-const-correctness` fixes for POD types and iterators

* applied `misc-const-correctness` fixes for references
2022-10-02 07:12:40 +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 339484d2a1
mitigated and enabled more clang-tidy warnings (#4470)
* fixed some `performance-inefficient-string-concatenation` clang-tidy warnings

* fixed and enabled `modernize-replace-random-shuffle` clang-tidy warning

* fixed and enabled `bugprone-suspicious-string-compare` clang-tidy warning

* mitigated and enabled `readability-non-const-parameter` clang-tidy warnings

* clang-tidy.md: documented some disabled checks

* mitigated and enabled `performance-unnecessary-value-param` clang-tidy warnings
2022-09-16 18:58:59 +02:00
Daniel Marjamäki 92845295b8 Fix broken CI caused by my qt fix 2022-09-08 11:12:38 +02:00
Oliver Stöneberg 54771306c5
selfcheck : cleaned up some suppressions, fixed warnings and some cleanups (#4436)
* cleaned up triage.pro and pass all triage files to selfcheck

* CI-unixish.yml: factored out redundant selfcheck flags

* CI-unixish.yml: cleaned up selfcheck suppressions and fixed warnings

* added explicit `missingInclude` checks to selfcheck to work around current issues/limitations / fixed selfcheck includes / added some unit tests for `missingInclude`

* applied the selfcheck changes to the sanitizer jobs

* only fail TSAN CI build in case of TSAN error / updated sanitizer CI build TODOs
2022-09-06 23:11:39 +02:00
chrchr-github 1aa259569e
Fix #10138 syntax error : int (operator"" _ii)(unsigned long long v) … (#4374)
* Fix #10138 syntax error : int (operator"" _ii)(unsigned long long v) { return v; }

* Format
2022-08-18 23:38:45 +02:00
chrchr-github e9f1665d4f
Add test for #10212 (#4373)
* Add test for #10603

* Add test for #10559

* Add test for #10212

* Format
2022-08-17 19:38:37 +02:00
chrchr-github 0978cc2d46
Add tests for #10559, #10603 (#4367) 2022-08-17 10:01:49 +02:00
chrchr-github 974e34490f
Fix #9282 FP Unused private function (#4327) 2022-08-07 20:06:32 +02:00
chrchr-github 38fdbe0890
Fix #9716 Syntax error for function-try-block in global scope (#4305)
* Fix #9716 Syntax error for function-try-block in global scope

* static through instance

* Handle multiple catch blocks

* Add test

* Fix skip logic

* Handle init lists in simplifyFunctionTryCatch()
2022-07-31 14:49:50 +02:00
chrchr-github b08aabefee
Fix #9877 FP unreadVariable (incomplete code; missing macro definition) (#4278) 2022-07-17 19:40:39 +02:00