Commit Graph

11184 Commits

Author SHA1 Message Date
Paul Fultz II a5c6ae1e08 Fix issue 9400: FP returnTempReference - triggered by cast (#2259) 2019-10-10 06:52:11 +02:00
Daniel Marjamäki 0c1e979af7 SymbolDatabase: Refactor handling of variable declarations in if condition 2019-10-09 22:27:48 +02:00
Daniel Marjamäki 5b9bc4918e ExprEngine: Better error output when solver fails 2019-10-09 22:16:30 +02:00
Daniel Marjamäki 63bd182e83 ExprEngine: Adapt to z3 handling of bool/int expressions 2019-10-09 20:18:17 +02:00
Daniel Marjamäki 9f4db5018d SymbolDatabase: Added testcase for variable in if-scope 2019-10-09 16:41:07 +02:00
Daniel Marjamäki 3776604f06 SymbolDatabase: Add variable in if condition 'if (auto x = bar())' 2019-10-09 15:55:54 +02:00
Daniel Marjamäki 273a1a7402 ExprEngine: Fix FP for 'int' overflows 2019-10-09 11:24:57 +02:00
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