Daniel Marjamäki
ff469867e7
Refactor CheckStl::stlOutOfBounds
2018-11-28 20:30:58 +01:00
Daniel Marjamäki
dd94bfede9
CheckStl: Improving checking of container access out of bounds
2018-11-28 19:27:28 +01:00
Daniel Marjamäki
6493db6ca2
Try to clarify message for container access out of bounds a little more.
2018-11-28 13:58:01 +01:00
Daniel Marjamäki
0f2f807798
Improve the container out of bounds messages. They are still not perfect.
2018-11-28 07:03:56 +01:00
Daniel Marjamäki
13c6489571
Redundant variable assignment: Fix FN for struct members
2018-11-27 18:22:22 +01:00
Daniel Marjamäki
32c05fef92
Redundant assignment: check that --enable=style has been used.
2018-11-27 13:04:50 +01:00
Daniel Marjamäki
0ad757fc78
valueFlowLifetime: Try to cleanup the loop a little. No functional change is intended.
2018-11-27 06:43:59 +01:00
Paul Fultz II
5a6f9ac82a
Fix FP with strcmp and terminating conditions
2018-11-27 06:39:29 +01:00
IOBYTE
f2660ed203
template simplifier: fix instantiated template names in forward declarations ( #1495 )
...
This now handles the revised example code in #8603 .
2018-11-27 06:17:04 +01:00
Daniel Marjamäki
2887ee10c0
Fixed #8800 (Possible variable assignment ignored in boolean expression)
2018-11-26 14:00:03 +01:00
Daniel Marjamäki
affd03f1d6
Minor tweak for redundantVariableAssignment
2018-11-26 11:16:50 +01:00
IOBYTE
e20079a5d9
template simplifier: fix 3 function forward declaration bugs ( #1493 )
...
* fix support for multi token types
* fix support for const member functions
* fix duplicate template parameters sometimes being inserted
2018-11-26 06:23:12 +01:00
Daniel Marjamäki
86f9fb778b
Fixed #8864 (compile commands: handle define with string value)
2018-11-25 15:09:23 +01:00
Daniel Marjamäki
0160f80ffe
redundantVarAssignment: avoid FPs when loops are used
2018-11-25 10:32:30 +01:00
Daniel Marjamäki
22f736eae2
redundant variable assignments: avoid FPs for initializations
2018-11-25 08:49:09 +01:00
Daniel Marjamäki
2f66b31d43
redundantAssignmentInSwitch: fix false positive when there is goto
2018-11-24 21:39:01 +01:00
Paul Fultz II
a3921ea861
Refactor valueFlowAfterCondition
...
So this unifies the `valueFlowAfterCondition` so it re-uses more code between checking for integers and container sizes. This should make valueFlowContainer more robust.
It also extends valueflow to support container comparisons such as `if (v.size() < 3)` or `if (v.size() > 3)` using the same mechanism that is used for integers.
2018-11-24 10:07:12 +01:00
Daniel Marjamäki
866688c70a
Rewriting redundantAssignment checker
2018-11-24 10:03:54 +01:00
Daniel Marjamäki
b049a31e7c
Refactoring; Use visitAstNodes
2018-11-23 20:41:39 +01:00
Daniel Marjamäki
2b09354b05
Refactoring; use visitAstNodes
2018-11-23 20:33:31 +01:00
Daniel Marjamäki
2214ef5359
Refactor isVLAIndex
2018-11-23 20:23:20 +01:00
Daniel Marjamäki
8f164d9602
Refactoring; use visitAstNodes
2018-11-23 19:22:53 +01:00
Daniel Marjamäki
52f9650533
Refactoring: Use visitAstNodes
2018-11-23 19:16:19 +01:00
Daniel Marjamäki
745b58de26
Refactoring: Use visitAstNodes
2018-11-23 17:18:07 +01:00
IOBYTE
358f0c473d
Modify template simplifier to add forward declarations of some templa… ( #1489 )
...
* Modify template simplifier to add forward declarations of some template functions so symbol database can make sense of the expanded templates.
* Fix travis.
2018-11-23 11:36:09 +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
f16d9d7d90
Issue 6175: Check lifetime of a variables stored in containers and member variables
...
Cppcheck will now warn for all cases here:
```cpp
#include <vector>
class CCluster {};
class MyClass
{ public:
std::vector<CCluster*> m_cluster;
void createCluster()
{
CCluster cl;
CCluster* pcl=&cl;
m_cluster.push_back(pcl);
}
void createCluster2()
{
CCluster cl;
m_cluster.push_back(&cl);
}
CCluster* Cluster()
{
CCluster cl;
CCluster* pcl=&cl;
return pcl;
}
CCluster* Cluster2()
{
CCluster cl;
return &cl;
}
};
```
2018-11-21 08:43:57 +01:00
Daniel Marjamäki
9d8e5e36eb
Added a few TODO comments
2018-11-20 22:57:01 +01:00
Daniel Marjamäki
8227188786
comment out old memleak checking. maybe it can be removed.
2018-11-20 18:40:18 +01:00
Daniel Marjamäki
a5af5b2d08
Revert "Fixed #7619 (False positive: Redundant assignment)"
...
There is a crash I need to look into.
2018-11-20 06:23:43 +01:00
Daniel Marjamäki
c899792232
Fixed #7619 (False positive: Redundant assignment)
2018-11-19 21:23:36 +01:00
Daniel Marjamäki
a8cbbe0e16
Fixed #8816 (FP shadowLocal - variable shadows a template function?)
2018-11-19 07:00:15 +01:00
Daniel Marjamäki
9ef3c79bc6
Fixed #8851 (Crash in valueFlowContainerForward (daca@home: pbbam))
2018-11-18 20:18:55 +01:00
Daniel Marjamäki
f2b26a488a
relative paths: another fix for {code}
2018-11-18 16:15:09 +01:00
Daniel Marjamäki
982f7dc2b3
relative paths: show {code} properly when there are relative paths
2018-11-18 16:08:08 +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
d376e9f245
Track variable lifetime through function calls ( #1481 )
2018-11-16 06:12:28 +01:00
Daniel Marjamäki
5d086d60ad
Fixed #8844 (snd: Wrong varid and ast)
2018-11-14 21:05:09 +01:00
Daniel Marjamäki
69f2e0938a
VarId: Improved varids for struct members ( #8844 )
2018-11-14 19:11:35 +01:00
Daniel Marjamäki
39c04b650d
astyle formatting
...
[ci skip]
2018-11-14 19:10:52 +01:00
Daniel Marjamäki
69f6100d83
Fixed #8339 (false positive: unread variable despite delete is used on it)
2018-11-14 17:04:21 +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
ac242b69d6
Refactoring: Use range for loops
2018-11-14 06:58:21 +01:00
Paul Fultz II
f0c86b9d14
Fix issue 8842: Crash in valueFlowTerminatingCondition on incomplete code ( #1480 )
2018-11-14 06:23:45 +01:00
Paul Fultz II
e839001f3d
Fix warnings ( #1478 )
2018-11-14 06:14:04 +01:00
Daniel Marjamäki
d97851b9db
change severity for 'unknown macro' to error for now.
2018-11-13 21:08:45 +01:00
Daniel Marjamäki
152be6df63
Report 'unknown macro' as information message with id unknownMacro
2018-11-13 20:14:56 +01:00
Daniel Marjamäki
a50eb56d8d
Extend 'Unknown macro' check
2018-11-13 18:30:40 +01:00
Daniel Marjamäki
e6a5e0f752
Warn when there is a unknown macro
2018-11-13 16:49:15 +01:00
Daniel Marjamäki
69e7392ce2
Fixed #8449 (False positive 'constStatement' when initializing std::unordered_map)
2018-11-12 18:10:34 +01:00