Commit Graph

296 Commits

Author SHA1 Message Date
Oliver Stöneberg 639a4131c4
changed `bool_to_string()` to return `const char*` instead and use it in more cases (#5385) 2023-09-11 11:34:22 +02:00
Daniel Marjamäki 276f017fbe
Partial fix for #11897 (Safety: show what checks are enabled/disabled) (#5372)
Example output on stdout:
```
$ ./cppcheck m1.cpp 
Checking m1.cpp ...
Active checkers: 59/177
```
2023-08-29 12:00:52 +02:00
Paul Fultz II 2adaafd20e
Fix 11887: FP knownPointerToBool with const_cast (#5357) 2023-08-23 01:07:49 +02:00
Paul Fultz II 03b952d5eb
Fix 11579: false negative: knownConditionTrueFalse with non-bool as bool parameter (#5349)
This adds a new checker to check for pointer to bool conversions that
are always known. I removed the previous knownConditionTrueFalse checks
since this was too noisy.
2023-08-20 22:32:41 +02:00
chrchr-github 827e87afe7
Fix #11579 FN knownConditionTrueFalse with non-bool as bool parameter / #9450 string literal to bool conversion in function call (#5338) 2023-08-18 10:32:52 +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
Anton Lindqvist b9cc138e57
Fix FP badBitmaskCheck in nested binary expressions (#5316)
If one operand is another binary expression, recursively ensure that no
nested operands are expanded macros.
2023-08-11 23:06:24 +02:00
Oliver Stöneberg dcdf67a694
some `-Wdouble-promotion` Clang compiler warnings (#4820) 2023-08-07 20:44:25 +02:00
Anton Lindqvist 4ebb8eaf0c
Ignore zero valued enum entries from badBitmaskCheck (#5195)
Usage of zero valued enum entries can be used for documenting purposes
and should be ignored just like zeroes expanded from macros.
2023-06-26 10:43:20 +02:00
chrchr-github bb962e2bc3
Enable and mitigate readability-else-after-return (#5175) 2023-06-20 18:43:21 +02:00
chrchr-github 2b92351b49
Fix #11679 FP knownArgument with known return value (#5007)
* Fix #11679 FP knownArgument with known return value

* Add test for #11051
2023-04-28 08:27:48 +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 3ccd0505cd
Enable and mitigate readability-simplify-boolean-expr (#4897) 2023-03-17 13:51: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
Daniel Marjamäki 464fbe8d53 Update copyright year 2023-01-28 10:16:34 +01:00
Oliver Stöneberg bea6aec2b2
extracted `ValueFlow::Value` to `vfvalue.{cpp|h}` (#4642) 2023-01-26 22:23:22 +01:00
chrchr-github 4ebdf5fae1
Fix #11478 FP identicalConditionAfterEarlyExit when passing *this (#4684) 2023-01-07 22:10:07 +01:00
Oliver Stöneberg 1cfe49e340
use `const_iterator` where possible (#4662) 2022-12-30 15:13:47 +01:00
chrchr-github 3273e51fd5
Fix #10412 FN useStlAlgorithm with iterators (#4157) 2022-10-16 13:46:26 +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 (#4446) 2022-10-09 21:03:48 +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 3644d79162
Fix duplicateConditionalAssign FP (#4484)
* Fix #9406 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 dcb332acb0
Fix #9406 FN redundant assignment of Boolean variable (#4482)
* Fix #9406 FN redundant assignment of Boolean variable

* Fix warning, refactor

* Update testcondition.cpp
2022-09-20 07:30:12 +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
Paul Fultz II 117a753b10
Partial fix 11154: FN: knownConditionTrueFalse (#4453)
* 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
Paul Fultz II 016793f258
Fix 11295: Regression FP: knownConditionTrueFalse (#4443) 2022-09-06 07:31:38 +02:00
Paul Fultz II 6ce5c24f21
Refactor knownConditionTrueFalse check and isUsedAsBool function (#4432)
* Refactor knownConditionTrueFalse check and isUsedAsBool function

* Format1

* Format

* Skip assign
2022-09-04 10:24:45 +02:00
chrchr-github 3925a27182
Fix FP knowConditionTrueFalse (#4419)
* Fix #10426 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 #10426 FN (style) Condition 's.empty()' is always false (#4414)
* Fix #10426 FN (style) Condition 's.empty()' is always false

* Fix test
2022-08-29 12:25:10 +02:00
Oliver Stöneberg 16f598c409
added missing `sstream` includes (#4381) 2022-08-19 10:16:23 +02:00
chrchr-github 078a6d7804
Fix #11238 FP knownConditionTrueFalse with constexpr? (#4341) 2022-08-07 19:06:19 +02:00
chrchr-github 0eabe0505b
Handle float values (#4336) 2022-08-02 22:11:31 +02:00
chrchr-github bc409776e3
Fix #10320 Wrong redundant condition: misleading/wrong message (#4334)
* Fix #10320 Wrong redundant condition: misleading/wrong message

* Use expressionString()

* Clarify condition

* Update testcondition.cpp

* Trigger CI
2022-08-02 18:31:02 +02:00
Oliver Stöneberg efaaa58896
fixed some `modernize-use-emplace` false negatives and some `bugprone-assignment-in-if-condition` warnings (#4311) 2022-07-28 22:53:59 +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 596f75e2af
Fix FP compareValueOutOfTypeRangeError (#4245)
* Fix FP compareValueOutOfTypeRangeError

* Remove suppressions
2022-07-01 10:48:32 +02:00
PKEuS 1275b5275e
LCppC backport: Various optimizations (#4182)
* Optimization: Use Token::eIncDecOp instead of expensive Token::Match calls

Merged from LCppC.

* Small Optimizations: - Moved a std::set that is only need during initialization of SymbolDatabase to function scope - Use std::vector instead of std::list

Merged from LCppC.

* Optimization: Refactorized various Token::Match calls and surrounding conditions

Merged from LCppC.

* Refactorization: Cleanup usage of std::multimap

Merged from LCppC.
2022-06-08 16:58:57 +02:00
chrchr-github b80d06b69e
Don't warn for 'x | MACRO' when MACRO is 0 (#4176) 2022-06-07 21:13:31 +02:00
chrchr-github 52453947c8
Don't warn for 'x | 0' in macro (#4172)
* Fix #11082 FN badBitmaskCheck for binary or with 0

* Add test for #10703

* Don't warn for 'x | 0' in macro

* Add test for #10876
2022-06-06 11:17:36 +02:00
chrchr-github f962436826
Fix #11082 FN badBitmaskCheck for binary or with 0 (#4170)
* Fix #11082 FN badBitmaskCheck for binary or with 0

* Add test for #10703
2022-06-04 17:25:10 +02:00
chrchr-github 2a7f00cf9a
Fix #8545 FN Condition '...' is always true ' uint16_t i; ( i <= 0xFFFF)' (#4114) 2022-05-21 08:33:42 +02:00
chrchr-github 63a1698335
Fix #11059 FP multiCondition when variable is assigned in if/else (#4102) 2022-05-11 20:01:13 +02:00
chrchr-github 28a024ac4a
Fix #9954 incorrectLogicOperator/knownConditionTrueFalse for constexpr (#4002) 2022-04-11 20:42:54 +02:00
chrchr-github 2bccde0e3b
Fix #9789 FP Logical condition considered always false (#3985) 2022-04-09 14:09:10 +02:00
Daniel Marjamäki 3989408738 Update copyright year 2022-02-05 11:45:17 +01:00
Oliver Stöneberg 171da2e6f9
avoid dependency on transitive includes - based on include-what-you-use (#3757) 2022-01-27 19:03:20 +01:00
chrchr-github 8df25ec4e9
Fix #8266 identicalConditionAfterEarlyExit variable modified in if-clause (#3610) 2021-12-18 22:52:54 +01:00
Oliver Stöneberg ba777b54d1
prevent uncaught exception in ThreadExecutor::handleRead() (#3514) 2021-10-20 20:41:42 +02:00