Commit Graph

7836 Commits

Author SHA1 Message Date
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
Daniel Marjamäki 43454936e7 Fixed #8014 (FP: Uninitialized variable 'f(1,{..});') 2017-04-21 22:33:27 +02:00
Robert Reif 78ad9825af Add support for auto variables in regular for loop. 2017-04-21 15:25:02 -04:00
Daniel Marjamäki e827119856 Fix testrunner InternalError 2017-04-21 21:02:46 +02:00
Daniel Marjamäki 902eb87a8a Fixed #8016 (AST: wrong ast for 'x=(s){...};') 2017-04-21 17:44:11 +02:00
Daniel Marjamäki eec8c77774 Merge pull request #892 from IOBYTE/master
Add support for auto variable initialized from function return type.
2017-04-20 22:17:23 +02:00
Daniel Marjamäki f8e9071de1 CheckFunction: In the <valid> check handle possible/conditional/inconclusive values better 2017-04-20 22:14:54 +02:00
Robert Reif 0ff8e49b69 Add support for auto variable initialized from function return type. 2017-04-20 15:22:57 -04:00
Daniel Marjamäki 95dd16892b Merge pull request #891 from IOBYTE/master
Fix #7963: crash; Variable::setFlag ; gecko-dev , dom/canvas/WebGLTra…
2017-04-20 20:51:40 +02:00
Daniel Marjamäki 1422487769 astyle formatting
[ci skip]
2017-04-20 17:43:28 +02:00
Robert Reif 69d18d9c29 Fix #7963: crash; Variable::setFlag ; gecko-dev , dom/canvas/WebGLTransformFeedback.cpp 2017-04-20 10:03:29 -04:00
Daniel Marjamäki 7a26e046a8 Fixed #8001 (AST: Wrong AST for lambda function with 'std::string const&' result type) 2017-04-18 21:21:30 +02:00
Daniel Marjamäki efcf71a5dc qt.cfg: attempt to fix cfg test 2017-04-18 19:26:54 +02:00
Daniel Marjamäki 296f250caa qt.cfg: configure some QString methods 2017-04-18 19:21:34 +02:00
Daniel Marjamäki 01c5c2fc5b qt.cfg: Add reademptycontainer test 2017-04-18 18:47:35 +02:00
Daniel Marjamäki c229754a70 qt.cfg: Add configuration for QString 2017-04-18 18:04:27 +02:00
Daniel Marjamäki 1a95dc9bd6 Fixed #7979 (Tokenizer: Detect and reject c++ code in .c file) 2017-04-17 22:15:29 +02:00
Daniel Marjamäki bb015c6a2b Fixed #8006 (AST: Wrong tree with complex for loops and casts) 2017-04-17 21:11:53 +02:00
Simon Martin 5fd686c878 Ticket #4544: Also handle Foo<struct Bar> constructs. 2017-04-17 11:24:28 +02:00
PKEuS b97779591e Fixed unit test in testbufferoverrun.cpp 2017-04-11 23:00:33 +02:00
Daniel Marjamäki 41a64f6d1f Fix crash 2017-04-11 20:16:33 +02:00
PKEuS b1f4bd7504 Refactorization: Reimplemented Settings::_enabled as a bitfeld instead of std::set (#7995) 2017-04-11 11:49:26 +02:00
Daniel Marjamäki 632a6b664c AST: Harden handling of C++11 2017-04-10 23:29:15 +02:00
Daniel Marjamäki 2c43075ece AST: weird clang syntax 2017-04-10 23:05:41 +02:00
Daniel Marjamäki df90ff9f5e Merge pull request #888 from simartin/ticket_7942
Don't generate invalid syntax for out of line template class constructors during instantiation
2017-04-10 22:18:20 +02:00
Daniel Marjamäki 5e1b6aee8c AST: Fix hang for weird VLA code 2017-04-10 22:17:34 +02:00
Daniel Marjamäki ffeadbdde4 AST: improved handling for struct initialization 's = { [0] = 123 }' 2017-04-10 07:25:18 +02:00
Daniel Marjamäki d92c529aa6 AST: Fix wrong handling of struct initialization, caused hang 2017-04-09 22:06:13 +02:00
Daniel Marjamäki e6005dfa3c AST: Fix AST for lambda '[&]{..}' 2017-04-09 17:49:55 +02:00
Matthias Krüger 494f64cb88 tests: fix some self-check findings about functions that can be static.
Was:
[test/testtype.cpp:223]: (performance, inconclusive) Technically the member function 'TestType::removeFloat' can be static.
[test/testsymboldatabase.cpp:61]: (performance, inconclusive) Technically the member function 'TestSymbolDatabase::getSymbolDB_inner' can be static.
[test/teststl.cpp:1437]: (performance, inconclusive) Technically the member function 'TestStl::getArraylength' can be static.
2017-04-09 17:28:00 +02:00
Simon Martin ee05fe7d77 Ticket #7942: Don't generate invalid syntax for out of line template class constructors during instantiation. 2017-04-09 16:12:59 +02:00
Daniel Marjamäki 8ffed6862d Tokenizer: Add --check-config warning for macro with semicolon in argument 2017-04-07 19:19:10 +02:00
Daniel Marjamäki 7d8af7bdca Fixed #7979 (crash (nr 2): CheckFunctions::checkIgnoredReturnValue()) 2017-04-07 13:18:53 +02:00
Daniel Marjamäki 392a06a44b AST: better handling of '(struct X){...}' 2017-04-06 21:28:13 +02:00
Daniel Marjamäki 50da7d4919 Tokenizer: Write syntax error if there is C++ code in C file. 2017-04-06 08:50:35 +02:00
Daniel Marjamäki fd2651909c Fixed #7978 (ValueType: container type not set properly) 2017-04-06 07:07:20 +02:00
Daniel Marjamäki fee86b9684 ValueType: Better handling of 'new Container' 2017-04-05 22:05:29 +02:00
Daniel Marjamäki e6ed08c4d8 Fixed #7976 (Internal error. Token::astOperand1() cyclic dependency. (ticket nr 2, new regression)) 2017-04-05 11:00:02 +02:00
Daniel Marjamäki 9c5a136f04 Fixed #7975 (crash: Tokenizer::createLinks2 problem with enable_if<x&&y,C*>) 2017-04-03 21:48:22 +02:00
Daniel Marjamäki abb43b6a81 Fixed #7934 (Wrong AST for 'for (i=0;cond;({min(x,10);}))') 2017-04-02 19:44:33 +02:00
Daniel Marjamäki 92fe210217 tweaked TestSymbolDatabase test case for unknown type. 2017-04-02 15:38:06 +02:00
Daniel Marjamäki d403a6a883 Preprocessor::getConfigs: Remove bad configurations when #error is seen 2017-04-02 12:15:53 +02:00
Daniel Marjamäki 7eb95aac2a Preprocessor::getConfigs: Handle #error in '#if !A' better 2017-04-02 10:06:39 +02:00
Daniel Marjamäki edd1c32e5b Preprocessor::getConfigs: Better handling of ! in #if 2017-04-02 09:03:43 +02:00
Daniel Marjamäki b7dcdc00d0 Fixed #7970 (ValueType: no types set below 'new std::string') 2017-04-01 22:22:37 +02:00
PKEuS ea215c3b7b Fixed false positives in CheckClass::checkConst() due to unmatched function overloads
Fixed function matching if constness mismatches
2017-04-01 10:19:32 +02:00
Daniel Marjamäki 164df2aa7b Fixed #7966 (ValueType: wrong type for gcc initialization {[1]=..}) 2017-03-31 09:41:38 +02:00
Daniel Marjamäki 8fe7ee1012 Fixed #7886 (ValueFlow: endless forloop 'for (i = 0, j = 0; i < sz && j < 9; i++)') 2017-03-30 22:02:36 +02:00
Daniel Marjamäki 2da3123db2 Fix ValueType. The '[' in variable declaration is not a dereference. 2017-03-30 11:01:29 +02:00
IOBYTE 7cae057615 Add missing varid or variable for member variables.
Add an optional extended description…
2017-03-30 10:07:58 +02:00
PKEuS 3c8f5b85ae Refactorization: Allocate Token::_values (ValueFlow information) dynamically, reducing size of each token by around 10% 2017-03-27 18:48:34 +02:00
PKEuS 2938278f00 Refactorization: Store minsizes in vector instead of list which has less overhead 2017-03-27 17:53:43 +02:00
PKEuS 680828788b Fixed false negative in CheckBufferOverrun::checkInsecureCmdLineArgs(), removed redundant tests 2017-03-27 11:30:07 +02:00
PKEuS 171e1b8244 Fixed false negatives in CheckBufferOverrun::arrayIndexThenCheck() 2017-03-27 11:07:49 +02:00
Robert Reif 3dba1b1739 Tests for git pull request #882. 2017-03-25 15:46:25 -04:00
Robert Reif c96e8daebc Don't change varid of member variables. 2017-03-25 10:59:35 -04:00
PKEuS f4c0ab5dd5 SymbolDatabase: Match function overloads by using ValueType information by running a second pass of the function pointer assignment routine. 2017-03-24 12:19:29 +01:00
Alexander Alekseev abba762d42 New check: checking for copy ctor and eq operator co-existence 2017-03-24 12:00:20 +01:00
Robert Reif bc87e874e9 Add variable and type information for auto and auto variables in range based for loops of containers. 2017-03-23 20:14:49 -04:00
Robert Reif 7adfb6e0e4 Add variable and type information to tokens for C array range based for loops. 2017-03-23 19:48:20 -04:00
Robert Reif f8dd6ee014 Fix test code so it compiles. 2017-03-23 19:16:15 -04:00
PKEuS 97fa9e9d1b ValueFlow: Stop on inline assembly 2017-03-23 20:01:16 +01:00
PKEuS 9225bff31d Added (back) support for enums to CheckCondition::checkIncorrectLogicOperator() (#7794) 2017-03-23 18:57:48 +01:00
PKEuS 996501a449 Fixed false positive #7953: Support type conversion operators returning pointers 2017-03-23 18:12:46 +01:00
Daniel Marjamäki c280bcedb4 Merge pull request #880 from IOBYTE/master
Update symbol database with new auto type and variable information for assignment to auto.
2017-03-23 08:51:06 +01:00
Robert Reif 662bc6f846 Add variable or type information to auto and auto variable tokens. Changing the auto variable type requires rerunning the variable pointer pass to correct the symbol database for the new type. 2017-03-22 22:09:40 -04:00