Commit Graph

171 Commits

Author SHA1 Message Date
chrchr-github e2082267e2
Fix #12218: class and union (#5705)
Co-authored-by: chrchr-github <chrchr@github>
2023-12-01 10:03:43 +01:00
chrchr-github 42a64d4d39
Fix #12218 syntaxError with typedef in namespace (#5694) 2023-11-25 22:59:51 +01:00
chrchr-github 2d232dcaac
Fix varid0 with rvalue reference typedef (#5649) 2023-11-11 10:09:08 +01:00
chrchr-github d24074f7b1
Fix #12166 debug: varid0 with reference typedef (#5643)
Why do we even split any declarations in the first place?
2023-11-09 10:11:34 +01:00
Daniel Marjamäki 780b742568
Fix #12165 (simplifyTypedef: the "enum" token is not inserted) (#5641) 2023-11-09 07:48:33 +01:00
chrchr-github 80c5cb6690
Fix #12008 debug: Executable scope 'x' with unknown function. (#5588) 2023-10-25 14:50:10 +02:00
Oliver Stöneberg a765a1310d
ValueFlow: omit unnecessary location information from `valueFlowBailoutIncompleteVar` (#5583)
This is unnecessary since we only issue it from a single location. It
also leads to a lot of unnecessary noise in the daca diff reports.
2023-10-23 10:13:10 +02:00
Daniel Marjamäki 17ea101e7b
Fix #12081 (Tokenizer::simplifyTypedef: Handle volatile structs better) (#5577) 2023-10-19 21:02:03 +02:00
Oliver Stöneberg ebb877adcc
gui/platforms.h: renamed `Platform` to `PlatformData` / Platform: removed unnecessary `cppcheck` namespace (#5545) 2023-10-13 16:02:04 +02:00
Oliver Stöneberg 06b5ef1e4d
cleaned up includes based on include-what-you-use (#5532) 2023-10-09 10:07:20 +02:00
Oliver Stöneberg 960e8bb4ea
testrunner: got rid of some redundant preprocessing code / added some missing asserts (#5521)
This consolidates the stray invocations of preprocessing.
2023-10-08 11:29:52 +02:00
Daniel Marjamäki 6a8f787915
Fix #12026 (simplifyTypedef: not handled properly when typedef and enum constant has same name) (#5500) 2023-10-01 21:26:54 +02:00
chrchr-github 6773cdb34b
Fix #12014 syntaxError due to bad typedef simplification (#5493) 2023-09-28 19:26:12 +02:00
Daniel Marjamäki ed5532c2a7
Fix #12019 (False positive: null pointer, array zero initialization) (#5495) 2023-09-28 15:18:08 +02:00
chrchr-github 57bbb17f3b
Fix #11986 debug: Executable scope 'x' with unknown function. (#5463) 2023-09-20 17:18:00 +02:00
chrchr-github 523c41a60b
Fix #11978 debug: Executable scope 'x' with unknown function. (#5437) 2023-09-13 11:39:09 +02:00
Oliver Stöneberg 2502897265
avoid some redundant and unused settings in tests among other cleanups / added and used `WARN_UNUSED` attribute (#5284) 2023-08-09 12:43:55 +02:00
chrchr-github 1ffff8dc06
Fix #11772 top() on empty stack in TypedefSimplifier::replace() (#5161) 2023-06-16 19:35:01 +02:00
chrchr-github ac86eda6b3
Revert "Revert "Skip forwarding values for unique expressions (#5103)"" (#5124) 2023-06-07 11:11:48 +02:00
Daniel Marjamäki 7d4472616b Revert "Skip forwarding values for unique expressions (#5103)"
This reverts commit 26ed052e8d.
2023-06-06 17:31:24 +02:00
Paul Fultz II 26ed052e8d
Skip forwarding values for unique expressions (#5103) 2023-06-05 20:49:19 +02:00
chrchr-github beea1a2345
Fix #11689 FP constStatement with nested typedefs (#5090)
* Fix #11689 FP constStatement with nested typedefs

* Add test
2023-05-26 06:12:40 +02:00
chrchr-github 33f728df14
Fix #11725 Hang in simplifyTypedef() with extra parentheses (#5078)
* Fix  #11725 Hang in simplifyTypedef() with extra parentheses

* Amend test
2023-05-23 06:26:22 +02:00
Daniel Marjamäki d475591665
Tokenizer: simplification of typedefs in _Generic arguments (#5059) 2023-05-14 15:14:52 +02:00
Daniel Marjamäki 2b74a2084e
Fixed #11716 (simplifyTypedef: function with const should be handled better) (#5054) 2023-05-12 20:39:08 +02:00
chrchr-github 1db510b9fd
Add test for #10796 (#5036) 2023-05-04 22:23:36 +02:00
Oliver Stöneberg 25183ff484
testrunner: more `SettingsBuilder` usage and `const` cleanups (#5026) 2023-05-02 15:54:19 +02:00
Oliver Stöneberg 2935c855c3
reduced usage of mutable `Settings` objects in tests (#4798) 2023-05-02 11:48:24 +02:00
chrchr-github 043f4fa621
Fix #11693 performance regression (hang) in 2.11dev (#5022) 2023-04-29 15:17:55 +02:00
chrchr-github bda9f707cc
Fix typedef in enum class (#4998) 2023-04-21 18:58:44 +02:00
chrchr-github 938ad990f5
Add tests for #6925, #11042, #11494 (#4987)
* Add tests for #6925, #11042, #11494

* Format
2023-04-19 21:19:45 +02:00
chrchr-github 29e2a7ed34
Fix #11640 internalAstError with typedef matching member function [regression] (#4981) 2023-04-18 18:38:16 +02:00
chrchr-github 5524bb4e58
Fix #11634 Crash in TypedefSimplifier (#4938)
* Fix #11634 Crash in TypedefSimplifier

* Call function

* Format
2023-04-07 11:09:13 +02:00
Daniel Marjamäki c79d859f8b Tokenizer::simplifyTypedef: new faster simplification.
It performs a more "lightweight" simplification of global typedefs that are not shadowed.

If a "heavy" simplification is needed that will be executed afterwards.
2023-03-26 17:16:45 +02:00
Paul Fultz II fd8a7b9537
ValueFlow: Evaluate if statement for function returns (#4908) 2023-03-24 13:31:26 +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
Daniel Marjamäki 65fc31cba9 Tokenizer: tweaked simplification of function pointers. Argument types are kept. 2023-02-26 18:03:24 +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
Daniel Marjamäki 464fbe8d53 Update copyright year 2023-01-28 10:16:34 +01:00
chrchr-github 7eb1da9ffc
Fix #11506 debug: simplifyUsing: unmatched body end (#4728) 2023-01-27 08:19:32 +01:00
Oliver Stöneberg 1d3955bd92
renamed some files in the `test` folder (#4705) 2023-01-27 08:18:32 +01:00
Robert Reif c3aa0940be
fix truncation of token flags (#4727) 2023-01-26 22:11:37 +01:00
chrchr-github b12aebc817
Fix #9353 FN (style) Condition '...' is always true, add test for #10508 (#4731) 2023-01-26 22:03:12 +01:00
chrchr-github e4c5f36af0
Fix #11373 typedef: not simplified after inline keyword (#4574) 2022-11-02 15:15:33 +01:00
chrchr-github ae16aab997
Handle simple typedefs (#4558) 2022-10-22 00:28:05 +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 5e0fc24bb7 Fixed #11232 (Syntax Error: AST broken, binary operator '!=' doesn't have two operands) 2022-08-27 18:02:19 +02:00
chrchr-github 974e34490f
Fix #9282 FP Unused private function (#4327) 2022-08-07 20:06:32 +02:00
Paul Fultz II aafd1e10be
Fix 11006: FP uninitvar with unknown constant (#4056) 2022-04-28 10:48:37 +02:00
Paul Fultz II d2a0b0f78e
Fix 10951: FP knownEmptyContainer with east-const (#3988)
* Fix 10951: FP knownEmptyContainer with east-const

* Format

* Use simpleMatch
2022-04-08 08:22:39 +02:00