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
Daniel Marjamäki
9f548efbd3
Refactoring: enum class
2019-07-10 15:27:07 +02:00
Daniel Marjamäki
95d65c8c34
Refactoring; enum class
2019-07-10 14:05:16 +02:00
Rikard Falkeborn
a1a14b8465
Fix FP with cast pointer to free() ( #1961 )
...
This fixes false positives when the pointer passed to free() (or similar
deallocation functions) is cast using a c-style cast.
2019-07-10 09:13:59 +02:00
Daniel Marjamäki
58076bc672
SymbolDatabase: Better handling of smart pointers
2019-07-09 17:32:19 +02:00
IOBYTE
a05dfc9150
fix daca codeblocks crash ( #1968 )
...
* fix daca codeblocks crash
* fix the cause of the missing scope
2019-07-09 16:04:22 +02:00
Daniel Marjamäki
862c4ef87b
Symboldatabase: Fix possible null pointer dereference if smart pointer type does not have a scope
2019-07-08 17:43:45 +02:00
Daniel Marjamäki
a0b22410cf
SymbolDatabase: Better handling of smart pointers
2019-07-07 21:52:49 +02:00
IOBYTE
e551057f59
Refactor Tokenizer::simplifyUsing to use continue to reduce indentation ( #1967 )
...
* Refactor Tokenizer::simplifyUsing to use continue to reduce indentation
added function findTemplateDeclarationEnd to skip template declarations
to reduce duplicate code
* fix travis build
2019-07-07 18:33:33 +02:00
IOBYTE
c902c5f688
Fix #9197 (Template name cache: Assertion `tok && tok->str() == ">"' failed.) ( #1964 )
2019-07-07 10:20:43 +02:00
Paul Fultz II
b0d10273ed
Fix issue 3695: Handle class pointers
...
This switches to use lifetime analysis to check for assigning to non-local variables:
```cpp
class test
{
public:
void f()
{
int x;
this->ptr = &x;
}
protected:
int *ptr;
};
```
2019-07-07 10:16:19 +02:00