Commit Graph

7901 Commits

Author SHA1 Message Date
Daniel Marjamäki d82805b7fe CheckCondition: Improved checking for same conditions 2017-09-04 22:40:34 +02:00
Daniel Marjamäki abae5e0156 Fixed #8198 (false positive: (warning) Same condition, second condition is always false) 2017-09-04 22:25:20 +02:00
Daniel Marjamäki ad494b996c TestCondition: break out tests to functions 2017-09-04 22:11:53 +02:00
Daniel Marjamäki d838dc2129 CheckCondition::multiCondition2: Fix FN for pointers 2017-09-04 15:58:22 +02:00
Daniel Marjamäki 9465dca583 CheckCondition: Fix FPs for aliased variables (daca) 2017-09-04 09:34:03 +02:00
Daniel Marjamäki a02fd54a69 ValueFlow: Avoid FPs for aliased variables 2017-09-03 23:24:55 +02:00
Daniel Marjamäki ef4a7ba7f2 Fix FP in CheckCondition::multiCondition2 2017-09-03 14:46:37 +02:00
Daniel Marjamäki b9849d9e4e CheckCondition::multiCondition2: Handle loops better 2017-09-03 11:03:01 +02:00
Daniel Marjamäki 01e65d3e00 Improved CheckCondition::multiCondition2 so deeper bugs are found 2017-09-03 10:44:22 +02:00
Daniel Marjamäki f2ec5f24ce Fixed #5845 (new check: same condition after noreturn conditional code => second condition is always false) 2017-09-03 10:34:34 +02:00
Hinterwaeldlers 8aa568f085 Corrected noexcept constructor delegating handling (#948) 2017-09-02 22:54:23 +02:00
Daniel Marjamäki 1ecefa045a Fixed #8194 (False positive reademptycontainer - range based loop) 2017-09-02 22:22:32 +02:00
Daniel Marjamäki 30f04a5a96 Fixed #8195 (False positive uninitvar (regression) - valueflow misses variable initialization via istringstream >>) 2017-09-02 21:53:51 +02:00
Daniel Marjamäki 0b751dcc1b Opposite conditions: Better matching when outer condition uses && 2017-09-01 23:24:15 +02:00
Daniel Marjamäki 3b4f60fd21 Updated error message 2017-09-01 13:33:47 +02:00
Daniel Marjamäki 7fad1b9a36 Improved checking for opposite conditions 2017-08-31 22:53:21 +02:00
Daniel Marjamäki dce942197c Fixed #8186 (Inner condition always false inside for loop) 2017-08-31 16:00:12 +02:00
Daniel Marjamäki 82527422a8 Fixed #5614 (Incorrect syntax error with function pointer typedef and dependent template types) 2017-08-30 19:18:05 +02:00
Daniel Marjamäki 9c99bc43c2 ValueFlow: Skip wrong handling of lambda functions. TODO: handle lambda functions properly. 2017-08-28 22:39:12 +02:00
Daniel Marjamäki 02a1b7cd2d Fixed #7965 (valueFlowForward: Improved handling of correlated variables) 2017-08-27 19:50:44 +02:00
Daniel Marjamäki 713f607168 Fixed #8156 (wrong ast for 'z = (x & (unsigned)1) | (y & (unsigned)2);') 2017-08-26 23:25:45 +02:00
Daniel Marjamäki e74e4c6934 Fixed #8030 (False positive 'constStatement' when indexing with {}) 2017-08-26 11:59:09 +02:00
Daniel Marjamäki 529b255e99 ValueFlow: Better errorpath for increment/decrement 2017-08-25 23:07:26 +02:00
Daniel Marjamäki b1b8e5270a ValueFlow: Better errorpath for increment/decrement 2017-08-25 22:15:52 +02:00
Heiko Eißfeldt bab2b26d10 Fixed #8154 (heap use after free in tokenlist) 2017-08-25 17:17:19 +02:00
Daniel Marjamäki 50636f75ba ValueFlow: Improved error path for compound assignments 2017-08-24 22:02:49 +02:00
Daniel Marjamäki d160d27417 Fixed #8172 (False positive uninitvar on sizeof *ptr) 2017-08-23 22:17:49 +02:00
Daniel Marjamäki f10634c021 ValueFlow: Dont try to evaluate '/=0;' 2017-08-23 17:53:05 +02:00
Daniel Marjamäki 167cfb1ac5 valueFlowForward: improve handling of compound assignments 2017-08-23 11:13:47 +02:00
Daniel Marjamäki 71b0370389 Fixed #1793 (CheckType::checkFloatToIntegerOverflow: assignments) 2017-08-23 05:34:47 +02:00
Daniel Marjamäki 2679b576c2 Fixed #1693 (false negative: std::vector, negative index) 2017-08-22 11:04:02 +02:00
Heiko Eißfeldt 04bcc86d59 Fixed #439 (Patch: Cppcheck reports wrong filename for filenames containing 8-bit ASCII) 2017-08-21 12:52:15 +02:00
Daniel Marjamäki 3abb62a6d1 Fixed #8036 (valueFlowUninit: strcpy(buf, e = str), free(e);) 2017-08-20 19:47:26 +02:00
Daniel Marjamäki 94c5c3703c astyle formatting
[ci skip]
2017-08-16 18:56:02 +02:00
Daniel Marjamäki 92e9744020 Fixed #8148 (Tokenizer: Braces are not added properly in do while) 2017-08-16 18:55:34 +02:00
Martin Güthle 1d491bd332 Treat noexcept correctly
Converts the noexcept to the already correctly handled noexcept(true)
2017-08-16 11:31:19 +02:00
Daniel Marjamäki 5c733c8f22 Fixed #8152 (Garbage code cause crash '0|\0|0>;') 2017-08-15 23:19:42 +02:00
Hinterwaeldlers 705e5e3468 Fix for http://trac.cppcheck.net/ticket/8151 (#942)
* Taking care of incorrect template syntax (missing close)

Forward the incorrectness via throw, as there is no direct access to the
syntaxError method, without converting the function to a member function
2017-08-15 22:40:55 +02:00
Dmitry-Me 6303437163 Resolve C4800 2017-08-15 17:42:56 +03:00
orbitcowboy 61e47208eb Removed hard coded avr8 platform and moved it into a platform file (avr8.xml). 2017-08-09 11:58:27 +02:00
amai2012 39955973e9 Merge pull request #931 from IOBYTE/master
Fixed #8142 (false positive: The class 'B' has 'copy constructor' but lack of 'operator='
2017-08-02 21:16:29 +02:00
Daniel Marjamäki e6f6efc684 astyle formatting
[ci skip]
2017-08-02 07:48:38 +02:00
Robert Reif f5044bb65f Fixed #8142 (false positive: The class 'B' has 'copy constructor' but lack of 'operator='.)
Do not count static member variables when trying to figure out if
'operator =' is needed.
2017-08-01 19:52:41 -04:00
Daniel Marjamäki 9ef9d0e4a8 Fixed #8128 (False negative: variable is assigned value that is not read) 2017-08-01 14:56:53 +02:00
Daniel Marjamäki 91eb0f1fad Removed XML version 1 2017-07-29 18:56:22 +02:00
Simon Martin aa35462add Ticket #8091: Don't replace std types within enum definitions. (#922) 2017-07-29 11:56:09 +02:00
Daniel Marjamäki 515e84ed00 Renamed PathMatch::Match to PathMatch::match 2017-07-28 11:27:04 +02:00
Daniel Marjamäki eb288ec2a1 CheckStl: Use AST to handle iterator comparisons better 2017-07-26 23:13:01 +02:00
Andreas Pokorny b802b98136 Do not warn when unique pointers are passed by value
A unique pointer should only be passed by value or by const reference.
Passing by value means transferring ownership it makes no sense to have a pass by value Warning for unique_ptr

Signed-off-by: Andreas Pokorny <andreas.pokorny@siemens.com>
2017-07-25 11:17:56 +02:00
Daniel Marjamäki 0a03bbb320 Fixed #6315 (false positive - unreadVariable - variable is used via pointer) 2017-07-23 23:32:14 +02:00
Daniel Marjamäki e58344c2c9 Fixed compiler warning 2017-07-22 16:23:33 +02:00
Daniel Marjamäki bf5040e3d6 Fixed #7701 (ValueFlow: handle 64-bit unsigned values ) 2017-07-22 12:19:46 +02:00
Daniel Marjamäki 12b7843937 astyle formatting
[ci skip]
2017-07-21 09:17:25 +02:00
Daniel Marjamäki 255d0410a4 Fixed #8085 (Token::expressionString: unsigned long long) 2017-07-21 09:16:42 +02:00
Robert Reif 354a773bfe Fix #8020 (ValueType: no value type for iterator + constant) 2017-07-16 11:27:32 -04:00
Daniel Marjamäki fabe07ffd6 Merge pull request #924 from IOBYTE/master
Fixed #6985 (SymbolDatabase: Function pointer not set when calling bas…
2017-07-16 14:04:25 +02:00
Robert Reif b0aec042a6 Fixed #6985(SymbolDatabase: Function pointer not set when calling base class function)
Use using namespace when looking up types.
2017-07-15 19:14:15 -04:00
Daniel Marjamäki 814d2ae2a4 Fixed #7028 (False positive: opposite conditions (const method modifies variable)) 2017-07-10 23:12:45 +02:00
Daniel Marjamäki f85e43d21f Fixed #8059 (Tokenizer::simplifyWhile0: for loop that modifies local variable) 2017-07-09 22:44:10 +02:00
Daniel Marjamäki dff9d13758 Fixed #8115 (Tokenizer: links not properly set in r-value template 'Foo<int> && foo') 2017-07-09 13:26:59 +02:00
Daniel Marjamäki 32fe0aba41 Fixed #8037 (ValueFlow: global variable might be modified by function call) 2017-07-09 12:50:17 +02:00
Daniel Marjamäki ac85b78e2a Fixed #5619 (false positive: unusedVariable - array accessed by pointer variable only) 2017-07-09 11:19:00 +02:00
Daniel Marjamäki 7161daefbd Fixed #8040 (False positive resourceLeak - handle assigned to class instead of scalar) 2017-07-08 22:28:31 +02:00
Daniel Marjamäki 6417be4a71 Fixed #8054 (Tokenizer::simplifyKnownVariables(): Wrong simplification for global variables) 2017-07-08 22:12:01 +02:00
Daniel Marjamäki 6b48781fdc Fixed #7105 (False positive resourceLeak - socket handle wiped after close) 2017-07-07 21:51:48 +02:00
Daniel Marjamäki d6f066482e Fixed #6542 (FP: Variable 'lcount' is not assigned a value - using address of integer array) 2017-07-01 11:31:51 +02:00
Daniel Marjamäki db01ea1408 Fixed #6261 (false positive: Variable used in ternary expression within function argument list) 2017-07-01 11:03:49 +02:00
Daniel Marjamäki f847631cdb Fixed #5273 (FP memleak: Unknown if() condition should make error inconclusive) 2017-06-30 23:05:09 +02:00
Daniel Marjamäki b97f5d909e Fixed #6570 (False positive unusedFunction - function called from within template function) 2017-06-30 14:34:28 +02:00
Daniel Marjamäki 22919da9a8 Fixed #6246 (Defect: False positive due to ignoring struct initialisation when nested in a loop and assigned to a member) 2017-06-30 13:41:19 +02:00
Daniel Marjamäki f4dba4ad3d testrunner: Remove TestPath::simplify_path as these tests has been moved to simplecpp 2017-06-23 20:32:00 +02:00
Daniel Marjamäki 1e12ec241c reuse simplecpp::simplifyPath 2017-06-21 14:27:46 +02:00
Daniel Marjamäki 453058c059 AST: Better handling of C++11 initializer lists 2017-06-09 22:35:46 +02:00
Alexander Mai d3e79b71b5 #8051 Add regression test. Issue got fixed before. 2017-06-08 19:22:01 +02:00
Daniel Marjamäki fd74d455ce AST: Better handling of case 2017-06-08 15:32:35 +02:00
Daniel Marjamäki c1ea873e1c TemplateSimplifier::simplifyCalculations: Add some more tests and make sure they pass 2017-06-08 08:15:05 +02:00
Daniel Marjamäki cb48e63f92 TemplateSimplifier: Fixed bug in simplifyCalculations. Now template58 test case does not throw InternalError 2017-06-08 00:49:46 +02:00
Daniel Marjamäki 18abe4a142 Fixed #6021 (TemplateSimplifier::simplifyCalculations causes heap corruption on invalid code) 2017-06-07 19:32:56 +02:00
Daniel Marjamäki 0967700f4b Refactoring tests 2017-06-06 08:59:18 +02:00
Stas Cymbalov ff38cc5c13 Set struct size cutoff in passedByValue check to 2*sizeof_pointer
Struct arguments are either pushed to the stack or passed in the
registers. Since both methods operate on machine words it is logical to
tie the maximum size of a struct argument that doesn't trigger
passedByValue diagnostic to the size of the machine word.

Also guessed size of STL classes is set to 3*sizeof_pointer, this better
represents reality and ensures that structs containing them will still
trigger passedByValue.
2017-06-06 08:48:11 +02:00
Ayaz Salikhov 3dc4188292 Improve Python code 2017-06-05 13:23:00 +02:00
Ayaz Salikhov 2dd6168258 Improve Python code 2017-06-04 22:51:48 +02:00
Daniel Marjamäki 26bd863d0a Fixed #7724 (hang: long expression => wrong AST) 2017-06-04 12:16:49 +02:00
Daniel Marjamäki b8ee500d45 Fixed #7092 (Invalid style error: Variable not assigned a value) 2017-06-03 15:31:29 +02:00
Daniel Marjamäki bbde3cc23a Merge pull request #910 from mathbunnyru/asalikhov/improve_readability
improve readability
2017-06-03 14:33:21 +02:00
Daniel Marjamäki b68c8d91ab Fixed #8039 (Tokenizer: wrong simplification of string) 2017-06-01 22:21:02 +02:00
Daniel Marjamäki bce0776417 Fixed #7795 (ValueFlow: Value is not known after conditional increment ) 2017-06-01 15:16:07 +02:00
Ayaz Salikhov 3cd2f2d092 Don't cast bool to bool 2017-06-01 01:49:40 +03:00
Ville Skyttä 5ab158fec2 Spelling fixes 2017-05-30 08:03:15 +03:00
Steve Browne b58562fc7d Added test cases for catching when assignment comes after an operator, compound assignment, or comparison for ticket #7429 and fixed the tests. 2017-05-28 16:00:06 +02:00
Daniel Marjamäki 18adb97873 astyle formatting
[ci skip]
2017-05-28 15:56:26 +02:00
Daniel Marjamäki be6e0cbf85 Tokenizer: I dont think its safe to calculate floating point equality comparisons, changing TODO assertion to normal assertion. 2017-05-28 12:34:29 +02:00
Frank Zingsheim aa937e426d Fixed #7849 (Tokenizer: Wrong simplification of floating point equality comparison) 2017-05-28 10:53:50 +02:00
Ayaz Salikhov 28aa939d69 iwyu - include what you use 2017-05-27 04:33:47 +02:00
uburuntu 3817384223 FIX: test: parameter 'settings' is always rewritten 2017-05-27 04:17:18 +02:00
amai 45ba1ff1e3 #8079 SymbolDatabase::createSymbolDatabaseEnums() crashes on invalid enum declaration 2017-05-25 09:50:14 +02:00
Daniel Marjamäki dda5556ded Fixed #8034 (AST: better handling for c++ type initialization) 2017-05-24 20:24:56 +02:00
Daniel Marjamäki 5444875f89 Fixed #8034 (AST: better handling for c++ type initialization) 2017-05-24 20:18:31 +02:00
Daniel Marjamäki 099b4435c3 Fixed #8074 (Preprocessor::getConfigs: wrong configuration extracted 'A;B;;') 2017-05-24 11:16:41 +02:00
Daniel Marjamäki 93e0516291 Fixed #8009 (Tokenizer: fix handling of template rvalue references) 2017-05-23 18:55:17 +02:00
orbitcowboy ffe6582e6b Added platform support for Atmel AVR 8 bit microcontrollers. 2017-05-22 14:46:19 +02:00
Daniel Marjamäki 8ef9ab26b1 Clarify floatConversionOverflow 2017-05-22 11:04:24 +02:00
Daniel Marjamäki 0cb1c4f221 Clarify integerOverflow messages 2017-05-22 10:10:56 +02:00
Daniel Marjamäki 82a372a380 Try to clarify ErrorPath texts 2017-05-20 08:47:35 +02:00
Daniel Marjamäki f92b16706c ValueFlow: Add ErrorPath info after for loop 2017-05-19 16:32:58 +02:00
Daniel Marjamäki 2bb54fef69 ValueFlow: Test ErrorPath handling 2017-05-19 14:34:59 +02:00
Daniel Marjamäki 899615c1e4 update simplecpp includes
[ci skip]
2017-05-18 22:26:07 +02:00
Matthias Krüger aa3f1db33c Add internal check that checks for redundant non-nullness checks in Token::(simple)Match checks.
In code like
if (tok && Token::simpleMatch(tok, "bla")) {}
or
if (tok->previous() && Token::Match(tok->previous(), "foo")) {},
the first check is redundant because Token::(simple)Match already checks if the argument token is null.
2017-05-18 22:12:33 +02:00
Daniel Marjamäki 040d2f0012 Use simplecpp lexer in test cases 2017-05-18 21:52:31 +02:00
Daniel Marjamäki d89baee1f6 teststring: remove invalid newlines from string literals 2017-05-18 21:50:45 +02:00
Daniel Marjamäki 469390504b Remove wrong newlines in TestGarbage 2017-05-18 17:26:00 +02:00
Daniel Marjamäki 2980654671 Remove wrong newlines in TestIO 2017-05-18 17:23:26 +02:00
Daniel Marjamäki 1f4b84379d Fix for #pragma asm 2017-05-17 21:58:46 +02:00
Daniel Marjamäki 67e3187653 Preprocessor: Refactor handling of #pragma asm 2017-05-17 10:25:37 +02:00
Daniel Marjamäki 8d75d1b920 Partial fix for #8028 (ValueFlow: Origin/callstack of value) 2017-05-15 20:05:11 +02:00
PKEuS fb94ad21fa Updated Visual Studio solution to VS2017. 2017-05-14 10:04:25 +02:00
Daniel Marjamäki 55cd69e290 alwaysTrueFalse: Dont warn when checking sizeof for some type. such condition might be platform dependent. 2017-05-13 19:07:24 +02:00
PKEuS 68d77b73da SymbolDatabase: Fixed parsing of unnamed arguments, properly detect pointers (#8052) 2017-05-07 09:03:58 +02:00
PKEuS 28b8bc57a8 CheckVaarg::va_list_usage(): Bailout on "goto" (#8043) 2017-05-07 08:32:48 +02:00
PKEuS b345c430fe CheckStl::readingEmptyStlContainer(): Skip over lambdas (#8055) 2017-05-07 08:15:58 +02:00
Alexander Mai c1cdcc158f Run astyle. Fix some Doxygen issues 2017-05-06 11:57:02 +02:00
amai2012 3e11eb9dca #8050 cppcheckError: 0xFFFFFFul -> 16777215ULU. Don't add a suffix 'U' if there is already a suffix present. 2017-05-05 14:47:58 +02:00
Daniel Marjamäki a8a54bbfa8 Fixed #6028 (Improvement: False positive caused by C keywords in assembly comments) 2017-05-05 08:57:24 +02:00
Daniel Marjamäki 65297ce285 Fixed #7191 (false positive memleak on in-place new) 2017-05-04 19:39:57 +02:00
Alexander Mai f54a6f085b #7883 hang: CheckOther::checkFuncArgNamesDifferent() template code in .h. Activate language check for header files + Small refactoring 2017-05-03 20:36:26 +02:00
Alexander Mai 6db9c78fb6 Address some warnings on test code 2017-05-03 14:39:21 +02:00
U-SAMS\Alexander a8e12a6f29 Fix&cheat to make config test pass on cygwin 2017-05-03 11:41:37 +02:00
Robert Reif e2bfe1c0ec Fixed #8044: Crash below SymbolDatabase::setValueType 2017-05-01 14:12:50 -04:00
Matthias Krüger cee0f724ff Fixed #8018: Tokenize::findGarbageCode: detect heads of for-loops with 1 or more than 2 semicolons as garbage code. 2017-05-01 18:28:26 +02:00
Daniel Marjamäki 8a08cc0796 Fixed #8029 (Tokenizer::simplifyCAlternativeTokens: dont simplify 'eb.and + 1') 2017-04-30 14:40:41 +02:00
Daniel Marjamäki 48f1d02355 astyle formatting
[ci skip]
2017-04-30 14:22:40 +02:00
Daniel Marjamäki 7fd04cd8d0 Updated Token::expressionString(), write '->' instead of '.' 2017-04-30 14:22:18 +02:00
Simon Martin 28960a8bba Remove bailout and fix varid for template class member initialized in out-of-line constructor (#8031) 2017-04-30 08:59:47 +02:00
IOBYTE 8a668aa860 Add missing else that could cause an extra try scope to be added to the scope list (#8025)
Add an optional extended description…
2017-04-30 08:58:41 +02:00
Alexander Mai 14be611a7e Correct configuration to allow NULL as 2nd argument to read/write. Whether it's a legal value depends on the 3rd argument 2017-04-29 17:57:16 +02:00
Daniel Marjamäki 980ca39fe2 valueFlowForward: better handling of sizeof() in rhs in assignments 2017-04-29 08:25:55 +02:00
Daniel Marjamäki 06102cb3d7 UninitVar: Don't warn for inconclusive values 2017-04-28 21:09:56 +02:00
Daniel Marjamäki d9f72d5f8c AST: Handle 'x = { [ID] = 1, .. }' when ID is unexpanded macro 2017-04-26 22:35:04 +02:00
Daniel Marjamäki bdf16b1157 Tokenizer::simplifyComma: dont simplify comma in '=(struct s){...}' 2017-04-26 20:48:08 +02:00
Daniel Marjamäki 4175902e36 astyle formatting
[ci skip]
2017-04-26 18:42:34 +02:00
orbitcowboy 0b6c726439 posix.cfg: Do not allow the second parameter of read and write to be a NULL pointer. 2017-04-26 14:25:14 +02:00
Daniel Marjamäki 89532cf8b9 Fixed #7968 (valueFlowBeforeCondition: better handling of compound assignments) 2017-04-25 20:45:02 +02:00
Daniel Marjamäki 140e086206 Fixed #7738 (False positive deallocret - delete and return NULL pointer) 2017-04-24 22:05:16 +02:00
Daniel Marjamäki 37fd60e879 Fixed #7293 (Use of uninitialized pointer not detected (worked in 1.71)) 2017-04-24 18:27:16 +02:00
Daniel Marjamäki 8a738eefab fixed #7998 (uninitialized variable is not found when used with switch/case) 2017-04-23 18:05:14 +02:00
Daniel Marjamäki 101dc28afa Refactoring: Moved checkMemset.. from CheckOther to CheckFunctions 2017-04-23 07:53:41 +02:00
Daniel Marjamäki e72ec4282d Fixed #7842 (Preprocessor::getConfigs: #error in #ifndef not handled well) 2017-04-22 12:44:57 +02:00
Daniel Marjamäki 1039c710e4 Fixed #8017 (AST: wrong ast for extra comma 's={1,}') 2017-04-22 11:23:11 +02:00
Daniel Marjamäki 7140bae226 Merge pull request #894 from simartin/ticket_7964
Ticket #7964: Don't crash on valid code using function pointers named strcpy or strcat in main()
2017-04-22 01:24:03 +02:00
Simon Martin b526fd7c49 Ticket #7964: Don't crash on valid code using function pointers named strcpy or strcat in main(). 2017-04-21 23:36:10 +02:00