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