Commit Graph

187 Commits

Author SHA1 Message Date
chrchr-github b26b78b86d
Fix #12258 Assert failure in setSymbolic() (#5759) 2023-12-12 22:37:33 +01:00
chrchr-github 7ac824f38a
Fix #12249 Assert failure in ExpressionAnalyzer (II) (#5733) 2023-12-08 14:46:20 +01:00
chrchr-github 613bbe7674
Fix #12249 Assert failure in ExpressionAnalyzer (#5731) 2023-12-06 20:04:20 +01:00
Daniel Marjamäki 70745b527a
Fix #12210 (Cppcheck hang in SymbolDatabase::createSymbolDatabaseExprIds) (#5699) 2023-12-05 14:22:32 +01:00
chrchr-github 328daeceb4
Fix #11334 debug: varid0 with anonymous union (#5648) 2023-11-11 10:01:03 +01:00
chrchr-github 502d7ea6db
Fix #12120 FP constStatement with class in C code (#5594) 2023-10-25 10:05:42 +02:00
chrchr-github f4d18a8d1e
#12077 FP constStatement with ctor in namespace (#5572) 2023-10-21 12:12:56 +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
chrchr-github d9a8909d2a
Fix #11408 debug: Function::addArguments found argument 't' with varid 0 (#5507) 2023-10-05 10:01:46 +02:00
Oliver Stöneberg 3cf9100198
fixed #6316 (Use std::to_string() in place of MathLib::toString() ...) - deleted default implementation of `Mathlib::toString()` (#5341)
It was also used inconsistently and seemed to imply there is some
special handling which wasn't the case. It was just an alias for
`std::to_string()` for non-`double` types. So there was no need for it.

---------

Co-authored-by: Robert Reif <reif@earthlink.net>
2023-08-17 16:46:32 +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 a6b0129725
Fix #11838 FP uninitvar with label matching variable name (#5251) 2023-07-20 10:45:44 +02:00
chrchr-github a4a29bfbc5
Fix #11411 FP selfInitialization after initialization of previous member from initializer list (#5239) 2023-07-14 10:33:05 +02:00
Daniel Marjamäki 9339802be3
Fix #11740 (FP syntaxError from switch in C code) (#5153) 2023-06-14 10:41:37 +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 1b98be458d
Fix #11739 Assert failure in valueflow.cpp / setSymbolic() (#5104) 2023-06-03 11:08:06 +02:00
Daniel Marjamäki 107eea236f
Improved handling of alignas. alignas will not be removed from now on so we don't loose this information. (#5081) 2023-05-24 10:33:53 +02:00
chrchr-github ba57e15cb2
Fix #11717 Warn when C++ code is scanned as C (prevent FPs) (#5064)
* Fix #11717 Warn when C++ code is scanned as C (prevent FPs)

* Don't throw for operators

* Detect reference variables

* Fix tests

* Fix compilation

* Fix test

* Fix another test

* Use strAt()
2023-05-21 13:59:49 +02:00
Daniel Marjamäki d24a1342a6
Fixed #11711 (Tokenizer: varId not set properly in function call) (#5041) 2023-05-08 12:11:30 +02:00
Oliver Stöneberg 5833fc3c19
testrunner: even more `SettingsBuilder` usage and `const` cleanups (#5030)
* moved some of the test-only `Library::loadxmldata()` calls into `test`

* testrunner: reduced need for backup/restore of settings
2023-05-04 10:31:05 +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 5b4c95f229
Fix varid assigned to function (#4991) (#5013) 2023-04-28 08:27:07 +02:00
chrchr-github a4e224b65c
Handle auto as first token, set varid (#4991)
* Handle auto as first token

* Set varid when initialized by function

* Fix TODO from #11444

* Fix function parsing

* Add parentheses

* Format
2023-04-21 10:13:25 +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 809430631f
Partial fix for #11611 FP constStatement with typedef and unknown macro (#4881) 2023-03-12 11:13:58 +01:00
Daniel Marjamäki f4e0ae3b84 Tokenizer: Improved removing of function pointer arguments to avoid false positives 2023-03-04 11:09:55 +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
chrchr-github c3225781f3
Fix #11533 Infinite recursion in typeDecl() (#4767) 2023-02-07 22:02:59 +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 b5a06d045e
Fix #11497 debug: CheckClass::isMemberVar found used member variable 'x' with varid 0 (inconclusive) (#4736) 2023-01-26 22:19:51 +01:00
chrchr-github 0b62c73ff0
Fix spurious variable declaration with unknown macro and using (#4698) 2023-01-18 17:11:41 +01:00
chrchr-github 491721a6ff
Fix spurious variable declaration with unknown macro (#4694) 2023-01-09 16:11:26 +01:00
chrchr-github 5b687cb038
Fix #11423 Crash in valueFlowForwardConst() (#4634) 2022-12-12 22:58:48 +01: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
chrchr-github 64f3f85804
Fix #11332 Function::addArguments found argument 'b' with varid 0 wit… (#4506)
* Fix #11332 Function::addArguments found argument 'b' with varid 0 with lambda parameter

* Fix varid0 warning
2022-09-26 18:21:21 +02:00
chrchr-github 3b07661fd3
Fix #11293 debug: CheckClass::isMemberVar found used member variable 'x' with varid 0 (#4489) 2022-09-21 17:35:10 +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
chrchr-github 80a486dda0
Fix #11167 FP virtual call in destructor even though class is final / Delete 'final' from specializations (#4383)
* Add 'final' keyword

* Delete 'final' from specializations

* Fix #11167 FP virtual call in destructor even though class is final

* Fix test
2022-08-19 18:26:00 +02:00
Oliver Stöneberg 1b4141cbe5
added more missing `sstream` includes (#4384) 2022-08-19 18:23:15 +02:00
PKEuS 99ce89c003
Improvement: Set varId for variables with global scope operator :: Refactorization: Moved internal class from tokenize.h to tokenize.cpp (#4184)
Merged from LCppC.
2022-06-11 08:11:16 +02:00
Paul Fultz II e2c35abde5
Fix 11050: False positive: unreadVariable for class variable when another function uses the same variable name (#4121) 2022-05-22 09:20:32 +02:00
chrchr-github 6a914dc435
Add tests for # 10773, #108787, #8991 (#4063)
* Add test for #10773

* Add test for #10878

* Add test for #8991
2022-04-30 08:20:00 +02:00
chrchr-github 6df0f9b3e3
Add tests for #7377, #8692, #9180 (#4053) 2022-04-27 12:43:21 +02:00