Commit Graph

381 Commits

Author SHA1 Message Date
Simon Martin da302b3912 Ticket #6680: Members can be initialized by operator>>. 2015-05-10 14:27:15 +02:00
amai2012 8d8fffb20f #6651 Don't call member function on NULL pointer - even if call is "safe" 2015-04-17 08:47:59 +02:00
Matthias Krüger 42f0955e3f Move more setting checks out of loops and use const bools instead. Reorder a few related checks.
Follow up to eedcb6abcb .
2015-04-10 14:31:19 +02:00
Daniel Marjamäki d563bd73f4 Fixed #6583 (False positive uninitvar - exit() ignored?!) 2015-04-08 15:35:04 +02:00
Dmitry-Me 5f6aaa4573 Make the check slightly less convoluted 2015-03-20 11:03:11 +03:00
Daniel Marjamäki 42c4aa1c49 Fixed #4880 (false negative: uninitialized variable, handling of conditional noreturn scopes) 2015-03-14 17:59:11 +01:00
Dmitry-Me 89ec9058a8 Proper if-else-if chain for mutually exclusive conditions 2015-03-14 15:09:46 +03:00
Daniel Marjamäki b1e9d9b86f Coverity CID 1270450: Removed redundant conditions 2015-02-17 19:32:59 +01:00
Dmitry-Me 5517c22524 Omit redundant token match 2015-02-03 15:01:09 +03:00
PKEuS 789665dadf Fixed #6455: Show uninitvar even for const variables 2015-01-31 13:21:22 +01:00
PKEuS b2835051df Refactorization: Renamed Token::Match pattern %var% to %name%, implement new pattern %var% which is true if varId > 0. 2015-01-31 12:32:04 +01:00
PKEuS 0d151b45b5 Better support for funciton pointers in checkuninitvar.cpp (#6404) 2015-01-30 19:16:25 +01:00
PKEuS ee046af20c Fixed false positives #6450 and #6451 2015-01-23 19:38:39 +01:00
PKEuS da35a74589 Fixed false negative: Passing uninitialized variable to stream (#4673) 2015-01-22 22:56:41 +01:00
PKEuS da5a04f071 Fixed recently introduced FP in checkuninitvar.cpp if address of variable is passed to a function 2015-01-22 21:22:02 +01:00
PKEuS f4d11a4209 Fixed false negatives on try and non-executable scopes in checkUninitVar, removed unnecessary function parameters 2015-01-22 13:55:19 +01:00
PKEuS 331a6b66be Fixed internal message 2015-01-22 10:53:53 +01:00
PKEuS 7c60fe4aef Fixed crash introduced by last commit. 2015-01-22 10:51:06 +01:00
PKEuS 7364cc8040 Fixed false positive in fityk: operator new calling constructor 2015-01-22 10:37:31 +01:00
PKEuS 60b2b655df Support new/delete in new uninitialized variable checking; realloc() requires an initialized first argument. 2015-01-21 23:46:52 +01:00
PKEuS c3e47f7eaa Fixed false positive in CheckUninitVar and internal message 2015-01-21 22:26:44 +01:00
PKEuS 94c3c45350 CheckUninitVar: Use function information from library, bailout for '?' 2015-01-21 22:02:25 +01:00
PKEuS ecb9d87e42 Fixed false positive: Bailout in checkuninitvar.cpp if setjmp is found 2015-01-21 16:49:34 +01:00
PKEuS 5334aaa25f Refactorization:
- Removed a few unit tests of old uninitialized variable checking expecting other results than same test for new checking
- A few tweaks to new uninitvar checking to improve results when run on tests for old check
- switched some (TODO) tests to new check if the TODO is fixed
2015-01-21 16:17:58 +01:00
PKEuS d8e282fe76 Refactorization: Made checkUninitVar::isVariableUsage() non-static 2015-01-21 13:52:03 +01:00
PKEuS 346532d312 Fixed false positives in CheckUninitVar::checkStruct() 2015-01-21 13:11:48 +01:00
PKEuS 54de731cac Refactorized CheckUninitVar::checkScope(), fixed false negative 2015-01-21 12:20:03 +01:00
Robert Reif ba1c24ee65 Fixed #6422 (symbol database: put function flags into a single flag variable) 2015-01-08 05:45:31 +01:00
Daniel Marjamäki a87fb96eaf Uninitialized variables: fix fp when 'a=((b)=c)' is used 2015-01-06 18:03:40 +01:00
Daniel Marjamäki f2e5fbd30d Uninitialized variables: bailout when ({..}) are used to avoid fp. it can be handled better. 2015-01-06 07:44:04 +01:00
Daniel Marjamäki b3c2ea2c4f CheckUninitVar: Fix fp for 'int x=2+x();' when x() is an unseen preprocessor macro 2015-01-04 11:13:20 +01:00
Daniel Marjamäki 8dd569b9e1 Refactoring: Use AST in CheckUninitVar::isVariableUsage() to determine if & operator is address-of. This fixes FP in linux. 2015-01-04 09:23:24 +01:00
Daniel Marjamäki ff11ba9847 Updated copyright year to 2015 2015-01-03 12:14:58 +01:00
Daniel Marjamäki f24e1b82cf astyle formatting 2014-12-20 18:47:40 +01:00
Daniel Marjamäki b8371ebd87 Revert 2e45df3b. Because there are FP. 2014-12-18 06:37:15 +01:00
Matthias Krüger cc7f69da54 fix two internal warnings:
[lib/checkuninitvar.cpp:1668]: (style) Call to 'Token::tokAt()' followed by 'Token::str()' can be simplified.
[lib/checkuninitvar.cpp:1669]: (style) Call to 'Token::tokAt()' followed by 'Token::str()' can be simplified.
2014-12-17 19:06:13 +01:00
orbitcowboy 2e45df3b72 Fixed #6341: false negative uninitvar pattern "return foo ( %var%" 2014-12-17 17:43:31 +01:00
Daniel Marjamäki 0b9d80c95d Refactoring CheckUnusedFunctions so it uses new infrastructure for multifile analysis 2014-12-02 06:41:18 +01:00
Daniel Marjamäki a002654c47 Reverted refactoring 828417c for now. It caused a major slowdown in the unused functions checking. 2014-11-24 06:37:08 +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
Daniel Marjamäki 828417c934 CheckUnusedFunction: Refactorings to use same infrastructure for whole program analysis as CheckUninitVar and CheckBufferOverrun 2014-11-15 18:44:23 +01:00
Daniel Marjamäki de7e9223b8 Fixed #6272 (Improve check: multifile checking in checkbufferoverrun) 2014-11-15 10:43:49 +01:00
Daniel Marjamäki b766071272 Fixed #4970 (false positive: conditionally initialized variable used in if-clause (git/notes.c)) 2014-11-01 14:03:02 +01:00
Frank Zingsheim 41a54fceba Fixed false positives about uninitialized member variables if variable has a default value (#5500) 2014-10-16 21:57:43 +02:00
Daniel Marjamäki bbbe2c1b94 Fixed #6169 (False positive: passing uninitialized struct buffer member to strncpy) 2014-09-15 15:58:21 +02:00
Daniel Marjamäki 865a252c89 astyle formatting
[ci skip]
2014-09-14 10:29:12 +02:00
PKEuS 0b7281803e Merge pull request #428 from Dmitry-Me/detectArrowAccessesViaUninitPtrs
Detect -> accesses on uninitialized pointers
2014-09-12 09:19:59 +02:00
Dmitry-Me a2b30c7801 Detect -> accesses on uninitialized pointers 2014-09-12 10:19:00 +04:00
Dmitry-Me f58a25bebd Reorder checks, move declaration closer to where it's needed 2014-09-11 17:14:06 +04:00
Dmitry-Me 0a1b8c22d6 Simplify null pointer handling 2014-09-09 13:11:41 +04:00
PKEuS a8dc17c1d9 Fixed false positive #5566. 2014-08-26 11:29:26 +02:00
PKEuS 8188578cf2 SymbolDatabase: Fixed handling of nested types for function arguments
Removed unnecessary loops between var->typeStartToken() and var->typeEndToken()
2014-08-19 11:55:00 +02:00
PKEuS 8130fda4ae Implemented support for C++11 uniform initialization in several checks. 2014-08-05 16:11:42 +02:00
Daniel Marjamäki a2f776b1b7 Dead pointer: Added checking for dead pointer usage when pointer alias local variable that has gone out of scope. 2014-08-05 06:24:23 +02:00
Alexander Mai b6a40fceb7 Fix some compiler warnings 2014-06-26 20:34:07 +02:00
orbitcowboy d299cae5ef Fixed typo in comment, no functional changes [ci-skip] 2014-05-23 22:31:01 +02:00
PKEuS 5fbd58d98d Fixed messages of CheckInternal, fixed a false positive. 2014-05-18 20:39:52 +02:00
Daniel Marjamäki 8cc1f664d8 Uninitialized member variable: Fixed false negative when struct is read 2014-05-10 20:20:55 +02:00
Daniel Marjamäki 4c344adcf1 Uninitialized struct member: fixed false negative when struct assignment is seen 2014-05-10 19:56:44 +02:00
Daniel Marjamäki a202956471 Uninitvar: Refactoring. Use AST instead of token matching to see if variable is used in RHS of assignment. 2014-04-21 12:01:02 +02:00
Daniel Marjamäki 04cd261ee2 Fixed #5664 (false positive: (error) Uninitialized variable: j (Comma operator in for loop)) 2014-04-21 10:32:29 +02:00
Daniel Marjamäki c8ae1e4751 Fixed #5658 (false positive: (error) Uninitialized variable: s) 2014-04-10 15:59:37 +02:00
XhmikosR be0fcefe1d Tabs to spaces.
[ci skip]
2014-03-20 09:02:14 +02:00
Daniel Marjamäki 22a5881bee Uninitialized variables: Experimental checking for passing const pointer to partially initialized struct to function. Ticket: #5586 2014-03-20 07:19:35 +01:00
Daniel Marjamäki 8de4246713 Uninitialized variables: Improved handling of function calls when struct members are checked 2014-03-20 06:48:17 +01:00
PKEuS b564986d5d Added missing casts causing assertion failures on Windows (#5391)
-> Changed much more occurences, especially in preprocessor.cpp.
2014-03-18 21:41:47 +01:00
Thomas Jarosch 93341f4449 Use simple match where possible
Fixes these warnings found by "--enable=internal":

[lib/checkclass.cpp:972]: (warning) Found simple pattern inside Token::Match() call: "* *"
[lib/checkbufferoverrun.cpp:635]: (warning) Found simple pattern inside Token::Match() call: "."
[lib/checkbufferoverrun.cpp:1397]: (warning) Found simple pattern inside Token::Match() call: ";"
[lib/checksizeof.cpp:299]: (warning) Found simple pattern inside Token::Match() call: "."
[lib/checksizeof.cpp:301]: (warning) Found simple pattern inside Token::Match() call: ")"
[lib/checksizeof.cpp:303]: (warning) Found simple pattern inside Token::Match() call: "]"
[lib/checksizeof.cpp:318]: (warning) Found simple pattern inside Token::Match() call: ")"
[lib/checknullpointer.cpp:413]: (warning) Found simple pattern inside Token::Match() call: "delete"
[lib/checkio.cpp:1336]: (warning) Found simple pattern inside Token::Match() call: "> ("
[lib/checkstl.cpp:1509]: (warning) Found simple pattern inside Token::findmatch() call: ";"
[lib/checkstl.cpp:1512]: (warning) Found simple pattern inside Token::findmatch() call: ";"
[lib/checkstl.cpp:1594]: (warning) Found simple pattern inside Token::Match() call: "="
[lib/checkstl.cpp:1598]: (warning) Found simple pattern inside Token::Match() call: "] ="
[lib/checkunusedvar.cpp:755]: (warning) Found simple pattern inside Token::Match() call: "goto"
[lib/checkunusedvar.cpp:793]: (warning) Found simple pattern inside Token::Match() call: "="
[lib/checkuninitvar.cpp:376]: (warning) Found simple pattern inside Token::Match() call: "> ("
[lib/checkother.cpp:86]: (warning) Found simple pattern inside Token::Match() call: "> ("
[lib/checkother.cpp:2181]: (warning) Found simple pattern inside Token::Match() call: "> {"
[lib/valueflow.cpp:54]: (warning) Found simple pattern inside Token::Match() call: "&"
[lib/valueflow.cpp:409]: (warning) Found simple pattern inside Token::Match() call: "do"
[lib/valueflow.cpp:425]: (warning) Found simple pattern inside Token::Match() call: ") {"
[lib/valueflow.cpp:487]: (warning) Found simple pattern inside Token::Match() call: ") {"
[lib/valueflow.cpp:511]: (warning) Found simple pattern inside Token::Match() call: "} else {"
[lib/valueflow.cpp:615]: (warning) Found simple pattern inside Token::Match() call: "for ("
[lib/symboldatabase.cpp:80]: (warning) Found simple pattern inside Token::Match() call: "= {"
[lib/symboldatabase.cpp:1069]: (warning) Found simple pattern inside Token::Match() call: "std ::"
[lib/tokenize.cpp:2207]: (warning) Found simple pattern inside Token::Match() call: "< >"
[lib/tokenize.cpp:2730]: (warning) Found simple pattern inside Token::Match() call: ";"
[lib/tokenize.cpp:4234]: (warning) Found simple pattern inside Token::Match() call: "try {"
[lib/tokenize.cpp:4235]: (warning) Found simple pattern inside Token::Match() call: "} catch ("
[lib/tokenize.cpp:5500]: (warning) Found simple pattern inside Token::Match() call: "INT8"
[lib/tokenize.cpp:5752]: (warning) Found simple pattern inside Token::Match() call: "}"
[lib/tokenize.cpp:5752]: (warning) Found simple pattern inside Token::Match() call: "do"
2014-03-14 16:27:47 +01:00
Daniel Marjamäki fb5c2d4b48 use nullptr in lib/checkother.cpp 2014-02-15 08:46:28 +01:00
Daniel Marjamäki fd3a8a2a18 Update copyright 2014-02-15 07:45:39 +01:00
Daniel Marjamäki bc9ad08831 Fixed #5245 (false positive: Uninitialized variable (assignment inside ternary operator)) 2014-01-25 10:12:50 +01:00
Daniel Marjamäki e45a2e2c61 Fixed #5347 (False positive: uninitialized variable (try catch)) 2014-01-14 06:24:09 +01:00
Daniel Marjamäki 6182394966 Uninitialized variables: Fixed false positive taking value of pointer that is allocated but not initialized 2013-12-25 14:00:27 +01:00
Daniel Marjamäki 26dfddac6b UninitVar: Fixed false positive when checking if allocated pointer is null 2013-12-24 12:48:17 +01:00
Daniel Marjamäki 753559fff3 Uninitialized variables: Don't warn about try/catch exception variables 2013-12-24 07:39:15 +01:00
Daniel Marjamäki 661784a170 Fixed #5255 (False positive (error) Uninitialized variable: ptr2 - calling a static member function) 2013-12-23 16:50:27 +01:00
Daniel Marjamäki e2fa6a291c Uninitialized variables: Fixed false negatives for loop variables / pointer dereference 2013-12-23 12:27:00 +01:00
Daniel Marjamäki 80dec5a976 Uninitialized variables: Fixed FP when taking address of uninitialized variable 2013-12-13 20:10:22 +01:00
Daniel Marjamäki 7fe923bfc5 Uninitialized variables: Fixed FP when the variable is initialized in do-while condition 2013-12-13 13:27:01 +01:00
Daniel Marjamäki 3e6fbc6517 Fixed uninitialized variable FP after realloc if it fails. Related with ticket: #5240 2013-12-13 07:15:59 +01:00
Daniel Marjamäki 35189e80f2 Uninitialized variables: Fixed false positive for '*p=..' 2013-12-12 15:33:31 +01:00
Daniel Marjamäki 7321f92eff CheckUninitVar: Fix Coverity warning about possible null pointer. 2013-12-12 12:36:49 +01:00
Daniel Marjamäki 1b86615a69 Uninitialized variables: Fixed false positive for 'p=malloc; if (p) {}' 2013-12-12 11:44:07 +01:00
Daniel Marjamäki 4e7594748d Uninitialized variables: Fixed false positive for 'p=malloc; if (python tools/daca2.py b)' 2013-12-12 09:17:41 +01:00
Daniel Marjamäki 9f62740e1d Fixed #5236 (varid 0: vlc: src/misc/objects.c:126) 2013-12-12 08:44:00 +01:00
Daniel Marjamäki a4f9cb78d5 Uninitialized variables: Fixed false positives when passing allocated pointer to function 2013-12-11 05:54:42 +01:00
Daniel Marjamäki ef15e40de5 Uninitialized variables: error when passing uninit pointer to function 2013-12-10 18:36:16 +01:00
Daniel Marjamäki be5c00d215 Uninitialized variables: check function arguments 2013-12-09 15:58:42 +01:00
Daniel Marjamäki 14a00046a3 Fixed #5207 (Struct uninitialized members useage is not giving error (malloc).) 2013-12-04 20:32:20 +01:00
Daniel Marjamäki d8b25da73c Fixed #4740 (False Positive: Uninitialised variable 'int *a[2][19]; int **b = a[0];') 2013-11-25 06:38:23 +01:00
Daniel Marjamäki 7fc07989a7 UninitVar: Fixed false positive 'data is allocated but not initialized' when there is assignment 2013-11-23 10:24:29 +01:00
Daniel Marjamäki 71e61fb1ed Uninitialized variables: Fixed false positive when using ?: 2013-11-17 12:42:53 +01:00
Daniel Marjamäki 77e09d72a1 Uninitialized variables: Fixed false negatives when using ({}) 2013-11-17 12:11:18 +01:00
Daniel Marjamäki d342387b95 Uninitialized var: Fixed false negatives for self assignment 2013-11-16 18:07:33 +01:00
Daniel Marjamäki cfd6b0c384 UninitVar: fixed false negatives for function calls 2013-11-16 12:02:21 +01:00
Daniel Marjamäki 85b41059c5 astyle formatting 2013-11-10 15:49:53 +01:00
Simon Martin 185b88c6e3 Ticket #5073: Don't crash upon invalid do-while loop. 2013-11-08 23:13:21 +01:00
Daniel Marjamäki 86358694fb Uninitvar: Added comment to clarify that the old logic for function calls has been removed because it had FP and the 'same' checking in the new checker will be used to catch these errors instead. 2013-10-26 18:46:06 +02:00
Daniel Marjamäki 51ad9ab6ac Fixed #4896 (FP Uninitialized variable on template function) 2013-10-26 18:39:40 +02:00
Felipe Pena ed565f1ab1 - Fix comment 2013-10-12 13:49:35 -03:00