Commit Graph

226 Commits

Author SHA1 Message Date
Dmitry-Me cfac54c42a Improve test coverage for %I32d used with scanf() 2019-11-19 18:05:21 +03:00
Wolfgang Stöggl 1ea3fc8083 Allow SSIZE_T in addition to ssize_t (#2263)
The Windows Data Type SSIZE_T is declared in BaseTsd.h
However, it is written in capital letters

- Fixes e.g. the following false positive:
  (portability) %zd in format string (no. 1) requires 'ssize_t' but the
  argument type is 'SSIZE_T {aka signed long long}'.
  [invalidPrintfArgType_sint]
2019-10-24 21:51:20 +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
rikardfalkeborn 0e988cc755 Fix #8992: Add originalTypeToken to auto (#1701) 2019-02-27 06:44:31 +01:00
rikardfalkeborn dc4e7cef88 Run simplifyPlatformTypes on library return types (#1672)
Add a call to simplifyPlatformTypes() in
SymbolDatabase::setValueTypeInTokenList() to simplify return types of
library configured functions. This fixes the FN in #8141. Regression
tests are added, both for the original issue and another FN in the comments.

In order to do that, move simplifyPlatformTypes() to TokenList from Tokenizer.
This is a pure refactoring and does not change any behaviour. The code was
literally copy-pasted from one file to another and in two places
'list.front()' was changed to 'front()'.

When adding the call to simplifyPlatformTypes(), the original type of
v.size() where v is a container is changed from 'size_t' to 'std::size_t'.
Tests are updated accordingly. It can be noted that if v is declared as
'class fred : public std::vector<int> {} v', the original type of 'v.size()'
is still 'size_t' and not 'std::size_t'.
2019-02-15 13:29:52 +01:00
Daniel Marjamäki bd7790fd8c Update copyright year 2019-02-09 07:24:06 +01:00
Daniel Marjamäki 8dd641b8be Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
IOBYTE ce50df8047 Fix override warnings. (#1234) 2018-05-15 16:37:40 +02:00
Daniel Marjamäki 0daa3bba30 ValueType: Improved type handling of containers when [] operator is used 2018-04-06 22:26:35 +02:00
Sebastian 2e5d7a8391 Fix #8381: false positives for swprintf_ and stprintf_s (#1080)
This fixes false positives because of wrong configuration in
windows.cfg.
Add tests in testio.cpp and test/cfg/windows.cpp to avoid regression.
2018-02-03 05:10:52 +01:00
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +01:00
IOBYTE 03603c85cf Fixed #8331 (stack overflow: daca: firefox-58.0b14) (#1027) 2018-01-12 08:19:21 +01:00
PKEuS b684e1f202 Updated AStyle to version 3.0.1 2018-01-08 20:20:33 +01:00
Dmitry-Me 4ac56a55be Fix FN for signed short passed as %hx into printf 2017-11-21 22:17:02 +03:00
Dmitry-Me c6bf881ee6 Fix FN for signed char passed as %hhx into printf 2017-11-21 22:14:48 +03:00
Dmitry-Me 5869f6d989 Fix FN for std::intmax_t passed as %ld, %lld into scanf 2017-11-20 23:07:37 +03:00
Dmitry-Me 7cf21f329a Fix FN for size_t, uintmax_t passed as %lx and %llx into printf 2017-11-20 22:56:33 +03:00
Dmitry-Me f0a7365f35 Fix FN for ptrdiff_t passed as %Ix into printf 2017-11-20 22:51:10 +03:00
Dmitry-Me 20eaf3fcca Tests for intmax_t passed as %ld and %lld into scanf 2017-11-20 22:34:31 +03:00
Dmitry-Me eb4bb893b3 Fix FP for std::intmax_t passed as %jd into scanf 2017-11-20 22:31:13 +03:00
Dmitry-Me 125daec71b Tests for std::intmax_t passed as %ju and %jx into scanf 2017-11-20 22:14:00 +03:00
Dmitry-Me c4b6db7e23 Fix FP for std::uintmax_t passed as %ju and %jx into scanf 2017-11-20 22:13:20 +03:00
Dmitry-Me cf05b722a9 Fix FN for intmax_t passed as %jx into printf 2017-11-18 00:00:02 +03:00
Dmitry-Me 73414ee56c Fix FN for std::uintmax_t passed as %Lu and %Lx into scanf 2017-11-17 23:58:09 +03:00
Dmitry-Me 167258a6bf Fix FNs when various types are passed as %tu into printf 2017-11-15 22:40:16 +03:00
Dmitry-Me 7f48283b98 Improve test coverage for %I64x used with scanf 2017-11-13 21:47:56 +03:00
Dmitry-Me ee4831ca2b Tests for %u, %x with various length specifiers used with printf 2017-11-13 21:46:26 +03:00
Dmitry-Me 24aa6a858a Tests for %u, %x with various length specifiers used with printf 2017-11-10 23:53:53 +03:00
Dmitry-Me 432ea03f59 Expect warning for wrong argument sign 2017-11-09 19:07:41 +03:00
Daniel Marjamäki ced3f4cde8 astyle formatting
[ci skip]
2017-11-09 15:57:03 +01:00
Dmitry-Me 94dd63f196 Fix FN for std::uintmax_t passed as %lx, %lu scanf read targets 2017-11-09 15:38:48 +03:00
Dmitry-Me b301b44897 Fix FN for unsigned ptrdiff_t passed as %lu into scanf 2017-11-09 14:43:09 +03:00
Dmitry-Me 054444167d Improve test coverage for %lx used with scanf 2017-11-09 14:15:02 +03:00
Dmitry-Me 78be821431 Fix FN for std::uintmax_t passed as %llx, %llu scanf read targets 2017-11-09 11:28:07 +03:00
Dmitry-Me 74c778c5f0 Fix FN when unsigned ptrdiff_t is passed as %llu into scanf 2017-11-09 00:26:07 +03:00
Dmitry-Me 703d86992d Fix FN when size_t, uintmax_t are passed as %Lx into scanf 2017-11-08 23:52:49 +03:00
Dmitry-Me c563917a5d Improve test coverage for intmax_t, uintmax_t, intptr_t, uintptr_t used as scanf read targets 2017-11-08 18:13:45 +03:00
Dmitry-Me 89b83b2d16 Fix FN for unsigned ptrdiff_t passed as %Ix into scanf 2017-11-08 15:06:51 +03:00
Dmitry-Me 970aee9ce1 Fix FN for ptrdiff_t passed as %zd into scanf 2017-11-08 14:22:03 +03:00
Dmitry-Me 3d2f86cef7 Improve test coverage for %zd used with scanf 2017-11-08 13:43:10 +03:00
Dmitry-Me 4fcef2f0c7 Improve test coverage for %llu, %llx, %Lu, %lx used with scanf 2017-11-08 12:18:35 +03:00
Dmitry-Me 9d53b70a56 Improve test coverage for Iu, Ix used with scanf 2017-11-08 08:06:05 +03:00
Dmitry-Me 1985d75442 Improve test coverage for %llx, %Lx, %I64x used with scanf 2017-11-08 00:05:21 +03:00
Dmitry-Me d31107451b Improve test coverage for void* passed as scanf read target 2017-11-07 23:43:30 +03:00
Dmitry-Me d4a1c0d8bd Improve test coverage for %lu and %llu used with printf 2017-11-07 21:44:46 +03:00
Dmitry-Me 043a565f5d Improve test coverage for %jx, %tx, %zx used with scanf 2017-11-07 00:27:47 +03:00
Dmitry-Me 95b37f665d Improve test coverage for %lx, %hx, %hhx used with scanf 2017-11-06 23:13:48 +03:00
Dmitry-Me 4681c7e4cf Improve test coverage for unsigned ptrdiff_t used as scanf read target 2017-11-06 22:04:59 +03:00
Dmitry-Me 41cffe40cf Improve test coverage for ptrdiff_t used as scanf read target with %Id 2017-11-06 21:01:34 +03:00
Dmitry-Me 3089352edb Improve test coverage for %lld used with printf 2017-10-27 22:25:34 +03:00