Commit Graph

443 Commits

Author SHA1 Message Date
Daniel Marjamäki 15d7b9c83f Fixed #9347 (FP uninitvar for pointer passed to sscanf) 2019-10-17 17:41:54 +02:00
Daniel Marjamäki da363c7d6f Fixed #9349 (FP ctuuninitvar for pointer dereferenced inside sizeof) 2019-09-12 13:29:52 +02:00
Paul Fultz II 2595b82634 Fix issue 9348: FP uninitvar for pointer passed to memcpy (#2167) 2019-09-10 19:40:08 +02:00
Sebastian 4a119640c5 #8755: Add regression test (#2160)
* #8755: Add regression test

https://trac.cppcheck.net/ticket/8755
False negative: uninitvar not detected

* Fixed formatting (runastyle)
2019-09-09 17:20:03 +02:00
Paul Fultz II 1afd56e964 Fix issue 8785: ValueFlow: Track pointer alias
This fixes the issue by making `ProgramMemory` keep track of values based on the conditions.

It also removes the `deadpointer` check since it duplicates the `invalidLifetime` check.
2019-09-03 17:16:15 +02:00
Paul Fultz II 55a78f482b Fix issue 9293: false negative: uninitvar 2019-09-03 06:46:34 +02:00
Daniel Marjamäki 7d63bdee6f astyle formatting
[ci skip]
2019-09-02 06:59:07 +02:00
Ken-Patrick Lehrmann 7a75aa084b Fix crash in CheckUninitVar (#2129)
http://cppcheck.osuosl.org:8000/ycmd
```
2019-08-30 23:21
ftp://ftp.se.debian.org/debian/pool/main/y/ycmd/ycmd_0+20181101+git600f54d.orig.tar.gz
cppcheck-options: -j1 --library=posix --library=gnu --library=qt --library=python --library=googletest --library=boost -D__GNUC__ --check-library --inconclusive --enable=style,information --platform=unix64 --template=daca2 -rp=temp temp
platform: Linux-4.15.0-58-generic-x86_64-with-Ubuntu-18.04-bionic
python: 2.7.15+
client-version: 1.1.31
cppcheck: head 1.88
count: Crash! 83
elapsed-time: -11.0 61.2
head results:
Checking temp/ycmd-0+20181101+git600f54d/ycmd/tests/clang/testdata/completion_fixit.cc: __GNUC__=1...

Program received signal SIGSEGV, Segmentation fault.
CheckUninitVar::valueFlowUninit (this=this@entry=0x7fffffffb350) at build/checkuninitvar.cpp:2376
2376	            if (!tok->variable())
 #0  CheckUninitVar::valueFlowUninit (this=this@entry=0x7fffffffb350) at build/checkuninitvar.cpp:2376
 #1  0x00005555556901ac in CheckUninitVar::runChecks (this=<optimized out>, tokenizer=0x7fffffffbcb0, settings=0x7fffffffcd10, errorLogger=<optimized out>) at lib/checkuninitvar.h:68
 #2  0x00005555556a2210 in CppCheck::checkNormalTokens (this=this@entry=0x7fffffffcaf0, tokenizer=...) at build/cppcheck.cpp:730
 #3  0x00005555556a6ee2 in CppCheck::checkFile (this=this@entry=0x7fffffffcaf0, filename="temp/ycmd-0+20181101+git600f54d/ycmd/tests/clang/testdata/completion_fixit.cc", cfgname="", fileStream=...) at build/cppcheck.cpp:540
 #4  0x00005555556aad4c in CppCheck::check (this=this@entry=0x7fffffffcaf0, path="temp/ycmd-0+20181101+git600f54d/ycmd/tests/clang/testdata/completion_fixit.cc") at build/cppcheck.cpp:195
 #5  0x00005555557ef167 in CppCheckExecutor::check_internal (this=this@entry=0x7fffffffd880, cppcheck=..., argv=argv@entry=0x7fffffffdc08) at cli/cppcheckexecutor.cpp:884
 #6  0x00005555557efa9a in CppCheckExecutor::check (this=0x7fffffffd880, argc=17, argv=0x7fffffffdc08) at cli/cppcheckexecutor.cpp:198
 #7  0x00005555555b1d1b in main (argc=17, argv=0x7fffffffdc08) at cli/main.cpp:95
```
2019-09-01 14:51:40 +02:00
Paul Fultz II 0b9e823fc8 Fix issue 9305: False positive uninitvar - struct initialized via function (#2123) 2019-08-30 18:32:45 +02:00
Paul Fultz II 2942be53f7 Add more tests for valueFlowUninit (#2124) 2019-08-30 08:41:17 +02:00
Paul Fultz II 03fe6795bf Fix issue 9302: FP uninitvar - struct accessed via pointer (#2121) 2019-08-29 08:38:50 +02:00
amai2012 1538248922 Fix syntax in test code example 2019-08-26 20:45:14 +02:00
Daniel Marjamäki 9d26be8380 Fixed #5259 (Improve check: Uninitialized variable not reported when used in array initialization) 2019-08-24 14:43:35 +02:00
Paul Fultz II 5c488b9519 Fix issue 9190: FP uninitvar for struct member (#2112)
* Fix issue 9190: FP uninitvar for struct member

* Add more test cases

* Fix false negative
2019-08-24 11:27:47 +02:00
Daniel Marjamäki 35fb55d76c Fixed #5259 (Improve check: Uninitialized variable not reported when used in array initialization) 2019-08-24 08:01:55 +02:00
Paul Fultz II c0a8d628b9 Fix issue 6010: Uninitialized inner struct (#2098)
* Fix issue 6010: Uninitialized inner struct

* Show to root variable that is unitialized

* Warn on pointer dereferences
2019-08-23 06:23:20 +02:00
Paul Fultz II 1f747d0b14 Add regression test for 9281 (#2097) 2019-08-19 09:09: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 3aef0c9bd3 Fix issue 8715: regression uninitvar not detected (#2092) 2019-08-16 07:48:54 +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
Daniel Marjamäki e11dcc609b Fixed #7758 (Function array is seen as Uninitialized) 2019-07-24 18:20:23 +02:00
Rikard Falkeborn 06337cedf5 Run more tests on full token list (#2020)
Since all checks are run on the full token list and not the simplified
one, run the tests on the full token list as well.
2019-07-22 10:26:55 +02:00
Daniel Marjamäki 7ca35d181b uninitStructMember: Fixed FP shown in daca@home 2019-06-02 20:19:53 +02:00
Daniel Marjamäki b9ac77a31b Uninitialized variables: Fixed false positive 2019-03-09 11:30:45 +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
Daniel Marjamäki 8a3b73ffdb Do not write extra uninitvar warnings 2019-03-02 13:17:15 +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
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
Daniel Marjamäki 6ca1aba4a7 UninitVar: Fix --experimental-fast issues 2019-02-10 19:00:01 +01:00
Daniel Marjamäki bd7790fd8c Update copyright year 2019-02-09 07:24:06 +01:00
Daniel Marjamäki 8dd641b8be Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
Daniel Marjamäki c8901e9bab CTU: Find paths better 2018-12-30 16:23:25 +01:00
Daniel Marjamäki 271763e680 CTU: Refactoring 2018-12-25 21:11:23 +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
Simon Martin 915acac0b8 Ticket #8734: Skip static member variables in CheckUninitVar. (#1388) 2018-09-22 16:52:34 +02:00
Daniel Marjamäki fc97a5b11c Uninitalized variables: Fixed false positive 2018-08-15 18:04:36 +02:00
IOBYTE ce50df8047 Fix override warnings. (#1234) 2018-05-15 16:37:40 +02:00
Daniel Marjamäki 26e36a1d6b Fix FP uninitvar when stream bool operator is used 2018-04-18 16:13:24 +02:00
Daniel Marjamäki c84628c28a Fixed #8494 (False positive: serialization class overloads operator) 2018-04-17 14:23:04 +02:00
Daniel Marjamäki 58066b1f0c Remove whole program analysis from 'uninitialized variables' and 'null pointer dereference' checkers. I think this logic can more or less be added in ValueFlow instead and then all ValueFlow checkers should get whole program analysis. 2018-02-06 14:56:17 +01:00
Daniel Marjamäki dbc6771a0b Uninitialized variables: Fix FP for unknown macro like 'list_for_each' 2018-02-04 22:30:08 +01:00
Daniel Marjamäki d47b7726fa Uninitialized variables: Fix potential false positives in subfunction if there is early return or conditional writes 2018-02-04 09:40:57 +01:00
Daniel Marjamäki 9109956c8c UninitVar: Improve whole program analysis, used isVariableUsage() 2018-01-25 21:49:21 +01:00
Daniel Marjamäki f73da16e94 Revert "UninitVar: Better checking in whole program analysis"
This reverts commit b2bdc2687b.
2018-01-25 17:05:57 +01:00
Daniel Marjamäki b2bdc2687b UninitVar: Better checking in whole program analysis 2018-01-25 15:56:46 +01:00
Daniel Marjamäki ce60b326f4 Whole program analysis: Improved handling of nested calls 2018-01-24 22:53:14 +01:00
Daniel Marjamäki 100887429d Uninitialized variables: Whole program analysis for function calls 2018-01-15 15:54:09 +01:00
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +01:00