Commit Graph

112 Commits

Author SHA1 Message Date
Rikard Falkeborn 2cacb13f85
Fix #10671: functionConst FN with begin/end and const_iterator (#3749)
Check if the iterator is assigned to a const_iterator or
const_revese_iterator, in which case it is possible the function can be
const. Unfortunately, it is not possible to remove the hard coding of
cbegin, cend, crbegin and crend due to the need to handle auto, as in
the following code snippet:

    void cbegin_auto(void)
    {
        for (auto it = m_str.cbegin(); it != m_str.cend(); ++it) {;}
    }
2022-02-02 19:37:06 +01:00
chrchr-github cb5a50c6a7
Fix #10710 FN passedByValue with QString (#3696) 2022-01-18 20:17:05 +01:00
Daniel Marjamäki b3f9df968b Uninitvar: fixed 'make checkcfg' 2021-10-03 20:32:39 +02:00
orbitcowboy 46f7275833 #8113: Added a regression test. 2021-08-09 18:30:29 +02:00
Paul Fultz II 7f358b2bed
Format with uncrustify (#3388) 2021-08-07 20:51:18 +02:00
orbitcowboy 8096fa4db1 std.cfg: Added overlappingWriteFunction-check to wcsncat(). 2021-07-16 14:30:49 +02:00
orbitcowboy 9b46f59ff0 std.cfg: Cleanup wrong test case. 2021-07-16 14:25:04 +02:00
orbitcowboy e90a3053d4 std.cfg: Added a overlappingWriteFunction-check to strncat 2021-07-16 14:01:40 +02:00
orbitcowboy 435cffa858 std.cfg: Improved configuration of std::next(),std::prev() and added TODO tests 2021-07-14 10:12:49 +02:00
orbitcowboy 7ad64891ea Added tests for overlapping data. 2021-07-10 18:28:26 +02:00
orbitcowboy c38a43c353 std.cfg: Added overlappingWriteFunction check to wcscpy(). 2021-07-10 09:20:51 +02:00
orbitcowboy 652e2765bc std.cfg: Added support for wcsncpy regarding data-overlapping 2021-07-09 16:32:54 +02:00
Daniel Marjamäki 86f1acc223 overlapping data; use the size value given by size-arg 2021-07-09 13:43:29 +02:00
orbitcowboy 58811808d5 std.cfg: Improved configuration of 'strncpy', which is vulnerable for overlapping write issues. 2021-07-09 09:48:24 +02:00
orbitcowboy f626035963 std.cfg: Added support for more interfaces 2021-06-03 08:07:53 +02:00
orbitcowboy 39912b5096 std.cfg: Added support for more interfaces 2021-06-03 07:55:26 +02:00
orbitcowboy 4c81a59c0b std.cfg: Added support for more interfaces 2021-06-03 07:33:23 +02:00
keinflue 6b8029633f
Fix build warnings and checkcfg errors with musl and libc++. (#3244)
* Fix musl include warning.

* Fix test/cfg errors with musl/libc++.

* Use correct C++ include for PR #3244

Co-authored-by: keinflue <>
2021-05-03 09:39:33 +02:00
orbitcowboy 2c15c384d1 Fixed some typos, there are no functional changes intended 2020-12-05 08:00:31 +01:00
orbitcowboy cabafca5ae windows.cfg: Added some constants from WinUser.h 2020-07-01 16:14:59 +02:00
orbitcowboy 02adb60f08 test std.cfg: Added a regression test for std::vsprintf(). The first argument is allowed to be a null pointer. 2019-11-11 09:29:16 +01:00
orbitcowboy f59a2b491d #9455: Added a test case. 2019-11-05 14:00:50 +01:00
versat 094caf31ac std.cfg: Remove redundant configurations for vector::(push|pop)_back()
Add tests in std.cpp to verify that a configuration for the functions
exists.
2019-10-18 12:40:10 +02:00
Sebastian 8eea046e5b
std.cfg: Add support for std::fill_n() (#2273)
Reference: https://en.cppreference.com/w/cpp/algorithm/fill_n
2019-10-18 12:24:57 +02:00
Sebastian 5615da4547
std.cfg: Add configuration and tests for std::bind() (#2207)
TODO:
Somehow Cppcheck fails to print an ignoredReturnValue message when the
return value is not used (see ticket 
https://trac.cppcheck.net/ticket/9369 )
2019-09-24 12:16:13 +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
orbitcowboy 1994cbbb9c std.cfg: Improved configuration for mbrlen() and extended test cases. 2019-08-27 08:18:19 +02:00
Sebastian 0934577dda
Library configuration: function argument direction fixes and enhancements (#1722)
* std.cfg: Add further argument directions (in, out, inout).

* testlibrary.cpp: Add test for function argument direction configuration.

* std.cfg: runastyle and add some more direction configurations.

* library.h: Add documentation for function argument direction enum.

* Do not use "direction" library information for pointer arguments.

Also fix further unmatched uninitvar messages in std configuration
tests.

* std.cfg: Add more argument direction configurations.

* test/cfg/std.c: Add test for argument direction configuration.

* astutils.cpp: Only ignore pointer arguments for out/inout arguments.

* library.h: Use suggested documentation for argument direction enum.
2019-03-04 22:57:40 +01:00
Daniel Marjamäki 5087f15035 Travis: Try to fix 'make checkcfg' 2019-03-02 19:38:11 +01:00
Sebastian 3427e61383
std.cfg: Add support for std::string::assign() (#1660)
Reference: https://en.cppreference.com/w/cpp/string/basic_string/assign
2019-02-11 13:40:36 +01:00
orbitcowboy 611eb81302 Fixed checkcfg: test/cfg/std.cpp:2904:error:uninitvar:Uninitialized variable: s 2018-12-23 18:09:55 +01:00
Daniel Marjamäki ec89c7b1b8 Travis: redundantCopy is not detected at the moment 2018-11-24 11:27:27 +01:00
orbitcowboy b4aa04db41 std.cfg: Added returnValue calculation for isless(), islessgreater() etc. 2018-11-20 16:58:33 +01:00
orbitcowboy 54c5d09ed3 test:std.cpp: Removed duplicate include <csetjmp>. 2018-10-06 00:23:14 +02:00
orbitcowboy ef82477d11 std.cfg: Do not take the return value of std::locale::global() into account. 2018-05-30 16:04:40 +02:00
orbitcowboy 5b6e6db376 test std.cfg: Added more test cases for strcat() functions. 2018-05-27 10:16:02 +02:00
Sebastian b53c4b2032 std.cfg: Add std::vector function configurations and tests (#1180) 2018-04-19 16:41:25 +02:00
Sebastian a36dad918a std.cfg: Add std::make_pair() (#1165) 2018-04-11 19:16:55 +02:00
orbitcowboy ef62207ada std.cfg: Added more tests for some std::vector functions. 2018-04-11 17:21:26 +02:00
Sebastian 3fc53eb122 std.cfg: Add std::[w]string::compare() with tests (#1162) 2018-04-10 21:07:39 +02:00
Daniel Marjamäki b10dd5d21e 2 TODOs are fixed 2018-03-19 11:02:58 +01:00
Daniel Marjamäki 58034dee86 Fixed #8076 (unmatched suppression when calling ./runtests.sh (test/cfg)) 2018-01-10 15:52:06 +01:00
U-SAMS\Alexander a8e12a6f29 Fix&cheat to make config test pass on cygwin 2017-05-03 11:41:37 +02:00
Matthias Krüger 65846efb6b test/cfg/std.cpp fix 'make checkcfg', std::vector needs to have <vector> #included 2017-03-06 16:59:17 +01:00
orbitcowboy e3d879e43d std.cfg: Improved support for some std::wstring functions. 2017-03-06 16:40:49 +01:00
Daniel Marjamäki 302bf925df Remove test/cfg/std.cpp test that fails 2017-03-06 12:39:08 +01:00
Daniel Marjamäki d535f17489 testing std::string and std::vector configuration a little 2017-03-05 22:23:45 +01:00
Daniel Marjamäki ecc59859e1 Don't simplify _Bool in TokenList 2017-03-04 11:13:28 +01:00
Daniel Marjamäki a8424bcb54 Test get/getline/read/readsome configuration in std.cfg 2017-03-04 08:56:37 +01:00
orbitcowboy 75124317e9 std.cfg: Added returnValue support for iswblank(). 2016-11-04 14:03:48 +01:00