Commit Graph

28 Commits

Author SHA1 Message Date
Daniel Marjamäki 6d796b434e Fixed #9731 (ValueFlow: does not handle many assignments well) 2020-06-08 21:17:12 +02:00
Ken-Patrick Lehrmann 8c2c81dbcd
Fix some false positive in loop forward analysis (#2669)
* Fix some false positive in loop forward analysis

In cases like:
```
bool b();
void f()
{
    int val[50];
    int i, sum=0;
    for (i = 1; b() && i < 50; i++)
        sum += val[i];
    for (; i < 50; i++)
        sum -= val[i];
}
```
The forward analysis assumed the second loop was entered, and we ended
up with false positive in it:
 `Array 'val[50]' accessed at index 50, which is out of bounds`

* Fix style
2020-06-05 18:06:03 +02:00
Paul Fultz II 526abd4b52
Fix issue 9738: ValueFlow: handle std::tie better (#2657) 2020-05-22 22:57:20 +02:00
Paul Fultz II 8301fa8244
Fix issue 8144: valueFlowBeforeCondition: struct (#2645) 2020-05-21 08:47:48 +02:00
PKEuS dc701276de Optimizations to ValueFlow and ForwardAnalyzer:
- Remove errorPath of a value on assignment (this fixes enormous memory consumption for code with many subsequent assignments)
- De-virtualized a simple get function that was virtual for no reason
- Cloned function isAliasOf() for single values to avoid instantiating unnecessary std::list objects (
- Replaced a couple of trivial Token::Match/simpleMatch expressions by direct comparison
- Treat enumerators as literal values
2020-05-19 21:07:04 +02:00
PKEuS 22884888fb Optimization: Improved performance of ForwardAnalyzer by adding some pre-checks and combining conditions 2020-05-19 13:48:15 +02:00
PKEuS 793ed68029 Refactorization: Moved code from header to source
- from utils.h to new utils.cpp
- from token.h to token.cpp
- from valueflow.h to valueflow.cpp
- from errorlogger.h to errorlogger.cpp
2020-05-19 08:35:12 +02:00
Paul Fultz II 2a09465a07
Fix issue 9686: Regression: ValueFlow should handle try/catch better (#2618) 2020-04-22 19:20:03 +02:00
Oliver Stöneberg 2c1e36e63e
cleaned up includes based on include-what-you-use (#2600)
* cleaned up includes based on include-what-you-use

* check.h: trying to work around Visual Studio 2012 bug

* fixed Visual Studio compilation
2020-04-13 13:44:48 +02:00
Paul Fultz II 8b27f1c216
Fix issue 9667: crash: crash in valueflow for weird code where label address is returned (#2602) 2020-04-11 13:56:53 +02:00
Daniel Marjamäki d7af52865d ValueFlow: avoid crash when && is used in r-value variable declaration 2020-04-09 14:38:10 +02:00
Daniel Marjamäki e7ddd9cc15 ForwardAnalyzer: Add recursion limit 10000 2020-04-09 12:11:33 +02:00
Paul Fultz II b68d6f9471
Fix crash in valueflow when using local classes (#2575) 2020-03-22 10:12:53 +01:00
Paul Fultz II 7fd3580f21
Dont traverse conditions multiple times (#2574) 2020-03-20 10:37:16 +01:00
Daniel Marjamäki 51732e9d75 ForwardAnalyzer: Fixed crash 2020-03-10 10:36:05 +01:00
Daniel Marjamäki f7612fd1a9 ForwardAnalyser; Tweak fix for crash 2020-03-08 12:02:45 +01:00
Daniel Marjamäki 2600dee36c ForwardAnalyzer: Fix crash in cast '(T* &&)', the && does not have operands 2020-03-08 11:49:14 +01:00
Daniel Marjamäki 26a11e20d0 Revert "Fix crash with garbage code (#2547)"
This reverts commit b25709a492.

The real problem was wrong AST for valid code, I want to fix that instead.
2020-02-21 09:35:01 +01:00
Paul Fultz II b25709a492
Fix crash with garbage code (#2547) 2020-02-21 06:53:28 +01:00
Paul Fultz II 392060aefe
Fix issue 7804: ValueFlow: possible value in second if body (#2543) 2020-02-19 07:55:04 +01:00
Armin Müller 75b1ade316
Typos found by running "codespell" (#2542) 2020-02-17 18:28:58 +01:00
Paul Fultz II 921887a281
Use valueFlowGeneric for valueFlowForwardExpression (#2537) 2020-02-16 16:02:22 +01:00
Daniel Marjamäki df21da35bf Refactoring; Use std::function instead of template type 2020-02-15 09:20:49 +01:00
Daniel Marjamäki 365da62624 Refactoring; Use std::function instead of template type 2020-02-15 09:14:14 +01:00
Daniel Marjamäki 697ca12d97 Refactoring; Convert templates to normal functions 2020-02-15 08:08:55 +01:00
Paul Fultz II 61d847cac2
Fix issue 9637: false positive: Condition 'i<2U' is always true (#2536) 2020-02-15 07:57:43 +01:00
Daniel Marjamäki 5f4a900f88 astyle formatting
[ci skip]
2020-02-13 17:04:05 +01:00
Paul Fultz II 7368a54629
Add generic valueflow forward analysis (#2511) 2020-02-13 16:27:06 +01:00