Commit Graph

9577 Commits

Author SHA1 Message Date
Daniel Marjamäki ab6167e3e6 TokenList::validateAst: optimised ~25% 2018-05-09 12:36:58 +02:00
Daniel Marjamäki ecccce0608 Tokenizer::setVarId: Made it ~5% faster 2018-05-09 10:25:29 +02:00
Paul Fultz II 0197343e0c Fix false positive when using null arithmetic with class type (#1214) 2018-05-09 09:06:49 +02:00
Paul Fultz II f5dbfce8ff Fix false positive with oppositeExpression when using binary op (#1211)
* Fix false positive with oppositeExpression when using binary op

* Simplify conditional
2018-05-08 20:43:57 +02:00
Daniel Marjamäki c266688784 Fix syntax error 2018-05-08 10:21:03 +02:00
Daniel Marjamäki 315dc2ad8a only show information message when information messages are enabled 2018-05-08 09:47:14 +02:00
IOBYTE 8b0b659965 Add support for namespace aliases and C++17 nested namespaces. (#1210)
* Add support for namespace aliases and C++17 nested namespaces.

These are implemented as tokenizer simplifications so changes are not
needed to the tokenizer and symbol database.

* Fix codacy warning.
2018-05-08 06:35:51 +02:00
Daniel Marjamäki 8e8919e906 Fix comment 2018-05-07 22:06:23 +02:00
Daniel Marjamäki 0bff08ca44 Fixed #1378 (#error macro makes unrelated errors undetectable) 2018-05-06 22:02:23 +02:00
Daniel Marjamäki 3b8a3aa4ba Fixed crashes in daca 2018-05-06 09:52:04 +02:00
Daniel Marjamäki 8c2a5c9813 astyle formatting
[ci skip]
2018-05-06 09:50:53 +02:00
Paul Fultz II 0561877182 Fix false positive with negative array index in issue 8536 (#1202)
* Fix FP with negative array index in valueflow

* Remove values when valueflow fails

* Add valueflow test
2018-05-06 08:35:29 +02:00
IOBYTE 5d417bbfa1 SymbolDatabase: harden code for missing links (#1207)
* SymbolDatabase: harden code for missing links

Missing links for templates are common so check links before using them
to prevent crashes.

* SymbolDatabase: replace link check and single token match with match of two tokens
2018-05-06 08:23:07 +02:00
Daniel Marjamäki 858e055c0e ValueFlow: Wrote a few basic comments 2018-05-05 23:03:04 +02:00
Paul Fultz II 067d82f0ea Check for smart pointer release (#1206) 2018-05-05 18:06:49 +02:00
Daniel Marjamäki 4408628107 Fixed #8538 (SymbolDatabase: wrong parsing of noexcept) 2018-05-05 08:31:56 +02:00
Daniel Marjamäki 64b85b474c Fixed #8542 (False positive: noOperatorEq) 2018-05-05 07:46:58 +02:00
Daniel Marjamäki 7fb28b05f6 Check Class: Try to clarify the warnings for noCopyConstructor/noOperatorEq/noDestructor. 2018-05-04 15:39:23 +02:00
Daniel Marjamäki 99003c2084 CheckClass: Better handling of defaulted and deleted functions in the noCopyConstructor/noOperatorEq/noDestructor 2018-05-04 14:58:38 +02:00
Daniel Marjamäki f2bb7397b3 astyle formatting
[ci skip]
2018-05-04 14:57:45 +02:00
Paul Fultz II cac68c6b81 Fix FP when using - as a binary operator (#1201) 2018-05-04 07:58:30 +02:00
IOBYTE f94e9c5447 Fix #8540 (Syntax error involving forward-declared 'enum class') (#1203) 2018-05-04 07:56:20 +02:00
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