Commit Graph

493 Commits

Author SHA1 Message Date
Daniel Marjamäki 4e076e1854 Fix travis build 2019-09-12 19:06:57 +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 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 005765a561 Clarify valueFlowUninit (#2136)
https://github.com/danmar/cppcheck/pull/2129#issuecomment-526916467
2019-09-02 06:50:56 +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
Daniel Marjamäki 0dfda5eb4a Try to make Travis happy 2019-08-24 15:43:31 +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
versat 50c6af5e5d astyle formatting
[ci skip]
2019-08-23 10:19:29 +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 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
amai2012 f02636e995 Refactoring: Convert enums to enum classes 2019-08-02 21:14:29 +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 0014fe880e Mark members and arguments with 'nonneg' 2019-07-14 12:22:33 +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 95d65c8c34 Refactoring; enum class 2019-07-10 14:05:16 +02:00
Daniel Marjamäki 7ca35d181b uninitStructMember: Fixed FP shown in daca@home 2019-06-02 20:19:53 +02:00
Daniel Marjamäki 15fc9a622d CheckBufferOverrun: Add CTU analysis 2019-03-23 08:36:10 +01: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
Sebastian 6228ea2266
checkuninitvar.cpp: Use argument direction info from library config. (#1728)
CheckUninitVar::isMemberVariableAssignment uses argument direction
to check for assignment when the member variable is handed over to a
function by reference. Currently implemented for "in" direction. "out"
will be added with another commit.
2019-03-06 19:26:38 +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 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 c75a2265c0 Fix inline suppression. 2019-01-13 12:10:26 +01:00
Daniel Marjamäki a520a41e64 CheckUninitVar: Try to report all CTU issues not just the first found issue 2018-12-31 07:54:00 +01:00
Daniel Marjamäki 91a580cbd7 CTU: more warnings 2018-12-30 18:31:37 +01:00
Daniel Marjamäki c8901e9bab CTU: Find paths better 2018-12-30 16:23:25 +01:00
Daniel Marjamäki 378e083585 CTU: Refactoring the xml load/write. Renamed members. 2018-12-30 11:55:39 +01:00
Daniel Marjamäki d18f5d8709 CTU: Reuse CheckNullPointer::isPointerDeRef in the nullpointer isUnsafeUsage 2018-12-29 09:26:57 +01:00
Daniel Marjamäki a788512d66 CTU: Refactor isUnsafeFunction 2018-12-26 19:17:49 +01:00
Daniel Marjamäki a6e227a73c CTU: Refactoring; getErrorPath 2018-12-26 15:56:10 +01:00
Daniel Marjamäki e39be48c92 CTU: Refactoring, create ErrorPath in ctu 2018-12-26 11:36:26 +01:00
Daniel Marjamäki 271763e680 CTU: Refactoring 2018-12-25 21:11:23 +01:00
Daniel Marjamäki a1dca6acd5 Fix CTU nullpointer check 2018-12-25 12:04:01 +01:00
Daniel Marjamäki c7993df4ff Refactoring; Use range for loops 2018-12-25 11:47:45 +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
Paul Fultz II 54453c5802 Fix FP when copying pointer to string (#1479) 2018-11-14 06:59:25 +01:00
Daniel Marjamäki be1ff268c0 Refactoring: Use range for loops 2018-10-24 11:29:15 +02: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