Commit Graph

10860 Commits

Author SHA1 Message Date
versat 641b350cf7 astutils.h: Remove conflicting function declaration for isAliased()
This function was made static with commit 6c82685fbf
2019-07-24 13:23:54 +02:00
Daniel Marjamäki fb7f18ddea ValueFlow: fix false detection of duplicate values 2019-07-24 12:30:33 +02:00
Daniel Marjamäki cab9f61b79 safe checks: Handle float parameters 2019-07-24 12:09:13 +02:00
Daniel Marjamäki e0738c48d2 simplify code 2019-07-24 11:40:51 +02:00
Daniel Marjamäki 10be2a1941 Safe checks: container parameters 2019-07-24 11:39:35 +02:00
Daniel Marjamäki 6c82685fbf Fixed compiler warnings 2019-07-24 11:01:38 +02:00
Paul Fultz II bb52a63c4e Add check for const variables
When a local reference is declared, this will check if that local reference can be declared as `const`.
2019-07-24 09:59:01 +02:00
Paul Fultz II 4c3191e577 Lower recursion limit when using asan (#2013) 2019-07-24 09:57:53 +02:00
Daniel Marjamäki 753efb4c9b Function::isSafe: handle global/namespace functions better 2019-07-24 08:23:05 +02:00
Daniel Marjamäki 3ec45acc43 astyle formatting
[ci skip]
2019-07-24 08:22:12 +02:00
Paul Fultz II 3ec3bd52e0 Fix FP when using a pointer to a container (#2029) 2019-07-24 00:04:49 +02:00
Paul Fultz II ab0fcc7640 Fix issue 9216: reset() method confusion (#2025)
* Fix issue 9216 with smart pointer reset

* Check for arrow
2019-07-23 22:45:58 +02:00
Paul Fultz II 60b670babd Fix issue 9219: False positive, returnDanglingLifetime (#2026)
* Check for pointer deref for container methods

* Formatting
2019-07-23 21:59:05 +02:00
IOBYTE 5ad5cfcc29 Fix #9217 (Regression: Memory explodes in simplifyTemplateAliases) (#2021)
* Fix #9217 (Regression: Memory explodes in simplifyTemplateAliases)

* fix use after free when nothing was copied
2019-07-23 21:28:24 +02:00
Daniel Marjamäki 4fb6c27276 Modernize: Use enum class 2019-07-23 14:29:02 +02:00
Daniel Marjamäki 680fbfe612 Fix Cppcheck warning, unused value 2019-07-23 14:10:34 +02:00
Daniel Marjamäki 681bd0a911 GUI: Better settings for extended safe checks 2019-07-23 11:54:38 +02:00
Daniel Marjamäki 74bd2aa680 Use range for loop 2019-07-22 12:24:16 +02:00
Daniel Marjamäki a81c39af09 Replace 'unsigned' with 'nonneg' 2019-07-22 11:25:51 +02:00
Daniel Marjamäki 7ed3db7b32 astyle formatting
[ci skip]
2019-07-22 10:38:17 +02:00
Rikard Falkeborn 8cd1d5a47d Use library for memleak checks (#2002)
* Use library for memleak checks

Change memleakOnRealloc and leakReturnValNotUsed to use library
configuration instead of hardcoding "realloc".

In order to do so, some care needs to be taken when matching for a
reallocation function, since it can no longer be assumed that the input
to be allocated is the first argument of the function. This complicates
getReallocationType() and checkReallocUsage() but is necessary in order
to handle for example freopen() properly.

Also, refactor memleakOnRealloc check to reduce duplicated code when
checking "a" and "*a". When doing so, extending the check to look for
arbitrary number of "*" can be done for free (just change an if
statement to a while statement). Most likely, this is an unusual case in
real world code.

* Remove redundant whitespace in Token::Match()

* Run on simplified checks

* Fix cppcheck warning
2019-07-22 10:37:36 +02:00
Rikard Falkeborn abea580b78 Fix FP memory leak with unknown function call in condition (#2012)
* Fix FP memory leak with unknown function call in condition

This was introduced in 8513fb81d2 when
fixing memory leaks for global variables allocated in condition. The
refactored code had an inconsistency where c and c++ code behaved
slightly differently when `var` is NULL. This seemed to not have an
impact as the code was written prior to 8513fb81d2,
but when the same code was used for conditions, FPs were introduced.

The introduced FPs were memleak warnings when there should have been an
information message about missing configurations for code like

	void f() {
		char *p = malloc(10);
		if (set_data(p)) {}
	}

Fix this by always returning true if varTok->Variable() is NULL for
both c and c++ code.

* Improve function name
2019-07-18 15:23:19 +02:00
Paul Fultz II 8cd8a2671c Fix issue 9211: No error on divide by zero outside template instatiation
I am not sure how to add a test for this.
2019-07-18 14:55:30 +02:00
Daniel Marjamäki 28e5133f50 Refactoring: Use range for loop 2019-07-18 14:55:01 +02:00
Paul Fultz II a08a9c1349 Switch to use lifetime analysis for iterators and pointers to invalid containers
This will diagnose more issues such as:

```cpp
void f(std::vector<int> &v) {
    auto v0 = v.begin();
    v.push_back(123);
    std::cout << *v0 << std::endl;
}
```
2019-07-18 10:56:44 +02:00
Daniel Marjamäki 421a8da6a8 Try to clarify signConversion message 2019-07-17 22:41:24 +02:00
Daniel Marjamäki f0aeb845e5 ValueFlow: Clarify warnings when argument min/max values are used 2019-07-17 22:17:34 +02:00
Daniel Marjamäki d11d6f112e Detect shadowed arguments 2019-07-17 17:08:42 +02:00
Daniel Marjamäki 0be78bbde6 Rename fileInd to fileIndex 2019-07-17 16:28:47 +02:00
Daniel Marjamäki 90a215af0e Rephraze performance message. /would be faster/could be faster/ to indicate that Cppcheck is not _sure_ that it would be faster 2019-07-17 16:06:10 +02:00
Daniel Marjamäki 64ef879ebf Fix syntaxError for struct initialization 2019-07-17 15:21:17 +02:00
Daniel Marjamäki 9973db3a71 Modernize: Use enum class for Library::Action and Library::Yield 2019-07-17 11:39:30 +02:00
Daniel Marjamäki ec4d68e231 Modernize: use enum class 2019-07-17 10:43:18 +02:00
Daniel Marjamäki 2afd5f5dd0 Modernize: Use enum class 2019-07-17 10:39:06 +02:00
Daniel Marjamäki b15e6801a4 Replace 'unsigned' with 'nonneg' in tokenizer 2019-07-17 10:36:49 +02:00
Daniel Marjamäki e9b12b1fe0 Replace 'unsigned' with 'nonneg' 2019-07-17 10:14:25 +02:00
Daniel Marjamäki e124b31334 Replace 'unsigned' with 'nonneg' 2019-07-17 09:11:42 +02:00
Daniel Marjamäki c04f31a2c2 Refactoring: Use common function 2019-07-17 09:04:42 +02:00
Daniel Marjamäki 5800692fa1 Move and refactor the CheckMemoryLeak::isclass 2019-07-17 08:59:09 +02:00
Rikard Falkeborn 8513fb81d2 Fix #9206 (FP with global variable allocated in condition) (#2007) 2019-07-17 07:43:07 +02:00
Daniel Marjamäki b3688f22e8 Unknown macro: Detect and warn about unknown macro before throw/return 2019-07-16 20:32:46 +02:00
Daniel Marjamäki b4a05a3dd0 Refactoring: Use enum class 2019-07-16 11:12:35 +02:00
Daniel Marjamäki 32eda27391 Refactoring: Use enum class 2019-07-16 10:51:26 +02:00
versat 4e89b13adf checkio.cpp: Fix forgotten "nonneg" change which breaks build 2019-07-16 09:30:36 +02:00
Daniel Marjamäki 7a4a9eba4b remove cast 2019-07-16 09:28:48 +02:00
Daniel Marjamäki ef73a10e30 Replace 'unsigned' with 'nonneg' in checkother 2019-07-16 09:10:10 +02:00
Daniel Marjamäki 3637c486c4 Replace 'unsigned' with 'nonneg' in checkclass 2019-07-16 09:03:45 +02:00
Daniel Marjamäki e877683f01 Replace 'unsigned' with 'nonneg' in checkleakautovar 2019-07-16 08:54:21 +02:00
Daniel Marjamäki c57d3e069a Replace 'unsigned' with 'nonneg' in checkfunctions 2019-07-16 08:49:02 +02:00
Daniel Marjamäki a038ba7dce replace 'unsigned' with 'nonneg' in checkio 2019-07-16 08:37:26 +02:00