Commit Graph

10952 Commits

Author SHA1 Message Date
Paul Fultz II 0c1dff5c93 Fix issue 9268: false negative: (style) Condition '...' is always true (#2080)
* Fix issue 9268: false negative: (style) Condition '...' is always true

* Fix copy and paste mistake
2019-08-14 06:34:27 +02:00
Paul Fultz II 13df5b2413 Fix FP with negative index and negated condition (#2081) 2019-08-14 06:32:31 +02:00
Daniel Marjamäki d4549217d0 Renamed safeClassRefMember => unsafeClassRefMember 2019-08-13 20:58:31 +02:00
Daniel Marjamäki ed7edc6d2a Improve warning message 2019-08-13 20:42:25 +02:00
Daniel Marjamäki 41f8c1b281 Fixed #9271 (Safe classes: Class that store references) 2019-08-13 20:40:48 +02:00
Rikard Falkeborn ffcceb097e Memleak: Refactor check to separate function (#2079)
This makes all the checks in CheckMemoryLeakNoVar separate functions to
improve readability.
2019-08-13 13:00:59 +02:00
Paul Fultz II c0c6f92221 Fix issue 8431 and 8776: Size of constant string
Fixes these cases:

```cpp
void f(void) {
        const std::string msg="xyz";
        if(!msg.empty()){} // Always true
}
```

And out of bounds access:

```cpp
#include <string>
char fstr1(){const std::string s = "<a><b>"; return s[42]; }
wchar_t fwstr1(){const std::wstring s = L"<a><b>"; return s[42]; }
```
2019-08-12 20:24:16 +02:00
Paul Fultz II 68e8253920 Fix issue 8313 and 7326: Track values of pointer aliases in valueflow 2019-08-12 12:58:53 +02:00
Daniel Marjamäki aec217fede astyle formatting
[ci skip]
2019-08-12 12:54:25 +02:00
Rikard Falkeborn cd36f8ed0a Fix #9253: leakNoVarFunctionCall: do not warn if freopen opens standard stream (#2076)
This fixes false positives from daca@home where freopen is used to
reopen a standard stream. There is no longer a warning for

	void f() {
		assert(freopen("/dev/null", "r", stdin));
	}
2019-08-12 12:53:59 +02:00
Paul Fultz II 9aa97cbb95 Fix issue 8296: ValueFlow: value not set in conditional scope in subfunction (#2071)
* Fix issue 8296: ValueFlow: value not set in conditional scope in subfunction

* Refactor condition checkingg

* Make test case TODO
2019-08-11 15:39:37 +02:00
Daniel Marjamäki 0edc4feb57 Try to make Appveyor happy 2019-08-10 08:46:27 +02:00
IOBYTE 5fc5e3728d template simplifier: refactor TemplateSimplifier::TokenAndName into a… (#2073)
* template simplifier: refactor TemplateSimplifier::TokenAndName into a class

assert when more than one family flag is set

* fix function parameter names
2019-08-10 08:42:12 +02:00
Daniel Marjamäki 6a260929e2 CLI: error id from addon is <addon>-<id> 2019-08-10 07:43:47 +02:00
Daniel Marjamäki 0fbbe2ff23 Refactor load/write of cppcheck project. Reuse same string constants in cli and gui. 2019-08-09 21:15:02 +02:00
Armin Müller 785cc69644 Typos found by running "codespell" (#2072) 2019-08-08 21:05:28 +02:00
Paul Fultz II bd02ca5ccb Fix issue 9207: Not detected 'always true' and unreachable code 2019-08-08 07:46:47 +02:00
IOBYTE c6c50567cf Fix #9250 (Regression: crash in gcc testsuite) (#2067)
* Fix #9250 (Regression: crash in gcc testsuite)

* fix cppcheck warning
2019-08-07 08:05:02 +02:00
Ken-Patrick cb0b057595 8706 (#2066)
* 8706

* Add test case for #8706
2019-08-07 08:04:10 +02:00
Ken-Patrick 9ec8886898 Use std::any_of in token.h (#2065)
[lib/token.h:964]: (style) Consider using std::any_of algorithm instead of a raw loop.
2019-08-07 08:02:07 +02:00
Paul Fultz II aaeec462e6 Re-enable valueFlowSubFunction (#2063)
* Re-enable valueFlowSubFunction

* Formatting

* Skip ternary operators in subfunctions

* Fix test with iostreams

* Fix FP with multiple parameters
2019-08-05 16:26:32 +02:00
Daniel Marjamäki ebcca4edd1 Improve --debug-warnings output for 'auto' tokens without type. Do not report that prematurely before the type is set properly. 2019-08-05 13:42:06 +02:00
Daniel Marjamäki 20278d9c92 Clarify signConversion warning message 2019-08-05 12:41:08 +02:00
Paul Fultz II ffdd2dc793 Fix issue 8924: Re-enable valueFlowTerminatingCondition 2019-08-05 07:18:06 +02:00
IOBYTE 7ebc9d1b5f Fix #9249 (Syntax error on valid C++) (#2062) 2019-08-04 10:24:44 +02:00
Daniel Marjamäki 510748134f Fixed #9234 (FP unreadVariable - assignment via iterator) 2019-08-04 10:21:16 +02:00
Daniel Marjamäki ce53931d00 Fixed #9251 (False positive: unininitialized variable (multi variables)) 2019-08-03 21:12:34 +02:00
Daniel Marjamäki cdc602e1be Fixed #9137 (Tokenizer: Wrong handling of volatile pointer) 2019-08-03 12:28:50 +02:00
Daniel Marjamäki c03df8e6b4 SymbolDatabase: Improved matchParameter for containers 2019-08-03 10:10:40 +02:00
IOBYTE 2da83df37b Fix #9246 (Syntax error on C++ code) (#2061) 2019-08-03 08:15:06 +02:00
amai2012 f02636e995 Refactoring: Convert enums to enum classes 2019-08-02 21:14:29 +02:00
rebnridgway d2b9c1f15a Fix some bugs in new Scope Calculation code (#2060)
* Fix for too much information in scope name

When the scope calculation encounters code such as 
"friend class X::Y;"
or
"template<> class X<void> {"
it will now reset the additional name component of the scope that is about to be opened.

* Made sure new scope name is reset after being used
2019-08-02 19:55:08 +02:00
Daniel Marjamäki e66e6549ee SymbolDatabase: Improved ValueType::matchParameter handling of containers 2019-08-02 15:59:22 +02:00
Daniel Marjamäki 26b0ea52ed SymbolDatabase: Simplify code 2019-08-02 15:41:18 +02:00
IOBYTE 0d1685cd29 Fix #9178 example with instantiation (#2059) 2019-08-02 07:53:39 +02:00
amai2012 29596baa92 Refactoring: Convert enum Direction to enum class 2019-08-01 20:56:02 +02:00
Daniel Marjamäki 7eaa49fd5b Refactoring SymbolDatabase::findFunction. No functional change is intended. 2019-08-01 17:53:14 +02:00
Daniel Marjamäki 81db8fda18 SymbolDatabase: Code cleanup in findFunction 2019-08-01 17:29:25 +02:00
Daniel Marjamäki 25a13d061c Refactoring SymbolDatabase::findFunction 2019-08-01 16:14:00 +02:00
Daniel Marjamäki f95fdd80dd SymbolDatabase: Refactoring findFunction 2019-08-01 14:30:29 +02:00
Daniel Marjamäki 2a17b897c5 SymbolDatabase: Use ValueType::matchParameter for *var parameters 2019-08-01 13:29:44 +02:00
Daniel Marjamäki dbddc321e8 SymbolDatabase: Try to match function parameters with unknown types 2019-08-01 13:25:03 +02:00
Rikard Falkeborn f6726b76ae Fix 9215 (add tilde for missing destructor override warning) (#2057) 2019-08-01 10:43:45 +02:00
amai2012 8a934805ed Convert InvalidValueType to enum class 2019-07-31 22:56:16 +02:00
amai2012 b0fbbb5aa7 Convert SHOWTIME_MODES to enum class 2019-07-31 22:35:51 +02:00
Daniel Marjamäki 8deb855b41 Fix ValueType::matchParameter for 'const float *' => 'signed long long' 2019-07-31 18:55:55 +02:00
Daniel Marjamäki 91ca6165eb SymbolDatabase: Use ValueType::matchParameter for expression parameters 2019-07-31 18:35:56 +02:00
Daniel Marjamäki 70ac607a5c SymbolDatabase: extend usage of ValueType::matchParameter for variable parameters 2019-07-31 18:25:47 +02:00
Daniel Marjamäki c51f44ce4c SymbolDatabase: extend usage of ValueType::matchParameter for variable parameters 2019-07-31 18:24:15 +02:00
Daniel Marjamäki 1eb5f2266c ValueType::matchParameter: Fix matching of char** and void* 2019-07-31 16:23:50 +02:00