Commit Graph

897 Commits

Author SHA1 Message Date
Daniel Marjamäki 348c26f59c fixed segmentation fault in case typeStartToken() returns 0 2014-03-29 21:01:21 +01:00
Daniel Marjamäki efc84ac310 Fix segmentation fault when checking build/tokenize.cpp 2014-03-29 20:41:17 +01:00
Daniel Marjamäki 407c9fdf9d Refactored checkNegativeBitwiseShift() so it uses ast and valueflow 2014-03-29 13:01:30 +01:00
Daniel Marjamäki 502ba95383 Simplification. Code 'else if ..' is simplified to 'else { if ..' 2014-03-28 18:21:56 +01:00
PKEuS 50a94885ce Fixed oppositeInnerCondition check:
- Resolved false positives #4170 and #4186, as well as numerous other potential false positives
- Improved message to point to both locations
- Inner condition could also be a while loop; Outer if could also be 'else if'
- Made the check non-experimental again (#3645)
2014-03-28 14:55:17 +01:00
PKEuS e8c7a723f5 Fixed five new true positives in cppcheck, silenced one new false positive (see #5618) 2014-03-27 15:50:30 +01:00
PKEuS b23aebf2f0 Show redundantCopyLocalConst for STL types (#4331) 2014-03-27 11:15:17 +01:00
PKEuS 5083dd4273 Fixed two visual studio warnings 2014-03-24 18:14:23 +01:00
PKEuS 8d5be8c4a4 Fixed related issues to #5601 2014-03-22 22:35:20 +01:00
PKEuS 58c2f372b9 Fixed false positive when noreturn function is defined (#5601, second attempt) 2014-03-22 19:55:13 +01:00
PKEuS 77c871035b Fixed false positive when noreturn function is defined (#5601) 2014-03-22 18:57:19 +01:00
Daniel Marjamäki 7d2357de8d Refactoring. Use astIsFloat() 2014-03-22 18:42:29 +01:00
Daniel Marjamäki 54e7f34f4a Fixed #5584 (FP: Division by zero when function not declared) 2014-03-20 16:12:58 +01:00
PKEuS 2568baa473 #5528: Raise duplicateExpressionError on operators /, % and -. 2014-03-17 18:35:36 +01:00
PKEuS fab6b56360 Improved check (#5553): Detect stricmp(var.c_str(), var.c_str()) 2014-03-17 17:41:45 +01:00
PKEuS ebd0b43c4f Fixed #5382: False positive "scope can be reduced" when initializing two-dimensional array. 2014-03-17 12:34:39 +01:00
PKEuS d325d14b11 Fixed false positive #5535: Reference named like its type. 2014-03-17 12:01:39 +01:00
Daniel Marjamäki ce1aa1e011 Library: I had misunderstood const/pure a little so I corrected cfg and code 2014-03-14 20:08:34 +01:00
Daniel Marjamäki b2708987c3 Merge pull request #264 from thomasjfox/simplematch
Use simple match where possible
2014-03-14 17:51:45 +01:00
Daniel Marjamäki a929b2146e Improved checking of const functions in checkIncorrectLogicOperator 2014-03-14 17:37:53 +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 8d8913a168 Partial fix for #5555. Add const,pure attributes to library. 2014-03-14 06:38:45 +01:00
Frank Zingsheim 5e0a575091 Optimization: tokenlist::addtoken 2014-03-09 17:54:49 +01:00
Alexander Mai 50a184c3e9 Fixed #5166 (segmentation fault (invalid code) in lib/checkother.cpp:329 ( void * f { } void b ( ) { * f } )) 2014-02-27 18:24:51 +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 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 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
Lucas Manuel Rodriguez 052840f8f5 Fixed #4818 (New check: Check memset() 2nd parameter) 2014-02-15 15:06:00 -03: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 486a3192c0 Fixed #5246 (false positive: (warning) Logical conjunction always evaluates to false: t > 0 && t < 1.) 2014-02-04 06:50:29 +01:00
Lucas Manuel Rodriguez ad0269eeeb Refactor checks using Variable::isStlType() 2014-01-30 01:26:48 -03: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 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 3facc06cb7 CheckOther: Removed non-valueflow check for division by possible zero before condition 2014-01-17 17:42:54 +01:00
Daniel Marjamäki ab866be03a Tokenizer: Move 'else if' simplification to tokenize 2014-01-12 17:47:02 +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 ceca6be22b Fixed #5334 (False positive: same expression on both sides of '||') 2014-01-11 15:15:01 +01:00
Daniel Marjamäki 39b47cc1e7 value flow: improved error message output for conditional division by zero 2014-01-06 10:51:17 +01:00
Daniel Marjamäki 0877adb542 astyle formatting 2014-01-05 21:12:32 +01:00
Daniel Marjamäki afaf1473a8 Value flow: refactorings, write debug warning if iterating too far 2014-01-05 20:06:46 +01:00
Daniel Marjamäki d8270c710a Add new experimental value flow analysis 2014-01-04 20:57:02 +01:00
Daniel Marjamäki 372c29c24e Fixed #5284 (duplicateExpression falsely reported by members of a union in some circumstances) 2014-01-02 16:58:07 +01:00
Daniel Marjamäki 4b72f01e99 clarify calculation: Fixed FP for 'a = (*p ? 1 : 2)' 2013-12-28 11:02:39 +01:00
Daniel Marjamäki 4c44e62159 AST: Refactored CheckOther::clarifyCalculation 2013-12-24 10:07:20 +01:00
Daniel Marjamäki 042d3afb80 CheckOther::checkDuplicateExpression: Readded warnings when there is a expression between the duplicate expressions 'X || Y || X' 2013-12-24 07:21:46 +01:00
Daniel Marjamäki ac30a84c3a Refactoring: Replaced CheckOther::checkCCTypeFunctions with configuration 2013-12-23 19:58:33 +01:00