Commit Graph

19515 Commits

Author SHA1 Message Date
Paul Fultz II 34330b51d1 Fix issue 8905: Condition 'a==0' is always false
This fixes the FP in:

```cpp
void f(const int a[]){ if (a == 0){} }
```
2018-12-18 08:16:43 +01:00
IOBYTE 1cba78090c Fix const anonymous struct. (#1527) 2018-12-18 08:15:12 +01:00
Daniel Marjamäki 0f63874c62 Take back the whole program analysis for null pointers and uninitialized variables 2018-12-18 07:56:33 +01:00
Daniel Marjamäki 643ddd4caa Code cleanup 2018-12-17 18:54:32 +01:00
Daniel Marjamäki 3b328f9187 CheckMemoryLeak: Cleanup the old memory leaks check 2018-12-17 18:12:50 +01:00
Daniel Marjamäki f118c22bb6 CheckUnusedVar: Cleanup checker 2018-12-17 17:48:45 +01:00
Daniel Marjamäki cf09fd6274 CheckUnusedVar: Code cleanup 2018-12-17 17:28:15 +01:00
orbitcowboy 9290122c2f wxwidgets.cfg: Added support for WX_DEFINE_ARRAY_PTR. 2018-12-17 16:58:56 +01:00
orbitcowboy 0221ec3fc2 wxwidgets.cfg: Added some wxLocal defintions. 2018-12-17 16:50:21 +01:00
Daniel Marjamäki fe38e256cc Fixed #7907 (FN: redundant assignment inside switchcase, overwritten by assignment outside of switch) 2018-12-17 16:10:47 +01:00
orbitcowboy 4558fd5a2c Merge branch 'master' of https://github.com/danmar/cppcheck 2018-12-17 15:49:03 +01:00
orbitcowboy a382657128 wxwidgets.cfg: Improved support for some defintions from wxGrid. 2018-12-17 15:48:26 +01:00
Daniel Marjamäki bf4e850e11 Fixed #4475 (New check: struct member is assigned a value that is not read) 2018-12-17 15:40:15 +01:00
Daniel Marjamäki 858d9a18a7 Fixed #3857 (false negative: (style) Variable 'var' is assigned a value that is never used) 2018-12-17 15:16:47 +01:00
orbitcowboy 8195a76035 wxwidgets.cfg: Added support for definitions from wx/defs.h 2018-12-17 14:08:53 +01:00
orbitcowboy 0fc62128f6 wxwidgets.cfg: Added support for definitions from wx/colour.h 2018-12-17 13:56:34 +01:00
orbitcowboy 04ffba3a8b wxwidgets.cfg: Added support for definitions from wx/artprov.h 2018-12-17 13:53:01 +01:00
orbitcowboy 548e529bfc wxwidgets.cfg: Added support for more constants from wx/defs.h. 2018-12-17 13:35:33 +01:00
orbitcowboy aba57e46c2 wxwidgets.cfg: Improved support for defines from wxDialog. 2018-12-17 13:19:58 +01:00
orbitcowboy ad29421c33 wxwidgets.cfg: EVT_SASH_DRAGGED_RANGE takes three arguments. 2018-12-17 09:23:50 +01:00
orbitcowboy 3473b6e5a8 wxwidgets.cfg: EVT_GRID_CMD_CELL_CHANGED requires two arguments. 2018-12-17 09:09:59 +01:00
orbitcowboy 7d8b60dcb9 wxwidgets.cfg: Improved support for some event table macros. 2018-12-17 09:01:47 +01:00
Paul Fultz II 025881cf35 Fix issue 8829: Condition '...' is always true (int buf[42]; if(buf != NULL){})
This makes arrays non-null in valueflow, so it can catch comparisons against null that is always true:

```cpp
void f(void) {
   int buf[42];
   if( buf != 0) {;} // << always true
}
```
2018-12-17 06:07:34 +01:00
Paul Fultz II 9b973e652c Issue 8830: New check: Function argument evaluates to constant value
Add a check for function arguments that can be constant:

```cpp
extern void bar(int);
void f(int x) {
   bar((x & 0x01) >> 7); // function 'bar' is always called with a '0'-argument
}
```
2018-12-17 06:04:24 +01:00
IOBYTE 2090866cd0 template simplifier: remove explicit instantiations after instantiation (#1523)
* template simplifier: remove explicit instantiations after instantiation

* Fix use after free crash in clang test suite.
2018-12-17 05:58:48 +01:00
Daniel Marjamäki 357e2fbfb3 Add testcase for #8807 (False negative: Redundant variable assignments (loop)) 2018-12-16 21:45:26 +01:00
Daniel Marjamäki c8d688607a Fixed #8901 (Unused value: const variable initialization) 2018-12-16 19:01:05 +01:00
Daniel Marjamäki 21eb1c5e22 FwdAnalysis: Fix false negatives for struct members 2018-12-16 18:32:34 +01:00
orbitcowboy 30220fa7fc wxwidgets.cfg: Added more constants from wx/gdicmn.h 2018-12-16 17:29:45 +01:00
Daniel Marjamäki 46a0172480 FwdAnalysis: fix FP in loop 2018-12-16 16:43:04 +01:00
orbitcowboy 152df1bf00 wxWidgets.cfg: Addd more definitions from multiple wxWidgets-classes. 2018-12-16 15:31:06 +01:00
orbitcowboy 60bfa3dfc0 wxwidgets.cfg: Added support for more macro defintions from various wxWidgets-classes. 2018-12-16 15:08:50 +01:00
orbitcowboy 44b545b1c5 wxwidgets.cfg: Added support for more macro defintions from various wxWidgets-classes. 2018-12-16 14:39:24 +01:00
Daniel Marjamäki 97d2075007 FwdAnalysis: better handling of loops 2018-12-16 11:42:11 +01:00
Daniel Marjamäki 3af0d73f82 Unused value: Fixed false negatives for loops 2018-12-16 11:18:37 +01:00
Paul Fultz II 3262a3bebe Add isSameExpression to valueflow analysis
Check for same expressions in valueflow analysis.
2018-12-16 07:35:27 +01:00
Paul Fultz II 45dcfad9f9 Fix issue 8899: False positive returnDanglingLifetime when returning by value
This fixes the FP from:

```cpp
#include <string>

class MyString
{
        public:
        MyString(char* source)
        {
                length = strlen( source );
                buffer = new char[length+1];
                if( buffer )
                {
                        strcpy( buffer, source );
                }
        }

        char* buffer;
        int length;
};

MyString Foo()
{
        char arr[20];
        sprintf(arr, "hello world");

        return arr;
}

void main()
{
        MyString str = Foo();

        printf(str.buffer);
}
```
2018-12-15 17:58:45 +01:00
Daniel Marjamäki 1bfe98447a FwdAnalysis: Tweak possiblyAliased 2018-12-15 11:54:00 +01:00
orbitcowboy 9dd00a8066 wxwidgets.cfg: Added more definitions from wx/defs.h 2018-12-15 10:48:36 +01:00
Daniel Marjamäki f26549e5ab Fixed #8896 (Tokenizer: Anonymous struct) 2018-12-15 08:42:35 +01:00
IOBYTE a1c275436f Fix #8902 (Crash in TemplateSimplifier) (#1521) 2018-12-15 07:52:47 +01:00
orbitcowboy fbcb0d55d4 wxwidgets.cfg: Improved support for more predefined values from wx/defs.h 2018-12-14 21:29:41 +01:00
orbitcowboy 9fdb1b1675 wxwidgets.cfg: Improved support for more predefined values from wx/defs.h 2018-12-14 20:54:54 +01:00
orbitcowboy f961aa9eca wxwidgets.cfg: Improved support for more predefined values from wx/defs.h 2018-12-14 20:48:03 +01:00
orbitcowboy 994366c284 wxwidgets.cfg: Improved support for some defines from wx/defs.h 2018-12-14 20:00:30 +01:00
orbitcowboy 179c652e49 wxwidgets.cfg: Improved support for some wxGauge functions. 2018-12-14 19:49:01 +01:00
orbitcowboy 4bc19d269c wxwidgets.cfg: improved support for some GDI constants. 2018-12-14 19:39:34 +01:00
Daniel Marjamäki 37416010ef Unused value: Fix false positive (ast, {}) 2018-12-14 18:56:09 +01:00
Paul Fultz II be6782d386 Fix FP 8891: Incorrect return scope when using uniform initialization
This fixes the FP in:

```cpp

std::string f(const std::string& data)
{
  if (data.empty())
    return {};

  data[0];
}
```
2018-12-14 18:31:10 +01:00
orbitcowboy 888490fe6c wxwidgets.cfg: Improved support for wxAboutDialogInfo functions. 2018-12-14 15:36:03 +01:00