Paul Fultz II
774464eabb
Fix issue 8996: False positive duplicateCondition
...
This fixes issue 8996 by improving the alias checking by using lifetime analysis. It also extends the lifetime checker to handle constructors and initializer lists for containers and arrays.
2019-03-19 06:25:10 +01:00
Daniel Marjamäki
d1025ce76d
Added testcases from 'duma' package
2019-03-18 06:58:12 +01:00
Rikard Falkeborn
794f65bac1
Handle prefixed strings and characters in Token ( #1742 )
...
This makes it possible to call getStrLength() and similar functions
before the tokenizer is called.
2019-03-18 06:18:25 +01:00
Daniel Marjamäki
03f8535c71
Better multiline warning when there is buffer overflow
2019-03-17 20:12:02 +01:00
Daniel Marjamäki
3c85d8a8ac
ValueFlow: Better info for buffer size values
2019-03-17 19:02:36 +01:00
Sebastian
19e9e42dd7
Library: Enhance minsize configuration and allow simple values. ( #1736 )
...
Some POSIX and Windows functions require buffers of at least some
specific size. This is now possible to configure via for example this
minsize configuration: `<minsize type="value" value="26"/>`.
The range for valid buffer size values is 1 to LLONG_MAX
(9223372036854775807)
2019-03-17 14:22:26 +01:00
Daniel Marjamäki
0771929518
Buffer overflow: Handling of dynamically allocated buffer
2019-03-17 13:40:56 +01:00
Daniel Marjamäki
92f4113b59
Array index: Checking array index out of bounds for dynamic buffers
2019-03-17 13:09:15 +01:00
Daniel Marjamäki
b0c92c1ac1
CheckNullPointer: Use library instead of hardcoding
2019-03-17 07:37:38 +01:00
Daniel Marjamäki
87fe5c060e
Refactoring of Null Pointer Checker
2019-03-16 21:21:30 +01:00
Daniel Marjamäki
ebef16b8a3
Travis: Try to remove temporary fix
2019-03-16 18:29:02 +01:00
Daniel Marjamäki
34a8b2b519
Quick fix for 'make checkcfg'
2019-03-16 18:17:16 +01:00
Daniel Marjamäki
e9d29e826f
Travis: Temporarily comment out failing test
2019-03-16 09:48:32 +01:00
Daniel Marjamäki
fb2198fd6b
Travis: Try to fix test
2019-03-16 09:28:00 +01:00
Daniel Marjamäki
3dc34f1515
Disable all simplified checks
2019-03-16 09:17:50 +01:00
Daniel Marjamäki
0e88a17aca
CheckInternal: Use 'normal' checking
2019-03-16 08:51:33 +01:00
Daniel Marjamäki
f40a80c349
Use 'normal' checking instead of 'simplified'
2019-03-16 07:19:48 +01:00
Daniel Marjamäki
a2a216bbe3
SymbolDatabase: Improved handling of 'normal' non simplified token list
2019-03-15 19:00:42 +01:00
Daniel Marjamäki
92485245ce
Restore severity for 'autoVariables'
2019-03-15 15:13:11 +01:00
versat
6f7612de03
boost.cfg: Add argument directions; some fixes; rearrange and document.
...
- Remove redundant function configurations for the same function since
it is not (yet) possible to configure overloaded functions. Instead mark
the optional arguments with `default="0"` so the configuration works
with a different number of arguments.
- Add documentation to boost.cfg (links and function declarations).
- Rearranged configurations so functions, defines, ... are together now.
- Add `direction` for function arguments where applicable.
- Add some tests to boost.cpp.
2019-03-15 11:13:08 +01:00
Daniel Marjamäki
3656f1ae4f
Auto variables: Fix false negatives for normal tokens
2019-03-14 13:51:35 +01:00
versat
3d02c10fde
gnu.cfg: Further fixes, enhancements and adding argument directions.
2019-03-14 09:26:27 +01:00
Daniel Marjamäki
6eeee743d2
Auto variables: Minor cleanup
2019-03-14 06:41:11 +01:00
Daniel Marjamäki
703e0a0153
Appveyor: Try to #include proper header for std::uint16_t
2019-03-13 21:44:26 +01:00
Daniel Marjamäki
1ca6d9c847
Appveyor: Fix missing #include for uint16_t
2019-03-13 19:01:54 +01:00
Daniel Marjamäki
cdeb91bfcc
Travis: Restore the uint8_t arrays
2019-03-13 18:59:55 +01:00
Daniel Marjamäki
b984897526
ValueFlow: Fix sizeof for array of library type
2019-03-13 18:31:41 +01:00
Sebastian
1230357146
Library: Add initial configuration with tests for SQLite3 library. ( #1737 )
2019-03-13 13:57:40 +01:00
Daniel Marjamäki
f9ce5b3407
Travis: quick fix for 'make checkcfg'
2019-03-13 09:30:59 +01:00
Daniel Marjamäki
81a1d744c6
CheckBufferOverrun: fix FP for array definition of static class member
2019-03-13 06:39:09 +01:00
Daniel Marjamäki
67e8b99c2c
CheckBufferOverrun: Readd a check for strncpy/memcpy/etc
2019-03-12 21:15:26 +01:00
Daniel Marjamäki
11e32ff445
ValueFlow: Handle compound assignments in execute()
2019-03-12 18:53:58 +01:00
Daniel Marjamäki
1d135d1a12
Added test/testsuites/readme.txt
2019-03-12 09:13:20 +01:00
Daniel Marjamäki
f986380b14
Added test/testsuites folder
...
My idea with this folder is to collect external suitable test cases so we can test Cppcheck on these.
2019-03-12 09:10:37 +01:00
Daniel Marjamäki
0c08f6db6c
CheckBufferOverrun: Use AST to lookup array
2019-03-12 06:46:38 +01:00
Daniel Marjamäki
ea23033a65
Array index out of bounds: Fix false positive
2019-03-11 20:33:08 +01:00
Daniel Marjamäki
7b17b33a49
ValueFlow: fix handling of sizeof(*p)
2019-03-11 20:32:24 +01:00
Daniel Marjamäki
bd048085bd
Add CheckBufferOverrun::arrayIndexThenCheck
2019-03-11 19:20:06 +01:00
Daniel Marjamäki
27d750b3a1
Travis: Fix 'make checkcfg'
2019-03-11 13:43:15 +01:00
Daniel Marjamäki
729f57d8f1
Start a major rewrite of CheckBufferOverrun. For now only the 'array index' and 'buffer overflow' checks are rewritten.
...
There are important TODOs still; for instance adding CTU support using our CTU infrastructure, add handling of pointers (maybe I'll use FwdAnalysis for this), add handling of multidimensional arrays, etc..
2019-03-11 12:34:33 +01:00
Rikard Falkeborn
a4269042e8
Add regression test for #8994 ( #1733 )
...
Trac ticket #8994 was fixed in b222953bae
.
Add a regression test to ensure it stays fixed.
2019-03-11 06:14:37 +01:00
Rikard Falkeborn
6a3dd9a185
Handle concatenated string and char literals
...
This handles concatenated strings and characters from simplecpp.
Previously, L'c' would be preprocessed to the tokens "L" and "'c'".
cppcheck would then remove the "L" token and set "'c'" to be a wide
character literal. Now, it needs to remove the prefix instead.
When doing this, add handling of utf32 encoded literals (U) and UTF-8
encoded literals (u8).
2019-03-10 10:38:50 +01:00
Daniel Marjamäki
69c05acd3b
CheckBoost: Use 'normal' checking
2019-03-09 20:00:31 +01:00
Daniel Marjamäki
e17ddfd964
Changed AST for variable declarations with initializations
2019-03-09 19:09:15 +01:00
Daniel Marjamäki
1b4895a579
ValueType: Set ValueType for false/true
2019-03-09 17:27:27 +01:00
Daniel Marjamäki
38d5712aaa
Moved CheckAssert::assertWithSideEffects to normal checking
2019-03-09 16:50:50 +01:00
Daniel Marjamäki
7caa6628d5
Fix 'make checkcfg'
2019-03-09 15:41:07 +01:00
Daniel Marjamäki
b9ac77a31b
Uninitialized variables: Fixed false positive
2019-03-09 11:30:45 +01:00
Daniel Marjamäki
f9fe6cc96a
STL: Removed auto_ptr checking.
2019-03-09 07:48:01 +01:00
Daniel Marjamäki
725abbfac3
Move CheckStl::missingComparison to normal checks
2019-03-08 20:19:40 +01:00
Daniel Marjamäki
75ce67f4b8
Fixed #9027 (cppcheck on Centos 7 - segmentation fault below CheckCondition::multiCondition2)
2019-03-08 19:27:20 +01:00
Sebastian
c8003d47e2
checkuninitvar.cpp: Use argument direction "out" info from library cfg ( #1730 )
...
CheckUninitVar::isMemberVariableAssignment uses argument direction "out"
now also to check for assignment when the member variable is handed over
to a function by reference.
testuninitvar.cpp: Improve tests, use a test library configuration.
2019-03-08 18:42:24 +01:00
amai2012
eb9edbc177
#9024 Crash caused by package "procserv" in lib/token.h:921 function Token::getKnownIntValue - Fix and test for alternative code example.
2019-03-08 11:07:33 +01:00
Daniel Marjamäki
f9a12b2a71
Fix small mistake in unit test
2019-03-07 06:38:58 +01:00
Daniel Marjamäki
6eaf2c03d9
CheckOther::checkInvalidFree: Move check to normal checking. And clarify the message.
2019-03-07 06:35:44 +01:00
Daniel Marjamäki
f20936ed8a
Moved CheckOther::checkPassByReference to normal checking
2019-03-06 20:59:45 +01:00
Daniel Marjamäki
ad37664e86
Changed severities
2019-03-06 19:00:58 +01:00
Daniel Marjamäki
c32d015337
Fixed false positives from terminateStrncpy
2019-03-06 18:50:50 +01:00
versat
df73f7f355
std.cfg, windows.cfg: Move strcpy_s from windows.cfg to std.cfg.
...
strcpy_s belongs to the standard so it must be in std.cfg instead of
windows.cfg.
Configuration for strcpy_s has been improved and tests were added.
Found by daca@home
2019-03-05 15:33:16 +01:00
IOBYTE
5ee6c2138c
Fixed #9016 (tokenizer: wrong simplification for operator ^ (){}) ( #1724 )
2019-03-05 11:35:45 +01:00
Sebastian
0934577dda
Library configuration: function argument direction fixes and enhancements ( #1722 )
...
* std.cfg: Add further argument directions (in, out, inout).
* testlibrary.cpp: Add test for function argument direction configuration.
* std.cfg: runastyle and add some more direction configurations.
* library.h: Add documentation for function argument direction enum.
* Do not use "direction" library information for pointer arguments.
Also fix further unmatched uninitvar messages in std configuration
tests.
* std.cfg: Add more argument direction configurations.
* test/cfg/std.c: Add test for argument direction configuration.
* astutils.cpp: Only ignore pointer arguments for out/inout arguments.
* library.h: Use suggested documentation for argument direction enum.
2019-03-04 22:57:40 +01:00
orbitcowboy
794d72d776
wxwidgets.cfg: Added more directions-attributes.
2019-03-04 10:26:37 +01:00
IOBYTE
40d7d5a3d0
template simplifier: fix return type of out of line member function when it is a template parameter ( #1723 )
2019-03-03 19:42:46 +01:00
Rikard Falkeborn
d49fe421e8
test/options: Rename member variables ( #1720 )
2019-03-03 07:42:14 +01:00
IOBYTE
b222953bae
template simplifier: only constant fold template instantiation arguments ( #1721 )
...
* template simplifier: only constant fold template instantiation arguments
* Fix travis build.
2019-03-03 07:40:55 +01:00
Daniel Marjamäki
5087f15035
Travis: Try to fix 'make checkcfg'
2019-03-02 19:38:11 +01:00
Daniel Marjamäki
8a3b73ffdb
Do not write extra uninitvar warnings
2019-03-02 13:17:15 +01:00
Rikard Falkeborn
40ead7fd25
Add help to testrunner ( #1704 )
...
For now, only print the ways of running testrunner and the few options
that are available.
Also, refactor to remove an unneeded const_cast and use a range for loop.
Partially fixes #8514 .
2019-03-02 08:06:23 +01:00
orbitcowboy
a5ac9fcac5
Running astyle [ci skip].
2019-03-01 15:05:53 +01:00
Daniel Marjamäki
845c407ab7
Fixed pattern matching in isVariableChanged() to handle normal token list better
2019-03-01 13:23:03 +01:00
orbitcowboy
360823203f
windows.cfg: Ensure the return value is taken into account for memory (re)-allocation functions.
2019-03-01 08:58:53 +01:00
IOBYTE
b78b3c6ab1
Fixed #9005 (Syntax error on valid C++) ( #1716 )
2019-03-01 08:18:53 +01:00
Armin Müller
f4b5b156d7
Typos found by running "codespell" ( #1715 )
2019-03-01 01:01:39 +01:00
Daniel Marjamäki
5563fef7bb
Fixed #9008 (new crash in clang test suite)
2019-02-28 20:34:07 +01:00
Daniel Marjamäki
4f5a426fe5
Improved isVariableChangedByFunctionCall, better logic when parameter might be passed by reference
2019-02-28 17:02:46 +01:00
Daniel Marjamäki
494dd2ba3a
Revert "Improved isVariableChangedByFunctionCall, better logic when parameter might be passed by reference"
...
This reverts commit 14a0031e88
.
2019-02-28 15:56:25 +01:00
versat
f6c3749015
gtk.cfg: Add support for g_alloca() and g_newa().
...
References:
https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html#g-alloca
https://github.com/GNOME/glib/blob/master/glib/galloca.h
2019-02-28 15:29:37 +01:00
Daniel Marjamäki
14a0031e88
Improved isVariableChangedByFunctionCall, better logic when parameter might be passed by reference
2019-02-28 10:26:47 +01:00
Daniel Marjamäki
857681a049
Make quick fix for uninitialized variable false positive. Will look more at this soon.
2019-02-28 09:52:52 +01:00
IOBYTE
98bf112352
template simplifier: fix recursive variable templates ( #1711 )
2019-02-28 08:30:04 +01:00
Daniel Marjamäki
e27a7a585f
Fix uninitvar false positive when taking address of variable
2019-02-27 18:44:30 +01:00
Daniel Marjamäki
80143725dd
Fixed #8999 (False positive uninitvar related to casting)
2019-02-27 17:58:25 +01:00
Martin Ettl
fe402498e1
qt.cfg: Added support for Q_DECLARE_PUBLIC()-macro.
2019-02-27 15:38:31 +01:00
Martin Ettl
17c1733b0e
gnu.cfg: Added support for asprintf() and vasprintf(). There is a FN with memory leak detection regarding pointer args, which is already mentioned in #8980 . A comment has been added.
2019-02-27 15:17:34 +01:00
Daniel Marjamäki
226f0c7544
Fixed ValueType for auto variable
2019-02-27 10:28:18 +01:00
Paul Fultz II
032020c40d
Fix issue 9001: FP: Found suspicious operator ',' [constStatement]
2019-02-27 07:09:22 +01:00
IOBYTE
9d75b718d3
template simplifier: remove use of simplifyTokenList2 in tests ( #1705 )
2019-02-27 07:06:34 +01:00
Paul Fultz II
e846312fed
Check subtraction of pointers to different objects
2019-02-27 06:55:48 +01:00
rikardfalkeborn
0e988cc755
Fix #8992 : Add originalTypeToken to auto ( #1701 )
2019-02-27 06:44:31 +01:00
Daniel Marjamäki
c44e2ed378
sizeof: write inconclusive warning if calculation in sizeof is done indirectly by macro
2019-02-26 21:06:44 +01:00
Daniel Marjamäki
b248075aae
Comment bailout
...
[ci skip]
2019-02-26 19:28:11 +01:00
Daniel Marjamäki
9e93e89a4d
UninitVar: Fix false positives when there is possible cast
2019-02-26 19:26:46 +01:00
Kamil Dudka
21c22d0d4d
TestNullPointer: add regression test to cover #8813 ( #1699 )
...
... which is fixed since 1.86-72-gbc34f0239
2019-02-26 17:14:45 +01:00
Sebastian
61f911d39a
qt.cfg: Add Q_DECLARE_TR_FUNCTIONS() and others ( #1677 )
...
Add unknownMacro Q_DECLARE_TR_FUNCTIONS found via daca@home.
Add function QCoreApplication::translate() and macro
QT_DECLARE_DEPRECATED_TR_FUNCTIONS() the unknownMacro depends on.
Reference:
https://doc.qt.io/qt-5/qcoreapplication.html#Q_DECLARE_TR_FUNCTIONS
https://doc.qt.io/qt-5/qcoreapplication.html#translate
2019-02-26 13:39:37 +01:00
IOBYTE
bf85767829
template simplifier: make sure all instantiations are found and expan… ( #1696 )
...
* template simplifier: make sure all instantiations are found and expanded in #5097
* template simplifier: check output on another test
* template simplifier: add output to another test
2019-02-26 06:41:04 +01:00
IOBYTE
3f257d6310
template simplifier: instantiate template class when something inside… ( #1695 )
...
* template simplifier: instantiate template class when something inside class instantiated.
* template simplifier: add output to another test that now works
2019-02-25 21:01:34 +01:00
Daniel Marjamäki
d84d8885f7
SymbolDatabase: Fix TODO assertions
2019-02-24 19:11:18 +01:00
IOBYTE
41d87d6306
template simplifier: check output of a few crash and hang checks that now generate correct output ( #1689 )
2019-02-24 10:31:49 +01:00
Daniel Marjamäki
ef731064bd
Fixed #8964 (ValueType: auto constness)
2019-02-24 08:16:08 +01:00
Daniel Marjamäki
c855cf8682
ValueType: Better constness for auto variable
2019-02-23 18:16:18 +01:00