Commit Graph

11284 Commits

Author SHA1 Message Date
Rikard Falkeborn 38dea4719b Fix #9166 (print proper types in invalidCast message) (#2347)
* Fix #9166 (print proper types in invalidCast message)

* Use ValueType->str()

* astyle

* Set default sign to avoid issues on different platforms
2019-11-11 07:17:50 +01:00
Daniel Marjamäki eaa5bfcadd Remove 'unsafeClassDivZero' warning. The software verification will cover this better. 2019-11-10 16:49:34 +01:00
Daniel Marjamäki fcc5fad3ed Fixed #9113 (false positive: (error) Buffer is accessed out of bounds) 2019-11-10 16:42:48 +01:00
Paul Fultz II 6f29e299fc Fix issue 9439: false positive: unique_ptr and nullPointerRedundantCheck (#2346) 2019-11-10 09:44:59 +01:00
Paul Fultz II c1da6c7dd2 Fix issue 9461: False positive: Reference to temporary returned using trailing return type (#2345) 2019-11-10 09:44:04 +01:00
IOBYTE 0fed6f0091 fix clang testsuite crash (#2341) 2019-11-09 18:00:21 +01:00
Daniel Marjamäki 81fff2edf1 Fixed #9464 (Import compile database; only check given configuration) 2019-11-09 17:51:42 +01:00
Paul Fultz II c75bbbe253 Fix issue 9404: False positive: Either the condition 'if(x)' is redundant or there is possible null pointer dereference: a->x (#2322)
* Fix issue 9404: False positive: Either the condition 'if(x)' is redundant or there is possible null pointer dereference: a->x

* Use simpleMatch

* Add a test case for the FP

* Check if expression is changed

* Check for no return scope

* Use simpleMatch
2019-11-08 08:11:41 +01:00
Rikard Falkeborn 1fcbd696be Token::ConcatStr(): Handle mixed string literals (#2337)
Improve handling of adjacent string literals of different types.

Example of adjacent string literals: "ab" L"cd".

In C89, C++98 and C++03, this is undefined. As of C99 and C++11, this is
well defined and the two string literals are concatenated to L"abcd".
C11 and C++11 introduces the utf16, utf32 and (C++ only) utf8 string
types. Concatenating any of these with a regular c-string works exactely
as the wide string example above. The result of having two adjacent
string literals with different prefix is implementation defined, unless
one is an UTF-8 string literal and the other is a wide string literal.
In this case the behaviour is undefined.

Ignore the undefined and ill-formed programs (this behaviour is unchanged)
and make sure that concatenating a plain c string literal with a prefixed
one works correct (in C99 and C++11 and later versions). It also makes the
behaviour consistent since previously, "ab" L"cd" would result in "abcd"
while L"ab" "cd" would result in L"abcd".

It also means the somewhat awkward updatePropertiesConcatStr() test can
be removed since the added tests would not work if update_properties()
was not called in concatStr().

Since the prefix is stored in the token, testing the type of the string
is not relevant in TestSimplifyTokens. It is tested extensively in
TestToken::stringTypes().
2019-11-08 08:03:45 +01:00
Paul Fultz II 2e955d0f22 Fix issue 9453: False positive: danglingLifetime, address of array argument (#2335) 2019-11-07 09:33:17 +01:00
Paul Fultz II d1f225b8ee Fix issue 9201: FP: returnDanglingLifetime on pointer to variable of static struct (#2303)
* Fix issue 9201: FP: returnDanglingLifetime on pointer to variable of static struct

* Fix capture of non-local variables in lambdas
2019-11-05 07:10:32 +01:00
Paul Fultz II c61880c457 Search relative path first before install path (#2328) 2019-11-05 07:09:59 +01:00
Daniel Marjamäki 06ea1a2b53 Fixed #9312 (FP : variable is assigned a value that is never used (static)) 2019-11-04 17:59:16 +01:00
Paul Fultz II acd2a92efc Fix issue 9395 and 9423: False positive: nullPointerRedundantCheck (#2323) 2019-11-04 07:02:25 +01:00
Paul Fultz II c38bbb75e4 Fix issue 9448: Check for temporaries from library function calls (#2312) 2019-11-03 22:02:10 +01:00
Daniel Marjamäki c7a23f126f Fixed #9373 (False Positive - missingOverride) 2019-11-03 18:42:04 +01:00
Daniel Marjamäki c3ae028a41 Fixed #8617 (False positive: uninitdata for memory allocated and initialized in function called new (C code)) 2019-11-03 17:08:28 +01:00
Daniel Marjamäki 8c8952ae7c Fixed #9324 (FP compareBoolExpressionWithInt - when using C++ and/or operator synonyms) 2019-11-03 12:53:30 +01:00
Daniel Marjamäki 03ae0ccef3 AST: Do not hang for code 'foo({ for (a;b;c) {} });' 2019-11-03 11:02:59 +01:00
Daniel Marjamäki 791242ea78 Fixed #6975 and #9376 (Tokenizer: unknown macro without semicolon) 2019-11-02 19:34:19 +01:00
Daniel Marjamäki 28182084f2 Fix crash when there are too many nested scopes. Bail out after 1000 nested scopes. The crash was in gcc and was seen with daca@home. 2019-11-02 18:23:10 +01:00
Dmitry-Me f2cf71f6e9 Fix typo 2019-11-01 18:39:53 +03:00
IOBYTE 3f0ef01154 Fix #9446 (Syntax error on valid C++ code) (#2316) 2019-11-01 09:11:29 +01:00
Daniel Marjamäki 35d04cd2d3 AST: non-standard handling of ; in argument list for unknown macro 2019-11-01 09:05:45 +01:00
Daniel Marjamäki 6e9d496ab3 ValueFlow: handling of char literal size before ValueType has been set 2019-10-31 14:06:46 +01:00
versat 181e1baa69 cppcheck.vcxproj.filters: Also update this Visual Studio file
This .filters file has been automatically updated by Visual Studio when
the two new files were added. So it should also be updated.
2019-10-31 09:05:58 +01:00
Daniel Marjamäki 9094ff01d3 Fixed #9363 (knownConditionTrueFalse: False positive about function parameter) 2019-10-31 08:34:09 +01:00
versat 470f0cdfe3 lib/cppcheck.vcxproj: Fix Visual Studio build, add new files. 2019-10-31 08:29:19 +01:00
Daniel Marjamäki 6d1c84e3a6 Fixed #9449 (SymbolDatabase: Function lookup fails when string literal is converted to bool) 2019-10-30 21:05:42 +01:00
Daniel Marjamäki b96a347914 Tokenizer: Report unknown macro when argument list contains if/for/while/switch 2019-10-30 19:36:19 +01:00
Daniel Marjamäki 33d43808f7 Run dmake 2019-10-30 18:38:37 +01:00
Daniel Marjamäki 8c591308cb astyle formatting
[ci skip]
2019-10-30 18:19:45 +01:00
Paul Fultz II 694d147097 Refactor ProgramMemory and PathAnalysis (#2311)
* Traverse conditions for container size

* Move program memory to seperate file

* Revert "Traverse conditions for container size"

This reverts commit 914783769f.

* Move pathanalysis to seperate files
2019-10-30 17:57:46 +01:00
Rikard Falkeborn 239b660a52 Fix #9438 (Don't warn for return (void*) malloc(1)) (#2307) 2019-10-30 17:55:47 +01:00
Daniel Marjamäki 277c59e5f3 AST: Fixed AST for lambda that returns template type 2019-10-30 16:05:34 +01:00
IOBYTE 02e7f4f61c Fix template templates where the template template parameter is not the first parameter. (#2309) 2019-10-30 12:12:47 +01:00
Daniel Marjamäki 210232d35c Fixed #9314 (false positive: (error) Uninitialized variable: ret) 2019-10-29 20:36:58 +01:00
cyy cf5dd48994 add override (#2305) 2019-10-29 20:06:40 +01:00
Paul Fultz II 1ef85f9229 Fix issue 9432 and 9433: False positive: Reference to temporary returned (#2302) 2019-10-29 19:12:58 +01:00
Daniel Marjamäki c3c9559bee Fix Cppcheck warning 2019-10-27 18:22:47 +01:00
Daniel Marjamäki c899d7becf --verify: Fix false negative in itc 2019-10-27 16:47:56 +01:00
Daniel Marjamäki 2fa9a29ea7 --verify: Fix false negative in itc test suite 2019-10-27 16:40:16 +01:00
Daniel Marjamäki 83a7987f6f --verify: Fix false negative in itc test suite 2019-10-27 16:23:37 +01:00
Daniel Marjamäki c56a45840a Verify: Fix false negative in itc 2019-10-27 15:35:04 +01:00
Daniel Marjamäki 2c1905cc2b AST: Somewhat better handling of '{x}' function parameters 2019-10-27 12:00:08 +01:00
Daniel Marjamäki f03945a9e2 AST: better handling when returning list of lambdas 2019-10-26 19:19:20 +02:00
IOBYTE 6b4a3bc830 fix #9431 (Invalid syntax error on valid C++ code) (#2298) 2019-10-26 17:39:46 +02:00
Georgy Komarov 72f07c8a33 Add MISRA checks for rules 21.1 and 21.12 (#2284)
* Add MISRA 21.1 check

This also required add static field for functions in symboldatabase.

* Add MISRA R21.12

* Use newer ASSERT macroses in tests
2019-10-26 08:32:46 +02:00
Daniel Marjamäki 37bb19f02c Verify: Fix a false negative in the itc test suite 2019-10-25 21:46:02 +02: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