Oliver Stöneberg
71cdacdc97
fixed missing location for `valueFlowMaxIterations` debug warning / also added it to daca server overview ( #4664 )
2022-12-30 21:20:00 +01:00
Oliver Stöneberg
1cfe49e340
use `const_iterator` where possible ( #4662 )
2022-12-30 15:13:47 +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 ( #4557 )
2022-12-20 20:51:08 +01:00
Oliver Stöneberg
3c68b9b29f
use `cbegin()` and `cend()` with `const_ierator` loops ( #4658 )
2022-12-20 20:32:16 +01:00
Paul Fultz II
9da574f4a0
Fix 11227: ValueFlow: Known value not set in condition for ternary operator ( #4653 )
...
* 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
dc5c5de10e
avoid some unnecessary copies ( #4589 )
2022-12-18 19:38:29 +01:00
chrchr-github
b1abaf8809
Fix FP useStlAlgorithm (don't suggest std::accumulate when nothing is accumulated) ( #4647 )
2022-12-18 16:52:04 +01:00
Daniel Marjamäki
7799f820a3
Refactoring: Use static for local function getMinMaxValues
2022-12-17 21:21:18 +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
Paul Fultz II
3f88744851
Fix 11358: FP containerOutOfBounds for container passed by pointer ( #4626 )
2022-12-09 19:43:21 +01:00
Paul Fultz II
6eccb2e36c
Throw internal error when tokens are not in order ( #4623 )
...
* Throw internal error when tokens are not in order
* Add semicolon
2022-12-09 07:17:16 +01:00
Paul Fultz II
7acbb656f3
Fix 11412: False positive: uninitvar ( #4624 )
...
* 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 ( #4625 )
...
* Fix 11384: FP knownConditionTrueFalse when variable is modified in return statement
* Format
2022-12-09 07:15:15 +01:00
Paul Fultz II
0cb742701d
Fix 11415: FP containerOutOfBounds for container initialized in virtual method ( #4622 )
2022-12-08 20:10:58 +01:00
chrchr-github
04b7c0c200
Fix #11404 FP knownConditionTrueFalse with iterator ( #4619 )
...
* Fix wrong value set in valueFlowSameExpressions()
* Fix #11404 FP knownConditionTrueFalse with iterator
2022-12-08 10:40:55 +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
chrchr-github
6c24d2b865
Fix #11321 FP uninitvar for in-class member initialization ( #4547 )
2022-10-14 19:48:27 +02:00
Daniel Marjamäki
ca32cf11ba
Fix handling of --performance-valueflow-max-time=T
2022-10-04 20:01:19 +02:00
Daniel Marjamäki
8686997292
Add experimental option --performance-valueflow-max-time=T
2022-10-04 14:02:55 +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
Oliver Stöneberg
eeb6db05f1
avoid some unnecessary object creations and copies ( #4493 )
2022-09-29 21:47:17 +02:00
Oliver Stöneberg
0481edf9c3
return `SmallVector` from `followAllReferences()` ( #3925 )
2022-09-29 21:41:32 +02:00
Oliver Stöneberg
b9e07e918e
enabled and fixed `readability-named-parameter` clang-tidy warnings ( #4487 )
2022-09-27 20:03:25 +02:00
Paul Fultz II
09944c0b7e
Fix 11298: FP danglingTemporaryLifetime when constructing from const char* ( #4479 )
...
* 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 ( #4478 )
...
* 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() ( #4477 )
...
* Fix 11306: FP knownConditionTrueFalse with strlen()
* Add another test
2022-09-18 08:29:10 +02:00
Oliver Stöneberg
339484d2a1
mitigated and enabled more clang-tidy warnings ( #4470 )
...
* 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
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
Oliver Stöneberg
76d1b9f31a
avoid unnecessary copies with `emplace_back()` ( #4450 )
...
* avoid unnecessary copies with `emplace_back()`
* cmdlineparser.cpp: suppress `accessMoved` selfcheck false positives
2022-09-10 11: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
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
Oliver Stöneberg
dbc05da356
fixed some clang-tidy warnings ( #4435 )
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 ( #4350 )
2022-09-08 19:59:02 +02:00
Paul Fultz II
f83b8dd385
Fix 11194: FN: knownConditionTrueFalse ( #4452 )
...
* Fix 11194: FN: knownConditionTrueFalse
* Format
2022-09-08 18:51:44 +02:00
Oliver Stöneberg
d46ea7ba86
avoid unnecessary copies with `push_back()` and `push_front()` ( #4451 )
2022-09-08 09:21:35 +02:00
Paul Fultz II
32d96104d6
Fix 6370: ValueFlow: array element with known value ( #4447 )
...
* 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 ( #4448 )
...
* Fix 11285: FN: zerodiv
* Format
2022-09-07 19:15:37 +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
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
456c6b410e
Fix #2304 FN known strcpy parameter ( #4396 )
...
* Fix #2304 FN known strcpy parameter
* Parentheses
* Format
2022-08-24 21:23:45 +02:00
Oliver Stöneberg
0e1cd8b2ac
do not do C++ processing for C code in `parsedecl()` ( #4304 )
2022-08-21 17:11:22 +02:00
Oliver Stöneberg
d73a33d17e
avoid redundant `Token::declEndToken()` calls ( #4363 )
2022-08-20 20:50:14 +02:00
Oliver Stöneberg
16f598c409
added missing `sstream` includes ( #4381 )
2022-08-19 10:16:23 +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
Oliver Stöneberg
98b9f2cbf1
reduced scope of some variables and avoided some copies ( #4328 )
2022-08-16 22:28:39 +02:00
Paul Fultz II
bfd9470600
Fix 11158: FP zerodiv in loop ( #4356 )
...
* Fix 11158: FP zerodiv in loop
* Format
* Add another test
* Format
* Fix FP
* Format
2022-08-13 08:27:20 +02:00
Paul Fultz II
c0f55a2b85
Fix 11142: FP nullPointer before assignment ( #4319 )
...
* Fix 11142: FP nullPointer before assignment
* Format
* Use simpleMatch
2022-08-03 19:05:07 +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
Oliver Stöneberg
b65b47d3a8
enabled and fixed `modernize-pass-by-value` clang-tidy warnings ( #4169 )
2022-07-28 22:51:45 +02:00
chrchr-github
c340b6ae6c
Fix #11191 FP moduloofone with pow() ( #4312 )
2022-07-28 22:11:23 +02:00
Oliver Stöneberg
0005be1dbf
some cleanups ( #4308 )
2022-07-26 08:28:55 +02:00
Oliver Stöneberg
b2f15fdbb1
reduced padding in some classes/structs ( #4295 )
2022-07-24 10:17:11 +02:00
chrchr-github
5342e2cd03
Fix #11037 FP knownConditionTrueFalse with dynamic_cast ( #4297 )
2022-07-20 20:48:17 +02:00
Oliver Stöneberg
4316884123
valueflow.cpp: avoid some copies related to `ErrorPath` ( #4160 )
2022-07-20 10:57:49 +02:00
chrchr-github
9e74da6126
Fix #11098 FP compare with negated constant ( #4282 )
2022-07-16 07:28:15 +02:00
Armin Müller
0ae9877766
Typos found by running "codespell" ( #4260 )
2022-07-10 22:40:05 +02:00
chrchr-github
f5c4a21eae
Fix #10704 FN redundantCopyLocalConst ( #4115 )
2022-07-10 11:33:24 +02:00
Paul Fultz II
edebe746bc
Fix 10361: false negative: uninitvar (std::next(iterator)) ( #4256 )
2022-07-09 07:39:04 +02:00
Paul Fultz II
0b63e7273d
Fix 11162: FP: knownConditionTrueFalse ( #4254 )
...
* Fix 11162: FP: knownConditionTrueFalse
* Format
2022-07-09 00:57:25 +02:00
Daniel Marjamäki
29402b4d1a
Fix Coverity CID1490221 warning. settings is dereferenced and then checked.
2022-07-05 07:46:39 +02:00
Paul Fultz II
e735376f7d
Refactor to use AST for isContainerSizeChanged ( #4222 )
2022-06-19 08:17:05 +02:00
Paul Fultz II
e6fdcb9de2
Refactor to use derefShared ( #4220 )
2022-06-19 08:16:27 +02:00
Paul Fultz II
3e09503561
Fix 11087: false negative: usage of reference to member of temporary object not detected ( #4217 )
...
* Fix 11087: false negative: usage of reference to member of temporary object not detected
* Format
* Add another test case
* Fix FP with pointer
* Format
2022-06-16 19:26:36 +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
de51ebbcf4
Fix 9135: Access of moved variable not detected in loop ( #4215 )
...
* Fix 9135: Access of moved variable not detected in loop
* Format
* Fix issue with pushing back on container
* Format
* Fix null pointer
* Remove yeild for now
2022-06-16 17:40:09 +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
cee48e5e19
Add backtrace to valueflow in debug mode ( #4195 )
2022-06-12 07:13:42 +02:00
Paul Fultz II
653a1ea83e
Fix 11100: FP knownConditionTrueFalse with getter/setter member functions ( #4198 )
...
* Fix 11100: FP knownConditionTrueFalse with getter/setter member functions
* Format
2022-06-11 11:00:40 +02:00
PKEuS
99ce89c003
Improvement: Set varId for variables with global scope operator :: Refactorization: Moved internal class from tokenize.h to tokenize.cpp ( #4184 )
...
Merged from LCppC.
2022-06-11 08:11:16 +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
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
Oliver Stöneberg
ce945ec7fc
enabled and fixed `modernize-use-override` clang-tidy warnings ( #4168 )
2022-06-03 21:32:39 +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
e430a11b49
Add debug_valueflow instrinsic to show valueflow values and its error path ( #4159 )
...
* Add debug_valueflow instrinsic to show valueflow values and its error path
* Format
2022-06-01 06:53:21 +02:00
Paul Fultz II
d7c914bd3e
Handle subfunction values in valueflow conditions ( #4128 )
2022-05-29 19:57:10 +02:00
Paul Fultz II
7405ea039d
Refactor valueflow forward and reverse functions and unify them ( #4127 )
...
* Move functions around
* Make it a template to handle both overloads
* Simplify forward
* Remove container forward
* Remove unused settings params
* Format
* Remove valueFlowForwardExpression
* Format
* Remove init list
* Make const ref
* Remove braces
* Remove braces
2022-05-24 06:41:17 +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
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
Oliver Stöneberg
14421ae627
fail `run-clang-tidy` in case of compiler warnings / fixed Clang warnings / cleanups ( #4036 )
2022-05-15 12:42:29 +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
Oliver Stöneberg
c71033548f
fixed some clang-tidy warnings ( #3080 )
2022-05-08 20:42:06 +02:00
Paul Fultz II
843f7893d6
Fix 11040: FP nullPointer after loop ( #4085 )
2022-05-05 06:55:02 +02:00
Paul Fultz II
5afd6880c3
Fix 11028: False positive: invalidContainer ( #4083 )
...
* Fix 11028: False positive: invalidContainer
* Format
2022-05-05 06:54:36 +02:00
Paul Fultz II
496b45f27b
Fix 11009: FP uninitvar ( #4076 )
...
* Fix 11009: FP uninitvar
* Format
2022-05-04 05:59:01 +02:00
Paul Fultz II
3edb10a006
Fix 11024: FP returnDanglingLifetime with c_str() passed to constructor ( #4072 )
2022-05-03 11:42:32 +02:00
Paul Fultz II
3e686103ae
Fix 10984: False positive: invalidContainer when explictly capturing vector by reference ( #4064 )
2022-04-30 09:36:28 +02:00
Paul Fultz II
4e7125554f
Fix 8358: FP: Condition '(number*0)!=0' is always false ( #4065 )
2022-04-30 09:35:51 +02:00
Paul Fultz II
9fa5c4e201
Fix 11011: FP returnDanglingLifetime with non-const reference argument [inconclusive] ( #4066 )
...
* Fix 11011: FP returnDanglingLifetime with non-const reference argument [inconclusive]
* Format
2022-04-30 08:23:58 +02:00
Paul Fultz II
aafd1e10be
Fix 11006: FP uninitvar with unknown constant ( #4056 )
2022-04-28 10:48:37 +02:00
chrchr-github
bcbc29affb
Fix #10526 FP: negativeIndex if function call is made after index check ( #4052 )
...
* Fix #10526 FP: negativeIndex if function call is made after index check
* Improve container check
* Format
2022-04-27 14:08:44 +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
chrchr-github
6e69b751eb
Fix Match pattern ( #4025 )
2022-04-15 08:48:49 +02:00
Paul Fultz II
28cf14f110
Fix 10975: false negative: dangling reference in class ( #4024 )
...
* Fix 10975: false negative: dangling reference in class
* Format
2022-04-14 18:59:12 +02:00
chrchr-github
6450d5701c
Fix #10979 FP arrayIndexOutOfBoundsCond with sizeof ( #4021 )
...
* Fix #10466 FP constVariable with pointer typedef
* Fix flag check
* Use isStatic()
* Fix #10979 FP arrayIndexOutOfBoundsCond with sizeof and extra parentheses
2022-04-14 18:13:29 +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