Commit Graph

905 Commits

Author SHA1 Message Date
Daniel Marjamäki 4138bf7fb3 SymbolDatabase: Better handling when return type of function is PodType 2019-09-28 14:57:41 +02:00
Oliver Stöneberg eac040a00b Various clang-tidy fixes (#2192)
* use range loops

* removed redundant string initializations

* use nullptr

* use proper boolean false

* removed unnecessary continue from end of loop

* removed unnecessary c_str() usage

* use emplace_back()

* removed redundant void arguments
2019-09-25 15:25:19 +02:00
Oliver Stöneberg de9f489b08 use range loops / constness (#2181)
* use range loops / constness

* platform.cpp: avoid shadowed variable
2019-09-19 20:29:33 +02:00
Paul Fultz II ba037837c9 Track lifetime across multiple returns
This will now warn when doing something like this:

```cpp
template <class T, class K, class V>
const V& get_default(const T& t, const K& k, const V& v) {
    auto it = t.find(k);
    if (it == t.end()) return v;
    return it->second;
}
const int& bar(const std::unordered_map<int, int>& m, int k) {
    auto x = 0;
    return get_default(m, k, x);
}
```

The lifetime warning is considered inconclusive in this case.

I also updated valueflow to no tinject inconclusive values unless `--inconclusive` flag is passed. This creates some false negatives because library functions are not configured to not modify their input parameters, and there are some checks that do not check if the value is inconclusive or not.
2019-09-11 19:25:09 +02:00
IOBYTE e5220bdf0c make ellipsis ... a single token (#2143)
* make ellipsis ... a single token

Using cppcheck -E to preprocess code with ellipsis produces output that
can't be compiled because ... is split into 3 tokens.

* try to fix addon
2019-09-04 08:07:30 +02:00
Ken-Patrick 2c656d6586 Issue 9255: Prevent infinite recursion in parsedecl (#2134) 2019-09-01 11:36:02 +02:00
Ken-Patrick d1c6cb9aa5 Fix issue 9304: boolean type of ternary (#2131)
* Add test cases for 9304

* Fix 9304
2019-09-01 09:51:53 +02:00
Paul Fultz II bd02ca5ccb Fix issue 9207: Not detected 'always true' and unreachable code 2019-08-08 07:46:47 +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
Paul Fultz II ffdd2dc793 Fix issue 8924: Re-enable valueFlowTerminatingCondition 2019-08-05 07:18:06 +02:00
Daniel Marjamäki c03df8e6b4 SymbolDatabase: Improved matchParameter for containers 2019-08-03 10:10:40 +02:00
amai2012 f02636e995 Refactoring: Convert enums to enum classes 2019-08-02 21:14:29 +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
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
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
Daniel Marjamäki a3dc2db77a SymbolDatabase: Use ValueType::matchParameter for variable address parameters 2019-07-31 12:38:36 +02:00
Daniel Marjamäki 039d49bcb1 Improve ValueType::matchParameter for pointers with different types 2019-07-31 12:12:17 +02:00
Daniel Marjamäki 35a3a34632 Revert "SymbolDatabase: Use ValueType::matchParameter"
This reverts commit cea00a8e09.
2019-07-31 12:07:07 +02:00
Daniel Marjamäki cea00a8e09 SymbolDatabase: Use ValueType::matchParameter 2019-07-31 11:20:43 +02:00
Daniel Marjamäki 728ac6ae2e SymbolDatabase: Use ValueType::matchParameter for char literal parameters 2019-07-31 09:35:32 +02:00
Daniel Marjamäki e58e51ee14 SymbolDatabase::findFunction: For string literal, a std::string parameter is a better match than a void* parameter 2019-07-30 21:20:01 +02:00
Daniel Marjamäki f5c269a191 SymbolDatabase: Use ValueType::matchParameter for string literal parameters 2019-07-30 21:02:35 +02:00
Daniel Marjamäki d5d50d9b17 ValueType::matchParameter: Improved constness matching 2019-07-30 09:19:51 +02:00
Daniel Marjamäki 914430dede Appveyor: A quick fix to make Appveyor happy, revert the changes 2019-07-30 07:59:28 +02:00
Daniel Marjamäki 88e3199372 SymbolDatabase: Use ValueType::matchParameter for numeric literal parameters 2019-07-30 07:48:14 +02:00
Daniel Marjamäki bf219aecde SymbolDatabase::findFunction: Use ValueType::matchParameter for expression parameters 2019-07-30 07:14:05 +02:00
Daniel Marjamäki f13b1a0bce SymbolDatabase: Use ValueType::matchParameter for boolean parameters 2019-07-29 22:58:12 +02:00
Daniel Marjamäki ed5ae7c5fa SymbolDatabase::findFunction: Use ValueType::matchParameter for float literal parameters 2019-07-29 21:53:39 +02:00
Daniel Marjamäki cccbfaa0e4 SymbolDatabase::findFunction: Use getArguments utility function 2019-07-29 21:17:31 +02:00
Daniel Marjamäki 9e738db435 SymbolDatabase: expand usage of ValueType::matchParameter for non-pointer variables 2019-07-29 18:46:50 +02:00
Daniel Marjamäki 3066c0653c Fixed #8668 (SymbolDatabase: Wrong findFunction match for const pointer argument) 2019-07-29 18:14:23 +02:00
Daniel Marjamäki 9009eeb83d Tweak Function::isSafe() 2019-07-25 20:52:24 +02:00
Daniel Marjamäki 4611cbb5bb One more fix for Function::isSafe 2019-07-25 17:31:52 +02:00
Daniel Marjamäki 09be07f2b2 Fix Function::isSafe 2019-07-25 17:28:32 +02:00
Paul Fultz II bb52a63c4e Add check for const variables
When a local reference is declared, this will check if that local reference can be declared as `const`.
2019-07-24 09:59:01 +02:00
Daniel Marjamäki 753efb4c9b Function::isSafe: handle global/namespace functions better 2019-07-24 08:23:05 +02:00
Daniel Marjamäki 4fb6c27276 Modernize: Use enum class 2019-07-23 14:29:02 +02:00
Daniel Marjamäki 681bd0a911 GUI: Better settings for extended safe checks 2019-07-23 11:54:38 +02:00
Daniel Marjamäki 74bd2aa680 Use range for loop 2019-07-22 12:24:16 +02:00
Daniel Marjamäki a81c39af09 Replace 'unsigned' with 'nonneg' 2019-07-22 11:25:51 +02:00