Commit Graph

5500 Commits

Author SHA1 Message Date
Daniel Marjamäki dea4107245 Fix Cppcheck warning 2014-02-26 06:38:48 +01:00
Daniel Marjamäki 7dbfd67da3 Fixed #5493 (False positive: Found a statement that begins with numeric constant / string constant - in the presence of initialization list.) 2014-02-26 06:18:52 +01:00
Daniel Marjamäki 8550289722 Fixed #5452 (AST: wrong handling of unary ::) 2014-02-25 06:36:10 +01:00
Alexander Mai 0747b55485 Fixed #5304 (Wrong simplification of numbers like 001E+07 to 1.0) 2014-02-24 18:52:31 +01:00
Daniel Marjamäki acf5723bdd AST: improved AST printout when --verbose is used 2014-02-24 17:22:29 +01:00
Daniel Marjamäki 8dd7f02e45 Fixed #5381 (Some false positives that came up when using --enable=performance file.c) 2014-02-23 11:02:39 +01:00
Daniel Marjamäki f6b42633e8 Fixed #5434 (FP: Out-of-bounds access with ternary operator in loop) 2014-02-22 17:59:12 +01:00
Daniel Marjamäki 34730f623a Fixed #5301 (False positive: (error) Division by zero - variables read from input stream) 2014-02-22 12:09:54 +01:00
Daniel Marjamäki 910a90e4c1 Revert "cxx11.h: removed the 'evil workaround'"
This reverts commit 2cb9032d76.
2014-02-21 20:06:55 +01:00
Alexander Mai 82a2279425 Fixed #5304 (Wrong simplification of numbers like 001E+07 to 1.0) 2014-02-20 16:56:49 +01:00
Daniel Marjamäki ed9153ee80 Symbol database: added simple mismatch check in Scope::findFunction when passing address to function that expects a reference 2014-02-19 06:35:51 +01:00
Daniel Marjamäki 690c37633b ValueFlow: Fixed bad values after break/continue 2014-02-17 20:07:38 +01:00
Daniel Marjamäki c050a92bae Fixed #5468 (crash: freebsd: llvm/RegionPrinter.cpp - AST failure) 2014-02-17 17:37:39 +01:00
Daniel Marjamäki d37359217c Merge pull request #241 from lanurmi/more-nullptr
Change some more 0 literals into nullptr.
2014-02-16 23:29:23 +01:00
Lauri Nurmi 70a67eaf85 Change some more 0 literals into nullptr. 2014-02-16 13:38:50 +02:00
Daniel Marjamäki fdcb325d70 DuplicateBranch: Made warning inconclusive since it's in most cases noise 2014-02-16 11:04:27 +01:00
Daniel Marjamäki 23efc68dd7 use nullptr 2014-02-16 10:32:10 +01:00
Lucas Manuel Rodriguez 052840f8f5 Fixed #4818 (New check: Check memset() 2nd parameter) 2014-02-15 15:06:00 -03:00
Daniel Marjamäki 2cb9032d76 cxx11.h: removed the 'evil workaround' 2014-02-15 16:19:50 +01:00
Daniel Marjamäki f0220c5340 astyle formatting 2014-02-15 16:18:13 +01:00
Daniel Marjamäki 209dffbe1b use nullptr in lib/checkmemoryleak.cpp 2014-02-15 16:17:56 +01:00
Daniel Marjamäki 68119f0230 use nullptr in lib/checknullpointer.cpp 2014-02-15 16:12:37 +01:00
Daniel Marjamäki fb5c2d4b48 use nullptr in lib/checkother.cpp 2014-02-15 08:46:28 +01:00
Daniel Marjamäki 720bd48a98 use nullptr in lib/library.cpp 2014-02-15 08:41:17 +01:00
Daniel Marjamäki 9eb789bdb2 use nullptr in lib/preprocessor.cpp 2014-02-15 08:37:57 +01:00
Daniel Marjamäki 5fe78d1534 use nullptr in lib/token.cpp 2014-02-15 08:05:54 +01:00
Daniel Marjamäki 384ffb4173 use nullptr in lib/tokenize.cpp 2014-02-15 08:04:54 +01:00
Lauri Nurmi 91340d4043 Emulate the C++11 'nullptr' and 'static_assert' 2014-02-15 07:52:17 +01:00
Daniel Marjamäki fd3a8a2a18 Update copyright 2014-02-15 07:45:39 +01:00
Daniel Marjamäki a1d9873558 Fixed #5465 (crash: AST doesnt produce good output for 'class C:public :🅰️:b<c>{..};') 2014-02-14 06:30:51 +01:00
Lucas Manuel Rodriguez 828609bb11 Fixed two doxygen errors - http://cppcheck.sourceforge.net/devinfo/doxygen-errors.txt 2014-02-09 16:46:49 -03:00
Daniel Marjamäki 8305015dea astyle formatting 2014-02-08 08:51:38 +01:00
Pavel Roschin 19a8cfd960 Library: add new "define" tag
This tag will allow to add some preprocessor defs into library.
It would be useful to provide more information about libraries
implementation details. As example GLib's library include tag
was added that helps to detect more memory leaks.
2014-02-07 10:13:36 +04:00
Daniel Marjamäki 3c6bfac89c Merge pull request #234 from scriptum/rpg-use-whitelist-from-library
CheckMemoryLeak: use library while checking whitelist functions
2014-02-05 11:41:47 +01:00
Daniel Marjamäki ec80068cd9 Merge pull request #228 from simartin/osx_build_restore
RFC: Restore build on OSX
2014-02-05 11:30:34 +01:00
Pavel Roschin 0dd227419d CheckMemoryLeak: use library while checking whitelist functions 2014-02-05 12:16:50 +04:00
Daniel Marjamäki 6ac9e180e0 ast: fixed hang when checking beid 2014-02-05 06:05:48 +01:00
Daniel Marjamäki 2ed3b40937 ast: fixed hang when checking bin-prot 2014-02-04 19:33:26 +01:00
Daniel Marjamäki 486a3192c0 Fixed #5246 (false positive: (warning) Logical conjunction always evaluates to false: t > 0 && t < 1.) 2014-02-04 06:50:29 +01:00
Daniel Marjamäki ec61143623 Merge pull request #233 from orbitcowboy/master
Fixed #389: Providing negative value to memory allocation function.
2014-02-02 10:47:37 -08:00
Heinrich Schuchardt 6bfd4af5f7 5355: False postive var not assigned
Avoid false positive "variable not assigned" for

struct Fred{
};
void foo () {
  Fred fred;
  throw fred;
}

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2014-02-01 22:40:35 +01:00
Martin Ettl 6ca7daec10 Fixed #389: Providing negative value to memory allocation function. 2014-02-01 22:38:29 +01:00
Simon Martin 8ff9696374 OSX's compiler supports C++11 but one needs to use GNU's STL to build cppcheck, that does not have cbegin/end. 2014-02-01 07:40:08 +01:00
Daniel Marjamäki b3bfd5014d Fixed #5433 (FP:Possible null pointer dereference) 2014-01-31 15:43:34 +01:00
Daniel Marjamäki 9aa9530e0d Fixed #5426 (crash: btrfs-progs cmds-inspect.c) 2014-01-31 06:19:36 +01:00
Lucas Manuel Rodriguez a34d2eb7b3 Fixed #4938: (.empty() method false positive for non-STL classes) 2014-01-30 18:09:24 -03:00
Daniel Marjamäki d6e3b3d3f3 ast: fixed syntax tree for 'a=(b)?1:0'. The parentheses should not be in the syntax tree 2014-01-30 17:31:06 +01:00
Lucas Manuel Rodriguez ad0269eeeb Refactor checks using Variable::isStlType() 2014-01-30 01:26:48 -03:00
Daniel Marjamäki 30b56437c1 Merge pull request #226 from scriptum/rpg-fix-function-parameter
CheckMemoryLeak: improve leak checking in function parameters
2014-01-28 20:32:56 -08:00
Lucas Manuel Rodriguez b69fedf70b Fix '-Wshadow' warning (from 'Fixed #5423' commit) 2014-01-28 23:16:29 -03:00
Lucas Manuel Rodriguez 7fdc4ab6cc Refactor isContainerSizeSlow() to use Variable::isStlType() 2014-01-28 13:31:23 -03:00
Kamil Dudka dee18d10a8 Fixed #5423 (fix parsing of #line NNNN "file.c") 2014-01-28 17:15:07 +01:00
Daniel Marjamäki abe8439917 Fixed #5416 (False positive: Array accessed at index, which is out of bounds.) 2014-01-28 16:55:10 +01:00
Lucas Manuel Rodriguez 2048313915 Add Variable::isStlType function 2014-01-28 11:44:56 -03:00
Pavel Roschin 2396073262 CheckMemoryLeak: improve leak checking in function parameters 2014-01-28 17:30:36 +04:00
Daniel Marjamäki 2108251851 Fixed #5417 (ast: avoid hang when '({})' is used) 2014-01-28 06:11:53 +01:00
Daniel Marjamäki c8a1424e10 Fixed #5406 (crash inside valueFlowBeforeCondition() on files from kernel-git) 2014-01-27 06:18:42 +01:00
Daniel Marjamäki 2b8cf462c9 CheckMemoryLeak: Move posix-opendir/closedir to library 2014-01-26 17:02:36 +01:00
Daniel Marjamäki 0c47555423 CheckNullPointer: use library instead of hard coded info 2014-01-26 16:19:49 +01:00
Daniel Marjamäki be082a8e4a value flow: added bailout for conditional return/continue/break when number_of_if is bigger than 0 2014-01-26 15:50:25 +01:00
Daniel Marjamäki c5971b7137 value flow: fix fp when conditional value is assigned 2014-01-25 20:14:49 +01:00
Daniel Marjamäki c1e35e1df1 value flow: fixed multivariable problem in condition 2014-01-25 19:13:33 +01:00
Daniel Marjamäki d227ed245f cleanup 2014-01-25 18:51:55 +01:00
Daniel Marjamäki df0995edf5 Fixed #5403 (Value flow: FP because post increment/decrement is not handled correctly) 2014-01-25 18:31:02 +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 35b51468cb value flow: Fixed FP for division then check in for loop: 'for (a=b/x;x>0;x--)' 2014-01-25 09:22:32 +01:00
Daniel Marjamäki 4647a9fc93 Fixed #5401 (value flow: fp when there are increment/decrement) 2014-01-24 18:22:38 +01:00
Daniel Marjamäki 1cac7e1686 value flow: better handling in function call bailout of casting address of variable 2014-01-24 17:47:49 +01:00
Daniel Marjamäki 135998abba value flow: use const when possible 2014-01-24 06:16:23 +01:00
Heinrich Schuchardt de20ba6763 [PATCH] Types in isRecordTypeWithoutSideEffects
The type definition of the iterator should match the type definition of the map <const Type *, bool>.
2014-01-24 06:10:19 +01:00
Daniel Marjamäki 85b6495cce value flow: fixed comments 2014-01-23 19:40:47 +01:00
Daniel Marjamäki ec034c1d59 Fixed #5386 (ast: hang when code is 'for (T a : b)') 2014-01-23 06:13:24 +01:00
Daniel Marjamäki 0dbb86f0cb Cleanup ExecutionPath from CheckBufferOverrun 2014-01-22 21:25:37 +01:00
Daniel Marjamäki 1d7bb05faf Remove ExecutionPath from CheckNullPointer 2014-01-22 20:24:51 +01:00
Daniel Marjamäki f3f7e6d302 value flow: replacing executionpath checking of null pointers 2014-01-22 20:16:31 +01:00
Daniel Marjamäki 43db1ee797 value flow: use more specific bailouts when analysing value flow after assignment 2014-01-22 06:38:25 +01:00
Daniel Marjamäki cc38dec3ad value flow: a bit better handling of assigned variable 2014-01-22 06:10:17 +01:00
Daniel Marjamäki 2b7a991c1a temporarily hide gcc warnings 2014-01-21 21:17:03 +01:00
Daniel Marjamäki a27ccbd0f8 value flow: start implementing value flow analysis of assigned value 2014-01-21 21:13:49 +01:00
Daniel Marjamäki a84fdf98cc Null pointer: remove old checking that is replaced by value flow checking 2014-01-21 19:50:52 +01:00
Daniel Marjamäki 20b73747e0 value flow: refactor. added Token::getMaxValue() 2014-01-21 16:58:23 +01:00
Daniel Marjamäki b91f42453b value flow: improved handling of cast 2014-01-20 22:26:55 +01:00
Daniel Marjamäki bb3cc67aaa value flow: improved calculations that depends on variable 2014-01-20 21:45:30 +01:00
Daniel Marjamäki 69109784e8 value flow: cleanup usage of valueflow. utility function Token::getValue was added. 2014-01-20 06:49:45 +01:00
Daniel Marjamäki add84187cc CheckOther: Removed old zero division check 2014-01-20 06:31:13 +01:00
Daniel Marjamäki 7ff7bc1c2e Fixed #5376 (false positive: zerodivcond (style) Either the condition 'B>0' is useless or there is division by zero) 2014-01-19 20:16:55 +01:00
Daniel Marjamäki 84c5f47eb1 value flow: bailout for class variables that are non-const 2014-01-19 11:55:02 +01:00
Daniel Marjamäki ccda78f347 value flow: fixed todo assertion for handling of conditions 2014-01-19 09:31:40 +01:00
Daniel Marjamäki cdaa7abf7e value flow: better handling of conditional code below || && ?: operators 2014-01-19 09:05:48 +01:00
Daniel Marjamäki 2d0a68cac2 cleanup redundant variable inconclusive 2014-01-18 19:51:57 +01:00
Daniel Marjamäki 77f3f6c21a valueflow: added setTokenValue that perform calculations using set value 2014-01-18 19:30:44 +01:00
Daniel Marjamäki 6a3a9ee8e7 ast: fixed tree for 'sizeof(struct S)' 2014-01-18 13:18:11 +01:00
Daniel Marjamäki c7032a8867 value flow: improved handling of loops 2014-01-18 11:54:00 +01:00
Daniel Marjamäki 498cdb8610 added debug output for the value flow 2014-01-18 09:58:32 +01:00
Ryan Pavlik 32bf275447 Fix case-insensitive string compare function on MinGW 2014-01-17 15:29:53 -06:00
Daniel Marjamäki 3e23e243f6 BufferOverflow: Updated message for out of bounds array index or redundant condition 2014-01-17 19:44:45 +01:00
Daniel Marjamäki 57d318b2e5 valueflow: better handling of increment/decrement 2014-01-17 19:28:28 +01:00
Daniel Marjamäki 18d6285ad2 BufferOverrun: Improved error message when array index is used before checking that its in limits 2014-01-17 18:56:46 +01:00
Daniel Marjamäki b2b5590f2b Refactoring: Moved astStringify to the Token class and renamed it to expressionString. This can often be useful when reporting error messages that contains source code. 2014-01-17 18:37:49 +01:00
Daniel Marjamäki 30cae358d8 Removed the --value-flow flag. ValueFlow analysis will always be enabled from now on. 2014-01-17 18:07:05 +01:00
Daniel Marjamäki 5721e1d745 CheckNullPointer: Removed some of the old checking that doesn't use ValueFlow 2014-01-17 17:47:59 +01:00
Daniel Marjamäki 311059f603 Tokenizer: Removed commented-out simplification 2014-01-17 17:44:33 +01:00
Daniel Marjamäki 3facc06cb7 CheckOther: Removed non-valueflow check for division by possible zero before condition 2014-01-17 17:42:54 +01:00
Daniel Marjamäki 0203a4a6f5 Tokenizer: Removed simplifyGoto as it's the cause of various FPs I see 2014-01-17 17:36:45 +01:00
Daniel Marjamäki 4eb746d7cc Tokenizer: Removed simplifyComparisonOrder 2014-01-17 17:25:56 +01:00
Daniel Marjamäki 0b4de97e2b value flow: Use ValueFlow in CheckBufferOverrun 2014-01-16 19:23:14 +01:00
Daniel Marjamäki 85b73f7c24 ast: fixed hang for weird loop: 'for (each_window(list,p))' 2014-01-16 16:58:50 +01:00
Daniel Marjamäki e72ec830ef ast: fixed hang in for-loop handling 2014-01-16 06:45:35 +01:00
Daniel Marjamäki 141e089329 ast: different handling of for loops. create a syntax tree for whole 'f(a;b;c)'. 2014-01-15 17:32:14 +01:00
Daniel Marjamäki c547c9a108 value flow: fixed fp when variable is used in for-loop condition 2014-01-14 17:57:50 +01:00
Daniel Marjamäki e45a2e2c61 Fixed #5347 (False positive: uninitialized variable (try catch)) 2014-01-14 06:24:09 +01:00
Robert Reif d679a4c1f7 Fixed #5248 (False positive: Invalid argument in scanf for %zd) 2014-01-14 06:09:13 +01:00
Daniel Marjamäki c1c2f4bbc6 value flow: fixed crash reported in #5343 when typeStartToken and typeEndToken are misplaced. 2014-01-13 20:54:09 +01:00
Daniel Marjamäki 7981e3d38f value flow: fix fp when gotos are used 2014-01-13 16:07:25 +01:00
Daniel Marjamäki bfc67a536a value flow: fixed fp when self-checking checkbool.cpp. added some comments. 2014-01-13 06:15:21 +01:00
Daniel Marjamäki b1bbb23225 value flow: fixed fp when checking symboldatabase 2014-01-13 05:52:28 +01:00
Daniel Marjamäki f6c7be91a9 Fixed cppcheck warning 2014-01-12 21:19:20 +01:00
Daniel Marjamäki 8b6f001f94 value flow: inconclusive handling of unknown functions 2014-01-12 19:48:20 +01:00
Daniel Marjamäki 5d2a39b580 CheckNullPointer: improved function call checking when new value flow analysis is used 2014-01-12 19:27:26 +01:00
Daniel Marjamäki 2e67ca06c0 value flow: some simplifications in unknown functions when there is library configuration 2014-01-12 18:19:00 +01:00
Daniel Marjamäki ab866be03a Tokenizer: Move 'else if' simplification to tokenize 2014-01-12 17:47:02 +01:00
Daniel Marjamäki d700114edf value flow: bailout if condition is defined by macro 2014-01-12 17:16:51 +01:00
Heinrich Schuchardt f6510a6b45 Fixed #5339 (Tokenizer::setVarId : function-pointer function argument not getting variable id, causing FP) 2014-01-12 15:15:09 +01:00
Daniel Marjamäki 3d79613f2b value flow: more bailouts when return/break/continue/goto is reached. TODO: handle these better. 2014-01-12 15:07:58 +01:00
Daniel Marjamäki 155990cb0e value flow: improved checking of do-while loops for non-local variables 2014-01-12 15:02:58 +01:00
Daniel Marjamäki 5b679fc732 value flow: fixed fp for data member 2014-01-12 14:37:26 +01:00
Alexander Mai 86763b401c Fixed #5340 (Preprocessor: not using errorLogger when reporting syntax errors) 2014-01-12 13:15:54 +01:00
PKEuS b775714e3d Moved several hardcoded function names in format string checking into libraries (std.cfg and windows.cfg).
Added support for loading a library in test suite.
2014-01-12 03:44:24 -08:00
Daniel Marjamäki 21d317b7d6 value flow: fixed redundant null pointer check 2014-01-12 12:38:41 +01:00
Daniel Marjamäki d8262963d9 value flow: condition in loop, bailout valueflow analysis before loop if there is assignment inside the loop 2014-01-12 11:58:10 +01:00
Daniel Marjamäki e3496080c8 Fixed #5334 (False positive: same expression on both sides of '||') 2014-01-12 07:40:56 +01:00
Daniel Marjamäki f58e1ab80e value flow: fixed fp in switch 2014-01-11 21:21:00 +01:00
Daniel Marjamäki 3625d179e5 value flow: don't perform value flow analysis in sizeof/typeof expressions 2014-01-11 21:10:01 +01:00
Daniel Marjamäki 680d3f1312 value flow: fixed fp for nested assignments 2014-01-11 20:53:23 +01:00
Daniel Marjamäki 4d045879aa value flow: fixed fp when while condition contains variable that is changed in loop body 2014-01-11 20:25:49 +01:00
Daniel Marjamäki 75f9111775 value flow: bailout when variable is used in assignment to itself 2014-01-11 15:36:09 +01:00
Daniel Marjamäki 1fc2c9fe79 ast: fixed syntax tree for statement enclosed in parentheses ';(expr);' 2014-01-11 15:18:39 +01:00
Daniel Marjamäki ceca6be22b Fixed #5334 (False positive: same expression on both sides of '||') 2014-01-11 15:15:01 +01:00
Daniel Marjamäki eaf8c83db5 value flow: refactoring. broke out function for skipping value simplifications in expressions. 2014-01-11 14:54:10 +01:00
Daniel Marjamäki 85dcb14813 value flow: bailout in valueFlowBeforeCondition if variable can be assigned by subfunction 2014-01-11 14:31:51 +01:00
Daniel Marjamäki 225001a45c value flow: changed astparent lookup 2014-01-11 12:47:47 +01:00
Daniel Marjamäki 02b92efd1a value flow: improved analysis of expressions below ?, && and || operators 2014-01-11 12:44:55 +01:00
Daniel Marjamäki 60348da1b5 value flow: fixed fp for rhs in && and || expressions 2014-01-11 11:30:34 +01:00
Daniel Marjamäki 1ad94a8be5 value flow: loosen up bailouts in valueFlowSubFunction 2014-01-11 07:52:25 +01:00
Daniel Marjamäki 57d241793f value flow: fix segfault if var is null 2014-01-10 18:30:41 +01:00
Daniel Marjamäki c687933e9f value flow: improved handling of for loops 2014-01-10 18:19:24 +01:00
Daniel Marjamäki 3eebc8a9f1 test1 2014-01-10 16:51:58 +01:00
Daniel Marjamäki 3e7f692d4d value flow: stop checking global variable when going out of function scope 2014-01-10 16:17:19 +01:00
Daniel Marjamäki acb103e214 value flow: skip scopes that don't contain variable 2014-01-10 16:13:39 +01:00
Daniel Marjamäki 81513b4346 value flow: Readded safety check that tok->astOperand1() is not NULL 2014-01-10 05:54:03 +01:00