Commit Graph

533 Commits

Author SHA1 Message Date
orbitcowboy c726c34fdf std.cfg: Updated commit f396571b6c and moved 'memcpy' to the right place 2020-09-05 07:30:03 +02:00
orbitcowboy f396571b6c std.cfg: Defined own rule for wmemcpy to avoid FPs because of different return types. 2020-09-05 07:12:41 +02:00
Georgy Komarov f5877e327b
std.cfg: Fix memcpy return type (#2777) 2020-09-05 06:29:39 +02:00
orbitcowboy ad8d8ca11d std.cfg: Added support for std::advance. Reference: https://en.cppreference.com/w/cpp/iterator/advance 2020-07-24 10:21:57 +02:00
orbitcowboy 8ab02ed97a std.cfg: Improved bsearch() configuration 2020-07-01 15:06:00 +02:00
orbitcowboy 0770a6fe62 std.cfg: Added support for std::at_quick_exit() 2020-07-01 14:43:17 +02:00
orbitcowboy 27d6b9a57d std.cfg: Formatted comments, there are no functional changes [ci skip] 2020-07-01 11:12:22 +02:00
orbitcowboy a3d58a9302 std.cfg: Allow scientific floating point notation for '<valid>'-tags 2020-06-12 08:51:33 +02:00
orbitcowboy 05b98712e8 std.cfg: Added valid range for 'acosh' 2020-06-11 09:22:24 +02:00
orbitcowboy 6c93a82575 std.cfg: Added valid range for 'atanh' 2020-06-11 09:19:47 +02:00
Daniel Marjamäki efb583e3d1 astyle formatting
[ci skip]
2020-04-04 10:31:38 +02:00
Paul Fultz II a22a77c1fc
Use library config for unstable containers instead of hardcoded values (#2585)
* Use library config for unstable containers instead of hardcoded values

* Fix xml validation
2020-04-03 13:16:57 +02:00
orbitcowboy e1eb7e04b5 std.cfg: Added <not-bool/>-flags for some functions from <cwctype> 2020-02-22 14:24:14 +01:00
orbitcowboy a62ddc6edd std.cfg: Added <not-bool/>-tag to isblank() function arg. 2020-02-22 09:43:15 +01:00
orbitcowboy be96abc21a std.cfg: Added <not-bool/>-tags to <cctype> function args. 2020-02-22 09:39:21 +01:00
Ken-Patrick Lehrmann 0b7649ca9b Fix 9298 (#2476)
* Fix 9298

Tell cppcheck that strcpy returns its first argument, and use that
knowledge in checkTokenInsideExpression.

* Add missing unit tests in cmake
2020-01-09 08:47:36 +01:00
orbitcowboy 18b8db1e15 std.cfg: Added missing unsigned type qualifiers to 'UINT_XXX'-constants. 2019-12-20 09:47:42 +01:00
Daniel Marjamäki 2f00141c72 Revert "Fixed #9452 (FP syntaxError - _Pragma before struct with two constructors)"
This reverts commit 14539b56a3.
2019-11-17 22:18:30 +01:00
Daniel Marjamäki 14539b56a3 Fixed #9452 (FP syntaxError - _Pragma before struct with two constructors) 2019-11-17 18:50:40 +01:00
Daniel Marjamäki f5e3dc9a38 Improved fix for #8978 (False positive: Variable assigned value that is never used when assigning via iterator) 2019-11-17 12:08:21 +01:00
Paul Fultz II 4ebf54d090 Fix issue 9437: Dont assume init list constructor for strings (#2366)
* Fix issue 9437: Dont assume init list constuctor for strings

* Update the schema

* Add documentation
2019-11-17 03:22:04 +01:00
orbitcowboy 1d19f57c5e std.cfg: No real changes. Updated wrong header for 'wcscmp' [ci skip] 2019-11-14 09:23:37 +01:00
orbitcowboy dd30f37642 std.cfg: Merged 'wcscmp' and 'strcmp' configurations and added better tests. 2019-11-14 08:43:31 +01:00
orbitcowboy 09eaa412b1 std.cfg: Improved cfg for 'mbstowcs' 2019-11-13 16:55:17 +01:00
orbitcowboy 177eed122a std.cfg: Added 'indirect' flag for destination argument of 'mbstrtowc' function. 2019-11-13 14:34:02 +01:00
Daniel Marjamäki 5bf53cc2b4 std.cfg: first parameter for vsprintf can be NULL 2019-11-10 19:09:34 +01:00
Paul Fultz II 650408a210 Improve librarys config of substr to improve checking cases in issue 8021 (#2338) 2019-11-08 08:02:33 +01:00
orbitcowboy f59a2b491d #9455: Added a test case. 2019-11-05 14:00:50 +01:00
Sebastian bca1192e61
std.cfg: Add some missing std::map::*() function configurations (#2289)
Reference:
https://en.cppreference.com/w/cpp/container/map/equal_range
https://en.cppreference.com/w/cpp/container/map/lower_bound
https://en.cppreference.com/w/cpp/container/map/upper_bound
https://en.cppreference.com/w/cpp/container/map/contains
2019-10-21 13:45:19 +02: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 42470d91bb std.cfg: Add support for C11 functions thrd_*() and mtx_*() (#2270)
* std.cfg: Add support for C11 function thrd_exit().

Reference: https://en.cppreference.com/w/c/thread/thrd_exit

* std.cfg: Add rest of thrd_*() functions and the mtx_*() functions
2019-10-16 12:13:16 +02:00
Sebastian d6f879c2f1
std.cfg: Add configuration for std::map::at() (#2256)
Reference: https://en.cppreference.com/w/cpp/container/map/at
2019-10-10 13:13:29 +02:00
Rikard Falkeborn ddcbed21d6 std.cfg: Add podtype char8_t (#2257)
c++20 introduced type char8_t.

From https://en.cppreference.com/w/cpp/language/types:

char8_t - type for UTF-8 character representation, required to be large
enough to represent any UTF-8 code unit (8 bits). It has the same size,
signedness, and alignment as unsigned char (and. therefore, the same size
and alignment as char and signed char), but is a distinct type.
2019-10-10 08:12:32 +02:00
Daniel Marjamäki 69a54b0ee9 Library: added 'stdtype' attribute in <podtype> element so we can configure standard types better 2019-09-29 16:48:25 +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
PKEuS 9864c8577f std.cfg: Added std::time_t and std::clock_t 2019-09-02 15:30:55 +02:00
orbitcowboy 1994cbbb9c std.cfg: Improved configuration for mbrlen() and extended test cases. 2019-08-27 08:18:19 +02:00
amai2012 a209c5b37a Correct config for mbrlen() 2019-08-26 21:25:50 +02:00
orbitcowboy a9bdf99e07 std.cfg: Added *experimental* support for math constants liken M_PI. These are *NOT* standard, but they are supported by GCC/Clang and VS. 2019-07-31 11:11:01 +02:00
Sebastian 2a3567cb44
std.cfg: Add std::string::copy() and std::wstring::copy() (#2041)
Reference:
https://en.cppreference.com/w/cpp/string/basic_string/copy
http://www.cplusplus.com/reference/string/string/copy/
2019-07-29 18:57:50 +02:00
Sebastian dcc2599121
std.cfg: Add `<pure/>` to std::min() and std::max() (#2037) 2019-07-26 07:51:26 +02:00
Sebastian 2d5f3ae3b4
std.cfg: Add std::next() and std::prev() (#2022)
Reference:
https://en.cppreference.com/w/cpp/iterator/next
https://en.cppreference.com/w/cpp/iterator/prev
2019-07-25 12:40:15 +02:00
Sebastian d185607122
std.cfg: Fix function configuration for std::back_inserter (#2023)
Reference: https://en.cppreference.com/w/cpp/iterator/back_inserter
2019-07-24 12:44:56 +02:00
amai2012 2915376c4f Remove attribute use-retval from std::rotate 2019-07-19 20:33:15 +02:00
Sebastian f50cd2330c
std.cfg: Add some more std::<container>::swap() functions (#2018) 2019-07-19 10:00:14 +02:00
Daniel Marjamäki 783f7f1648 Rename safeValues to unknownValues 2019-07-11 16:05:48 +02:00
Sebastian e49b098a86
std.cfg: Add mem_fn() (#1976)
std.cfg: Add mem_fn()

Reference:
https://en.cppreference.com/w/cpp/utility/functional/mem_fn
2019-07-11 08:26:24 +02:00
Daniel Marjamäki 05d35b063d Function return: Extra check of safe function return values 2019-07-10 20:00:21 +02:00
Rikard Falkeborn 839fcddd8a Fix #6115 (Add support to realloc to cfg files) (#1953)
* Allow to configure realloc like functions

* memleakonrealloc: Bring back tests.

The old memleak checker was removed, and the tests for it was removed in
commit 9765a2dfab. This also removed the
tests for memleakOnRealloc. Bring back those tests, somewhat modified
since the checker no longer checks for memory leaks.

* Add realloc to mem leak check

* Add tests of realloc buffer size

* Configure realloc functions

* Add test of freopen

* Allow to configure which element is realloc argument

* Fix wrong close in test

cppcheck now warns for this

* Update manual

* Update docs

* Rename alloc/dalloc/realloc functions

Naming the member function realloc caused problems on appveyor. Rename
the alloc and dealloc functions as well for consistency.

* Change comparisson order

* Remove variable and use function call directly

* Create temporary variable to simplify

* Throw mismatchError on mismatching allocation/reallocation

* Refactor to separate function

* Fix potential nullptr dereference

As pointed out by cppcheck.
2019-07-05 12:44:52 +02:00
orbitcowboy 952a4becf6 std.cfg: Added return type to itoa(). 2019-06-20 15:24:35 +02:00
orbitcowboy 1e53cf0397 std.cfg: Added support for std::stringstream::str() 2019-06-07 21:07:22 +02:00
orbitcowboy 92d8b9d68f std.cfg: Added support for std::ofstream::write(). 2019-06-07 21:02:16 +02:00
orbitcowboy 89d4cefa96 std.cfg: Added support for std::distance() and std::set::count(). 2019-06-07 20:57:26 +02:00
orbitcowboy a6e681f71e std.cfg: Added support for std::rotate() and std::rotate_copy(). 2019-06-06 15:04:00 +02:00
orbitcowboy 2b816d09fb std.cfg: Added support for std::min_element() and std::max_element(). 2019-06-06 14:55:37 +02:00
orbitcowboy 9a163e59bf std.cfg: Added support for std::ostream::put() and std::stringstream::put(). 2019-06-06 14:45:51 +02:00
orbitcowboy 080ba9004c std.cfg: Attempt to add (partial) support for std::istringstream::get. 2019-06-05 13:54:38 +02:00
orbitcowboy 0b726d5738 std.cfg: Attempt to add (partial) support for std::istream::get(). 2019-06-05 13:53:01 +02:00
orbitcowboy c73d3930cc std.cfg: Added support for more interfaces. 2019-06-04 17:01:30 +02:00
orbitcowboy da3dc168cd std.cfg: Added support for more interfaces. 2019-06-04 16:44:14 +02:00
orbitcowboy 613defbf39 std.cfg: Added support for std::ostream::write() and std::fstream::write(). 2019-06-04 09:02:25 +02:00
Paul Fultz II 091f4bcf8d Add check for unnecessary search before insertion
This will warn for cases where searching in an associative container happens before insertion, like this:

```cpp
void f1(std::set<unsigned>& s, unsigned x) {
    if (s.find(x) == s.end()) {
        s.insert(x);
    }
}

void f2(std::map<unsigned, unsigned>& m, unsigned x) {
    if (m.find(x) == m.end()) {
        m.emplace(x, 1);
    } else {
        m[x] = 1;
    }
}
```

In the case of the map it could be written as `m[x] = 1` as it will create the key if it doesnt exist, so the extra search is not necessary.

I have this marked as `performance` as it is mostly concerning performance, but there could be a copy-paste error possibly, although I dont think thats common.
2019-05-02 11:04:23 +02:00
amai2012 b5ee9d97ef Move some signal constants from posix.cfg to std.cfg. Add some more interfaces to posix.cfg 2019-04-26 19:26:04 +02:00
Daniel Marjamäki 87a3d2caa1 std.cfg: Add auto_ptr and weak_ptr configs 2019-04-24 14:21:26 +02:00
Daniel Marjamäki 2513c1499b Library: Added <smart-pointer> element 2019-04-24 13:06:58 +02:00
orbitcowboy 7ac3bf5fd8 std.cfg: Removed MIN/MAX macros since they cause problems with http://cppcheck.osuosl.org:8000/amap-align 2019-04-03 09:11:48 +02:00
Daniel Marjamäki b88cc7c19d Fix std.cfg 2019-04-01 20:28:31 +02:00
Daniel Marjamäki 761f18c75c Fixed #8988 (False positive: using memset on struct) 2019-04-01 19:32:03 +02:00
versat 316475f79f std.cfg: Add "buffer-size" attribute and tests for aligned_alloc(). 2019-03-21 09:25:42 +01:00
Sebastian 432c04281a
Libraries: Move valloc() from std.cfg to posix.cfg. (#1743)
Move valloc() to posix.cfg since it is a legacy POSIX function and not
part of the standard (not even commonly used). It is not available in
msvc (Visual Studio).
2019-03-20 14:10:36 +01:00
Daniel Marjamäki 14528bcf25 Library: allowed values for the buffer-size attribute: malloc/calloc/strdup 2019-03-20 06:46:55 +01:00
Daniel Marjamäki 18668a52b9 Library: Added buffer-size attribute for <alloc> 2019-03-17 10:55:15 +01:00
orbitcowboy f449e75214 std.cfg: Added support for std::getline(). 2019-03-11 15:32:15 +01:00
Sebastian 0bab9d778b
std.cfg: Fix wprintf(), add comment to swprintf(). (#1729)
wprintf(): The format string must be initialized. So add `<not-uninit/>`
swprintf(): `<formatstr/>` should not be used because Microsoft uses the
same function with a different order of the arguments. Add comment to
document this in the library configuration also. See ticket
https://trac.cppcheck.net/ticket/4790
2019-03-06 21:13:48 +01:00
orbitcowboy 8c0ab16863 std.cfg: Added support for more interfaces. 2019-03-05 18:13:42 +01:00
versat df73f7f355 std.cfg, windows.cfg: Move strcpy_s from windows.cfg to std.cfg.
strcpy_s belongs to the standard so it must be in std.cfg instead of
windows.cfg.
Configuration for strcpy_s has been improved and tests were added.
Found by daca@home
2019-03-05 15:33:16 +01:00
versat 0ae24b950f std.cfg: Add support for snprintf_s().
sprintf_s works very similar but it is already configured in the
windows library. Configuring sprintf_s in std.cfg leads to conflicts in
the windows configuration tests.
Found by daca@home
2019-03-05 14:44:33 +01:00
versat ce818631ab std.cfg: Add support for ctime_s(). 2019-03-05 13:57:52 +01:00
Sebastian 9efb720a98
std.cfg: Add missing argument directions as far as possible. (#1725)
I added all argument directions i know or where i was able to find
information without too much effort. When in doubt i looked at the
Microsoft SAL annotations and used similar configurations when this
made sense.
2019-03-05 13:45:41 +01: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
Sebastian 9a5fcddb5d
Library configuration: Enable configuring the direction of arguments. (#1717)
This enhances the library configuration so the direction of function
arguments can be specified (in, out, inout).
isVariableChangedByFunctionCall() uses this information now to avoid
guessing.
2019-03-01 15:47:08 +01:00
orbitcowboy aa4265978c std.cfg: Added support for std::list::remove(). 2019-03-01 15:10:36 +01:00
orbitcowboy 16e3a0ada6 std.cfg: Added support for std::shuffle() and std::random_shuffle(). 2019-03-01 15:05:10 +01:00
orbitcowboy 9348a627e0 std.cfg: Added support for more interfaces. 2019-03-01 09:28:46 +01:00
orbitcowboy 2fad53e4f8 std.cfg: Enusre the return value of realloc()-functions is taken into account. 2019-03-01 08:57:59 +01:00
orbitcowboy f70e01b2b1 std.cfg: Added (experimental) support for MIN/MAX-macros. In case it turnes out this causes unexpected side effects, they can be easily removed. 2019-02-28 23:03:38 +01:00
Sebastian 71b1b2dd76
std.cfg: Add support for std::vector::assign(). (#1713)
Reference:
https://en.cppreference.com/w/cpp/container/vector/assign
2019-02-28 18:43:54 +01:00
Sebastian 13b37631a6
std.cfg: Add support for std::vector::swap() and std::swap() (#1700)
References:
https://en.cppreference.com/w/cpp/container/vector/swap
https://en.cppreference.com/w/cpp/algorithm/swap
2019-02-26 18:21:17 +01:00
orbitcowboy d218fa5919 std.cfg: Added support for more interfaces. 2019-02-24 18:43:07 +01:00
orbitcowboy 406b29548a std.cfg: Added support for more interfaces. 2019-02-24 18:35:02 +01:00
orbitcowboy 32e1d383a4 std.cfg: Added support for std::replace() and std::replace_if(). 2019-02-24 00:06:38 +01:00
orbitcowboy 748fe7f25e std.cfg: Added support for std::back_inserter(). 2019-02-24 00:00:20 +01:00
orbitcowboy c38cbd967b std.cfg: Added support for std::reverse(). 2019-02-23 23:55:13 +01:00
orbitcowboy 59d3ce2343 std.cfg: Added support for std::remove_if(). 2019-02-23 23:51:11 +01:00
orbitcowboy 568887eadf std.cfg: Added support for std::unique(). 2019-02-23 23:44:23 +01:00
orbitcowboy 0fa70ebb2a std.cfg: Added support for more interfaces. 2019-02-23 18:38:48 +01:00
orbitcowboy 216d324a59 std.cfg: Added support for more interfaces. 2019-02-23 18:35:13 +01:00
orbitcowboy af9cbe23f9 std.cfg: Added support for more interfaces. 2019-02-20 10:02:01 +01:00
orbitcowboy a7b9d8de1b std.cfg: Added support for std::ios_base::setf() and std::ostringstream::setf(). 2019-02-18 12:20:34 +01:00