Commit Graph

1059 Commits

Author SHA1 Message Date
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 606bb78297 ValueFlow: Better handling of casts 2016-12-20 19:32:21 +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
Daniel Marjamäki 8cba02dc66 Readd test case I removed in b098d5fbd6 2016-12-11 21:24:12 +01:00
Daniel Marjamäki b098d5fbd6 ValueFlow: We need better handling of casts 2016-12-10 22:09:01 +01:00
PKEuS 2f6350a0d0 Refactorized Library 2016-12-06 14:09:28 +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
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
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
orbitcowboy 919f8ac323 Fixed typos. There are no real changes. 2016-11-04 15:01:05 +01:00
Boris Egorov 0154d39bf6 Show struct member in unsignedLessThanZeroError warning
Before:
    [/tmp/test.c:8]: (style) Checking if unsigned variable '.' is less than zero.
    [/tmp/test.c:12]: (style) Checking if unsigned variable '.' is less than zero.

After:
    [/tmp/test.c:8]: (style) Checking if unsigned variable 'd.n' is less than zero.
    [/tmp/test.c:12]: (style) Checking if unsigned variable 'd.n' is less than zero.
2016-09-22 08:03:30 +07:00
Matthias Krüger 2f39ed6f88 redundantPointerOpError: put pointer name into single quotes in the error message. 2016-09-16 22:18:24 +02:00
Daniel Marjamäki 939b42df06 Fixed #7134 (False positive redundantAssignment - assignment to local variable of unknown type) 2016-08-29 03:48:08 +02:00
Daniel Marjamäki bd21cd7c85 Fixed #6309 (FP: checkRedundantAssignment should not warn for pointer alias) 2016-08-08 21:43:00 +02:00
Daniel Marjamäki e784901303 Fixed #6971 (False positive duplicateExpressionTernary - cast ignored) 2016-08-01 21:53:43 +02:00
PKEuS 92e3e802fb Attempt to fix travis build and testrunner failure 2016-07-28 20:59:09 +02:00
PKEuS 452ecc7ceb Improved check: Detect passedByValue even for arguments that are not declared as "const" 2016-07-28 19:37:10 +02:00
Daniel Marjamäki 0767284ca1 Fixed #7630 (FP: dead store, modifying array, index var modified) 2016-07-25 07:35:33 +02:00
Daniel Marjamäki ed4a47de45 Tokenizer: Improve syntax checking of switch,if,while 2016-07-22 16:54:24 +02:00
Daniel Marjamäki 03d2829fb9 Merge simplecpp branch 2016-07-20 12:21:00 +02:00
Daniel Marjamäki 0ddeac0429 refactor (use ast) and improve CheckOther::checkRedundantAssignment (warn about global variables unless they are volatile, handle arrays in lhs better) 2016-07-18 12:43:23 +02:00
Daniel Marjamäki d1f06ff47c Fixed #7175 (False positive performance warning (buffer overwritten before its old content has been used)) 2016-06-13 15:46:43 +02:00
Daniel Marjamäki 710e066a9a Fixed #6406 (VarId: struct member initialization) 2016-05-22 21:18:52 +02:00
PKEuS 0bf85f9aa5 ValueType: Support integers defined in libraries (#7394) 2016-05-04 15:39:56 +02:00
Robert Reif 100c4276ea Fixed #7424 (value type: wrong sign) 2016-03-18 10:30:57 +01:00
amai2012 9700dfead0 Testcase succeeds on Win32-VC-32bit, only 64bit needs to be fixed. 2016-03-01 22:32:27 +01:00
PKEuS b4b38fb7ce Use ValueType in CheckOther::invalidPointerCast()
False negative: operator new is currently not supported by ValueType.
2016-02-05 20:28:43 +01:00
PKEuS cc8c498ebb Moved a few tests to testgarbage.cpp 2016-02-04 09:10:20 +01:00
PKEuS 841f17776b Set ValueType for assignment operators, detect division by zero for %= and /= again (#7322) 2016-02-02 17:17:55 +01:00
PKEuS 9d2258677d Improved CheckOther::checkUnusedLabel(): Write a warning instead of a style message if it happens inside a switch() 2016-01-31 12:07:24 +01:00
Daniel Marjamäki 79aec559d5 Fixed #7243 (False positive unknownEvaluationOrder - comma operator inside while-clause) 2016-01-18 16:10:51 +01:00
Matthias Krüger 7b1710a44f redundantAssignment: change from severity 'performance' to 'style' since avoiding unneccessary stores is a basic optimization done by compilers. 2016-01-15 22:01:40 +01:00
Alexander Mai 7802517a69 #7285 wrong var name: memset() called to fill 0 bytes of '&' memset with pointer: remove var name from message. Correct some entries in posix.cfg. 2016-01-12 23:20:48 +01:00
Daniel Marjamäki b3208fb4b3 Fixed #7211 (False positive: Finding the same expression on both sides of an operator (enumconstant == 0)) 2016-01-10 11:21:43 +01:00
Daniel Marjamäki 79e663dd6f Settings: Remove '_' prefix for public member variables 2016-01-03 16:18:17 +01:00
Lauri Nurmi 996c9244d8 Update copyright year to 2007-2016. 2016-01-01 15:34:45 +02:00
Daniel Marjamäki bd1037e95b Fixed #7242 (False positive unknownEvaluationOrder - comma expression in function argument) 2015-12-29 12:06:42 +01:00
Daniel Marjamäki 25a5ac1846 Split up TestOther::testEvaluationOrder() 2015-12-28 14:04:14 +01:00
Daniel Marjamäki 15ecb26a6c Tokenizer: Moved simplifyAssignmentInFunctionCall from simplifyTokenList1 to simplifyTokenList2 2015-12-28 13:58:41 +01:00
Daniel Marjamäki 0ddb5c12ce Fixed #7238 (False positive unknownEvaluationOrder for comma operator on C code) 2015-12-28 13:45:55 +01:00
Daniel Marjamäki 908bc664a4 Evaluation order: ignore usage in sizeof 2015-12-27 14:08:16 +01:00
Daniel Marjamäki c672210e06 Evaluation order: don't warn for 'dostuff(expr++, &expr)' 2015-12-26 15:48:43 +01:00
Daniel Marjamäki ab6809f3fa Fixed testrunner 2015-12-25 19:01:32 +01:00
Daniel Marjamäki 24438c326e Fixed #7233 (Fasle negative 'unknownEvaluationOrder in case of macro) 2015-12-25 18:31:21 +01:00
Daniel Marjamäki 27af1bcfd8 Fixed #7229 (Improve check; unknown evaluation order, write different message for self assignment) 2015-12-25 18:00:19 +01:00
Daniel Marjamäki 07b929e13f Added TODO test case for unknown evaluation order 2015-12-25 17:48:15 +01:00
Daniel Marjamäki 90a54b1fae Fixed #7232 (False positive unknownEvaluationOrder on id = Remap( id += 42 );) 2015-12-25 16:45:11 +01:00
Daniel Marjamäki 81f0597316 Fixed #3206 and #7226 (New check: Undefined execution order) 2015-12-24 09:13:20 +01:00
Daniel Marjamäki 0baad496f2 Fixed #6383 (FP shiftNegative - value converted to unsigned in function argument) 2015-12-14 10:55:23 +01:00
Alexander Mai 9d8dffbd79 #6269 false positives in case of overloaded standard library functions. Detect memset() with proper argument cound, using new function numberOfArguments() 2015-12-06 12:50:05 +01:00
Alexander Mai 98f2cd021e #7199 SymbolDatabase::validate() should be run in debug mode and print debug messages. In turn correct some test examples with invalid code. 2015-12-06 08:14:04 +01:00
Dmitry-Me 8f8a0097fe Detect more non-interlocked accesses 2015-12-02 10:58:57 +03:00
Daniel Marjamäki fb8cce647c invalidTestForOverflow: Refactor; move from checkother to checkcondition 2015-11-30 08:51:15 +01:00
Daniel Marjamäki 26a07265a8 Fixed #7184 (Invalid test for overflow 'p + x < p') 2015-11-29 20:59:50 +01:00
Daniel Marjamäki 4fa888ec44 Warn when shifting a negative value, it is UB. (#4931) 2015-11-29 16:28:55 +01:00
PKEuS f516de8633 Moved a few checks from CheckOther to CheckFunctions 2015-11-22 13:49:10 +01:00
Daniel Marjamäki 0f9d90d2be Changed Copyrights. Removed my name. 2015-11-18 20:04:50 +01:00
Alexander Mai 435a980ce2 Convert wrong test result for #7133 to TODO_ASSERT_EQUALS and add more test cases 2015-11-15 20:14:20 +01:00
Alexander Mai 65666a1ba4 Makefile: explicit list directories which should be used with ctags. Run astyle. 2015-11-15 19:03:18 +01:00
amai2012 f0bf749621 #7133 crash: Variable::declarationId(). 2015-11-15 19:01:29 +01:00
PKEuS 1589841cb6 Fixed crash in clang test suite with member variable pointers 2015-11-11 18:26:59 +01:00
PKEuS 36c5815ddb Fixed false positive about redundant variable assignment in try-scopes if the variable is read in catch block (#6555) 2015-11-11 17:21:55 +01:00
Alexander Mai 7d8b62e615 Add regression test for #6669 Return value of malloc is reported not stored, while it is. 2015-10-26 18:24:49 +01:00
PKEuS ee58587706 Fixed false positive unreachableCode when ternary operator is used (#6664) 2015-10-26 08:29:43 +01:00
PKEuS 0a34b206e8 Refactorization: Reduced code duplication in test suite 2015-10-08 11:35:51 +02:00
PKEuS 07b661ef62 Refactorization: Improved handling of preprocessor in test suite
- Set Preprocessor::macroChar to '$' once in the beginning to avoid problems when changing the order of tests
- Removed Preprocessor usage from where it is not required
- Fixed a TODO in testuninitvar.cpp
2015-10-07 14:18:57 +02:00
Daniel Marjamäki a574fda8a9 Fixed #6935 (Wrong duplicate expression) 2015-10-03 14:56:24 +02:00
PKEuS c5a8ecb6f9 New check: Detect unused 'goto' labels (#5124) 2015-08-30 16:45:47 +02:00
Simon Martin 6fb19b02d0 Properly differentiate arrays of pointers and pointers to arrays. 2015-08-25 21:19:19 +02:00
PKEuS 128a926d9d Collected some more garbage code tests in testgarbage.cpp; Avoid std::string creation in testgarbage.cpp 2015-08-16 19:12:12 +02:00
PKEuS b77912a0b5 Support namespaces in CheckOther::checkIgnoredReturnValue() 2015-08-15 12:19:14 +02:00
Matthias Krüger 391194579c CheckOther::checkComparisonFunctionIsAlwaysTrueOrFalseError: "evaluates always" -> "always evaluates" 2015-08-11 13:27:55 +02:00
Daniel Marjamäki c9e239afbf Fixed #6908 (False positive: Same expression on both sides of '+='.) 2015-08-07 20:28:25 +02:00
Daniel Marjamäki ec3d76be5e astyle formatting 2015-08-07 20:27:32 +02:00
amai2012 53feb88614 Merge pull request #630 from Dmitry-Me/detectRaceInInterlockedAccess
Prototype for detecting non-interlocked check after InterlockedDecrement()
2015-08-06 15:43:10 +02:00
Dmitry-Me 43800a9419 Detect non-interlocked check after InterlockedDecrement() 2015-08-05 12:20:28 +03:00
Daniel Marjamäki 67e9ed9294 ZeroDiv: Avoid constant folding in testcases 2015-08-02 18:56:26 +02:00
Alexander Mai ea62ab337b Add more testcases for zerodiv 2015-08-02 14:05:09 +02:00
Alexander Mai 965a034afd Fix some more false positives on zerodiv: error should be issued if type of epxression is known to be integral 2015-08-01 18:42:17 +02:00
Alexander Mai f91ad9bbf6 5402 false positive: (error) Division by zero -- with boost::format 2015-08-01 17:28:54 +02:00
Daniel Marjamäki d4344bd859 cleanup testcases for div() 2015-07-30 14:05:53 +02:00
Daniel Marjamäki 6790d91fbb Improve error messages for conditional values. make valueFlowSwitchVariable values conditional that depend on the case. Partial fix for #6884. 2015-07-29 19:54:57 +02:00
PKEuS 738057229c Improved astIsFloat(): Handle function calls and sizeof, fixed ordering of checks
Handle sizeof in isSameExpression() (#6851)
2015-07-29 14:28:24 +02:00
Daniel Marjamäki 29fbbef001 TestOther: Added zeroDiv test to make sure there is not FN when there is cast 2015-07-26 22:23:37 +02:00
Daniel Marjamäki bf921251e9 TestOther: code cleanup 2015-07-26 22:21:26 +02:00
Daniel Marjamäki 389aec51ae Fixed #6598 (False positive zerodivcond - cast to double ignored) 2015-07-26 22:08:36 +02:00
Alexander Mai 473336f986 #6426 FP duplicateExpressionTernary - (expr) ? ~0u : ~0ul. Regression test added. That issue got fixed in 1.69 already 2015-07-26 06:28:23 +02:00
PKEuS 176b3925b3 Removed "verify" code in testrunner. Fixing its messages reduces the accuracy of the test suite. 2015-07-25 14:18:41 +02:00
Simon Shanks 9910c1fa0c Fixed #6617 (preprocessor performance improvement) 2015-07-24 13:30:41 +02:00
orbitcowboy 48fed95942 Fixed wrong test case in testother: mathfunctionCall_atan2(). 2015-07-16 10:55:58 +02:00
Martin Ettl 027bdd3370 Reverted cebc105856. 2015-07-13 21:31:24 +02:00
orbitcowboy 08d6c244ee Running astyle. 2015-07-13 16:50:48 +02:00
orbitcowboy cebc105856 Changed test case from recent commit into a TODO test case. Since it is a FP. 2015-07-13 16:50:23 +02:00
orbitcowboy d042151b62 Checkother:selfAssignment: Improved test coverage. 2015-07-13 16:39:21 +02:00
Alexander Mai 6e03e7dca2 Remove some code checking for invalid class hierarchy which got obsolete since 480a5672b0. Run astyle 2015-07-01 07:50:13 +02:00
amai2012 108b035af2 Adjust two checks which have different results on Windows/Visual Studio than on Linux: one succeeds already, another fails. Analysis/fix is under development. Temporary repair allows to detect further regressions. 2015-06-30 21:21:26 +02:00
Daniel Marjamäki 63f39ea48f Change unusedScopedObject severity from error to style. The checker does not determine that there is ub or wrong behaviour. 2015-06-20 11:22:15 +02:00
Simon Martin 519bd7007a Ticket #6588: Properly detect whether the condition in a ternary operator is constant on C input. 2015-05-31 22:40:13 +02:00
Simon Martin 764df4dd56 Ticket #6588: Added test cases since the initial issue is fixed by some past commit. 2015-05-30 22:57:54 +02:00
Alexander Mai e28e9be82f Add TODO testcase for #5738. Refactoring: add some const 2015-05-25 08:20:14 +02:00
PKEuS 22fbc18fb7 Fixed false positive for *a++ in for-loop condition
Moved unit test to testgarbage.cpp
2015-05-07 20:34:57 +02:00
Dmitry-Me 818346622c More tests for checking negative pointers 2015-03-19 16:46:00 +03:00
PKEuS bc5132e0ac Refactorization: Moved declaration of errout, ... to testsuite.h, uniformized style 2015-03-11 22:54:43 +01:00
Daniel Marjamäki 6646a896f9 Fixed #6446 (FP zerodivcond on double arithmetics) 2015-03-03 15:50:31 +01:00
Robert Reif 130ffc5752 Fixed #6538 (Symboldatabase: improve isFunction) 2015-02-24 06:11:31 +01:00
Daniel Marjamäki fb5cc6fded Fixed #5905 (isSameExpression: comparisons 'a<b' and 'a>b' are same) 2015-02-23 16:38:55 +01:00
Daniel Marjamäki 830d1eb3fd Revert "Fixed #6538 (Symboldatabase: improve isFunction)"
This reverts commit d7ef89bbe6.

There was crashes in a Travis job.
2015-02-23 08:07:19 +01:00
Robert Reif d7ef89bbe6 Fixed #6538 (Symboldatabase: improve isFunction) 2015-02-23 06:49:50 +01:00
PKEuS 5f31242ee8 CheckOther::checkRedundantAssignment(): Bail out on inline assembly (#6525) 2015-02-22 12:03:53 +01:00
Daniel Marjamäki e9663873e5 TestOther: refactoring library testing 2015-02-17 15:52:45 +01:00
Alexander Mai 0a6babea74 #6181 Drop redundantGetAndSetUserId. Ensure (style-) warnings are issued if setuid()/getuid() and some related functions are ignored. Move strdupa()/strndupa() from posix.cfg to gnu.cfg 2015-02-16 22:19:51 +01:00
Daniel Marjamäki d83f07dddd TestOther: moved posix.cfg testing 2015-02-16 16:25:27 +01:00
PKEuS 21cb0cfd60 Take simplifyIfNotNull and simplifyIfNot out of simplifyTokenList1 (first step for #6072) 2015-01-31 20:12:02 +01:00
PKEuS 0488f45a5f Removed standalone check CheckOther::checkDoubleFree(), integrated (most of) the functionality into CheckLeakAutoVar. Added support for new/delete to checkLeakAutoVar. 2015-01-28 17:38:43 +01:00
Daniel Marjamäki 3285f85ebf Fixed #6460 (Library: better function/type matching) 2015-01-27 17:55:18 +01:00
Thomas Jarosch 58cb6cc116 Add new "style" check to catch redundant pointer operations
Doing "&*some_ptr_var" is redundant and might be the remainder
of a refactoring. Warnings for expanded macros are excluded though:
They are often used with and without pointers and
do something like this: "func(&(*macroarg))".

The new check is fully AST based and was given
strong false positive testing on a large code base.
2015-01-18 00:34:07 +01:00
Thomas Jarosch cf64fd3dad Add more complex variation of the #6406 unit test
This is a false negative right now.
2015-01-15 14:45:10 +01:00
Thomas Jarosch 0286abfb45 Add unit test for #6406 2015-01-14 23:05:33 +01:00
Daniel Marjamäki a80101f277 CheckMemoryLeak: Fix FP for allocation functions that register memory before returning it 2015-01-05 13:23:38 +01:00
Daniel Marjamäki fb685f096a CheckOther:checkNegativeBitwiseShift: Fix FP when shift is protected by ?: 2015-01-05 10:01:04 +01:00
Daniel Marjamäki 7bafbfbd6e Tokenizer: cleanup simplification of '!= 0' to avoid FP in 'x[(y & 0x80) != 0]' (linux) 2015-01-04 13:50:54 +01:00
PKEuS 267552779d Improved check (#6391): Detect identical code in both branches of ternary operator 2015-01-03 18:01:49 +01:00
Daniel Marjamäki ff11ba9847 Updated copyright year to 2015 2015-01-03 12:14:58 +01:00
PKEuS 9e8a66ee40 Fixed #6373: Support bitops in clarifyCalculation check 2014-12-30 17:55:29 +01:00
Robert Reif 9e60f584d9 Fixed #6321: Implemented function Token::swapWithNext(). 2014-12-27 10:53:26 +01:00
Thomas Jarosch d5e10c18d3 checkUnreachableCode(): fix FP for statements that just hide compiler warnings about unused function arguments
Seen throughout the rockbox codebase.
2014-12-22 11:18:23 +01:00
orbitcowboy 4cbbca3db0 Refactoring: Avoid to load posix.cfg multiple times while testing (testother.cpp) (#6336) 2014-12-17 16:33:55 +01:00
Thomas Jarosch 6b78ae7c46 Add mmap() / mmap64() / munmap() to posix.cfg. Enables basic leak tracking
Includes function prototype in posix.cfg as comment
for easier overview of the function arguments.
2014-12-14 13:30:24 +01:00
Thomas Jarosch 269a4419f0 Fixed false positives about strdupa() / strndupa() memleak
strdupa() / strndupa() allocates memory on the stack using alloca().
This memory is freed automatically once the current function is left.
2014-12-10 22:23:52 +01:00
Daniel Marjamäki 051d42ae6b astyle formatting 2014-11-20 14:20:09 +01:00
orbitcowboy f5d804f71a running astyle 2014-11-20 10:13:03 +01:00
Dmitry-Me cb9a6c1cb5 Don't show warning for same expressions alongside == in static_assert 2014-11-13 16:04:34 +01:00
Frank Zingsheim 7e0fc3d481 Fixed #6252 (False positive "freed twice")
--HG--
extra : rebase_source : 24f801452fbefa3a59ab2cca62c3cf02aea513b6
2014-11-03 21:24:34 +01:00
PKEuS 662283cab8 Refactorization: Avoid iterations over whole token list, limited several checks to function scopes. 2014-10-31 11:42:54 +01:00
PKEuS b5ea677180 Some fixes for CheckOther::checkIgnoredReturnValue():
- Fixed name of the function
- Fixed false positive for code like "class strcmp { strcmp() {} };"
- Fixed FP #6233 on checking side (no AST generated for function call)
2014-10-30 23:24:13 +01:00
PKEuS b7996bd0b0 Handle overloads and custom implementations of functions checkReturnIgnoredReturnValue() to avoid false positives 2014-10-30 21:26:32 +01:00
Frank Zingsheim 3923618b8d Fixed #6222 (Missing varid for multiple braced initialized variables)
-> Fixed broken code in unit tests
2014-10-16 20:46:57 +02:00
PKEuS 49a14d72e7 Fixed C&P-error in unit test that was added in previous commit 2014-09-29 19:57:27 +02:00
PKEuS 374ea8f039 Fixed false positive ignoredReturnValue on unknown member function log() (#6197) 2014-09-29 19:55:32 +02:00
PKEuS 1495a411eb Fixed false positive ignoredReturnValue for variables initialized with constructor syntax (#6194) 2014-09-29 10:15:29 +02:00
PKEuS 210294443e New check: Check for unused return values (#653) 2014-09-27 21:31:04 +02:00
PKEuS cafddcb109 Fixed wrong function log10 being recommended instead of log1p 2014-09-14 13:36:12 +02:00
Dmitry-Me 1e298a31cf Refactoring tests. Use utility function to warn about unsimplified code in tests. 2014-09-13 12:59:32 +02:00
Simon Martin bf3a8686ec Ticket #6164: Added test case that now works (failed in 1.66). 2014-09-12 21:56:13 +02:00
PKEuS 6f92557478 Use information about pure/leak-ignore from library to improve accuracy of several bailouts 2014-09-11 20:27:07 +02:00
PKEuS fb0d145b34 Don't show inconclusive message redundantCopyLocalConst if --inconclusive is not set.
Ran AStyle
2014-09-11 19:45:52 +02:00
Daniel Marjamäki 7847263451 Fixed #6158 (New check: dangerous sign conversion) 2014-09-11 18:10:19 +02:00
PKEuS 865fc9aa67 Fixed #6154: Don't suggest to reduce scope if inner scope is a lambda. 2014-09-10 20:56:34 +02:00