Commit Graph

12333 Commits

Author SHA1 Message Date
chrchr-github 491721a6ff
Fix spurious variable declaration with unknown macro () 2023-01-09 16:11:26 +01:00
Oliver Stöneberg 8cc3e0b2ff
errortypes.h: use `enum class` instead of wrapping types into classes () 2023-01-08 19:31:54 +01:00
chrchr-github 911d610f2d
Fix FN unusedFunction when enum value with same name exists () 2023-01-08 14:30:42 +01:00
Paul Fultz II cefc105c5f
Fix 11468: false positive danglingTempReference warning () 2023-01-07 23:44:22 +01:00
chrchr-github b29f111082
Improve qt.cfg: unreadVariable for macro parameter () 2023-01-07 23:29:47 +01:00
chrchr-github 4ebdf5fae1
Fix FP identicalConditionAfterEarlyExit when passing *this () 2023-01-07 22:10:07 +01:00
Paul Fultz II 6020feb271
Fix 11461: arrayIndexOutOfBounds false positive () 2023-01-07 22:09:17 +01:00
chrchr-github 4c1c506d21
FP returnTempReference with cast and scope operator () 2023-01-02 22:13:56 +01:00
chrchr-github 2007cd0a1d
Fix FP returnDanglingLifetime/returnTempreference with typeid () 2023-01-02 17:46:03 +01:00
chrchr-github f793b7dd35
Fix unintvar false positive ()
* Fix  unintvar false positive

* Format
2023-01-02 17:44:52 +01:00
chrchr-github 11f1a9d1f5
Fix crash on ternary with omitted operand ()
* Fix MSVC compiler warning

* Fix crash on incomplete ternary operator

* Revert "Fix crash on incomplete ternary operator"

This reverts commit 28df0f0ab6ff794e733617447f847a97c1a7a609.

* Handle ternary with omitted operand
2023-01-02 17:44:17 +01:00
Daniel Marjamäki bf11cdf299 TestCmdLineParser: Add tests for ignored paths 2023-01-01 15:32:37 +01:00
Oliver Stöneberg 0c95971c54
added .gitattributes and normalized files () 2022-12-30 21:33:45 +01:00
Oliver Stöneberg 1cfe49e340
use `const_iterator` where possible () 2022-12-30 15:13:47 +01:00
orbitcowboy 3136a50b97 Formatting [ci skip] 2022-12-22 11:59:10 +01:00
orbitcowboy 347c10db3b posix.cfg: Improved configuration of mq_timedsend(). 2022-12-22 11:58:32 +01:00
orbitcowboy f5b9445767 posix.cfg: Added support for more posix_trace..() functions 2022-12-22 11:48:51 +01:00
orbitcowboy 3c57752c9b posix.cfg: Added support for more posix_trace..() functions 2022-12-22 11:39:00 +01:00
orbitcowboy 5991c33b0e posix.cfg: Added support for pthread_attr_getstack() and pthread_attr_setstack(). 2022-12-22 10:07:50 +01:00
orbitcowboy ccbc6a3b72 gnu.cfg: Added support for gethostbyname_r() and gethostbyname2_r() 2022-12-22 09:47:19 +01:00
orbitcowboy 3576f0a0c7 gnu.cfg: Added support for gethostbyaddr_r() 2022-12-22 09:36:53 +01:00
orbitcowboy ea56359a3f posix.cfg: Added nullPointer test for setkey() 2022-12-22 09:36:18 +01:00
orbitcowboy 24a71144f6 posix.cfg: Added support for encrypt() 2022-12-22 09:19:46 +01:00
orbitcowboy 7df6ba419e gnu.cfg: Added nullPointer tests for getop_long_only() 2022-12-22 09:13:18 +01:00
orbitcowboy 70ea3c2902 posix.cfg: Added nullPointer tests for getop() 2022-12-22 09:12:57 +01:00
orbitcowboy 521f0ce720 gnu.cfg: Added nullpointer tests for getopt_long(). 2022-12-21 17:06:08 +01:00
Oliver Stöneberg b380fd2589
added command-line option `--valueflow-max-iterations` to control amount of valueflow iterations / also log debug warning when iterations are being exceeded () 2022-12-20 20:51:08 +01:00
Oliver Stöneberg 3c68b9b29f
use `cbegin()` and `cend()` with `const_ierator` loops () 2022-12-20 20:32:16 +01:00
Paul Fultz II f8132ea022
Fix 11381: FP derefInvalidIteratorRedundantCheck when updating iterator using std::tie () 2022-12-20 20:29:19 +01:00
chrchr-github 7506b4ab52
Fix FP variableScope when lambda is used () 2022-12-20 14:50:31 +01:00
chrchr-github ad858e92dc
Partial fix for cppcheckError: Analysis failed (function not recognized) () 2022-12-19 22:29:43 +01:00
Paul Fultz II da32c5aecd
Fix 11442: new "Reference to temporary returned." FPs () 2022-12-19 22:28:59 +01:00
Oliver Stöneberg 2cd8bb94e4
some small `CmdLineParser` cleanups and improvements () 2022-12-19 22:28:36 +01:00
Paul Fultz II 9da574f4a0
Fix 11227: ValueFlow: Known value not set in condition for ternary operator ()
* Evaluate args before function call

* Fix tests

* Format

* Add test for 11227

* Format

* Fix known condition
2022-12-18 22:07:43 +01:00
Oliver Stöneberg 0ed98c8f29
removed unused test files () 2022-12-18 19:36:37 +01:00
chrchr-github 98b3d66684
Add test for () 2022-12-18 16:57:25 +01:00
chrchr-github 76c28073aa
Revert fix for () 2022-12-18 16:55:55 +01:00
chrchr-github 617cd29a41
Get type from auto () 2022-12-18 16:54:58 +01:00
chrchr-github b1abaf8809
Fix FP useStlAlgorithm (don't suggest std::accumulate when nothing is accumulated) () 2022-12-18 16:52:04 +01:00
gerboengels 63e30d1b8c
Fix syntaxError on lambda inside decltype ()
Use case where it gave an issue:

using customComparator = decltype([] (const X& lhs, const X& rhs) { return lhs.CompareTo(rhs); });
std::map<X, int, costomComparator> m;

Co-authored-by: Gerbo Engels <gerbo.engels@ortec-finance.com>
2022-12-18 16:46:04 +01:00
chrchr-github 4c8aa56d8b
Partial fix for internalAstError regressions (iscpp11init) ()
* Partial fix for  internalAstError regressions (iscpp11init)

* Use %cop%

* Add test for 

* Format

* Format
2022-12-16 10:46:15 +01:00
Paul Fultz II 9c55b933c1
Partial fix for 11303: False negative: knownConditionTrueFalse using container .back() ()
* Partial fix for 11303: False negative: knownConditionTrueFalse using container .back()

* Format

* Fix error message
2022-12-15 18:35:19 +01:00
Paul Fultz II 90898945c1
Fix 10532: False negative: dangling string_view when using ternary operator ()
* Fix 10532: False negative: dangling string_view when using ternary operator

* Format

* Update
2022-12-15 18:34:43 +01:00
chrchr-github 553b579f8d
Fix FP knownConditionTrueFalse with loop over bool array ()
* Fix  FP knownConditionTrueFalse with loop over bool array

* Simplify
2022-12-15 14:31:02 +01:00
chrchr-github 0c1e2ceeb9
Fix FP wrongPrintfScanfArgNum - snprintf with parameter pack () 2022-12-15 08:52:13 +01:00
chrchr-github b7693ccc7a
Fix FP resourceLeak with goto () 2022-12-14 22:47:14 +01:00
Oliver Stöneberg 29e0133cb5
extracted `FwdAnalysis` from `astutils.{cpp|h}` ()
* added missing filtering offiles in Visual Studio project

* extracted `FwdAnalysis` from `astutils.{cpp|h}`
2022-12-13 22:29:23 +01:00
Paul Fultz II e2f398f81a
Fix 11250: FN: bufferAccessOutOfBounds (comma operator: int x = (3,4) ) ()
* Fix 11250: FN: bufferAccessOutOfBounds (comma operator: int x = (3,4) )

* Format
2022-12-13 07:52:58 +01:00
Oliver Stöneberg e01c463ff8
fixed - improved handling of suffixes in `MathLib::to{Double|ULong|Long}Number()` ()
* fixed  - improved handling of suffices in `MathLib::to{Double|ULong|Long}Number()`

* testmathlib.cpp: adjustments for `libc++`

* mathlib.cpp: added TODO
2022-12-13 07:52:45 +01:00
Paul Fultz II b4d455df48
Fix 11349: FP negativeIndex for clamped array index ()
* Fix 11349: FP negativeIndex for clamped array index

* Format

* Use emplace_back

* Use default constructor
2022-12-13 07:50:01 +01:00
chrchr-github 5b687cb038
Fix Crash in valueFlowForwardConst() () 2022-12-12 22:58:48 +01:00
chrchr-github 3f5054035d
Fix FP passedByValue for overriden function () 2022-12-12 21:52:58 +01:00
Paul Fultz II 3f88744851
Fix 11358: FP containerOutOfBounds for container passed by pointer () 2022-12-09 19:43:21 +01:00
Oliver Stöneberg 40a69e5afb
optimized deserializing of `ErrorMessage` and related main process code () 2022-12-09 19:34:51 +01:00
Paul Fultz II 7acbb656f3
Fix 11412: False positive: uninitvar ()
* Dont remove modified variables from dead code

* Add test for 11412

* Format
2022-12-09 07:15:47 +01:00
Paul Fultz II c150317f02
Fix 11384: FP knownConditionTrueFalse when variable is modified in return statement ()
* Fix 11384: FP knownConditionTrueFalse when variable is modified in return statement

* Format
2022-12-09 07:15:15 +01:00
chrchr-github c779cefa61
Fix debug: Missing variable class for variable with varid () 2022-12-08 20:17:06 +01:00
Paul Fultz II 0cb742701d
Fix 11415: FP containerOutOfBounds for container initialized in virtual method () 2022-12-08 20:10:58 +01:00
chrchr-github 04b7c0c200
Fix FP knownConditionTrueFalse with iterator ()
* Fix wrong value set in valueFlowSameExpressions()

* Fix   FP knownConditionTrueFalse with iterator
2022-12-08 10:40:55 +01:00
Paul Fultz II 663a8411dd
Fix 11416: FP nullPointerRedundantCheck for check after loop with break () 2022-12-08 07:27:06 +01:00
Oliver Stöneberg 4103d05c7f
improved `ErrorMessage::deserialize()` error messages () 2022-12-07 18:00:45 +01:00
chrchr-github 8713dabe58
Get type from iterator () 2022-12-07 09:38:36 +01:00
Oliver Stöneberg 8bb5ac0efd
improved `MathLib::to{ULong|Long|Double}Number()` and increased test coverage / added CMake option `USE_LIBCXX` / fixed () 2022-12-07 09:20:09 +01:00
chrchr-github 89dba226dd
Fix FP uninitvar with unseen typedef () 2022-12-07 09:14:22 +01:00
chrchr-github 0e57c27dd3
Fix debug: CheckClass::checkConst found unlinked template argument list () 2022-12-07 09:12:46 +01:00
chrchr-github d5d7446433
Add cfg for std::scoped_lock, handle template arguments in checkMisusedScopedObject() () 2022-12-07 09:10:48 +01:00
Oliver Stöneberg 7d3ce62ee9
improved errorhandling related to deserializing `ErrorMessage` () 2022-12-03 15:44:33 +01:00
Rikard Falkeborn 9427fa3c66
Refactor runtests to allow to specify files on command line () 2022-12-03 15:41:11 +01:00
chrchr-github 0854fda28a
Get type from smartpointer ()
* Fix  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 7d6683fb78
Fix FP knownConditionTrueFalse with container and brace init ()
* Fix  FP knownConditionTrueFalse with container and brace init

* Format

* Format

* Move to getInitListSize()
2022-12-02 22:07:08 +01:00
chrchr-github e4ee7cd59c
Get type from 'auto p = new ...' ()
* Fix  checkLibraryFunction treats "auto" as type

* Use utility function

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

* Fix merge
2022-12-02 20:28:14 +01:00
chrchr-github 9efedd6be9
Fix checkLibraryFunction treats "auto" as type ()
* Fix  checkLibraryFunction treats "auto" as type

* Use utility function
2022-12-02 07:21:33 +01:00
chrchr-github 428f5016d4
Partial fix for (iscpp11init) ()
* Partial fix for  (iscpp11init)

* Improve fix

* Add fix
2022-11-27 09:26:46 +01:00
chrchr-github 665e4230f2
Fix FP returnDanglingLifetime, std::unique_ptr and implicit conversion to bool () 2022-11-27 09:24:19 +01:00
chrchr-github 4cb49013a7
Fix FP danglingTemporaryLifetime with std::string_view () 2022-11-27 09:22:55 +01:00
Rikard Falkeborn 52264b9c26
Fix nullpointer dereference with alignof ()
* checknullpointer: Don't report dereference with alignof

* Refactor unevaluating operator check in checknullpointer

Unifying these ensures the different checks treat the operators the
same.

* Fix FP with _Alignof and null pointer

Just like alignof, _Alignof does not evaluate its operand.

* CheckNullPointer: Also support compiler specific alignof

This fixes  which is about __alignof__. For good measure, also add
the microsoft extensions __alignof and _alignof.
2022-11-27 09:20:19 +01:00
Rikard Falkeborn 8465d901c8
Fix 11396, doublefree on munmap in if-statement () 2022-11-26 15:45:27 +01:00
Daniel Marjamäki c26a8fb4ce Fixed (Cant exclude file) 2022-11-24 13:45:57 +01:00
Stefan van Kessel a5c16af16d
Fix lambda capture template syntax error () 2022-11-23 20:15:10 +01:00
chrchr-github 68acd77053
Fix FP ctuPointerArith with unknown buffer size () 2022-11-23 19:11:47 +01:00
Daniel Marjamäki ad8c1e26f0 dump: output language to dumpfile 2022-11-20 12:30:09 +01:00
chrchr-github 9f50611a44
Fix FP doubleFree with goto () 2022-11-19 16:49:34 +01:00
chrchr-github 80aa6dc1d9
Fix FP mismatchAllocDealloc with std::unique_ptr and custom deleter () 2022-11-18 19:45:25 +01:00
gerboengels 3fdba645a6
Improve fix for FP selfAssignment: lambda capture () 2022-11-18 19:44:32 +01:00
chrchr-github 4ce76d0b58
Fix debug: SymbolDatabase::findFunction found '>' without link. () 2022-11-14 21:08:15 +01:00
chrchr-github e3939d32d0
Fix crash on nullptr ()
* Update tokenlist.cpp

* Update testincompletestatement.cpp

* Fix  FP constStatement with lambda

* Format

* Fix crash on nullptr

* Emit syntax error

* Fix test

* Use strAt()

* Fix another crash on nullptr

* Update testconstructors.cpp

* Fix crash on nullptr

* Fix test
2022-11-13 23:04:51 +01:00
chrchr-github 701d381895
Fix FP selfAssignment: lambda capture / FP operatorEqRetRefThis ()
* Fix   FP selfAssignment: lambda capture /  
FP operatorEqRetRefThis

* Format
2022-11-13 21:20:44 +01:00
chrchr-github e8b37235d6
Fix internalAstError regressions (iscpp11init) () 2022-11-12 22:25:05 +01:00
Daniel Marjamäki 8fb8e06003 SymbolDatabase: Set valuetype for this 2022-11-12 22:23:42 +01:00
chrchr-github 4e75c08f58
Respect [[maybe_unused]] in unusedPrivateFunction () 2022-11-10 20:58:39 +01:00
Armin Müller 7f74aad8e2
Typos found by running "codespell" () 2022-11-09 22:52:03 +01:00
chrchr-github ffc0c57562
Fix crashes on nullptr () 2022-11-09 21:56:16 +01:00
gerboengels bd95efc987
Fix internal error "Unexpected tokens in initializer" with anonymous namespace ()
Co-authored-by: Gerbo Engels <gerbo.engels@ortec-finance.com>
2022-11-05 22:41:13 +01:00
Daniel Marjamäki e45e5f9f15 SymbolDatabase: fix ValueType for '&array[x]' 2022-11-05 21:22:08 +01:00
Daniel Marjamäki ecb2938e7e SymbolDatabase: Set correct ValueType when there is array-to-pointer decay 2022-11-05 17:38:31 +01:00
gerboengels d7a8f7f297
Fix couple issues with missing operatorEqVarError () 2022-11-05 10:48:34 +01:00
omarandlorraine 6488650d24
use python3 on debians too ()
* use python3 on debians too

in Debian 11 which is Bullseye, /usr/bin/python is a Python2
interpreter, which means that cppcheck-htmlreport fails to run here.
So I've chenged the shebang to use python3

* change all shebangs from python to python3

Co-authored-by: Sam M W <smw@alertergroup.co.uk>
2022-11-03 22:14:30 +01:00
Rikard Falkeborn 3c21b9cc53
Fix , FP memory leak in if-statement in realloc with cast () 2022-11-03 10:37:43 +01:00
chrchr-github e4c5f36af0
Fix typedef: not simplified after inline keyword () 2022-11-02 15:15:33 +01:00
chrchr-github ccf2176664
Fix FP constStatement with lambda ()
* Update tokenlist.cpp

* Update testincompletestatement.cpp

* Fix  FP constStatement with lambda

* Format
2022-11-01 11:50:08 +01:00
chrchr-github d717e62ec3
Fix Detect assignment to temporary ()
* Fix  Detect assignment to temporary

* Use AST

* Warn if type definition is not seen
2022-11-01 11:46:42 +01:00
chrchr-github cf8051b7e2
Fix FP "Same value in both branches of ternary operator" on plus and minus zero ()
Fix  FP "Same value in both branches of ternary operator" on plus and minus zero
2022-10-31 15:18:25 +01:00
chrchr-github 6df8573e15
Fix Syntax error. Unexpected tokens in initializer. () 2022-10-29 21:24:50 +02:00
chrchr-github b4e78e8ac5
Fix new internalAstError ()
* Fix  new internalAstError

* Format

* Handle scope operator

* Format

* Format
2022-10-25 21:50:37 +02:00
chrchr-github 3b5601dbea
Add tests for , ()
* Add test for 

* Add test for 
2022-10-25 19:41:48 +02:00
chrchr-github 13d81cdd58
follow-up: Handle more variadic template arguments ()
* Update templatesimplifier.cpp

* Add tests
2022-10-22 00:28:33 +02:00
chrchr-github ae16aab997
Handle simple typedefs () 2022-10-22 00:28:05 +02:00
chrchr-github e046232535
Fix FP returnDanglingLifetime for pointer to struct member in static array ()
* Fix   FP returnDanglingLifetime for pointer to struct member in static array

* Undo
2022-10-22 00:27:30 +02:00
chrchr-github 515369739c
Fix FP constStatement for function-local struct definition+initialization statement () 2022-10-22 00:27:19 +02:00
Razvan Ioan Alexe 1da37461e3
Typo found in Summary of CWE: 758 () 2022-10-20 19:11:15 +02:00
chrchr-github 7b9c99003b
Improve unreachableCodeError: handle library functions ()
* Update templatesimplifier.cpp

* Add tests

* Improve unreachableCodeError message

* Update templatesimplifier.cpp

* Add tests

* Improve unreachableCodeError message

* Revert "Update templatesimplifier.cpp"

This reverts commit 3fd152ed4063772a5f162bd985c3d91bcc65eb55.

* Revert "Add tests"

This reverts commit e760ab51e66a0a2c3a0250caf4cf3b745db44d10.

* Improve unreachableCodeError: handle library functions

* Fix merge
2022-10-20 07:00:36 +02:00
chrchr-github 9c7b4c9540
Improve unreachableCodeError message ()
* Update templatesimplifier.cpp

* Add tests

* Improve unreachableCodeError message

* Update templatesimplifier.cpp

* Add tests

* Improve unreachableCodeError message

* Revert "Update templatesimplifier.cpp"

This reverts commit 3fd152ed4063772a5f162bd985c3d91bcc65eb55.

* Revert "Add tests"

This reverts commit e760ab51e66a0a2c3a0250caf4cf3b745db44d10.
2022-10-19 19:19:31 +02:00
chrchr-github 192c30ab1d
Fix crash in arraySize() ()
* Fix   FN: arrayIndexOutOfBounds

* Fix

* Fix crash in arraySize()
2022-10-19 19:19:01 +02:00
gerboengels 6a01fa9b70
Fix broken AST with (designated) initializers ()
* 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 } ()

- _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 5a8e55c083
Fix FN: arrayIndexOutOfBounds ()
* Fix   FN: arrayIndexOutOfBounds

* Fix
2022-10-18 07:24:24 +02:00
chrchr-github c6c339a3e7
Fix Assert failure in templatesimplifier.cpp () 2022-10-16 19:34:25 +02:00
gerboengels 221873e69f
Fix ()
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
Oliver Stöneberg 2ac9fbc1bf
include all (internal non-generated) headers in clang-tidy checks () 2022-10-16 13:51:17 +02:00
chrchr-github 3273e51fd5
Fix FN useStlAlgorithm with iterators () 2022-10-16 13:46:26 +02:00
chrchr-github 6c24d2b865
Fix FP uninitvar for in-class member initialization () 2022-10-14 19:48:27 +02:00
chrchr-github 544ec38ca9
Add test for () 2022-10-14 11:55:45 +02:00
Daniel Marjamäki b8b6be48d9 Fixed (False positive assertWithSideEffects, calling method that has no side effects) 2022-10-12 07:51:50 +02:00
Daniel Marjamäki 2a81388c95 Fixed (False positive: unreadVariable when union in derived struct is used) 2022-10-11 20:47:07 +02:00
chrchr-github c51fb3864a
Add test for () 2022-10-11 07:23:28 +02:00
Daniel Marjamäki 584a428025 Fixed ("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 ()
* 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
Daniel Marjamäki 65cd6ea7b4 Clarify knownConditionTrueFalse warnings 2022-10-10 13:45:30 +02:00
Paul Fultz II bd22ea565f
Use return instead of condition for alwaysTrueFalse check () 2022-10-09 21:03:48 +02:00
Oliver Stöneberg fa7e08a29f
optimized `CheckOther::checkDuplicateBranch()` a bit () 2022-10-09 20:48:54 +02:00
Oliver Stöneberg d1bfae989e
fixed handling of incomplete char/string literals in `isPrefixStringCharLiteral()` - also optimized it a bit ()
* fixed handling of incomplete char/string literals in `isPrefixStringCharLiteral()` - also optimized it a bit / added tests for `isStringLiteral()` and `isCharLiteral()`

* utils.h: early out in `isStringCharLiteral()` to avoid the loop
2022-10-09 11:19:19 +02:00
Oliver Stöneberg 7ead32f96e
various optimizations ()
* avoid potentially duplicated `strTolower()` call in `Path::getFilenameExtensionInLowerCase()`

* avoid unnecessary copies

* use `unordered_*` containers for faster lookups

* symboldatabase.cpp: do not perform call in `checkReturns()` until needed

* astutils.cpp: do not perform calls in `isVariableChangedByFunctionCall()` until necessary

* tokenize.cpp: small `hasIfDef()` optimization

* use `unordered_map` for `CheckUnusedFunctions::FunctionUsage::mFunctions` / adjusted test case
2022-10-06 20:12:07 +02:00
Oliver Stöneberg ee124cd097
modernized `erase()` calls () 2022-10-02 07:13:31 +02:00
Oliver Stöneberg cff1cd9cda
applied clang-tidy `misc-const-correctness` fixes for POD types, iterators and references ()
* 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 586c29c772
Partial fix for False negative: stlOutOfBounds, cast ()
* Fix leakNoVarFunctionCall FP

* Partial fix for  False negative: stlOutOfBounds, cast
2022-09-30 14:43:21 +02:00
chrchr-github 4d13266e99
Fix FN unusedScopedObject: temporary lock 'std::lock_guard<std::mutex>(m)' ()
* Fix  FN unusedScopedObject: temporary lock 'std::lock_guard<std::mutex>(m)'

* Format

* Fix cppcheck-cfg.rng

* Format
2022-09-30 07:25:33 +02:00
chrchr-github 6142ba542a
Fix leakNoVarFunctionCall FP () 2022-09-29 21:58:11 +02:00
chrchr-github 260a757791
Fix internalAstError with function returning a function () 2022-09-29 21:56:26 +02:00
chrchr-github b8b6b41833
Fix Broken AST lambda inside for loop ()
* Fix  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 33fde8ae6b
Add tests for , ()
* Add test for , avoid duplicate warning

* Add test for 

* Fix test

* Merge

* Add test for 

* Fix  checkLibraryCheckType with asm goto() (invalid varid)

* Format

* Add tests for , 

* Fix test

* Add test for 

* Add tests for , 
2022-09-29 12:33:34 +02:00
chrchr-github 32c7b919ba
Add tests for , , ()
* Add test for , avoid duplicate warning

* Add test for 

* Fix test

* Merge

* Add test for 

* Fix  checkLibraryCheckType with asm goto() (invalid varid)

* Format

* Add tests for , 

* Fix test

* Add test for 
2022-09-29 07:05:29 +02:00
chrchr-github 56e2af5dec
Fix FP leakReturnValNotUsed although (void) is specified () 2022-09-27 20:09:04 +02:00
Oliver Stöneberg b9e07e918e
enabled and fixed `readability-named-parameter` clang-tidy warnings () 2022-09-27 20:03:25 +02:00
chrchr-github cab4997b0b
Fix Empty AST with delete new / FP leakReturnValNotUsed with new and offset ()
* Fix internalAstError with new

* Format

* nullptr check

* Add test for 

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

* Format

* nullptr check
2022-09-26 22:05:58 +02:00
chrchr-github 64f3f85804
Fix Function::addArguments found argument 'b' with varid 0 wit… ()
* Fix  Function::addArguments found argument 'b' with varid 0 with lambda parameter

* Fix varid0 warning
2022-09-26 18:21:21 +02:00
Paul Fultz II fc39a4d1bb
Fix 11171: False positive: missing return statement when std::enable_if_t is used ()
* Fix 11171: False positive: missing return statement when std::enable_if_t is used

* Format

* Return false

* Workaround bug in cppcheck
2022-09-26 18:20:42 +02:00
orbitcowboy 2bdeaf858e Added regression test for ticket - FP: Using object that is a temporary 2022-09-24 22:11:04 +02:00
chrchr-github 2808fc615e
Fix "statement without effect" / FN unusedScopedObject does not work for classes in different namespace ()
* Partial fix for  unused variable without assignment not detected

* Add test for 

* Fix  FN unusedScopedObject does not work for classes in different namespace

* Merge

* Fix  "statement without effect" (unused variable without assignment) not detected

* Format
2022-09-24 12:49:37 +02:00
Oliver Stöneberg dc03a50414
some small cleanups and refactorings ()
* moved `plistFile` from `ErrorLogger` to `CppCheck`

* got rid of global CWE objects

* lib/CMakeLists.txt: suppress some `-Wfloat-equal` clang warning in matchcompiled builds as well

* lib/CMakeLists.txt: moved a loop into proper block

* test/CMakeLists.txt: simplified `add_fixture`

* test/CMakeLists.txt: moved `fixture_cost`

* fixed `naming-privateMemberVariable` selfcheck warning
2022-09-24 11:59:13 +02:00
chrchr-github d608bec414
Fix FP with std::array ()
* Fix  wrong usage of std::string in memcpy

* Fix memsetClass FP

* Fix  FN memset on container containing structs with containers

* Token::Match

* Use AST

* simpleMatch

* Fix FP with std::array

* simpleMatch
2022-09-23 20:18:49 +02:00
chrchr-github 0bb82b70d9
Fix FN functionStatic, functionConst with this ()
* Fix  FN functionStatic, functionConst with this

* Fix FP
2022-09-23 08:46:31 +02:00
chrchr-github bb2ba53bf5
Add tests for , ()
* Add test for 

* Add test for 
2022-09-22 19:41:29 +02:00
Jim Kuhn f27fbdd8ab
Fix sense of test (.analyzerinfo files get placed in wrong directory) ()
* Fix sense of test (.analyzerinfo files get placed in wrong directory)

* Update testanalyzerinformation.cpp

style (tabs -> spaces)
2022-09-21 17:38:23 +02:00
chrchr-github 3b07661fd3
Fix debug: CheckClass::isMemberVar found used member variable 'x' with varid 0 () 2022-09-21 17:35:10 +02:00
chrchr-github 2aca275e0c
Fix FN memset on container containing structs with containers ()
* Fix  wrong usage of std::string in memcpy

* Fix memsetClass FP

* Fix  FN memset on container containing structs with containers

* Token::Match

* Use AST

* simpleMatch
2022-09-21 17:33:48 +02:00
chrchr-github 3644d79162
Fix duplicateConditionalAssign FP ()
* Fix  FN redundant assignment of Boolean variable

* Fix warning, refactor

* Update testcondition.cpp

* Fix duplicateConditionalAssign FP

* Format
2022-09-20 21:57:27 +02:00
chrchr-github 48999cf1d1
Add support for std::ofstream::precision() ()
* Add support for std::copy_n/merge/stable_sort

* Format

* Add support for std::unordered_set::count(), std::push_heap

* Missing include

* Add support for std::iota

* Missing include

* Add support for std::ofstream::precision()

* Typo

* Typo
2022-09-20 17:23:18 +02:00
chrchr-github 2ce25abd81
Add support for std::iota ()
* Add support for std::copy_n/merge/stable_sort

* Format

* Add support for std::unordered_set::count(), std::push_heap

* Missing include

* Add support for std::iota

* Missing include
2022-09-20 07:30:24 +02:00
chrchr-github dcb332acb0
Fix FN redundant assignment of Boolean variable ()
* Fix  FN redundant assignment of Boolean variable

* Fix warning, refactor

* Update testcondition.cpp
2022-09-20 07:30:12 +02:00
chrchr-github f274d499a1
Fix FP missing return statement when std::enable_if_t is used ()
* Fix  FP missing return statement when std::enable_if_t is used

* Add check
2022-09-19 12:47:58 +02:00
Paul Fultz II 09944c0b7e
Fix 11298: FP danglingTemporaryLifetime when constructing from const char* ()
* Fix 11298: FP danglingTemporaryLifetime when constructing from const char*

* Format
2022-09-18 08:30:58 +02:00
Paul Fultz II de7d02293f
Fix 11308: FP accessMoved with virtual function ()
* Fix 11308: FP accessMoved with virtual function

* Format
2022-09-18 08:30:06 +02:00
Paul Fultz II d34de745c0
Fix 11306: FP knownConditionTrueFalse with strlen() ()
* Fix 11306: FP knownConditionTrueFalse with strlen()

* Add another test
2022-09-18 08:29:10 +02:00
Oliver Stöneberg 8126d5c1a6
improved `TestCmdlineParser` () 2022-09-17 18:50:25 +02:00
chrchr-github cb6f04a16c
Fix FP zerodivcond from enum definition / FP unassignedVariable with static variable ()
* Fix  FP zerodivcond from enum definition

* Simplify Boolean expression

* Fix  FP unassignedVariable with static variable
2022-09-17 18:50:07 +02:00
Oliver Stöneberg 897826006e
mitigated some clang-tidy warnings in headers ()
* erroritem.h: avoid `performance-no-int-to-ptr` clang-tidy warning

* suppress `readability-inconsistent-declaration-parameter-name` clang-tidy warnings for Qt signals

* tokenlist.h: mitigated `readability-make-member-function-const` clang-tidy warnings

* fixed `modernize-use-override` clang-tidy warnings in headers

* fixed `modernize-pass-by-value` clang-tidy warnings in headers

* tokenize.cpp: avoid unnecessary copy
2022-09-16 18:59:15 +02:00
Oliver Stöneberg 339484d2a1
mitigated and enabled more clang-tidy warnings ()
* 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
chrchr-github 45ccc9ba1e
Fix ctunullpointer FP () 2022-09-16 12:11:34 +02:00
Oliver Stöneberg b3ec225480
iwyu.yml: use `debian:unstable` to always get latest include-what-you-use / cleaned up includes ()
* 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 d6aab96734
Add support for std::unordered_set::count(), std::push_heap ()
* Add support for std::copy_n/merge/stable_sort

* Format

* Add support for std::unordered_set::count(), std::push_heap

* Missing include
2022-09-16 07:12:36 +02:00
chrchr-github c9ade33298
Fix memsetClass FP () 2022-09-15 20:20:49 +02:00
chrchr-github 7111270d5f
Add support for std::copy_n/merge/stable_sort ()
* Add support for std::copy_n/merge/stable_sort

* Format
2022-09-15 19:56:45 +02:00
chrchr-github d1386a842a
Fix debug: constStatementError not handled. ()
* Fix  debug: constStatementError not handled.

* Use function
2022-09-14 23:57:02 +02:00
chrchr-github 266174ddc4
Fix danglingTemporaryLifetime reported in two different locati… ()
* Fix  danglingTemporaryLifetime reported in two different locations for std::string_view usage

* Missing include

* Add test
2022-09-14 07:28:04 +02:00
chrchr-github 07caf17eb3
Fix wrong usage of std::string in memcpy () 2022-09-13 15:14:25 +02:00
chrchr-github e904f7341e
Fix ValueFlow crash () 2022-09-13 12:25:15 +02:00
Paul Fultz II 43caa32abf
Fix 9755: false negative: access of moved variable in conditional code ()
* Fix 9755: false negative: access of moved variable in conditional code

* Format
2022-09-11 12:32:01 +02:00
Paul Fultz II 53820515c9
Set valueflow for container elements ()
* Track elements to containers

* Format

* Handle other access methods

* Format
2022-09-10 09:26:44 +02:00
Paul Fultz II 117a753b10
Partial fix 11154: FN: knownConditionTrueFalse ()
* Partial fix 11154: FN: knownConditionTrueFalse

* Formay

* Add more tests

* FOrmat

* Fix FP

* Add test

* Check for side effects

* Format

* Update tests

* Format
2022-09-08 22:08:38 +02:00
Oliver Stöneberg dbc05da356
fixed some clang-tidy warnings () 2022-09-08 20:01:41 +02:00
Paul Fultz II 7c986fbef1
Fix 11203: false positive: knownConditionTrueFalse 'always false' when comparing integer with floating-point () 2022-09-08 19:59:02 +02:00
Paul Fultz II f83b8dd385
Fix 11194: FN: knownConditionTrueFalse ()
* Fix 11194: FN: knownConditionTrueFalse

* Format
2022-09-08 18:51:44 +02:00
Daniel Marjamäki 92845295b8 Fix broken CI caused by my qt fix 2022-09-08 11:12:38 +02:00
Paul Fultz II 32d96104d6
Fix 6370: ValueFlow: array element with known value ()
* Fix 6370: ValueFlow: array element with known value

* Format

* Move comment
2022-09-07 19:16:07 +02:00
Paul Fultz II 6543b429c5
Fix 11285: FN: zerodiv ()
* Fix 11285: FN: zerodiv

* Format
2022-09-07 19:15:37 +02:00
Oliver Stöneberg 54771306c5
selfcheck : cleaned up some suppressions, fixed warnings and some cleanups ()
* 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 6960332f8a
Fix FP arrayIndexOutOfBoundsCond with extra parentheses () 2022-09-06 21:21:06 +02:00
Oliver Stöneberg b3762cd76a
actually perform system tinyxml2 build on macos / fixed system tinyxml2 include ()
* lib/CMakeLists.txt: removed unnecessary external include

* look up tinyxml2 include dir when using system one and specify it

* lib/CMakeLists.txt: do not treat bundled headers as system ones

* CI-unixish.yml: actually perform system tinyxml2 build on macos
2022-09-06 18:30:59 +02:00
Paul Fultz II 2d37a77281
Fix 11296: FN: knownConditionTrueFalse ( a !=0 && b != 0 && a == 0) () 2022-09-06 07:31:48 +02:00
Paul Fultz II 016793f258
Fix 11295: Regression FP: knownConditionTrueFalse () 2022-09-06 07:31:38 +02:00
chrchr-github 31118fdce5
Fix noreturn FP with while() ()
* Fix checkLibraryFunction FPs

* Fix FP with fclose()

* Format

* Fix FP with reinterpret_cast

* Fix noreturn FP with while()
2022-09-04 10:26:31 +02:00
Paul Fultz II 6ce5c24f21
Refactor knownConditionTrueFalse check and isUsedAsBool function ()
* Refactor knownConditionTrueFalse check and isUsedAsBool function

* Format1

* Format

* Skip assign
2022-09-04 10:24:45 +02:00
Maksim Derbasov f93b588603
New check: use memcpy/memset instead of loop () 2022-09-03 23:29:06 +02:00
chrchr-github cf52ee098a
Fix checkLibraryFunction FPs ()
* Fix checkLibraryFunction FPs

* Fix FP with fclose()

* Format

* Fix FP with reinterpret_cast
2022-09-02 07:51:10 +02:00
chrchr-github 79daad8ff4
Fix FP arrayIndexOutOfBounds if string literals are assigned conditionally () 2022-09-01 22:59:46 +02:00
Daniel Marjamäki 4779f0e172 TemplateSimplifier: Fixed instantiation when template parameters are A<..>, B<..> 2022-09-01 20:24:01 +02:00
chrchr-github 5804cc44e7
Fix FP bufferAccessOutOfBounds ()
* Fix FN with buffer size 1

* Fix FP bufferAccessOutOfBounds
2022-08-31 19:31:37 +02:00
chrchr-github 3925a27182
Fix FP knowConditionTrueFalse ()
* Fix  FN (style) Condition 's.empty()' is always false

* Fix test

* Fix FP knowConditionTrueFalse

* Check for casts

* Fix FP for user-defined functions

* Adjust condition detection

* Tweaks
2022-08-30 18:08:24 +02:00
chrchr-github 9ab4f9976d
Fix FN (style) Condition 's.empty()' is always false ()
* Fix  FN (style) Condition 's.empty()' is always false

* Fix test
2022-08-29 12:25:10 +02:00
chrchr-github 1e14e360cb
Fix FN (error) Buffer is accessed out of bounds (wcpncpy, wcsncpy) ()
* Fix  FN (error) Buffer is accessed out of bounds (wcpncpy, wcsncpy)

* Fix cfg, validation

* Fix validation
2022-08-29 12:24:58 +02:00
chrchr-github df704361f6
Fix FN with buffer size 1 () 2022-08-29 12:24:44 +02:00
Daniel Marjamäki a400c94230 Update Copyrights 2022-08-28 14:22:12 +02:00
Daniel Marjamäki 5e0fc24bb7 Fixed (Syntax Error: AST broken, binary operator '!=' doesn't have two operands) 2022-08-27 18:02:19 +02:00
chrchr-github 7156afe003
Fix FN (error) buffer access out of bounds - known argument ()
* Fix  FN (error) buffer access out of bounds - known argument const char* argv[]

* Format
2022-08-26 17:27:54 +02:00
chrchr-github b815153b0c
Add test for () 2022-08-26 11:36:47 +02:00
chrchr-github 917496a844
Fix FN destructor with no definition hide mismatching alloc/dealloc ()
* Fix  FN destructor with no definition hide mismatching allocation / deallocation

* Format

* Fix test

* Format
2022-08-25 22:52:51 +02:00
chrchr-github 456c6b410e
Fix FN known strcpy parameter ()
* Fix  FN known strcpy parameter

* Parentheses

* Format
2022-08-24 21:23:45 +02:00
Daniel Marjamäki 112852f70b formatting 2022-08-24 08:53:59 +02:00
Oliver Stöneberg 467648bec6
fixed (potential hang with -j and --showtime= when using threads) - synchronized access to `TimerResults::mResults` / added TSAN to CI () 2022-08-23 20:30:45 +02:00
chrchr-github 13e8d5220c
Fix another c_strParam regression () 2022-08-23 20:26:36 +02:00
chrchr-github 4be7f689d7
Fix c_strParam regression ()
* Fix  New check: Not needed c_str() operation

* Comment

* Detect more instances of c_str() misuse

* Fix bad merge

* Check for data() also

* Fix

* Format

* Format

* Fix c_strParam regression
2022-08-23 15:00:27 +02:00
chrchr-github 66fca7ba91
Detect more instances of c_str() misuse ()
* Fix  New check: Not needed c_str() operation

* Comment

* Detect more instances of c_str() misuse

* Fix bad merge

* Check for data() also

* Fix

* Format

* Format
2022-08-22 14:06:10 +02:00
PKEuS d81a758850
LCppC backports: Refactorizations/Optimizations () 2022-08-21 17:21:02 +02:00
chrchr-github d351a97a0f
Fix FN stlcstrParam ()
* Fix  New check: Not needed c_str() operation

* Comment

* Fix error messages

* Handle more complex string expressions

* Fix  FN stlcstrParam

* Handle iterators

* Format

* Format

* Parentheses
2022-08-21 13:04:43 +02:00
Oliver Stöneberg 1202efb438
some `--exception-handling` related improvements () 2022-08-20 20:54:31 +02:00
chrchr-github b04bf7396f
Fix New check: Not needed c_str() operation () 2022-08-20 20:52:10 +02:00
chrchr-github 5cc8ef7e87
Add test for ()
* Add test for 

* Add test for 

* Revert
2022-08-20 19:23:55 +02:00
Oliver Stöneberg 1d95d1908d
refs - sped up `Library::detectContainerOrIterator()` by iterating the containers only once () 2022-08-20 12:14:55 +02:00
chrchr-github 2ab8de2650
Fix FP negativeMemoryAllocationSize with possible value () 2022-08-20 07:56:31 +02:00
Oliver Stöneberg f138df2909
mathlib.h: replaced slow `std::ostringstream` with `std::to_string()` in `MathLib::toString()` () 2022-08-19 20:44:24 +02:00
chrchr-github 80a486dda0
Fix FP virtual call in destructor even though class is final / Delete 'final' from specializations ()
* Add 'final' keyword

* Delete 'final' from specializations

* Fix  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 () 2022-08-19 18:23:15 +02:00
chrchr-github 1aa259569e
Fix syntax error : int (operator"" _ii)(unsigned long long v) … ()
* Fix  syntax error : int (operator"" _ii)(unsigned long long v) { return v; }

* Format
2022-08-18 23:38:45 +02:00
chrchr-github 2fee7a6e3f
Add test for , ()
* Add test for 

* Add test for 

* Add test for 

* Format

* Add test for 

* Format

* Add test for 
2022-08-18 23:37:41 +02:00
chrchr-github 6a0c254d1f
Fix FP zerodiv (daca@home) ()
* Fix  FP zerodiv (daca@home)

* Format

* Parentheses

* clang-tidy
2022-08-18 20:38:36 +02:00
chrchr-github 4a64e20592
unusedScopedObject: Don't warn for void statements ()
* Fix unusedScopedObject FPs

* Simplify

* Simplify

* Fix test

* Don't warn for void statements

* Format
2022-08-17 19:45:46 +02:00
chrchr-github e9f1665d4f
Add test for ()
* Add test for 

* Add test for 

* Add test for 

* Format
2022-08-17 19:38:37 +02:00
chrchr-github 0978cc2d46
Add tests for , () 2022-08-17 10:01:49 +02:00
chrchr-github 5b4c6c1e73
Fix FP pointerOutOfBounds with strlen() () 2022-08-17 09:45:07 +02:00
chrchr-github 1a95515e47
Fix unusedScopedObject FPs () 2022-08-17 09:11:23 +02:00
chrchr-github 3dc2c0bd42
Fix FN constStatement with misused comma () 2022-08-16 22:10:58 +02:00
Oliver Stöneberg 31d704e4bc
cppcheckexecutor.cpp: extracted platform-dependent code into separate files () 2022-08-16 22:03:44 +02:00
Oliver Stöneberg 4bf5dcd29f
cleaned up includes based on include-what-you-use ()
* cleaned up includes based on include-what-you-use

* testlibrary.cpp: no need for `empyString` optimization
2022-08-14 12:44:19 +02:00
chrchr-github afef71f6b6
Partial fix for unused variable without assignment not detected ()
* Partial fix for  unused variable without assignment not detected

* Add test for 
2022-08-13 08:29:06 +02:00
Paul Fultz II bfd9470600
Fix 11158: FP zerodiv in loop ()
* Fix 11158: FP zerodiv in loop

* Format

* Add another test

* Format

* Fix FP

* Format
2022-08-13 08:27:20 +02:00
chrchr-github bdbd84ba98
: Fix regression ()
* Fix  FP knownConditionTrueFalse with constexpr?

* Modify isConstVarExpression()

* Use predicate

* Format

* : Fix regression
2022-08-09 13:13:16 +02:00
chrchr-github 974e34490f
Fix FP Unused private function () 2022-08-07 20:06:32 +02:00
chrchr-github 078a6d7804
Fix FP knownConditionTrueFalse with constexpr? () 2022-08-07 19:06:19 +02:00
chrchr-github d5a0dfda00
Fix checkLibraryCheckType with asm goto() (invalid varid), add test for ()
* Add test for , avoid duplicate warning

* Add test for 

* Fix test

* Merge

* Add test for 

* Fix  checkLibraryCheckType with asm goto() (invalid varid)

* Format
2022-08-04 21:35:18 +02:00
Paul Fultz II c0f55a2b85
Fix 11142: FP nullPointer before assignment ()
* Fix 11142: FP nullPointer before assignment

* Format

* Use simpleMatch
2022-08-03 19:05:07 +02:00
Paul Fultz II 6cb3a79a64
Fix 11147: FP invalidContainer with substr() ()
* Fix 11147: FP invalidContainer with substr()

* Format
2022-08-03 19:04:44 +02:00
chrchr-github dd927aab9b
Fix checkLibraryNoReturn with unassigned object ()
* Handle float values

* Fix  checkLibraryNoReturn with unassigned object
2022-08-03 19:04:10 +02:00
chrchr-github a62c3ea90e
Fix Broken AST with auto**, FP constStatement () 2022-08-03 19:03:38 +02:00
chrchr-github 0eabe0505b
Handle float values () 2022-08-02 22:11:31 +02:00
chrchr-github 71f9a7269f
Add test for , , avoid duplicate warning ()
* Add test for , avoid duplicate warning

* Add test for 

* Fix test
2022-08-02 21:43:18 +02:00
chrchr-github bc409776e3
Fix Wrong redundant condition: misleading/wrong message ()
* Fix  Wrong redundant condition: misleading/wrong message

* Use expressionString()

* Clarify condition

* Update testcondition.cpp

* Trigger CI
2022-08-02 18:31:02 +02:00
chrchr-github 92d569afb6
FP: knownConditionTrueFalse (wrong message text) ()
*  FP: knownConditionTrueFalse (wrong message text)

* Format

* Update testcondition.cpp

* Trigger CI
2022-08-02 18:18:46 +02:00
chrchr-github 38fdbe0890
Fix Syntax error for function-try-block in global scope ()
* Fix  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 c878285a42
Add tests for , , , () 2022-07-30 16:15:32 +02:00
orbitcowboy 1934386738 windows.cfg: deprecate '_alloca()'. Ref. https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/alloca?view=msvc-170 2022-07-29 21:41:32 +02:00
Oliver Stöneberg efaaa58896
fixed some `modernize-use-emplace` false negatives and some `bugprone-assignment-in-if-condition` warnings () 2022-07-28 22:53:59 +02:00
chrchr-github 304e448749
Fix --check-library reports missing configuration for static_assert () 2022-07-28 22:47:15 +02:00
chrchr-github c340b6ae6c
Fix FP moduloofone with pow() () 2022-07-28 22:11:23 +02:00
Daniel Marjamäki 898ad314ab badBitmaskCheck: Avoid FP when there is #ifdef in expression 2022-07-28 21:56:05 +02:00
chrchr-github 3fc276fb51
Add test for () 2022-07-26 11:14:35 +02:00
chrchr-github 58d7185d64
Fix FP functionConst when overloaded operator ++ is used () 2022-07-26 08:30:59 +02:00
chrchr-github 15f8c71ec3
Fix FP: unassignedVariable when operator() is called subsequently () 2022-07-24 17:52:14 +02:00
chrchr-github 479533a80a
Rework fix for () 2022-07-24 12:15:04 +02:00
chrchr-github 1aceded300
Fix FP noExplicitConstructor with variadic template () 2022-07-24 10:18:19 +02:00
chrchr-github 0d72216cca
Fix BufferOverrun TODO ()
* Fix BufferOverrun TODO

* clang-tidy
2022-07-22 07:24:34 +02:00
chrchr-github 79f091c59a
Fix uselessCallsConstructor TODOs ()
* Fix uselessCallsConstructor TODOs

* Format
2022-07-21 22:15:16 +02:00
chrchr-github 5342e2cd03
Fix FP knownConditionTrueFalse with dynamic_cast () 2022-07-20 20:48:17 +02:00
chrchr-github 457a0cff87
Fix FP unusedStructMember when used through iterator (regression) ()
* Format

* Fix  FP unusedStructMember when used through iterator (regression)

* Format

* Fix test

* Format

* Nullptr check
2022-07-19 20:42:54 +02:00
chrchr-github 5e537a666f
Fix --check-library warning for int(i) () 2022-07-19 20:41:18 +02:00
chrchr-github c736fe8787
Fix FP doubleFree with pointer in struct () 2022-07-19 20:41:08 +02:00
chrchr-github 6dc606fd6a
Add tests for , , () 2022-07-18 18:03:08 +02:00
Daniel Marjamäki db155a59c1 Tokenizer: remove simplifyTokenList2 2022-07-18 16:20:36 +02:00
chrchr-github b08aabefee
Fix FP unreadVariable (incomplete code; missing macro definition) () 2022-07-17 19:40:39 +02:00
orbitcowboy 4de443957c gnu.cfg: Added support for error() function. And a TODO testcase for ticket . 2022-07-17 14:43:52 +02:00
chrchr-github 4894cdab8f
Fix FP unreadVariable with unique_ptr and unknown c'tor ()
* Fix  FP unreadVariable with unique_ptr and unknown c'tor

* Fix test
2022-07-16 23:46:55 +02:00
chrchr-github b16d12b5fb
Improve check for wchar_t () 2022-07-16 23:46:10 +02:00
chrchr-github 109a031ec7
Fix Add redundantContinue check () 2022-07-16 16:02:58 +02:00
chrchr-github 9e74da6126
Fix FP compare with negated constant () 2022-07-16 07:28:15 +02:00
chrchr-github 71d386819e
Fix FP bufferAccessOutOfBounds is reported on strncmp() ()
* Add test

* Fix  FP bufferAccessOutOfBounds is reported on strncmp()

* Remove suppressions
2022-07-15 17:43:18 +02:00
chrchr-github 53cd3dc665
Fix FP extern function reported as unused () 2022-07-14 20:59:58 +02:00
chrchr-github 2543dc97d2
Fix FP bitwiseOnBoolean () 2022-07-14 20:59:39 +02:00
chrchr-github 2c7d98626a
Fix FP leakNoVarFunctionCall with Qt object ()
* Add missing <leak-ignore/>, test

* Fix qt.cfg, format

* Fix FP leakNoVarFunctionCall

* Format

* Delete memory, rule of five

* Missing include

* Avoid dependency

* explicit

* Fix Qt test case

* Fix typo

* Fix

* Add Q_OBJECT
2022-07-13 21:09:53 +02:00
chrchr-github 6eab3cb8bd
Fix ctu: false negative array index out of bounds for array arguments () 2022-07-13 21:08:51 +02:00
chrchr-github 49117f5aeb
Fix static_assert shouldn't be reported by --check-library ()
* No need to check smart pointers, since they take template arguments

* Fix  static_assert shouldn't be reported by --check-library
2022-07-13 21:08:43 +02:00
chrchr-github b31e40f578
Add tests for , , , ()
* Add tests for , 

* Add test for 

* Add test for 
2022-07-13 21:08:30 +02:00
Daniel Marjamäki b387ae80f1 Fixed whole program analysis 2022-07-12 22:58:52 +02:00
Daniel Marjamäki fa5fd9cae0 Fixed (Unmatched suppression for inline suppression even though --suppress=unmatchedSuppression is used) 2022-07-12 22:51:26 +02:00
PKEuS f3565e1056
Improvement: Support member variables in CheckOther::checkIncompleteArrayFill() ()
Merged from LCppC.
2022-07-12 19:43:48 +02:00
chrchr-github 381c38b2f5
Improve check: uselessCallsConstructor () 2022-07-12 17:40:14 +02:00
Oliver Stöneberg 22be5f29aa
fixed (checkLibraryFunction with parameter to "std::string()") / added rudimentary tests for `CheckFunctions::checkLibraryMatchFunctions()` / added test for () 2022-07-12 17:39:01 +02:00
Oliver Stöneberg aea4fd1068
some `TestSuppressions` improvements and cleanups () 2022-07-12 17:36:36 +02:00
chrchr-github 47c2a01392
Fix inefficient way to remove last character from std::string ()
* Fix  inefficient way to remove last character from std::string

* Format

* Modify message, add test

* Format

* Fix another warning
2022-07-11 23:07:37 +02:00
chrchr-github c5dcd49dae
Fix FN: Bitwise operation with bool and int ()
* Fix  FN: Bitwise operation with bool and int

* Format
2022-07-11 22:58:37 +02:00
chrchr-github 8fc75402a1
Fix FP invalidFunctionArgStr () 2022-07-11 22:58:19 +02:00
chrchr-github f9337b725b
Fix nullptr deref ()
* Fix some FNs related to c_str()

* Format, fix FP

* Fix nullptr deref

* Fix merge
2022-07-11 22:58:08 +02:00
chrchr-github c218859418
Fix some FNs related to c_str() () 2022-07-10 11:38:01 +02:00
chrchr-github f5c4a21eae
Fix FN redundantCopyLocalConst () 2022-07-10 11:33:24 +02:00
Oliver Stöneberg c36320747f
some `missingInclude`/`missingIncludeSystem` fixes and tests ()
* do not emit `missingInclude` and `missingIncludeSystem` errors when not enabled / fixed and improved TestPreprocessor::inline_suppression_for_missing_include()

* testpreprocessor.cpp: added missing tests for `missingInclude` and `missingIncludeSystem`

* cppcheckexecutor.cpp: `missingIncludeSystem` was not emitted in normal analysis if `missingInclude` existed

* dmake

* added `run-dmake` as `testrunner` dependency
2022-07-09 23:21:11 +02:00
orbitcowboy c117f62926 Fixed zerodiv/moduloofone FNs for more math functions 2022-07-09 22:36:17 +02:00
orbitcowboy 8215521843 Fixed zerodiv/moduloofone FNs for more math functions 2022-07-09 19:59:16 +02:00
orbitcowboy ef47d34e75 Fixed zerodiv/moduloofone FNs for more math functions 2022-07-09 19:21:58 +02:00
orbitcowboy 0282c3a86e Fixed zerodiv/moduloofone FN for '1/std::expm1(0)' 2022-07-09 17:52:58 +02:00
orbitcowboy 07eeee1620 Fixed zerodiv FN for '1/std::exp2(0)' 2022-07-09 17:47:21 +02:00
orbitcowboy 048d31ec56 Fixed zerodiv FN for '1/std::erfc(42)' 2022-07-09 17:43:17 +02:00
orbitcowboy 87c1e6587a Fixed zerodiv FN for '1/std::erf(0)' 2022-07-09 17:38:28 +02:00