Commit Graph

7683 Commits

Author SHA1 Message Date
Daniel Marjamäki c18fe8262b Fixed #7934 (Wrong AST for 'for (i=0;cond;({min(x,10);}))') 2017-03-19 07:26:11 +01:00
PKEuS 8a3fb4dd6c SymbolDatabase: Fixed return type token detection for template member functions (#7945) 2017-03-16 20:47:24 +01:00
PKEuS ca3e3b3cdb Fixed false positive multiCondition when & is used in both conditions (#7827) 2017-03-15 19:37:14 +01:00
PKEuS 816106560a More conservative check for non-commutative operator+ in isSameExpression() (#7938) 2017-03-15 19:17:40 +01:00
PKEuS bcba27fbb9 SymbolDatabase: Removed unnecessary bailout in function matching for pointers in function overload matching 2017-03-15 18:45:33 +01:00
PKEuS b27ba72fdd SymbolDatabase: Support function overload matching for member variables (#7932) 2017-03-15 18:37:22 +01:00
PKEuS 92414b923a Library: Support variadic functions which are not a formatstr-function 2017-03-14 17:41:34 +01:00
Daniel Marjamäki 263c3596d5 known conditions: dont warn about 0 or 1 conditions as those look intentional 2017-03-08 18:39:19 +01:00
PKEuS 0073a633b0 Refactorized test suite 2017-03-08 15:16:19 +01:00
PKEuS a447d2c6a8 Refactorized testio.cpp 2017-03-08 14:24:14 +01:00
Daniel Marjamäki 8c707876ed Tokenizer: Don't simplify '({..})' wrongly 2017-03-08 11:41:18 +01:00
PKEuS 00904ba32a Fixed false negatives in CheckOther::checkPassByReference() when assignment operator is used. 2017-03-07 21:49:28 +01: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 5ea9519586 UseRetVal: Fix FN for methods 2017-03-05 22:23:16 +01:00
Simon Martin 43e4364675 Ticket #7912: Properly preprocess files with decreasing line numbers, due to #line directives. 2017-03-05 16:46:43 +01:00
Daniel Marjamäki f3c0461001 ValueType: handling scoped types in 'new ...' 2017-03-05 10:24:51 +01:00
Daniel Marjamäki e0dd0a82ed ValueType: refactor and improve handling of 'new ...' 2017-03-05 10:02:47 +01:00
Robert Reif e02b2c4483 ValueType: handle new nothrow 2017-03-05 02:13:00 +01:00
Daniel Marjamäki 920398615d ValueType: handle scoped types in parsedecl 2017-03-05 01:21:02 +01:00
Daniel Marjamäki 12fe4a8b3e Fixed #7885 (ValueType: Wrong type for large hexvalue (platform=win32A)) 2017-03-04 14:19:14 +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
Daniel Marjamäki f0c353abcb TokenList: append 'U' if needed on hexvalues 2017-03-04 08:47:53 +01:00
Daniel Marjamäki 1c6c209353 Fixed #7890 (1.77 false positive from knownConditionTrueFalse with function-like macros) 2017-03-03 19:53:16 +01:00
Daniel Marjamäki 59c1c76a97 Fixed #7466 (Reference variable does not count side-effects (FP variableScope)) 2017-03-03 19:07:00 +01:00
Daniel Marjamäki b5f2fd3c55 Fixed #7738 (False positive deallocret - delete and return NULL pointer) 2017-03-03 18:36:06 +01:00
Daniel Marjamäki d1c66edb03 ValueFlow: Known values in conditional code 2017-03-03 01:29:34 +01:00
Daniel Marjamäki 45c5860ca4 Fixed #7926 (Memory Leak with auto not detected) 2017-03-02 22:24:26 +01:00
Daniel Marjamäki 9dc219f1ba CheckIO: Use ValueType more 2017-03-01 22:33:31 +01:00
Daniel Marjamäki 51b5f1c286 Fixed #7931 (crash: SymbolDatabase: Variable::setFlag) 2017-03-01 17:13:22 +01:00
Daniel Marjamäki 279425499e Fixed #7930 (Improve check: Missing stlcstr warning for reference variable) 2017-03-01 02:03:08 +01:00
PKEuS 85768f1829 SymbolDatabase: Overload matching with boolean literals as argument and with arbitrary null-pointers 2017-02-28 22:43:47 +01:00
PKEuS 942644fde6 SymbolDatabase: Overload matching with character literals as argument 2017-02-28 22:08:41 +01:00
Daniel Marjamäki 841e0c2921 Fixed #7546 (Assignment to array element not detected if pointer addition is used) 2017-02-28 22:04:05 +01:00
Daniel Marjamäki 16c06e5714 Fixed #7588 (Opposite conditions in nested 'if' blocks lead to a dead code block.) 2017-02-28 18:46:28 +01:00
Daniel Marjamäki beaf29c158 SymbolDatabase: Update some properties for auto variables 2017-02-27 23:04:25 +01:00
Daniel Marjamäki 994f6b684d ValueType: initial handling of new 2017-02-27 20:57:28 +01:00
Daniel Marjamäki 7ecd5db8fb ValueType: Handle auto in range for loop 2017-02-27 02:09:33 +01:00
Daniel Marjamäki 2da360eec5 ValueType: Handle 'auto *p = ..' 2017-02-26 22:43:10 +01:00
Matthias Krüger 1e5e32c4a2 testrunner: remove non-gcc-style output format 2017-02-26 21:39:06 +01:00
Daniel Marjamäki dad455c0dd ValueType: Handle 'auto'. First fix for #4345 2017-02-26 20:02:57 +01:00
Daniel Marjamäki d840005f06 Fixed #7656 (stlcstr - false positive) 2017-02-26 17:25:32 +01:00
Daniel Marjamäki f68fa72095 Fixed #7583 (Defect: False positive '(error) Reference to temporary returned') 2017-02-26 13:41:49 +01:00
PKEuS c1d8fd7f13 SymbolDatabase: Better handling of pointers in findFunction(), supporting const pointers and std::string overloads 2017-02-26 11:36:04 +01:00
PKEuS 4a27376694 SymbolDatabase: Implement two-stage fallback mechanism for matching function overloads, increasing matching accuracy 2017-02-25 23:12:00 +01:00
Daniel Marjamäki adc659f58b Fixed #7897 (MathLib::toDoubleValue: Does not handle character literal) 2017-02-25 21:58:09 +01:00
Daniel Marjamäki 26fc7abfac Fixed #7837 (Field dereference triggers format string type warning) 2017-02-25 18:22:14 +01:00
Daniel Marjamäki 55d7ab65b9 Fixed #7918 (::exit() not recognized as noreturn) 2017-02-25 12:12:39 +01:00
Daniel Marjamäki 99544069d1 CheckLeakAutoVar: better handling of noreturn functions. Partial fix for #7918. 2017-02-25 11:36:48 +01:00
PKEuS 3f1e2b4270 More conservative fallback for function overload matching 2017-02-24 20:56:47 +01:00
PKEuS 4e28d40bf0 Fixed matching long long overload to function call f(0) 2017-02-24 20:33:52 +01:00
PKEuS de86d40c97 Fixed handling of NULL and nullptr in CheckNullPointer 2017-02-24 19:44:28 +01:00
PKEuS b08f99a082 Fixed false negative: nullpointer passed as std::string argument (#7927)
Refactorization: Removed dead code from CheckNullPointer::parseFunctionCall()
2017-02-24 19:10:34 +01:00
Daniel Marjamäki a53f14da25 Fixed #7925 (False Positive identical condition) 2017-02-22 21:13:36 +01:00
Robert Reif 8e0f1ec788 Fixed #7909 (Crash in CheckMemoryLeakInClass) 2017-02-20 23:09:35 +01:00
Simon Martin 487f76cdd1 Ticket #7916: Don't incorrectly simplify return statements involving template instantiations. 2017-02-18 21:14:50 +01:00
Daniel Marjamäki 774a8979a3 Fixed #7095 (False positive: (warning) Return value of function to_string() is not used.) 2017-02-12 16:50:45 +01:00
Daniel Marjamäki 7c800d6ed7 Fixed #7447 (FP: ignoredReturnValue on C++11 uniform initialization) 2017-02-12 16:33:28 +01:00
Simon Martin 0c0fe4605a Ticket #7465: Added test case highlighting the issue has been fixed since it's been reported. 2017-02-11 17:55:51 +01:00
Simon Martin 326d152aa2 Ticket #7914: Properly recognize template parameters that contains operators. (#870) 2017-02-11 10:13:41 +01:00
Simon Martin 0943b2145b Ticket #7891: Do not remove spaces in the internal representation for template instantiations. 2017-02-05 17:35:29 +01:00
orbitcowboy beb72c2583 Revert changes from 9cb0941df2. 2017-02-02 15:53:52 +01:00
orbitcowboy 9cb0941df2 std.cfg: Take the return value from fread() into account. 2017-02-02 13:33:06 +01:00
Matthias Krüger f80e888b7e run astyle
[ci-skip]
2017-01-31 16:22:31 +01:00
Simon Martin 5262ed018e Ticket #7440: Function calls should not abort pointer alias analysis for local variables. 2017-01-27 22:56:28 +01:00
umanamente a012e5b5fb (Fixed #7846) Syntax error when using C++11 braced-initializer in function last argument
Add an optional extended description…
2017-01-23 12:50:36 +01:00
umanamente 0c1ba8e8b4 (Fixed #7895) C++11 brace initialization. Added test. (#862)
Add an optional extended description…
2017-01-22 10:16:40 +01:00
PKEuS 3022d74801 Do not suggest pass by reference for std::initializer_list 2017-01-19 11:14:55 +01:00
amai2012 722fac391d Merge pull request #858 from simartin/ticket_7820
Ticket #7820: Properly report leaks with conditional deallocations followed by a return.
2017-01-18 09:31:49 +01:00
Simon Martin 9e76b21d7f Ticket #7820: Properly report leaks with conditional deallocations followed by a return. 2017-01-17 23:02:39 +01:00
Simon Martin ae939b1385 Teach CheckMemoryLeak about "alloc ; loop alloc ;" kinds of patterns. (#861)
Add an optional extended description…
2017-01-15 22:16:23 +01:00
Simon Martin c82d8a0d06 Ticket #7745: Simplify "alloc ; dealloc ;" blocks that we don't have any value for CheckMemoryLeak's analysis. (#860)
Add an optional extended description…
2017-01-15 22:14:37 +01:00
Daniel Marjamäki 47d39d0a14 Revert "Fixed #7888 (1.77 false positive from knownConditionTrueFalse with sizeof(int) == sizeof(long))"
This reverts commit a762511067.
2017-01-10 13:22:48 +01:00
Daniel Marjamäki a762511067 Fixed #7888 (1.77 false positive from knownConditionTrueFalse with sizeof(int) == sizeof(long)) 2017-01-09 22:28:55 +01:00
Daniel Marjamäki b1f7e46491 Fixed #7323 (valueflow: global variables) 2017-01-09 15:53:08 +01:00
Simon Martin 417c7e36c0 Ticket #7548: Properly detect the end of template parameter default values during instantiation. 2017-01-08 09:38:29 +01:00
Matthias Krüger d4dcef4a30 add testcase for #6011 (crash in libreoffice, failure to create AST for comparison) which I still had in some branch. 2017-01-08 02:36:21 +01:00
Matthias Krüger 064a4aa4cc improve constness of functions as per cppchecks suggestions. 2017-01-07 14:31:03 +01:00
Simon Martin bd92ddd386 Ticket #7850: Properly handle C functions called "class". 2017-01-06 21:16:28 +01:00
Robert Reif 4123b457d7 Fixed #7441 (SymbolDatabase: No scope when function return type not specified) 2017-01-06 11:53:17 +01:00
Robert Reif 139071d88b Fixed #7875 (New check: function declaration and definition argument names don't match) 2017-01-05 08:52:11 +01:00
Robert Reif 4c25e798b1 Fixed #7865 (Tokenizer::createLinks2(): does does set links for <> in struct template) 2016-12-31 22:05:29 +01:00
Simon Martin f43431408b Ticket #7685: Properly handle function calls as argument to a dealloc function. (#853)
Add an optional extended description…
2016-12-29 13:17:46 +01:00
Daniel Marjamäki 85ae3adeb2 Fixed #5144 (FP old memleak - tree structure) 2016-12-27 08:12:37 +01:00
Daniel Marjamäki 1b21767954 Fixed #5666 (False positive when modifiying std::string by pointer) 2016-12-26 17:13:35 +01:00
Daniel Marjamäki 770abcf453 Fixed #5398 (False positive: Scope of variable can be reduced does not account for other variables not reduceable) 2016-12-26 14:14:40 +01:00
Daniel Marjamäki c8a450c9be uninitvar: Fixed a FP seen in daca2 2016-12-25 22:43:29 +01:00
Matthias Krüger ecc91ba914 fix a couple of issues in shell scripts found by codacy. 2016-12-25 00:43:47 +01:00
PKEuS ea53bd22b7 Fixed false positive returnTempReference with operator++ (#7874) 2016-12-22 11:49:59 +01:00
Daniel Marjamäki df6ae9f3b4 Fixed #7847 (Can't detect shift negative values when some op is executed) 2016-12-22 09:40:19 +01:00
Daniel Marjamäki d79688c40b Fixed #7822 (False positive for uninitialized variable if array type is used) 2016-12-21 23:11:11 +01:00
Daniel Marjamäki 28af5c0379 Integer Overflow: Don't warn about left-shift expressions with negative result like '1<<31'. That is common practice. 2016-12-21 18:19:59 +01:00
Daniel Marjamäki 426d1b4196 Merge pull request #846 from simartin/ticket_7805
Ticket #7805: Ignore enumerators when simplifying known variables.
2016-12-21 17:58:48 +01:00
Daniel Marjamäki f40bdddbab ValueFlow: Better handling when casting calculation result 2016-12-20 23:09:50 +01:00
Daniel Marjamäki f0d91fb74b Fixed #7869 (False positive: Array index out of bounds) 2016-12-20 22:01:19 +01:00
Daniel Marjamäki 44ccbdedec ValueFlow: Improved value for cast 2016-12-20 21:37:25 +01:00
Daniel Marjamäki 606bb78297 ValueFlow: Better handling of casts 2016-12-20 19:32:21 +01:00
Daniel Marjamäki e14e86c103 ValueFlow: only set values in conditional code in subfunctions when sure 2016-12-20 11:06:20 +01:00
Daniel Marjamäki 807b653739 ValueFlow: Fix FP in for loops when 2nd expression is 0 2016-12-20 07:54:38 +01:00
Daniel Marjamäki f1ad7368f6 ValueFlow: bool values 2016-12-19 21:21:18 +01:00
Daniel Marjamäki aaf19c1e4f Fixed #7839 (Prefix increment triggers parameter modification warning) 2016-12-19 15:25:36 +01:00
Daniel Marjamäki f5ad7482a8 CheckBufferOverrun: Skip warnings about array index out of bounds in unions. Theoretically, the array is at least as large as the biggest union member. 2016-12-18 22:10:30 +01:00
Daniel Marjamäki 4558701c08 varid: don't generate varid and symboldatabase variable for function call parameter 2016-12-18 20:16:38 +01:00
Daniel Marjamäki 17aaecbd6b ValueFlow: Improved handling of sizeof 2016-12-18 14:03:48 +01:00
Daniel Marjamäki 461e5cc5c9 CheckBufferOverrun: Moved check from simplified to normal. This fixes a FP in asterisk. 2016-12-18 11:14:05 +01:00
Daniel Marjamäki 72e4bc9d88 ValueFlow: skip values that cause false assertion condition 2016-12-17 21:23:14 +01:00
Frank Zingsheim cb5a5e6a25 Improve Fix #6180 (Access of moved variable still allowed until function is called) 2016-12-17 16:42:46 +01:00
Frank Zingsheim 9a871d33f7 Improve Fix #6180 ("reset" and "clear" clears the move status) 2016-12-17 16:39:30 +01:00
Frank Zingsheim f4ab45f13b Improve Fix #6180 (Do not warn about move if it is part of a reassignment of the variable) 2016-12-17 16:39:30 +01:00
Simon Martin 5119ae84b8 Ticket #7805: Ignore enumerators when simplifying known variables. 2016-12-17 14:05:26 +01:00
Daniel Marjamäki 8cba02dc66 Readd test case I removed in b098d5fbd6 2016-12-11 21:24:12 +01:00
Daniel Marjamäki 31337dda27 ValueFlow: Better handling of && and || in for loop to avoid FP 2016-12-11 21:19:24 +01:00
Daniel Marjamäki d4f2512421 Tokenizer::simplifyKnownVariables: Added bailout when pointer alias is simplified and loop is encountered 2016-12-11 19:12:23 +01:00
Frank Zingsheim e0d4720e19 Fix #7829 (false-positive: knownConditionTrueFalse linked to virtual method)
Return values of virtual functions in valueflow are only possible values
since function might be overloaded.
2016-12-11 10:44:05 +01:00
Daniel Marjamäki 87abe1174f floatConversionOverflow: Avoid warnings when 255.5 is converted to unsigned char etc. 2016-12-10 23:14:40 +01:00
Daniel Marjamäki b098d5fbd6 ValueFlow: We need better handling of casts 2016-12-10 22:09:01 +01:00
PKEuS 120fe2e4d6 Fixed false positive: The function 'operatorstd::string' is never used. (#7853) 2016-12-08 13:54:54 +01:00
PKEuS cfac3b457d Several small refactorizations 2016-12-06 22:12:02 +01:00
Daniel Marjamäki 7fc9fbc746 synthetic: reduce controlflow testcases 2016-12-06 21:45:51 +01:00
PKEuS 40401534d7 Refactorized Library 2016-12-06 14:50:27 +01:00
PKEuS 2f6350a0d0 Refactorized Library 2016-12-06 14:09:28 +01:00
PKEuS d665641a76 Refactorizations:
- use std::string::pop_back() and std::string::back()
- pass argument as const std::string&
- Moved iterator into for loop head
2016-12-05 14:50:01 +01:00
Daniel Marjamäki 5df8e7f50c Fixed #7596 (ValueFlow: better handling for 'x*(1-x-1)') 2016-12-04 22:39:59 +01:00
Daniel Marjamäki c12cb69cc2 ValueType: Handle function pointers 2016-12-04 16:02:50 +01:00
Daniel Marjamäki 9c69546d72 Fixed #7842 (Preprocessor::getConfigs: #error in #ifndef not handled well) 2016-12-03 11:59:48 +01:00
orbitcowboy 8a45c3192b There is not need to clear a string directly after its creation. 2016-11-30 10:39:14 +01:00
PKEuS 36d12d7866 SymbolDatabase: Function::retDef should not point at "static" or "extern" 2016-11-28 17:23:39 +01:00
Stefan Weil 57b57428c2 Fix some typos in comments (found by codespell)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-27 11:40:42 +01:00
Daniel Marjamäki b6cba4a55c Fixed #7784 (Token: can't be both type and variable) 2016-11-26 22:39:47 +01:00
orbitcowboy 55ae961ac2 std.cfg and windows.cfg: Improved support for <use-retval/> for functions like ftell(), [f]get[w]c(). 2016-11-26 21:31:15 +01:00
orbitcowboy 8a0f856e95 Fixed regression in test/cfg/std.c introduced by b0d09926fb. 2016-11-26 21:14:31 +01:00
Matthias Krüger 213589ee68 ValueFlow: don't perform UB when a function returns shifts of/by negative values. Fixes #7814. 2016-11-24 23:23:47 +01:00
Daniel Marjamäki a61f4e9c94 Fixed #7831 (false-positive: terminateStrncpy) 2016-11-24 07:04:58 +01:00
Matthias Krüger cf24ea5221 fix #7783: false positive knownConditionTrueFalse on assert(0 && "message"). 2016-11-23 21:54:38 +01:00
Daniel Marjamäki e1a3c0955a synthetic tests: Added run-clang.sh 2016-11-23 14:49:46 +01:00
Matthias Krüger 01e5f14bf8 CheckClass::virtualDestructorError and a variation of CheckNullPointer::nullPointerError would print inconclusive,warning messages altough no --enable=warning was given. Fix. 2016-11-23 00:13:09 +01:00
Daniel Marjamäki 0b3751520b Add a check for float conversion overflows 2016-11-22 22:37:13 +01:00
Daniel Marjamäki 8870195794 Synthetic: Add run-lint.bat script 2016-11-22 19:25:05 +01:00
PKEuS 02d8f691f8 Fixed false positive: Do not show useInitializationList message for enums 2016-11-22 12:09:30 +01:00
Daniel Marjamäki aff84daff3 synthetic tests: renamed functions 2016-11-22 11:37:15 +01:00
Daniel Marjamäki d40f4e4a55 Fixed #7778 (valueFlowAfterAssign: alias) 2016-11-21 17:26:36 +01:00
Daniel Marjamäki 21364b4401 Refactoring fix for #7816 2016-11-21 13:54:59 +01:00
amai2012 933815ee54 #7816 Segmentation fault at Tokenizer::simplifyAttribute() for stand-alone void. Throw syntax error on incomplete code 2016-11-21 12:19:47 +01:00
Daniel Marjamäki 74fa69fe5e Fixed #7821 (syntax error, first token is &) 2016-11-20 17:59:50 +01:00
Frank Zingsheim c8ff96fe8f Fixed #6180 (Usage of variable after std::move or std::forward) 2016-11-20 15:14:49 +01:00
PKEuS e23dc5c1e2 Fixed wrong message shown if unused label appears directly after a switch() scope 2016-11-20 14:43:54 +01:00
Matthias Krüger d3919b23fa testrunner: testgarbage: test-function was not called, fix. 2016-11-20 14:36:36 +01:00