Commit Graph

6066 Commits

Author SHA1 Message Date
Daniel Marjamäki de1a91f30d Incomplete statement: tweaked bailout for '(void*)0' using isCasted() 2014-12-23 18:19:33 +01:00
Daniel Marjamäki 1b2a23b3fe Fixed #6350 (Tokenizer::simplifyCast: set Token::isCasted when cast is removed) 2014-12-23 16:16:14 +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
Daniel Marjamäki 10ae551fef CheckBufferOverrun: Use portability warning for pointer arithmetic UB. It can be used by intention and usually works as intended. 2014-12-22 10:56:17 +01:00
Thomas Jarosch bac1dfce86 Add test cases when sizeof is used on struct members 2014-12-22 09:59:34 +01:00
Thomas Jarosch dca65ce3da Fix FP if sizeof is used without parentheses on struct members
Right now we only support checking basic pointer types.
Pointers inside structs are not supported yet.

Consider the tokens "foo@1 . bar@2",
Token::Match( "sizeof ( %varid% )" ) won't match it.
Token::Match( "sizeof %varid%" ) did match it -> FP.
2014-12-22 09:44:08 +01:00
Daniel Marjamäki 93ac5a41cd Fixed #6346 (pointer calculation overflow) 2014-12-22 09:38:00 +01:00
Daniel Marjamäki 293dc1efc7 Fixed #6327 (Unwanted constStatement on (void)0) 2014-12-21 13:42:21 +01:00
PKEuS e03f49360f Merge pull request #484 from simartin/ticket_6181
Ticket #6181: Properly handle >> terminating template parameter lists.
2014-12-21 12:21:17 +01:00
Daniel Marjamäki a95e5bff2b Fixed #6344 (false positive: out of bounds access when array size is unknown) 2014-12-20 18:50:08 +01:00
Daniel Marjamäki b8371ebd87 Revert 2e45df3b. Because there are FP. 2014-12-18 06:37:15 +01:00
orbitcowboy 2e45df3b72 Fixed #6341: false negative uninitvar pattern "return foo ( %var%" 2014-12-17 17:43:31 +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
Daniel Marjamäki a1537e1a6e Fixed #6339 (false negative: array index out of bounds on allocated buffer using valueflow) 2014-12-17 16:23:48 +01:00
orbitcowboy f13475ceb2 Refactoring of testuninitvar: Splitted large test functions into smaller pieces. 2014-12-16 22:02:03 +01:00
orbitcowboy ade7365cc0 testuninitvar: moved more tests to checkUninitVar2, which does not rely on ExecutionPath. 2014-12-15 19:47:20 +01:00
orbitcowboy bf4b6dfd19 testuninitvar: changed test cases to do not rely on ExecutionPath. 2014-12-15 15:41:03 +01:00
orbitcowboy 32cd7d727d Fixed #6325: false negative: uninitialized variable usage (write, posix). 2014-12-15 10:05:44 +01:00
Simon Martin 4c7a8c5497 Ticket #6181: Properly handle >> terminating template parameter lists. 2014-12-14 15:14:27 +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
PKEuS 010eb1c8cb Merge pull request #483 from simartin/ticket_6172
Ticket #6172: Properly grok %type%... template parameters.
2014-12-14 17:01:25 +01:00
Simon Martin 859c6381cc Ticket #6172: Properly grok %type%... template parameters. 2014-12-14 14:33:37 +01:00
Daniel Marjamäki 5490fad8c7 Fixed #5840 (False positive (inconclusive): Possible nullpointer dereference - use before for-loop over nested list) 2014-12-14 14:10:42 +01:00
orbitcowboy ac4f7879db posix.cfg: Added support for rewinddir(). 2014-12-10 16:10:03 +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
orbitcowboy def3491829 posix.cfg: Added support for readdir(). 2014-12-10 17:44:21 +01:00
PKEuS ff5ede342b Fixed #6266: Support noexcept(false) 2014-12-09 23:53:50 +01:00
PKEuS 493ab541ab Fixed #6291 and #6293: Support :: in front of function name in checkUnusedFunctions
Simplified code in CheckUnusedFunctions
2014-12-09 22:04:51 +01:00
PKEuS e9bc3b7acf Fixed #6308: Properly associate Function with Scope for destructors in SymbolDatabase 2014-12-09 21:36:09 +01:00
orbitcowboy b8cca63a76 Improved test coverage of MathLib. 2014-12-03 18:24:27 +01:00
Alexander Mai ec2c4aa2e3 #6301 Unused shared lock variable. Add exception for std::shared_lock() to CheckUnusedVar::checkFunctionVariableUsage_iterateScopes() 2014-12-07 15:32:09 +01:00
Alexander Mai d11eb4931a #6306 false positive with strxfrm NULL argument. Adjust std.cfg in favor of no false positive 2014-12-07 15:24:27 +01:00
Alexander Mai c2584aa635 #6303 crash in CheckBufferOverrun. Add check on loop variable in CheckBufferOverrun::checkScope(). 2014-12-04 20:49:58 +01:00
Robert Reif c5bfd21d48 Tokenizer::simplifyTypedef: Add test that #5191 is fixed (function pointer) 2014-12-04 05:43:58 +01:00
Daniel Marjamäki e3892a95b5 Fixed #6290 (Tokenizer: Because 'and' is not simplified to '&&' there are false positives) 2014-12-03 16:32:05 +01:00
Robert Reif 418c2e51a0 Fixed #3314 (cppcheck incorrectly reporting Syntax error.) 2014-11-28 17:44:36 +01:00
Robert Reif 0dad8b64e8 Fixed #6268 (False positive functionStatic (inconclusive) - nested namespaces) 2014-11-27 06:29:33 +01:00
Alexander Mai 1779921306 Increase test coverage for MathLib 2014-11-26 17:35:32 +01:00
Dmitry-Me f926958acb Fix false positive about return type when there's =delete in operator= declaration 2014-11-25 15:52:52 +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
Frank Zingsheim 9497732ac8 Fixed #6238 (false positive with double fopen) 2014-11-20 22:19:39 +01:00
Daniel Marjamäki 051d42ae6b astyle formatting 2014-11-20 14:20:09 +01:00
orbitcowboy 4a2a4474c9 Fixed #6281: MathLib: Long integer suffix i64 is not supported. 2014-11-20 10:23:09 +01:00
orbitcowboy f5d804f71a running astyle 2014-11-20 10:13:03 +01:00
Robert Reif d12f14844a Fixed #6279 (False Positive: Member variable 'Fred::i' is not initialized in the constructor) 2014-11-20 06:18:29 +01:00
Robert Reif b7c9187539 Fixed #6280 (MathLib: binary literals are integers) 2014-11-19 06:43:52 +01:00
Alexander Mai 1c191845fb Fix invalid assertion from recent commit. Make single argument givenACodeSampleToTokenize ctor explicit. 2014-11-18 19:52:06 +01:00
PKEuS 4163f1e122 Fixed #6260 - C++11 style array initialization 2014-11-18 19:50:09 +01:00
PKEuS 428587f3d4 Fixed #6275: Simplification of = (NULL); to = 0; 2014-11-18 19:39:38 +01:00
Alexander Mai 85c02df56c Fix compiler warning. run astyle 2014-11-18 19:36:47 +01:00
PKEuS ad8749c0bd Fixed #6278: Remove casts to references to pointers in Tokenizer::simplifyCasts() 2014-11-18 19:23:59 +01:00
Alexander Mai 0ba3c15c52 Cure null pointer access within Scope::findFunction introduced by recent cs 2014-11-17 23:05:15 +01:00
Robert Reif c5e15950df Fixed #6230 (SymbolDatabase: Wrong function() is set for token) 2014-11-17 16:04:44 +01:00
Robert Reif 7c4a137e14 Fixed #6274 (MathLib::isFloat doesn't recognize long double literal suffix L or l) 2014-11-17 06:53:32 +01:00
Alexander Mai ea94b2748f #633 Adding tests for some MathLib member functions, should reach 100% function coverage now 2014-11-16 18:09:21 +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 149fe74d9d astyle formatting 2014-11-14 21:43:37 +01:00
orbitcowboy b9a9f51fe0 MathLib: Added test for isDec() and removed not required state. 2014-11-14 04:29:35 +01:00
Dmitry-Me cb9a6c1cb5 Don't show warning for same expressions alongside == in static_assert 2014-11-13 16:04:34 +01:00
Daniel Marjamäki 189dfd64f7 Revert "Fixed #6230 (SymbolDatabase: Wrong function() is set for token)"
This reverts commit 685fce6b91.
2014-11-11 07:29:16 +01:00
Daniel Marjamäki ea765c24f2 Fixed #3262 (Tokenizer: wrong 'return a=1,b=2,...;' simplification;) 2014-11-10 17:31:19 +01:00
Simon Martin cc6b51f2d9 Ticket #6059: Properly handle class... in parameter lists. 2014-11-07 23:08:54 +01:00
Daniel Marjamäki 685fce6b91 Fixed #6230 (SymbolDatabase: Wrong function() is set for token) 2014-11-07 11:10:20 +01:00
Robert Reif 1f32e9eee5 Symbol database: added test for findfunction 2014-11-07 10:46:31 +01:00
Daniel Marjamäki 8012ac9562 Fixed #5993 (FP: memleak (linux list)) 2014-11-07 07:44:12 +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 e5d63195cb Fixed #5983: Support storing pointers/references to member variables in CheckClass::checkConst() 2014-11-02 13:38:03 +01:00
Robert Reif df6855c216 SymbolDatabase: reintroduce test, move symboldatabase cleanup code to SymbolDatabase destructor 2014-11-02 10:36:52 +01:00
Frank Zingsheim 0e4c508d7b Fixed #4272 and #6237 (Crash from running out of memory with many templates) 2014-11-01 22:07:24 +01:00
Robert Reif 4eb33e7479 SymbolDatabase: Refactoring of findFunction 2014-11-01 14:36:17 +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
PKEuS c7d315fba3 Refactorization: Changed simplifyMathFunctions() to a single pass simplifier 2014-10-31 23:08:11 +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
PKEuS 6fdaf65cea Fixed createLinks2() when > is followed by ; (#6242) 2014-10-30 11:15:24 +01:00
Daniel Marjamäki 6088ba7951 Merge pull request #456 from simartin/ticket_6817_take2
Ticket #6187: Avoid infinite loop if eraseDeadCode does not remove anything (this time without memory corruption).
2014-10-23 09:43:02 +02:00
Daniel Marjamäki 4483c3e820 Fixed #6234 (FP : shift by too many bits is undefined on a QT container) 2014-10-23 06:52:19 +02:00
Simon Martin c6e2107d99 Ticket #6187: Avoid infinite loop if eraseDeadCode does not remove anything (this time without memory corruption). 2014-10-22 20:25:36 +02:00
Frank Zingsheim 71c5d4bd60 Ticket #6232 (cppOut of bounds array access)
--HG--
extra : rebase_source : 79ed3533a12a486ea3ed3f09f9bc55b1a4771161
2014-10-21 22:56:53 +02:00
Daniel Marjamäki a3efa1e180 Fixed #4776 (FP: Assignment of function parameter has no effect outside the function, with goto) 2014-10-21 16:21:33 +02:00
Robert Reif 42f709c09d Fixed #6229 (Move Windows builtin types __intXX to library) 2014-10-21 06:11:19 +02:00
Daniel Marjamäki d8b50e73df Fixed #6002 (Defect: False positive due to pointer address not being associated with variable in for loop) 2014-10-20 15:54:02 +02:00
Robert Reif d5908f03b7 Fixed #6226 (false negative: printf format check for user defined array type) 2014-10-20 06:33:36 +02:00
Robert Reif e2f72b4cb1 Fixed #6215 (Move Windows platform types into library) 2014-10-19 07:34:40 +02:00
PKEuS b724784f0b Removed obsolete comments 2014-10-18 11:18:07 +02:00
Daniel Marjamäki 0fd6586fcc Fixed #6219 (valueFlowForward: better multivariable analysis needed to avoid FP) 2014-10-17 06:50:33 +02: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
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 a99fd364ef Restored functionality to detect std::string(0) calls as null pointer dereferences (#6189) 2014-10-16 19:12:02 +02:00
Daniel Marjamäki 7107286be6 Fixed #5891 (AST: wrong ast generated for 'x = (int)(double(123)*i);') 2014-10-16 15:57:05 +02:00
PKEuS eefaddf980 Fixed bug in Tokenizer::simplifyReference() (#6133) 2014-10-16 11:43:42 +02:00
PKEuS 9a755714b5 Removed unused function from testsymboldatabase.cpp 2014-10-16 11:12:28 +02:00
PKEuS 6955e719cf Collected garbage code tests and moved them to testgarbage.cpp 2014-10-16 10:59:46 +02:00
Frank Zingsheim 9dd3bce98b Fixed #6214: non-static member initializer causes false positive 2014-10-16 09:11:09 +02:00
Daniel Marjamäki ecd17d84fb Reverted f088588c fix for #6187 that fixes infinite loop, the fix cause a use-after-free regression. 2014-10-16 06:32:06 +02:00
Robert Reif 45a2986f34 Added test for #6171 2014-10-15 21:41:15 +02:00
Frank Zingsheim eab0878b8a Support {} initialization in initializer list (#6216) 2014-10-15 21:33:21 +02:00
Daniel Marjamäki 228206f556 Fixed #6067 (ValueFlow: subfunction, condition with && or ||) 2014-10-15 16:34:03 +02:00