Paul Fultz II
4e147a4c59
Add a check for duplicate if statements
...
This will warn for this:
```cpp
int f(int val)
{
int i = 0;
if( val & 0xff)
i = 1;
if( val & 0xff)
i = 1;
return i;
}
```
2019-01-09 20:41:01 +01:00
Daniel Marjamäki
35e56942d1
Fixed #8116 ([False positive] Invalid memory leak detection when using reference.)
2019-01-09 20:38:32 +01:00
Daniel Marjamäki
75e367c48b
Fixed #8340 (incorrect memleak errors)
2019-01-09 19:50:41 +01:00
ivangalkin
5ddc6c64d7
CheckStl: add missing error ID iterators2 ( #1576 )
...
due to equal arguments...
* iterators1 (`CheckStl::iteratorsError(const Token*, const std::string&, const std::string&)`) and
* iterators2 (`CheckStl::iteratorsError(const Token*, const Token*, const std::string&, const std::string&)`)
... produced equal messages. Equal messages were filtered-out `CppCheck::reportErr(const ErrorLogger::ErrorMessage&)`.
So the error iterators2 disapeared from the error list.
2019-01-09 06:45:38 +01:00
Daniel Marjamäki
0f9ce5edd5
Fixed #8365 (False positive on memory leak when assigned inside if statement)
2019-01-08 20:54:39 +01:00
Daniel Marjamäki
e4525d56a0
Fixed #8111 (performance warning - member variable at constructor)
2019-01-07 21:26:58 +01:00
IOBYTE
07da4b4d37
template simplifier: Add flag variable to cache information about dec… ( #1569 )
...
* template simplifier: Add flag variable to cache information about declarations.
Also fix some cppcheck warnings.
* Make variable const.
2019-01-07 06:55:22 +01:00
practicalswift
0a1b3a9d6f
Fix typos ( #1568 )
2019-01-06 17:15:57 +01:00
Daniel Marjamäki
5636497c0b
Fixed #8863 (false positive: (warning) Accessing an item in container 's'. Either the condition 's.empty()' is redundant or 's' can be empty.)
2019-01-06 12:21:55 +01:00
Daniel Marjamäki
ea0232653f
Fixed #8563 (CPPCheck not able to locate file through compilation database)
2019-01-05 23:11:43 +01:00
IOBYTE
817c748e4d
Fixed #5953 (debug: varid0: Function::addArguments) ( #1567 )
2019-01-05 19:42:04 +01:00
Daniel Marjamäki
36ffa91825
Replace std::set::emplace with std::set::insert to make Cppcheck compilable in Slackware 14.0
2019-01-05 18:18:15 +01:00
Daniel Marjamäki
5f5c33baf2
Json: Use simple json library picojson to read compile databases
2019-01-05 17:45:07 +01:00
Daniel Marjamäki
615903c6be
Improve syntax errors for unmatched (){}[]
2019-01-05 11:56:21 +01:00
IOBYTE
32a5d66e5b
Fixed #8927 (SIGSEGV below TemplateSimplifier::expandTemplate) ( #1564 )
2019-01-05 11:14:09 +01:00
Paul Fultz II
bba6dfb8b2
Fix issue 4744: ValueFlow: known integer result
...
This fixes valueflow to have a value for `||` operator here:
```cpp
bool f()
{
bool a = (4 == 3); // <-- 0
bool b = (3 == 3); // <-- 1
return a || b; // <-- 1
}
```
2019-01-03 07:05:31 +01:00
Daniel Marjamäki
2b63997c2c
Fixed #8928 (false positive: (style) Variable 'x' is assigned a value that is never used.)
2019-01-02 20:23:02 +01:00
Daniel Marjamäki
39ceb53578
Comment out code in valueFlowArray. There was too many false positives.
2019-01-02 19:57:11 +01:00
Daniel Marjamäki
39a96a5a16
ValueFlow: Temporarily comment out valueFlowTerminatingCondition
2019-01-02 19:42:08 +01:00
Daniel Marjamäki
7a40b85531
Fixed #8906 (Encoding error in XML message: info attribute)
2019-01-02 18:22:12 +01:00
amai2012
af639e9848
#7772 Add uninitMemberVarPrivate to errorlist ( #1557 )
2019-01-02 18:08:39 +01:00
Daniel Marjamäki
236c88151f
Fixed #8926 (false positive: (style) Condition 's.x<=y' is always true)
2019-01-02 18:05:55 +01:00
IOBYTE
3b9828a132
template simplifier: fix crash on daca c++-annotations project ( #1556 )
...
Fix scope info bug on derived template class which caused a use after
free crash when deleting a template forward declaration in a different
scope.
2019-01-02 07:15:45 +01:00
Daniel Marjamäki
19514331fb
Fixed #8907 (unknown macro not detected)
2019-01-01 19:30:13 +01:00
Daniel Marjamäki
115be7dfc8
ValueFlow: better FwdAnalysis for complex expressions
2019-01-01 18:23:47 +01:00
Daniel Marjamäki
be7afac875
ValueFlow: remove handling of == for complex expressions it did not work properly
2019-01-01 17:23:46 +01:00
Daniel Marjamäki
20436ea986
Fix compiler warning
2019-01-01 17:04:47 +01:00
rikardfalkeborn
13ffefc8b8
Valueflow: Fix right shift with more than 31 bits ( #1553 )
...
When comparing if the shift is large enough to make the result zero, use
an unsigned long long to make sure the result fits. Also, a check that
avoids setting the value if the shift is equal to or larger than the
number of bits in the operand (this is undefined behaviour). Finally,
add a check to make sure the calculated value is not too large to store.
Add test cases to cover this.
This was detected by an MSVC warning.
valueflow.cpp(1350): warning C4334: '<<' : result of 32-bit shift implicitly
converted to 64 bits (was 64-bit shift intended?)
2019-01-01 14:15:50 +01:00
Daniel Marjamäki
a73e989d1a
isConstVarExpression: Fix FPs when there is C++ cast
2019-01-01 11:34:44 +01:00
Daniel Marjamäki
04d3672bde
Fixed #7203 (Better syntax error, handle array declaration with @)
2019-01-01 09:45:41 +01:00
IOBYTE
c37b807613
template simplifier: also check if instantiated template is not specialized ( #1551 )
2018-12-31 21:29:53 +01:00
Daniel Marjamäki
ac357a96f7
Fixed #7384 (confuses syntax with variable name / "variable '(' is less than zero")
2018-12-31 18:36:06 +01:00
Daniel Marjamäki
ed514644b8
Renamed FwdAnalysisAllPaths to FwdAnalysis
2018-12-31 18:00:47 +01:00
Daniel Marjamäki
4918a18bfb
ValueFlow: Value of expression after condition
2018-12-31 17:37:38 +01:00
IOBYTE
9dc8faa3b6
template simplifier: fix location of forward declaration for explicit specializations ( #1550 )
2018-12-31 17:19:34 +01:00
Daniel Marjamäki
141ce7cd63
ValueFlow: Use FwdAnalysisAllPaths in ValueFlow to track complex expressions
2018-12-31 17:05:46 +01:00
Daniel Marjamäki
fd8f599802
CTU: Use column in function id
2018-12-31 10:18:28 +01:00
Daniel Marjamäki
aa4f61acdf
CTU: Avoid FP in else block
2018-12-31 08:24:39 +01:00
Daniel Marjamäki
fb6a291370
CTU: Avoid FP in code protected by &&,||,?
2018-12-31 08:16:21 +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
37a3544ff5
CheckNullPointer: Try to report all CTU issues not just the first found issue
2018-12-31 07:52:14 +01:00
Daniel Marjamäki
5cc61e55f9
CTU: Refactoring; Use ValueFlow::Value::errorSeverity
2018-12-31 07:50:02 +01:00
amai2012
f2d7cb3ab6
Fix VS compiler warning and add a const
2018-12-30 22:17:21 +01:00
IOBYTE
36dfa0f27a
template simplifier: refactor to use cached information ( #1548 )
...
* use already cached name token rather than recalculating it
multiple times
* cache end of template parameters token and use it rather than
recalculating it multiple times
* remove unnecessary end of template token and name token checks
* remove function parameter that is already contained in another
parameter
2018-12-30 21:16:11 +01:00
Daniel Marjamäki
6b49a784c5
Fixed #8911 (Regression: False positive: Unassigned variable (alias))
2018-12-30 20:20:20 +01:00
amai2012
73fa941352
Doxygen fixes
2018-12-30 19:31:50 +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
b3fcd8a685
astyle formatting
...
[ci skip]
2018-12-30 11:59:06 +01:00
Daniel Marjamäki
378e083585
CTU: Refactoring the xml load/write. Renamed members.
2018-12-30 11:55:39 +01:00