Commit Graph

663 Commits

Author SHA1 Message Date
Paul Fultz II 346ecdb53a
Improve valueflow after pushing to container (#4803) 2023-02-23 18:05:31 +01:00
Paul Fultz II 91d2526c41
Fix reverse analysis when modifying variable with function (#4800) 2023-02-23 18:04:16 +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
Paul Fultz II 2b9af94b9a
Fix 11548: FP knownConditionTrueFalse with empty() == false (#4788)
* Fix 11548: FP knownConditionTrueFalse with empty() == false

* Format

* Fix test
2023-02-11 10:42:13 +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
Oliver Stöneberg bea6aec2b2
extracted `ValueFlow::Value` to `vfvalue.{cpp|h}` (#4642) 2023-01-26 22:23:22 +01:00
chrchr-github 11f1a9d1f5
Fix crash on ternary with omitted operand (#4673)
* 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
Oliver Stöneberg 1cfe49e340
use `const_iterator` where possible (#4662) 2022-12-30 15:13:47 +01:00
Paul Fultz II e2f398f81a
Fix 11250: FN: bufferAccessOutOfBounds (comma operator: int x = (3,4) ) (#4636)
* Fix 11250: FN: bufferAccessOutOfBounds (comma operator: int x = (3,4) )

* Format
2022-12-13 07:52:58 +01:00
Paul Fultz II b4d455df48
Fix 11349: FP negativeIndex for clamped array index (#4627)
* 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 7d6683fb78
Fix #11417 FP knownConditionTrueFalse with container and brace init (#4606)
* Fix #11417 FP knownConditionTrueFalse with container and brace init

* Format

* Format

* Move to getInitListSize()
2022-12-02 22:07:08 +01:00
chrchr-github 3273e51fd5
Fix #10412 FN useStlAlgorithm with iterators (#4157) 2022-10-16 13:46:26 +02:00
Paul Fultz II d34de745c0
Fix 11306: FP knownConditionTrueFalse with strlen() (#4477)
* Fix 11306: FP knownConditionTrueFalse with strlen()

* Add another test
2022-09-18 08:29: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 e904f7341e
Fix ValueFlow crash (#4461) 2022-09-13 12:25:15 +02:00
Paul Fultz II 53820515c9
Set valueflow for container elements (#4455)
* Track elements to containers

* Format

* Handle other access methods

* Format
2022-09-10 09:26:44 +02:00
Oliver Stöneberg dbc05da356
fixed some clang-tidy warnings (#4435) 2022-09-08 20:01:41 +02:00
Paul Fultz II f83b8dd385
Fix 11194: FN: knownConditionTrueFalse (#4452)
* Fix 11194: FN: knownConditionTrueFalse

* Format
2022-09-08 18:51:44 +02:00
Paul Fultz II 6543b429c5
Fix 11285: FN: zerodiv (#4448)
* 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 (#4436)
* 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 #11294 FP arrayIndexOutOfBoundsCond with extra parentheses (#4442) 2022-09-06 21:21:06 +02:00
Paul Fultz II 2d37a77281
Fix 11296: FN: knownConditionTrueFalse ( a !=0 && b != 0 && a == 0) (#4444) 2022-09-06 07:31:48 +02:00
Oliver Stöneberg 1b4141cbe5
added more missing `sstream` includes (#4384) 2022-08-19 18:23:15 +02:00
chrchr-github 6a0c254d1f
Fix #9931 FP zerodiv (daca@home) (#4379)
* Fix #9931 FP zerodiv (daca@home)

* Format

* Parentheses

* clang-tidy
2022-08-18 20:38:36 +02:00
chrchr-github 15f8c71ec3
Fix #9946 FP: unassignedVariable when operator() is called subsequently (#4303) 2022-07-24 17:52:14 +02:00
Paul Fultz II 0b63e7273d
Fix 11162: FP: knownConditionTrueFalse (#4254)
* Fix 11162: FP: knownConditionTrueFalse

* Format
2022-07-09 00:57:25 +02:00
Paul Fultz II 9cecc8468e
Fix 10570: Improve check; condition then pointer dereference, different pointers (#4216)
* Try to use after assign in loop

* Update valueflow forward to handle init tokens

* Fix tests

* Make test TODO

* Format

* Add tests

* Format

* Fix ubsan error

* Use simpleMatch
2022-06-16 19:26:23 +02:00
Paul Fultz II d4fb5652c0
Fix 10619: Valueflow: Library function in subfunction does not propagate all values (#4209) 2022-06-12 07:17:28 +02:00
Paul Fultz II c9b85010f9
Fix 11096: FP knownConditionTrueFalse in do while loop (#4192)
* Check for loop

* Improve handling of exit values

* Add more checks to test

* Simplify

* Remove unnecessary test

* Fix typo

* Format

* Use simpleMatch
2022-06-10 20:42:02 +02:00
Paul Fultz II 72342de0da
Fix 11114: FP knownConditionTrueFalse across functions (#4163)
* Fix 11114: FP knownConditionTrueFalse across functions

* Format
2022-06-02 23:24:11 +02:00
Paul Fultz II d7c914bd3e
Handle subfunction values in valueflow conditions (#4128) 2022-05-29 19:57:10 +02:00
Paul Fultz II 5999b35130
Fix 10944: FN: knownConditionTrueFalse (#4124)
* Fix 10944: FN: knownConditionTrueFalse

* Use or

* Format
2022-05-23 23:22:08 +02:00
Paul Fultz II feaef46436
Fix 11076: Assert failure / crash with loop over init list (#4119) 2022-05-21 08:25:09 +02:00
Paul Fultz II 90e6c10c12
Fix 11072: FP arrayIndexOutOfBounds, nullPointer with nested loops (#4113)
* Fix 11072: FP arrayIndexOutOfBounds, nullPointer with nested loops

* Format

* Remove print statement
2022-05-18 08:29:30 +02:00
Paul Fultz II fbba72ab5a
Fix 11057: FP danglingTemporaryLifetime with reference member (#4103)
* Fix 11057: FP danglingTemporaryLifetime with reference member

* Add test

* Format

* Use ast for number of arguments

* Get number of arguments using ast

* Skip aggregate constructor when there are too many arguments

* Format
2022-05-13 06:51:07 +02:00
Paul Fultz II 5f9bee9b91
Fix 11056: FP uninitvar with known condition in loop (#4107)
* Fix 11056: FP uninitvar with known condition in loop

* Format
2022-05-12 06:37:48 +02:00
Paul Fultz II be6daa94bb
Fix 11053: Integer division by zero in calculate.h (#4092)
* Fix 11053: Integer division by zero in calculate.h

* Format
2022-05-09 20:27:32 +02:00
Paul Fultz II 69f09da63e
Fix 11044: FP knownConditionTrueFalse after early return (#4091)
* Fix 11044: FP knownConditionTrueFalse after early return

* Format
2022-05-09 20:26:52 +02:00
Paul Fultz II 474c7fe5cc
Fix 10953: False positive: Possible null pointer dereference when calling derived function (#4044) 2022-04-26 17:57:06 +02:00
Paul Fultz II 5d5562266d
ValueFlow: Assume constant is nonzero when its negated (#4041)
* ValueFlow: Assume constant is nonzero when its negated

* Format

* Format
2022-04-23 06:19:07 +02:00
Paul Fultz II 4eed29502c
ValueFlow: Set values to parameters to longjmp and setjmp (#4040)
* ValueFlow: Set values to parameters to longjmp and setjmp

* Format
2022-04-23 06:18:55 +02:00
Paul Fultz II 6deb8068fa
Fix 10981: ValueFlow: multiplication with 0 should have known value 0 (#4023) 2022-04-14 18:13:04 +02:00
Paul Fultz II 09597bc7e8
Fix 10956: ValueFlow: Incorrect value when assigned to two variables (#4019)
* Fix 10956: ValueFlow: Incorrect value when assigned to two variables

* Format
2022-04-14 07:35:07 +02:00
chrchr-github 5ac4afa5b8
Fix cppcheckError with spaceship operator (#10251) (#4001)
* Fix cppcheckError with starship operator (#10251)

* Fix test case

* Return result
2022-04-13 12:23:38 +02:00
Paul Fultz II 99757c6d06
ValueFlow: Set values to parameters to escape functions (#3994)
* ValueFlow: Set values to parameters to escape functions

* Format
2022-04-11 07:23:58 +02:00
Paul Fultz II 45b4580554
Fix 10957: Crash on valid code (#3991) 2022-04-10 22:47:58 +02:00
Paul Fultz II 74667d1e2a
Fix 10418: false negative: knownConditionTrueFalse (#3981)
* Improve handling inverted condition

* Fix tests

* Rename variables for clarity

* Add initial test

* Add another test

* Format

* Fix FP
2022-04-07 06:48:13 +02:00
Paul Fultz II bb640c4879
Fix 10950: Crash on function declaration (#3979)
* Fix 10950: Crash on function declaration

* Format
2022-04-06 19:00:05 +02:00
Paul Fultz II 1d92665ad2
Fix 10867: false negative: containerOutOfBounds with std::array (regression) (#3976)
* Fix 10867: false negative: containerOutOfBounds with std::array (regression)

* Format
2022-04-06 06:25:28 +02:00