Commit Graph

13685 Commits

Author SHA1 Message Date
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
Oliver Stöneberg 40bcbd47d6
small `Token::Match()` optimizations (#4154)
* token.cpp: fixed `readability-else-after-return` warnings in `Match()`

* token.cpp: removed some duplicated code from `Match()`

* token.cpp: use `strchr()` instead of loop in `Match()`

* token.cpp: added early exit and removed unnecessary loop condition in `Match()`
2022-05-31 13:52:34 +02:00
Oliver Stöneberg 3d5d2e8fd8
inlined `findAstNode()` calls (#4146) 2022-05-31 13:37:21 +02:00
chrchr-github 423e67bd6a
Fix FP memleak (#4145) 2022-05-30 06:55:15 +02:00
Paul Fultz II d7c914bd3e
Handle subfunction values in valueflow conditions (#4128) 2022-05-29 19:57:10 +02:00
chrchr-github 7fbb9c7c13
Fix #10980 FN constVariable with range-based for loop (#4144)
* Fix #10980 FN constVariable with range-based for loop

* Format

* nullptr check

* Restrict scopes

* Add const

* Undo

* Add more const
2022-05-29 17:06:33 +02:00
chrchr-github e1c51940a2
Fix #11095 FP constParameter with decremented pointer (#4131) 2022-05-28 08:32:58 +02:00
chrchr-github 16a4449901
Fix crash with statement expression (#4142) 2022-05-28 00:11:23 +02:00
chrchr-github 16af6561c2
Fix FP memleak with unknown ptr typedef (#4141)
* Fix #11019 FN memleak with redundant pointer op

* Style

* Fix #7705 FN: Memory leak not detected on struct member

* Fix FP memleak with function call, fix cppcheckError

* Fix FP memleak with array

* Fix FPs memleak with array and ptr to ptr

* Fix FP memleak with unknown ptr typedef

* Format
2022-05-27 23:52:56 +02:00
chrchr-github d5d6da0dd4
Fix #11094 FP unreadVariable with unique_ptr and unknown type (#4140) 2022-05-27 17:17:50 +02:00
Rikard Falkeborn 068e5bad27
Fix #9966: FP memleak with multiple assignments in if-statement (#4138)
Similar to how we do for assignments outside if-statements, bail out
since we do not track multiple variables.
2022-05-27 07:57:43 +02:00
chrchr-github 19dd59eae6
Fix FPs memleak with array and ptr to ptr (#4139)
* Fix #11019 FN memleak with redundant pointer op

* Style

* Fix #7705 FN: Memory leak not detected on struct member

* Fix FP memleak with function call, fix cppcheckError

* Fix FP memleak with array

* Fix FPs memleak with array and ptr to ptr
2022-05-26 15:27:36 +02:00
chrchr-github 86763b7b0a
Fix FP memleak with array (#4133)
* Fix #11019 FN memleak with redundant pointer op

* Style

* Fix #7705 FN: Memory leak not detected on struct member

* Fix FP memleak with function call, fix cppcheckError

* Fix FP memleak with array
2022-05-26 00:03:30 +02:00
orbitcowboy eb3b8a6cec checkAlwaysTrueOrFalseStringCompare: Added '_mbscmp_l' to list of functions. 2022-05-25 13:35:39 +02:00
chrchr-github 1ed280fe63
Fix FP memleak with function call, fix cppcheckError (#4130)
* Fix #11019 FN memleak with redundant pointer op

* Style

* Fix #7705 FN: Memory leak not detected on struct member

* Fix FP memleak with function call, fix cppcheckError
2022-05-24 14:02:06 +02:00
chrchr-github 2ceaf308de
Fix #11084: ValueType for pointer typedef, don't warn for typedef'd pointers, improve error message (#4123)
* Fix ValueType for pointer typedef

* Add test

* Don't warn for typedef'd pointers, improve error message

* Fix tests

* Add TODO

* Fix test

* Set isSimplifiedTypedef() for more tokens, add test

* Add test
2022-05-24 10:09:48 +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
chrchr-github 1ced94be43
Fix #11019 FN memleak with redundant pointer op / #7705 FN: Memory leak not detected on struct member (#4126)
* Fix #11019 FN memleak with redundant pointer op

* Style

* Fix #7705 FN: Memory leak not detected on struct member
2022-05-23 23:21:36 +02:00
Daniel Marjamäki 03c9253962 Token: add isRestrict flag 2022-05-22 14:10:55 +02:00
Paul Fultz II e2c35abde5
Fix 11050: False positive: unreadVariable for class variable when another function uses the same variable name (#4121) 2022-05-22 09:20:32 +02:00
chrchr-github 22a4fdb6c4
Fix crash in checkPassByReference() (#4122) 2022-05-21 16:02:35 +02:00
Daniel Marjamäki 1f6554e2e8 Update copyright year 2022-05-21 12:18:27 +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
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 a62fb986a5
Fix 11090: Infinite recursion in findTypeInBase() (#4120) 2022-05-21 08:24:29 +02:00
chrchr-github 2b723eafcb
Fix ValueType for references in range-based for loop (#4116)
* Fix ValueType for references in range-based for loop

* Format
2022-05-20 08:48:01 +02:00
chrchr-github 112b1573c5
Fix #11078 FN constructing string from nullptr / #11079 FN unread variables (#4112)
* Fix #11078 FN constructing string from nullptr / #11079 FN unread variables

* Format
2022-05-18 13:52:44 +02:00
Daniel Marjamäki 54ec666739 provide more details when executing addons fails 2022-05-18 08:36:20 +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
orbitcowboy e02182bd88 Cleanup redundant parentheses 2022-05-15 07:53:32 +02:00
orbitcowboy 4f410ffb79
library: Improved argument <valid>-interface to defined values that are explicitly excluded. (#4111)
* library: Improved <valid>-interface to defined values that are explicitly excluded.

* std.cfg: Improved configuration of remainder[fl]().

* Fixed failing self check

* Fixed failing self check

* std.cfg: Added support for std::remquo().
2022-05-14 16:05:18 +02:00
chrchr-github 52f507d1fb
Fix #8004 unintentional semicolon in expression '.. ; +dostuff();' (#4109)
* Fix #8004 unintentional semicolon in expression '.. ; +dostuff();'

* Improve error message

* Don't remove single unary + in front of variables
2022-05-13 06:54:02 +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 5d8da2b83c
Fix 11035: FP arrayIndexOutOfBoundsCond with array and vector (#4105)
* Fix 11035: FP arrayIndexOutOfBoundsCond with array and vector

* Format

* Move comment
2022-05-12 06:21:33 +02:00
chrchr-github e7e8b1baf9
Fix #9861 FN: "static" not suggested for non-const method (#4101)
* Fix #9861 FN: "static" not suggested for non-const method

* Format

* Make functions static

* static
2022-05-11 20:01:22 +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 942dbad11c
Fix #7197 not getting expected warning in relational comparison of booleans (#4095)
* Fix #7197 not getting expected warning in relational comparison of booleans

* return nullptr
2022-05-11 08:09:32 +02:00
Daniel Marjamäki 72ba85a2fc AST: Fix AST for array size calculation in cast (char (*)[...]) 2022-05-10 22:47:57 +02:00
Daniel Marjamäki 4257f9d46a Tokenizer: fix for __attribute__ before function that returns a reference 2022-05-10 20:59:24 +02:00
chrchr-github a70d11adb6
Fix #11052 inline static global struct declaration interferes with checks (#4098) 2022-05-10 20:43:11 +02:00
chrchr-github 759c16fcef
Fix boolean expressions (#4099)
* Enable experimental check

* Remove experimental

* Don't compare Booleans using relational operators

* Fix boolean expressions
2022-05-10 20:42:24 +02:00
Daniel Marjamäki 0a4e2abf01 dump: add token isComplex attribute 2022-05-10 19:05:02 +02:00
chrchr-github e2bb77f990
Remove severity 'experimental' from checkComparisonOfBoolWithBool() (#4097)
* Enable experimental check

* Remove experimental

* Don't compare Booleans using relational operators
2022-05-10 18:25:13 +02:00
chrchr-github 52cbbb0229
Fix FP uninitMemberVar with defaulted special member functions (#4094)
* Fix #10569 FN: duplicateExpression with multiple strings compared

* Fix compiler warning

* TODO -> ASSERT

* Update testautovariables.cpp

* Improve error message

* Format

* Improve message

* Fix FP with defaulted operator=

* Fix condition
2022-05-10 13:04:45 +02:00
chrchr-github 54f832a2fe
Fix #10569 FN: duplicateExpression with multiple strings compared (#4087) 2022-05-09 21:05:35 +02:00
chrchr-github 38bdece3fe
Fix #9391 False negative: Uninitialized struct member (default constructor) (#4088)
* Fix #9391 False negative: Uninitialized struct member (default constructor)

* Format

* Initialize variables

* Init
2022-05-09 20:28:21 +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