Commit Graph

59 Commits

Author SHA1 Message Date
Rikard Falkeborn 82a1e3c61c CheckInternal: Extend redundant null pointer check before Token::Match() (#1789)
Improve the internal check for redundant null pointer check before
calling Token::Match() (and friends). Now, warn about code snippets like

    if (a && tok && Token::Match(tok, "foo"))

Also, extend the check for the inverted case.

There is still no warning for

    if (tok && a && Token::Match(tok, "foo"))

since that would require checking if a is independent of tok.
2019-04-06 07:44:44 +02:00
Daniel Marjamäki bd7790fd8c Update copyright year 2019-02-09 07:24:06 +01:00
Daniel Marjamäki 5f198662ff rephraze internal warning 2019-01-13 12:12:07 +01:00
Daniel Marjamäki 79ffe1d4fc Rename _tokenizer, _settings, _errorLogger 2018-06-16 16:10:28 +02:00
Daniel Marjamäki 45379a3aa6 Updated copyright year for modified files
[ci skip]
2018-06-10 22:07:21 +02:00
Daniel Marjamäki f336c2efe7 Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +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
PKEuS e2002db78d Replaced make_container by C++11 initializer lists 2018-04-08 23:03:44 +02:00
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +01:00
Matthias Krüger 1f3ca7ddf6 oops, remove some leftover commented-out debug code and run astyle. 2018-01-01 05:04:59 +01:00
Matthias Krüger f2b2be2166 CheckInternal::checkRedundantTokCheck(): also catch patterns of the form if(!tok || !Token::Match(tok, "foo")). 2018-01-01 05:02:41 +01:00
Ville Skyttä 5ab158fec2 Spelling fixes 2017-05-30 08:03:15 +03:00
Ayaz Salikhov 28aa939d69 iwyu - include what you use 2017-05-27 04:33:47 +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
PKEuS eafed235a6 Attempt to fix build on Unix systems, ran AStyle. 2016-07-26 16:50:32 +02:00
Dmitry-Me 560e7d618d Get rid of "magic" patterns set
* magic should match "knownPatterns" but it didn't
* two identical sets are of no use
2016-07-26 16:42:17 +03:00
Dmitry-Me 2b31afe2ab Variable name consistent with surroundings 2016-07-26 09:46:50 +03:00
Dmitry-Me 64360d291d Variable name consistent with surroundings 2016-07-25 17:04:18 +03:00
PKEuS f44d9d5c9b Optimizations in CheckInternal:
- Run checks only on executable scopes
- Simplified patterns
2016-07-24 12:05:58 +02:00
Lauri Nurmi 996c9244d8 Update copyright year to 2007-2016. 2016-01-01 15:34:45 +02:00
Daniel Marjamäki 5dc42ccd49 try to fix Travis. teach checkinternal about %assign% 2015-12-31 01:56:48 +01:00
Daniel Marjamäki 1de21a8356 try to fix Travis. teach checkinternal about %assign% 2015-12-31 01:32:34 +01:00
Alexander Mai f5194accfd Run dmake. Add missing include to lib/checkinternal.cpp 2015-11-29 11:09:21 +01:00
PKEuS e8522c7883 Small refactorizations:
- #include cleanup
- Use std::array instead of std::vector
- Do not create a stringstream to concatenate 4 strings
- Use std::cout instead of printf
2015-11-29 10:56:44 +01:00
Daniel Marjamäki 0f9d90d2be Changed Copyrights. Removed my name. 2015-11-18 20:04:50 +01:00
PKEuS 4d80df2f4a Added pointer to Type to Token (similar to Token::Variable() and Token::function()):
- Accessible via Token::type()
- Renamed former Token::type() to Token::tokType()
- Removed SymbolDatabase::isClassOrStruct()
2015-08-15 11:19:21 +02:00
PKEuS 189a652c2e Fixed garbage code in checkinternal.cpp 2015-06-18 17:13:46 +02:00
Alexander Mai eebb5b8c77 Fix some compiler warnings in checkio.cpp. Fix some (potential) multi-threading issues in checkinternal.cpp 2015-06-17 21:25:15 +02:00
PKEuS f771a79738 Removed obsolete internal check. The underlying but in Token::Match should be fixed since b4f0869a71 2015-01-31 12:56:54 +01:00
PKEuS b2835051df Refactorization: Renamed Token::Match pattern %var% to %name%, implement new pattern %var% which is true if varId > 0. 2015-01-31 12:32:04 +01:00
PKEuS 3342ea4c54 CheckInternal: Complain about Token::Match pattern if %or% or %oror% is the only "complex" pattern 2015-01-28 19:48:36 +01:00
Daniel Marjamäki ff11ba9847 Updated copyright year to 2015 2015-01-03 12:14:58 +01:00
Thomas Jarosch 17b47f1ce0 New internal check: Catch extra whitespace in match patterns
Inspired by a recent commit from PKEuS.
2014-12-30 14:21:18 +01:00
PKEuS 719304a8fc Added internal check for || and | inside Token::Match patterns. 2014-07-02 15:51:18 +02:00
PKEuS 5fbd58d98d Fixed messages of CheckInternal, fixed a false positive. 2014-05-18 20:39:52 +02:00
PKEuS 9cb544241d Internal checking is now enabled by the macro CHECK_INTERNAL 2014-05-18 19:50:06 +02:00
Daniel Marjamäki fd3a8a2a18 Update copyright 2014-02-15 07:45:39 +01:00
Daniel Marjamäki 126f2ed423 Fixed Visual Studio compiler error 2014-01-06 18:14:29 +01:00
Daniel Marjamäki c32d0f1992 CheckInternal: Improved checking of multiCompare patterns. The multiCompare pattern can contain any %cmd% until there is non-%cmd% used. For instance %var%|%num% is handled ok. 2014-01-05 23:03:36 +01:00
Daniel Marjamäki 4620284cbf astyle formatting 2014-01-05 22:06:11 +01:00
Daniel Marjamäki 62c608141d CheckInternal: Improved checking of multiCompare patterns 2014-01-05 21:15:41 +01:00
PKEuS f899e6ca30 Changed behaviour of %op% pattern accordingly to changes to Token::isOp(). Added %cop% as replacement for old %op% 2013-03-01 02:43:59 -08:00
Reijo Tomperi 5d5f7085bf Updating year 2012 -> 2013 to .cpp and .h files and man page. 2013-01-01 18:29:08 +02:00
Edoardo Prezioso aeb4531a58 Token::Match: add a new pattern: '%comp%'.
Token::Match returns true if the token is a comparison operator. It's equivalent to matching '<|<=|==|!=|>=|>' and the tests show that the new pattern speeds up the program execution. Added the new pattern in CheckInternal (and also reordered the %cmd% lists) and in TestToken.
2012-12-01 00:55:24 +01:00
Edoardo Prezioso ca2a6e6054 Add '%char%' as a CheckInternal known pattern. 2012-11-05 17:25:36 +01:00
PKEuS a4b5824dec New internal check: checkRedundantNextPrevious().
Fixed findings by new internal check
2012-09-07 12:36:40 +02:00
Ville Skyttä 7ab2f6a9fa Spelling fixes. 2012-07-21 18:11:20 +02:00
PKEuS e8f4dce25f Added check to CheckInternal: detect invalid patterns like "%typ%"
Replaced some Token::Match by Token::simpleMatch (suggestions of internal checks)
2012-07-11 08:45:16 -07:00
PKEuS 9dc8123151 Refactorizations:
- Use const string references instead of const strings copies when possible
- Fixed cppcheck warning about postfix increment in CheckIO
- Use symbolDatabase to detect pointers in CheckOther::checkAssignBoolToPointer
2012-05-25 03:09:41 -07:00