Sebastian
b7e48a9b27
Fix #9399 (Build Failure on x86: error: unknown type name '__int128_t') ( #2254 )
...
https://stackoverflow.com/questions/16088282/is-there-a-128-bit-integer-in-gcc
suggests to test for __SIZEOF_INT128__. This test is added now and
Cppcheck now also compiles for a 32 bit target with the expected
warning that there is no 128-bit integer. "make test" also works.
2019-10-09 10:25:21 +02:00
Daniel Marjamäki
ab6354754f
ExprEngine: Catch z3::exception and print message
2019-10-09 09:42:18 +02:00
Daniel Marjamäki
c04e25e936
Revert " #9391 Detecting uninited member variables with default ctor ( #2249 )"
...
This reverts commit 08bc369296
.
2019-10-09 08:17:47 +02:00
Daniel Marjamäki
b27fe83da4
ExprEngine: Handle << and >>
2019-10-08 21:38:10 +02:00
Daniel Marjamäki
3e50150dbf
ExprEngine: Fix the checking for integer overflows
2019-10-08 20:13:25 +02:00
blacktea
08bc369296
#9391 Detecting uninited member variables with default ctor ( #2249 )
2019-10-08 19:33:07 +02:00
IOBYTE
c98732dd8b
fix using type aliases in out of class destructors ( #2250 )
2019-10-08 19:30:41 +02:00
Daniel Marjamäki
1abf70a7cb
SymbolDatabase: Add null pointer check for ast operand for '(' token
2019-10-08 17:53:29 +02:00
Steve Mokris
506a952ad2
Parse `extern "C"`, and use it to avoid FP reference warnings ( #2234 )
...
Previously, cppcheck discarded the `extern "C"` specifier. This patch modifies cppcheck to parse each as a Scope in the symbol database, then uses that scope to avoid false positives when making recommendations about changing a function argument to be a reference (since variable references is a C++ feature, unavailable in C, and thus unavailable in `extern "C"`).
2019-10-08 17:48:09 +02:00
Daniel Marjamäki
9f40341ba8
SymbolDatabase: Hardcoded handling for std::make_shared and std::make_unique , todo: library configuration would be better than hard coding
2019-10-08 17:19:24 +02:00
Daniel Marjamäki
79356b1883
SymbolDatabase: Better ValueType handling of 'LibraryType(..)'
2019-10-08 11:25:05 +02:00
Paul Fultz II
4eb4762d95
Extend lifetime checking to temporaries ( #2242 )
...
* Use lifetimes to check for returning reference to temporaries
* Check for dangling temporaries
* Check for unknown types for returining by reference
* Remove old returnTemporary check
* Format
* Check for deref op
* Ternary operator return an lvalue reference
* Warn when returning temporaries from member functions
* Improve handling of pointer to function
* Extend lifetimes of const references
2019-10-08 09:28:39 +02:00
Daniel Marjamäki
21774cbdc4
ExprEngine: Handle while/for loops
2019-10-07 17:45:06 +02:00
Daniel Marjamäki
d82b1b29ce
ExprEngine: Initial handling of switch
2019-10-06 19:58:51 +02:00
Daniel Marjamäki
05aae9569b
ExprEngine: Execute false execution path even if there is no else, upon Z3 exception assume that value is in range (safe option)
2019-10-06 18:26:40 +02:00
Daniel Marjamäki
6c0c9ba6d3
ExprEngine: Handle 'break' and 'while (0);'
2019-10-06 17:43:30 +02:00
Daniel Marjamäki
dcf8a7213f
ExprEngine: ExprData::getConstraintExpr
2019-10-06 14:47:50 +02:00
IOBYTE
78b9fd9bb9
Fix #9383 ("debug: Function::addArguments found argument 'x' with varid 0." with variadic templates) ( #2238 )
2019-10-06 12:45:42 +02:00
Daniel Marjamäki
3c085fd88a
Fixed #9359 (SymbolDatabase: function lookup fails when -funsigned-char is used)
2019-10-06 12:05:58 +02:00
Tyson Nottingham
0950a97df2
Fix false negatives in checkBitwiseOnBoolean ( #2220 )
...
* Fix false negatives in checkBitwiseOnBoolean
Use AST-based tests in favor of token-based tests for greater coverage.
* Travis: add suppressions for bitwiseOnBool
2019-10-06 09:57:31 +02:00
Daniel Marjamäki
b97436e8f8
Fixed #9382 (Hang: CheckLeakAutoVar pellepl/spiffs/src/spiffs_hydrogen.c)
2019-10-06 09:52:05 +02:00
IOBYTE
8f46bb3ef6
fix #9392 (SymbolDatabase: Weird default constructor outside class) ( #2243 )
2019-10-06 07:21:12 +02:00
Daniel Marjamäki
7294145797
SymbolDatabase: set value type for std::move()
2019-10-05 19:57:52 +02:00
Daniel Marjamäki
4e525e52ec
ExprEngine: Avoid endless recursion for struct members that have struct type
2019-10-05 18:29:41 +02:00
Daniel Marjamäki
e686699294
ExprEngine: Fix ExprEngin::IntRange::isIntValueInRange
2019-10-05 16:33:40 +02:00
Daniel Marjamäki
954e98cc03
astyle formatting
...
[ci skip]
2019-10-05 16:32:43 +02:00
Paul Fultz II
cf1c766292
Fix issue 9317: False positive returnDanglingLifetime when using reference to constant inside if statement ( #2241 )
2019-10-05 16:32:20 +02:00
Paul Fultz II
6b6553e320
Dont warn for arrays that are containers ( #2240 )
2019-10-05 16:14:30 +02:00
IOBYTE
46f3f58e5f
Fix #9388 ("debug: Executable scope 'x' with unknown function." with alias used in initialization list) ( #2239 )
2019-10-05 09:34:37 +02:00
Daniel Marjamäki
fcccd5f42e
ExprEngine: Small tweaks
2019-10-04 17:58:18 +02:00
IOBYTE
c32a568c1f
fix #8965 ("(debug) Executable scope 'x' with unknown function." with rvalue parameter in method) ( #2237 )
...
I fixed the AST enough to pass testrunner but I don't believe it is
correct.
This code:
void Foo4(int&&b);
has this AST:
( 'void'
|-Foo4
`-&& 'bool'
|-int
`-b 'signed int'
but I don't believe && should have `bool`.
2019-10-04 12:30:11 +02:00
IOBYTE
50d82763fc
Fix #9385 ("debug: Executable scope 'func' with unknown function" with parameter in member function) ( #2235 )
2019-10-03 21:13:03 +02:00
Daniel Marjamäki
f80d387374
ExprEngine: Arrays if-then-else
2019-10-03 20:16:06 +02:00
Daniel Marjamäki
555890fdfa
ExprEngine: Removed NullPointerDereference checker for now.
2019-10-03 19:24:14 +02:00
IOBYTE
3e17c24dd8
fix syntax error on template operator ( #2225 )
2019-10-03 12:26:45 +02:00
Paul Fultz II
997803869d
Forward values after assignment in valueFlowReverse ( #2226 )
...
* Forward values after assignment in valueFlowReverse
* Rename variables
* Format
2019-10-03 09:58:57 +02:00
Daniel Marjamäki
b79283306f
ExprEngine: Rename Data::conditions => Data::constraints
2019-10-03 08:48:05 +02:00
Daniel Marjamäki
d916379f9f
ExprEngine: Better handling of if/else
2019-10-02 21:47:00 +02:00
Daniel Marjamäki
7ab22c7176
ExprEngine: Use smt solver Z3
2019-10-02 17:59:04 +02:00
IOBYTE
4ba00d0694
Fix #9381 (alias in namespace not replaced in method declaration) ( #2232 )
2019-10-02 08:11:04 +02:00
Daniel Marjamäki
cf965b72b5
SymbolDatabase: look for functions in anonymous namespaces in the findFunction
2019-10-01 19:09:34 +02:00
Daniel Marjamäki
07b337c580
Removed extra zero division heuristics, they seem redundant as ValueType is used
2019-10-01 17:33:58 +02:00
orbitcowboy
f05e21efa8
Formatted the code, there are no functional changes [ci skip].
2019-10-01 08:39:08 +02:00
Paul Fultz II
166bd2bafc
Fix issue 2153: valueFlowAfterCondition: struct member ( #2228 )
...
* Fix issue 2153: valueFlowAfterCondition: struct member
* Fix null pointer dereference
* Formatting
* Check for another null pointer
* Initialize variables
* Remove redundant condition
* Format
* Add missing initialization to copy constructor
* Format
2019-09-30 21:04:43 +02:00
Armin Müller
b4af8bdc2e
Typos found by running "codespell" ( #2227 )
2019-09-29 21:23:19 +02:00
Daniel Marjamäki
1ccc303602
ExprEngine: Simplify array value if possible, ensure each array data has a unique name
2019-09-29 21:20:57 +02:00
Daniel Marjamäki
03ff32993e
Fixed Cppcheck warning
2019-09-29 17:32:26 +02:00
Daniel Marjamäki
1979b64170
ExprEngine: Bailout when for|while|switch is seen
2019-09-29 17:28:12 +02:00
Daniel Marjamäki
69a54b0ee9
Library: added 'stdtype' attribute in <podtype> element so we can configure standard types better
2019-09-29 16:48:25 +02:00
Daniel Marjamäki
40c3e68e07
ExprEngine: Add --debug-verify, fixed handling of global arrays
2019-09-29 15:00:54 +02:00
Daniel Marjamäki
60e1cf8b8d
ExprEngine: Fix NULL pointer dereference tests
2019-09-29 08:26:09 +02:00
Daniel Marjamäki
2dc477571c
Fix gcc compiler warnings
2019-09-28 20:50:56 +02:00
Oliver Stöneberg
1fa4df419a
avoid some unnecessary copies in emplace_back() calls ( #2194 )
2019-09-28 20:22:46 +02:00
Daniel Marjamäki
3f587bef65
ExprEngine: Add some CWE476 (Null pointer dereference) checks
2019-09-28 19:28:12 +02:00
Daniel Marjamäki
1acd78a038
ExprEngine: Translate uninitialized values to value ranges
2019-09-28 16:16:36 +02:00
Daniel Marjamäki
2e5d663ae9
ExprEngine: Handle void* -> int* casts better
2019-09-28 15:40:00 +02:00
Daniel Marjamäki
4138bf7fb3
SymbolDatabase: Better handling when return type of function is PodType
2019-09-28 14:57:41 +02:00
Daniel Marjamäki
f6c0550c41
ExprEngine: Do not bailout if function type is not known if the result is not used anyway
2019-09-28 11:55:06 +02:00
Daniel Marjamäki
b2239f04ba
ExprEngine: Improve 'division by zero' warning
2019-09-28 11:03:20 +02:00
Daniel Marjamäki
0de3e76b2d
ExprEngine: Clarify when analysis is aborted
2019-09-28 10:59:28 +02:00
Daniel Marjamäki
a3cad7fa51
Fix Coverity warning CID 1405837; negative bit shift
2019-09-28 06:34:51 +02:00
SimonCornell1
6453a85363
Fix the following compilation error on VC142 : ( #2224 )
...
Error C2039 'inserter': is not a member of 'std' cppcheck C:\Users\simon\__Si\git_projects\cppcheck\lib\astutils.cpp 1229
2019-09-28 06:24:32 +02:00
Daniel Marjamäki
8b8701d078
ExprEngine: Cleanup output when variable declaration and initialization is separated
2019-09-27 21:03:47 +02:00
Daniel Marjamäki
398cfc1f5a
ExprEngine: Create array value in struct
2019-09-27 18:58:49 +02:00
Daniel Marjamäki
2b4fe66908
Try to make Travis happy
2019-09-27 16:13:43 +02:00
Daniel Marjamäki
f7a8075001
ExprEngine: Disable integerOverflow check
2019-09-27 15:07:56 +02:00
Daniel Marjamäki
7ea8b69235
ExprEngine: Robustness
2019-09-27 14:36:33 +02:00
Daniel Marjamäki
69016e38bc
ExprEngine: Add a temporary overflow check
2019-09-27 14:20:17 +02:00
Daniel Marjamäki
8ccbdfe725
ExprEngine: Better output
2019-09-27 13:30:09 +02:00
Daniel Marjamäki
71aa9a531a
ExprEngine: Create symbolic expression for string arguments
2019-09-27 13:12:16 +02:00
Daniel Marjamäki
7f64faae99
Virtual Destructors: Base class must have virtual destructor no matter if derived class has a destructor or not. There is UB according to paragraph 3 in [expr.delete].
2019-09-27 09:55:56 +02:00
Rikard Falkeborn
0111b4afdc
Silence unused variable warning ( #2223 )
2019-09-27 08:19:45 +02:00
Daniel Marjamäki
350363616c
Fix Cppcheck naming convention
2019-09-27 08:17:46 +02:00
Daniel Marjamäki
dffae8f7d9
Try to make Travis happy
2019-09-26 21:43:29 +02:00
Daniel Marjamäki
371babc322
ExprEngine: Improved handling of structs
2019-09-26 21:35:29 +02:00
Daniel Marjamäki
f47aaed21e
ExprEngine: Improve output
2019-09-26 21:00:36 +02:00
Daniel Marjamäki
f1b42fe05c
ExprEngine: Extend output
2019-09-26 20:49:03 +02:00
Daniel Marjamäki
2e1cbbeb14
ExprEngine: Fix output for StructValue
2019-09-26 19:39:30 +02:00
IOBYTE
d0968a1377
Warn about unknown macro causing template syntax error ( #2222 )
2019-09-26 16:01:01 +02:00
Daniel Marjamäki
cd816f42eb
ExprEngine: fix code for float comparisons
2019-09-26 12:13:14 +02:00
Daniel Marjamäki
b55c587ab2
astyle formatting
...
[ci skip]
2019-09-26 10:32:49 +02:00
Paul Fultz II
597d0fa35b
Support expression in valueFlowAfterCondition ( #2219 )
...
* Add valueFlowForwardExpression function to forward values of an expression
* Use token for expression
* Fix name in bailout message
* Handle expressions
* Add more tests for more expressions
* Add more tests
* Solve the expression if possible
* Formatting
2019-09-26 10:32:25 +02:00
IOBYTE
4475c4c7e2
template simplifier: fix syntax error ( #2218 )
2019-09-26 10:31:19 +02:00
Daniel Marjamäki
d7d22f51b7
ExprEngine: Minor output cleanup
2019-09-26 10:07:31 +02:00
Daniel Marjamäki
c5302d20a3
ExprEngine: ConditionalValues, output symbolic expressions
2019-09-26 10:03:58 +02:00
Rikard Falkeborn
4dbf006dc7
Fix severity of c++14 shifts with too many bits ( #2213 )
...
For c++14, shifting a variable with a value larger than or equal to the
number of bits in the variable is undefined. Left-shifting with a value
equal to the number of bits of the variable is implementation defined.
See also trac ticket #9306 .
2019-09-25 20:16:04 +02:00
Daniel Marjamäki
9e76630a4b
ExprEngine: Restructure handling of arrays to handle dynamic buffers better
2019-09-25 18:33:21 +02:00
Oliver Stöneberg
eac040a00b
Various clang-tidy fixes ( #2192 )
...
* use range loops
* removed redundant string initializations
* use nullptr
* use proper boolean false
* removed unnecessary continue from end of loop
* removed unnecessary c_str() usage
* use emplace_back()
* removed redundant void arguments
2019-09-25 15:25:19 +02:00
Tyson Nottingham
ca5f2562fc
Fix false negatives in checkIncrementBoolean ( #2210 )
...
Detect incrementing boolean expressions involving pointer dereferences,
array element accesses, etc.
2019-09-25 13:07:39 +02:00
IOBYTE
12f93b63a8
template simplifier: fix simplification of "< %num% %comp% %num% >" ( #2214 )
...
* template simplifier: fix simplification of "< %num% %comp% %num% >"
* fix test to not fail on 32 bit platforms
2019-09-25 12:06:29 +02:00
Daniel Marjamäki
0011fb5a36
ExprEngine: Temporary hardcoding for calloc
2019-09-24 22:22:16 +02:00
Daniel Marjamäki
7cf8327b31
ExprEngine: Sign extension in truncateValue
2019-09-24 20:31:12 +02:00
Daniel Marjamäki
0471e74489
ExprEngine: Handle char literals
2019-09-24 20:11:07 +02:00
Daniel Marjamäki
1769af4a6c
ExprEngine: Passing variable address to function
2019-09-24 19:53:33 +02:00
Daniel Marjamäki
ba035074f0
ExprEngine: Extended value truncation
2019-09-24 13:28:14 +02:00
Paul Fultz II
0df4876059
Fix issue 9367: FP knownConditionTrueFalse ( #2209 )
2019-09-24 08:15:03 +02:00
Daniel Marjamäki
c1ff3419a6
ExprEngine: Value truncation
2019-09-23 20:28:12 +02:00
Paul Fultz II
1616282f6b
Use fixed number of iterations for valueflow loop ( #2205 )
2019-09-23 19:35:39 +02:00
Daniel Marjamäki
9025b47f82
ExprEngine: some handling of NULL pointer
2019-09-23 18:10:06 +02:00
Paul Fultz II
a903aa7070
Fix issue 9351: false negative: (style) Condition '...' is always true ( #2201 )
2019-09-23 08:49:04 +02:00
Rikard Falkeborn
bb5ac32872
Fix #7031 (improve error message for memory related warnings) ( #2204 )
...
Printout both the locations on double free errors, mismatching
alloc/dealloc and dealloc return error.
2019-09-22 21:50:02 +02:00
Daniel Marjamäki
28d13e7567
ExprEngine: Implement basic float handling
2019-09-22 21:14:36 +02:00
Rikard Falkeborn
df800e35d4
Fix memleak FP with return with parenthesis ( #2202 )
...
* Fix memleak FP with return with parenthesis
Fix FPs pointed out by daca@home on the following form:
void* f(void) {
void* x = malloc(1);
return(x);
}
Fix it by only skipping tokens if there is an actual match with a
variable. This allows to remove the special casing of "return;".
* Add testcase with cast
2019-09-22 19:18:31 +02:00
Daniel Marjamäki
6e17853ea9
ExprEngine: Guess function call return value
2019-09-22 16:40:48 +02:00
Daniel Marjamäki
5c07cfd2e8
ExprEngine: Better handling of pointer aliasing
2019-09-22 15:58:55 +02:00
Daniel Marjamäki
ec4b7c1f4b
ExprEngine: Better handling of pointers
2019-09-22 10:56:57 +02:00
Daniel Marjamäki
7d6fd915be
ExprEngine: Better handling of compound assignments
2019-09-21 21:15:51 +02:00
Paul Fultz II
c1961cec1c
Fix issue 9362: FP: (style) Condition '(v&1)==0' is always false ( #2200 )
2019-09-21 19:53:54 +02:00
Daniel Marjamäki
da91c139d5
ExprEngine: Passing array to function, array data might be overwritten
2019-09-21 19:34:06 +02:00
Rikard Falkeborn
46ac0d79c1
Checkmemleakautovar: fix crash and FP ( #2196 )
...
This fixes crashes found by daca where valueType() is NULL. Also,
somewhat related, it removes warnings when casting to a type that is
unknown to cppcheck, for example, there is no longer a warning for the
following code:
void* f() {
void *x = malloc(1);
return (mytype)x;
}
2019-09-21 14:59:54 +02:00
Daniel Marjamäki
b2cab003ff
ExprEngine: Fix output for arrays
2019-09-21 14:17:16 +02:00
Daniel Marjamäki
3d0d3ec4c5
ExprEngine: handling array initialization with string literal
2019-09-21 11:36:34 +02:00
Tyson Nottingham
d6a70d27c7
Fix false negatives in checkAssignBoolToFloat and minor related improvements ( #2198 )
...
* Fix false negatives in checkAssignBoolToFloat
Detect assignments to expressions involving pointer dereferences, array
element accesses, etc.
* Pass assignment token to assignBoolToFloatError
Pass assignment token rather than boolean token to make error reporting
consistent between checkAssignBoolToFloat and checkAssignBoolToPointer,
as well as with other assignment checks in the code base.
* Make checkAssignBoolToPointer check consistent with checkAssignBoolToFloat
2019-09-21 08:24:54 +02:00
Paul Fultz II
40f1635c35
Fix issue 9361: false positive: (style) Condition 'isdigit(c)!=0' is always true ( #2199 )
2019-09-21 08:19:54 +02:00
Oliver Stöneberg
65d1e90aa3
deleted methods should be public ( #2193 )
2019-09-20 21:58:09 +02:00
Oliver Stöneberg
b5c598cca4
added missing OVERRIDE usage and removed redundant virtual ( #2190 )
2019-09-20 21:57:16 +02:00
Oliver Stöneberg
9028b4a81d
do not access static methods through instance ( #2189 )
2019-09-20 21:54:30 +02:00
Ken-Patrick Lehrmann
49b7ef84d9
Fix crashes in checkleakautovar ( #2195 )
...
Crashes found by daca@home
http://cppcheck1.osuosl.org:8000/crash.html
For instance
```
2019-09-20 16:27
ftp://ftp.se.debian.org/debian/pool/main/n/nedit/nedit_5.7.orig.tar.gz
cppcheck-options: -j1 --library=posix --library=gnu --library=motif -D__GNUC__ --check-library --inconclusive --enable=style,information --platform=unix64 --template=daca2 -rp=temp temp
platform: Linux-4.19.0-6-amd64-x86_64-with-debian-10.1
python: 2.7.16
client-version: 1.1.37
cppcheck: head 1.89
head-info: 38dec6a9a
(2019-09-20 16:46:57 +0200)
count: Crash! 934
elapsed-time: -11.0 9.0
head results:
Checking temp/nedit-5.7/source/shell.c: __GNUC__=1...
Program received signal SIGSEGV, Segmentation fault.
0x000055555564b862 in CheckLeakAutoVar::ret (this=0x7fffffffb8c0, tok=0x5555582ea9e0, varInfo=...) at lib/token.h:340
340 return mImpl->mValueType;
#0 0x000055555564b862 in CheckLeakAutoVar::ret (this=0x7fffffffb8c0, tok=0x5555582ea9e0, varInfo=...) at lib/token.h:340
#1 0x0000555555651764 in CheckLeakAutoVar::check (this=0x7fffffffb8c0) at build/checkleakautovar.cpp:714
#2 0x0000555555652b37 in CheckLeakAutoVar::runChecks (this=<optimized out>, tokenizer=0x7fffffffc3a0, settings=<optimized out>, errorLogger=<optimized out>) at lib/checkleakautovar.h:108
#3 0x00005555556bc833 in CppCheck::checkNormalTokens (this=0x7fffffffce50, tokenizer=...) at build/cppcheck.cpp:732
#4 0x00005555556bf694 in CppCheck::checkFile (this=0x7fffffffce50, filename=..., cfgname=..., fileStream=...) at build/cppcheck.cpp:542
#5 0x00005555556c1cb8 in CppCheck::check (this=this@entry=0x7fffffffce50, path="temp/nedit-5.7/source/shell.c") at /usr/include/c++/8/bits/basic_string.h:936
#6 0x00005555557fd63f in CppCheckExecutor::check_internal (this=0x7fffffffdbd0, cppcheck=..., argv=<optimized out>) at cli/cppcheckexecutor.cpp:884
#7 0x00005555557fda92 in CppCheckExecutor::check (this=this@entry=0x7fffffffdbd0, argc=argc@entry=14, argv=argv@entry=0x7fffffffdf58) at cli/cppcheckexecutor.cpp:198
#8 0x00005555555e6358 in main (argc=14, argv=0x7fffffffdf58) at cli/main.cpp:95
DONE
```
2019-09-20 21:29:17 +02:00
Daniel Marjamäki
6c59957109
ExprEngine: Better handling of conditions
2019-09-20 21:27:51 +02:00
Rikard Falkeborn
007b5d3e8d
Fix #9343 (memleak FP when return with cast) ( #2162 )
...
This was most likely introduced when the checks were changed to run on
the full tokenlist instead of the simplified one.
Take care to warn about cases where casts destroy the pointer, such as
uint8_t f() {
void* x = malloc(1);
return (uint8_t)x;
}
2019-09-20 15:09:27 +02:00
Daniel Marjamäki
049f6475ee
astyle formatting
...
[ci skip]
2019-09-20 15:07:27 +02:00
Paul Fultz II
ad8abdb0c3
Add impossible values to ValueFlow ( #2186 )
...
* Add impossible category
* Replace values
* Try to adjust known values
* Add ! for impossible values
* Add impossible with possible values
* Remove contradictions
* Add values when the branch is not dead
* Only copy possible values
* Dont bail on while loops
* Load std lib in valueflow
* Check for function calls
* Fix stl errors
* Fix incorrect impossible check
* Fix heap-after-use error
* Remove impossible values when they are lowered
* Show the bound and remove overlaps
* Infer conditions
* Dont push pointer values through dynamic_cast
* Add test for dynamic_cast issue
* Add shifttoomanybits test
* Add test for div by zero
* Add a test for issue 9315
* Dont make impossible value inconclusive
* Fix FP with shift operator
* Improve handleKnownValuesInLoop for impossible values
* Fix cppcheck warning
* Fix impossible values for ctu
* Bailout for streams
* Check equality conditions
* Fix overflows
* Add regression test for 9332
* Remove duplicate conditions
* Skip impossible values for invalid value
* Check for null
* Rename bound to range
* Formatting
2019-09-20 15:06:37 +02:00
IOBYTE
8c5cf8c029
Fixed #9046 syntaxError ( #2180 )
...
* Fixed #9046 syntaxError
* fix another syntax error
* fix some more syntax errors
2019-09-20 12:35:01 +02:00
Daniel Marjamäki
8fba2af267
Try to make Travis happy
2019-09-20 07:04:58 +02:00
Daniel Marjamäki
6c38b69e11
Rename dataIndex to mDataIndex according to our naming conventions
2019-09-20 06:12:35 +02:00
Oliver Stöneberg
de9f489b08
use range loops / constness ( #2181 )
...
* use range loops / constness
* platform.cpp: avoid shadowed variable
2019-09-19 20:29:33 +02:00
Daniel Marjamäki
5f0f8afc27
ExprEngine: Print some 'debug' output
2019-09-19 20:18:55 +02:00
Sebastian
bf55e835aa
Windows testrunner: Add testexprengine.cpp ( #2184 )
...
Add export of executeAllFunctions() in exprengine.h
2019-09-19 19:40:00 +02:00
Daniel Marjamäki
745c91106e
Removed unused Data::dump
2019-09-19 09:16:18 +02:00
orbitcowboy
b37b0c0f78
Running astyle [ci skip]
2019-09-19 08:03:29 +02:00
amai2012
d97c826319
Compile fix for VisualStudio
2019-09-18 22:07:42 +02:00
amai2012
5355df8b6e
Add exprengine.cpp to VisualStudio solution
2019-09-18 21:56:31 +02:00
amai2012
5a6084fbec
Map #warning to #pragma message for VisualStudio
2019-09-18 21:50:23 +02:00
Daniel Marjamäki
b66d701599
Fix Cppcheck warnings
2019-09-17 22:28:36 +02:00
Daniel Marjamäki
2d651b09fc
ExprEngine: Add new experimental path-sensitive data flow analysis. Initially used for 'verification' but could possibly later be used as a complement in the normal analysis. The code is work-in-progress and hacky!
2019-09-17 21:00:59 +02:00
Daniel Marjamäki
033640310b
One more fix for #9354 (Unknown macro is not reported and then Cppcheck is silent about issues)
2019-09-15 21:07:20 +02:00
Daniel Marjamäki
742c437953
Fixed #9354 (Unknown macro is not reported and then Cppcheck is silent about issues)
2019-09-13 13:05:48 +02:00
Paul Fultz II
068b0b246c
Fix issue 9352: FP constParameter and constVariable for auto& in combination with ternary ?: operator ( #2173 )
2019-09-13 08:33:30 +02:00
Daniel Marjamäki
fc25fe83bd
ctu: fixed error locations
2019-09-12 19:20:13 +02:00
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
Daniel Marjamäki
b8e3d3b982
CTU: Add 'column'
2019-09-12 10:46:33 +02:00
Daniel Marjamäki
8855978f8a
Import project: Ignoring paths better
2019-09-12 09:32:24 +02:00
IOBYTE
4e222afa2c
template simplifier: ignore alias template definitions with syntax errors ( #2169 )
...
Is not allowed to define a type in an alias template definition.
This code:
template<int N>
using A1 = struct B1 { static auto constexpr value = N; };
A1<0> a1;
produces this output:
2: } ;
3: struct B1 { static const auto value = 0 a1 ;
test.cpp:2:57: error: Analysis failed. If the code is valid then please
report this failure. [cppcheckError]
using A1 = struct B1 { static auto constexpr value = N; };
^
because it tries to instantiate the invalid alias template definition
and generates garbage code.
2019-09-11 19:31:15 +02:00
Paul Fultz II
ba037837c9
Track lifetime across multiple returns
...
This will now warn when doing something like this:
```cpp
template <class T, class K, class V>
const V& get_default(const T& t, const K& k, const V& v) {
auto it = t.find(k);
if (it == t.end()) return v;
return it->second;
}
const int& bar(const std::unordered_map<int, int>& m, int k) {
auto x = 0;
return get_default(m, k, x);
}
```
The lifetime warning is considered inconclusive in this case.
I also updated valueflow to no tinject inconclusive values unless `--inconclusive` flag is passed. This creates some false negatives because library functions are not configured to not modify their input parameters, and there are some checks that do not check if the value is inconclusive or not.
2019-09-11 19:25:09 +02:00
warmsocks
a56bc006b7
Fixed a typo in lib/checkother.cpp. Corrected spelling errors found by codespell. ( #2170 )
2019-09-11 19:21:38 +02:00
Daniel Marjamäki
bee30b0ca2
astyle formatting
...
[ci skip]
2019-09-10 19:42:17 +02:00
Paul Fultz II
dc0b3527ad
Fix issue 9311: False positive duplicateCondition "same if condition" with pointer inside array of struct ( #2166 )
...
* Check for typeOf through an array
* Handle array constructors
* Format
* Fix compile error on gcc 4.8
2019-09-10 19:41:35 +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
Paul Fultz II
ddb1f1b5ce
Try to fix issue 9341: daca crash: isContainerSizeChangedByFunction ( #2168 )
2019-09-10 19:39:44 +02:00