Commit Graph

8951 Commits

Author SHA1 Message Date
Daniel Marjamäki f7514fcd2c Fix issue detected by Coverity, dereference tok3 and then check if its null. 2017-08-02 08:38:36 +02:00
Daniel Marjamäki e977cea04c Fix issue detected by Coverity, either null pointer check is useless or there is null pointer dereference 2017-08-02 08:24:16 +02:00
Daniel Marjamäki 32422c815b Fix issue found by Coverity, scope cant be null since scope is dereferenced on all paths before the while and also unconditionally inside while 2017-08-02 08:17:29 +02:00
Daniel Marjamäki 462ae455c8 Fix issue detected by Coverity, missing check if _settings is null 2017-08-02 08:04:35 +02:00
Daniel Marjamäki 60f819dbe7 Refactoring, use continue in loop 2017-08-02 08:00:52 +02:00
Daniel Marjamäki 5abf39503a Fix issue detected by Coverity, in case solution does not specify platform configuration the platform will be uninitialized 2017-08-02 07:59:25 +02:00
Daniel Marjamäki 05cdda3f4c Fix issue detected by Coverity, XMLElement::Attribute might return null 2017-08-02 07:56:22 +02:00
Daniel Marjamäki 55aec0ef1b Fix issue detected by Coverity, vt2 is null checked and then dereferenced 2017-08-02 07:48:11 +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
Matthias Krüger 9b6d371762 checkbufferoverrun: remove dead store
the variable was declared inside a loop and the dead store also took place inside the loop (guarded by a condition) without further access of the value after that store.
Found by clang analyzer.

Was:

lib/checkbufferoverrun.cpp:1223:17: warning: Value stored to 'tok' is never read
                tok = tok->next();
                ^     ~~~~~~~~~~~
2017-08-01 16:53:00 +02: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 1758c3b4e7 Fix suspicious code found by Coverity, dont check if scope->function is null and then dereference it 2017-08-01 13:26:35 +02:00
Daniel Marjamäki 058c439b2a Coverity detected useless function call, cleanup code 2017-08-01 12:45:37 +02:00
Daniel Marjamäki 0c8a899f59 Fix issue detected by Coverity, there was dead code because the wrong variable was used in condition 2017-08-01 11:45:51 +02:00
Daniel Marjamäki be998773ee Minor refactoring, fixes FP from Coverity 2017-08-01 11:33:24 +02:00
Daniel Marjamäki 6cc7f46696 Fix issue detected by Coverity, ternary condition is always true 2017-08-01 11:25:28 +02:00
Daniel Marjamäki 267a2e154d Fixed #8127 (cppcheck 1.80 compilation by MINGW32 gcc 6.3 failed) 2017-07-31 18:30:20 +02:00
Daniel Marjamäki cdeae918a8 Fix issue detected by Coverity (ternary operator false expression is unreachable) 2017-07-31 17:58:07 +02:00
Daniel Marjamäki a024f339dd Fix issue detected by Coverity (ternary operator false expression is unreachable) 2017-07-31 17:55:15 +02:00
Daniel Marjamäki fec0c46af0 Refactoring, use continue in loop 2017-07-30 14:53:58 +02:00
Daniel Marjamäki 29265cdd49 Refactoring, use continue 2017-07-30 12:46:04 +02:00
PKEuS 9558877458 Set version to 1.80.99/1.81 dev 2017-07-30 08:48:47 +02:00
Daniel Marjamäki f76ff9e7bf Tokenizer: Put struct in anonymous namespace 2017-07-29 19:46:18 +02:00
Daniel Marjamäki 91eb0f1fad Removed XML version 1 2017-07-29 18:56:22 +02:00
Daniel Marjamäki baedfa6718 1.80: Set versions 2017-07-29 12:55:53 +02:00
Daniel Marjamäki a78fd23732 Refactoring, skipEnumBody 2017-07-29 12:13:32 +02:00
Daniel Marjamäki abf525e46d Fix Cppcheck warning 2017-07-29 11:58:00 +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 01f023dc0a CheckClass: Refactor hasAssignSelf to use AST 2017-07-28 23:49:11 +02:00
orbitcowboy 0e575ce12c Modernize: make use of 'nullptr' and added a rule-file for finding non-nullptr (zero) initializations. 2017-07-28 15:20:43 +02:00
Daniel Marjamäki c4bd70210c GUI: Rename methods in FileList and PathMatch 2017-07-28 10:55:51 +02:00
Daniel Marjamäki a4dd8f0aa4 modernize, use nullptr 2017-07-27 18:36:33 +02:00
Daniel Marjamäki 5ae962194d revert mode change for lib/checkstl.cpp 2017-07-26 23:51:30 +02:00
Daniel Marjamäki 27af3edc5b CheckStl: Safer use of AST 2017-07-26 23:43:39 +02:00
Daniel Marjamäki eb288ec2a1 CheckStl: Use AST to handle iterator comparisons better 2017-07-26 23:13:01 +02:00
Daniel Marjamäki a3916c501c Refactor loop, use continue 2017-07-26 22:03:55 +02:00
Daniel Marjamäki da26ef0650 Refactoring: Use continue in loop 2017-07-26 21:13:49 +02:00
Daniel Marjamäki 32940c023a Refactoring: Use continue in loop 2017-07-26 20:32:14 +02:00
Daniel Marjamäki 2d4f64027a Refactoring: Use continue in loop 2017-07-26 20:29:13 +02:00
Daniel Marjamäki 2f38d3d80e CheckStl: Use ValueType 2017-07-26 20:19:36 +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 b41350e8d8 Token::expressionString(): Fixed output of library types 2017-07-22 16:42:42 +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
Daniel Marjamäki 76a50e60b9 Merge pull request #926 from mathbunnyru/asalikhov/fix_warnings_macro
Fix warnings
2017-07-17 22:46:40 +02:00
Ayaz Salikhov 4bbc830a85 Fix warnings 2017-07-17 10:13:11 +03: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
rsBNT fb7230ce05 importSln: Handle absolute paths for vcxproj 2017-07-10 11:12:48 +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 ea598d5284 refactoring, use early return 2017-07-09 13:09:36 +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 0a91ced941 refactoring, use continue in loop instead of nesting 2017-07-09 12:36:33 +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 6c2002a150 minor constness fix 2017-07-08 21:41:57 +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 211d8c6020 Refactoring checking for unused variables (avoid FN when not taking address) 2017-07-01 22:45:51 +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 4827751b04 improve constness 2017-07-01 09:10:23 +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 3ab8466415 refactoring, use early continue in for loop 2017-06-30 12:45:48 +02:00
x29a 15b0eb42bd import solution: Support system environment variables 2017-06-27 12:41:25 +02:00
Daniel Marjamäki dc37034687 Merge pull request #917 from x29a/unique_includes
Unique includes
2017-06-23 20:21:38 +02:00
neheb ef86ac04b4 Add OpenCL support
OpenCL is basically C99.
2017-06-22 17:34:07 -07:00
x29a b3a747d606 fix brainfart 2017-06-22 16:53:13 +02:00
x29a cde17935ea only use each include path once 2017-06-22 16:49:36 +02:00
Daniel Marjamäki 1e12ec241c reuse simplecpp::simplifyPath 2017-06-21 14:27:46 +02:00
Daniel Marjamäki f86d8244fa Fixed #8022 (DacaWrongData: checkIgnoredReturnValue, hana) 2017-06-10 08:23:26 +02:00
Daniel Marjamäki 453058c059 AST: Better handling of C++11 initializer lists 2017-06-09 22:35:46 +02:00
Daniel Marjamäki fd74d455ce AST: Better handling of case 2017-06-08 15:32:35 +02:00
Daniel Marjamäki da87fdbb90 Refactoring TemplateSimplifier::simplifyCalculations, Token::Match patterns 2017-06-08 08:18:40 +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 d2e7df2c04 TemplateSimplifier: Broke out code into separate function 2017-06-08 00:16:43 +02:00
Daniel Marjamäki 2740736136 Avoid 'deleteThis' in TemplateSimplifier::simplifyCalculations as it can cause 'use after free' see #6021 2017-06-07 20:09:06 +02:00
Daniel Marjamäki d335412858 Avoid 'deleteThis' in TemplateSimplifier::simplifyCalculations as it can cause 'use after free' see #6021 2017-06-07 19:46:02 +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 60e36492e2 Refactoring, renamed local variable 2017-06-07 12:37:44 +02:00
Alexander Mai ce13b75967 Add missing types to Platform::platformString(). Add another pattern to Tokenizer::findGarbageCode() to avoid potential crash in Valueflow 2017-06-06 22:15:11 +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
Daniel Marjamäki 3b805e7001 fix testrunner (WRONG_DATA usage) 2017-06-05 18:49:20 +02:00
Daniel Marjamäki 150d2aa902 Refactor and rename CHECK_WRONG_DATA 2017-06-05 18:41:15 +02:00
Daniel Marjamäki 62c22a8e06 daca2: change output for DacaWrongData. Show location. And use severity 'debug' 2017-06-04 19:46:20 +02:00
Daniel Marjamäki 66a488586e Temporarily readd the UNSTABLE configuration 2017-06-04 18:30:49 +02:00
Daniel Marjamäki 20b27cfd51 avoid some WrongData warnings 2017-06-04 18:27:42 +02:00
Daniel Marjamäki 0c6a551039 Try to limit Daca2WrongData output a little 2017-06-04 16:41:30 +02:00
Daniel Marjamäki 9715164d0a Fixed DACA2 CHECK_WRONG_DATA macro 2017-06-04 15:50:27 +02:00
Daniel Marjamäki 35348fcf98 Try to fix Travis 2017-06-04 14:46:57 +02:00
Daniel Marjamäki 1439b08fbd Fixed -DDACA2 compiler errors 2017-06-04 14:14:42 +02:00
Daniel Marjamäki 2106099029 daca2: print error message (DacaWrongData) instead of crashing when wrong data is seen 2017-06-04 14:05:34 +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 ccb2f2ce6a astyle formatting
[ci skip]
2017-06-03 15:30:36 +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 aeef7117fe astyle formatting
[ci skip]
2017-06-03 11:34:30 +02:00
Daniel Marjamäki 7ec3715c57 check.h: Cppcheck will be stable by default. Use -DUNSTABLE to make it unstable. 2017-06-03 11:18:00 +02:00
uburuntu f4ce49d883 ENH: perfomance: using clear() and empty() more faster for stl containers 2017-06-02 22:38:00 +04:00
Ayaz Salikhov f5646183cd Move comment to the right place 2017-06-02 17:15:24 +03:00
Alexander Mai b4a58be113 #define HIDE_WRONG_DATA to get release mode build (hiding crashes on invalid AST/symboldatabase). Fix doxygen syntax. 2017-06-01 23:38:02 +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
Daniel Marjamäki 5efb2e3be0 Visual Studio: Skip unknown platforms (ARM, ARM64) 2017-06-01 13:13:23 +02:00
Ayaz Salikhov 132c0af22a Simplify some statements 2017-06-01 02:02:12 +03:00
Ayaz Salikhov 3cd2f2d092 Don't cast bool to bool 2017-06-01 01:49:40 +03:00
Ayaz Salikhov cb58cf8163 .length() > 0 == !.emepty() 2017-06-01 01:42:29 +03:00
Daniel Marjamäki 1f48b082d1 CLI: Add --output-file flag so results can be written to file directly. 2017-05-30 15:04:28 +02:00
Ville Skyttä 5ab158fec2 Spelling fixes 2017-05-30 08:03:15 +03:00
Daniel Marjamäki 1961d6d0f7 CppCheck: make sure preprocessor syntax errors are reported 2017-05-28 20:34:58 +02:00
Sam Truscott 956b5812e7 Fixed #7866 (Crash while scanning QML files) 2017-05-28 16:39:18 +02: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
Frank Zingsheim aa937e426d Fixed #7849 (Tokenizer: Wrong simplification of floating point equality comparison) 2017-05-28 10:53:50 +02:00
amai 624ceb5027 Fix includes for cygwin 2017-05-27 10:23:06 +02:00
Ayaz Salikhov 28aa939d69 iwyu - include what you use 2017-05-27 04:33:47 +02:00
uburuntu d41d091c07 ENH: perfomance: seeking of one char is more efficiently 2017-05-27 04:15:54 +02:00
amai 45ba1ff1e3 #8079 SymbolDatabase::createSymbolDatabaseEnums() crashes on invalid enum declaration 2017-05-25 09:50:14 +02:00
Daniel Marjamäki 1dd42d9a9e arrayIndexOutOfBounds: Make sure error message is clarified for daca2 --template format 2017-05-25 08:18:37 +02:00
Daniel Marjamäki 0262020707 --template: Removed 'clang' and renamed 'cppcheck2' to 'daca2' 2017-05-25 05:24:42 +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
Daniel Marjamäki 70c2de62b7 arrayIndexOutOfBounds: better note 2017-05-23 16:06:32 +02:00
Daniel Marjamäki 6e1544bd49 ValueFlow: Use getOrdinalText() 2017-05-23 15:01:56 +02:00
Daniel Marjamäki e73657b198 Clarify arrayIndexOutOfBounds 2017-05-23 14:58:43 +02:00
Daniel Marjamäki a3c0eecccf Added --template=cppcheck2 output format 2017-05-23 12:19:11 +02:00
Daniel Marjamäki 6cb563b3fe ErrorLogger: Adjust the severity in the 'clang' output format. as far as I know, clang severities are 'fatal error', 'error' and 'warning'. 2017-05-23 12:02:57 +02:00
Daniel Marjamäki d3d3d31613 Clarify 'invalidFunctionArg' messages 2017-05-23 11:57:25 +02:00
Daniel Marjamäki f7cda81c0c Refactoring: ValueFlow::Value::errorSeverity() will have the logic if value is 'error' or 'warning' 2017-05-23 11:43:56 +02:00
orbitcowboy ba2b235e24 Fixed: warning: ‘tokvalue’ may be used uninitialized in this function [-Wuninitialized]. 2017-05-22 15:22:38 +02:00
orbitcowboy ffe6582e6b Added platform support for Atmel AVR 8 bit microcontrollers. 2017-05-22 14:46:19 +02:00
Daniel Marjamäki b59bd96c6d ErrorLogger: Fix crash when error message does not have a FileLocation 2017-05-22 11:25:58 +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 9374055238 ErrorPath: clarify the 'shiftTooManyBits' error message 2017-05-22 07:58:56 +02:00
Daniel Marjamäki 7af58cf31a show full error path in xml files 2017-05-22 07:42:54 +02:00
Daniel Marjamäki 58da0df2f6 astyle formatting
[ci skip]
2017-05-20 18:52:48 +02:00
Daniel Marjamäki 82a372a380 Try to clarify ErrorPath texts 2017-05-20 08:47:35 +02:00
Daniel Marjamäki 55ae206ecc ErrorPath: better output 2017-05-19 17:29:16 +02:00
Daniel Marjamäki b53a2ff9eb Command line: Added --template=clang formatting 2017-05-19 17:09:49 +02:00