Paul Fultz II
941dd79f0d
Fix FP issue 8986: constArgument check warns for elements of const array ( #1683 )
2019-02-22 06:39:59 +01:00
Daniel Marjamäki
bd7790fd8c
Update copyright year
2019-02-09 07:24:06 +01:00
Paul Fultz II
d7c20b15e7
Fix FP with const argument when doing a variable and cast ( #1649 )
2019-02-07 14:59:09 +01:00
Daniel Marjamäki
8c07be136a
Fixed #8949 (False Positive: Variable 'f' is assigned a value that is never used.)
2019-01-22 21:16:27 +01:00
Daniel Marjamäki
d50c3de740
Remove inline suppression and fix false positive.
2019-01-13 07:59:41 +01:00
Daniel Marjamäki
2b1b8f8fe9
Fix Cppcheck warnings
...
[ci skip]
2019-01-12 18:29:08 +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
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
236c88151f
Fixed #8926 (false positive: (style) Condition 's.x<=y' is always true)
2019-01-02 18:05:55 +01:00
Daniel Marjamäki
115be7dfc8
ValueFlow: better FwdAnalysis for complex expressions
2019-01-01 18:23:47 +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
ed514644b8
Renamed FwdAnalysisAllPaths to FwdAnalysis
2018-12-31 18:00:47 +01:00
Daniel Marjamäki
141ce7cd63
ValueFlow: Use FwdAnalysisAllPaths in ValueFlow to track complex expressions
2018-12-31 17:05:46 +01:00
rikardfalkeborn
036fcf7827
Fix warnings ( #1541 )
...
* Fix reorder warning
* Fix override warnings
Clang warns about missing overrides.
* Remove unused function
* Add missing argument to function calls
2018-12-28 12:59:05 +01:00
Daniel Marjamäki
6fef02498c
Fixed #7263 (False negative: redundant assignment using +=)
2018-12-27 17:27:53 +01:00
Daniel Marjamäki
ddbe5c129c
Clarify FwdAnalysis. It is useful for checks that need data flow analysis of ALL paths.
2018-12-25 11:56:06 +01:00
Daniel Marjamäki
e2c433a0f8
Fixed #8914 (False positive with unary_function argument)
2018-12-19 19:43:05 +01:00
Daniel Marjamäki
bf4e850e11
Fixed #4475 (New check: struct member is assigned a value that is not read)
2018-12-17 15:40:15 +01:00
Daniel Marjamäki
858d9a18a7
Fixed #3857 (false negative: (style) Variable 'var' is assigned a value that is never used)
2018-12-17 15:16:47 +01:00
Paul Fultz II
9b973e652c
Issue 8830: New check: Function argument evaluates to constant value
...
Add a check for function arguments that can be constant:
```cpp
extern void bar(int);
void f(int x) {
bar((x & 0x01) >> 7); // function 'bar' is always called with a '0'-argument
}
```
2018-12-17 06:04:24 +01:00
Daniel Marjamäki
c8d688607a
Fixed #8901 (Unused value: const variable initialization)
2018-12-16 19:01:05 +01:00
Daniel Marjamäki
21eb1c5e22
FwdAnalysis: Fix false negatives for struct members
2018-12-16 18:32:34 +01:00
Daniel Marjamäki
46a0172480
FwdAnalysis: fix FP in loop
2018-12-16 16:43:04 +01:00
Daniel Marjamäki
97d2075007
FwdAnalysis: better handling of loops
2018-12-16 11:42:11 +01:00
Daniel Marjamäki
3af0d73f82
Unused value: Fixed false negatives for loops
2018-12-16 11:18:37 +01:00
Daniel Marjamäki
1bfe98447a
FwdAnalysis: Tweak possiblyAliased
2018-12-15 11:54:00 +01:00
Daniel Marjamäki
37416010ef
Unused value: Fix false positive (ast, {})
2018-12-14 18:56:09 +01:00
Paul Fultz II
be6782d386
Fix FP 8891: Incorrect return scope when using uniform initialization
...
This fixes the FP in:
```cpp
std::string f(const std::string& data)
{
if (data.empty())
return {};
data[0];
}
```
2018-12-14 18:31:10 +01:00
Daniel Marjamäki
8464085535
UnusedVariables: Fix FP for unknown variable
2018-12-13 21:37:21 +01:00
Daniel Marjamäki
092d434f91
UnusedVar: Fix FP for array arguments
2018-12-13 21:08:18 +01:00
Daniel Marjamäki
1f27cd56c0
FwdAnalysis; Code cleanup, isNullOperand
2018-12-13 21:01:33 +01:00
Daniel Marjamäki
0b4e08cac9
Use FwdAnalysis in UnusedVar. This is still work-in-progress. Merging to master branch so it can be tested.
2018-12-13 18:52:56 +01:00
Daniel Marjamäki
452318dfa4
Remove FwdAnalysis::reads: It is not finished
2018-12-04 18:46:23 +01:00
Daniel Marjamäki
c03c262058
Preparing FwdAnalysis for ValueFlow usage where we want to fetch read locations
2018-12-02 18:29:16 +01:00
Daniel Marjamäki
d8fada6702
Refactoring FwdAnalysis
2018-12-02 17:42:18 +01:00
Daniel Marjamäki
6734571f06
Refactoring: Create FwdAnalysis class in astutils
2018-12-02 17:01:52 +01:00
Daniel Marjamäki
ecb3c04fba
astutils: Add function that visits nodes in AST tree
2018-11-23 06:53:43 +01:00
Paul Fultz II
7ef119cbfc
Fix FPs in lifetime checker
...
This fixes several FPs in the lifetime checker. It also fixes issue [8846](https://trac.cppcheck.net/ticket/8846 ):
```cpp
int * f(int a[])
{
return a;
}
```
2018-11-17 09:41:59 +01:00
Paul Fultz II
54453c5802
Fix FP when copying pointer to string ( #1479 )
2018-11-14 06:59:25 +01:00
Paul Fultz II
0e11bb07c8
Extend lifetime analysis to pointer usage ( #1477 )
...
* Use lifetime analysis for pointers as well
* Fix issue 1143: Pointer to local array
* Update message when using pointers
* Avoid infinite loop in tracing lifetimes
2018-11-12 10:08:17 +01:00
Paul Fultz II
68d6b96878
Diagnose invalid lifetimes ( #1475 )
...
* Add check for invalid lifetimes
* Fix FP with member variables
* Dont forward lifetime values in subfunction
* Update message to use out of scope
2018-11-11 16:43:54 +01:00
Daniel Marjamäki
d5a478d5c5
astyle formatting
...
[ci skip]
2018-11-10 21:30:01 +01:00
Paul Fultz II
1ffcc6b730
Add initial lifetime checker ( #1448 )
...
* Inital valueflow lifetime checker
* Forward values
* Add initial tests
* Fix deplicate messages
* Fix traversing nested lambdas
* Turn test case into a todo
* Skip if returning a container
* Fix FP when using references
* Add missing header
* Fix FP from broken scopes
* Fix FP with static variable
* Add test for more FPs
* Parse lambda functions
* Check for capture by value
* Add tests for using a container and lambda together
* Fix cppcheck errors
* Add test for nextAfterAstRightmostLeaf
* Add valueflow tests
* Update error message
* Check for correct lambda token
* Improve error path reporting
* Fix hang when parsing arrays that look almlost like lambdas
2018-11-10 16:40:40 +01:00
Paul Fultz II
7373be2bfa
Add a pass in valueflow for terminating conditions ( #1323 )
...
* Add valueflow for terminating conditions
* Add valueflow test
* Dont check for same expressions for now to avoid double diagnostics
* Check nesting
* Add more tests
* Ensure conditions happen in order
* Check for null
* Add error path
* Support same expression check as well
* Use early continue
* Skip checking the same token
* Avoid double condtion diagnosis
* Fix FP when in switch statements
* Fix FP when time function
* Skip conditional escapes
* Use simpleMatch
* Fix naming
* Fix typo
2018-11-07 06:49:07 +01:00
rikardfalkeborn
88008fedb1
findLambdaEndToken handle explicit type ( #1458 )
...
* findLambdaEndToken: Add tests
* Add handling of explicit return in findLambdaEndToken()
* Use AST in findLambdaEndToken()
* Fix ast when lambda is mutable
2018-10-31 12:36:08 +01:00
Kamil Dudka
d206047b84
Fixed #8794 - Memory leak false positive triggered by !(x != NULL) ( #1450 )
2018-10-26 06:21:45 +02:00
Daniel Marjamäki
044c4b7fbb
Refactoring: Use range for loop
2018-10-25 06:14:27 +02:00
Daniel Marjamäki
b8e8b12783
Fixed #8797 (exprDependsOnThis handle method call in non-inline method)
2018-10-24 20:17:00 +02:00
Daniel Marjamäki
64fbffc90d
astyle formatting
...
[ci skip]
2018-10-21 20:28:46 +02:00
Paul Fultz II
2989c44f59
Enable checking duplicate expressions across associative operators ( #1445 )
...
* Enable checking duplicate expressions across associative operators
* Remove bitshift operators and check for streamRead
2018-10-21 07:09:20 +02:00