Daniel Marjamäki
f614d32d6a
Fixed #9519 (Syntax error on valid C++ 'enum {} (a)')
2019-12-15 08:40:04 +01:00
Daniel Marjamäki
bcfc5924fa
Fixed #9532 (False positive: Out of bounds access in expression 'v[0]' because 'v' is empty.)
2019-12-14 19:04:19 +01:00
Paul Fultz II
06752d75a5
Fix issue 9485: knownConditionTrueFalse false positive with integer constants ( #2447 )
...
* Fix issue 9485: knownConditionTrueFalse false positive with integer constants
* Formatting
2019-12-14 09:15:00 +01:00
IOBYTE
0e4efea530
fix #9539 (Syntax error for valid C++14 code) ( #2446 )
2019-12-12 20:50:20 +01:00
RobkeBaer
370196a14c
Fix extern c typedef syntax error ( #2438 )
...
* Fix extern c typedef syntax error
* Fix extraWhiteSpaceError
* Move test from testgarbage to testtokenize
2019-12-12 13:51:14 +01:00
Dmitry-Me
064795a705
Remove duplicate test
...
This partially reverts commit 047418dda1
2019-12-11 19:17:59 +03:00
Sebastian
6f2879a59b
errorlogger.cpp: Handle empty file-name like "*" (unmatchedSuppression) ( #2440 )
...
Using "--suppress=unmatchedSuppression" did not suppress the error-id in
all files, one needed to specify "*" as file-name. This commit also
allows empty file-names to suppress "unmatchedSuppression", not only "*"
or the exact file-name.
The manual uses the following example for suppressions specified in a
file:
// suppress all uninitvar errors in all files
uninitvar
This example suggests that no "*" has to be used to get suppression in
all files. I think that the command line parameter should work in the
same way.
2019-12-11 09:07:18 +01:00
Paul Fultz II
ad2f71338c
Fix issue 9525: Syntax Error: AST broken, 'if' doesn't have two operands inside lambda ( #2433 )
...
* Fix issue 9525: Syntax Error: AST broken, 'if' doesn't have two operands inside lambda
* Fix incorrect matchers
2019-12-10 21:21:07 +01:00
Sebastian
de4d44ae2f
opencv2.cfg: Add initial OpenCV 2.x API Library Configuration ( #2439 )
2019-12-10 19:34:30 +01:00
Paul Fultz II
4aa6385a97
Regression test for 9106: False positive duplicateCondition for struct member ( #2434 )
2019-12-09 06:51:58 +01:00
amai2012
f5df06a143
Run astyle [ci skip]
2019-12-08 11:22:19 +01:00
Paul Fultz II
ea2916a3e4
Fix issue 9514: Syntax Error: AST broken, 'for' doesn't have two operands. ( #2429 )
...
* Fix issue 9514: Syntax Error: AST broken, 'for' doesn't have two operands.
* Fix typo
2019-12-07 21:16:25 +01:00
Paul Fultz II
56e17fb228
Fix issue 9524: Syntax Error: AST broken, 'if' doesn't have two operands. ( #2432 )
2019-12-07 21:06:45 +01:00
Dmitry-Me
047418dda1
Improve test coverage for redundant bitwise operations
2019-12-06 19:14:03 +03:00
Sebastian
95e0b0d0f9
Fix #9510 : Crash in valueflow.cpp solveExprValues() (division by zero) ( #2420 )
...
`break` if divider `intval` is 0 to avoid division by 0 as suggested by @pfultz2
Trac ticket: https://trac.cppcheck.net/ticket/9510
2019-12-06 08:08:40 +01:00
IOBYTE
f637d97080
Fix 9509 (Syntax error on empty attribute list) ( #2423 )
2019-12-06 05:17:19 +01:00
Paul Fultz II
2978c67e6f
Fix issue 9511: Syntax Error: AST broken, 'if' doesn't have two operands. ( #2428 )
2019-12-06 04:19:46 +01:00
IOBYTE
5979eec2c0
Fix 9518 (Syntax error on valid C++) ( #2424 )
2019-12-05 20:51:36 +01:00
Dmitry-Me
7da68bff7b
Improve test coverage for missing destructors
2019-12-05 18:25:50 +03:00
Dmitry-Me
571de5844f
Improve test coverage for functions returning bool values
2019-12-04 18:12:10 +03:00
John Marshall
297efcd049
Avoid some additional memleakOnRealloc false positives ( #2422 )
...
* Avoid some additional memleakOnRealloc false positives
checkReallocUsage() already contains code to suppress the
`p = realloc(p, size)` error message when the pointer has been
previously copied from another variable (hence there is an additional
copy of the original pointer value) within the same function, as in
the added realloc21() test case.
Extend this so that `p = *pp` and `p = ptr->foo` are also recognized
as copies from another variable with the same original pointer value,
as in the added realloc22() and realloc23() test cases.
* Rewrite as a single findmatch() expression
2019-12-04 12:13:44 +01:00
Dmitry-Me
cf7ef2e703
Valid code for incrementing raw pointer ( #2418 )
2019-12-03 18:33:05 +01:00
Paul Fultz II
36977becba
Fix issue 9196: Lambda confuses check ( #2415 )
2019-12-03 18:30:52 +01:00
Dmitry-Me
b14a976c6c
Improve test coverage for postfix increment of raw pointers
2019-12-02 18:12:14 +03:00
Paul Fultz II
78b4485670
Regression for issue 8653: valueFlowAfterCondition: compound conditional ( #2416 )
2019-12-02 11:35:51 +01:00
Paul Fultz II
9cb39b1d7e
Fix issue 9482: False positive: Reference to temporary returned using trailing return type ( #2413 )
2019-12-01 15:10:02 +01:00
Paul Fultz II
f77347d7b4
Fix crash 9492: Crash in FwdAnalysis::checkRecursive() (condTok is nullptr) ( #2411 )
...
* Fix crash 9492: Crash in FwdAnalysis::checkRecursive() (condTok is nullptr)
* Formatting
2019-12-01 14:53:03 +01:00
Paul Fultz II
a71f58ffc2
Fix issue 9441: false positive: new(std::nothrow) and nullPointerRedundantCheck ( #2403 )
...
* Fix issue 9441: false positive: new(std::nothrow) and nullPointerRedundantCheck
* Skip new if it is a variable
2019-12-01 12:16:31 +01:00
Paul Fultz II
79a2e61721
Fix issue 6850: Valueflow: pointer alias, conditional value ( #2402 )
2019-11-30 09:22:03 +01:00
Paul Fultz II
f9d33c07f8
Fix issue 9458: Crash with shadow variables in a lambda ( #2406 )
...
* Fix issue 9458: Crash with shadow variables in a lambda
* Format
2019-11-29 09:45:02 +01:00
IOBYTE
f554a71dea
fix #9495 (Crash when parsing angle brackets in template with type traits (assertion failure)) ( #2407 )
2019-11-29 09:44:27 +01:00
Daniel Marjamäki
676a837af6
Fixed #9335 (FP constStatement "Found a statement that begins with string constant")
2019-11-28 17:49:33 +01:00
Dmitry-Me
ff36ebcff2
Improve test coverage for testing AST
2019-11-28 18:11:55 +03:00
Sebastian
fd900ab8b2
testnullpointer.cpp: Add test for dereferencing returned NULL pointer ( #2401 )
...
This adds a regression test to make sure that directly dereferencing a
returned NULL pointer issues a warning.
This has been asked on Stack Overflow:
https://stackoverflow.com/q/58981369
Cppcheck 1.89 does not warn for such a code, but 1.90 dev does. So it
is a good idea to make sure it is detected in the future too I guess.
2019-11-27 19:41:36 +01:00
Dmitry-Me
8af2ee968e
Fix incorrect usage of "unlikely" hint
2019-11-27 18:08:10 +03:00
Dmitry-Me
45e617f50b
Fix -Wint-conversion warning
2019-11-27 18:08:10 +03:00
Daniel Marjamäki
937c82efbe
AST: initializer list with lambda
2019-11-27 06:44:58 +01:00
Dmitry-Me
8f72a714d1
Fix -Wint-conversion warning
2019-11-26 18:03:47 +03:00
Sebastian
c3c3d6770c
Fix #9478 : Valueflow: printf does not change value ( #2388 )
...
Format-string arguments are now marked to have `in` direction, except
for `scan`-functions (like `scanf`) where these arguments are explicitly
marked to have `out` direction.
2019-11-24 01:40:31 +01:00
Daniel Marjamäki
ab2274b8ad
AST: lambdas and scopes in expressions
2019-11-23 21:36:36 +01:00
Daniel Marjamäki
ebd32cfd73
Syntax error: if (retval==)
2019-11-23 18:50:46 +01:00
IOBYTE
fb1d60bfb1
fix syntax error for num.operator std::string()[0] ( #2389 )
2019-11-23 17:42:24 +01:00
Dmitry-Me
5a48ac0c6e
Improve test coverage for invalid use of bool parameters
2019-11-22 18:11:38 +03:00
IOBYTE
df952926f8
fix syntax error for a.operator++() ? a.operator--() : 0 ( #2382 )
2019-11-20 22:13:32 +01:00
Dmitry-Me
98488790a1
Improve test coverage for %jd used with scanf()
2019-11-20 18:10:56 +03:00
IOBYTE
590aeea8f8
Fix #9483 (Assertion `tok && tok->str() == ">"' failed) ( #2381 )
2019-11-20 07:02:25 +01:00
Rikard Falkeborn
f6a2034a4c
Add regression tests for fixed crashes ( #2379 )
...
The invalid code in Trac tickets #8750 , #8753 , #8756 , #8762 , #8764
and #8765 previously crashed cppcheck. Now it throws a syntax error
instead. Add some tests for these tickets.
2019-11-19 21:50:53 +01:00
Armin Müller
130ebe4b85
Typos found by running "codespell" ( #2380 )
2019-11-19 20:02:24 +01:00
Dmitry-Me
cfac54c42a
Improve test coverage for %I32d used with scanf()
2019-11-19 18:05:21 +03:00
Paul Fultz II
479fbb85a2
Fix issue 9443: Internal error: Token::astOperand2() cyclic dependency. ( #2376 )
...
* Improve nested init lists
* Fix issue 9443: Internal error: Token::astOperand2() cyclic dependency.
2019-11-19 11:38:03 +01:00
Dmitry-Me
55051b777b
Remove unneeded string copy
2019-11-19 10:19:13 +03:00
orbitcowboy
2ff18b76ec
test std.cfg: Improved tests for strncpy and strrchr .
2019-11-18 13:53:42 +01:00
orbitcowboy
d5d2915873
test std.cfg: Improved tests for strncmp and strncat.
2019-11-18 13:43:49 +01:00
Paul Fultz II
ed1acc319d
Fixx issue 9355: FP constParameter when returning non-const reference to struct member ( #2373 )
2019-11-18 06:39:50 +01:00
IOBYTE
7f6ebaa6b2
fix syntax error for VTK_LEGACY_BODY(vtkMatrix3x3::operator[], "VTK 7.0"); ( #2372 )
2019-11-18 06:38:53 +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
Daniel Marjamäki
5654630099
Fixed #8978 (False positive: Variable assigned value that is never used when assigning via iterator)
2019-11-16 19:49:54 +01:00
Daniel Marjamäki
7cd7aff60a
Fixed #9285 (Misleading warning message)
2019-11-16 17:24:54 +01:00
Daniel Marjamäki
bae4faa786
Fixed #9422 (FP uninitdata - writing pointer to output stream)
2019-11-16 11:47:57 +01:00
IOBYTE
754c1fff66
fix syntax error for conversion operator for type with global namespace ( #2365 )
...
* fix syntax error for conversion operator for type with global namespace
* fix syntax error when taking address of operator function
* fix syntax error for using ::operator "" _a;
* fix syntax error for template<> void operator "" _h<'a', 'b', 'c'>() {}
* fix syntax error for operator in parentheses
2019-11-16 08:03:13 +01:00
IOBYTE
3a617fa04a
Fix #9472 (Syntax error on valid C++ code) ( #2363 )
...
There are probably a lot more valid code patterns that generates syntax
errors so I added "operator" to the error message to make it easier to
find them.
2019-11-15 07:03:57 +01:00
Daniel Marjamäki
7e0fc4fb00
Tokenizer: Detect more syntax errors when operator does not have operands
2019-11-14 21:18:31 +01:00
orbitcowboy
dbbb7f544a
test std.cfg: Improved strlen() tests.
2019-11-14 16:45:27 +01:00
orbitcowboy
ea92695e54
test std.cfg: Improved sscanf() tests.
2019-11-14 16:38:30 +01:00
orbitcowboy
ade54bef3f
test std.cfg: Added better tests.
2019-11-14 10:48:23 +01:00
IOBYTE
2eb575d990
Fix #9468 (Syntax error on valid C++) ( #2358 )
2019-11-14 09:26:21 +01:00
orbitcowboy
dd30f37642
std.cfg: Merged 'wcscmp' and 'strcmp' configurations and added better tests.
2019-11-14 08:43:31 +01:00
orbitcowboy
20e2c513b6
test std.cfg: Added better test cases for toupper() and tolower().
2019-11-14 08:31:00 +01:00
IOBYTE
f88ae21d8f
Fix #9467 (False positive on local variable when template specialization is used) ( #2357 )
2019-11-13 21:34:27 +01:00
orbitcowboy
09eaa412b1
std.cfg: Improved cfg for 'mbstowcs'
2019-11-13 16:55:17 +01:00
orbitcowboy
aa5c42ffc5
test std.cfg: Addressed comments from 177eed122a (comments)
2019-11-13 15:07:57 +01:00
orbitcowboy
177eed122a
std.cfg: Added 'indirect' flag for destination argument of 'mbstrtowc' function.
2019-11-13 14:34:02 +01:00
Paul Fultz II
7841430793
Fix issue 9428: FP uninitvar for pointer passed to sscanf ( #2344 )
...
* Add indirect to library cfg files
* Check indirect for non null arguments
* Reenable subfunction analysis
* Use indirect 1 when using not-null
* Parse correct string name
* Update documentation
* Make attribute optional
2019-11-13 12:46:54 +01:00
Daniel Marjamäki
f5a6aa530d
Fixed #9417 (FP uninitvar - member initialized in operator())
2019-11-11 15:00:53 +01: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
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
Rikard Falkeborn
af170c8e3f
Add regression test for #8923 ( #2348 )
...
This was fixed in 5a32d2d017
. Add a regression test
with array arguments.
2019-11-11 07:15:24 +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
Rikard Falkeborn
2d326c011d
Add regression test for #9028 ( #2343 )
...
Ticket #9028 was fixed in 5800692fa1
, add a test case where the
class definition is seen.
2019-11-10 08:28:46 +01:00
Rikard Falkeborn
11319a397a
ValueFlow: Add test with hexadecimal floating point literal ( #2342 )
2019-11-10 08:27:55 +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
650408a210
Improve librarys config of substr to improve checking cases in issue 8021 ( #2338 )
2019-11-08 08:02:33 +01:00
orbitcowboy
c358688c68
Formatted code. There are no functional changes. [ci skip]
2019-11-07 11:29:37 +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
KenPatrickLehrmann
1114dc0536
Enhance handling of assertion from googletest ( #2331 )
...
* Enhance handling of assertion from googletest
* Update googletest, and add it to cmake build
* Enhance ASSERT_STR* in googletest.cfg
2019-11-06 21:38:01 +01:00
orbitcowboy
f59a2b491d
#9455 : Added a test case.
2019-11-05 14:00:50 +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
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
fadf209e18
Add test for #9326 (FP knownConditionTrueFalse - Returning bool variable treated as condition)
2019-11-03 08:49:39 +01:00
Daniel Marjamäki
df8bdabddd
Testing; Readded tests
2019-11-03 08:45:34 +01:00
Daniel Marjamäki
791242ea78
Fixed #6975 and #9376 (Tokenizer: unknown macro without semicolon)
2019-11-02 19:34:19 +01:00
Dmitry-Me
0b97f37736
Improve test coverage
2019-11-01 18:41:10 +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
Sebastian
8b2903d5ce
openssl.cfg: Add OpenSSL library configuration with tests ( #2248 )
...
* openssl.cfg: Add OpenSSL library configuration with tests
Reference: https://www.openssl.org/docs/man1.1.1/man3/
* openssl.cfg: Add some configurations for EVP functions
Add alloc/dealloc configuration for EVP_CIPHER_CTX_new and
EVP_CIPHER_CTX_free.
Add configuration for encryption functions that are used in example code
which is added to the tests.
2019-10-31 09:21:08 +01:00
Daniel Marjamäki
9094ff01d3
Fixed #9363 (knownConditionTrueFalse: False positive about function parameter)
2019-10-31 08:34:09 +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
8c591308cb
astyle formatting
...
[ci skip]
2019-10-30 18:19:45 +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
Paul Fultz II
02150e741d
Fix issue 7836: Add regression test ( #2308 )
2019-10-30 12:12:02 +01:00
Sebastian
02c0240dcd
Fix #9322 : bsd.cfg, gnu.cfg: Fix FP for mmap when argument "fd" is -1 ( #2306 )
...
In contrast to POSIX, GNU and BSD allow or even require the argument
"fd" to be set to -1 if MAP_ANONYMOUS or MAP_ANON is specified.
2019-10-30 09:39:50 +01:00
Daniel Marjamäki
210232d35c
Fixed #9314 (false positive: (error) Uninitialized variable: ret)
2019-10-29 20:36:58 +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
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
Sebastian
8fb794e731
libsigc++.cfg: Add configuration for library libsigc++ ( #2291 )
...
* libsigc++.cfg: Add configuration for library libsigc++
Reference: https://libsigcplusplus.github.io/libsigcplusplus/
* Make code compatible with libsigc++-2.0 instead of 3.0
Since Version 3.0 C++14 is required which is not (fully) supported in
some older GCC versions.
2019-10-26 17:37:14 +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
Daniel Marjamäki
fbd59b2fc5
Verify: Add test script itc.py. clarify juliet.py test script
2019-10-24 21:48:34 +02:00
Daniel Marjamäki
dedee2b173
SymbolDatabase: Better ValueType handling for containers
2019-10-23 19:54:59 +02:00
Daniel Marjamäki
e879de6489
Verify: Update Juliet Testing
2019-10-23 16:49:45 +02:00
Daniel Marjamäki
87f65230ae
SymbolDatabase: Better valuetype handling of container addition
2019-10-23 12:42:46 +02:00
Daniel Marjamäki
f131a99ae3
SymbolDatabase: Improved ValueType in range for loop
2019-10-23 11:52:29 +02:00
Daniel Marjamäki
c5c07b61a6
SymbolDatabase: Fix type for expression 'x = uint8_t(a[b])'
2019-10-22 20:40:36 +02:00
Daniel Marjamäki
cf1dd2e6f6
AST: Fix AST when returning list of lambda functions
2019-10-22 18:39:59 +02:00
orbitcowboy
24d6794ba6
windows.cfg: Added support for more interfaces.
2019-10-21 10:09:20 +02:00
versat
6cf0aed737
test/cfg/runtests.sh: Remove verbose output (meant for debugging)
2019-10-21 08:53:21 +02:00
Rikard Falkeborn
73a569be97
TestBufferOverRun: Handle string literals ( #2287 )
2019-10-21 07:11:22 +02:00
Rikard Falkeborn
f83eb127ae
ValueFlow: sizeof string and char literals ( #2285 )
2019-10-20 21:02:28 +02:00
Daniel Marjamäki
78c02f0505
ValueFlow: Fixed false positives after escape scope
2019-10-20 20:57:16 +02:00
Daniel Marjamäki
223ceeb97f
SymbolDatabase: Do not set constructor flag for function in namespace
2019-10-20 18:12:52 +02:00
Daniel Marjamäki
82d8f3e7f5
SymbolDatabase: Fix crash if std::shared_ptr type is only forwarded, not defined
2019-10-20 17:00:15 +02:00
Daniel Marjamäki
e50b9e2bef
Fixed #8784 (False positive uninitialized variable)
2019-10-20 15:20:05 +02:00
Daniel Marjamäki
68ea60d207
Try to make Travis happy
2019-10-20 07:44:56 +02:00
Rikard Falkeborn
5c061c1c12
Set correct type and size of string and char literals ( #2275 )
...
* Set correct type and size of string and char literals
Use that string and char literal tokens store the prefix. This makes
it possible to distinghuish between different type of string literals
(i.e., utf8 encoded strings, utf16, wide strings, etc) which have
different type.
When the tokens holding the string and character values have the correct
type, it is possible to improve Token::getStrSize() to give the correct
result for all string types. Previously, it would return the number of
characters in the string, i.e., it would give the wrong size unless
the type of the string was char*.
Since strings now can have different size (in number of bytes) and
length (in number of elements), add a new helper function that returns
the number of characters. Checkers have been updated to use the correct
functions.
Having the size makes it possible to find more problems with prefixed
strings, and to reduce false positives, for example in the buffer
overflow checker.
Also, improve the stringLiteralWrite error message to also print the
prefix of the string (if there is one).
* Add comment and update string length
2019-10-20 07:11:57 +02:00
Daniel Marjamäki
00fae7fb42
Fixed #9261 (Inconsistent violation report between using global enum and namespaced enum.)
2019-10-20 07:07:38 +02:00
Daniel Marjamäki
4943771e41
Fix #9262 (False positive on variable assignment when putting enum in namespace)
2019-10-19 21:41:50 +02:00
Daniel Marjamäki
9a2b71494f
ValueFlow: Set value for ::
2019-10-19 21:08:59 +02:00
IOBYTE
5658dfcaf3
better fix for #9392 that also handles namespaces ( #2282 )
2019-10-18 18:05:48 +02:00
Daniel Marjamäki
e0093c99ce
Fixed #9276 (False positive: ValueFlow does not handle return in switch properly.)
2019-10-18 16:16:56 +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