Commit Graph

105 Commits

Author SHA1 Message Date
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 bfb50ca9d8
removed unnecessary `Settings` parameter from `Check::runChecks()` and made `Tokenizer` a reference (#5308)
There was no need for the `Tokenizer` parameter to be a pointer as it
could never be `nullptr` and was also dereferenced without checking
first.

As a reference to the `Settings` was already available via the
`Tokenizer` there was no need to pass it separately. In the production
code there will only be one instance of it but in the tests we could
have accidentally passed a different one.
2023-08-18 12:03:50 +02:00
chrchr-github 5ff8955dbe
Fix #11862 FP truncLongCastAssignment with increment (#5290) 2023-08-03 13:49:11 +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
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
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 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
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
Oliver Stöneberg 7c7ccdf7c0
Check: disallow more than one instance per check (#4749) 2023-01-29 17:23:03 +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 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
Oliver Stöneberg 1b4141cbe5
added more missing `sstream` includes (#4384) 2022-08-19 18:23:15 +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
Oliver Stöneberg f32583e097
removed OVERRIDE and FINAL defines and use the keywords directly (#3767) 2022-02-10 23:02:24 +01: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
orbitcowboy b2d81f0870 Ticket #8640: Added regression test 2021-12-19 17:43:32 +01:00
chrchr-github ca311ebcdf
ASSERT() on calls to Tokenizer::tokenize() in test code (#3501) 2021-11-29 07:34:39 +01:00
Paul Fultz II 7f358b2bed
Format with uncrustify (#3388) 2021-08-07 20:51:18 +02:00
Paul Fultz II 486e440c4a
Fix 10298: ValueFlow: Wrong known value, 'x == -1' implicit unsigned cast for rhs (#3277) 2021-06-04 17:17:41 +02:00
keinflue d2184ac6a8
Fix UB on right-shift. (#3235) 2021-04-28 11:57:28 +02:00
Daniel Marjamäki 42437277dc Update Copyright year 2021-03-21 20:58:32 +01:00
Rikard Falkeborn 103e52f394
Fix tokenizing of x[i](0) (Fixes #8875) (#3167)
Fix faulty removal of parenthesis when "]" is followed by parenthesis
with a number inside, for example when calling a function pointer in
an array or (perhaps more common) in c++, calling operator ( on an
element in an array.

Fixes #8875 where such wrong simplification lead to a FP with too many
bits shifted due to "<<" was interpreted like a shift operator rather
than a stream output.
2021-03-11 08:16:25 +01:00
PKEuS 141d2ac215 Refactorization: Improved internal implementation of severity and certainty levels
Backported from LCppC.
2021-02-24 22:00:06 +01:00
PKEuS cf1937294a Refactorization: Removed unnecessary \n and spaces in strings
Merged from LCppC.
2021-02-20 12:58:42 +01:00
Daniel Marjamäki b3b7ecc7ea Removed integerOverflowOptimization checking and merged functionality into invalidTestForOverflow 2021-01-05 11:38:19 +01:00
Daniel Marjamäki 52491f1c53 Signed integer optimisations; Also warn about 'x+y<x' 2021-01-03 22:12:19 +01:00
Daniel Marjamäki 6375fb4f08 New check: Warn about nonportable code that can be optimised (signed integer overflow) 2021-01-03 21:03:07 +01:00
Rikard Falkeborn 7973fd843c Refactor: Simplify checkSignConversion
The loop only checks astoperand1 and astoperand2. Simplify the condition
to loop over these instead of using a stack. Also, add a testcase for
when astoperand2 is negative.
2020-07-20 11:16:56 +02:00
Daniel Marjamäki 08ddd84780 Update copyright year 2020-05-10 11:16:32 +02:00
Daniel Marjamäki 3e0218299b Revert "Update copyright year"
This reverts commit 6eec6c4bd5.
2020-05-10 11:13:05 +02:00
Daniel Marjamäki 6eec6c4bd5 Update copyright year 2020-05-10 11:11:34 +02:00
Rikard Falkeborn f6e7fb4bd9
Bugfix valuetype for some integer constants (#2545) 2020-02-19 07:51:39 +01:00
Rikard Falkeborn 4dbf006dc7 Fix severity of c++14 shifts with too many bits (#2213)
For c++14, shifting a variable with a value larger than or equal to the
number of bits in the variable is undefined. Left-shifting with a value
equal to the number of bits of the variable is implementation defined.

See also trac ticket #9306.
2019-09-25 20:16:04 +02:00
Paul Fultz II ad8abdb0c3 Add impossible values to ValueFlow (#2186)
* Add impossible category

* Replace values

* Try to adjust known values

* Add ! for impossible values

* Add impossible with possible values

* Remove contradictions

* Add values when the branch is not dead

* Only copy possible values

* Dont bail on while loops

* Load std lib in valueflow

* Check for function calls

* Fix stl errors

* Fix incorrect impossible check

* Fix heap-after-use error

* Remove impossible values when they are lowered

* Show the bound and remove overlaps

* Infer conditions

* Dont push pointer values through dynamic_cast

* Add test for dynamic_cast issue

* Add shifttoomanybits test

* Add test for div by zero

* Add a test for issue 9315

* Dont make impossible value inconclusive

* Fix FP with shift operator

* Improve handleKnownValuesInLoop for impossible values

* Fix cppcheck warning

* Fix impossible values for ctu

* Bailout for streams

* Check equality conditions

* Fix overflows

* Add regression test for 9332

* Remove duplicate conditions

* Skip impossible values for invalid value

* Check for null

* Rename bound to range

* Formatting
2019-09-20 15:06:37 +02:00
Paul Fultz II e8435b9ecb Fix issue 9306: Adjust shiftTooManyBitsSigned for C++14 (#2127) 2019-08-31 07:40:57 +02:00
Paul Fultz II aaeec462e6 Re-enable valueFlowSubFunction (#2063)
* Re-enable valueFlowSubFunction

* Formatting

* Skip ternary operators in subfunctions

* Fix test with iostreams

* Fix FP with multiple parameters
2019-08-05 16:26:32 +02:00
Daniel Marjamäki 20278d9c92 Clarify signConversion warning message 2019-08-05 12:41:08 +02:00
Daniel Marjamäki 7c0b011c05 Fixed #9230 (Improve check: integer conversion overflow in return) 2019-07-24 16:17:52 +02:00
Daniel Marjamäki 421a8da6a8 Try to clarify signConversion message 2019-07-17 22:41:24 +02:00
Scott Furry a195477470 Correct Zero/Null as pointer constant (#1938)
Building with enhanced clang warnings indicated a large number of
instances with the warning:

`warning: zero as null pointer constant`

Recommended practice in C++11 is to use `nullptr` as value for
a NULL or empty pointer value. All instances where this warning
was encountered were corrected in this commit.

Where warning was encountered in dependency code (i.e. external library)
no chnages were made. Patching will be offered upstream.
2019-06-30 21:39:22 +02:00
Rikard Falkeborn 68869438be Refactoring: Use range based for loops (#1817) 2019-05-02 06:53:07 +02:00
Rikard Falkeborn 1cc5f3abe7 Set wchar_t type (#1807)
This is necessary for valueflow to know the size, for example when
calculating sizeof(wchar_t).
2019-05-01 16:34:28 +02:00
Daniel Marjamäki bd7790fd8c Update copyright year 2019-02-09 07:24:06 +01:00
Daniel Marjamäki 8dd641b8be Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
Daniel Marjamäki b79619832e Clarify warning 2018-12-23 12:42:18 +01:00