Commit Graph

10796 Commits

Author SHA1 Message Date
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
IOBYTE 9569fa1374 Partial fix for #9191 (simplifyTypedef: Problem when namespace is used) (#1952)
* Partial fix for #9191 (simplifyTypedef: Problem when namespace is used)

This fixes simplifyUsing which has the same problem as simplifyTypedef.

simplifyUsing was designed to support using namespace but it was never
implemented. The changes are minor to add it.

simplifyTypedef requires much more work to support using namespace.

* reduce scope of variable

* make idx const
2019-07-06 20:22:13 +02:00
PKEuS ae86536128 Updated to Visual Studio 2019 2019-07-06 12:11:19 +02:00
Paul Fultz II 65af02f0cf Fix crash with lambda capture (#1960) 2019-07-06 10:46:17 +02:00
versat 57d44f1362 astyle formatting
[ci skip]
2019-07-05 14:00:59 +02:00
Rikard Falkeborn 839fcddd8a Fix #6115 (Add support to realloc to cfg files) (#1953)
* Allow to configure realloc like functions

* memleakonrealloc: Bring back tests.

The old memleak checker was removed, and the tests for it was removed in
commit 9765a2dfab. This also removed the
tests for memleakOnRealloc. Bring back those tests, somewhat modified
since the checker no longer checks for memory leaks.

* Add realloc to mem leak check

* Add tests of realloc buffer size

* Configure realloc functions

* Add test of freopen

* Allow to configure which element is realloc argument

* Fix wrong close in test

cppcheck now warns for this

* Update manual

* Update docs

* Rename alloc/dalloc/realloc functions

Naming the member function realloc caused problems on appveyor. Rename
the alloc and dealloc functions as well for consistency.

* Change comparisson order

* Remove variable and use function call directly

* Create temporary variable to simplify

* Throw mismatchError on mismatching allocation/reallocation

* Refactor to separate function

* Fix potential nullptr dereference

As pointed out by cppcheck.
2019-07-05 12:44:52 +02:00
Paul Fultz II e0ced1c415 Parse lambdas as functions (#1955)
* Parse lambdas as functions

* Fix issue with missing paren

* Fix error when parsing non-existent args

* Remove unused function variable
2019-07-05 12:30:42 +02:00
Rikard Falkeborn 2a17e624d9 Overlapping sprintf, improve handling of casts (#1945)
* Overlapping sprintf, improve handling of casts

If there is a cast of the argument buffer, cppcheck would print out the
expression including the cast, which looks a bit strange to talk about

    Variable (char*)buf is used as...

Instead, only print the variable name without the cast.

Also, handle arbitrary many casts (the previous code only handled one).
Multiple casts of the input arguments is probably an unusual case in
real code, but can perhaps occur if macros are used.

* Fix printing of variable

... and add a test.

* Simplify testcase
2019-07-05 12:27:39 +02:00
Paul Fultz II 5801fb26f0 Fix syntax error with lambda captures (#1954)
* Fix syntax error with lambda captures

* Fix issue when using initializer in lambdas
2019-07-05 12:26:01 +02:00
shaneasd 7e54f989f9 Update symbol database such that the override keyword implies that the function is also virtual (#1907)
* Update symbol database such that the override keyword implies that the function is also virtual

* Add test case for implicit override

* change isVirtual to hasVirtualSpecifier

* fix method documentation for getVirtualFunctionCalls and getFirstVirtualFunctionCallStack

* Fix isImplicitlyVirtual to consider the override keyword and document logic

* Fix getFirstVirtualFunctionCallStack and getVirtualFunctionCalls to use isImplicitlyVirtual instead of isVirtual so new test case passes
2019-07-04 12:32:32 +02:00
Rikard Falkeborn 60a213e6a5 Fix #9047 (c-style casts before malloc) (#1930)
* Fix #9047 (c-style casts before malloc)

Note that there are still no warnings for c++-style casts

* Fix memleak check with casts of assignments in if-statements

* Fix possible null pointer dereference

As pointed out by cppcheck.

* Add check of astOperand2 when removing casts

This is similar to how it is done in other checks.
2019-07-03 08:39:44 +02:00
IOBYTE c4933acb5a Fixed #9147(SymbolDatabase bailout: unhandled code) (#1948)
* Fixed #9147(SymbolDatabase bailout: unhandled code)

* add test for #9183
2019-07-03 08:35:48 +02:00
Daniel Marjamäki f84dcc4738 astyle formatting
[ci skip]
2019-07-03 08:29:47 +02:00
Paul Fultz II 8f4cb36e1e Check for more garbage code (#1949)
* Check for garbage commas

* Find garbage dot operator
2019-07-03 08:28:24 +02:00
Ken-Patrick d6f6e68fa2 Fix false positive 9167 (#1904)
Skip returns from local class/struct definition in FwdAnalysis.
2019-07-03 08:17:06 +02:00