Commit Graph

9705 Commits

Author SHA1 Message Date
Daniel Marjamäki 59cc479855 Save bitfield bit counts 2018-05-02 20:55:11 +02:00
Daniel Marjamäki 920b553ebf astyle formatting
[ci skip]
2018-05-02 12:58:10 +02:00
Daniel Marjamäki 7dfbe7389b Clarify null pointer arithmetic message 2018-05-02 12:57:24 +02:00
Paul Fultz II f191a3e753 Improve checking of opposite expressions (#1199)
* Improve checking of opposite expressions

* Fix some formatting
2018-05-02 06:32:33 +02:00
Daniel Marjamäki b2343a2d4b Fixed #8518 (Clarify warning for a NULL pointer which is received by a function call parameter.) 2018-05-01 17:30:29 +02:00
Daniel Marjamäki 31148fdfed Fixed #8523 (Clarify warning: noConstructor) 2018-05-01 15:50:03 +02:00
Daniel Marjamäki 40b6f6b3dd CheckClass: Fix the noDestructor warning 2018-05-01 15:31:13 +02:00
Daniel Marjamäki 9710e819be CheckClass: Disable noDestructor for now, we need to handle new better 2018-05-01 09:26:03 +02:00
Daniel Marjamäki 42100fdf11 CheckClass: Better handling of non-copyable classes in the noCopyConstructor check 2018-05-01 08:33:23 +02:00
Sebastian f0646d3754 checkunusedfunctions.cpp: Fix files.txt parsing (#1197)
On Windows searching for the last colon finds the colon which is part of
the path of the source file (e.g. "C:/projects/a.cpp"). Thus the path is
saved incomplete. This fix searches for the second instead of the last
colon and uses the data after the second colon as the path of the source
file.
2018-05-01 08:09:11 +02:00
IOBYTE c3c1abd05e SymbolDatabase: improve checking of uninstantiated templates (#1196)
* SymbolDatabase: improve checking of uninstantiated templates

* Add bailout and debug warning for '>' token without a link in SymbolDatabase::findFunction()..

Don't crash on bad code simplification from tokenizer.
2018-05-01 07:32:19 +02:00
Daniel Marjamäki 73b41455dd CheckClass: If class has memory management it should have copy constructor, operator= and destructor 2018-04-30 23:13:33 +02:00
Daniel Marjamäki eb1571af81 Refactoring: use range for 2018-04-30 22:10:54 +02:00
Daniel Marjamäki fce7a0a128 dump: add Function::type 2018-04-30 16:52:51 +02:00
Daniel Marjamäki 7015fb097e SymbolDatabase::isFunction: better handling of return types 2018-04-29 15:35:31 +02:00
Daniel Marjamäki 45c4456c24 Tokenizer: Code cleanup 2018-04-29 15:05:13 +02:00
Daniel Marjamäki ff732e41ac SymbolDatabase: Remove unused Function constructor 2018-04-29 14:57:02 +02:00
Paul Fultz II e571e598b6 Fix false positive with inner conditions when using pointers (#1195) 2018-04-28 18:56:13 +02:00
Markus Elfring 521e3495b7 Adjustment for implementation of Token::insertToken() (#1194)
Three attributes are reset in this member function even if their values
are stored in the same token object.
Move a corresponding sanity check so that less assignments could be
performed eventually.
Link: https://trac.cppcheck.net/ticket/8532
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
2018-04-28 17:17:40 +02:00
Daniel Marjamäki ca8e19c96d SymbolDatabase: Refactor SymbolDatabase: variable list 2018-04-28 09:38:33 +02:00
Daniel Marjamäki 1a9e8c158d CheckClass::copyconstructors: Use library to determine if function is a allocation function 2018-04-27 23:20:04 +02:00
Daniel Marjamäki c80c44ab20 Refactoring: use range for loop, early continue 2018-04-27 23:04:48 +02:00
Daniel Marjamäki f336c2efe7 Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +02:00
Daniel Marjamäki ed79f300f0 Refactoring; use range for loop, use early continue/break 2018-04-27 22:18:26 +02:00
Daniel Marjamäki e6a37ec0b7 Fixed #8531 (false positive: (style) The function 'foo' overrides a function in a base class but is not marked with a 'override' specifier.) 2018-04-27 21:49:18 +02:00
Daniel Marjamäki 25599a76a7 Handle 'final' specifier better. 2018-04-27 14:57:43 +02:00
Daniel Marjamäki b830f462e6 Added missingOverride checker; Function 'f' overrides function in base class but does not have the 'override' keyword. 2018-04-27 11:12:09 +02:00
Daniel Marjamäki c7e5b941be Symbol database: Minor tweaks 2018-04-27 10:35:11 +02:00
Daniel Marjamäki 8304290f06 astyle formatting
[ci skip]
2018-04-27 10:29:27 +02:00
Daniel Marjamäki d15b945c9e SymbolDatabase::isFunction: Fix wrong detection function 2018-04-27 10:24:02 +02:00
Simon Martin 9fade65dbb Ticket #8281, #8417: Properly detect the end of "switch" statements to accept all legitimate uses of "case". (#1112) 2018-04-26 22:26:26 +02:00
Daniel Marjamäki 5384802e16 SymbolDatabase: Look for types in anonymous scopes 2018-04-26 17:55:04 +02:00
amai2012 55983e2a0b #8509 Uniform initialization ignored for iterator 2018-04-26 08:57:25 +02:00
Daniel Marjamäki d8634ca2a9 SymbolDatabase: Disable code for function pointers
This hopefully fixes all Travis crashes when running cppcheck:
[./test/Analysis/stack-addr-ps.c] (error) Internal error: Child process crashed with signal 11 [cppcheckError]
[./test/Index/complete-pointer-and-reference-to-functions.cpp] (error) Internal error: Child process crashed with signal 11 [cppcheckError]
[./test/SemaCXX/vararg-non-pod.cpp] (error) Internal error: Child process crashed with signal 11 [cppcheckError]
2018-04-25 18:48:26 +02:00
rebnridgway faf348306b Escaped filename, which can contain invalid xml (#1192) 2018-04-25 18:28:04 +02:00
Daniel Marjamäki e95c6e3038 Travis: Fix segmentation fault 2018-04-25 16:02:42 +02:00
Daniel Marjamäki bd54986017 SymbolDatabase: Refactoring parsing of ) ... in functions 2018-04-25 14:35:09 +02:00
Daniel Marjamäki 6efe118aa3 Fix Cppcheck warning 2018-04-25 14:29:34 +02:00
Daniel Marjamäki e97be9db2f SymbolDatabase: Refactoring, move logic from SymbolDatabase to Function class. Add a Function::isOverride() method. 2018-04-25 12:05:49 +02:00
Daniel Marjamäki 9aeb2aaa17 update doxygen comments 2018-04-25 10:14:57 +02:00
IOBYTE fac851192a SymbolDatabase: fix problem where definition coudn't find forward declaration in class (#1190) 2018-04-24 22:43:47 +02:00
Daniel Marjamäki deaafd59d7 CheckClass: Undo the rule of 3 checker to avoid some warnings 2018-04-24 22:42:25 +02:00
rebnridgway 995b496ddf Add suppressions to the XML dump (#1166)
* Added parsing suppressions from dump xml.

* Added code to dump suppressions to an xml file

* Added declaration for dump function

* Suppressions will now be written to the xml file when a dump is requested

* Fixed syntax error

* Removed excess whitespace

* Fixed indentation to be consistent

* Fixed indentation to be consistent

* Fixed indentation to be consistent

* Added missing include for ErrorLogger::toXml

* Fixed suggestions from pull request #1166

Switched to using ranged for loop to iterate through suppressions.
Made the line number attribute optional, rather than 0 if not specified.  This means when Python deserialises it it will be None, which is more pythonic.

* Implemented checking suppressions in reportError

This modification expects suppressions and a function to be called to write a line of output to be passed in.  The function checks if any of the suppressions match the warning (with the new Suppression.isMatch function) and if so returns None.  This change maintains the old behaviour of returning the warning text, but adds the possibility of returning None if the warning was suppressed.

* Fixed code quality warnings

* Removed more extraneous whitespace
2018-04-24 22:19:24 +02:00
Daniel Marjamäki 485d3e0229 CheckClass: Tweak rule of 3 checker 2018-04-24 21:45:30 +02:00
Daniel Marjamäki 5518247b96 Refactoring; use range for 2018-04-24 21:18:36 +02:00
Daniel Marjamäki b0b08a3bb0 Refactoring: Use range for loop 2018-04-24 18:17:47 +02:00
Daniel Marjamäki dbcdb19b73 Refactoring; Use range for 2018-04-24 18:02:36 +02:00
Daniel Marjamäki 6fb25dcaa4 CheckClass: Changed checker for 'copy constructor' and 'operator=' to a 'rule of 3' checker 2018-04-24 16:07:58 +02:00
Daniel Marjamäki 8310198cd5 SymbolDatabase: Refactoring and testing isImplicitlyVirtual 2018-04-24 13:53:58 +02:00
Daniel Marjamäki b94d8fd686 SymbolDatabase: Improve doxygen comments 2018-04-24 13:03:32 +02:00
Daniel Marjamäki c3cb0ddf8c Refactoring; use range for loops 2018-04-24 11:13:19 +02:00
Daniel Marjamäki f7db818273 errorlogger: fix handling of {inconclusive} 2018-04-24 11:10:41 +02:00
Daniel Marjamäki 22963f3ed8 Refactoring; use range for loop 2018-04-24 11:04:47 +02:00
Daniel Marjamäki bb227613bb SymbolDatabase: Better type lookup in methods 2018-04-23 22:27:15 +02:00
Daniel Marjamäki f021094f75 minor refactorings in SymbolDatabase 2018-04-23 21:45:25 +02:00
Daniel Marjamäki e3a4ef795e Refactoring: After conditional return the 'else' is not needed 2018-04-23 16:27:56 +02:00
Daniel Marjamäki 6d86ad78ba Refactoring, use early continue 2018-04-23 16:23:22 +02:00
Daniel Marjamäki 84aaec26e6 --template: fixed {code} output with tabs 2018-04-23 14:11:33 +02:00
Daniel Marjamäki f058d9ad08 CLI: Added more fields for --template and added a new --template-location. The gcc predefined template now matches latest gcc better. 2018-04-23 12:21:18 +02:00
Daniel Marjamäki b44a40801b ErrorLogger: add {column} and {code} 2018-04-23 09:18:32 +02:00
Daniel Marjamäki 42c54f12fe Refactoring: Use range for loops in CheckClass 2018-04-23 07:51:28 +02:00
Daniel Marjamäki e08683c009 Refactoring: Use range for loops in CheckFunctions 2018-04-23 07:49:38 +02:00
Daniel Marjamäki c6d834ae17 Refactoring: Use range for loops in CheckBool 2018-04-23 07:46:37 +02:00
Daniel Marjamäki b6e89f85d0 CheckOther: Use isLikelyStreamRead 2018-04-22 17:14:28 +02:00
Daniel Marjamäki b7a52c3811 CheckUnusedVar: Use isLikelyStreamRead 2018-04-22 17:08:23 +02:00
Daniel Marjamäki fba8208134 CheckUninitVar: Use isLikelyStreamRead 2018-04-22 17:04:54 +02:00
Daniel Marjamäki cc4977e140 Tweaking CheckUninitVar (<< and >> handling) 2018-04-22 16:39:57 +02:00
Daniel Marjamäki 7b10375683 Try to make Travis happy 2018-04-22 14:00:03 +02:00
Daniel Marjamäki 3d78320d04 CheckCondition: Use isLikelyStreamRead 2018-04-22 09:48:54 +02:00
Daniel Marjamäki 0263452f5d CheckClass: Use isLikelyStreamRead 2018-04-22 07:45:36 +02:00
Daniel Marjamäki be48de1be9 CheckClass: Use isLikelyStreamRead 2018-04-22 07:40:11 +02:00
Daniel Marjamäki 121d4ff2ba isLikelyStreamRead: when using & dont allow astParent 2018-04-22 07:30:45 +02:00
Daniel Marjamäki e1db4c0e2c astyle formatting
[ci skip]
2018-04-21 13:28:31 +02:00
Daniel Marjamäki 8cc7131ee9 Rename CppCheck::processFile to CppCheck::checkFile 2018-04-21 13:28:26 +02:00
Simon Martin a451a5b598 Ticket #8436: Handle C++11 initializations within ternary operator. (#1174) 2018-04-21 11:30:07 +02:00
Paul Fultz II d939c6015a Report opposite expressions (#1182)
* Report opposite expressions

* Skip assignment operator
2018-04-21 11:28:21 +02:00
Paul Fultz II bad66594d6 Fix double free regression with smart pointers (#1184) 2018-04-21 11:24:19 +02:00
Daniel Marjamäki 2073bd02d8 Refactoring: Use range for loop 2018-04-20 22:13:05 +02:00
Daniel Marjamäki 3fdb2da0d1 Refactoring: Use range for loop 2018-04-20 22:10:29 +02:00
Daniel Marjamäki 46bb63ceaf Refactoring: Use range for loop 2018-04-20 22:08:22 +02:00
Daniel Marjamäki d5fb529d4f Fixed #8492 (Improve message: parameter should be passed by reference) 2018-04-20 17:33:42 +02:00
Daniel Marjamäki 313b2a1755 Refactoring: Use ranged for loops 2018-04-19 22:31:36 +02:00
rikardfalkeborn 57019c0128 Fix comment in Tokenizer::simplifyMathFunctions (#1179)
In 9cea2d6df, simplifications were removed for a number of functions
which should instead be handled with configurations. The commit did
however not update the description of the function, do this now.

Also sin() and sinh() and their float and long double versions were
missing from the comment so add these as well.
2018-04-19 06:14:16 +02:00
Daniel Marjamäki b459da2ac3 Refactor Path::getRelativePath() 2018-04-18 22:23:38 +02:00
Daniel Marjamäki 4b8769a9f5 astyle formatting
[ci skip]
2018-04-18 17:46:31 +02:00
Daniel Marjamäki 7ee636b934 Refactoring: Reuse isLikelyStreamRead in isVariableChanged 2018-04-18 17:46:10 +02:00
Daniel Marjamäki 26e36a1d6b Fix FP uninitvar when stream bool operator is used 2018-04-18 16:13:24 +02:00
Daniel Marjamäki 1b4f4d7130 Fixed #8495 (False positive: boolean result used in bitwise operation when & is overloaded) 2018-04-17 22:14:17 +02:00
Daniel Marjamäki 219176c11c Update isLikelyStreamRead (#8494) 2018-04-17 20:34:31 +02:00
Daniel Marjamäki 7825eb8670 Refactoring; reuse isLikelyStreamRead 2018-04-17 19:51:27 +02:00
Daniel Marjamäki 4f6bd5d607 Fix Travis 2018-04-17 14:54:12 +02:00
Daniel Marjamäki c84628c28a Fixed #8494 (False positive: serialization class overloads operator) 2018-04-17 14:23:04 +02:00
Paul Fultz II 7d5a1b1248 Fix shadow warning (#1175) 2018-04-17 08:37:41 +02:00
Daniel Marjamäki a4f8c44432 astyle formatting
[ci skip]
2018-04-16 12:55:37 +02:00
Paul Fultz II 2a657cfd08 Check for double frees when using smart pointers (#1172)
* Check for double frees when using smart pointers

* Some updates from feedback

* Add test for mismatch allocation

* Constants

* Check smart pointer deleter

* Switch order

* Use next

* Add owned state

* Fix handling of leaks

* Use ast for checking addressof operator

* Remove stray character

* Add a test for mismatch allocator

* Add another test for deallocating with custom function
2018-04-16 11:11:13 +02:00
Simon Martin 5c1540915d Fix warning emitted by clang. (#1173) 2018-04-15 20:40:24 +02:00
Daniel Marjamäki 9a0756c13f CheckLeakAutoVar: clarify the code; replace magic values with constants, add a comment 2018-04-15 01:53:00 +02:00
Daniel Marjamäki 6ecd638e49 chmod 644 checkinternal.*
[ci skip]
2018-04-14 19:45:42 +02:00
Daniel Marjamäki 0a83c6b173 CheckInternal: Check that emplace is not used 2018-04-14 19:43:57 +02:00
Daniel Marjamäki e95ff8c7b6 Avoiding emplace 2018-04-14 19:24:35 +02:00
Daniel Marjamäki e73fe49d3c 4e820b6c4a 2018-04-14 15:46:55 +02:00
Daniel Marjamäki be78e44c3f Revert "I see compilation problems with std::multimap::emplace on a old system so lets avoid that"
This reverts commit 4e820b6c4a.
2018-04-14 15:43:14 +02:00
Daniel Marjamäki 4e820b6c4a I see compilation problems with std::multimap::emplace on a old system so lets avoid that 2018-04-14 15:19:04 +02:00
Daniel Marjamäki 97c86ff0e6 Dumps: Added isVirtual/isImplicitlyVirtual info 2018-04-13 21:15:43 +02:00
Daniel Marjamäki f7d65cd735 SymbolDatabase: add constness attribute for Variable 2018-04-12 20:23:34 +02:00
Sebastian c39a3e3f1c
windows string macros: Handle _T, _TEXT and TEXT internally, add tests (#1163)
Remove TEXT() macro from windows.cfg and handle it internally where it
can be correctly simplified (Ansi vs. Unicode).
Also add handling of _TEXT() macro which is just a synonym for _T().
Add tests to verify correct function and macro simplification.
2018-04-12 08:52:31 +02:00
PKEuS b596b0d549 Refactorization: pass std::string directly to std::*fstream 2018-04-11 09:50:42 +02:00
PKEuS d2146844dd Refactorizations:
- Replace several push_back-calls by emplace_back
- Replace some x = x.substr(0, y) calls by x.erase(y)
2018-04-11 09:44:35 +02:00
Daniel Marjamäki a0c9de0048 Suppressions: Validate inline suppressions 2018-04-11 08:18:00 +02:00
Daniel Marjamäki 87557afc43 Suppressions: Better XML formatting 2018-04-10 16:32:47 +02:00
Daniel Marjamäki a2b8eb7405 Suppressions: Report error if bad suppression element is used 2018-04-10 16:26:00 +02:00
Daniel Marjamäki 1767fe525b Addons: Fixed handling of noname arguments 2018-04-10 11:10:10 +02:00
Daniel Marjamäki 8c082f1b3f Remove lib/cxx11emu.h 2018-04-09 22:28:41 +02:00
Daniel Marjamäki c5923fbdd3 astyle formatting 2018-04-09 22:21:17 +02:00
Daniel Marjamäki 8f84a493f4 remove foreach emulator 2018-04-09 22:09:10 +02:00
Daniel Marjamäki e6114a2321 glob patterns: wildcards also match path separators (like before) 2018-04-09 18:59:18 +02:00
IOBYTE 8734e4dd38 Fix SymbolDatabase bailout to also support struct (#1160) 2018-04-09 18:53:55 +02:00
Paul Fultz II d8b3fa5c70 Fix #8482: Regression with valueflow (#1159)
* Fix regression with valueflow

* Simplify test case
2018-04-09 16:13:17 +02:00
Daniel Marjamäki f677322c69 Suppressions: Allow symbol-based inline suppressions 2018-04-09 11:50:59 +02:00
PKEuS 17b4721bd2 C++17: Support "if constexpr" (by simplifying it to plain if() statement)
This might lead to complaints about constant expressions as if() statement, but should fix syntax errors.
2018-04-09 11:42:59 +02:00
PKEuS b15cc3f236 Refactorization: Replace several push_back-sequences by initializer lists 2018-04-09 09:54:39 +02:00
Daniel Marjamäki 6f9c115640 Refactoring: use range for loops 2018-04-09 08:00:11 +02:00
Daniel Marjamäki a0906140a6 Suppressions: New extensible Suppressions xml format that allow more attributes. To start with it also allows symbolName. 2018-04-09 06:43:48 +02:00
PKEuS e2002db78d Replaced make_container by C++11 initializer lists 2018-04-08 23:03:44 +02:00
Daniel Marjamäki ae3e649cc4 astyle formatting
[ci skip]
2018-04-08 20:29:52 +02:00
Dmitry-Me d9cbaa83d6 Extract common condition 2018-04-08 21:11:44 +03:00
Paul Fultz II 95fc84a26b Find duplicate expressions assigned to the same variable (#1129)
* Check for duplicate assignments

* Improve checking of expression

* Add more tests

* Use simple match

* Improve robustness of check

* check for null

* Reduce side effects by checking for side effects

* Improve verbose message

* Reword the error message
2018-04-08 14:43:19 +02:00
Daniel Marjamäki ee5c60e8f6 Refactoring, use early continue 2018-04-08 09:30:13 +02:00
Daniel Marjamäki 795b9f5e0f astyle formatting 2018-04-08 09:25:59 +02:00
Paul Fultz II aed84abfd5 Extend valueflow comparison ops (#1153)
* Handle else clause when doing a compare

* Break early

* Fix bug in checking no return else

* Escape quotes

* Add equal sign

* Simplify the logic
2018-04-08 09:24:01 +02:00
Paul Fultz II b85dda77da Add a check for identical inner conditions (#1156) 2018-04-08 08:13:44 +02:00
Daniel Marjamäki 541e255159 Remove inner identical condition 2018-04-08 08:12:56 +02:00
IOBYTE 90983303f0 Fix #8477 (False positive caused by anonymous enum in method body) (#1154) 2018-04-08 08:00:12 +02:00
IOBYTE 4f9073159a Fix another SymbolDatabase bailout (#1157) 2018-04-08 07:29:19 +02:00
IOBYTE 20f0784c06 Fix #8470 ((error) SymbolDatabase bailout; unhandled code) (#1155) 2018-04-07 16:41:39 +02:00
Matthias Krüger 5a104cab6e remove weird "#line 2" from valueflow.cpp 2018-04-06 23:26:08 +02:00
Daniel Marjamäki 0daa3bba30 ValueType: Improved type handling of containers when [] operator is used 2018-04-06 22:26:35 +02:00
IOBYTE 7e15e39f39 Fix some new SymbolDatabase bailout; unhandled code syntax errors. (#1152) 2018-04-06 21:32:32 +02:00
Daniel Marjamäki 05acf9b352 Fixed #8470 ((error) SymbolDatabase bailout; unhandled code) 2018-04-06 16:03:58 +02:00
jrp2014 034296039c Refactor lib/checkunusedvar.cpp 2018-04-06 08:07:15 +02:00
jrp2014 d2160f00b2 Refactor lib/checkuninitvar.cpp 2018-04-06 08:04:06 +02:00
jrp2014 15b5b7ebf4 Refactor lib/checkother.cpp 2018-04-06 08:00:10 +02:00
IOBYTE 9f386d305a Fixed #8280 (False positive uninitMemberVar - initialized from nested overloaded function) (#1151) 2018-04-06 07:53:05 +02:00
jrp2014 c5e14ad590 Refactor lib/checkmemoryleak.cpp 2018-04-05 21:41:31 +02:00
jrp2014 94048d93f6 Refactor lib/checkleakautovar.cpp 2018-04-05 15:58:28 +02:00
jrp2014 c367fc9f09 Refactor lib/checkio.cpp 2018-04-05 15:55:57 +02:00
jrp2014 17bd2f0c72 Refactor lib/checkcondition.cpp 2018-04-05 15:53:49 +02:00
jrp2014 043b64467b Refactor lib/checkclass.cpp 2018-04-05 15:48:23 +02:00
Daniel Marjamäki 4836df9b1d Fix Token::Match pattern 2018-04-05 15:47:25 +02:00
Daniel Marjamäki e5db23fff3 project: import compile_commands.json generated by compiledb-generator 2018-04-05 15:40:59 +02:00
Daniel Marjamäki 3ad6c7ebce Refactoring, use early continue 2018-04-05 08:21:43 +02:00
jrp2014 67a71fa362 Refactor lib/checkbufferoverrun.cpp 2018-04-05 08:17:56 +02:00
jrp2014 e65c63e2bb Refactor lib/astutils.cpp 2018-04-05 08:07:22 +02:00
jrp2014 214322d501 Refactor lib/tokenize 2018-04-05 08:02:59 +02:00
Paul Fultz II b871c85b67 Improve valeflow analysis with comparison operators (#1131)
* Improve valeflow analysis with comparison operators

* Use simple match

* Dont add 0 on comparisons

* Check reverse comparisons

* Use nullptr

* Remove duplicate code tests
2018-04-05 06:51:31 +02:00
Paul Fultz II 54de7b48c9 Fix false positive when constructing with curly brace (#1148) 2018-04-05 06:47:59 +02:00
IOBYTE 06133fa3ba Refactor findFunction to unify two ValueFlow paths. (#1149) 2018-04-05 06:46:48 +02:00
Paul Fultz II 0c6f184423 Fix false positive for opposite conditions when using different containers (#1143)
* Fix false positive for opposite conditions when using different containers

* Add additional test
2018-04-05 06:43:13 +02:00
jrp2014 b6504c70ca Improve constness 2018-04-04 21:51:31 +02:00
IOBYTE a62c932a8f Improve findFunction for function calls with function calls as arguments. (#1147)
Duplicate the existing logic for variable to variable type comparisons
for function return type to variable type comparisons.
2018-04-04 20:44:01 +02:00
Daniel Marjamäki 0d434efc15 virtualCallInConstructor: Clarify warning message 2018-04-04 13:04:40 +02:00
Daniel Marjamäki b3b364b42f virtualCallInConstructor: Updated warning message 2018-04-04 12:52:58 +02:00
Daniel Marjamäki 3b07b749d6 Refactoring, use early return 2018-04-04 10:50:10 +02:00
IOBYTE fa968d75bd Partial fix for #8291: (False positive uninitMemberVar when calling delegated constructor) (#1142) 2018-04-04 08:29:12 +02:00
Paul Fultz II bce5fe5cef Improve duplicate expressions in the ternary op by checking for equal values as well (#1134)
* Improve duplicate expressions in the ternary op by checking for equal values as well

* Use value instead of expression
2018-04-03 21:43:55 +02:00
Paul d240a36a60 Extend nullPointerArithmetic to check for addition as well 2018-04-03 21:32:37 +02:00
Daniel Marjamäki ee22a325c7 virtual function call in constructor: don't warn about explicit scoped call 2018-04-03 14:02:59 +02:00
IOBYTE 2a418fa0f5 Fixed #8466 (False Positive: Member variable is not initialized in the constructor. When using overloaded constructors) (#1141) 2018-04-02 18:32:45 +02:00
Daniel Marjamäki 1046ca2120 Improve check: Warn about virtual function calls in constructor/destructor 2018-04-02 15:31:47 +02:00
Daniel Marjamäki e492932f19 Improve check: Variable is not initialized in private constructor (C++11 or later) 2018-04-02 15:26:15 +02:00
PKEuS 32a2060f14 Set version to 1.83.99/1.84 dev
Updated copyright year in version.h
2018-04-02 15:21:37 +02:00
Daniel Marjamäki 9f92685b92 SymbolDatabase: Throw InternalError if parsing fails 2018-04-02 13:14:48 +02:00
Daniel Marjamäki c0272fc2ef Fixed #8259 (Don't combine &= for anonymous reference parameters) 2018-04-01 10:27:16 +02:00
Daniel Marjamäki 7260be81a6 Update version 2018-03-31 21:25:29 +02:00
Daniel Marjamäki 7e4dba6a7e Updated copyright year 2018-03-31 20:59:09 +02:00
Daniel Marjamäki 4af2e517b9 Fixed #8465 (SymbolDatabase: bailout if there is 'struct A::B ab[5];') 2018-03-31 17:54:47 +02:00
Daniel Marjamäki ecfb4fd26c Fix --dump output 2018-03-31 10:27:34 +02:00
Daniel Marjamäki da4fc25fee Fixed #8432 (Problem with dump files and non-ASCII characters) 2018-03-30 22:34:55 +02:00
Daniel Marjamäki 95ccd9483b gcc 4.5 compatibility 2018-03-30 20:57:25 +02:00
Daniel Marjamäki dbe962ad5d Compatibility fix for gcc 4.5 2018-03-29 22:00:04 +02:00
Daniel Marjamäki 96167ffa51 Compatibility fixes for gcc 4.5 2018-03-29 17:37:06 +02:00
Daniel Marjamäki 1bc8f7f29a astyle formatting 2018-03-29 17:25:20 +02:00
Paul Fultz II 70da3acb70 Add foreach emulation for older compilers (#1138) 2018-03-29 04:51:22 +02:00
Daniel Marjamäki 210b921062 Fixed #8462 (AST: no ast created for 'e = { std::move(address),httpPort, (httpsPort) };') 2018-03-27 13:44:28 +02:00
Daniel Marjamäki e65a5529ad astyle formatting
[ci skip]
2018-03-24 12:30:11 +01:00
Paul 43be20a824 Check more opposite conditions 2018-03-24 07:58:37 +01:00
IOBYTE 5bc039b7da Fix #6367 and #8439 (improve sizeof value flow support) (#1132) 2018-03-23 08:28:12 +01:00
Daniel Marjamäki 5a444f764b Fixed one more syntax error FP related to #8390 2018-03-22 15:20:37 +01:00
Daniel Marjamäki 3d4b773fd1 Fixed #8390 (Syntax error from an MSVC internal header) 2018-03-22 09:07:58 +01:00
Daniel Marjamäki 1ae75303a7 micro optimisation, use const reference 2018-03-19 09:53:14 +01:00
Daniel Marjamäki 7699f6432b Fixed #8288 (valueFlowGlobalVar: compound assignments) 2018-03-18 19:53:33 +01:00
Daniel Marjamäki f7d537ea26 Null pointers: better detection of null pointer dereference 2018-03-18 19:02:30 +01:00
Daniel Marjamäki ec6133aea2 Fixed #8182 (False positive uninitvar - variable initialized in function in ternary expression) 2018-03-16 19:13:48 +01:00
Paul Fultz II 166e4cafcd Check for functions calls in sizeof calculations (#1111)
* Check for functions calls in sizeof calculations

* Use seperate message and id for sizeofFunction

* Check for overloads

* Using decltype with a function should not be an error

* Fix warning

* Fix false positives when running pass the close paren

* Fix test error

* Try to fix more false positives

* Traverse using astOperand2

* Only check first argument

* Update fixes from feedback from PR
2018-03-15 10:24:17 +01:00
Daniel Marjamäki 814828f436 dump: save if variable is const 2018-03-14 11:54:23 +01:00
Daniel Marjamäki 2c3cd402ba Thread safety: changed local static variable 'count' to member variable 2018-03-14 09:41:27 +01:00
Daniel Marjamäki 9800e82d13 GUI: Allow that platform is selected in project dialog 2018-03-13 13:07:10 +01:00
Daniel Marjamäki 0d2171a553 astyle formatting 2018-03-12 13:43:04 +01:00
Daniel Marjamäki 31dd4ed787 use early continue 2018-03-12 12:50:33 +01:00
Daniel Marjamäki c0e14d0a5d Added doxygen comment 2018-03-12 12:49:27 +01:00
Daniel Marjamäki 3ef3a6088d astyle formatting 2018-03-12 10:19:55 +01:00
Hinterwaeldlers a9b1f4c640 Taking care of operation overloading functions (#1108) 2018-03-12 10:25:30 +01:00
Daniel Marjamäki 46307df9b6 Renamed method 2018-03-11 15:06:08 +01:00
Daniel Marjamäki 380ecc408f Fixed #8418 (AST: wrong ast for throw expression) 2018-03-10 22:30:21 +01:00
amai2012 b1d943894b Copy platforms/ directory to bin/ 2018-02-27 09:09:12 +01:00
Sebastian 54d1490c89 platform.cpp: Fix that platform files on Windows are not found (#1096)
* platform.cpp: Fix that platform files on Windows are not found

I suggested this change here:
https://trac.cppcheck.net/ticket/8242#comment:7

* Use fromNativeSeparators() and only search for forwardslash
2018-02-26 13:51:02 +01:00
Daniel Marjamäki 1628405869 Fix internal warning 2018-02-24 22:35:37 +01:00
Daniel Marjamäki 7701e4594a ValueFlowBeforeCondition: Fix wrong value in do-while condition when there is a break in the loop body 2018-02-24 22:07:34 +01:00
orbitcowboy b7b376d901 checkTypes: Take into account type promotion to integer. 2018-02-19 23:55:38 +01:00
orbitcowboy b1b3164259 checktype: Added handling of 'short'-type and added test cases. 2018-02-18 21:09:19 +01:00
orbitcowboy 50844aa7fc checkType: Take into account the size of char. 2018-02-18 14:28:48 +01:00
Daniel Marjamäki 5c44580528 Refactoring, use early continue and make code a bit more specific. 2018-02-16 22:59:38 +01:00
IOBYTE fcde1d80e9 Fix #8382 (Syntax error when scanning code with template and attribute) (#1089)
* Fix #8382 (Syntax error when scanning code with template and attribute)

This commit only addresses #8382. There are issues concerning which
versions of C++ should be supported and also generic C++ 14 attribute
support which can be revisited later.

* Remove all C++ style attributes.

Remove all C++ style attributes when C++ version is 11 or greater.
Rename simplify function to simplifyCPPAttributes.
Handle more cases of roreturn function attribute.
2018-02-16 22:25:51 +01:00
Daniel Marjamäki 03a222e926 Platform: Improve testability of platform file loading 2018-02-15 21:01:34 +01:00
orbitcowboy b86b7175cb cli:platforms: Added missing sizeof Boolean variable handling when platform file is loaded from XML. 2018-02-13 11:27:50 +01:00
orbitcowboy 1906067aac cli:platforms: Fixed wrong loading of platform info. 2018-02-13 10:41:15 +01:00
Daniel Marjamäki 69b50b274c Try to make Travis happy 2018-02-11 22:54:14 +01:00
Daniel Marjamäki e62b9bdc77 Fixed #8348 (ValueFlow: wrong Uninit value with abort() in else-branch) 2018-02-11 22:14:44 +01:00
IOBYTE d68f07e50c Add purgedConfiguration to list of error ids. (#1087)
purgedConfiguration was not showing up in the GUI supression list.
2018-02-10 22:30:49 +01:00
Daniel Marjamäki f5b91ffca8 Platform: Fix CFGDIR handling 2018-02-10 22:24:40 +01:00
Daniel Marjamäki db274e8308 Fix testrunner in cygwin 2018-02-10 15:34:49 +01:00
Simon Martin 66d16b51f0 Ticket #8352: Properly detect AST cycles. (#1060) 2018-02-10 14:39:57 +01:00
Daniel Marjamäki 7c33207a72 astyle formatting
[ci skip]
2018-02-09 21:43:44 +01:00
Lauri Nurmi e0e664f996 Fix permissions of certain non-executable files (#1083)
mode 0755 => 0644
2018-02-09 19:46:38 +01:00
Matthias Krüger b71c945ac4 fix build (CFG_DIR => CFGDIR) and run dmake. 2018-02-09 17:44:26 +01:00
Daniel Marjamäki 780bd7e63e More flexible loading of platform files, when using --platform it should not be necessary to provide the full path 2018-02-09 16:22:22 +01:00
Daniel Marjamäki 85d8bbacb8 integerOverflow: Separate id for conditional integer overflows 2018-02-07 12:49:56 +01:00
Daniel Marjamäki 58066b1f0c Remove whole program analysis from 'uninitialized variables' and 'null pointer dereference' checkers. I think this logic can more or less be added in ValueFlow instead and then all ValueFlow checkers should get whole program analysis. 2018-02-06 14:56:17 +01:00
Daniel Marjamäki 71511f3131 Refactor f487182 2018-02-06 08:59:36 +01:00
Daniel Marjamäki 13daaac264 astyle formatting
[ci skip]
2018-02-06 08:10:28 +01:00
Ivan Maidanski f487182075 Suppressed unused functions should not lead to nonzero exit code (#1026) (#1078)
This is a fix of commit 97ffec8.
2018-02-06 07:44:53 +01:00
Daniel Marjamäki 8a3c25210d SymbolDatabase: Remove useless break. As far as I know Tokenizer::syntaxError() throws an exception and therefore the break after the function call is unreachable 2018-02-05 23:28:33 +01:00
Alexander Mai 68eb6c4e6f Refactoring: Add Tokenizer::findGarbageCode to time report. The method now calls syntaxError instead of returning an invalid token 2018-02-05 21:47:33 +01:00
Daniel Marjamäki dbc6771a0b Uninitialized variables: Fix FP for unknown macro like 'list_for_each' 2018-02-04 22:30:08 +01:00
Matthias Krüger f009cfc845 fix some typos found by codespell. 2018-02-04 20:53:43 +01:00
Daniel Marjamäki 4998248501 Null pointers: Fixed false positives when running whole program analysis. Copied the fix from the CheckUninitVar::isUnsafeFunction. 2018-02-04 15:29:57 +01:00
Jørgen Kvalsvik a61f21d1b6 Accept nested templates in tokenizer-simplify (#1070)
The following snippet triggerd the error:

template<typename DerivedT>
template<typename T>
auto ComposableParserImpl<DerivedT>::operator|( T const &other ) const -> Parser {
    return Parser() | static_cast<DerivedT const &>( *this ) | other;
}

Whenever simplifyFunctionParameters was called on a templated class'
templated member function (and probably any nested template), the
tokenizer would recognise it as a syntax error, assuming that return
type *must* come after a template<> token.
2018-02-04 09:48:37 +01:00
Daniel Marjamäki d47b7726fa Uninitialized variables: Fix potential false positives in subfunction if there is early return or conditional writes 2018-02-04 09:40:57 +01:00
Daniel Marjamäki 1fe59faecb changed message ids for uninitvar/nullpointer errors that was found by whole program analysis 2018-02-03 16:05:07 +01:00
IOBYTE d721c6aca5 Fixed #8386 (syntax error not found (segmentation fault)) (#1081) 2018-02-03 15:50:05 +01:00
orbitcowboy 82c963d3a2 symboldatabase: Fix null pointer dereference, introduced by ee1ba85e15 (comments). 2018-02-02 08:45:13 +01:00
orbitcowboy ee1ba85e15
symboldatabase: Fix potential null pointer dereference (#1072)
There is a  potential `nullPointer` dereference in symboldatabase. This PR attempts to fix this. Additionally, this could be detected by Cppcheck as well. 

Here is a reduced and compilable testcase, where Cppcheck fails to detect a potential `nullPointer` dereference:

```
class Scope
{
public:
    bool bar();
    int *definedType;
};

int f(Scope *new_scope)
{
    int ret = 1;
    if (new_scope)
    {
        if (new_scope->bar())
        {
            if (!new_scope->definedType) {} // check for null
            ret = *new_scope->definedType; // dereference
        }
    }
    return ret;
}
```
The corresponding ticket on track, addressing the false negative: https://trac.cppcheck.net/ticket/8375
2018-01-31 11:00:42 +01:00
orbitcowboy f5e6ef9fd2
checkio: Fixed potential usage of invalid iterator. (#1066)
* checkio: Fixed potential usage of invalid iterator.

* formatted the code.

A ticket about FN (invalidIterator1) is created at https://trac.cppcheck.net/ticket/8373
2018-01-30 08:43:15 +01:00
Daniel Marjamäki f5a11a6510 UninitVar: Speedup whole program analysis a bit 2018-01-29 15:15:35 +01:00
orbitcowboy fb7f1efc49 token: Fixed potential null pointer dereference. (#1062) 2018-01-28 14:27:01 +01:00
Daniel Marjamäki 21a35de0d2 Tokenizer: Refactoring garbage check 2018-01-27 22:26:43 +01:00
David Hallas 4d18d3948f Fixes issue with case inside switch that is not a compound statement (#1031)
* Fixes issue with case inside switch that is not a compound statement was treated as garbage

This fixes an issue with the check for case keywords outside of switch
detection that would treat a case statement inside a switch that is not
a compound statement as garbage, but this is perfectly valid C++. This
construct is used in several libraries, i.e. Google Test.

* Tweak check and handle missing semicolon

Tweaks the check with feedback from danmar.
Handle the case where there is no semicolon and document it with a unit
test.
2018-01-27 22:21:26 +01:00
Daniel Marjamäki 5b6ec49a6f Pointer overflow: Fixed false positive 2018-01-27 22:09:43 +01:00
Daniel Marjamäki 189e0b3890 Fix Cppcheck warning about uninitialized variable 2018-01-27 22:05:29 +01:00
Daniel Marjamäki bc40f5041d Fixed #6356 (Improve checking: pointer arithmetic "ab.a + 100" overrun) 2018-01-27 15:39:39 +01:00