Commit Graph

243 Commits

Author SHA1 Message Date
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 45158ec064
cleaned up includes based on include-what-you-use (#4007)
* cleaned up includes based on include-what-you-use

* updated translations
2022-04-13 12:24:00 +02:00
Paul Fultz II 45de9a7d08
Refactor: Use getEndOfExprScope instead of getEndOfVarScope (#3855) 2022-02-24 06:50:34 +01:00
Oliver Stöneberg 6e57cc4323
small utils.h cleanup (#3821) 2022-02-11 19:44:08 +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
Paul Fultz II 7bf0ca8d00
Fix 10672: crash: CheckAutoVariables (#3657) 2022-01-01 00:14:36 +01:00
Rikard Falkeborn 8537331ad6
AutovarDeallocation: Fix grammar in error message (#3654) 2021-12-23 20:09:55 +01:00
Rikard Falkeborn e7b6920cf4
Fix #10600: FP invalid dealloc of function array argument (#3613)
Do not warn for array arguments that are free'd, since they decay to
pointers.
2021-12-09 07:16:40 +01:00
Rikard Falkeborn 1a50146745
autovarInvalidDeallocation: Fix fp with impossible value (#3604)
daca reports new false positives after db4f94fdfe on the form:

	void f() {
	    char *ptr = malloc(10);
	    char *empty_str = "";
	    if (ptr == NULL)
	        ptr = empty_str;
	    if (ptr != empty_str)
	        free(ptr);
	}

Add a check that the value is not impossible to avoid this.
2021-12-05 15:47:21 +01:00
Rikard Falkeborn db4f94fdfe
Fix #7341: Dealloc string literal (#3586) 2021-11-30 07:31:28 +01:00
Paul Fultz II 57f5b19b34
Fix 7812: False negative: return pointer of local variable (#3583)
* Fix 7812: False negative: return pointer of local variable

* Format

* Add test case for 3029

* Format
2021-11-28 15:25:21 +01:00
Daniel Marjamäki f701a9361d chmod; Use 644 for source files 2021-11-17 08:25:25 +01:00
Paul Fultz II c057dcce0f
Fix 10592: False positive: returnDanglingLifetime (#3557) 2021-11-11 08:00:05 +01:00
Paul Fultz II b835744a81
Fix 10585: FP danglingTemporaryLifetime recent regression (#3544)
Fix 10585: FP danglingTemporaryLifetime recent regression
2021-11-04 09:24:24 +01:00
Paul Fultz II d3f0aa5b34
Fix 10033: false negative: danglingTemporaryLifetime with usage of reference from nested object not detected (#3542) 2021-11-01 19:23:15 +01:00
Paul Fultz II 7d7584b456
Fix 10575: Improve check; lifetime, struct member points to local data (#3541) 2021-11-01 19:22:21 +01:00
Paul Fultz II 8668d445c7
Add support for string_view (#3480) 2021-10-05 08:28:19 +02:00
Paul Fultz II 95c872b1ec
Fix todo test for returning a dangling reference (#3284) 2021-06-04 17:15:39 +02:00
Ken-Patrick Lehrmann 9aa131a12e
Remove unnecessary null check (#3215)
Spotted by coverity (as the condition in the `if` part `isArrayVar(tok)`
dereferences tok.
Tok can't be null here, because the condition in the `else if`on line
268 checks that there is a `%var%` following, and
`tok = Token::findmatch(tok->next(), "%var%");` simply gets this `%var%`
token.
2021-04-28 18:05:32 +02:00
Paul Fultz II db5f00a16a
Fix issue 10214: FP: danglingTempReference doesn't account for reference lifetime extension (#3220)
* Fix issue 10214: FP: danglingTempReference doesn't account for reference lifetime extension
2021-04-19 14:20:29 +02:00
Paul Fultz II 563c9dd9cc
Fix issue 10208: FP: knownConditionTrueFalse in for loop with function that assigns by ref (#3198) 2021-04-18 21:42:27 +02:00
Oliver Stöneberg 6397e29f84
cleaned up includes based on include-what-you-use (#3141) 2021-04-03 21:30:50 +02:00
Daniel Marjamäki 42437277dc Update Copyright year 2021-03-21 20:58:32 +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 6a811eec1c Refactorization: Removed unused functions 2021-02-17 22:44:03 +01:00
Paul Fultz II 0ecac8e23b
Fix issue 10090: ValueFlow: Wrong lifetime, pointer member is not allocated on stack (#3109) 2021-02-03 10:22:31 +01:00
Daniel Marjamäki bf236e91d7 Fixed #9918 (False positive: autoVariable pointer is NULLed later) 2020-09-28 22:48:57 +02:00
Paul Fultz II 857722f859
Fix issue 9711: FP knownConditionTrueFalse for variable modified via pointer (#2813) 2020-09-20 14:27:09 +02:00
Paul Fultz II 34d65e25d6
Merge branch 'main' into lifetime-subfunction 2020-09-09 12:02:02 -05:00
Paul 8d7088aa24 Fix issue 9835: False negative: Return reference to temporary with const reference 2020-09-08 18:30:45 -05:00
Paul 1be67ea008 Merge 2020-09-08 11:00:57 -05:00
Paul Fultz II 362ab44c40
Fix issue 9646: False negative: Return reference to temporary with const reference (#2782) 2020-09-07 10:52:54 +02:00
Paul 786672e19d Format 2020-09-06 21:59:21 -05:00
Paul c7a5d3c5f1 Fix FPs 2020-09-06 21:58:36 -05:00
Paul 264c0cae8b Formatting 2020-09-04 11:59:30 -05:00
Paul bb37b07def Extend lifetimes to subfunctions 2020-09-04 11:56:34 -05:00
Paul Fultz II 0a718694af
Fix issue 9852: False positive: danglingTemporaryLifetime when returning a vector of vectors (#2766) 2020-09-01 11:21:29 +02:00
Paul e2a81a382f Track reading aliases during valueflow forward 2020-07-19 23:25:35 -05:00
Paul Fultz II eb4754b7d9
Fix issue 9587: False positive: parameter can be declared with const (#2667) 2020-05-31 10:10:10 +02:00
Oliver Stöneberg 37bc0483a4
made check.h less heavy (#2633) 2020-05-23 07:16:49 +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
Paul Fultz II 453a69dd8c
Fix issue 9677: False positive: returning pointer to oject that will not be invalid (#2607)
* Fix issue 9677: False positive: returning pointer to oject that will not be invalid

* Formatting
2020-04-18 09:23:10 +02:00
orbitcowboy acdc62f8f0 Formatted the code. There are no functional changes [ci skip] 2020-03-26 17:03:21 +01:00
Paul Fultz II 5462e43161
Fix issue 9639: False positive: Returning object that points to local variable that will be invalid when returning (#2576)
* Follow reference when tracking local variables

* Fix issue 9639: False positive: Returning object that points to local variable that will be invalid when returning
2020-03-23 22:54:53 +01:00
Daniel Marjamäki a5a294cf13 Code cleanup 2020-01-25 18:11:54 +01:00
Daniel Marjamäki f911495db3 Clang import; Handle clang-9 while loop better 2020-01-25 16:10:13 +01:00
Daniel Marjamäki 7db54bde6f Run normal checks on --clang output 2020-01-24 18:04:39 +01:00