Commit Graph

2996 Commits

Author SHA1 Message Date
Oliver Stöneberg e38a031ae6
ValueFlow: pass `SymbolDatabase` by reference into `ValueFlow::setValues()` (#5295) 2023-08-07 18:41:50 +02:00
Oliver Stöneberg 77c479a6c4
pass `TokenList` as reference into `ValueFlow::setValues()` (#4868)
This avoid lots of unchecked pointer dereferences.

There was a single case which checked it and that looked like a
leftover. The only way this might have been a `nullptr` pointer was
through several default constructors which were not used at all so I
removed them.
2023-08-04 18:17:27 +02:00
chrchr-github faf8047050
Fix FP truncLongCastReturn on Windows (#5262) 2023-08-02 12:27:29 +02:00
Oliver Stöneberg 45de338f1b
cleaned up includes based on include-what-you-use / iwyu.yml: updated to yet another distro to get the latest version and updated the Chaotic-AUR key (#5267)
This is a mess. The version is AUR is still outdated and also doesn't
install anymore. Fedora 38 carries the latest version of it so use that
now. Keep the old steps in case we need to switch again in the future.
2023-08-02 10:36:17 +02:00
chrchr-github 101ddea1e6
Fix #11840 FP constStatement with template parameters on operator (#5258) 2023-07-21 17:33:18 +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 2878c68ec0
Fix FP unknownMacro (#5249) 2023-07-18 12:16:54 +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
chrchr-github c0bd9f8bbd
Fix #11827 FP duplInheritedMember - different return type (#5231) 2023-07-12 15:56:07 +02:00
Daniel Marjamäki 3508464c6d
dump: fix dump output for typedef info, file is <stdout> (#5236) 2023-07-12 11:21:59 +02:00
chrchr-github cc38ef4168
Fix #11818 FP constParameterReference / #11819 FP stlcstrConstructor / #11814 FP unknownMacro (#5224) 2023-07-07 15:54:07 +02:00
chrchr-github fa03f49d2b
Fix #11810 nullptr deref in compilePrecedence2() (II) (#5222) 2023-07-07 10:42:11 +02:00
Daniel Marjamäki 2ff9e60650
Fix #11815 (dump: add token attribute isTemplateArg) (#5220) 2023-07-05 23:12:22 +02:00
chrchr-github ee5cf0f141
Fix #11810 nullptr deref in compilePrecedence2() (#5218) 2023-07-05 22:34:25 +02:00
Daniel Marjamäki 96955ccfe9
Tokenizer: detect unknown macro 'if (x) MACRO }' (#5209) 2023-07-01 13:17:41 +02:00
chrchr-github 0a72cd3b72
Fix #11795 debug: simplifyUsing: unmatched body end (#5198) 2023-06-27 15:45:25 +02:00
Daniel Marjamäki 87c2b8df04
Tokenizer: dumpfile will say if type token is _Atomic (#5189) 2023-06-25 11:22:30 +02:00
chrchr-github 9a95d4fe67
Fix #11785 Syntax error: typedef not first keyword in statement (#5178) 2023-06-21 18:26:28 +02:00
chrchr-github bb962e2bc3
Enable and mitigate readability-else-after-return (#5175) 2023-06-20 18:43:21 +02:00
chrchr-github 082331c210
Fix #11770 cppcheckError for unknown macro after else (#5163) 2023-06-17 18:39:23 +02:00
chrchr-github 58dd92dd1b
Merge pull request #5152 from chrchr-github/chr_Fix11189
Partial fix for #11189 checkLibraryNoReturn with std::function parameter
2023-06-16 23:59:17 +02:00
chrchr-github 62dfa8877c
Merge pull request #5147 from chrchr-github/chr_astregr
Fix AST regression
2023-06-16 22:47:47 +02:00
chrchr-github 3f0f9e4476
Merge pull request #5158 from chrchr-github/chr_Fix11770
Partial fix for #11770 cppcheckError with unknown macro
2023-06-16 22:40:56 +02:00
chrchr-github 1ffff8dc06
Fix #11772 top() on empty stack in TypedefSimplifier::replace() (#5161) 2023-06-16 19:35:01 +02:00
chrchr 9579b4509d Partial fix for #11770 cppcheckError with unknown macro 2023-06-15 18:36:21 +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 457e0ce0c8 Partial fix for #11189 checkLibraryNoReturn with std::function parameter 2023-06-13 21:48:16 +02:00
chrchr fad1f6b559 Fix AST regression 2023-06-13 14:32:31 +02:00
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 901b775471
Fix scope for function returning rvalue reference, insert std:: in return statement (#5119)
* Fix scope for function returning rvalue reference

* Insert std:: in return statement

* Fix failing test
2023-06-08 07:47:21 +02:00
chrchr-github 18b60d2f2b
Fix #11670 FP constStatement (inconclusive) triggered by namespace (#5114) 2023-06-03 15:13:15 +02:00
chrchr-github 774123d28d
Remove hardcoded lists of functions/templates/types (#5069)
* Remove hardcoded list of functions

* Remove hardcoded list of templates

* Remove hardcoded list of types

* Format

* Fix test

* Unused variable

* Add tests

* auto -> int
2023-05-28 14:33:41 +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
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
Stefan Hagen 9e8cb6904a
[nit] Fixed lib/tokenize.cpp:2815:2: warning: extra ‘;’ [-Wpedantic] (#5071)
Single character fix removing extra semi colon.
2023-05-23 06:27:25 +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
chrchr-github 78182d4773
Fix FN constVariablePointer (#5076)
* Fix FN constVariablePointer

* Fix FP

* Add const

* Fix tests

* Add const
2023-05-22 19:53:51 +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 f72db74817
Fixed #11013 (FP overlappingWriteUnion with anonymous struct in union) (#5067) 2023-05-20 10:34:42 +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 793d6aef01
Tokenizer: do not report unknownMacro for alignas (#5058) 2023-05-14 15:14:41 +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 f5b1537ed1
Fix internalASTError with decltype() (#5047) 2023-05-11 14:35:23 +02:00
Daniel Marjamäki d5951fa2b9
Tokenizer: Add attribute for exported symbols (#5043) 2023-05-09 20:15:00 +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
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
Paul Fultz II 86757de4d5
ValueFlow: Add pass runner to check timeout and report time (#4952) 2023-04-30 20:39:05 +02:00
chrchr-github 043f4fa621
Fix #11693 performance regression (hang) in 2.11dev (#5022) 2023-04-29 15:17:55 +02:00
chrchr-github 5b4c95f229
Fix varid assigned to function (#4991) (#5013) 2023-04-28 08:27:07 +02:00
chrchr-github 9c184462ad
Fix #10720 Hang/Crash with big variadic template (#5018)
* Fix #10720 Hang/Crash with big variadic template

* Fix CI
2023-04-28 08:26:35 +02:00
chrchr-github 9ea223b367
Fix #11309 debug: Scope::checkVariable found variable 'v' with varid 0 (#5006)
* Fix #11309 debug: Scope::checkVariable found variable 'v' with varid 0

* Format
2023-04-24 20:27:10 +02:00
chrchr-github bda9f707cc
Fix typedef in enum class (#4998) 2023-04-21 18:58:44 +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
chrchr-github e17af6d2d8
Report unknown macro (#4990) 2023-04-20 17:55:16 +02:00
chrchr-github bf3be95046
Fix #11453, #11490 internalAstError with templates (#4986)
* Fix #11490 internalAstError with unknown template in index expression

* Comment

* Fix #11490
2023-04-19 21:20:57 +02:00
chrchr-github 29e2a7ed34
Fix #11640 internalAstError with typedef matching member function [regression] (#4981) 2023-04-18 18:38:16 +02:00
tsteven4 4183336dc1
fix skipping of cpp attributes. (#4971)
* fix skipping of cpp attributes.

* fix simplifyCPPAttribute loop.

When the first token was the start of a c++ attribute on a function,
so that tok->previous() was nullptr at the bottom of the loop,
an extra token would be skipped.  This could result in the corresponding
function being omitted from the symbol table.

* fix alignas test failure, enhance cpp attr test.

* uncrustify.

* fix redundantNextPrevious

* delete redundant code.

* add some tokenizer tests for simplifyCPPAttribute.

* enhance noreturn symbol test.

The order of a noreturn attribute and another attribute used to
matter.  Test both orders.
2023-04-17 20:36:25 +02:00
Daniel Marjamäki afb9e43f2a dump: write container information 2023-04-12 21:57:37 +02:00
Daniel Marjamäki e59e34c0eb showtime: separate items properly 2023-04-11 19:52:55 +02:00
Daniel Marjamäki 3eeeaeffd2 Tokenizer::simplifyTypedef: ensure externC flag is preserved when simplifying typedefs 2023-04-09 09:38:12 +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
chrchr-github b2b0962067
Fix #11629 debug: Scope::checkVariable found variable 'np' with varid 0. (#4915) 2023-04-03 15:41:19 +02:00
chrchr-github a336048d14
Fix #11599 false negative: constParameter (#4902)
* Partial fix for #11599 false negative: constParameter

* Adjust test

* Update testother.cpp

* Update testother.cpp

* Fix #11599 false negative: constParameter

* Fix new warnings

* Format

* Add difference_type

* Remove isAliased()

* Undo

* Adjust test

* Add test

* Improve const check

* Tweak constness, add tests

* Add tests

* Use new helper function, fixtest

* Remove bailout, fix check for cast

* Prevent FP

* Fix constVariable check, add tests

* Format

* Format

* Add test for #11632
2023-04-02 20:36:23 +02:00
chrchr-github 89ec148199
Partial fix for #11638 Library::getFunctionName: SIGSEGV (#4920)
* Partial fix for #11638 Library::getFunctionName: SIGSEGV

* Fix test

* simpleMatch()
2023-03-30 07:25:26 +02:00
chrchr-github 13e12da08f
Fix #11639 findGarbageCode(): SIGSEGV (#4917) 2023-03-28 11:24:52 +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
chrchr-github 3ccd0505cd
Enable and mitigate readability-simplify-boolean-expr (#4897) 2023-03-17 13:51:55 +01:00
chrchr-github 980c92d19d
Partial fix for #11378 internalAstError regressions (iscpp11init) (#4884) 2023-03-12 15:39:02 +01:00
chrchr-github 809430631f
Partial fix for #11611 FP constStatement with typedef and unknown macro (#4881) 2023-03-12 11:13:58 +01:00
Mateusz Michalak 2d5cabed4b
Add std::*begin and std::*end cfg (#4796) 2023-03-09 17:06:53 +01:00
Daniel Marjamäki b0e8ed3117 dump: add more template info to dumpfile 2023-03-08 18:59:34 +01:00
Oliver Stöneberg 20db3ff368
SymbolDatabase: made `mTokenizer` and `mSettings` references (#4857) 2023-03-07 12:22:06 +01:00
Oliver Stöneberg a3cacf1ba1
TemplateSimplifier: made `mTokenizer` and `mSettings` references (#4856) 2023-03-07 12:12:31 +01:00
Daniel Marjamäki e8e00d8fdf Unused Var: Fix FP when initialization is made in macro 2023-03-05 15:31:53 +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
Oliver Stöneberg b70e1d5461
avoid some unchecked pointer dereferences (#4811) 2023-03-02 22:05:41 +01:00
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 8f5f06add7
some `Tokenizer` construction and related other cleanups (#4799) 2023-03-02 21:48:14 +01:00
chrchr-github 7f62d8ff98
Fix #11594 internalAstError with immediately instantiated enum (#4841) 2023-03-02 21:17:39 +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
Oliver Stöneberg 8583fcf96e
avoid more cases of returning non-const pointers from `const` objects (#4821) 2023-02-24 21:22:08 +01:00
chrchr-github d1e1f951df
Don't show checkLibraryNoReturn for functions with visible declaration (#11523, #11190) (#4809) 2023-02-24 06:49:28 +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
Oliver Stöneberg 8ef14dad98
fixed and enabled `performance-faster-string-find` clang-tidy warning (#4769) 2023-02-08 21:01:51 +01:00
Oliver Stöneberg 14e78e1800
greatly improved error handling in Cppcheck project file parsing / some cleanups (#4752) 2023-02-08 20:30:43 +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
chrchr-github 3ccc0adbca
Fix #11182 checkLibraryFunction with overloaded method / #11198 inconsistent reporting of checkLibraryNoReturn (#4740) 2023-01-26 22:29:49 +01:00
Oliver Stöneberg fd15811215
de-coupled `--check-library` from `information` severity and other dependencies (#3861) 2023-01-26 22:28:04 +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 3076f9def1
Fix #11449 Function call not recognized with extra parentheses / FP nullPointer (#4703) 2023-01-18 20:38:37 +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 9cf934c10d
Improve handling of 'final' in class declaration (#4706) 2023-01-18 17:08:43 +01:00
Armin Müller a77f0d9403
Typos found by running "codespell" (#4702) 2023-01-10 15:15:27 +01:00
chrchr-github 491721a6ff
Fix spurious variable declaration with unknown macro (#4694) 2023-01-09 16:11:26 +01:00
Oliver Stöneberg d3a2cdc26c
converted (undocumented) define `MAXTIME` into (undocumented) command-line options `--checks-max-time=`, `--template-max-time=` and `--typedef-max-time=` (#4661) 2022-12-30 21:21:05 +01:00
Oliver Stöneberg 1cfe49e340
use `const_iterator` where possible (#4662) 2022-12-30 15:13:47 +01:00
Oliver Stöneberg 3c68b9b29f
use `cbegin()` and `cend()` with `const_ierator` loops (#4658) 2022-12-20 20:32:16 +01:00