Daniel Marjamäki
d95f29b23a
Fixed test/cli
2019-08-18 12:51:32 +02:00
Daniel Marjamäki
2d9a131817
Refactoring: Rename variables. Do not use leading _. Renamed 'col' to 'column'
2019-08-18 12:19:05 +02:00
Daniel Marjamäki
de9b928d98
ErrorLogger: add 'column' in serializer/deserializer
2019-08-18 09:06:40 +02:00
Daniel Marjamäki
04e3884ff6
xml: Add column attribute in <location>
2019-08-18 08:37:56 +02:00
Daniel Marjamäki
c3a27eb8c1
Fix a few cppcheck internal warnings
2019-08-17 16:02:58 +02:00
Daniel Marjamäki
a17f2a6f05
Compiling/Installing : The CFGDIR parameter was removed. Use FILESDIR instead.
2019-08-17 10:53:07 +02:00
IOBYTE
04bb6c0d1f
template simplifier: fix new daca crashes ( #2093 )
2019-08-17 07:38:07 +02:00
Paul Fultz II
ee7fe3aaa1
Fix FP: Unitialized variable when using a pointer
...
This fixes the FP in cases like this:
```cpp
void f() {
bool b;
bool * x = &b;
if (x != nullptr)
x = 1;
}
```
It tracks the indirection of the uninit value in valueflow.
2019-08-17 07:36:41 +02:00
Paul Fultz II
3e0d1141d3
Fix issue 9277: FP: Dont warn for knwon conditions in if constexpr ( #2085 )
2019-08-16 07:56:39 +02:00
Paul Fultz II
3aef0c9bd3
Fix issue 8715: regression uninitvar not detected ( #2092 )
2019-08-16 07:48:54 +02:00
Paul Fultz II
ef714225bb
Use library to track container lifetimes
2019-08-15 21:14:54 +02:00
Daniel Marjamäki
95ac8db584
TemplateSimplifier: Set column number for expanded tokens
2019-08-15 15:22:56 +02:00
Daniel Marjamäki
f33a8a417f
Put 'isExpandedMacro' info in the dump files
2019-08-15 14:24:56 +02:00
Daniel Marjamäki
a57d22d2d9
astyle formatting
...
[ci skip]
2019-08-15 10:46:16 +02:00
Paul Fultz II
af214e8212
Fix issue 8825: ValueFlow: uninitialized struct member ( #2087 )
...
* Pass uninit value across pointers
* Add more testing
2019-08-15 10:44:55 +02:00
Rikard Falkeborn
fc1d5b187f
leakNoVarFunctionCall: Use AST more ( fix #9252 ) ( #2086 )
...
Use the AST a little bit more to improve the check. In order to do so,
rewrite the check to work from the outer function first and then check
the arguments, instead of the other way around.
It also fixes Trac ticket #9252 , no warning is now given for
void* malloc1() {
return(malloc1(1));
}
This FP seems to be common in daca results.
It also makes it possible to improve handling of casts, for example
cppcheck now warns about
void f() {
strcpy(a, (void*) strdup(p));
}
But not for
char* f() {
char* ret = (char*)strcpy(malloc(10), "abc");
return ret;
}
These FP/FN were introduced when the check was switched to use the
simplified token list.
2019-08-14 22:01:40 +02:00
Rikard Falkeborn
f139558d90
Dmake cleanups ( #2077 )
...
* dmake: Refactor object files to separate function
No functional change.
* dmake: Use range for loops
No functional change.
* Add all external cpp files instead of open coding
No functional change.
* Remove duplicate check.h in lib.pri HEADERS
* Add missing newline
No functional change, but the readability of the generated Makefile is
slightly improved.
2019-08-14 20:53:51 +02:00
Paul Fultz II
4f76588f98
Fix issue 9275: False positive: Non-local object uses local variable ( #2084 )
2019-08-14 20:09:33 +02:00
Paul Fultz II
0c1dff5c93
Fix issue 9268: false negative: (style) Condition '...' is always true ( #2080 )
...
* Fix issue 9268: false negative: (style) Condition '...' is always true
* Fix copy and paste mistake
2019-08-14 06:34:27 +02:00
Paul Fultz II
13df5b2413
Fix FP with negative index and negated condition ( #2081 )
2019-08-14 06:32:31 +02:00
Daniel Marjamäki
d4549217d0
Renamed safeClassRefMember => unsafeClassRefMember
2019-08-13 20:58:31 +02:00
Daniel Marjamäki
ed7edc6d2a
Improve warning message
2019-08-13 20:42:25 +02:00
Daniel Marjamäki
41f8c1b281
Fixed #9271 (Safe classes: Class that store references)
2019-08-13 20:40:48 +02:00
Rikard Falkeborn
ffcceb097e
Memleak: Refactor check to separate function ( #2079 )
...
This makes all the checks in CheckMemoryLeakNoVar separate functions to
improve readability.
2019-08-13 13:00:59 +02:00
Paul Fultz II
c0c6f92221
Fix issue 8431 and 8776: Size of constant string
...
Fixes these cases:
```cpp
void f(void) {
const std::string msg="xyz";
if(!msg.empty()){} // Always true
}
```
And out of bounds access:
```cpp
#include <string>
char fstr1(){const std::string s = "<a><b>"; return s[42]; }
wchar_t fwstr1(){const std::wstring s = L"<a><b>"; return s[42]; }
```
2019-08-12 20:24:16 +02:00
Paul Fultz II
68e8253920
Fix issue 8313 and 7326: Track values of pointer aliases in valueflow
2019-08-12 12:58:53 +02:00
Daniel Marjamäki
aec217fede
astyle formatting
...
[ci skip]
2019-08-12 12:54:25 +02:00
Rikard Falkeborn
cd36f8ed0a
Fix #9253 : leakNoVarFunctionCall: do not warn if freopen opens standard stream ( #2076 )
...
This fixes false positives from daca@home where freopen is used to
reopen a standard stream. There is no longer a warning for
void f() {
assert(freopen("/dev/null", "r", stdin));
}
2019-08-12 12:53:59 +02:00
Paul Fultz II
9aa97cbb95
Fix issue 8296: ValueFlow: value not set in conditional scope in subfunction ( #2071 )
...
* Fix issue 8296: ValueFlow: value not set in conditional scope in subfunction
* Refactor condition checkingg
* Make test case TODO
2019-08-11 15:39:37 +02:00
Daniel Marjamäki
0edc4feb57
Try to make Appveyor happy
2019-08-10 08:46:27 +02:00
IOBYTE
5fc5e3728d
template simplifier: refactor TemplateSimplifier::TokenAndName into a… ( #2073 )
...
* template simplifier: refactor TemplateSimplifier::TokenAndName into a class
assert when more than one family flag is set
* fix function parameter names
2019-08-10 08:42:12 +02:00
Daniel Marjamäki
6a260929e2
CLI: error id from addon is <addon>-<id>
2019-08-10 07:43:47 +02:00
Daniel Marjamäki
0fbbe2ff23
Refactor load/write of cppcheck project. Reuse same string constants in cli and gui.
2019-08-09 21:15:02 +02:00
Armin Müller
785cc69644
Typos found by running "codespell" ( #2072 )
2019-08-08 21:05:28 +02:00
Paul Fultz II
bd02ca5ccb
Fix issue 9207: Not detected 'always true' and unreachable code
2019-08-08 07:46:47 +02:00
IOBYTE
c6c50567cf
Fix #9250 (Regression: crash in gcc testsuite) ( #2067 )
...
* Fix #9250 (Regression: crash in gcc testsuite)
* fix cppcheck warning
2019-08-07 08:05:02 +02:00
Ken-Patrick
cb0b057595
8706 ( #2066 )
...
* 8706
* Add test case for #8706
2019-08-07 08:04:10 +02:00
Ken-Patrick
9ec8886898
Use std::any_of in token.h ( #2065 )
...
[lib/token.h:964]: (style) Consider using std::any_of algorithm instead of a raw loop.
2019-08-07 08:02:07 +02:00
Paul Fultz II
aaeec462e6
Re-enable valueFlowSubFunction ( #2063 )
...
* Re-enable valueFlowSubFunction
* Formatting
* Skip ternary operators in subfunctions
* Fix test with iostreams
* Fix FP with multiple parameters
2019-08-05 16:26:32 +02:00
Daniel Marjamäki
ebcca4edd1
Improve --debug-warnings output for 'auto' tokens without type. Do not report that prematurely before the type is set properly.
2019-08-05 13:42:06 +02:00
Daniel Marjamäki
20278d9c92
Clarify signConversion warning message
2019-08-05 12:41:08 +02:00
Paul Fultz II
ffdd2dc793
Fix issue 8924: Re-enable valueFlowTerminatingCondition
2019-08-05 07:18:06 +02:00
IOBYTE
7ebc9d1b5f
Fix #9249 (Syntax error on valid C++) ( #2062 )
2019-08-04 10:24:44 +02:00
Daniel Marjamäki
510748134f
Fixed #9234 (FP unreadVariable - assignment via iterator)
2019-08-04 10:21:16 +02:00
Daniel Marjamäki
ce53931d00
Fixed #9251 (False positive: unininitialized variable (multi variables))
2019-08-03 21:12:34 +02:00
Daniel Marjamäki
cdc602e1be
Fixed #9137 (Tokenizer: Wrong handling of volatile pointer)
2019-08-03 12:28:50 +02:00
Daniel Marjamäki
c03df8e6b4
SymbolDatabase: Improved matchParameter for containers
2019-08-03 10:10:40 +02:00
IOBYTE
2da83df37b
Fix #9246 (Syntax error on C++ code) ( #2061 )
2019-08-03 08:15:06 +02:00
amai2012
f02636e995
Refactoring: Convert enums to enum classes
2019-08-02 21:14:29 +02:00
rebnridgway
d2b9c1f15a
Fix some bugs in new Scope Calculation code ( #2060 )
...
* Fix for too much information in scope name
When the scope calculation encounters code such as
"friend class X::Y;"
or
"template<> class X<void> {"
it will now reset the additional name component of the scope that is about to be opened.
* Made sure new scope name is reset after being used
2019-08-02 19:55:08 +02:00
Daniel Marjamäki
e66e6549ee
SymbolDatabase: Improved ValueType::matchParameter handling of containers
2019-08-02 15:59:22 +02:00
Daniel Marjamäki
26b0ea52ed
SymbolDatabase: Simplify code
2019-08-02 15:41:18 +02:00
IOBYTE
0d1685cd29
Fix #9178 example with instantiation ( #2059 )
2019-08-02 07:53:39 +02:00
amai2012
29596baa92
Refactoring: Convert enum Direction to enum class
2019-08-01 20:56:02 +02:00
Daniel Marjamäki
7eaa49fd5b
Refactoring SymbolDatabase::findFunction. No functional change is intended.
2019-08-01 17:53:14 +02:00
Daniel Marjamäki
81db8fda18
SymbolDatabase: Code cleanup in findFunction
2019-08-01 17:29:25 +02:00
Daniel Marjamäki
25a13d061c
Refactoring SymbolDatabase::findFunction
2019-08-01 16:14:00 +02:00
Daniel Marjamäki
f95fdd80dd
SymbolDatabase: Refactoring findFunction
2019-08-01 14:30:29 +02:00
Daniel Marjamäki
2a17b897c5
SymbolDatabase: Use ValueType::matchParameter for *var parameters
2019-08-01 13:29:44 +02:00
Daniel Marjamäki
dbddc321e8
SymbolDatabase: Try to match function parameters with unknown types
2019-08-01 13:25:03 +02:00
Rikard Falkeborn
f6726b76ae
Fix 9215 (add tilde for missing destructor override warning) ( #2057 )
2019-08-01 10:43:45 +02:00
amai2012
8a934805ed
Convert InvalidValueType to enum class
2019-07-31 22:56:16 +02:00
amai2012
b0fbbb5aa7
Convert SHOWTIME_MODES to enum class
2019-07-31 22:35:51 +02:00
Daniel Marjamäki
8deb855b41
Fix ValueType::matchParameter for 'const float *' => 'signed long long'
2019-07-31 18:55:55 +02:00
Daniel Marjamäki
91ca6165eb
SymbolDatabase: Use ValueType::matchParameter for expression parameters
2019-07-31 18:35:56 +02:00
Daniel Marjamäki
70ac607a5c
SymbolDatabase: extend usage of ValueType::matchParameter for variable parameters
2019-07-31 18:25:47 +02:00
Daniel Marjamäki
c51f44ce4c
SymbolDatabase: extend usage of ValueType::matchParameter for variable parameters
2019-07-31 18:24:15 +02:00
Daniel Marjamäki
1eb5f2266c
ValueType::matchParameter: Fix matching of char** and void*
2019-07-31 16:23:50 +02:00
Daniel Marjamäki
a3dc2db77a
SymbolDatabase: Use ValueType::matchParameter for variable address parameters
2019-07-31 12:38:36 +02:00
Daniel Marjamäki
039d49bcb1
Improve ValueType::matchParameter for pointers with different types
2019-07-31 12:12:17 +02:00
Daniel Marjamäki
35a3a34632
Revert "SymbolDatabase: Use ValueType::matchParameter"
...
This reverts commit cea00a8e09
.
2019-07-31 12:07:07 +02:00
Daniel Marjamäki
cea00a8e09
SymbolDatabase: Use ValueType::matchParameter
2019-07-31 11:20:43 +02:00
orbitcowboy
a9bdf99e07
std.cfg: Added *experimental* support for math constants liken M_PI. These are *NOT* standard, but they are supported by GCC/Clang and VS.
2019-07-31 11:11:01 +02:00
Daniel Marjamäki
728ac6ae2e
SymbolDatabase: Use ValueType::matchParameter for char literal parameters
2019-07-31 09:35:32 +02:00
rebnridgway
e629f9a90f
Calculate token scopes in advance rather than as the tokenlist is iterated ( #2038 )
...
* Removed redundant scope calculation
* Add scope propagation code to insertToken
* Add relevant scope code to Token class
* Add code to calculate the scope of Tokens
* Add calculateScopes method to class
* Add missing include for shared_ptr
2019-07-31 09:19:27 +02:00
IOBYTE
9436f72a94
Fix daca dnsdist crash ( #2053 )
2019-07-31 09:18:43 +02:00
Daniel Marjamäki
e58e51ee14
SymbolDatabase::findFunction: For string literal, a std::string parameter is a better match than a void* parameter
2019-07-30 21:20:01 +02:00
Daniel Marjamäki
f5c269a191
SymbolDatabase: Use ValueType::matchParameter for string literal parameters
2019-07-30 21:02:35 +02:00
Daniel Marjamäki
d5d50d9b17
ValueType::matchParameter: Improved constness matching
2019-07-30 09:19:51 +02:00
Daniel Marjamäki
914430dede
Appveyor: A quick fix to make Appveyor happy, revert the changes
2019-07-30 07:59:28 +02:00
Daniel Marjamäki
88e3199372
SymbolDatabase: Use ValueType::matchParameter for numeric literal parameters
2019-07-30 07:48:14 +02:00
Daniel Marjamäki
bf219aecde
SymbolDatabase::findFunction: Use ValueType::matchParameter for expression parameters
2019-07-30 07:14:05 +02:00
Daniel Marjamäki
f13b1a0bce
SymbolDatabase: Use ValueType::matchParameter for boolean parameters
2019-07-29 22:58:12 +02:00
Daniel Marjamäki
ed5ae7c5fa
SymbolDatabase::findFunction: Use ValueType::matchParameter for float literal parameters
2019-07-29 21:53:39 +02:00
Daniel Marjamäki
cccbfaa0e4
SymbolDatabase::findFunction: Use getArguments utility function
2019-07-29 21:17:31 +02:00
Daniel Marjamäki
3ad9d6a1ad
Make the code a bit more robust
2019-07-29 20:57:16 +02:00
Daniel Marjamäki
f63011c219
Try to fix daca@home crashes
2019-07-29 19:06:41 +02:00
Daniel Marjamäki
9e738db435
SymbolDatabase: expand usage of ValueType::matchParameter for non-pointer variables
2019-07-29 18:46:50 +02:00
Daniel Marjamäki
3066c0653c
Fixed #8668 (SymbolDatabase: Wrong findFunction match for const pointer argument)
2019-07-29 18:14:23 +02:00
Daniel Marjamäki
607b3daca8
ValueFlow: Improve bailout for structs etc in loops
2019-07-29 15:51:48 +02:00
Daniel Marjamäki
a1214348c0
Fixed #8974 (false negative regression about never used variable)
2019-07-29 08:49:19 +02:00
IOBYTE
07ac6c5f08
Fix ternary operator simplification to accept template parameters. ( #2048 )
...
Also simplify decltype of bool and numeric literals in template
arguments.
2019-07-28 21:52:52 +02:00
IOBYTE
badc573b80
Fix #9224 (Performance regression in template parsing: 250x - 1200x slower) ( #2046 )
2019-07-28 09:25:18 +02:00
Daniel Marjamäki
e8ec6e6f11
Fixed #8349 (Noisy nullPointerRedundantCheck)
2019-07-27 20:03:06 +02:00
Rikard Falkeborn
0324bbf63c
dmake: Fix check of last header file in lib.pri ( #2045 )
...
Since the number of test files is larger than the number of lib files,
this only caused an extra harmless '\' being printed after the last
header file in lib.pri. If the number of test files would have been
smaller than the number of lib files, the generated lib.pri would have
been broken.
2019-07-27 09:45:04 +02:00
Daniel Marjamäki
1c75257212
Token::hasKnownIntValue: Fix when there is one possible int value and one known BUFFER_SIZE value, it should return false.
2019-07-27 08:25:07 +02:00
Rikard Falkeborn
f95d193e22
Fix #8282 (memleak FP when returning std::pair) ( #2039 )
2019-07-26 07:03:58 +02:00
Paul Fultz II
ee28a45db4
Fix issue 9235: new crash in astutils isVariableChanged from endless recursion ( #2040 )
2019-07-26 07:03:21 +02:00
Paul Fultz II
b049fd9303
Improve propogation of lifetimes of function arguments
...
This will now warn for cases like this:
```cpp
int* f(int * x) {
return x;
}
int * g(int x) {
return f(&x);
}
````
2019-07-26 07:02:07 +02:00
Rikard Falkeborn
a69a570505
Fix FP leakVarNotUsed with freopen() and stdin ( #2034 )
...
One usecase for freopen() is to redirect input and output streams to
files. For that, the return value is not needed.
2019-07-25 21:09:23 +02:00
Daniel Marjamäki
9009eeb83d
Tweak Function::isSafe()
2019-07-25 20:52:24 +02:00
Daniel Marjamäki
4611cbb5bb
One more fix for Function::isSafe
2019-07-25 17:31:52 +02:00
Daniel Marjamäki
09be07f2b2
Fix Function::isSafe
2019-07-25 17:28:32 +02:00
Daniel Marjamäki
45d1ca6f7c
Safe checks: Clarify a warning message
2019-07-25 17:19:51 +02:00
Paul Fultz II
744a94ad5a
Fix issue 9231: FP constParameter - argument passed parent ctor ( #2032 )
2019-07-24 20:59:58 +02:00
IOBYTE
999d2f797c
Fix #9225 (Crash on valid C++14 code) ( #2031 )
...
* Fix #9225 (Crash on valid C++14 code)
This only fixes the crash. Specialization of nested templates is still
broken.
* fix cppcheck warnings
* fixed another cppcheck warning
2019-07-24 19:20:19 +02:00
Daniel Marjamäki
bbcffce529
Fixed #9062 (False positive "condition is always true")
2019-07-24 19:16:35 +02:00
Daniel Marjamäki
e11dcc609b
Fixed #7758 (Function array is seen as Uninitialized)
2019-07-24 18:20:23 +02:00
Daniel Marjamäki
7c0b011c05
Fixed #9230 (Improve check: integer conversion overflow in return)
2019-07-24 16:17:52 +02:00
Daniel Marjamäki
2da75d5af4
Split up Cppcheck attribute. low and high values can be specified separately and they can be used for variables also.
2019-07-24 15:08:26 +02:00
versat
641b350cf7
astutils.h: Remove conflicting function declaration for isAliased()
...
This function was made static with commit 6c82685fbf
2019-07-24 13:23:54 +02:00
Daniel Marjamäki
fb7f18ddea
ValueFlow: fix false detection of duplicate values
2019-07-24 12:30:33 +02:00
Daniel Marjamäki
cab9f61b79
safe checks: Handle float parameters
2019-07-24 12:09:13 +02:00
Daniel Marjamäki
e0738c48d2
simplify code
2019-07-24 11:40:51 +02:00
Daniel Marjamäki
10be2a1941
Safe checks: container parameters
2019-07-24 11:39:35 +02:00
Daniel Marjamäki
6c82685fbf
Fixed compiler warnings
2019-07-24 11:01:38 +02:00
Paul Fultz II
bb52a63c4e
Add check for const variables
...
When a local reference is declared, this will check if that local reference can be declared as `const`.
2019-07-24 09:59:01 +02:00
Paul Fultz II
4c3191e577
Lower recursion limit when using asan ( #2013 )
2019-07-24 09:57:53 +02:00
Daniel Marjamäki
753efb4c9b
Function::isSafe: handle global/namespace functions better
2019-07-24 08:23:05 +02:00
Daniel Marjamäki
3ec45acc43
astyle formatting
...
[ci skip]
2019-07-24 08:22:12 +02:00
Paul Fultz II
3ec3bd52e0
Fix FP when using a pointer to a container ( #2029 )
2019-07-24 00:04:49 +02:00
Paul Fultz II
ab0fcc7640
Fix issue 9216: reset() method confusion ( #2025 )
...
* Fix issue 9216 with smart pointer reset
* Check for arrow
2019-07-23 22:45:58 +02:00
Paul Fultz II
60b670babd
Fix issue 9219: False positive, returnDanglingLifetime ( #2026 )
...
* Check for pointer deref for container methods
* Formatting
2019-07-23 21:59:05 +02:00
IOBYTE
5ad5cfcc29
Fix #9217 (Regression: Memory explodes in simplifyTemplateAliases) ( #2021 )
...
* Fix #9217 (Regression: Memory explodes in simplifyTemplateAliases)
* fix use after free when nothing was copied
2019-07-23 21:28:24 +02:00
Daniel Marjamäki
4fb6c27276
Modernize: Use enum class
2019-07-23 14:29:02 +02:00
Daniel Marjamäki
680fbfe612
Fix Cppcheck warning, unused value
2019-07-23 14:10:34 +02:00
Daniel Marjamäki
681bd0a911
GUI: Better settings for extended safe checks
2019-07-23 11:54:38 +02:00
Daniel Marjamäki
74bd2aa680
Use range for loop
2019-07-22 12:24:16 +02:00
Daniel Marjamäki
a81c39af09
Replace 'unsigned' with 'nonneg'
2019-07-22 11:25:51 +02:00
Daniel Marjamäki
7ed3db7b32
astyle formatting
...
[ci skip]
2019-07-22 10:38:17 +02:00
Rikard Falkeborn
8cd1d5a47d
Use library for memleak checks ( #2002 )
...
* Use library for memleak checks
Change memleakOnRealloc and leakReturnValNotUsed to use library
configuration instead of hardcoding "realloc".
In order to do so, some care needs to be taken when matching for a
reallocation function, since it can no longer be assumed that the input
to be allocated is the first argument of the function. This complicates
getReallocationType() and checkReallocUsage() but is necessary in order
to handle for example freopen() properly.
Also, refactor memleakOnRealloc check to reduce duplicated code when
checking "a" and "*a". When doing so, extending the check to look for
arbitrary number of "*" can be done for free (just change an if
statement to a while statement). Most likely, this is an unusual case in
real world code.
* Remove redundant whitespace in Token::Match()
* Run on simplified checks
* Fix cppcheck warning
2019-07-22 10:37:36 +02:00
Rikard Falkeborn
abea580b78
Fix FP memory leak with unknown function call in condition ( #2012 )
...
* Fix FP memory leak with unknown function call in condition
This was introduced in 8513fb81d2
when
fixing memory leaks for global variables allocated in condition. The
refactored code had an inconsistency where c and c++ code behaved
slightly differently when `var` is NULL. This seemed to not have an
impact as the code was written prior to 8513fb81d2
,
but when the same code was used for conditions, FPs were introduced.
The introduced FPs were memleak warnings when there should have been an
information message about missing configurations for code like
void f() {
char *p = malloc(10);
if (set_data(p)) {}
}
Fix this by always returning true if varTok->Variable() is NULL for
both c and c++ code.
* Improve function name
2019-07-18 15:23:19 +02:00
Paul Fultz II
8cd8a2671c
Fix issue 9211: No error on divide by zero outside template instatiation
...
I am not sure how to add a test for this.
2019-07-18 14:55:30 +02:00
Daniel Marjamäki
28e5133f50
Refactoring: Use range for loop
2019-07-18 14:55:01 +02:00
Paul Fultz II
a08a9c1349
Switch to use lifetime analysis for iterators and pointers to invalid containers
...
This will diagnose more issues such as:
```cpp
void f(std::vector<int> &v) {
auto v0 = v.begin();
v.push_back(123);
std::cout << *v0 << std::endl;
}
```
2019-07-18 10:56:44 +02:00
Daniel Marjamäki
421a8da6a8
Try to clarify signConversion message
2019-07-17 22:41:24 +02:00
Daniel Marjamäki
f0aeb845e5
ValueFlow: Clarify warnings when argument min/max values are used
2019-07-17 22:17:34 +02:00
Daniel Marjamäki
d11d6f112e
Detect shadowed arguments
2019-07-17 17:08:42 +02:00
Daniel Marjamäki
0be78bbde6
Rename fileInd to fileIndex
2019-07-17 16:28:47 +02:00
Daniel Marjamäki
90a215af0e
Rephraze performance message. /would be faster/could be faster/ to indicate that Cppcheck is not _sure_ that it would be faster
2019-07-17 16:06:10 +02:00
Daniel Marjamäki
64ef879ebf
Fix syntaxError for struct initialization
2019-07-17 15:21:17 +02:00
Daniel Marjamäki
9973db3a71
Modernize: Use enum class for Library::Action and Library::Yield
2019-07-17 11:39:30 +02:00
Daniel Marjamäki
ec4d68e231
Modernize: use enum class
2019-07-17 10:43:18 +02:00
Daniel Marjamäki
2afd5f5dd0
Modernize: Use enum class
2019-07-17 10:39:06 +02:00
Daniel Marjamäki
b15e6801a4
Replace 'unsigned' with 'nonneg' in tokenizer
2019-07-17 10:36:49 +02:00
Daniel Marjamäki
e9b12b1fe0
Replace 'unsigned' with 'nonneg'
2019-07-17 10:14:25 +02:00
Daniel Marjamäki
e124b31334
Replace 'unsigned' with 'nonneg'
2019-07-17 09:11:42 +02:00
Daniel Marjamäki
c04f31a2c2
Refactoring: Use common function
2019-07-17 09:04:42 +02:00
Daniel Marjamäki
5800692fa1
Move and refactor the CheckMemoryLeak::isclass
2019-07-17 08:59:09 +02:00
Rikard Falkeborn
8513fb81d2
Fix #9206 (FP with global variable allocated in condition) ( #2007 )
2019-07-17 07:43:07 +02:00
Daniel Marjamäki
b3688f22e8
Unknown macro: Detect and warn about unknown macro before throw/return
2019-07-16 20:32:46 +02:00
Daniel Marjamäki
b4a05a3dd0
Refactoring: Use enum class
2019-07-16 11:12:35 +02:00
Daniel Marjamäki
32eda27391
Refactoring: Use enum class
2019-07-16 10:51:26 +02:00
versat
4e89b13adf
checkio.cpp: Fix forgotten "nonneg" change which breaks build
2019-07-16 09:30:36 +02:00
Daniel Marjamäki
7a4a9eba4b
remove cast
2019-07-16 09:28:48 +02:00
Daniel Marjamäki
ef73a10e30
Replace 'unsigned' with 'nonneg' in checkother
2019-07-16 09:10:10 +02:00
Daniel Marjamäki
3637c486c4
Replace 'unsigned' with 'nonneg' in checkclass
2019-07-16 09:03:45 +02:00
Daniel Marjamäki
e877683f01
Replace 'unsigned' with 'nonneg' in checkleakautovar
2019-07-16 08:54:21 +02:00
Daniel Marjamäki
c57d3e069a
Replace 'unsigned' with 'nonneg' in checkfunctions
2019-07-16 08:49:02 +02:00
Daniel Marjamäki
a038ba7dce
replace 'unsigned' with 'nonneg' in checkio
2019-07-16 08:37:26 +02:00
Daniel Marjamäki
5dc4f44091
Replace 'unsigned' with 'nonneg' in checkcondition
2019-07-16 08:21:25 +02:00
Daniel Marjamäki
1888b39314
Use 'nonneg' instead of 'unsigned' in checkbufferoverrun
2019-07-16 07:59:35 +02:00
Daniel Marjamäki
5eff1b0f4a
Replace 'unsigned' with 'nonneg' in checkstl
2019-07-15 14:05:23 +02:00
Daniel Marjamäki
38182bf37b
Replace 'unsigned' with 'nonneg' in valueflow
2019-07-15 13:47:17 +02:00
Daniel Marjamäki
5175bda774
Use 'nonneg' instead of 'unsigned' in checkautovariables
2019-07-15 13:33:29 +02:00
Daniel Marjamäki
4122b2111f
astyle formatting
...
[ci skip]
2019-07-15 12:56:44 +02:00
IOBYTE
6d6bb31926
fix crash in daca gcc-avr from intentional bad instantiation test ( #1994 )
...
* fix crash in daca gcc-avr from intentional bad instantiation test
* fix cppcheck warning
2019-07-15 12:41:06 +02:00
IOBYTE
c2ccfd5f8b
Increase Windows stack size to 8M ( #1998 )
...
* Increase Windows stack size to 8M
* try to add stack size cmake
2019-07-15 12:39:58 +02:00
Daniel Marjamäki
af051a3787
astyle formatting
...
[ci skip]
2019-07-15 09:29:47 +02:00
Denis
68e6a440ff
Fix adding unescaped slash token when splitting gcc case range. ( #1987 )
...
* Fix adding unescaped slash token when splitting gcc case range.
Construction like case '!'...'~' converted to a list of separate case
tokens. When slas '\' symbol appears as a part of this list it was added
"as is", but it should be escaped like '\\' to be valid c++ code.
* Add test for switch-case range with slash
2019-07-15 09:29:31 +02:00
Daniel Marjamäki
aeefaf7004
Travis: Fix one more 'nonneg' issue
2019-07-14 22:49:37 +02:00
Daniel Marjamäki
b30ef3d050
Fix wrong 'nonneg'
2019-07-14 17:31:26 +02:00
Daniel Marjamäki
d2284ddbcd
Fix false positives in self check: Variable t is assigned a value that is never used. Classes with destructors was not handled properly.
2019-07-14 16:20:45 +02:00
Daniel Marjamäki
534659e596
Avoid 'unsigned' in Tokenizer. Use 'nonneg' instead for arguments and members.
2019-07-14 15:48:20 +02:00
Daniel Marjamäki
0014fe880e
Mark members and arguments with 'nonneg'
2019-07-14 12:22:33 +02:00
Daniel Marjamäki
36d7e8a361
Add 'nonneg' macro
2019-07-14 11:40:44 +02:00
Daniel Marjamäki
1cadd9398a
Fixed #8933 (false negative: (style) Variable is assigned a value that is never used (std::string))
2019-07-14 09:44:30 +02:00
Daniel Marjamäki
cf06acae08
Fixed #5995 (False negative selfAssignment regression from 1.65)
2019-07-13 21:45:54 +02:00
Daniel Marjamäki
49dd2deef1
Avoid 'unsigned' in ctu
2019-07-13 20:31:50 +02:00
Daniel Marjamäki
e489d9a40f
Fix bug. Used wrong ValueType in smart pointer handling
2019-07-13 20:29:15 +02:00
Daniel Marjamäki
5d853bcb58
Avoid 'unsigned' in astutils
2019-07-13 16:13:21 +02:00
Daniel Marjamäki
316537a837
Avoid 'unsigned' for int variables
2019-07-13 16:06:24 +02:00
Daniel Marjamäki
cff462c6ef
Token deleteNext/deletePrevious parameters
2019-07-13 15:47:53 +02:00
Daniel Marjamäki
bf9edc00c2
Fix compiler errors
2019-07-13 15:42:36 +02:00
Daniel Marjamäki
f5e76a2d18
Avoid 'unsigned' when declaring int variables in checkuninitvar
2019-07-13 15:31:17 +02:00
Daniel Marjamäki
794d25fcf5
Avoid 'unsigned' when declaring int variables in Platform
2019-07-13 15:23:59 +02:00
IOBYTE
526a86dc60
Fix recursiveCount in CheckLeakAutoVar to really be recursive count. ( #1988 )
2019-07-13 07:40:24 +02:00
Scott Furry
61dcf10b6c
Edit Change lib/errorlogger.h ( #1992 )
...
Shortening extremely long lines in file to improve readability.
2019-07-13 07:19:12 +02:00
Daniel Marjamäki
37d407641d
Avoid 'unsigned' types. line number.
2019-07-13 06:27:40 +02:00
Daniel Marjamäki
ae933c20c7
Fixed #1765 (Improve check: delete not handled well when there are extra parentheses)
2019-07-12 18:25:20 +02:00
Daniel Marjamäki
8ad3e43f92
Add handling of a simple C++ contract
2019-07-12 16:05:35 +02:00
Daniel Marjamäki
68cc7516a1
Annotations: Add annotation __cppcheck_in_range__(low,high)
2019-07-12 11:09:54 +02:00
IOBYTE
74e3114a64
Fix #9097 (Crash on thousands of "else ifs"s in gcc-avr package) ( #1982 )
...
* Fix #9097 (Crash on thousands of "else ifs"s in gcc-avr package)
* increase recursion count maximum to 512 because cppcheck was hitting the 256 limit
* 512 was too much for windows
2019-07-12 07:56:05 +02:00
Daniel Marjamäki
783f7f1648
Rename safeValues to unknownValues
2019-07-11 16:05:48 +02:00
IOBYTE
9700490e51
fix lib/checkclass.cpp:51:12: warning: enumeration value ‘eLambda’ not handled in switch [-Wswitch] ( #1978 )
2019-07-11 08:25:25 +02:00
Daniel Marjamäki
a9d61c4ddd
Fix Cppcheck warning
2019-07-10 22:08:27 +02:00
Daniel Marjamäki
5f217021ab
Another attempt to fix appveyor
2019-07-10 21:30:50 +02:00
Daniel Marjamäki
45844ef962
Try to fix appveyor. Replace int64_t with MathLib::bigint.
2019-07-10 21:26:20 +02:00
Daniel Marjamäki
05d35b063d
Function return: Extra check of safe function return values
2019-07-10 20:00:21 +02:00
Daniel Marjamäki
c9906125de
Safe functions: Check more possible function argument values
2019-07-10 16:59:05 +02:00