IOBYTE
9f3ecdde31
Fixed #9076 (Template Simplifier : template < template <typename> T >) ( #1777 )
...
This does not add support for template templates. It only skips the
template template parameter.
2019-04-03 06:02:38 +02:00
Daniel Marjamäki
3f9dd4c567
Variable scope: Fix FP for reference variable in range for loop
2019-04-02 12:59:24 +02:00
Daniel Marjamäki
761f18c75c
Fixed #8988 (False positive: using memset on struct)
2019-04-01 19:32:03 +02:00
versat
974f01ce59
gtk.cfg: Add / improve g_str*() functions and add GTK_SIGNAL_FUNC().
2019-04-01 16:15:32 +02:00
versat
9d8b965270
gtk.cfg: Add / improve g_string_*() function configurations.
...
daca@home reported missing configurations for most of them.
2019-04-01 15:33:27 +02:00
Daniel Marjamäki
fbc769266c
Fixed #9060 (TemplateSimplifier::templateParameters : var <...>)
2019-03-31 16:29:28 +02:00
Daniel Marjamäki
0efddc4010
astyle formatting
...
[ci skip]
2019-03-31 16:20:06 +02:00
Daniel Marjamäki
29a5404d1e
Incomplete statement: Fix FP for 'ar & x'
2019-03-31 11:50:57 +02:00
Daniel Marjamäki
73433c2961
Syntax error: Clarify a syntax error in audacity
2019-03-31 10:46:59 +02:00
Daniel Marjamäki
b30d463baf
Fix wrong syntax error
2019-03-31 09:34:19 +02:00
Daniel Marjamäki
c5807459f9
CheckBufferOverrun: Add check for pointer arithmetics
2019-03-31 09:00:52 +02:00
Daniel Marjamäki
4107671549
TestBufferOverrun: Uncommented and moved CTU tests
2019-03-30 15:10:00 +01:00
Daniel Marjamäki
b0c58f2b10
Fixed #9000 (SymbolDatabase: lambda scope)
2019-03-30 10:32:36 +01:00
Daniel Marjamäki
fe285f1df3
Fixed #9055 (SymbolDatabase: second argument is missing in the symbol database)
2019-03-30 07:44:36 +01:00
IOBYTE
d88ee2d6a2
Fixed #9070 (Segmentation fault in TemplateSimplifier::simplifyTemplateAliases (scram package)) ( #1771 )
...
This only fixes the crash. It does not fix the underlying problem of
template using with templates of templates causing the use of deleted
instantiations.
2019-03-30 06:53:17 +01:00
Daniel Marjamäki
b5a285319c
Fixed #9073 (Segmentation fault in Token::isUnaryOp() with ode)
2019-03-29 19:37:23 +01:00
Daniel Marjamäki
54bea2847a
STL: Better out of bounds checking for empty containers when index is unknown
2019-03-29 15:20:17 +01:00
Daniel Marjamäki
3c30d274a0
Clarify STL out of bounds warning message
2019-03-29 11:13:25 +01:00
Daniel Marjamäki
e88a0c00c1
Fixed #9039 (STL: array index out of bounds: str.begin() + 1)
2019-03-28 12:49:52 +01:00
IOBYTE
22f01f035c
Fixed #9042 (Another `using BOOL` type breach) ( #1765 )
2019-03-27 21:42:50 +01:00
Daniel Marjamäki
0f6a90c595
Fixed #9069 (crash on invalid code: ' x= y{ } name5 ')
...
Credit to OSS-Fuzz for reporting this!
2019-03-27 18:17:11 +01:00
Frank Zingsheim
574b77cf1f
Fixed: FP return reference to thread_local variable ( #1758 )
2019-03-27 12:22:53 +01:00
Daniel Marjamäki
c77f31319d
Fix crash when checking re2c textfile
2019-03-26 20:51:41 +01:00
Rikard Falkeborn
6b478c362e
Allow multiple test case arguments to testrunner ( #1755 )
...
Take some care to not run the same test case twice, even if running:
./testrunner TestClass TestClass::TestCase
2019-03-26 20:28:40 +01:00
Daniel Marjamäki
c262aeffdd
Fixed #9068 (crash on invalid code)
2019-03-26 19:57:32 +01:00
Daniel Marjamäki
15676612c0
Fixed #9034 (crash on reading invalid code: '> typedef')
2019-03-26 16:14:24 +01:00
Sebastian
6976d5c6e2
gtk.cfg: Add support for g_new() and similar macros. ( #1760 )
...
Also add / improve corresponding function configurations and some tests.
2019-03-26 10:45:06 +01:00
IOBYTE
5b72e1f568
Fixed #9040 (Type alias 'BOOL' declared with 'using' keyword breaks type detection) ( #1759 )
...
Moved simplifyUsing from TemplateSimplifier to Tokenizer.
2019-03-26 07:09:56 +01:00
Daniel Marjamäki
49e2f9d551
Fixed #9063 (Crash on invalid code: x='0' ++ '0' ( return)[ ];)
2019-03-25 15:29:23 +01:00
IOBYTE
10fcf731d9
Fixed #9021 (template simplifier: crash in simplifyCalculations) ( #1757 )
2019-03-25 14:56:51 +01:00
orbitcowboy
9bfe7d74c0
windows.cfg: Fixed FP for invalidFunctionArg in second argument of _getcwd(). Reference: https://docs.microsoft.com/en-us/previous-versions/sf98bd4y(v%3Dvs.140)
2019-03-25 09:07:02 +01:00
IOBYTE
b6faa11fbf
Fixed #9056 ("using namespace" inside namespace causes "SymbolDatabase bailout;) ( #1753 )
...
Fixed the bailout warning and one of the varid bugs.
The trailing return type still has a varid.
2019-03-24 17:31:34 +01:00
Daniel Marjamäki
e0f1418228
Fixed #9034 (Tokenizer::setVarId: function call parameter is not variable declaration)
2019-03-24 07:06:21 +01:00
Daniel Marjamäki
418eb43d45
Fixed #9032 (False-positive detection of reassigned value before used for pointer parameter)
2019-03-23 19:01:02 +01:00
Daniel Marjamäki
a9082c902a
Fixed #9058 (crash on invalid code in FwdAnalysis::checkRecursive)
2019-03-23 18:27:41 +01:00
Daniel Marjamäki
d6b806c592
CheckBufferOverrun: Better CTU checking when variable address is passed
2019-03-23 15:57:17 +01:00
Daniel Marjamäki
9653760547
CheckBufferOverrun: Improved CTU analysis for array
2019-03-23 11:20:35 +01:00
IOBYTE
40af889df0
Fixed #9053 (simplifyTypedef: wrong simplification of '(const d)' when 'd' is a array) ( #1751 )
...
* Fixed #9053 (simplifyTypedef: wrong simplification of '(const d)' when 'd' is a array)
* fix whitespace
2019-03-23 10:45:38 +01:00
Daniel Marjamäki
15fc9a622d
CheckBufferOverrun: Add CTU analysis
2019-03-23 08:36:10 +01:00
versat
0d14bdac22
windows.cfg: Add "buffer-size" attributes, fix allocation configuration.
...
Memory allocated with `_aligned_*malloc*()` must be freed with
`_aligned_free*()`. Using `free()` is illegal.
See
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/aligned-malloc
for details.
Also add tests for some of the changed functions.
2019-03-22 13:11:03 +01:00
Paul Fultz II
91138578cc
Fix 9052: Crash: SIGSEGV in Token::previous (this=0x0) while checking mariadb-10.0
2019-03-22 01:56:09 +01:00
versat
7c09b0cfe0
gnu.cfg: Add "buffer-size" attribute and tests for xcalloc().
2019-03-21 10:44:18 +01:00
versat
316475f79f
std.cfg: Add "buffer-size" attribute and tests for aligned_alloc().
2019-03-21 09:25:42 +01:00
Daniel Marjamäki
031362ae01
CheckBufferOverrun: Fix false positive
2019-03-19 21:07:08 +01:00
versat
9b6b94336c
gnu.cfg: Add buffer-size to xmalloc; add some __builtin_*() functions.
2019-03-19 15:24:02 +01:00
Daniel Marjamäki
a0e58f0039
Revert "Revert "CheckBufferOverrun: Handle multidimensional arrays""
...
This reverts commit 9d1755f449
.
2019-03-19 13:16:22 +01:00
Daniel Marjamäki
9d1755f449
Revert "CheckBufferOverrun: Handle multidimensional arrays"
...
This reverts commit e98a4a6f14
.
2019-03-19 13:13:29 +01:00
Daniel Marjamäki
e98a4a6f14
CheckBufferOverrun: Handle multidimensional arrays
2019-03-19 09:29:32 +01:00
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
Daniel Marjamäki
b43572d75e
Fixed #8969 (C++ functional cast not handled correctly)
2019-02-23 17:29:53 +01:00
Daniel Marjamäki
68062e3702
Fixed #8954 (false positive: Local variable x shadows outer variable)
2019-02-23 16:22:22 +01:00
Paul Fultz II
fd3c1fd040
Fix issue 1777: Undefined Behavior: Comparing pointers to different objects
...
This uses the lifetime analysis to check when comparing pointer that point to different objects:
```cpp
int main(void)
{
int foo[10];
int bar[10];
int diff;
if(foo > bar) // Undefined Behavior
{
diff = 1;
}
return 0;
}
```
2019-02-23 08:32:08 +01:00
amai2012
7859d7d879
#3030 add another regression test
2019-02-22 21:10:05 +01:00
Paul Fultz II
941dd79f0d
Fix FP issue 8986: constArgument check warns for elements of const array ( #1683 )
2019-02-22 06:39:59 +01:00
Paul Fultz II
507c7a4388
Improvement to lifetime tracking of addressof and derefencing
...
This will now warn for cases like this:
```cpp
auto& f() {
std::vector<int> x;
return x[0];
}
```
It also improves the handling of address of operator, so it can now warn across some function calls, like this:
```cpp
int& f(int& a) {
return a;
}
int* hello() {
int x = 0;
return &f(x);
}
```
2019-02-22 06:38:56 +01:00
Paul Fultz II
715714f4de
Forward lifetimes in "for" loops ( #1682 )
...
* Forward lifetimes in for loops
* Format
2019-02-22 06:37:02 +01:00
Paul Fultz II
0ee3f678b5
Fix issue 8987: False positive knownConditionTrueFalse ( #1678 )
2019-02-20 15:28:31 +01:00
orbitcowboy
c3244cb359
Fixed regression introduced by my previous commit.
2019-02-20 11:11:20 +01:00
Paul Fultz II
dfaf75db54
Fix issue 8984: FP constStatement regression with qualified name ( #1676 )
2019-02-19 07:08:36 +01:00
versat
dc63cb9f98
gtk.cfg: Add more details for g_print() and g_printerr()
...
Reference:
https://developer.gnome.org/glib/stable/glib-Warnings-and-Assertions.html#g-print
2019-02-18 16:48:46 +01:00
Kamil Dudka
2908593cf6
checkautovariables: eliminate false positives on assignment of &ptr->item ( #1667 )
...
Even if `ptr` is a local variable, the object `ptr->item` might be not.
So taking address of `ptr->item` is definitely not unsafe in general.
This commit fixes false positives triggered by commit
1.85-249-gf42648fe2 on the following code of sssd:
https://github.com/SSSD/sssd/blob/d409df33/src/sbus/request/sbus_request.c#L359
2019-02-18 09:35:07 +01:00
Paul Fultz II
cf1ad5087a
Extend constStatement checker
...
This reworks constStatement to find more issues. It catches issue [8827](https://trac.cppcheck.net/ticket/8827 ):
```cpp
extern void foo(int,const char*,int);
void f(int value)
{
foo(42,"test",42),(value&42);
}
```
It also catches from issue [8451](https://trac.cppcheck.net/ticket/8451 ):
```cpp
void f1(int x) {
1;
(1);
(char)1;
((char)1);
!x;
(!x);
~x;
}
```
And also:
```cpp
void f(int x) {
x;
}
```
The other examples are not caught due to incomplete AST.
2019-02-15 13:31:40 +01:00
rikardfalkeborn
dc4e7cef88
Run simplifyPlatformTypes on library return types ( #1672 )
...
Add a call to simplifyPlatformTypes() in
SymbolDatabase::setValueTypeInTokenList() to simplify return types of
library configured functions. This fixes the FN in #8141 . Regression
tests are added, both for the original issue and another FN in the comments.
In order to do that, move simplifyPlatformTypes() to TokenList from Tokenizer.
This is a pure refactoring and does not change any behaviour. The code was
literally copy-pasted from one file to another and in two places
'list.front()' was changed to 'front()'.
When adding the call to simplifyPlatformTypes(), the original type of
v.size() where v is a container is changed from 'size_t' to 'std::size_t'.
Tests are updated accordingly. It can be noted that if v is declared as
'class fred : public std::vector<int> {} v', the original type of 'v.size()'
is still 'size_t' and not 'std::size_t'.
2019-02-15 13:29:52 +01:00
versat
4dae640e8c
gtk.cfg: Add type conversion macros
...
Reference:
https://developer.gnome.org/glib/stable/glib-Type-Conversion-Macros.html
daca@home found that they are missing.
2019-02-15 08:44:21 +01:00
IOBYTE
8bd5b3eccf
Fixed #8962 ("(debug) Unknown type 'T'" with template typename parame… ( #1671 )
...
* Fixed #8962 ("(debug) Unknown type 'T'" with template typename parameter)
Only simple one parameter template functions with one function parameter
are supported.
* Added TODO test case for FIXME.
2019-02-14 11:48:59 +01:00
versat
ed25ae3acb
gtk.cfg: Add some configurations often reported as missing by daca@home
...
Add two g_assert*(), g_signal_connect_data(), some g_signal_connect*() functions and macros and g_strdup_printf().
2019-02-13 15:35:46 +01:00
versat
fe6ea282d3
qt.cfg: Add support for QT_TR_NOOP* and QT_TRANSLATE_NOOP* macros
...
Reference:
https://doc.qt.io/qt-5/i18n-source-translation.html#using-qt-tr-noop-and-qt-translate-noop-in-c
2019-02-12 10:21:56 +01:00
IOBYTE
9dc5dbe1ab
Fixed #8976 (Crash on `using mystring = std::string;`) ( #1663 )
...
* Fixed #8976 (Crash on `using mystring = std::string;`)
* templateSimplifier: move test case to correct file.
2019-02-12 09:39:01 +01:00
versat
8207e48adc
qt.cfg: Add support for macros Q_LIKELY and Q_UNLIKELY
...
Reference:
https://doc.qt.io/qt-5/qtglobal.html#Q_LIKELY
https://doc.qt.io/qt-5/qtglobal.html#Q_UNLIKELY
2019-02-12 08:21:49 +01:00
Sebastian
2c1f97d787
qt.cfg: Add support for macros `forever` and `Q_FOREVER` ( #1662 )
...
Reference:
https://doc.qt.io/qt-5/qtglobal.html#forever
https://doc.qt.io/qt-5/qtglobal.html#Q_FOREVER
2019-02-11 16:35:01 +01:00
Sebastian
3427e61383
std.cfg: Add support for std::string::assign() ( #1660 )
...
Reference: https://en.cppreference.com/w/cpp/string/basic_string/assign
2019-02-11 13:40:36 +01:00
IOBYTE
9490d0db8c
token simplifier: fix crashes related to #8972 ( #1659 )
2019-02-11 07:45:03 +01:00
Daniel Marjamäki
6ca1aba4a7
UninitVar: Fix --experimental-fast issues
2019-02-10 19:00:01 +01:00
Simon Martin
eaaff30e65
Ticket #8878 : Properly simplify typedefs within template instantiations. ( #1656 )
2019-02-10 09:45:33 +01:00
IOBYTE
155e4ce912
Fixed #8971 ("(debug) Unknown type 'x'." using alias in class members) ( #1653 )
...
* Fixed #8971 ("(debug) Unknown type 'x'." using alias in class members)
* template simplifier: partial fix for #8972
Add support for multi-token default template parameters.
* template simplifier: fix for #8971
Remove typename outside of templates.
2019-02-09 08:34:59 +01:00
Daniel Marjamäki
bd7790fd8c
Update copyright year
2019-02-09 07:24:06 +01:00
Paul Fultz II
d7c20b15e7
Fix FP with const argument when doing a variable and cast ( #1649 )
2019-02-07 14:59:09 +01:00
Sebastian
5fe7aad5e3
qt.cfg: Add configuration and tests for macro Q_NULLPTR ( #1651 )
...
Qt defines `Q_NULLPTR` with `nullptr` if it is available, otherwise with `NULL`.
Since there seems to be no (sane) way to configure it the same way in the library configuration it is just defined with `NULL`.
2019-02-07 12:27:25 +01:00
IOBYTE
7025254c26
Fixed #8969 (syntax error: template) ( #1647 )
...
Fixed template detection to handle multi-token template parameters.
2019-02-07 08:50:49 +01:00
rikardfalkeborn
aa730f45c6
Add regression test for #7714 ( #1648 )
...
Ticket #7714 was fixed in ea215c3b7b
.
Add a regression test to make sure it stays fixed.
2019-02-07 08:49:55 +01:00
Sebastian
55ce6d2073
qt.cfg: Add support and tests for QFile::exists function ( #1645 )
...
Found by daca@home
2019-02-06 13:23:05 +01:00
Daniel Marjamäki
14a312e310
useInitializationList: Skip warning when rhs is a multi line lambda. For readability it might be better to have assignments in constructor in this case.
2019-02-05 19:53:10 +01:00
IOBYTE
1faae52d06
Fixed #8960 ("(debug) Unknown type 'x'." with alias in template class alias) ( #1643 )
...
* Fixed #8960 ("(debug) Unknown type 'x'." with alias in template class alias)
This commit adds non-template type alias support to the template
simplifier. Only relatively simple type aliases are supported at this
time. More complex types will be added later.
--debug-warnings will show unsupported type aliases.
Type alias support will be removed from the symbol database in the
future. Type alias tests have been removed from the symbol database
tests.
* Add the changes.
* Fix codacy warning.
* Fix travis warnings.
2019-02-05 08:52:23 +01:00
Daniel Marjamäki
a4406aca32
Fixed #7845 (Leak reported when ignoring return value of 'new', even if pointer saved by constructor)
2019-02-03 12:15:05 +01:00
Daniel Marjamäki
ae001d4336
Fixed #8957 (Tokenizer::setVarId: varid not set when lambda function is used)
2019-02-03 08:57:04 +01:00
Daniel Marjamäki
4457faa26b
Fixed #8850 (Array in-class initialization for private member considered uninitialized)
2019-02-02 18:34:41 +01:00
Daniel Marjamäki
9d8f798aca
Fixed #8951 (false postive: (style) The class 'x' does not have a constructor although it has private member variables.)
2019-02-02 18:25:26 +01:00
Daniel Marjamäki
a878f90299
Fix Cppcheck warning about unused variable
2019-02-01 07:01:08 +01:00
IOBYTE
d08aa666f6
template simplifier: fix crash on windows ( #1639 )
...
* template simplifier: fix crash on windows
Use right token when searching for template type alias to delete.
* template simplifier: fix a cppcheck warning
2019-02-01 06:59:49 +01:00
IOBYTE
98fc6d1d32
Fixed #8959 ("(debug) Unknown type 'x'" with using/alias) ( #1635 )
...
* Fixed #8959 ("(debug) Unknown type 'x'" with using/alias)
* fix cppcheck warning
2019-01-31 23:57:37 +01:00
rikardfalkeborn
91de606243
TestOther: Shorter test cases ( #1637 )
...
* Remove newlines after check(
* Remove unneeded statements after if-statements
As an example, the previous test case
check(
"bool foo(int x) {\n"
" if (x < 0)"
" return true;\n"
" return false;\n"
"}");
is changed to
check("void foo(int x) {\n"
" if (x < 0) {}\n"
"}");
2019-01-31 23:57:05 +01:00
Daniel Marjamäki
961f66baff
Fixed #8820 (import GUI project)
...
This has basic handling of GUI projects. But further work will be needed to handle addons etc, the plan is that we will be able to run addons from the command line soon.
2019-01-31 20:40:21 +01:00
IOBYTE
05a3e6807b
Fixed #8950 and #8952 (improve type alias support) ( #1633 )
...
* Fixed #8950 and #8952 (improve type alias support)
* fix travis build
2019-01-31 16:53:51 +01:00
Paul Fultz II
c176775afb
Avoid infinite recursion in getLifetimeVariable ( #1634 )
...
* Fix direct recursion
* Limit depth of getLifetimeVariable
2019-01-31 10:34:41 +01:00
rikardfalkeborn
7779a9186e
Use valueflow in unsigned less than zero checker ( #1630 )
...
The unsigned less than zero checker looked for patterns like "<= 0".
Switching to use valueflow improves the checker in a few aspects.
First, it removes false positives where instead of 0, the code is using
0L, 0U, etc. Instead of having to hard code the different variants of 0,
valueflow handles this automatically. This fixes FPs on the form
uint32_t value = 0xFUL;
void f() {
if (value < 0u)
{
value = 0u;
}
}
where 0u was previously not recognized by the checker. This fixes #8836 .
Morover, it makes it possible to handle templates properly. In commit
fa076598ad
, all warnings inside templates
were made inconclusive, since the checker had no idea if "0" came from
a template parameter or not.
This makes it possible to not warn for the following case which was
reported as a FP in #3233
template<int n> void foo(unsigned int x) {
if (x <= n);
}
foo<0>();
but give a warning for the following case
template<int n> void foo(unsigned int x) {
if (x <= 0);
}
Previously, both these cases gave inconclusive warnings.
Finally, it makes it possible to give warnings for the following code:
void f(unsigned x) {
int y = 0;
if (x <= y) {}
}
Also, previously, the checker for unsigned variables larger than 0, the
checker used the string of the astoperand. This meant that for code like
the following:
void f(unsigned x, unsigned y) {
if (x -y >= 0) {}
}
cppcheck would output
[unsigned-expression-positive.c] (style) Unsigned variable '-' can't be negative so it is unnecessary to test it.
using expressionString() instead gives a better error message
[unsigned-expression-positive.c] (style) Unsigned expression 'x-z' can't be negative so it is unnecessary to test it.
2019-01-31 09:30:29 +01:00
Paul Fultz II
165a22ed0f
Lifetime: Support analysis with functions that do not return a reference ( #1632 )
...
* Initial support for function return
* Add test case
* Add support for reference parameters
* Format
2019-01-29 09:47:52 +01:00
versat
62b9368b3c
gtk.cfg: Add configurations for g_free() and g_malloc() / g_malloc0()
...
Reference: https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html
daca@home found these missing function configurations among others.
Also add tests for g_malloc() and g_free().
2019-01-28 13:47:46 +01:00
Daniel Marjamäki
54cebfaf94
Fixed #8392 (false positive: "Memory leak" with malloc in if)
2019-01-27 10:27:44 +01:00
Daniel Marjamäki
2bba9ac78a
Fixed #8948 (False Positive: Variable 'n' is assigned a value that is never used.)
2019-01-26 21:44:07 +01:00
Paul Fultz II
d6aaf401df
Lifetime: Follow functions that return references
...
This will now warn for cases like this:
```cpp
int& f(int& a) {
return a;
}
int& hello() {
int x = 0;
return f(x);
}
```
2019-01-26 11:03:57 +01:00
IOBYTE
68bbe15116
template simplifier: fix missing instantiation ( #1627 )
2019-01-26 07:08:54 +01:00
Sebastian
b1f68229f2
Library cfg tests: Enable all tests again, exclude regressions for now ( #1626 )
...
Use `--check-library` for all tests as it was done before.
Re-enable all tests in runtests.sh again.
The regressions where runtests.sh would fail are disabled via "FIXME"
comment in the inline suppression comment.
2019-01-25 17:03:16 +01:00
Sebastian
ce96ffd433
gtk.cfg: Add internationalization macros / functions ( #1623 )
...
Found via Donate CPU / daca@home.
Reference: https://developer.gnome.org/glib/stable/glib-I18N.html
Update header comment in gtk.cfg since it is now only edited manually.
2019-01-25 13:07:48 +01:00
rikardfalkeborn
a05079fef7
Add regression test for #8780 ( #1619 )
...
Ticket #8780 was fixed in b839ad60dd
.
Add a test to avoid regressions.
2019-01-25 07:48:18 +01:00
IOBYTE
cb1a1df0fa
template simplifier: fix out of line member function scope and use more full name matching ( #1617 )
2019-01-24 07:21:22 +01:00
rikardfalkeborn
080c9d53af
8205 regression test ( #1618 )
...
* Fix trac ticket reference
* Add regression test for #8205
Ticket #8205 was fixed in f65cf220ba
.
Add a test case to avoid regressions.
2019-01-24 07:20:26 +01:00
Daniel Marjamäki
c773e6ed10
runtests.sh: uncomment the xmlstarlet checking
2019-01-23 09:40:43 +01:00
rikardfalkeborn
8356ec6774
Add regression test for #6906 and #7284 ( #1614 )
...
* Add regression test for #6906
Ticket #6906 was fixed in f65cf220ba
.
Add a test to make sure there are no regressions.
* Add regression test for #7284
Ticket #7284 was fixed in 5d1fdf7958
.
Add tests to avoid regressions.
2019-01-23 09:09:03 +01:00
IOBYTE
ec8bc785a2
template simplifier: add support for using namespace when instantiating templates ( #1615 )
2019-01-23 08:53:01 +01:00
Paul Fultz II
3975913637
Extend lifetime checking for references
...
This will use the lifetime checker for dangling references. It will find these cases for indirectly assigned reference:
```cpp
int &foo()
{
int s = 0;
int& x = s;
return x;
}
```
This will also fix issue 510 as well:
```cpp
int &f( int k )
{
static int &r = k;
return r;
}
```
2019-01-23 07:29:16 +01:00
Daniel Marjamäki
8c07be136a
Fixed #8949 (False Positive: Variable 'f' is assigned a value that is never used.)
2019-01-22 21:16:27 +01:00
Daniel Marjamäki
87489c3ffd
Try to make Travis happy
2019-01-22 18:56:12 +01:00
Daniel Marjamäki
f03ce97aae
unmatched suppression: fix test case
2019-01-22 18:47:52 +01:00
versat
6f62b83fe6
checkcfg: Add regression test for umatchedSuppression errors
...
As discussed in https://trac.cppcheck.net/ticket/8931 a regression test is added
to the test/cfg/runtests.sh script to make sure that unmatchedSuppression messages result in an Cppcheck exit code that signals a failure.
2019-01-21 20:53:13 +01:00
Paul Fultz II
4b37f276c2
ValueFlow: Set arrays to true when converting to a boolean
...
This sets it by checking the parent. It doesn't handle function parameters yet.
2019-01-21 20:05:35 +01:00
Daniel Marjamäki
91435310cb
Fixed #8925 (compile_commands.json: False positives in .mm (Objective-C++) files, that file type should maybe just be ignored)
2019-01-21 06:36:31 +01:00
Daniel Marjamäki
8da4e31c42
Fixed #8941 (False Positive: Variable 'f' is assigned a value that is never used.)
2019-01-20 13:20:23 +01:00
rikardfalkeborn
f7d85e9df2
Add regression test for #6904 ( #1611 )
...
Ticket #6904 was fixed in 34dbc3c00c
.
Add a regression test to make sure it doesn't reappear.
2019-01-20 10:05:09 +01:00
IOBYTE
1acbdde302
Fixed #7417 ("syntax error" in valid code containing explicitly specialised variable template) ( #1604 )
2019-01-18 21:12:39 +01:00
Lauri Nurmi
3bbd9fc9a4
Replace "virtual method" with "virtual function" in messages.
...
The term "method" is not really a part of C++ terminology.
2019-01-15 06:22:14 +01:00
Sebastian
aa40e374ac
test/cfg/runtests.sh: Qt test: Fix syntax check when "-fPIC" is required ( #1600 )
...
On linux systems (like travis) Qt often seems to be built with the option "reduce_relocations" which requires an application using it to specify the option "-fPIC".
2019-01-14 17:48:04 +01:00
Daniel Marjamäki
d50c3de740
Remove inline suppression and fix false positive.
2019-01-13 07:59:41 +01:00
amai2012
738fef6c27
Run astyle
2019-01-12 21:51:39 +01:00
amai2012
2adf65968b
posix.cfg: improve configuration for dlsym()
2019-01-12 21:50:02 +01:00
Daniel Marjamäki
022259caf3
Fix Cppcheck warning
...
[ci skip]
2019-01-12 19:11:18 +01:00
Daniel Marjamäki
14b419a48f
Fix Cppcheck warning
...
[ci skip]
2019-01-12 19:10:59 +01:00
Daniel Marjamäki
21f7274533
Remove TestMemleakGlib and TestMemleakWindows
...
[ci skip]
2019-01-12 19:09:55 +01:00
Daniel Marjamäki
9765a2dfab
Remove unused test class. The old memleaks checker will not be used anymore.
2019-01-12 18:45:42 +01:00
Daniel Marjamäki
5276fd68b2
Remove unused test functions
...
[ci skip]
2019-01-12 18:32:18 +01:00
Daniel Marjamäki
8dd641b8be
Use OVERRIDE in test
2019-01-12 15:45:25 +01:00
Daniel Marjamäki
1cd16cf94f
Suppressions: Handle comment in file that starts with #
2019-01-12 15:21:47 +01:00
Daniel Marjamäki
8b5f36670a
Introduce macro OVERRIDE for gcc-4.6 compatibility.
2019-01-12 07:37:42 +01:00
juremenart
45def06d59
fix trailing / from CMAKE JSON file and update unittests to cover both (w and w/o cases) ( #1592 )
...
* fix for CMake compile_commands.json input - director does not include trailing / which makes include directories wrong - so add it if it doesnt exist
* fix the bugfix for trailing / in the directory name of CMAKE JSON file, add also new test case to see if it works in both cases (with and without trailing /)
* revert adding accidental new line
2019-01-11 16:36:55 +01:00
rikardfalkeborn
49bad106bb
Add regression test for 8168 ( #1588 )
...
Ticket 8168 was fixed in 713f607168
.
Add a regression test to make sure the bug doesn't reappear.
2019-01-11 14:11:48 +01:00
Paul Fultz II
921f6e4313
Fix issue 8883: False positive: returnDanglingLifetime with local struct or class ( #1585 )
2019-01-11 09:51:02 +01:00
Paul Fultz II
5fa956a597
Fix issue 8932: False positive knownConditionTrueFalse - valueflow ignores operator < ( #1584 )
2019-01-11 08:39:23 +01:00
amai2012
400c6c8e76
Improve configuration for dlopen and add suitable test
2019-01-10 21:14:37 +01:00
Daniel Marjamäki
8509159d1a
Uninitialized Member variable: Fixed FP when delegate constructor is used
2019-01-10 20:13:37 +01:00
rikardfalkeborn
a48c8abcda
Fix 8124: False positive va_end missing with lambda ( #1577 )
...
Skip lambdas, to avoid false positives due to possible
return statements in lambdas.
Also, run dmake.
2019-01-10 18:32:17 +01:00
Paul Fultz II
4e147a4c59
Add a check for duplicate if statements
...
This will warn for this:
```cpp
int f(int val)
{
int i = 0;
if( val & 0xff)
i = 1;
if( val & 0xff)
i = 1;
return i;
}
```
2019-01-09 20:41:01 +01:00
Daniel Marjamäki
35e56942d1
Fixed #8116 ([False positive] Invalid memory leak detection when using reference.)
2019-01-09 20:38:32 +01:00
Daniel Marjamäki
75e367c48b
Fixed #8340 (incorrect memleak errors)
2019-01-09 19:50:41 +01:00
amai2012
97bf5de133
Add more Windows (Microsoft) macros and a few lines of related test code
2019-01-08 21:15:04 +01:00
Daniel Marjamäki
0f9ce5edd5
Fixed #8365 (False positive on memory leak when assigned inside if statement)
2019-01-08 20:54:39 +01:00
Sebastian
0aa4910244
Boost configuration: Add macros and initial test file ( #1575 )
2019-01-08 20:30:21 +01:00
Daniel Marjamäki
e4525d56a0
Fixed #8111 (performance warning - member variable at constructor)
2019-01-07 21:26:58 +01:00
Sebastian
7a59949cb4
qt config test: Use pkg-config to retrieve Qt settings. ( #1571 )
...
To be able to use real Qt-Code in "test/cfg/qt.cpp" and still do a
syntax check the Qt settings are read out via pkg-config now if it is
available. This way the test now can contain Qt macros and functions and
the syntax check can still be used.
Additionally the same options as for the other tests are used now for
the Qt config tests.
Installing the package "qtbase5-dev" should be enough to enable the
syntax checks (already installed for travis tests).
2019-01-07 14:40:21 +01:00
practicalswift
0a1b3a9d6f
Fix typos ( #1568 )
2019-01-06 17:15:57 +01:00
Daniel Marjamäki
5636497c0b
Fixed #8863 (false positive: (warning) Accessing an item in container 's'. Either the condition 's.empty()' is redundant or 's' can be empty.)
2019-01-06 12:21:55 +01:00
Daniel Marjamäki
ea0232653f
Fixed #8563 (CPPCheck not able to locate file through compilation database)
2019-01-05 23:11:43 +01:00
IOBYTE
817c748e4d
Fixed #5953 (debug: varid0: Function::addArguments) ( #1567 )
2019-01-05 19:42:04 +01:00
Daniel Marjamäki
615903c6be
Improve syntax errors for unmatched (){}[]
2019-01-05 11:56:21 +01:00
IOBYTE
32a5d66e5b
Fixed #8927 (SIGSEGV below TemplateSimplifier::expandTemplate) ( #1564 )
2019-01-05 11:14:09 +01:00
Paul Fultz II
bba6dfb8b2
Fix issue 4744: ValueFlow: known integer result
...
This fixes valueflow to have a value for `||` operator here:
```cpp
bool f()
{
bool a = (4 == 3); // <-- 0
bool b = (3 == 3); // <-- 1
return a || b; // <-- 1
}
```
2019-01-03 07:05:31 +01:00
Daniel Marjamäki
2b63997c2c
Fixed #8928 (false positive: (style) Variable 'x' is assigned a value that is never used.)
2019-01-02 20:23:02 +01:00
Daniel Marjamäki
39ceb53578
Comment out code in valueFlowArray. There was too many false positives.
2019-01-02 19:57:11 +01:00
Daniel Marjamäki
39a96a5a16
ValueFlow: Temporarily comment out valueFlowTerminatingCondition
2019-01-02 19:42:08 +01:00
Daniel Marjamäki
7a40b85531
Fixed #8906 (Encoding error in XML message: info attribute)
2019-01-02 18:22:12 +01:00
Daniel Marjamäki
236c88151f
Fixed #8926 (false positive: (style) Condition 's.x<=y' is always true)
2019-01-02 18:05:55 +01:00
IOBYTE
3b9828a132
template simplifier: fix crash on daca c++-annotations project ( #1556 )
...
Fix scope info bug on derived template class which caused a use after
free crash when deleting a template forward declaration in a different
scope.
2019-01-02 07:15:45 +01:00
Daniel Marjamäki
19514331fb
Fixed #8907 (unknown macro not detected)
2019-01-01 19:30:13 +01:00
Daniel Marjamäki
115be7dfc8
ValueFlow: better FwdAnalysis for complex expressions
2019-01-01 18:23:47 +01:00
Daniel Marjamäki
be7afac875
ValueFlow: remove handling of == for complex expressions it did not work properly
2019-01-01 17:23:46 +01:00
rikardfalkeborn
13ffefc8b8
Valueflow: Fix right shift with more than 31 bits ( #1553 )
...
When comparing if the shift is large enough to make the result zero, use
an unsigned long long to make sure the result fits. Also, a check that
avoids setting the value if the shift is equal to or larger than the
number of bits in the operand (this is undefined behaviour). Finally,
add a check to make sure the calculated value is not too large to store.
Add test cases to cover this.
This was detected by an MSVC warning.
valueflow.cpp(1350): warning C4334: '<<' : result of 32-bit shift implicitly
converted to 64 bits (was 64-bit shift intended?)
2019-01-01 14:15:50 +01:00
Daniel Marjamäki
a73e989d1a
isConstVarExpression: Fix FPs when there is C++ cast
2019-01-01 11:34:44 +01:00
Daniel Marjamäki
04d3672bde
Fixed #7203 (Better syntax error, handle array declaration with @)
2019-01-01 09:45:41 +01:00
IOBYTE
c37b807613
template simplifier: also check if instantiated template is not specialized ( #1551 )
2018-12-31 21:29:53 +01:00
Daniel Marjamäki
ac357a96f7
Fixed #7384 (confuses syntax with variable name / "variable '(' is less than zero")
2018-12-31 18:36:06 +01:00
Daniel Marjamäki
4918a18bfb
ValueFlow: Value of expression after condition
2018-12-31 17:37:38 +01:00
IOBYTE
9dc8faa3b6
template simplifier: fix location of forward declaration for explicit specializations ( #1550 )
2018-12-31 17:19:34 +01:00
Daniel Marjamäki
141ce7cd63
ValueFlow: Use FwdAnalysisAllPaths in ValueFlow to track complex expressions
2018-12-31 17:05:46 +01:00
Daniel Marjamäki
aa4f61acdf
CTU: Avoid FP in else block
2018-12-31 08:24:39 +01:00
Daniel Marjamäki
fb6a291370
CTU: Avoid FP in code protected by &&,||,?
2018-12-31 08:16:21 +01:00
Daniel Marjamäki
6b49a784c5
Fixed #8911 (Regression: False positive: Unassigned variable (alias))
2018-12-30 20:20:20 +01:00
Daniel Marjamäki
91a580cbd7
CTU: more warnings
2018-12-30 18:31:37 +01:00
Daniel Marjamäki
c8901e9bab
CTU: Find paths better
2018-12-30 16:23:25 +01:00
IOBYTE
da91ce2016
Fixed #6183 (TemplateSimplifier: Does not handle methods) ( #1546 )
...
* Fixed #6183 (TemplateSimplifier: Does not handle methods)
* Fix function lookup.
2018-12-29 11:19:53 +01:00
Paul Fultz II
e4677ae640
Fix issue 8910: Regression: ValueFlow: wrong conditional tokvalue
...
This fixes issue in:
```cpp
void f()
{
char stack[512];
RGNDATA *data;
if (data_size > sizeof (stack))
data = malloc (data_size);
else
data = (RGNDATA *)stack;
if ((char *)data != stack)
free (data); // <- data is not stack
}
```
It seems the `ProgramMemory` can't handle two known values(such as int and tok) together. So instead `ValueFlowAfterAssign` runs `ValueFlowForward` with tok values and then runs it with the other values.
2018-12-29 09:31:21 +01:00
Daniel Marjamäki
d18f5d8709
CTU: Reuse CheckNullPointer::isPointerDeRef in the nullpointer isUnsafeUsage
2018-12-29 09:26:57 +01:00
amai2012
03ed4afc70
Export interfaces from cppcheck-core.dll used from testrunner. In turn remove ctu sources from testrunner which are obsolete now.
2018-12-28 23:09:44 +01:00
amai2012
128ad96b59
Add ctu sources to VS projects
2018-12-27 22:11:40 +01:00
Daniel Marjamäki
a40fe3c67f
Fixed #7872 (ValueFlow: static_cast)
2018-12-27 21:33:01 +01:00
Daniel Marjamäki
6fef02498c
Fixed #7263 (False negative: redundant assignment using +=)
2018-12-27 17:27:53 +01:00
Daniel Marjamäki
271763e680
CTU: Refactoring
2018-12-25 21:11:23 +01:00
Daniel Marjamäki
a1dca6acd5
Fix CTU nullpointer check
2018-12-25 12:04:01 +01:00
Daniel Marjamäki
162576146e
Revert "Fixed #6183 (TemplateSimplifier: Does not handle methods) ( #1540 )"
...
This reverts commit 7875555b03
.
2018-12-24 20:10:00 +01:00
IOBYTE
7875555b03
Fixed #6183 (TemplateSimplifier: Does not handle methods) ( #1540 )
2018-12-24 07:25:11 +01:00
orbitcowboy
611eb81302
Fixed checkcfg: test/cfg/std.cpp:2904:error:uninitvar:Uninitialized variable: s
2018-12-23 18:09:55 +01:00
Daniel Marjamäki
b79619832e
Clarify warning
2018-12-23 12:42:18 +01:00
Daniel Marjamäki
e6e3987935
snprintf/g_snprintf: do not allow uninitialized target buffer
2018-12-22 20:40:47 +01:00
IOBYTE
48c960f56c
template simplifier: better detection of template functions ( #1539 )
...
* template simplifier: better detection of template functions
* fix comment
2018-12-22 10:05:10 +01:00
Rikard Falkeborn
204ce795ba
Print test case name in assert
...
I sometimes find myself wondering which test cases I have broken when I fiddle with some check (since I then can try running these specific tests in the debugger, or make a small change and see if the tests pass). This PR adds the testclass and the test case names to the file and line number. I took special care to cover the case where an assert would be placed directly in the ```run()```-function, i.e., not inside a test case (from what I could see, no such case exists). If there is no need to handle this case, the code can be simplified (there wouldn't be need for the ```teardownTest()```-function for example).
The exact format for how to print the test name is very much up for discussion.
2018-12-21 13:55:24 +01:00
IOBYTE
d528934139
template simplifier: also remove forward declarations when removing expanded templates ( #1536 )
2018-12-20 20:55:27 +01:00
amai2012
19e979315f
Correct detection of Microsoft extensions in MathLib::isValidIntegerSuffix. Remove public overloaded implementation which was not used outside mathlib.cpp. ( #1531 )
2018-12-20 12:20:31 +01:00
amai2012
0f4eac657d
Make script less verbose
2018-12-19 22:18:24 +01:00
IOBYTE
c31331d085
template simplifier: fix explicit instantiation with types starting with const and ending in * and &. ( #1530 )
2018-12-19 21:59:59 +01:00
Daniel Marjamäki
e2c433a0f8
Fixed #8914 (False positive with unary_function argument)
2018-12-19 19:43:05 +01:00
amai2012
378ffed37e
Address compiler warning
2018-12-19 14:39:04 +01:00
Daniel Marjamäki
bc34f0239d
Disable the subfunction value flow analysis. It does not work well and needs to be rewritten. There are false positives.
2018-12-18 14:36:49 +01:00
Paul Fultz II
34330b51d1
Fix issue 8905: Condition 'a==0' is always false
...
This fixes the FP in:
```cpp
void f(const int a[]){ if (a == 0){} }
```
2018-12-18 08:16:43 +01:00
IOBYTE
1cba78090c
Fix const anonymous struct. ( #1527 )
2018-12-18 08:15:12 +01:00
Daniel Marjamäki
0f63874c62
Take back the whole program analysis for null pointers and uninitialized variables
2018-12-18 07:56:33 +01:00
Daniel Marjamäki
643ddd4caa
Code cleanup
2018-12-17 18:54:32 +01:00
Daniel Marjamäki
3b328f9187
CheckMemoryLeak: Cleanup the old memory leaks check
2018-12-17 18:12:50 +01:00
Daniel Marjamäki
fe38e256cc
Fixed #7907 (FN: redundant assignment inside switchcase, overwritten by assignment outside of switch)
2018-12-17 16:10:47 +01:00
Daniel Marjamäki
bf4e850e11
Fixed #4475 (New check: struct member is assigned a value that is not read)
2018-12-17 15:40:15 +01:00
Daniel Marjamäki
858d9a18a7
Fixed #3857 (false negative: (style) Variable 'var' is assigned a value that is never used)
2018-12-17 15:16:47 +01:00
Paul Fultz II
025881cf35
Fix issue 8829: Condition '...' is always true (int buf[42]; if(buf != NULL){})
...
This makes arrays non-null in valueflow, so it can catch comparisons against null that is always true:
```cpp
void f(void) {
int buf[42];
if( buf != 0) {;} // << always true
}
```
2018-12-17 06:07:34 +01:00
Paul Fultz II
9b973e652c
Issue 8830: New check: Function argument evaluates to constant value
...
Add a check for function arguments that can be constant:
```cpp
extern void bar(int);
void f(int x) {
bar((x & 0x01) >> 7); // function 'bar' is always called with a '0'-argument
}
```
2018-12-17 06:04:24 +01:00
IOBYTE
2090866cd0
template simplifier: remove explicit instantiations after instantiation ( #1523 )
...
* template simplifier: remove explicit instantiations after instantiation
* Fix use after free crash in clang test suite.
2018-12-17 05:58:48 +01:00
Daniel Marjamäki
357e2fbfb3
Add testcase for #8807 (False negative: Redundant variable assignments (loop))
2018-12-16 21:45:26 +01:00
Daniel Marjamäki
c8d688607a
Fixed #8901 (Unused value: const variable initialization)
2018-12-16 19:01:05 +01:00
Daniel Marjamäki
21eb1c5e22
FwdAnalysis: Fix false negatives for struct members
2018-12-16 18:32:34 +01:00
Daniel Marjamäki
46a0172480
FwdAnalysis: fix FP in loop
2018-12-16 16:43:04 +01:00
Daniel Marjamäki
3af0d73f82
Unused value: Fixed false negatives for loops
2018-12-16 11:18:37 +01:00
Paul Fultz II
3262a3bebe
Add isSameExpression to valueflow analysis
...
Check for same expressions in valueflow analysis.
2018-12-16 07:35:27 +01:00
Paul Fultz II
45dcfad9f9
Fix issue 8899: False positive returnDanglingLifetime when returning by value
...
This fixes the FP from:
```cpp
#include <string>
class MyString
{
public:
MyString(char* source)
{
length = strlen( source );
buffer = new char[length+1];
if( buffer )
{
strcpy( buffer, source );
}
}
char* buffer;
int length;
};
MyString Foo()
{
char arr[20];
sprintf(arr, "hello world");
return arr;
}
void main()
{
MyString str = Foo();
printf(str.buffer);
}
```
2018-12-15 17:58:45 +01:00
Daniel Marjamäki
1bfe98447a
FwdAnalysis: Tweak possiblyAliased
2018-12-15 11:54:00 +01:00
Daniel Marjamäki
f26549e5ab
Fixed #8896 (Tokenizer: Anonymous struct)
2018-12-15 08:42:35 +01:00
IOBYTE
a1c275436f
Fix #8902 (Crash in TemplateSimplifier) ( #1521 )
2018-12-15 07:52:47 +01:00
Daniel Marjamäki
37416010ef
Unused value: Fix false positive (ast, {})
2018-12-14 18:56:09 +01:00
Paul Fultz II
be6782d386
Fix FP 8891: Incorrect return scope when using uniform initialization
...
This fixes the FP in:
```cpp
std::string f(const std::string& data)
{
if (data.empty())
return {};
data[0];
}
```
2018-12-14 18:31:10 +01:00
Daniel Marjamäki
9742c1e2ae
make checkcfg: Try to fix inline suppressions
2018-12-14 13:51:03 +01:00
Daniel Marjamäki
8464085535
UnusedVariables: Fix FP for unknown variable
2018-12-13 21:37:21 +01:00
Daniel Marjamäki
092d434f91
UnusedVar: Fix FP for array arguments
2018-12-13 21:08:18 +01:00
Daniel Marjamäki
1f27cd56c0
FwdAnalysis; Code cleanup, isNullOperand
2018-12-13 21:01:33 +01:00
Daniel Marjamäki
0b4e08cac9
Use FwdAnalysis in UnusedVar. This is still work-in-progress. Merging to master branch so it can be tested.
2018-12-13 18:52:56 +01:00
IOBYTE
0f83aff3b8
Improve trailing return type support. ( #1520 )
...
* Improve trailing return type support.
* Partial fix for #8889 (varid on function when using trailing return type)
* Handle operators in templates.
2018-12-13 06:34:10 +01:00
Daniel Marjamäki
e0b64ec7a9
Fixed #8884 (AST: handle xs... template argument)
2018-12-12 19:00:14 +01:00
amai2012
6924522475
Refactor methods for identification of numeric literals. ( #1514 )
2018-12-10 12:10:26 +01:00
Daniel Marjamäki
a16f694254
Revert "Fix issue 8884: Regression: False positive: Variable 'f' is reassigned a value before the old one has been used ( #1513 )"
...
This reverts commit 6953dddfa6
.
2018-12-08 08:25:20 +01:00
Paul Fultz II
6953dddfa6
Fix issue 8884: Regression: False positive: Variable 'f' is reassigned a value before the old one has been used ( #1513 )
2018-12-08 07:33:51 +01:00
amai2012
a68086c959
Implement hexadecimal float conversion in MathLib::toDoubleNumber ind… ( #1506 )
...
* Implement hexadecimal float conversion in MathLib::toDoubleNumber independent of C99/C++17
* Refactor MathLib::isFloatHex and cure some false results
2018-12-06 22:16:16 +01:00
IOBYTE
a90c56ad76
Fixed #8880 (Regression: syntax error for valid C++ template code) ( #1509 )
2018-12-06 21:47:48 +01:00
Daniel Marjamäki
01d0199ecf
Fix testrunner
2018-12-04 19:56:22 +01:00
Daniel Marjamäki
bd0a935d8a
Tokenizer: Improved handling of compiler extensions that use @ (see https://sourceforge.net/p/cppcheck/discussion/general/thread/8f618cb0a3 )
2018-12-04 19:33:39 +01:00
Daniel Marjamäki
88c61e8d1e
ValueFlow: Avoid FP when lambda is used
2018-12-04 18:54:26 +01:00
Daniel Marjamäki
f5a94ed300
ValueFlow: Fix FP when lambda is called
2018-12-04 18:46:00 +01:00
Daniel Marjamäki
7c47283e6d
Fix testrunner
2018-12-04 17:17:07 +01:00
Daniel Marjamäki
49413b7d4c
Tokenizer: Add simplifyAt to handle some nonstandard code with @
2018-12-04 16:52:41 +01:00
Igor
61878c5e11
Add null pointer check to fix SEGFAULT ( #1499 )
...
* Add null pointer check to fix segfault
* Add first test case to reproduce problem
2018-12-02 14:36:01 +01:00
Paul Fultz II
3e1b34dd8f
Fix FPs and crashes with byDerefCopy ( #1503 )
...
* Fix FP when inserting a range into a container
* Formatting
* Fix crash
2018-12-02 14:31:31 +01:00
Daniel Marjamäki
ba564076db
Fixed #7907 (FN: redundant assignment inside switchcase, overwritten by assignment outside of switch)
2018-12-02 14:04:59 +01:00
Daniel Marjamäki
8087cfed5d
Fixed #8627 (Tokenizer::setVarIdPass2: constructor parameter)
2018-12-02 09:28:05 +01:00
Daniel Marjamäki
ccbaad32f9
Fix merge conflicts
2018-12-01 19:14:43 +01:00
Paul Fultz II
b841b818d2
Fix 8872: Crash in LifetimeStore when there is no scope for variable
...
This fixes crash in:
```cpp
struct edit_line_paste_over {
void operator()(agi::Context *c) override {
paste_lines(c, true, [&](AssDialogue *new_line) -> AssDialogue * {
AssDialogue *ret = paste_over(c->parent, pasteOverOptions, new_line, static_cast<AssDialogue*>(&*pos));
return ret;
});
}
};
```
2018-12-01 19:11:26 +01:00
Paul Fultz II
67dd822910
Fix FP in lifetime anlaysis: Dont decay std array
...
This will fix FP with:
```cpp
std::array<char, 1> f() {
std::array<char, 1> x;
return x;
}
```
2018-12-01 19:09:19 +01:00
Paul Fultz II
229c45e7f8
Fix issue 8865: FP with dangling lifetime
...
This fixes:
```cpp
void f(uint32_t event, unsigned long op, const xen_ulong_t *args)
{
struct __packed {
uint32_t op;
uint32_t args[6];
} d;
uint32_t *a = d.args;
}
```
2018-12-01 19:07:46 +01:00
Daniel Marjamäki
2c803a1ead
Revert " #6514 Try to support hexadecimal floating numbers in MathLib::toDoubleNumber"
...
This reverts commit a73decf7e4
.
2018-12-01 19:01:51 +01:00
Daniel Marjamäki
501f99ac5a
Revert "astyle formatting"
...
This reverts commit 9289c9a283
.
2018-12-01 19:01:40 +01:00
Daniel Marjamäki
96929c53c0
Fixed #8873 (Add syntaxError when there is no RHS for +-)
2018-12-01 17:29:41 +01:00
Daniel Marjamäki
9289c9a283
astyle formatting
2018-12-01 13:17:16 +01:00
Daniel Marjamäki
f42648fe22
Fixed #8114 (false positive: Address of local auto-variable assigned to a function parameter.)
2018-12-01 10:11:02 +01:00
amai2012
a73decf7e4
#6514 Try to support hexadecimal floating numbers in MathLib::toDoubleNumber
2018-12-01 00:50:26 +01:00
Colomban Wendling
cad4e4ab20
Fix handling of `sizeof &var` ( #1498 )
...
Fixes https://trac.cppcheck.net/ticket/8870
2018-11-30 13:53:58 +01:00
IOBYTE
3d024f3f6d
template simplifier: fix function forward declaration bug for constructor with initializer list. ( #1497 )
2018-11-29 06:24:28 +01:00
Daniel Marjamäki
dd94bfede9
CheckStl: Improving checking of container access out of bounds
2018-11-28 19:27:28 +01:00
Daniel Marjamäki
6493db6ca2
Try to clarify message for container access out of bounds a little more.
2018-11-28 13:58:01 +01:00
Daniel Marjamäki
0f2f807798
Improve the container out of bounds messages. They are still not perfect.
2018-11-28 07:03:56 +01:00
Daniel Marjamäki
13c6489571
Redundant variable assignment: Fix FN for struct members
2018-11-27 18:22:22 +01:00
Paul Fultz II
5a6f9ac82a
Fix FP with strcmp and terminating conditions
2018-11-27 06:39:29 +01:00
IOBYTE
f2660ed203
template simplifier: fix instantiated template names in forward declarations ( #1495 )
...
This now handles the revised example code in #8603 .
2018-11-27 06:17:04 +01:00
Daniel Marjamäki
2887ee10c0
Fixed #8800 (Possible variable assignment ignored in boolean expression)
2018-11-26 14:00:03 +01:00
Daniel Marjamäki
affd03f1d6
Minor tweak for redundantVariableAssignment
2018-11-26 11:16:50 +01:00
IOBYTE
e20079a5d9
template simplifier: fix 3 function forward declaration bugs ( #1493 )
...
* fix support for multi token types
* fix support for const member functions
* fix duplicate template parameters sometimes being inserted
2018-11-26 06:23:12 +01:00
Daniel Marjamäki
86f9fb778b
Fixed #8864 (compile commands: handle define with string value)
2018-11-25 15:09:23 +01:00
Daniel Marjamäki
0160f80ffe
redundantVarAssignment: avoid FPs when loops are used
2018-11-25 10:32:30 +01:00
Daniel Marjamäki
22f736eae2
redundant variable assignments: avoid FPs for initializations
2018-11-25 08:49:09 +01:00
Daniel Marjamäki
2f66b31d43
redundantAssignmentInSwitch: fix false positive when there is goto
2018-11-24 21:39:01 +01:00
Daniel Marjamäki
b7ca9bdc8d
Travis: redundantCopy is not detected at the moment
2018-11-24 12:01:10 +01:00
Daniel Marjamäki
ec89c7b1b8
Travis: redundantCopy is not detected at the moment
2018-11-24 11:27:27 +01:00
Paul Fultz II
a3921ea861
Refactor valueFlowAfterCondition
...
So this unifies the `valueFlowAfterCondition` so it re-uses more code between checking for integers and container sizes. This should make valueFlowContainer more robust.
It also extends valueflow to support container comparisons such as `if (v.size() < 3)` or `if (v.size() > 3)` using the same mechanism that is used for integers.
2018-11-24 10:07:12 +01:00
Daniel Marjamäki
866688c70a
Rewriting redundantAssignment checker
2018-11-24 10:03:54 +01:00
IOBYTE
358f0c473d
Modify template simplifier to add forward declarations of some templa… ( #1489 )
...
* Modify template simplifier to add forward declarations of some template functions so symbol database can make sense of the expanded templates.
* Fix travis.
2018-11-23 11:36:09 +01:00
orbitcowboy
ef05be2600
wxwidgets.cfg: Fixed FP due to overlaoded function wxSizer::Add().
2018-11-23 09:49:08 +01:00
Daniel Marjamäki
c181d28b1a
astyle formatting
...
[ci skip]
2018-11-23 06:47:27 +01:00
orbitcowboy
428d0147bc
wxwidgets.cfg: Added support for wxSizer::Add().
2018-11-22 14:04:22 +01:00
orbitcowboy
d6c85118a7
wxwidgets.cfg: Improved support for some wxStaticText member functions.
2018-11-22 13:47:17 +01:00
orbitcowboy
2b9bdc52d7
wxwidgets.cfg: Added support for wxWindow::Close() and derived classes.
2018-11-22 13:31:09 +01:00
Paul Fultz II
f16d9d7d90
Issue 6175: Check lifetime of a variables stored in containers and member variables
...
Cppcheck will now warn for all cases here:
```cpp
#include <vector>
class CCluster {};
class MyClass
{ public:
std::vector<CCluster*> m_cluster;
void createCluster()
{
CCluster cl;
CCluster* pcl=&cl;
m_cluster.push_back(pcl);
}
void createCluster2()
{
CCluster cl;
m_cluster.push_back(&cl);
}
CCluster* Cluster()
{
CCluster cl;
CCluster* pcl=&cl;
return pcl;
}
CCluster* Cluster2()
{
CCluster cl;
return &cl;
}
};
```
2018-11-21 08:43:57 +01:00
Daniel Marjamäki
081bd7660e
Fix Travis
2018-11-21 08:39:21 +01:00
orbitcowboy
b4aa04db41
std.cfg: Added returnValue calculation for isless(), islessgreater() etc.
2018-11-20 16:58:33 +01:00
orbitcowboy
58b3d75b62
std.cfg: Added invalidFunctionArg cfg for strchr().
2018-11-20 08:32:54 +01:00
Daniel Marjamäki
a8cbbe0e16
Fixed #8816 (FP shadowLocal - variable shadows a template function?)
2018-11-19 07:00:15 +01:00
Daniel Marjamäki
9ef3c79bc6
Fixed #8851 (Crash in valueFlowContainerForward (daca@home: pbbam))
2018-11-18 20:18:55 +01:00
Paul Fultz II
7ef119cbfc
Fix FPs in lifetime checker
...
This fixes several FPs in the lifetime checker. It also fixes issue [8846](https://trac.cppcheck.net/ticket/8846 ):
```cpp
int * f(int a[])
{
return a;
}
```
2018-11-17 09:41:59 +01:00
Paul Fultz II
d376e9f245
Track variable lifetime through function calls ( #1481 )
2018-11-16 06:12:28 +01:00
Carlo Marcelo Arenas Belon
d880d64a9c
test: avoid a mutable comparator for test ( #1482 )
2018-11-15 16:21:12 +01:00
Daniel Marjamäki
5d086d60ad
Fixed #8844 (snd: Wrong varid and ast)
2018-11-14 21:05:09 +01:00
Daniel Marjamäki
69f2e0938a
VarId: Improved varids for struct members ( #8844 )
2018-11-14 19:11:35 +01:00
Daniel Marjamäki
69f6100d83
Fixed #8339 (false positive: unread variable despite delete is used on it)
2018-11-14 17:04:21 +01:00
Paul Fultz II
54453c5802
Fix FP when copying pointer to string ( #1479 )
2018-11-14 06:59:25 +01:00
Paul Fultz II
f0c86b9d14
Fix issue 8842: Crash in valueFlowTerminatingCondition on incomplete code ( #1480 )
2018-11-14 06:23:45 +01:00
Daniel Marjamäki
e6a5e0f752
Warn when there is a unknown macro
2018-11-13 16:49:15 +01:00
Daniel Marjamäki
69e7392ce2
Fixed #8449 (False positive 'constStatement' when initializing std::unordered_map)
2018-11-12 18:10:34 +01:00
Daniel Marjamäki
3d629944da
Fixed #8100 (False positive when method/function defines lambda with pointer return value)
2018-11-12 11:28:38 +01:00
Paul Fultz II
0e11bb07c8
Extend lifetime analysis to pointer usage ( #1477 )
...
* Use lifetime analysis for pointers as well
* Fix issue 1143: Pointer to local array
* Update message when using pointers
* Avoid infinite loop in tracing lifetimes
2018-11-12 10:08:17 +01:00
Daniel Marjamäki
58882b1f14
Fixed #8261 (False positive "Statements following return, break, continue, goto or throw will never be executed.")
2018-11-12 06:31:17 +01:00
Paul Fultz II
68d6b96878
Diagnose invalid lifetimes ( #1475 )
...
* Add check for invalid lifetimes
* Fix FP with member variables
* Dont forward lifetime values in subfunction
* Update message to use out of scope
2018-11-11 16:43:54 +01:00
Daniel Marjamäki
3f55707b30
Fixed #8064 (Taking the address of a moved variable is not accessing it)
2018-11-11 12:47:27 +01:00
Paul Fultz II
e46691597e
Fix issue 8841: FP knownConditionTrueFalse - Dont treat unknown function as noreturn ( #1474 )
...
* Fix issue 8841: Dont treat unknown function as noreturn
* Add a parameter to set default value when the function is unknown
2018-11-11 08:04:01 +01:00
Daniel Marjamäki
ee2dfb6604
Fixed #8058 (False positive returnAddressOfAutoVariable within lambda)
2018-11-11 07:52:38 +01:00
Daniel Marjamäki
93cde415a7
Fixed #7988 (variable in condition gets wrong varid)
2018-11-11 07:50:25 +01:00
Daniel Marjamäki
148f257c6b
Fixed #8838 (False positive on overridden virtual function that is marked both const and final)
2018-11-10 21:57:50 +01:00
Daniel Marjamäki
8327aab127
Fixed #8628 (Wrong AST in case)
2018-11-10 21:32:06 +01:00
Daniel Marjamäki
d5a478d5c5
astyle formatting
...
[ci skip]
2018-11-10 21:30:01 +01:00
Daniel Marjamäki
4cef2e94e7
Fixed #8368 (FP redundantAssignment - assignment has unknown side-effects)
2018-11-10 18:42:13 +01:00
IOBYTE
69e6e11844
Fix a template simplifier namespace bug in #7145 ( #1473 )
...
* Fix a template simplifier namespace bug in #7145
* Refactor template simplifier to only call getTemplateDeclarations once per loop.
2018-11-10 16:41:14 +01:00
Paul Fultz II
1ffcc6b730
Add initial lifetime checker ( #1448 )
...
* Inital valueflow lifetime checker
* Forward values
* Add initial tests
* Fix deplicate messages
* Fix traversing nested lambdas
* Turn test case into a todo
* Skip if returning a container
* Fix FP when using references
* Add missing header
* Fix FP from broken scopes
* Fix FP with static variable
* Add test for more FPs
* Parse lambda functions
* Check for capture by value
* Add tests for using a container and lambda together
* Fix cppcheck errors
* Add test for nextAfterAstRightmostLeaf
* Add valueflow tests
* Update error message
* Check for correct lambda token
* Improve error path reporting
* Fix hang when parsing arrays that look almlost like lambdas
2018-11-10 16:40:40 +01:00
IOBYTE
e302e6e7a1
Fix symbol database argsMatch to skip all redundant type information (class, struct, union, enum) ( #1472 )
2018-11-09 15:54:17 +01:00
IOBYTE
67fe99fcd9
Fix symbol database argsMatch function and its usage so qualified types are handled properly. ( #1470 )
...
* Fix symbol database argsMatch function and its usage so qualified types are handled properly.
* Remove assert.
2018-11-09 06:11:48 +01:00
Paul Fultz II
36e663e250
Fix issue 8839: FP knownConditionTrueFalse - condition inside a while-clause ( #1469 )
2018-11-09 06:09:51 +01:00
IOBYTE
17a8a4898d
Fix another template simplifier namespace bug. ( #1467 )
...
* Fix another template simplifier namespace bug.
* Add missing forward declarations caused by token bug.
2018-11-07 21:25:42 +01:00
Paul Fultz II
7373be2bfa
Add a pass in valueflow for terminating conditions ( #1323 )
...
* Add valueflow for terminating conditions
* Add valueflow test
* Dont check for same expressions for now to avoid double diagnostics
* Check nesting
* Add more tests
* Ensure conditions happen in order
* Check for null
* Add error path
* Support same expression check as well
* Use early continue
* Skip checking the same token
* Avoid double condtion diagnosis
* Fix FP when in switch statements
* Fix FP when time function
* Skip conditional escapes
* Use simpleMatch
* Fix naming
* Fix typo
2018-11-07 06:49:07 +01:00
IOBYTE
c966f31183
Fixed #8835 (friend class and non-empty constructor: Uninitialized members not reported) ( #1466 )
2018-11-06 06:44:08 +01:00
Daniel Marjamäki
00340efc57
ValueFlow: Refactoring valueFlowCallFunction
2018-11-06 06:38:26 +01:00
IOBYTE
9b67e680ae
Fix template simplifier namespace support. ( #1464 )
2018-11-05 19:55:21 +01:00
Paul Fultz II
d62ed420d8
Add a check target to cmake ( #1465 )
2018-11-05 18:13:04 +01:00
Daniel Marjamäki
ca19894a04
ValueFlow: In evaluate handle correlated values
2018-11-05 18:07:35 +01:00
IOBYTE
2275f05f65
Fixed #8833 (false negative: No 'return' statement in non-void function causes undefined behavior.) ( #1463 )
2018-11-05 06:55:30 +01:00
Daniel Marjamäki
8a54420274
ValueFlow: Try to handle multiple argument values in <returnValue> evaluation
2018-11-04 20:52:12 +01:00
orbitcowboy
1d5e797e6d
testother: Fixed typos in tests. Replaced 'voif' with 'void'.
2018-11-04 14:46:22 +01:00
Daniel Marjamäki
6878de2c5e
ValueFlow: getExpressionRange, valueFlowRightShift
2018-11-03 23:25:46 +01:00
Daniel Marjamäki
f8b0584f6a
replace 'constexpr' with 'const'
2018-11-03 19:22:51 +01:00
Daniel Marjamäki
66ca03fa0c
Fixed #8826 (false negative: Invalid memory address freed)
2018-11-03 18:55:20 +01:00
Daniel Marjamäki
ef35b86b4a
Multipass Valueflow
2018-11-03 15:53:24 +01:00
Daniel Marjamäki
6138294e3d
Fixed #8818 (AST broken: restrict)
2018-11-03 11:05:38 +01:00
Daniel Marjamäki
9741239b2f
Fixed #8824 (False positive: uninitialized variable (regression))
2018-11-03 10:31:55 +01:00
Daniel Marjamäki
a4afcb5995
Revert "Fixed #8818 (AST broken: restrict)"
...
This reverts commit e7d61f399a
.
2018-11-02 21:07:37 +01:00
Daniel Marjamäki
0cc4555337
Revert "Tokenizer: Do not remove 'constexpr'"
...
This reverts commit 2f400b40ba
.
2018-11-02 21:07:24 +01:00
Daniel Marjamäki
2f400b40ba
Tokenizer: Do not remove 'constexpr'
2018-11-02 20:32:12 +01:00
Daniel Marjamäki
e7d61f399a
Fixed #8818 (AST broken: restrict)
2018-11-02 20:28:49 +01:00
Daniel Marjamäki
5de683ec49
Container size: Fix false positive
2018-11-02 20:10:40 +01:00
Daniel Marjamäki
e53be26f48
Try to fix Travis
2018-11-02 19:04:21 +01:00
Daniel Marjamäki
16cc20a232
ValueFlow: Better handling of container size values
2018-11-02 18:28:32 +01:00
Daniel Marjamäki
3798feecad
TemplateSimplifier : Remove 'class|struct' in template arguments
2018-11-02 14:49:40 +01:00
rikardfalkeborn
869e4ba6ab
Add check for return value of boolean function ( #1451 )
...
* Add check for return value of boolean function
The rule for converting an integer to a boolean is that 0 is mapped to
false and everything else is mapped to true. There is nothing wrong with
the following code (according to the standards):
bool f()
{
return -1;
}
and neither gcc nor clang will warn about it. However, it's a bit
confusing. This commit adds a check that warns when a value other than 0
or 1 is returned from a boolean function (similar to the existing check
that functions with boolean arguments are only passed 0 or 1). Since the
code is perfectly legal, set the severity to "Style".
* Use early continue and remove some braces
* Add testcase with multiple returns
* Avoid null pointer dereference in case of return without operand
* Skip lambdas
Add TODO-test cases that shows FPs when the return type of lambdas are
specified explicitly (this is a problem with findLambdaEndToken).
* Enable testcases
2018-11-01 11:08:16 +01:00
rikardfalkeborn
88008fedb1
findLambdaEndToken handle explicit type ( #1458 )
...
* findLambdaEndToken: Add tests
* Add handling of explicit return in findLambdaEndToken()
* Use AST in findLambdaEndToken()
* Fix ast when lambda is mutable
2018-10-31 12:36:08 +01:00
Paul Fultz II
fafd0742d4
Fix FPs with return conditions ( #1455 )
...
* Fix 8815: FP with identical inner conditions
* Fix issue 8801: FP when not returning a bool
* Fix FP
* Add missing semicolon
* Move returnVar
2018-10-31 09:47:48 +01:00
amai
3032ac4619
Fix compile error in test code
2018-10-28 21:36:28 +01:00
Daniel Marjamäki
c03d32b429
ValueFlow: Improve containerSize handling of string like classes
2018-10-28 19:14:00 +01:00
Daniel Marjamäki
8beb42cc90
astyle formatting
...
[ci skip]
2018-10-28 17:37:19 +01:00
Paul Fultz II
2b6cc33dc6
Fix issue 8757: Throw syntax error on invalid code ( #1378 )
...
* Fix issue 8757: Throw syntax error on invalid code
* Fix FP with lambda returns
* Remove double percent
* Check more keywords
* Skip preprocessor directives
* Check for valid PP directive
* Fix preprocessor check
* Dont check for preprocessor directives
2018-10-28 17:17:53 +01:00
Paul Fultz II
f5811c6818
Fix issue 8732: Syntax error when using enable_if ( #1453 )
...
* Fix issue 8732: Syntax error when using enable_if
* Fix FPs
* Use simpleMatch
2018-10-28 17:16:31 +01:00
Daniel Marjamäki
06ede9c239
ValueFlow: handle x+=y for containers
2018-10-27 18:38:04 +02:00
orbitcowboy
b998dcb5aa
gnu.cfg: Added support for '__builtin_memset'.
2018-10-27 18:25:05 +02:00
IOBYTE
adbbadec7f
Fixed #8798 (template simplifier: wrong simpifications for namespaces) ( #1452 )
2018-10-26 14:20:13 +02:00
Daniel Marjamäki
ab08801dc4
Remove header tests from testconstructors, because they were invalid (using preprocessor directive)
...
The checker does not care if it's a header or source file. So I guess these tests were added to test
some parsing problem. Nowadays, #line is removed by simplecpp::preprocess, but there is no proper
testing for it in simplecpp.. I will add some testing for #line asap.
2018-10-26 07:03:15 +02:00
Kamil Dudka
d206047b84
Fixed #8794 - Memory leak false positive triggered by !(x != NULL) ( #1450 )
2018-10-26 06:21:45 +02:00
Daniel Marjamäki
b8e8b12783
Fixed #8797 (exprDependsOnThis handle method call in non-inline method)
2018-10-24 20:17:00 +02:00
Daniel Marjamäki
2348dcde6c
#8801 : Quick fix for false positives
2018-10-24 19:57:50 +02:00
IOBYTE
0763fdbfad
Copy template default argument values from forward declaration to declaration. ( #1447 )
...
It is possible to define default template parameter values in forward
declarations and not define any in the actual declaration. Cppcheck
ignores forward declarations and only uses the default values in the
actual declaration so default values in forward declarations are copied
to the actual declaration when necessary.
2018-10-24 14:38:59 +02:00
Daniel Marjamäki
15160f1691
Fixed #8788 (AST Broken error from assigning lambda to variable)
2018-10-22 17:25:01 +02:00
Daniel Marjamäki
dc38681a56
Remove FIXME in AST validation. Ticket #8749
2018-10-22 11:37:24 +02:00
Daniel Marjamäki
c483bcb12b
Fixed testrunner
2018-10-22 00:28:09 +02:00
Daniel Marjamäki
f9b132e831
Tokenizer::simplifyTypedef: Fix bug with arrays
2018-10-21 21:15:34 +02:00
Paul Fultz II
edde0eedaa
Fix FP issue 8801: Condition 'a+b' is always true ( #1444 )
2018-10-21 08:04:00 +02:00
Paul Fultz II
2989c44f59
Enable checking duplicate expressions across associative operators ( #1445 )
...
* Enable checking duplicate expressions across associative operators
* Remove bitshift operators and check for streamRead
2018-10-21 07:09:20 +02:00
Daniel Marjamäki
14afc3fd3a
Fixed #8796 (Tokenizer::simplifyCompoundAssignment: Wrong simplification of return)
2018-10-20 21:33:43 +02:00
Daniel Marjamäki
29feaa5a51
Tokenizer: Avoid constant folding
2018-10-20 10:51:50 +02:00
Daniel Marjamäki
d265a0d6ab
Fixed #8798 (SymbolDatabase: Inner unnamed union)
2018-10-20 09:43:08 +02:00
orbitcowboy
0858488825
insecureCmdLineArgs: Fixed FN in case strdup() copies argv[]. ( #1438 )
...
* insecureCmdLineArgs: Fixed FN in case strdup() copies argv[].
* Formatted the code. There are no functional changes intended.
* Changes due to review comments from Daniel.
2018-10-19 11:04:15 +02:00
rikardfalkeborn
402d0c565f
Fix false positive: Invalid string argument with array ( #1439 )
2018-10-19 07:48:47 +02:00
Paul Fultz II
40cb9cb1bc
Check conditions in return statements ( #1411 )
...
* Identify return conditions in multiconditions
* Improve error messages
* Check return statements are always true or false
* Add more tests for FPs
* Fix FP when returning const like variables
* Fix FP when returning pointers or classes
* Fix FP with member variable access
* Check non-local variables
* Use simplematch
* Check for null
2018-10-18 21:01:47 +02:00
Daniel Marjamäki
465db2dff7
Fixed #8786 (internalAstError on valid code with C style cast)
2018-10-18 20:17:23 +02:00
Daniel Marjamäki
4983a6a5dc
astyle formatting
2018-10-18 20:08:32 +02:00
Paul Fultz II
16c62281d0
Use followVar in checking duplicateBranch ( #1423 )
...
* Use isSameExpression for duplicate branches
* Add errorPath
* Add another test
2018-10-18 11:56:23 +02:00
Paul Fultz II
58d1de5814
Expand the duplicate variable assignment warnings when the inconclusive flag is used ( #1433 )
...
* Warn for more duplicate var expressions when inconclusive is set
* Fix issue with missing function name
2018-10-17 06:57:33 +02:00
Igor
0a9be3e734
Improve STL iterators checking ( #1380 )
...
* Improve STL interators checking
* Improve error messages for container iterators from different scopes
* Mini refactoring
* Replace hardcoded pattern to ValueType::Type::ITERATOR
* Error messages improvements, more tests and refactoring
* Refactoring after code review
* Put getting operand data into separate function
* Update getErrorMessages and iterator errors ids
* Refactoring
* Fix error
* Refactoring, early return implementation
* Delete redundant code
* Tiny changes in comments
2018-10-17 06:36:51 +02:00
Daniel Marjamäki
1245a036f7
Add check for shadow variables
2018-10-16 20:17:27 +02:00
rikardfalkeborn
f1074ea1ab
Fix false positive: Invalid string argument with pointer to pointer ( #1427 )
...
If the address is taken inside an array, the address is not of a single
character, so do not warn about this.
2018-10-16 06:54:25 +02:00
IOBYTE
290563b964
Fix specialized template regression. ( #1425 )
...
* Fix specialized template regression.
Only check for instantiation of template being processed rather than
count of all instantiations.
* Add 2 more tests.
2018-10-15 19:35:26 +02:00
orbitcowboy
a6e8270474
insecureCmdLineArgs: Fixed false negatives in case arguments are const. ( #1419 )
...
* insecureCmdLineArgs: Fixed false negatives in case arguments are const.
* Formatted the code, there are functional changes.
* Simplified matching as suggested by Daniel.
2018-10-15 10:05:43 +02:00
rikardfalkeborn
613dc19b68
#4241 : Check for address of single character passed as string ( #1381 )
...
* #4241 : Check for address of single character passed as string
Add a check that address of a single character is not passed as argument
to argument marked as strings (using strz). The check does not warn if
the address of a character with known value '\0'.
Since ValueFlow currently does not handle global constants (see #7597 ),
do not warn if the variable is global to avoid FPs when the address of
a global variable assigned to '\0' is passed to a function expecting a
string.
Remove comment in docs saying strz is unused.
* Change asdf to Hello world
* Add test of address to first element in string
* Add error reporting function to getErrorMessages
* Fix strings in test
2018-10-14 18:49:34 +02:00
IOBYTE
0a30768b59
Fixed #8693 (Template specialization: Constructor detected as normal … ( #1418 )
...
* Fixed #8693 (Template specialization: Constructor detected as normal function (functionStatic error))
Refactor template simplifier to remove the existing full specialization
function expandSpecialized and allow full specializations to use the
existing function expandTemplate. The function expandTemplate was
modified to either expand the template like it originally did by copying
it or to modify the template in place. Both instantiated and
uninstantiated full specializations are modified in place. This also
fixes #8692 and probably other related tickets as well.
The function simplifyTemplates now tries twice to simplify templates so
more templates can be simplified. We should try as many times as
necessary to find all possible templates. We can't do that now because
uninstantiated templates are left unchanged. It is relatively straight
forward to have the new code also expand in place uninstantiated
templates with their symbolic types but namespaces are not handled
properly (ticket #8671 ) and it would introduce regressions.
* Fix travis warnings.
2018-10-14 16:57:07 +02:00
Daniel Marjamäki
140b0b5ae9
astyle formatting
...
[ci skip]
2018-10-13 18:42:09 +02:00
Paul Fultz II
9cf092657c
Skip some ast errors to avoid regressions ( #1422 )
...
* Skip some ast errors to avoid regressions
* Use simpleMatch
* Skip operator functions
* Add a test for issue 8788
2018-10-13 18:38:44 +02:00
Daniel Marjamäki
7833ade128
Updated copyright year
2018-10-13 18:20:31 +02:00
Daniel Marjamäki
7eb5ebe17e
Fixed #7887 (User function 'search' is wrongly mixed with std function)
2018-10-10 17:35:53 +02:00
Daniel Marjamäki
c048bd45f6
Refactor test code
2018-10-10 14:35:58 +02:00
Daniel Marjamäki
25cbfe27cf
Partial fix for #7887 , Improved tokenizer simplification of 'using namespace std;' - do not simplify user functions
2018-10-10 14:28:53 +02:00
Daniel Marjamäki
053b0d1654
STL: enable inconclusive warnings with --inconclusive
2018-10-09 20:10:43 +02:00
rikardfalkeborn
75caf8e4de
Fix #8230 : FP unknown evaluation order on comma expression in while clause ( #1415 )
...
The while part of a do-while loop looks almost like a function call, so
extend the check for function calls to ignore while-statements.
Note that there was only an FP when checking c-code, since the check is
disabled for c++-code. Therefore, make sure the test cases are run on a
c-file.
2018-10-09 14:44:01 +02:00
Daniel Marjamäki
20121b34d8
Fixed #7718 (False positive: out of bounds of already resized std::string)
2018-10-09 06:53:26 +02:00
Daniel Marjamäki
aa58f41e6d
Fixed #7152 (False positive for redundantAssignment after calling a lambda function)
2018-10-08 21:07:21 +02:00
PKEuS
86a1b84b0c
Fixed handling of macros with known value defined in header file in configuration splitting ( #8404 )
...
Added proper unit test for configuration validation to ensure that it actually works when cppcheck is executed
2018-10-08 16:38:47 +02:00
Daniel Marjamäki
c3e6e7c338
Fixed #8664 (setVarId: Wrongly set varid for lambda argument)
2018-10-07 20:40:59 +02:00
Daniel Marjamäki
f961324d45
Fixed #8735 (FP oppositeInnerCondition - regression)
2018-10-07 18:30:29 +02:00
orbitcowboy
54c5d09ed3
test:std.cpp: Removed duplicate include <csetjmp>.
2018-10-06 00:23:14 +02:00
Paul Fultz II
e170a45230
Enable followVar for opposite expressions ( #1404 )
...
Enable followVar for opposite expressions
2018-10-04 21:17:47 +02:00
Daniel Marjamäki
a31db92918
Fixed #8669 (operator>> causes wrong style message)
2018-10-03 13:00:11 +02:00
Paul Fultz II
1fe1ec09a8
Reenable follow var for logical conjunction ( #1400 )
2018-10-01 14:40:03 +02:00
Paul Fultz II
2c91b95d2a
Reenable followVar for multicondition ( #1401 )
2018-10-01 14:34:55 +02:00
Paul Fultz II
4598995564
Enable followVar for duplicate ternary expressions ( #1406 )
2018-10-01 14:31:06 +02:00
rikardfalkeborn
b3fef7957a
Fix FP with fclose after comma ( #7525 ) ( #1407 )
2018-10-01 11:58:27 +02:00
Paul Fultz II
4ed22f1ff8
Fix some FPs in mismatchingContainerExpression ( #1402 )
2018-09-30 14:49:58 +02:00
amai
5c0fd0d5b4
Skip some test on cygwin since interface is not available
2018-09-29 16:49:12 +02:00
Paul Fultz II
f65cf220ba
Fix false positives in unknownEvaluationOrder when using followVar ( #1391 )
...
Fix false positives in unknownEvaluationOrder when using followVar
2018-09-28 08:38:24 +02:00
Daniel Marjamäki
9dccc4037b
Fixed #8747 (Syntax error, AST broken (a = --*b))
2018-09-27 19:26:08 +02:00
IOBYTE
33b74a04ab
Add union support to template simplifier. ( #1398 )
2018-09-26 06:23:12 +02:00
orbitcowboy
2bbe73e04a
Fixed compiler warning from VS2017: testsuppressions.cpp(450): warning C4458: declaration of 'errmsg' hides class member. ( #1397 )
2018-09-25 17:19:25 +02:00
orbitcowboy
879803c90f
gnu.cfg: Fixed FP (nullpointer) when third parameter of epoll_ctl is set to NULL.
2018-09-25 09:07:49 +02:00
rikardfalkeborn
5e120b567c
isVariableDeclaration: Handle pointer to const pointer ( #1395 )
...
isVariableDeclaration did not handle pointer to const pointer, or
pointer to volatile pointer. This resulted in FPs in examples like the
following:
class Fred {
public:
const char *const *data;
const char *const *getData() { return data; };
}
where cppcheck would say getData could be static, since it didn't
recognize const char *const *data as a variable declaration.
2018-09-25 06:19:26 +02:00
orbitcowboy
2f032d8fa7
Improved const correctness of local variables. ( #1396 )
...
* Improved const correctness of local variables.
* Running astyle [ci-skip].
* Removed duplicate 'const'-keyword.
2018-09-24 15:08:16 +02:00
Paul Fultz II
5bebeec224
Fix issue 8775: Dont follow aliased variables ( #1390 )
2018-09-24 06:37:47 +02:00
Daniel Marjamäki
afe09f4d7a
Temporarily comment out the followVariable() handling
2018-09-23 16:03:18 +02:00
Simon Martin
6bde2445a6
Ticket #8632 : Parenthesize ternary operator operands containing < to avoid wrongly thinking a template instantiation is met. ( #1389 )
2018-09-23 10:27:38 +02:00
Simon Martin
915acac0b8
Ticket #8734 : Skip static member variables in CheckUninitVar. ( #1388 )
2018-09-22 16:52:34 +02:00
Paul Fultz II
d43cd56afd
Show line number when suggesting std::transform ( #1385 )
2018-09-21 10:38:30 +02:00
orbitcowboy
a26ac4d266
Running astyle. There is no functional change intended.
2018-09-21 08:53:09 +02:00
Paul Fultz II
1e347f6cde
Initial check for recommending algorithms ( #1352 )
...
Add initial check for loop algorithms
2018-09-19 18:58:59 +02:00
shikamu
83cb0b3394
--suppress on line 0 ( #1354 )
...
Fixed --suppress on line 0
2018-09-18 12:58:14 +02:00
IOBYTE
e9a44f70b2
Remove out of line member functions of instantiated template classes. ( #1377 )
...
* Remove out of line member functions of instantiated template classes.
2018-09-14 14:16:34 +02:00
Paul Fultz II
4e7ed9ea6e
More robust checking for crashes in followVar ( #1375 )
...
More robust checking for crashes in followVar
2018-09-13 09:19:15 +02:00
Paul Fultz II
eb07280075
Fix issue 8743: FP when derefencing iterators ( #1376 )
2018-09-12 17:33:53 +02:00
Paul Fultz II
90a29d986b
Fix issue 8730: Dont follow variables with unknown symbols ( #1374 )
2018-09-12 17:30:18 +02:00
orbitcowboy
399a90c00e
#8383 : Segmentation fault on garbage code. Added regression test.
2018-09-10 16:28:32 +02:00
orbitcowboy
95da9f77c4
#8385 : Segmentation fault on garbage code. Added regression test.
2018-09-10 16:24:09 +02:00
orbitcowboy
bc84ce43ec
#8265 : Segmentation fault on garbage code. Added regression test.
2018-09-10 16:17:44 +02:00
amai2012
4b249877f1
#8709 Add stability regression test
2018-09-10 08:40:53 +02:00
Daniel Marjamäki
523a9c1c4a
Fixed #8746 (Syntax error, AST broken (using a::operator=))
2018-09-09 21:11:45 +02:00
Daniel Marjamäki
404eb6c746
Fixed #8745 (Syntax error: AST broken (or))
2018-09-09 16:41:06 +02:00
Daniel Marjamäki
772939476d
Remove inconclusive warnings about reading empty stl container. We have better ValueFlow-based checking.
2018-09-09 11:25:04 +02:00
Daniel Marjamäki
b3f12fcc7e
astyle formatting
...
[ci skip]
2018-09-09 07:10:37 +02:00
Paul Fultz II
f4f3f81e8f
Fix issue 8741: Require pure when following variables in isSameExpression ( #1373 )
2018-09-09 07:08:32 +02:00
Paul Fultz II
fa40b821e6
Fix issue 8740: Add a pass to check for valid operators ( #1372 )
2018-09-08 21:10:34 +02:00
Daniel Marjamäki
509cb35168
astyle formatting
...
[ci skip]
2018-09-08 15:19:32 +02:00
tam do thanh
7ad09b44c3
Ticket 7792: Suppression both exit_code and syntaxError when call cppcheck suppressions ( #1345 )
2018-09-08 11:09:49 +02:00
Daniel Marjamäki
d7de46f50e
ValueFlow: Fix false positive for container size
2018-09-08 10:43:08 +02:00
Daniel Marjamäki
738fb1b23a
Disabled CheckClass::checkCopyCtorAndEqOperator because of FP ( #8388 )
2018-09-08 09:14:02 +02:00
Paul Fultz II
cb03b9883f
Fix issue 8737: FP with identical inner condition due to followVar ( #1371 )
2018-09-07 20:16:38 +02:00
Paul Fultz II
5a2362b2a0
Fix issue 8738: Dont warn about multiconditions when value is known ( #1369 )
2018-09-07 15:02:34 +02:00
Paul Fultz II
f7e7e9bd3c
Fix issue 8736: Iterators to containers from different expressions (a.begin().x == b.begin().x) ( #1370 )
2018-09-07 07:08:02 +02:00
Paul Fultz II
2da958efb5
Fix issue 8722: Avoid duplicate messages due for followVar ( #1367 )
2018-09-06 06:55:36 +02:00
Paul Fultz II
b46e25c18e
Fix issue 8730: False positive: Opposite expression on both sides of && ( #1366 )
2018-09-05 18:07:01 +02:00
Simon Martin
1d85a78874
Ticket #8654 : Properly setup links for variadic template bases. ( #1357 )
2018-09-05 14:10:56 +02:00
Paul Fultz II
08f301a0de
Reenable followVar ( #1363 )
...
Reenable followVar
2018-09-05 05:53:33 +02:00
Daniel Marjamäki
c6d43506b6
ValueFlow: Fix FP in switch
2018-09-04 20:28:48 +02:00
Daniel Marjamäki
3a8bdad20a
Fixed #8232 (segmentation fault on valid C++ code in isOppositeCond())
2018-09-04 18:10:31 +02:00
orbitcowboy
361ae311f6
cmdlineparser: Stop processing in case an invalid path for --includes-file=<PATH> and --config-excludes-file=<PATH> is provided.
2018-09-04 16:37:43 +02:00
Daniel Marjamäki
5afb755a3c
SymbolDatabase: Fix variable matching
2018-09-04 06:39:02 +02:00
Paul Fultz II
93be440f92
Fix issue 8709: crash with switch statement with followVar ( #1362 )
...
* Fix crash with switch statement
* Update comment
2018-09-03 19:54:14 +02:00
Paul Fultz II
0e5fabf4dc
Dont follow volatile variables ( #1365 )
2018-09-03 19:51:48 +02:00
Daniel Marjamäki
756c1d8de7
Fixed #8341 (error:iterators not correct)
2018-09-02 21:04:45 +02:00
IOBYTE
7224ee27d9
Fixed #8122 (simplifyTemplates: constructor outside template class not simplified properly) ( #1361 )
2018-09-02 17:49:13 +02:00
Daniel Marjamäki
cc402869a6
Fixed #8689 (False positive: containerOutOfBounds after function call)
2018-09-02 14:08:34 +02:00
IOBYTE
341dee4a07
Fixed #8725 (Template out of line function return type missing when instantiated.) ( #1360 )
2018-09-02 08:35:05 +02:00
Paul Fultz II
8353f94b93
Fix crashes in followVarExpression ( #1358 )
...
* Fix crashes in followVarExpression
* Add a regression test for issue 8717
* Skip reference declarations
2018-09-02 08:28:53 +02:00
IOBYTE
508e8c234b
Fixed #8683 (Using deleted token with multiple template instantiations.) ( #1353 )
...
* Fixed #8683 (Using deleted token with multiple template instantiations.)
* Fixed #8321 (heap use after free: templatesimplifier)
* Add a flag to Token indicating that it has a pointer to it.
* Run dmake
* Fix one source of list pointers to deleted tokens.
Refactor TemplateSimplifier class to get access to template lists.
Remove many function parameters now that they are class variables.
Fix one source of list pointers to deleted tokens.
Add tests with no output to catch crashes.
* Run dmake again.
* Make 2 more functions private.
* Make requested changes.
* Missed one change request.
* Use TokenList rather than Tokenizer.
* Move TokenAndName constructor to cpp file so token.h is not needed in header file.
2018-09-01 11:26:10 +02:00
Daniel Marjamäki
a331206b44
Temporarily disable followVariableExpressions(), there are problems that should be fixed.
2018-09-01 08:32:06 +02:00
Daniel Marjamäki
f388c77042
Fixed #8721 (Regression: False positive array index out of bounds)
2018-08-31 18:25:43 +02:00
Daniel Marjamäki
7591616f43
Fixed #8710 (Update message duplicateExpression when operand is integer literal)
2018-08-30 18:28:34 +02:00
Daniel Marjamäki
27aae8d032
Fixed #8644 (crash (CheckBufferOverrun::checkGlobalAndLocalVariable): local function)
2018-08-30 10:04:07 +02:00
Daniel Marjamäki
6223204a06
Fixed #8708 (FP: Accessing an item in container that is empty)
2018-08-27 13:49:47 +02:00
Paul Fultz II
fc135e1087
Check if member function modifies the variable ( #1350 )
...
* Check if member function modifies the variable
* Check for const pointer
* Add test for const condition
* Add more null checking
* Add todo assert for FN
2018-08-27 11:09:09 +02:00
Simon Martin
acb0b9f07e
Ticket #8679 : Add support for C++11 thread_local and GCC's (among others) __thread extension. ( #1351 )
2018-08-26 19:46:36 +02:00
Paul Fultz II
a5f4c5d0eb
Improve message for same expressions ( #1349 )
...
* Improve message for same expressions
* Update message
2018-08-25 14:25:31 +02:00
Paul Fultz II
f79849f6ba
Diagnose mismatching iterators used together in operators ( #1343 )
...
* Diagnose mismatching iterators used together in operators
* Fix fp getting iterator expression in function call
2018-08-21 06:34:30 +02:00
Daniel Marjamäki
866d198756
Fixed #8697 (noreturn output stream)
2018-08-21 06:32:33 +02:00
Daniel Marjamäki
4d78a2e178
Fixed #7790 (Wrong order of <location> XML-elements for error duplInheritedMember)
2018-08-19 14:13:58 +02:00
Daniel Marjamäki
43233e72b2
Fixed #8691 (False negative for uselessAssignmentArg)
2018-08-17 19:56:36 +02:00
Kevin Kendzia
c5ebf26f9f
cppcheck.cpp: fix suppression of syntaxError ( #1333 )
...
* cppcheck.cpp: fix suppression of syntaxError
* test: add supression test for syntaxError while file read
2018-08-17 10:05:25 +02:00
Sylvain Joubert
13617375df
missingOverride: False positive with cv-ref mismatch ( #1340 )
2018-08-17 08:42:22 +02:00
Sebastian
78715d3eff
bsd.cfg: Add arc4random* functions with tests. ( #1344 )
...
Reference: https://www.freebsd.org/cgi/man.cgi?query=arc4random
2018-08-16 21:37:40 +02:00
tam do thanh
f33c09f1a7
Allow syntax "typedef 'typename' unsigned 'typename' (functon_name)()" ( #1334 )
...
* Allow syntax "typedef 'typename' unsigned 'typename' (functon_name)()" for some old libraries
https://trac.cppcheck.net/ticket/7792
* Unnecessary check of "tokOffset", match-function already checks if it is null
* add testcase ticket #7792 : simplifyTypedef124
2018-08-16 14:30:28 +02:00
Daniel Marjamäki
fc97a5b11c
Uninitalized variables: Fixed false positive
2018-08-15 18:04:36 +02:00
Daniel Marjamäki
2f834c3c3b
Fixed #8688 (False positive: containerOutOfBounds)
2018-08-13 21:27:29 +02:00
Paul Fultz II
c5154286da
Fix issue 8687: false positive with same expression ( #1336 )
2018-08-13 12:55:41 +02:00
Daniel Marjamäki
55ab842083
valueFlowSizeForward: Bailout when function calls modify the container size
2018-08-13 06:54:18 +02:00
Daniel Marjamäki
183345a939
valueFlowContainerSize: Fix FP when container size is changed
2018-08-12 22:23:19 +02:00
Daniel Marjamäki
7074eeb869
valueFlowContainerSize: assignment of string-like containers
2018-08-12 22:01:58 +02:00
Daniel Marjamäki
189ea5003a
valueFlowContainerSize: empty container variables
2018-08-12 14:41:00 +02:00
Daniel Marjamäki
be4ae66e36
Fix wrong message
2018-08-12 08:01:15 +02:00
Daniel Marjamäki
0e30bdef9d
containerAccessOutOfBounds: Fix FPs for maps etc
2018-08-11 18:57:21 +02:00
Daniel Marjamäki
811a71aa06
valueFlowContainerSize: Handle guard logic
2018-08-11 15:08:54 +02:00
Daniel Marjamäki
6008bbdfb4
valueFlowContainerSize: Fix wrong value after condition if conditional code escapes
2018-08-11 13:49:42 +02:00
Daniel Marjamäki
1f427eda8f
CheckStl: rewrite and refactor out of bounds checker
2018-08-11 11:40:48 +02:00
Daniel Marjamäki
10461e5429
valueFlowContainerSize: forward analysis inside conditional code
2018-08-10 22:18:38 +02:00
Daniel Marjamäki
4a502a7f6b
valueFlowContainerSize: add simple forward analysis
2018-08-10 22:06:23 +02:00
Daniel Marjamäki
2b10e38eec
valueFlowContainerSize: handling of 'v.size() == 10'
2018-08-10 21:43:47 +02:00
Paul Fultz II
3947c23290
Fix issue 8369: False negative: Condition 'condition' is always true ( #1325 )
...
* Fix issue 8369: False negative: Condition 'condition' is always true
* Use simpleMatch
* Add iterator header
* Cleanup
* Remove unused variable
2018-08-10 18:05:23 +02:00
Daniel Marjamäki
907f81d059
ValueFlow: Improved analysis of container size
2018-08-10 11:53:56 +02:00
Daniel Marjamäki
81f54f7094
Fixed #8681 (ValueFlow: Container size)
2018-08-10 11:29:16 +02:00
Daniel Marjamäki
f2e7071922
Fix FP, conversion of char literal '\0' to boolean is not true
2018-08-08 19:04:10 +02:00
Daniel Marjamäki
1f1c44a04f
Fixed #8677 (False positive: unused method)
2018-08-08 11:31:35 +02:00
Paul Fultz II
80290a15e0
Fix FP with duplicate assign ( #1330 )
2018-08-08 08:31:31 +02:00
Daniel Marjamäki
c3a44ce56b
astyle formatting
...
[ci skip]
2018-08-07 18:06:51 +02:00
Daniel Marjamäki
78df7f98dd
Fixed #8674 (False positive: Method that returns const should not be const)
2018-08-07 18:06:14 +02:00
Paul Fultz II
f603b529df
Fix issue 8413: Condition is always false 'i=expr; if (i != expr) {}' ( #1295 )
...
* Follow variables when comparing same expression
* Remove assert include
* Dont follow function arguments
* Improve the checking to check more cases
* Add more tests
* Check if the variable is used inside a loop
* Follow both variables
* Only skip loops when variable is modified in scope
* Fix FP when followed variable is modified
* Dont follow arrays
* Skip pointer indirection
* Make recursive
* Improve checking more variables
* Fix test with sizeof
* Skip following operators
* Fix test when using sizeof
* Dont check every step
* Use early returns
* Update test to use a loop instead of conditional
* Add static
* Check variables are global
* Check local variables in another scope
* Fix issue with const pointers
* Distinguish between pointer indirection and multiply
* Use simple match
* Prevent crash with uniform initialization
* Use unary op and ast to detect pointer indirection
* Expand error message when expression do not match exactly
* Add errorpath to issameexpression
* Revert "Clarify warning message for 'Same expression on both sides of operator'"
This reverts commit 0e491b41a8
.
* Check if the tokens are the same
* Report the operator and not the expressions
2018-08-07 09:32:16 +02:00
Daniel Marjamäki
1b933f4dd1
astyle formatting
...
[ci skip]
2018-08-05 22:40:21 +02:00
Paul Fultz II
b839ad60dd
Fix issue 6856: add checks in isOppositeCond when using == and < or > ( #1298 )
...
* Fix issue 6856: add checks in isOppositeCond when using == and < or >
* Move tests to testcondition
* Fix some more tests
* Fix test messages
* Remove the float check
2018-08-05 22:39:40 +02:00
Daniel Marjamäki
d8997bb43f
Fix testrunner
2018-08-05 14:01:24 +02:00
Daniel Marjamäki
0e491b41a8
Clarify warning message for 'Same expression on both sides of operator'
2018-08-05 10:48:02 +02:00
Paul Fultz II
ed197f235a
Fix issue 4693: Diagnostic when using the same iterators to an algorithm ( #1326 )
...
* Fix issue 4693: Diagnostic when using the same iterators to an algorithm
* Update classinfo
2018-08-05 09:10:54 +02:00
rikardfalkeborn
710d7ce015
Add checks of log2 and log1p range ( #1324 )
...
* Add tests for log10{,f,l} valid arguments
* Add log2{,f,l} to checkfunctions
* Add log1p{,f,l} to checkfunctions
* checkfunctions: Simplify check for log function limit out of range
The conditions for negative and non-negative int and float were
identical so the call to isNegative can be removed and the if-statements
be simplified.
2018-08-03 12:14:39 +02:00
Paul Fultz II
0d35a96594
Improve checking of mismatch iterators ( #1293 )
2018-07-26 22:00:48 +02:00
Daniel Marjamäki
54e2726bf3
Fixed #8636 (Misleading verbose message if virtual method called from destructor)
2018-07-26 09:16:17 +02:00
Daniel Marjamäki
fc5d8e5082
TestSuite: Allow that verbose messages are reported in a test
2018-07-26 09:15:33 +02:00
Daniel Marjamäki
c666f74755
astyle formatting
...
[ci skip]
2018-07-25 23:02:16 +02:00
Paul Fultz II
f093692551
ValueFlow: Set values in else branch even when the first branch modifies the value ( #1309 )
...
* Set values in else branch even when the first branch modifies the value
* Move tests
* Add check for goto
* Remvoe todo
* Also check scope is noreturn
* Use isEscapeScope when variables are changed
2018-07-25 22:59:54 +02:00
Daniel Marjamäki
f9a5a114bb
astyle formatting
...
[ci skip]
2018-07-25 07:44:06 +02:00
Paul Fultz II
9895ea5ff2
Fix issue 470: Condition is always true or false on logical operators ( #1294 )
...
* Fix issue 470: Condition is always true or false on logical operators
* Dont warn on literals
* Compute logical operators using valueflow
* Fix FP when using literals
* Always warn on subconditions that are always true
* Use percent matches first
* Add test for logical operators
* Check if parent is null
2018-07-23 08:51:59 +02:00
lordylike
12e58c8521
fix ticket 8570: passedByValue with member initializer list and std::move ( #1316 )
...
* fix ticket 8570
allow member initializer list variables that are moved to be non-const
* review feedback
* replace tabs with spaces in test code
2018-07-22 15:01:18 +02:00
Daniel Marjamäki
77b653bf94
Clarify warnings when char literals are converted to bool in conditions
2018-07-21 18:40:06 +02:00
Sebastian
f862cf603f
posix.cfg: Add some pthread_mutex_* functions. ( #1320 )
...
References:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_init.html
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_lock.html
2018-07-21 17:52:12 +02:00
rikardfalkeborn
30a8d953e3
Move sqrt{,f,l} argument checks to cfg file ( #1313 )
2018-07-20 20:56:39 +02:00
Sebastian
4ef452132c
posix.cfg,gnu.cfg: Add (get|set)hostname functions. ( #1315 )
...
Reference for POSIX gethostname:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/gethostname.html
Reference for sethostname:
http://man7.org/linux/man-pages/man2/gethostname.2.html
2018-07-18 09:40:06 +02:00
Daniel Marjamäki
7c4820e047
Rename Library::isargvalid()
2018-07-15 23:05:48 +02:00
rikardfalkeborn
491ee577c6
Support floats in valid config ( #1297 )
...
* Add tests for invalid ranges
* Refactor loadLibErrors
This reduces the amount of code slightly and will simplify adding
more tests.
* Handle empty valid field
Before this change, the sequence <valid></valid> in a config file would
result in a segmentation fault. Now an empty field results in the error
message:
cppcheck: Failed to load library configuration file 'mycfg.cfg'. Bad attribute value '""'
* Add support for valid for floating point arguments
Previously, it was not possible to add valid ranges to floating point
arguments since it only handled integers. This made ranges not work well
for floating point arguments since arguments were cast to integers
before the ranges were handled.
Fix this by using doubles instead of integers if the argument is a float.
Add some tests for this and make sure errors are printed with enough
precision (somewhat arbitrarily chosen).
Note that it is still only possible to add integer ranges (i.e. -1:1).
* Add support for floats in configuration valid range
Now that it is possible to handle decimal arguments, there is no reason
to not allow non-integer ranges. Take care to not allow broken
configurations.
* Move check to within if-clause
* Move asin{,f,l} and acos{,f,l} input checks to config file
2018-07-15 22:47:56 +02:00
rikardfalkeborn
0e639ea7c9
runtest.sh: Bugfix cfg dir when run in test/cfg ( #1311 )
...
Commit 5cc8da2db4
introduced syntax checking of xml-files. This broke
running the file directly in the test/cfg folder since it assumed the
config files to check were located in cfg in the current working
directory. Fix this by adding a variable that holds the correct path.
2018-07-15 22:24:31 +02:00
Paul Fultz II
5d1fdf7958
Fix issue 7904: Handle double nots in isSameExpression ( #1305 )
...
* Fix issue 7904: Handle double nots in isSameExpression
* Skip checking double nots in assignments
* Use ast to check for double not
2018-07-15 11:30:02 +02:00
Paul Fultz II
42f075c3fa
Skip literals for always true/false ( #1304 )
2018-07-12 23:06:47 +02:00
Sebastian
5cc8da2db4
cfg/runtests.sh: Check syntax of defines in configuration files. ( #1303 )
...
travis: Add xmlstarlet package used by cfg/runtests.sh
2018-07-12 08:40:26 +02:00
Daniel Marjamäki
b398398dec
Fixed #8360 (false positive "Ineffective call of function 'empty()'")
2018-07-10 22:58:02 +02:00
Daniel Marjamäki
7e2858f158
astyle formatting
...
[ci skip]
2018-07-10 22:56:18 +02:00
Daniel Marjamäki
03faa25d12
Conditions: Better handling of function calls
2018-07-08 15:58:04 +02:00
amai2012
c2f0828a61
#6645 false negative: condition is always false. Add a regression test
2018-07-03 08:25:37 +02:00
Daniel Marjamäki
24dd4c9c26
Restore code in checkVariableScope. Fixes false negative
2018-07-01 22:31:45 +02:00
Daniel Marjamäki
60ac463a79
CheckClass: Restore a few warnings about member initialization of classes
2018-06-29 22:54:12 +02:00
Alexander Mai
320a957bbc
Extend TestSymbolDatabase::findFunction19 to outline different results depending whether char is signed or unsigned on compile time
2018-06-28 22:16:18 +02:00
Daniel Marjamäki
61c56eda44
Tweak the CheckClass::constructors() check
2018-06-27 14:02:57 +02:00
Daniel Marjamäki
10e693a8c3
Revert "SymbolDatabase: Improved lookup of function calls"
...
This reverts commit 3c87d60d5d
.
2018-06-26 23:14:12 +02:00
Daniel Marjamäki
3c87d60d5d
SymbolDatabase: Improved lookup of function calls
2018-06-26 22:12:12 +02:00
Daniel Marjamäki
c583fb9186
Revert "SymbolDatabase: Improved lookup of function calls"
...
This reverts commit e4a70f87e6
.
2018-06-26 13:05:33 +02:00
Daniel Marjamäki
e4a70f87e6
SymbolDatabase: Improved lookup of function calls
2018-06-26 11:38:45 +02:00
Daniel Marjamäki
33493883b2
TestSymbolDatabase: Remove unused variable
2018-06-24 17:13:27 +02:00
Daniel Marjamäki
ea6a9c965d
TestSymbolDatabase: Code cleanup
2018-06-24 17:06:51 +02:00
Daniel Marjamäki
cde63c7573
Use Variable::valueType instead of Variable::typeStartToken in auto variables
2018-06-24 08:25:19 +02:00
Daniel Marjamäki
655a8b21b6
Fix false positive 'passedByValue' when address of argument is used
2018-06-23 23:25:06 +02:00
Daniel Marjamäki
2a8296879c
CheckOther: Use Variable::valueType() instead of Variable::typeStartToken
2018-06-23 16:42:36 +02:00
Daniel Marjamäki
d0614b9b36
varScope: Fix false negatives for references
2018-06-22 22:51:03 +02:00
Daniel Marjamäki
10fc070f44
SymbolDatabase: Better handling of type aliases in ValueType
2018-06-20 14:49:55 +02:00
Daniel Marjamäki
b4cb2505c3
SymbolDatabase: Add Variable::valueType(). First step to reuse ValueType handling in Variable
2018-06-20 10:00:15 +02:00
Daniel Marjamäki
610b26bfbc
Rename private member _platform_types
2018-06-17 16:58:28 +02:00
Daniel Marjamäki
074177fc6e
Rename private member variables
2018-06-17 16:55:02 +02:00
Daniel Marjamäki
e08859e329
Fix testrunner compiling
2018-06-16 22:28:14 +02:00
Daniel Marjamäki
76280fe847
Fix testrunner
2018-06-16 21:36:30 +02:00
Daniel Marjamäki
593f7eee38
Fixed #8624 (Crash below CheckOther::checkDuplicateExpression)
2018-06-14 22:39:26 +02:00
Daniel Marjamäki
45379a3aa6
Updated copyright year for modified files
...
[ci skip]
2018-06-10 22:07:21 +02:00
Paul Fultz II
daacf27c2e
Fix false positive from issue 8612 ( #1285 )
2018-06-10 00:05:23 +02:00
Daniel Marjamäki
03b2e0eee7
inline suppressions: treat arithmetic operators as start-of-comment
2018-06-09 22:50:51 +02:00
Paul Fultz II
8d53bcfd63
Fix FP when using non-const members and also check return type of function ( #1283 )
2018-06-09 08:05:19 +02:00
orbitcowboy
d10788164a
windows.cfg: Added support for _locale_t
2018-06-08 14:41:56 +02:00
orbitcowboy
c56033f998
test/windows.cfg: Fixed wrong test case.
2018-06-08 14:33:37 +02:00
Daniel Marjamäki
84f0a18053
passedByReference: avoid false positives for std::pair
2018-06-08 10:19:02 +02:00
Daniel Marjamäki
44c78d1770
passedByReference: avoid false positives for std::function
2018-06-08 08:40:14 +02:00
Daniel Marjamäki
de09c117bf
Fixed #8618 (False positive: shared_ptr is passed by reference by intention)
2018-06-07 22:39:21 +02:00
Daniel Marjamäki
1abc9008d8
Fixed #8573 (FP noCopyConstructor - derive from noncopyable class)
2018-06-06 16:02:25 +02:00
Daniel Marjamäki
b9c1308a81
Fixed #8575 (false positive: longCastAssign)
2018-06-04 22:51:21 +02:00
orbitcowboy
74b18d7fd9
windows.cfg: Added support for _strncpy_s_l().
2018-06-04 16:58:09 +02:00
Daniel Marjamäki
7b106c067a
Fixed #8603 (SymbolDatabase: 2 scopes with same function)
2018-06-03 23:14:24 +02:00
orbitcowboy
55ff7c0823
test std.cfg: Updated tests for strncpy_s().
2018-05-31 11:23:54 +02:00
Daniel Marjamäki
ccbfd623d5
astyle formatting
...
[ci skip]
2018-05-31 07:02:08 +02:00
amai2012
8d55d361ae
#8602 Template default parameter without name yields syntax error
2018-05-30 17:09:31 +02:00
orbitcowboy
c7993c38b5
bsd.cfg: Added support for strlcat().
2018-05-30 16:47:00 +02:00
orbitcowboy
d412c3908f
test std.cfg: Fixed introduced regression.
2018-05-30 16:30:00 +02:00
orbitcowboy
39feb150c0
std.cfg and windows.cfg: Added support for wcscat_s() and _tcscat_s().
2018-05-30 16:25:09 +02:00
orbitcowboy
ef82477d11
std.cfg: Do not take the return value of std::locale::global() into account.
2018-05-30 16:04:40 +02:00
IOBYTE
7681bbf227
Fixed #8146 (false positive: enum initialized using class member initializer syntax in struct in struct) ( #1270 )
2018-05-30 15:40:16 +02:00
orbitcowboy
d06eb3eb8f
std.cfg: Added support for strcat_s() (since C11).
2018-05-30 14:30:26 +02:00
IOBYTE
3982c81394
Add support for C++ attribute nodiscard for functions. ( #1269 )
2018-05-29 21:43:56 +02:00
Daniel Marjamäki
7d4a80fbd2
astyle formatting
...
[ci skip]
2018-05-29 16:30:33 +02:00
orbitcowboy
976e9e2544
Cleared -Wshadow warnings.
2018-05-29 11:54:07 +02:00
orbitcowboy
53c53db312
windows.cfg: Added support for _mbscat_s().
2018-05-28 21:52:44 +02:00
orbitcowboy
75e28e46c5
windows.cfg: Added support for _mbscat().
2018-05-28 10:08:11 +02:00
IOBYTE
36f7585798
Fixed #8600 (false-positive/regression: confusion between copy constructors of internal classes and lack of explicit keyword) ( #1266 )
2018-05-27 10:53:34 +02:00
orbitcowboy
5b6e6db376
test std.cfg: Added more test cases for strcat() functions.
2018-05-27 10:16:02 +02:00
orbitcowboy
3407f3e932
windows.cfg: Added test cases for CreateThread().
2018-05-25 11:50:12 +02:00
orbitcowboy
d7c8c46c10
test std.cfg: Improved testing for strcat() and wcscat().
2018-05-25 08:36:47 +02:00
rebnridgway
42a65c5160
Fix crash bug #8579 ( #1238 )
...
* Added declaration for deletePrevious function
* Added definition for deletePrevious function
* Fixed crash from deleteThis invalidating pointers
The crash was caused by deleteThis() invalidating the pointer to a constant variable usage. This happened when a usage followed an assignment. This fixes bug #8579 .
* Added tokensFront to match tokensBack
This means deletePrevious can set the list's front if necessary.
* Initialised tokensFront in appropriate places
* Switched to using default Token constructor
* Switched to using Token default constructor
* Switched to using default constructor for Token
* Added missing argument to Token constructor
* Changed to use default constructor for Tokens
* Switched to using default constructor for Tokens
* Switched to using default constructor for Token
* Added new test for deleting front Token
Also made sure to use the correct constructor for Token in other tests.
* Syntax error
* Replaced tokensFront and tokensBack with a struct
This decreases the size of the Token class for performance purposes.
* Replaced tokensFront and tokensBack with a struct
* Added tokensFrontBack to destructor
* Reworked to use TokensBackFront struct
Also ran astyle.
* Reworked to use TokenList's TokensFrontBack member
* Reworked to use TokensFrontBack struct
* Reworked to use TokensFrontBack struct
* Reworked to work with TokensFrontBack struct
* Removed unnecessary scope operator
* Added missing parentheses
* Fixed syntax error
* Removed unnecessary constructor
* Default constructor now 0-initialises everything
This is safer for not using a temporary TokensFrontBack object, and doesn't use delegating constructors which aren't supported yet.
* Fixed unsafe null check
* Added missing explicit keyword
* Fixing stylistic nits
Removed default constructor as it has been superseded by the single-argument constructor with a default argument value.
Renamed listEnds to tokensFrontBack.
Fixed if statement that was supposed to be adding safety but would actually cause a crash if tokensFrontBack was null.
* Fixing stylistic nits
Removed default constructor and replaced it with a single-argument constructor with a default value.
* Fixing stylistic nits
Renamed _listEnds to _tokensFrontBack.
* Fixing stylistic nits
Renamed _listEnds to _tokensFrontBack.
2018-05-25 07:15:05 +02:00
Sebastian
8b94bfaf0a
windows.cfg: Add macros SUCCEEDED() and FAILED(). ( #1264 )
...
Somehow the opposite inner condition is not detected when macros are used. I created this ticket: https://trac.cppcheck.net/ticket/8596
2018-05-24 14:52:32 +02:00
orbitcowboy
3311307227
windows.cfg: Added test cases for toupper/tolower functions.
2018-05-24 10:05:56 +02:00
IOBYTE
fc1d62fd45
Fixed #7406 (Tokenizer::simplifyTypedef: array typedef used as template parameter) ( #1257 )
2018-05-22 17:31:58 +02:00
umanamente
a3b02d6ece
Fixed #8262 : false positive memleak (`shared_ptr` in function argument) ( #1249 )
...
* Fixed #8262 .
checkleakautovar.cpp:
* added `isFunctionCall` (supports template functions)
* smart pointer check in `functionCall`
* updated test case
* Renamed "bracket" to "parenthesis"
* (#8262 ) Fixed broken test
* (#8262 ) Code review comments
* (#8262 ) Renamed `tokOpeningBr` to `tokOpeningPar`
2018-05-22 09:08:23 +02:00
IOBYTE
8320be203d
Fixed #8258 (Incorrect diagnostics when using delegating consturctor with default values) ( #1255 )
2018-05-22 06:42:37 +02:00
IOBYTE
5c15cd3981
Fix DACA2 SymbolDatabase bailout; unhandled code for final class ( #1253 )
...
* Fix DACA2 SymbolDatabase bailout; unhandled code for final class
* Replace Match with simpleMatch
2018-05-21 21:23:21 +02:00
Paul Fultz II
406aa6cf1c
Improve support of using a lambda as a deleter ( #1246 )
...
* Improve support of using a lambda as a deleter
* Use simple match
2018-05-21 08:22:18 +02:00
IOBYTE
42ed5a6b98
Fixed #8581 (Delegating contructor warns for unintialized variables) ( #1250 )
...
* Fixed #8581 (Delegating contructor warns for unintialized variables)
* Replace Token::Match with isStandardType
2018-05-20 22:58:05 +02:00
Sebastian
aa3722feea
windows.cfg: Add lstrlen() configuration and tests. ( #1239 )
...
Reference: https://msdn.microsoft.com/en-us/library/windows/desktop/ms647492(v=vs.85).aspx
2018-05-17 15:43:01 +02:00
orbitcowboy
3ad8fa5288
windows.cfg: Improved support for more types.
2018-05-16 16:26:40 +02:00
IOBYTE
d567b878ba
Fix template instantialion failure for qualified template type. ( #1237 )
2018-05-16 15:24:23 +02:00
orbitcowboy
4e38627a3d
windows.cfg: Improved support for Windows types (ref. https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx ).
2018-05-16 09:16:12 +02:00
Daniel Marjamäki
21ab5c7591
Removed the generated cfg tests, these are not used.
2018-05-16 07:09:08 +02:00
IOBYTE
ce50df8047
Fix override warnings. ( #1234 )
2018-05-15 16:37:40 +02:00
Daniel Marjamäki
6bd4bdb0f9
Updated 'noValidConfiguration' message. It should not write this message when there is no code. It should be possible to see the preprocessor errors otherwise it is hard to fix the configuration.
2018-05-15 15:42:54 +02:00
Daniel Marjamäki
f7746e4fb6
Revert "Missing override specifier warning on a pure virtual function makes no sense. ( #1230 )"
...
This reverts commit 348eb1c5c9
.
2018-05-15 10:48:34 +02:00
orbitcowboy
d0089fe305
windows.cfg: Added missing PFLOAT definition.
2018-05-15 09:43:28 +02:00
IOBYTE
348eb1c5c9
Missing override specifier warning on a pure virtual function makes no sense. ( #1230 )
...
This fixes a large number of false positives for cppcheck source code.
2018-05-14 23:08:40 +02:00
Daniel Marjamäki
66599b4ade
astyle formatting
...
[ci skip]
2018-05-14 22:48:37 +02:00
umanamente
d2d1bf900b
( #8262 ) Added TODO test for "False positive: memory leak with shared_ptr stored in container" ( #1228 )
2018-05-14 13:08:33 +02:00
PKEuS
090a178ed6
Refactorization in SymbolDatabase: Do not redundantly store name in FriendInfo, and store FriendInfo in vector instead of list
2018-05-14 12:18:59 +02:00
PKEuS
4d549553b0
Small optimization in checkmemoryleak.cpp: Allow passing literals to addtoken()
...
Ran AStyle
2018-05-14 10:15:50 +02:00
Paul Fultz II
7ef714b0c6
Fix FP with duplicate assignments by checking if the expression is unique ( #1223 )
...
* Fix FP with duplicate assignments by checking if the expression is unique
* Use array of pointers
* Reorder scope condition
2018-05-13 20:20:55 +02:00
IOBYTE
5c06d08bfb
Fix many DACA2 SymbolDatabase bailout; unhandled code false positives ( #1225 )
2018-05-13 19:00:42 +02:00
IOBYTE
9ee6068e20
Remove duplicate namespace aliases so they don't produce syntax errors. ( #1222 )
...
* Remove duplicate namespace aliases so they don't produce syntax errors.
DACA2 results showed new SymbolDatabase syntax errors when duplicate
namespace aliases were simplified improperly. The solution is to remove
them in the tokenizer when found.
* Add tests for deleting namespace aliases at end of token list.
* Use eraseTokens to delete multiple tokens at once.
2018-05-13 08:29:40 +02:00
Simon Martin
16e1e1d8f9
Ticket #8550 : Properly simplify "typedef class A B;". ( #1224 )
2018-05-12 10:20:33 +02:00
Daniel Marjamäki
98e3f373e9
Revert "Optimize usage of TemplateSimplifier::simplifyCalculations"
...
This reverts commit 3044612fe9
.
I got a report about a significant slowdown for a code.
2018-05-11 21:26:28 +02:00
Daniel Marjamäki
3044612fe9
Optimize usage of TemplateSimplifier::simplifyCalculations
2018-05-11 14:48:59 +02:00
Paul Fultz II
c520735009
Improve checking of size condition against empty to avoid FPs ( #1213 )
...
* Improve checking of size condition against empty to avoid FPs
* Add const and todo for reverse conditions
2018-05-11 10:22:06 +02:00
Daniel Marjamäki
1e7c1841f7
Fixed #8515 (Wrong info message about unmatched suppression)
2018-05-11 09:01:24 +02:00
IOBYTE
9d30496ea1
Extend symbol database test for const volatile member function. ( #1220 )
2018-05-11 08:15:46 +02:00
IOBYTE
184537884f
Don't remove the volatile keyword so we can properly overload functions. ( #1218 )
...
* Don't remove the volatile keyword so we can properly overload functions.
I fixed all the checks that had tests that use volatile. There will
probably be more changes needed due to lack of test coverage for
volatile in some checks.
* Fix unused private function warning.
2018-05-10 07:40:01 +02:00
IOBYTE
5452c4dc4a
Fixed #8560 (Symboldatabase lacks entry for C++11 overloaded member function) ( #1217 )
2018-05-09 20:16:08 +02:00
Sebastian
50aa3620da
posix.cfg: Add minsize to readlink[at] function configurations ( #1216 )
2018-05-09 18:20:45 +02:00
Paul Fultz II
0197343e0c
Fix false positive when using null arithmetic with class type ( #1214 )
2018-05-09 09:06:49 +02:00
Paul Fultz II
f5dbfce8ff
Fix false positive with oppositeExpression when using binary op ( #1211 )
...
* Fix false positive with oppositeExpression when using binary op
* Simplify conditional
2018-05-08 20:43:57 +02:00
IOBYTE
8b0b659965
Add support for namespace aliases and C++17 nested namespaces. ( #1210 )
...
* Add support for namespace aliases and C++17 nested namespaces.
These are implemented as tokenizer simplifications so changes are not
needed to the tokenizer and symbol database.
* Fix codacy warning.
2018-05-08 06:35:51 +02:00
Daniel Marjamäki
8c2a5c9813
astyle formatting
...
[ci skip]
2018-05-06 09:50:53 +02:00
Paul Fultz II
0561877182
Fix false positive with negative array index in issue 8536 ( #1202 )
...
* Fix FP with negative array index in valueflow
* Remove values when valueflow fails
* Add valueflow test
2018-05-06 08:35:29 +02:00
Paul Fultz II
067d82f0ea
Check for smart pointer release ( #1206 )
2018-05-05 18:06:49 +02:00
Daniel Marjamäki
4408628107
Fixed #8538 (SymbolDatabase: wrong parsing of noexcept)
2018-05-05 08:31:56 +02:00
Daniel Marjamäki
64b85b474c
Fixed #8542 (False positive: noOperatorEq)
2018-05-05 07:46:58 +02:00
Daniel Marjamäki
7fb28b05f6
Check Class: Try to clarify the warnings for noCopyConstructor/noOperatorEq/noDestructor.
2018-05-04 15:39:23 +02:00
Daniel Marjamäki
99003c2084
CheckClass: Better handling of defaulted and deleted functions in the noCopyConstructor/noOperatorEq/noDestructor
2018-05-04 14:58:38 +02:00
Paul Fultz II
cac68c6b81
Fix FP when using - as a binary operator ( #1201 )
2018-05-04 07:58:30 +02:00
IOBYTE
f94e9c5447
Fix #8540 (Syntax error involving forward-declared 'enum class') ( #1203 )
2018-05-04 07:56:20 +02:00
Daniel Marjamäki
59cc479855
Save bitfield bit counts
2018-05-02 20:55:11 +02:00
Daniel Marjamäki
7dfbe7389b
Clarify null pointer arithmetic message
2018-05-02 12:57:24 +02:00
Paul Fultz II
f191a3e753
Improve checking of opposite expressions ( #1199 )
...
* Improve checking of opposite expressions
* Fix some formatting
2018-05-02 06:32:33 +02:00
Daniel Marjamäki
b2343a2d4b
Fixed #8518 (Clarify warning for a NULL pointer which is received by a function call parameter.)
2018-05-01 17:30:29 +02:00
Daniel Marjamäki
31148fdfed
Fixed #8523 (Clarify warning: noConstructor)
2018-05-01 15:50:03 +02:00
Daniel Marjamäki
40b6f6b3dd
CheckClass: Fix the noDestructor warning
2018-05-01 15:31:13 +02:00
Daniel Marjamäki
9710e819be
CheckClass: Disable noDestructor for now, we need to handle new better
2018-05-01 09:26:03 +02:00
Daniel Marjamäki
42100fdf11
CheckClass: Better handling of non-copyable classes in the noCopyConstructor check
2018-05-01 08:33:23 +02:00
Sebastian
b370861bed
test/cfg/std.c: Cleaning up function names and redundant tests ( #1198 )
...
Make the names of uninitvar_* functions consistent and fix typos.
Remove completely redundant functions/tests. Combine according tests if
they are not completely redundant.
2018-05-01 07:33:43 +02:00
IOBYTE
c3c1abd05e
SymbolDatabase: improve checking of uninstantiated templates ( #1196 )
...
* SymbolDatabase: improve checking of uninstantiated templates
* Add bailout and debug warning for '>' token without a link in SymbolDatabase::findFunction()..
Don't crash on bad code simplification from tokenizer.
2018-05-01 07:32:19 +02:00
Daniel Marjamäki
73b41455dd
CheckClass: If class has memory management it should have copy constructor, operator= and destructor
2018-04-30 23:13:33 +02:00
Daniel Marjamäki
7015fb097e
SymbolDatabase::isFunction: better handling of return types
2018-04-29 15:35:31 +02:00
Paul Fultz II
e571e598b6
Fix false positive with inner conditions when using pointers ( #1195 )
2018-04-28 18:56:13 +02:00
Daniel Marjamäki
ca8e19c96d
SymbolDatabase: Refactor SymbolDatabase: variable list
2018-04-28 09:38:33 +02:00
Sebastian
6208ee4af1
std.cfg: Add asctime_s function configuration with tests ( #1191 )
...
* std.cfg: Add asctime_s function configuration with tests
* std.cfg: Remove redundant/not needed not-bool attributes.
2018-04-27 23:51:16 +02:00
Daniel Marjamäki
1a9e8c158d
CheckClass::copyconstructors: Use library to determine if function is a allocation function
2018-04-27 23:20:04 +02:00
Daniel Marjamäki
f336c2efe7
Refactoring; Renamed Scope::classStart and Scope::classEnd
2018-04-27 22:36:30 +02:00
Daniel Marjamäki
e6a37ec0b7
Fixed #8531 (false positive: (style) The function 'foo' overrides a function in a base class but is not marked with a 'override' specifier.)
2018-04-27 21:49:18 +02:00
Daniel Marjamäki
25599a76a7
Handle 'final' specifier better.
2018-04-27 14:57:43 +02:00
Daniel Marjamäki
b830f462e6
Added missingOverride checker; Function 'f' overrides function in base class but does not have the 'override' keyword.
2018-04-27 11:12:09 +02:00
Daniel Marjamäki
8304290f06
astyle formatting
...
[ci skip]
2018-04-27 10:29:27 +02:00
Daniel Marjamäki
d15b945c9e
SymbolDatabase::isFunction: Fix wrong detection function
2018-04-27 10:24:02 +02:00
Simon Martin
9fade65dbb
Ticket #8281 , #8417 : Properly detect the end of "switch" statements to accept all legitimate uses of "case". ( #1112 )
2018-04-26 22:26:26 +02:00
Daniel Marjamäki
5384802e16
SymbolDatabase: Look for types in anonymous scopes
2018-04-26 17:55:04 +02:00
amai2012
55983e2a0b
#8509 Uniform initialization ignored for iterator
2018-04-26 08:57:25 +02:00
Sebastian
038064436d
std.cfg: Fix minsize configuration for vsprintf ( #1188 )
...
minsize with argvalue for arg 2 which is a char pointer makes no sense.
Changing it to minsize with strlen for arg 2 results in false positives
(and i think false negatives too).
In std.c a test with a valid vsprintf usage is added that would result
in a FP when minsize with strlen for arg 2 would be used.
2018-04-25 02:52:19 +02:00
IOBYTE
fac851192a
SymbolDatabase: fix problem where definition coudn't find forward declaration in class ( #1190 )
2018-04-24 22:43:47 +02:00
Daniel Marjamäki
deaafd59d7
CheckClass: Undo the rule of 3 checker to avoid some warnings
2018-04-24 22:42:25 +02:00
Daniel Marjamäki
485d3e0229
CheckClass: Tweak rule of 3 checker
2018-04-24 21:45:30 +02:00
Daniel Marjamäki
6fb25dcaa4
CheckClass: Changed checker for 'copy constructor' and 'operator=' to a 'rule of 3' checker
2018-04-24 16:07:58 +02:00
Daniel Marjamäki
8310198cd5
SymbolDatabase: Refactoring and testing isImplicitlyVirtual
2018-04-24 13:53:58 +02:00
Daniel Marjamäki
bb227613bb
SymbolDatabase: Better type lookup in methods
2018-04-23 22:27:15 +02:00
Sebastian
a61f9abbb7
Visual Studio: testrunner: Add missing testastutils ( #1186 )
2018-04-23 20:03:06 +02:00
orbitcowboy
92fd0595b1
Merge branch 'master' of https://www.github.com/danmar/cppcheck
2018-04-23 12:55:10 +02:00
orbitcowboy
e76f1e70e8
Added tests for invalidFunctionArg.
2018-04-23 12:54:49 +02:00
Daniel Marjamäki
7c5058a42d
Refactoring. Rename methods
2018-04-23 12:39:47 +02:00
Daniel Marjamäki
f058d9ad08
CLI: Added more fields for --template and added a new --template-location. The gcc predefined template now matches latest gcc better.
2018-04-23 12:21:18 +02:00
Daniel Marjamäki
e1db4c0e2c
astyle formatting
...
[ci skip]
2018-04-21 13:28:31 +02:00
Simon Martin
a451a5b598
Ticket #8436 : Handle C++11 initializations within ternary operator. ( #1174 )
2018-04-21 11:30:07 +02:00
Paul Fultz II
d939c6015a
Report opposite expressions ( #1182 )
...
* Report opposite expressions
* Skip assignment operator
2018-04-21 11:28:21 +02:00
Paul Fultz II
bad66594d6
Fix double free regression with smart pointers ( #1184 )
2018-04-21 11:24:19 +02:00
Daniel Marjamäki
d5fb529d4f
Fixed #8492 (Improve message: parameter should be passed by reference)
2018-04-20 17:33:42 +02:00
Sebastian
b53c4b2032
std.cfg: Add std::vector function configurations and tests ( #1180 )
2018-04-19 16:41:25 +02:00
amai2012
e256ce8ea8
Add more tests for Path::isAbsolute
2018-04-19 14:35:26 +02:00
Daniel Marjamäki
7ee636b934
Refactoring: Reuse isLikelyStreamRead in isVariableChanged
2018-04-18 17:46:10 +02:00
Daniel Marjamäki
26e36a1d6b
Fix FP uninitvar when stream bool operator is used
2018-04-18 16:13:24 +02:00
Sebastian
3b68c913cb
testrunner: Add testplatform to verify platform loading ( #1176 )
2018-04-18 16:12:35 +02:00
Daniel Marjamäki
1b4f4d7130
Fixed #8495 (False positive: boolean result used in bitwise operation when & is overloaded)
2018-04-17 22:14:17 +02:00
Daniel Marjamäki
c84628c28a
Fixed #8494 (False positive: serialization class overloads operator)
2018-04-17 14:23:04 +02:00
Daniel Marjamäki
a4f8c44432
astyle formatting
...
[ci skip]
2018-04-16 12:55:37 +02:00
Paul Fultz II
2a657cfd08
Check for double frees when using smart pointers ( #1172 )
...
* Check for double frees when using smart pointers
* Some updates from feedback
* Add test for mismatch allocation
* Constants
* Check smart pointer deleter
* Switch order
* Use next
* Add owned state
* Fix handling of leaks
* Use ast for checking addressof operator
* Remove stray character
* Add a test for mismatch allocator
* Add another test for deallocating with custom function
2018-04-16 11:11:13 +02:00
Sebastian
c39a3e3f1c
windows string macros: Handle _T, _TEXT and TEXT internally, add tests ( #1163 )
...
Remove TEXT() macro from windows.cfg and handle it internally where it
can be correctly simplified (Ansi vs. Unicode).
Also add handling of _TEXT() macro which is just a synonym for _T().
Add tests to verify correct function and macro simplification.
2018-04-12 08:52:31 +02:00
Sebastian
a36dad918a
std.cfg: Add std::make_pair() ( #1165 )
2018-04-11 19:16:55 +02:00
orbitcowboy
ef62207ada
std.cfg: Added more tests for some std::vector functions.
2018-04-11 17:21:26 +02:00
PKEuS
b596b0d549
Refactorization: pass std::string directly to std::*fstream
2018-04-11 09:50:42 +02:00
PKEuS
d2146844dd
Refactorizations:
...
- Replace several push_back-calls by emplace_back
- Replace some x = x.substr(0, y) calls by x.erase(y)
2018-04-11 09:44:35 +02:00
Daniel Marjamäki
a0c9de0048
Suppressions: Validate inline suppressions
2018-04-11 08:18:00 +02:00
Sebastian
3fc53eb122
std.cfg: Add std::[w]string::compare() with tests ( #1162 )
2018-04-10 21:07:39 +02:00
Daniel Marjamäki
c5923fbdd3
astyle formatting
2018-04-09 22:21:17 +02:00
Daniel Marjamäki
8f84a493f4
remove foreach emulator
2018-04-09 22:09:10 +02:00
Daniel Marjamäki
e6114a2321
glob patterns: wildcards also match path separators (like before)
2018-04-09 18:59:18 +02:00
IOBYTE
8734e4dd38
Fix SymbolDatabase bailout to also support struct ( #1160 )
2018-04-09 18:53:55 +02:00
Paul Fultz II
d8b3fa5c70
Fix #8482 : Regression with valueflow ( #1159 )
...
* Fix regression with valueflow
* Simplify test case
2018-04-09 16:13:17 +02:00
Daniel Marjamäki
f677322c69
Suppressions: Allow symbol-based inline suppressions
2018-04-09 11:50:59 +02:00
PKEuS
17b4721bd2
C++17: Support "if constexpr" (by simplifying it to plain if() statement)
...
This might lead to complaints about constant expressions as if() statement, but should fix syntax errors.
2018-04-09 11:42:59 +02:00
PKEuS
bbfcccf078
Refactorization: Replace several push_back-sequences by initializer lists
2018-04-09 09:41:24 +02:00
Daniel Marjamäki
a0906140a6
Suppressions: New extensible Suppressions xml format that allow more attributes. To start with it also allows symbolName.
2018-04-09 06:43:48 +02:00
PKEuS
e2002db78d
Replaced make_container by C++11 initializer lists
2018-04-08 23:03:44 +02:00
Paul Fultz II
95fc84a26b
Find duplicate expressions assigned to the same variable ( #1129 )
...
* Check for duplicate assignments
* Improve checking of expression
* Add more tests
* Use simple match
* Improve robustness of check
* check for null
* Reduce side effects by checking for side effects
* Improve verbose message
* Reword the error message
2018-04-08 14:43:19 +02:00
Daniel Marjamäki
795b9f5e0f
astyle formatting
2018-04-08 09:25:59 +02:00
Paul Fultz II
aed84abfd5
Extend valueflow comparison ops ( #1153 )
...
* Handle else clause when doing a compare
* Break early
* Fix bug in checking no return else
* Escape quotes
* Add equal sign
* Simplify the logic
2018-04-08 09:24:01 +02:00
Paul Fultz II
b85dda77da
Add a check for identical inner conditions ( #1156 )
2018-04-08 08:13:44 +02:00
IOBYTE
90983303f0
Fix #8477 (False positive caused by anonymous enum in method body) ( #1154 )
2018-04-08 08:00:12 +02:00
IOBYTE
4f9073159a
Fix another SymbolDatabase bailout ( #1157 )
2018-04-08 07:29:19 +02:00
orbitcowboy
270635eb1f
wxwidgets.cfg: Improved support for wxString to number conversion functions.
2018-04-07 20:27:02 +02:00
IOBYTE
20f0784c06
Fix #8470 ((error) SymbolDatabase bailout; unhandled code) ( #1155 )
2018-04-07 16:41:39 +02:00
Daniel Marjamäki
0daa3bba30
ValueType: Improved type handling of containers when [] operator is used
2018-04-06 22:26:35 +02:00
IOBYTE
7e15e39f39
Fix some new SymbolDatabase bailout; unhandled code syntax errors. ( #1152 )
2018-04-06 21:32:32 +02:00
Daniel Marjamäki
05acf9b352
Fixed #8470 ((error) SymbolDatabase bailout; unhandled code)
2018-04-06 16:03:58 +02:00
IOBYTE
9f386d305a
Fixed #8280 (False positive uninitMemberVar - initialized from nested overloaded function) ( #1151 )
2018-04-06 07:53:05 +02:00
Paul Fultz II
b871c85b67
Improve valeflow analysis with comparison operators ( #1131 )
...
* Improve valeflow analysis with comparison operators
* Use simple match
* Dont add 0 on comparisons
* Check reverse comparisons
* Use nullptr
* Remove duplicate code tests
2018-04-05 06:51:31 +02:00
Paul Fultz II
54de7b48c9
Fix false positive when constructing with curly brace ( #1148 )
2018-04-05 06:47:59 +02:00
Paul Fultz II
0c6f184423
Fix false positive for opposite conditions when using different containers ( #1143 )
...
* Fix false positive for opposite conditions when using different containers
* Add additional test
2018-04-05 06:43:13 +02:00
orbitcowboy
6e21d5ab84
wxwidgets.cfg: Added support for wxAtoi, wxAtol and wxAtof.
2018-04-04 21:29:55 +02:00
amai2012
41a46364c8
Fix sorting order for test fixtures to get consistent behaviour across different platforms ( #1145 )
2018-04-04 20:51:47 +02:00
IOBYTE
a62c932a8f
Improve findFunction for function calls with function calls as arguments. ( #1147 )
...
Duplicate the existing logic for variable to variable type comparisons
for function return type to variable type comparisons.
2018-04-04 20:44:01 +02:00
amai
b133d50ebe
#6426 Regression now has platform dependent results
2018-04-04 16:07:07 +02:00
amai
7581231d9d
#6426 FP duplicateExpressionTernary - (expr) ? ~0u : ~0ul. Add regression test
2018-04-04 14:31:48 +02:00
Daniel Marjamäki
0d434efc15
virtualCallInConstructor: Clarify warning message
2018-04-04 13:04:40 +02:00
Daniel Marjamäki
b3b364b42f
virtualCallInConstructor: Updated warning message
2018-04-04 12:52:58 +02:00
Daniel Marjamäki
7efc4dd26e
astyle formatting
...
[ci skip]
2018-04-04 10:04:40 +02:00
IOBYTE
fa968d75bd
Partial fix for #8291 : (False positive uninitMemberVar when calling delegated constructor) ( #1142 )
2018-04-04 08:29:12 +02:00
Paul Fultz II
bce5fe5cef
Improve duplicate expressions in the ternary op by checking for equal values as well ( #1134 )
...
* Improve duplicate expressions in the ternary op by checking for equal values as well
* Use value instead of expression
2018-04-03 21:43:55 +02:00
Paul
d240a36a60
Extend nullPointerArithmetic to check for addition as well
2018-04-03 21:32:37 +02:00
Daniel Marjamäki
ee22a325c7
virtual function call in constructor: don't warn about explicit scoped call
2018-04-03 14:02:59 +02:00
IOBYTE
2a418fa0f5
Fixed #8466 (False Positive: Member variable is not initialized in the constructor. When using overloaded constructors) ( #1141 )
2018-04-02 18:32:45 +02:00
Daniel Marjamäki
1046ca2120
Improve check: Warn about virtual function calls in constructor/destructor
2018-04-02 15:31:47 +02:00
Daniel Marjamäki
e492932f19
Improve check: Variable is not initialized in private constructor (C++11 or later)
2018-04-02 15:26:15 +02:00
Daniel Marjamäki
9f92685b92
SymbolDatabase: Throw InternalError if parsing fails
2018-04-02 13:14:48 +02:00
Daniel Marjamäki
af88d7c4a9
Makefile: updated for release
2018-04-02 09:02:50 +02:00
Daniel Marjamäki
c0272fc2ef
Fixed #8259 (Don't combine &= for anonymous reference parameters)
2018-04-01 10:27:16 +02:00
Daniel Marjamäki
7e4dba6a7e
Updated copyright year
2018-03-31 20:59:09 +02:00
Daniel Marjamäki
4af2e517b9
Fixed #8465 (SymbolDatabase: bailout if there is 'struct A::B ab[5];')
2018-03-31 17:54:47 +02:00
orbitcowboy
e3977f7e51
Formatted test/cfg files and updated 'runastyle' script. The generated test files are exclued, since they are not style-compliant.
2018-03-31 13:49:47 +02:00
orbitcowboy
d7072136dc
wxwidgets.cfg: Added support for wxMenuBar::Append().
2018-03-31 13:34:40 +02:00
orbitcowboy
43aac4696e
wxwidgets.cfg: Added support for more functions.
2018-03-31 13:23:12 +02:00
Sebastian
3c5777fbc6
windows library: Add config for some Local* functions ( #1139 )
...
Add configuration and tests for LocalAlloc, LocalFree and some other
Local* functions.
LocalReAlloc is currently not configured as an alloc/dealloc function
(like realloc is not configured in std.cfg), i am not sure how to
correctly configure it.
2018-03-29 20:47:22 +02:00
Daniel Marjamäki
1bc8f7f29a
astyle formatting
2018-03-29 17:25:20 +02:00
Paul Fultz II
70da3acb70
Add foreach emulation for older compilers ( #1138 )
2018-03-29 04:51:22 +02:00
Daniel Marjamäki
210b921062
Fixed #8462 (AST: no ast created for 'e = { std::move(address),httpPort, (httpsPort) };')
2018-03-27 13:44:28 +02:00
Dmitry-Me
c76b593467
Resolve C4800 warning
2018-03-27 00:58:53 +03:00
Sebastian
d3284d5d54
std.cfg: Add strncpy_s and strncat_s ( #1136 )
2018-03-26 18:38:26 +02:00
Paul
43be20a824
Check more opposite conditions
2018-03-24 07:58:37 +01:00
amai
dbb7e98711
#8346 Add regression test
2018-03-24 07:28:02 +01:00
IOBYTE
5bc039b7da
Fix #6367 and #8439 (improve sizeof value flow support) ( #1132 )
2018-03-23 08:28:12 +01:00
Daniel Marjamäki
5a444f764b
Fixed one more syntax error FP related to #8390
2018-03-22 15:20:37 +01:00
Daniel Marjamäki
3d4b773fd1
Fixed #8390 (Syntax error from an MSVC internal header)
2018-03-22 09:07:58 +01:00
Sebastian
e38ec41ded
windows.cfg: Add some commonly used macros ( #1127 )
2018-03-22 08:31:50 +01:00
Daniel Marjamäki
dfd8ef5d52
generate_cfg_tests: fix argument count
2018-03-19 20:46:55 +01:00
Daniel Marjamäki
7202787435
posix: remove function 'remove' that is also configured in std.cfg
2018-03-19 20:04:58 +01:00
Daniel Marjamäki
3af7aef3f0
update generated cfg tests ( aca16e3
)
2018-03-19 16:25:44 +01:00
Daniel Marjamäki
6b00ca33bd
posix.cfg: Removed rename function as this is configured in std.cfg
2018-03-19 15:29:47 +01:00
Daniel Marjamäki
4e1ad40c87
update generated cfg tests ( 113f1ef
)
2018-03-19 13:51:51 +01:00
Daniel Marjamäki
6e66150feb
posix.cfg: update configuration for rename
2018-03-19 11:51:19 +01:00
Daniel Marjamäki
f94a02a61e
update generated qt.cfg tests
2018-03-19 11:51:03 +01:00
Daniel Marjamäki
b10dd5d21e
2 TODOs are fixed
2018-03-19 11:02:58 +01:00
Daniel Marjamäki
0d3ddd85b1
updated generated cfg tests
2018-03-19 09:46:16 +01:00
Daniel Marjamäki
7699f6432b
Fixed #8288 (valueFlowGlobalVar: compound assignments)
2018-03-18 19:53:33 +01:00
Daniel Marjamäki
e932c44ae6
generate cfg tests: updated NULL pointer testing
2018-03-18 19:04:17 +01:00
Daniel Marjamäki
0741c389c0
generated cfg tests: updates, most unmatched suppressions are removed now
2018-03-18 14:06:26 +01:00
Daniel Marjamäki
c800ac5118
generate_cfg_tests: updating testing for not-null
2018-03-18 13:53:46 +01:00
Daniel Marjamäki
914eea7ed1
generated cfg tests: updated test files
2018-03-18 13:22:33 +01:00
Daniel Marjamäki
cf180dcc6b
add script to generate cfg tests
2018-03-18 13:03:19 +01:00
Paul Fultz II
73ac27cc79
Fix loading library when running tests from build directory ( #1123 )
2018-03-18 06:50:33 +01:00
Daniel Marjamäki
ec6133aea2
Fixed #8182 (False positive uninitvar - variable initialized in function in ternary expression)
2018-03-16 19:13:48 +01:00
Sebastian
65c85cbb53
Windows library: Add intrinsics __noop and __nop ( #1119 )
2018-03-15 12:31:20 +01:00
Paul Fultz II
166e4cafcd
Check for functions calls in sizeof calculations ( #1111 )
...
* Check for functions calls in sizeof calculations
* Use seperate message and id for sizeofFunction
* Check for overloads
* Using decltype with a function should not be an error
* Fix warning
* Fix false positives when running pass the close paren
* Fix test error
* Try to fix more false positives
* Traverse using astOperand2
* Only check first argument
* Update fixes from feedback from PR
2018-03-15 10:24:17 +01:00
Sebastian
ed3cd2929e
Windows library: Enhance functions, add tests ( #1117 )
...
Enhance *Equal/*Compare/*Copy/*Move/*Zero/*Fill memory functions to
catch buffer access out of bounds errors and ignored return values.
Replaced some function configuration by according defines as it is done
in windows to avoid redundant (and error prone) configurations.
2018-03-14 15:01:37 +01:00
Daniel Marjamäki
cb6ed0555c
Fix testrunner
2018-03-14 11:11:35 +01:00
Hinterwaeldlers
a9b1f4c640
Taking care of operation overloading functions ( #1108 )
2018-03-12 10:25:30 +01:00
Daniel Marjamäki
380ecc408f
Fixed #8418 (AST: wrong ast for throw expression)
2018-03-10 22:30:21 +01:00
Sebastian
7ba9ab7e4c
Gtk library: Add configuration to avoid syntax error, add test file ( #1109 )
...
Add configuration for G_UNLIKELY and G_LIKELY to avoid syntax errors
when these macros are used as condition without enclosing brackets.
Add test file to verify Gtk library configuration. Syntax check for the
test file is only done when Gtk+2.0 or Gtk+3.0 is found and working.
Tested on Cygwin and on Ubuntu 16.04.
2018-03-10 11:22:10 +01:00
Alexander Mai
70664e5857
Ensure wxWidgets installation is at least 2.9.5
2018-02-26 20:46:56 +01:00
Daniel Marjamäki
7701e4594a
ValueFlowBeforeCondition: Fix wrong value in do-while condition when there is a break in the loop body
2018-02-24 22:07:34 +01:00
Sebastian
346704b2e2
windows library: Mainly add socket functions, some other stuff and tests. ( #1095 )
...
Add Windows Socket 2 type/function configuration. There are still many
(microsoft specific) socket functions that are not yet configured.
Add configuration for GetUserName(), GetWindowText() and _fileno().
On Windows __wchar_t is a synonym for wchar_t, so an according define is
added.
2018-02-23 12:51:37 +01:00
amai2012
1c38b3aae7
Fix warning in test on Cygwin
2018-02-22 12:27:46 +01:00
Sebastian
1d14919649
wxwidgets: Fix syntax checking errors and warning ( #1093 )
...
wxDebugContext is only defined if wxUSE_DEBUG_CONTEXT is 1, so otherwise
just skip it for syntax checking because it will fail.
Change wxT to wxT_2 and add wxT_2 to the config to remove a warning
during syntax check and be more compatible with newer/older wxwidgets
versions.
Be more precise when replacing function like macros, fix redundant macro
definition for "_".
2018-02-21 12:20:56 +01:00
orbitcowboy
2ce8a3fc95
wxwidgets.cfg: Improved support for some deprecated functions.
2018-02-20 23:34:01 +01:00
orbitcowboy
a4ab30cbe3
Replace uint8_t with short to fix CI.
2018-02-20 00:22:14 +01:00
orbitcowboy
46b4a502df
Added missing include.
2018-02-20 00:18:20 +01:00
orbitcowboy
b7b376d901
checkTypes: Take into account type promotion to integer.
2018-02-19 23:55:38 +01:00
orbitcowboy
b1b3164259
checktype: Added handling of 'short'-type and added test cases.
2018-02-18 21:09:19 +01:00
orbitcowboy
50844aa7fc
checkType: Take into account the size of char.
2018-02-18 14:28:48 +01:00
orbitcowboy
782ebdc8e8
testlibrary: Minor improvements, take into account the return values from readLibrary in unit-tests.
2018-02-17 23:33:24 +01:00
IOBYTE
fcde1d80e9
Fix #8382 (Syntax error when scanning code with template and attribute) ( #1089 )
...
* Fix #8382 (Syntax error when scanning code with template and attribute)
This commit only addresses #8382 . There are issues concerning which
versions of C++ should be supported and also generic C++ 14 attribute
support which can be revisited later.
* Remove all C++ style attributes.
Remove all C++ style attributes when C++ version is 11 or greater.
Rename simplify function to simplifyCPPAttributes.
Handle more cases of roreturn function attribute.
2018-02-16 22:25:51 +01:00
orbitcowboy
2defdb7d4c
wxwidgets.cfg: Added more deprecated functions.
2018-02-14 09:53:40 +01:00
Sebastian
bbe9fad81d
std library: Resolve two TODOs ( #1074 )
...
First resolved TODO in std.c is obsolete since the "res" variable is used later
and there is therefore no warning issued.
Second resolved TODO in std.c: A warning for uninit variables is issued by
cppcheck, so this check can be enabled. Since assert() has no noreturn configuration
(currently a useful configuration is not really possible, see ticket 8329) the
check-library message is suppressed.
2018-02-12 16:42:23 +01:00
Daniel Marjamäki
e62b9bdc77
Fixed #8348 (ValueFlow: wrong Uninit value with abort() in else-branch)
2018-02-11 22:14:44 +01:00
orbitcowboy
8ef56972da
wxwidgets.cfg: Added more deprecated-functions.
2018-02-11 16:58:39 +01:00
IOBYTE
d68f07e50c
Add purgedConfiguration to list of error ids. ( #1087 )
...
purgedConfiguration was not showing up in the GUI supression list.
2018-02-10 22:30:49 +01:00
Simon Martin
66d16b51f0
Ticket #8352 : Properly detect AST cycles. ( #1060 )
2018-02-10 14:39:57 +01:00
Sebastian
9eb6d38c06
std library: Add tests for wide character string functions, fix config ( #1085 )
...
Add equivalent tests for the wide character string functions like they
are already done for the normal string functions.
Fixed some issues with the configuration of the wide character string
functions that arised through the tests and were already fixed for the
normal string functions.
2018-02-09 21:17:01 +01:00
Sebastian
170d60712f
wxwidgets library tests: Add syntax checking, fix test file. ( #1084 )
...
For the syntax check g++ needs to know the wxWidgets include paths which
are retrieved via wx-config. If includes are missing or not working the
syntax check is skipped.
wxwidgets.cpp: Fixed syntax, includes and added code so the syntax check
does not fail if some special features are not present.
2018-02-09 20:34:15 +01:00
Lauri Nurmi
e0e664f996
Fix permissions of certain non-executable files ( #1083 )
...
mode 0755 => 0644
2018-02-09 19:46:38 +01:00
orbitcowboy
dccf96cb7b
wxwidgets.cfg: Added more deprecated functions.
2018-02-07 13:33:15 +01:00
orbitcowboy
dea662891a
wxwidgets.cfg: Added some functions from the deprecated wxWidets-list ( http://docs.wxwidgets.org/trunk/deprecated.html ).
2018-02-07 11:40:42 +01:00
Sebastian
14e45f9dcb
wxwidgets library: Fix/Enhance cfg, add test file ( #1082 )
...
Add test file for wxwidgets configuration, fix found issues and enhance
the cfg a bit:
Fix declarations in comments for wxLog* functions.
Merge the two wxTextFile::Create overloaded function configurations into
one that works for both now.
Removed use-retval attribute from wxBoxSizer::AddSpacer and
wxButton::SetDefault configuration since the functions have side effects
and there is no need to use the return value.
Add some function configurations, the macro _(str) and POD wxLogLevel.
2018-02-06 15:33:45 +01:00
Daniel Marjamäki
58066b1f0c
Remove whole program analysis from 'uninitialized variables' and 'null pointer dereference' checkers. I think this logic can more or less be added in ValueFlow instead and then all ValueFlow checkers should get whole program analysis.
2018-02-06 14:56:17 +01:00
Daniel Marjamäki
71511f3131
Refactor f487182
2018-02-06 08:59:36 +01:00
Ivan Maidanski
f487182075
Suppressed unused functions should not lead to nonzero exit code ( #1026 ) ( #1078 )
...
This is a fix of commit 97ffec8
.
2018-02-06 07:44:53 +01:00
Daniel Marjamäki
dbc6771a0b
Uninitialized variables: Fix FP for unknown macro like 'list_for_each'
2018-02-04 22:30:08 +01:00
Matthias Krüger
f009cfc845
fix some typos found by codespell.
2018-02-04 20:53:43 +01:00
Daniel Marjamäki
4998248501
Null pointers: Fixed false positives when running whole program analysis. Copied the fix from the CheckUninitVar::isUnsafeFunction.
2018-02-04 15:29:57 +01:00
Jørgen Kvalsvik
a61f21d1b6
Accept nested templates in tokenizer-simplify ( #1070 )
...
The following snippet triggerd the error:
template<typename DerivedT>
template<typename T>
auto ComposableParserImpl<DerivedT>::operator|( T const &other ) const -> Parser {
return Parser() | static_cast<DerivedT const &>( *this ) | other;
}
Whenever simplifyFunctionParameters was called on a templated class'
templated member function (and probably any nested template), the
tokenizer would recognise it as a syntax error, assuming that return
type *must* come after a template<> token.
2018-02-04 09:48:37 +01:00
Daniel Marjamäki
d47b7726fa
Uninitialized variables: Fix potential false positives in subfunction if there is early return or conditional writes
2018-02-04 09:40:57 +01:00
IOBYTE
d721c6aca5
Fixed #8386 (syntax error not found (segmentation fault)) ( #1081 )
2018-02-03 15:50:05 +01:00
Sebastian
2e5d7a8391
Fix #8381 : false positives for swprintf_ and stprintf_s ( #1080 )
...
This fixes false positives because of wrong configuration in
windows.cfg.
Add tests in testio.cpp and test/cfg/windows.cpp to avoid regression.
2018-02-03 05:10:52 +01:00
Sebastian
c235930539
windows library: Add function configurations with tests ( #1079 )
...
Add function configurations with tests for:
GetLocalTime, GetSystemTime, GetLastError, SetLastError,
AllocateAndInitializeSid, FreeSid, HeapAlloc, HeapReAlloc, HeapFree,
HeapSize, HeapValidate and GetProcessHeap.
test/cfg/runtests.sh: Enable --inconclusive for the windows tests to
avoid some issues in the future.
2018-02-02 11:28:54 +01:00
Sebastian
1ad22ae231
windows library: Add strlwr/strupr configuration, fixing tests ( #1076 )
...
Add configuration for the deprecated strlwr/strupr functions with
according warning.
test/cfg/windows.cpp: Added tests for strlwr and strupr. Moved function
call that does not return (FreeLibraryAndExitThread) to the end of the
function to fix analysis that was silently aborted at that point
(reported as issue #8378 ).
2018-01-31 17:43:19 +01:00
Sebastian
7b02b45a76
posix library: Add strtok tests ( #1069 )
...
* posix library: Add strtok tests
In the posix library there is the same configuration for strtok but a
warning is added.
* posix.cfg: Remove redundant configuration for strtok, add comment.
2018-01-31 10:58:30 +01:00
Sebastian
c62abee07a
windows library: Add _malloca/_freea and _alloca configuration with tests ( #1071 )
2018-01-30 16:40:38 +01:00
orbitcowboy
f5e6ef9fd2
checkio: Fixed potential usage of invalid iterator. ( #1066 )
...
* checkio: Fixed potential usage of invalid iterator.
* formatted the code.
A ticket about FN (invalidIterator1) is created at https://trac.cppcheck.net/ticket/8373
2018-01-30 08:43:15 +01:00
Sebastian
4b5e4f989a
std config: Remove misspelled function "strbprk" ( #1065 )
...
Remove misspelled function configuration "strbprk" (also from the
tests). The correct function "strpbrk" is already configured and tested.
2018-01-29 17:28:44 +01:00
Sebastian
30b9391461
windows library: Enhance Event function configuration, add tests ( #1064 )
2018-01-29 14:08:56 +01:00
Sebastian
e8a262a1f2
posix.cfg: Enable/Add fdopen tests ( #1063 )
...
* posix.cfg: Enable/Add fdopen tests
* posix.cfg: Add missing empty line
2018-01-29 11:19:31 +01:00
David Hallas
4d18d3948f
Fixes issue with case inside switch that is not a compound statement ( #1031 )
...
* Fixes issue with case inside switch that is not a compound statement was treated as garbage
This fixes an issue with the check for case keywords outside of switch
detection that would treat a case statement inside a switch that is not
a compound statement as garbage, but this is perfectly valid C++. This
construct is used in several libraries, i.e. Google Test.
* Tweak check and handle missing semicolon
Tweaks the check with feedback from danmar.
Handle the case where there is no semicolon and document it with a unit
test.
2018-01-27 22:21:26 +01:00
Daniel Marjamäki
bc40f5041d
Fixed #6356 (Improve checking: pointer arithmetic "ab.a + 100" overrun)
2018-01-27 15:39:39 +01:00
Daniel Marjamäki
c110770481
Fixed #8325 (False negative: address of auto variable being returned when assigned to another variable first)
2018-01-27 14:48:45 +01:00
Simon Martin
71ba513bdb
Ticket #8361 : Fix false positive in Tokenizer::findGarbageCode. ( #1061 )
2018-01-26 22:06:07 +01:00
Daniel Marjamäki
a5f202360a
Fixed crash for garbage code, found by fuzzing
2018-01-26 09:34:27 +01:00
Daniel Marjamäki
cb297a00fc
Auto variables: Assign address of local variable to global pointer ( #6825 )
2018-01-25 22:50:41 +01:00
Daniel Marjamäki
9109956c8c
UninitVar: Improve whole program analysis, used isVariableUsage()
2018-01-25 21:49:21 +01:00
Daniel Marjamäki
f73da16e94
Revert "UninitVar: Better checking in whole program analysis"
...
This reverts commit b2bdc2687b
.
2018-01-25 17:05:57 +01:00
Daniel Marjamäki
b2bdc2687b
UninitVar: Better checking in whole program analysis
2018-01-25 15:56:46 +01:00
Daniel Marjamäki
c04557eb73
Fix crashes detected with fuzzing
2018-01-25 15:53:58 +01:00
Daniel Marjamäki
ce60b326f4
Whole program analysis: Improved handling of nested calls
2018-01-24 22:53:14 +01:00
Daniel Marjamäki
599e038282
AutoVariables: Warn when address of local array is assigned to global pointer and pointer is not reassigned
2018-01-24 21:33:58 +01:00
Sebastian
eabe5787ba
Add windows configuration tests ( #1053 )
...
Implemented tests for the following windows configurations (more will
follow):
-Semaphore usage
-lstrcat function configuration
-_countof macro configuration
-Mutex usage
-Library usage (LoadLibrary, GetProcAddress, ...)
2018-01-24 20:05:16 +01:00
Daniel Marjamäki
96e387a486
Fixed #8351 (segmentation fault on objective C code)
2018-01-24 18:06:11 +01:00
IOBYTE
558e0757c2
Fix simplifyTypedef crash on lambda. ( #1054 )
2018-01-24 15:04:33 +01:00
Daniel Marjamäki
0f561d0ed6
Fix crashes for garbage code, found by fuzzing
2018-01-24 13:53:03 +01:00
IOBYTE
4710d80a40
Fix #5766 (FP: typedef array throws off parser) ( #1052 )
...
* Fix #5766 (FP: typedef array throws off parser)
* Fix travis build.
2018-01-24 09:51:22 +01:00
Daniel Marjamäki
ce44a5805c
astyle formatting
...
[ci skip]
2018-01-23 18:15:37 +01:00
Sebastian
b78d714037
posix.cfg: access(): Removed redundant configuration, added tests ( #1048 )
...
I intentionally removed the second access() configuraion because it was
missing the use-retval attribute. But calling access() without using the
return value is absolutely senseless.
I added tests to posix.c to verify the correct configuration of
access().
2018-01-22 14:54:14 +01:00
IOBYTE
e6d285d3ca
Fixed #8357 (crash: cmake Tests/CMakeLib/testUTF8.cxx --debug --verbose) ( #1046 )
2018-01-22 08:06:56 +01:00
IOBYTE
3159d151d3
Fix symbol database crash on template type aliases by ignoring them. ( #1045 )
2018-01-21 21:22:26 +01:00
Alexey Eryomenko
913fdf44b6
member access operators are allowed inside the embedded SQL block when ( #1043 )
...
passing arguments for a query
2018-01-21 15:58:12 +01:00
IOBYTE
5673348215
Fixed #8350 (False positive: enum class static_cast to int is treated as non-primitive when type inference is used) ( #1042 )
2018-01-21 07:26:37 +01:00
Simon Martin
b4f32206af
Ticket #8337 : Fix false positive in copy constructor detection. ( #1040 )
2018-01-20 14:46:09 +01:00
Daniel Marjamäki
0a70b8794c
astyle formatting
...
[ci skip]
2018-01-19 23:26:28 +01:00
Sebastian
de7aa8f513
Fix #7504 : posix: open() was twice in configuration file ( #1032 )
...
* Fix #7504 : posix: open() was twice in configuration file
This fixes ticket #7504 : Problems with the open function were not always
detected because the open function was twice in posix.cfg and only the
second configuration was used by cppcheck. Like suggested now only
one configuration is used and the third parameter has a default value
and is thereby optional.
use-retval has been removed to avoid duplicate warnings because the
alloc/dealloc configuration already warns about unused retval.
According tests to verify that open is configured
correctly now have been added to test/cfg/posix.c.
* posix.cfg: open(): Add TODO for use-retval configuration
2018-01-18 13:56:36 +01:00
Simon Martin
8878e6dd0d
Ticket #8333 : Properly report a syntax error for functions with invalid parameter types. ( #1030 )
2018-01-18 08:51:35 +01:00
Daniel Marjamäki
100887429d
Uninitialized variables: Whole program analysis for function calls
2018-01-15 15:54:09 +01:00
Daniel Marjamäki
c4caee6b18
Updated copyright year
2018-01-14 15:37:52 +01:00
Ivan Maidanski
97ffec85c0
Fixed #7502 (Correct exit code if never used function is found) ( #1026 )
2018-01-12 08:24:01 +01:00
IOBYTE
03603c85cf
Fixed #8331 (stack overflow: daca: firefox-58.0b14) ( #1027 )
2018-01-12 08:19:21 +01:00
Daniel Marjamäki
1b13490ac1
Move code
2018-01-11 14:27:41 +01:00
Daniel Marjamäki
6fd157e93b
ValueFlow: Template arguments have 'possible' values
2018-01-11 14:22:27 +01:00
Daniel Marjamäki
bbeff99cc3
Fixed #6930 (Token: need function that says if the token comes from instantiated template argument)
2018-01-11 09:41:22 +01:00
Daniel Marjamäki
323e9ab509
astyle formatting
...
[ci skip]
2018-01-11 09:31:16 +01:00
IOBYTE
cefb2131c7
Add support for simple c++ 11 type ailases like: using INT = int; ( #1024 )
...
* Add support for simple c++ 11 type ailases like: using INT = int;
Only types supported by ValueType are supported. Complex types like
function pointers are not supported. Template type aliases are not
supported.
* Fix crash when type in using type alias is simplified away.
This fixes a crash when size_t is replaced with unsigned long in: using
size_t = unsigned long; by the tokenizer.
This does not fix the problem where Tokenizer::simplifyPlatformTypes()
simplifies away size_t in other cases. This is only a problem when the
new type is different from the platform type.
2018-01-10 22:16:18 +01:00
Daniel Marjamäki
58034dee86
Fixed #8076 (unmatched suppression when calling ./runtests.sh (test/cfg))
2018-01-10 15:52:06 +01:00
amai2012
b17807c568
#6572 False positive eraseDereference - in iterator class - flag error inconclusive if iterator is not STL type
2018-01-10 09:37:21 +01:00
PKEuS
b684e1f202
Updated AStyle to version 3.0.1
2018-01-08 20:20:33 +01:00
Iván Matellanes
cfeea3d35c
Fixed #7331 : Detect copy and move constructors with default parameters ( #1018 )
2018-01-07 14:20:19 +01:00
PKEuS
c8010fdf42
Fixed crash on garbage code ( #8307 )
2018-01-07 13:11:56 +01:00
PKEuS
817f66d74d
Fixed crash on garbage code ( #8317 )
2018-01-07 12:52:28 +01:00
Matthias Krüger
eb58df236e
CheckOther::accessMovedError() / accessMoved, accessForwarded warnings: put variable name into single quotes.
2018-01-07 10:57:19 +01:00
Daniel Marjamäki
83b87b54b4
Fixed #8191 (False positive iterators regression)
2018-01-06 22:25:13 +01:00
Daniel Marjamäki
61767d4932
Fixed #8125 (incorrect error iterators)
2018-01-06 16:08:12 +01:00
Daniel Marjamäki
98b45ffbc0
Fixed #8314 (TemplateSimplifer crash)
2018-01-06 15:16:03 +01:00
Daniel Marjamäki
943693acfb
TemplateSimplifier: Improved code for template aliases
2018-01-06 08:40:06 +01:00
Martin Ettl
53fbfc9fdb
test: Various micro optimizations: Replaced std::string() with std::string(). Use std::string::clear() instead of s = and prefer std::string::empty() instead of (s == ) for checking a string is empty.
2018-01-05 22:03:49 +01:00
Daniel Marjamäki
04c57381ea
Fixed #8315 (heap use after free: templatesimplifier)
2018-01-05 16:10:13 +01:00
Daniel Marjamäki
a95108ebe3
TemplateSimplifier: Fix incorrect recursion when template is reused inside itself
2018-01-03 23:05:57 +01:00