Commit Graph

20679 Commits

Author SHA1 Message Date
Sebastian 4986b02566
qt.cfg: Add functions of class QRegExp (#2017)
This class is also used by the Cppcheck GUI.
Reference: https://doc.qt.io/qt-5/qregexp.html
2019-07-22 12:53:58 +02:00
Daniel Marjamäki 82c6a72b48 Rename variable pDlg to dlg 2019-07-22 12:50:42 +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 06337cedf5 Run more tests on full token list (#2020)
Since all checks are run on the full token list and not the simplified
one, run the tests on the full token list as well.
2019-07-22 10:26:55 +02:00
amai2012 2915376c4f Remove attribute use-retval from std::rotate 2019-07-19 20:33:15 +02:00
Sebastian f50cd2330c
std.cfg: Add some more std::<container>::swap() functions (#2018) 2019-07-19 10:00:14 +02:00
amai2012 453de18101
Run pylint on addons providing a buld breaker on travis (#2011)
* Run pylint (using a pylintrc file) on the addon Python scripts. It serves as a build breaker for severe issues.
* Skip y2038 addon for now until it's fixed.
2019-07-18 20:51:58 +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
Sebastian 9c8c539549
qt.cfg: Add some functions of class QXmlStreamAttributes (#2016)
This class is also used by the Cppcheck GUI.
2019-07-18 12:38:42 +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
Sebastian 512c1b12c6
qt.cfg: Add some functions of class QXmlStreamWriter (#2010)
This class is also used by the Cppcheck GUI.
2019-07-18 06:30:53 +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
Sebastian a997a30824
cppcheck-lib.cfg: Enhance Cppcheck library configuration (#2009) 2019-07-17 20:05:13 +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 40600cbc38 GUI: Fixed build directory, use project file path by default 2019-07-17 16:01:54 +02:00
Daniel Marjamäki 64ef879ebf Fix syntaxError for struct initialization 2019-07-17 15:21:17 +02:00
Sebastian a309095ec3
donate-cpu-server.py: Fix rare version verification issue (#2008)
The loop should be exited as soon as the line with the Cppcheck version
information has been found. Not only when the verification failed.
2019-07-17 14:29:07 +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
Sebastian 64fea0d270
appveyor.yml: Add Cygwin build and tests (#2006) 2019-07-17 10:22:08 +02:00
Daniel Marjamäki e9b12b1fe0 Replace 'unsigned' with 'nonneg' 2019-07-17 10:14:25 +02:00
versat 61ddda6252 run dmake 2019-07-17 10:02:28 +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
Georgy Komarov 413a5a4865 MISRA: Fix rules suppression, add tests (#1996)
* MISRA: Fix suppressed rules line numbers

Line numbers represented as strings in lxml ETree, but we use it in
integer comparison later.

* MISRA: Use standard library function instead file_prefix.

* MISRA: Use pytest's capsys for capturing, add suppressions tests.

* travis.yml: Update pytest version
2019-07-16 22:32:41 +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 7b48fb6b32 Revert "cfg: Add python macros to fix daca crashes"
This reverts commit 760586dd0a.
2019-07-16 16:52:48 +02:00
orbitcowboy d17ab72e3c wxwidgets.cfg: Added support for wxGrid::XYToCell(). 2019-07-16 16:49:42 +02:00
versat ab227cbf6e sqlite3.cfg: Add more functions reported as missing by daca@home 2019-07-16 16:21:05 +02:00
versat 8e00f4ddfb sqlite3.cfg: Add some functions reported as missing by daca@home 2019-07-16 14:59:33 +02:00
Sebastian 820ffdeee8
gtk.cfg: Add some macros and functions reported as missing by daca@home (#2005) 2019-07-16 13:42:01 +02:00
orbitcowboy 2ae5ac7dc2 windows.cfg: Removed TEXT()-macro since it is handled internally. 2019-07-16 13:40:41 +02:00
Daniel Marjamäki 760586dd0a cfg: Add python macros to fix daca crashes 2019-07-16 13:30:59 +02:00
orbitcowboy 1f7fdb229a windows.cfg: Added support for GetFullPathName(). Reference: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfullpathnamea 2019-07-16 13:23:39 +02:00
orbitcowboy f2e70f9236 wxwidgets.cfg: Added support for wxFile::ReadAll(). 2019-07-16 13:14:20 +02:00
orbitcowboy 29983aac0c windows.cfg: Added support for more platform types and some macros defined in winnt.h 2019-07-16 13:10:04 +02:00
Sebastian 7d7078f126 Makefile/dmake: Increase stack size to 8M for Cygwin builds to avoid segfaults (#2001)
* Makefile: Increase stack size to 8M for Cygwin builds to avoid segfaults

See https://github.com/danmar/cppcheck/pull/1988
and https://github.com/danmar/cppcheck/pull/1998

* dmake.cpp: Add parameter to CXXFLAGS for increased stack size in Cygwin
2019-07-16 12:14:18 +02:00
Daniel Marjamäki b4a05a3dd0 Refactoring: Use enum class 2019-07-16 11:12:35 +02:00