Commit Graph

75 Commits

Author SHA1 Message Date
Edoardo Prezioso 6236e1dc38 Token::Match: removed harmless special code for initial '!!foo' patterns. 2013-01-09 20:13:33 +01:00
Thomas Jarosch 7dd07d8e77 Properly implement %op% for Token::multiCompare
Use tok->isOp() instead of doing it "manually".

This fixes false positives for the C++ template case since
the brackets in "template < something >" are not comparison operators.

Profiling showed using tok->isOp() is actually faster than before (-O2).
2013-01-09 17:05:53 +01:00
Thomas Jarosch 29c66dd9bc Add another TODO test case for Token::Match 2013-01-08 00:19:12 +01:00
Thomas Jarosch 818362f496 Add TODO test case for a bug in Token::Match multicompare
The result of the %op% operator is wrong in the multicompare
case for C++ templates. Detected by comparing the output
of the compiled matches with the on-the-fly match parser.
2013-01-07 23:47:20 +01: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 9d0a295b85 Partially fixed #4288 (handle %var%|%num% patterns). 2012-11-17 20:51:18 +01:00
Edoardo Prezioso 87c931b74b Add '%char%' as pattern to match in Token::Match.
All and only those single characters enclosed in "'" are accepted.
2012-11-04 16:58:18 +01:00
Ankita-gupta ff7373f46f Fixed bug in Token::Match (#3720) 2012-08-30 13:33:19 +02:00
PKEuS 4bb2a1b27b Made some functions static or const according to cppcheck results 2012-05-17 01:33:24 -07:00
PKEuS c976325086 Refactorizations in test suite:
- Implement createOnly mode in givenACodeSampleToTokenize so that only createTokens is called instead of tokenize
-> Ensures that no simplifications are done which could make the testing basic functions (like Token::Match) less accurate. We often don't need this simplifications in testtoken.cpp.
-> Ensures that no validation of the source is done (Fix #2104)
- reduced overhead of givenACodeSampleToTokenize: Don't store a std::istringstream instance, avoid creation of std::string when ctor is called
2012-05-16 09:04:03 -07:00
PKEuS 1a5fbd61d2 Splitted class TokenList from Tokenizer 2012-05-05 09:33:26 -07:00
Ettl Martin bb8342fbb4 fixed misspelled word 'Comparision' --> 'Comparison' 2012-04-26 23:04:55 +02:00
PKEuS e0a3ca0845 Refactorizations in class Token: changed handling of different types of tokens.
- Replace _isNumber, _isName, _isBoolean attributes by a single _type attribute (enum Token::Type), because not two of the old booleans could be true at the same time.
-> Add support for lots of different other kinds of tokens. (More precise checking of token type possible)
-> Replaced instant checking of type for Operators, etc. by a value calculated at creation time. (Faster checking)
2012-04-23 21:05:26 +02:00
PKEuS cb064dc20e Implemented generic mechanism for '<'-'>' "linkage" before link() works (Taken from Scope::findClosingBracket, but C++11 right angle bracket support added): Token::findClosingBracket
-> Replaced several indendation-counting mechanisms in tokenize.cpp

Fixed build failure in checkclass.cpp
2012-04-18 16:02:03 +02:00
PKEuS a971e1530b Refactorizations in test suite:
- Removed another custom stringify implementation (testtoken.cpp)
- Removed unnecessary forward declaration (testsuite.h)
- Use std::ostringstream instead of std::stringstream (redirect.h)
2012-04-17 12:57:16 +02:00
Reijo Tomperi 194327048a Add InternalError and change MathLib to throw it in case of an error.
- Previously MathLib errors did not provide a filename, but after this change at least source file name should be printed
and if token is provided, also line number should be printed.
- Change also Token to use InternalError
- Modify Cppcheck-class to catch InternalError instead of Token
- Run dmake to update Makefile
2012-01-08 22:19:44 +02:00
Daniel Marjamäki 73d9dc870e TestRunner: Make sure no xml output is reported when running TestToken (#3015) 2012-01-06 09:03:23 +01:00
Reijo Tomperi 8cae17fda8 Update year to 2012 2012-01-01 01:05:37 +02:00
PKEuS dca03c3ce2 Remove unnecessary includes
Also add a unit test related to #3427
Also improve the description text in checkclass and remove unused variable.
2011-12-23 23:31:48 +02:00
Reijo Tomperi eebd1393ff "Internal error. Token::Match called with varid 0." didn't work when error was in a header file. Fixed that. 2011-11-21 00:41:26 +02:00
Reijo Tomperi 91e89380c2 astyle fix 2011-11-20 23:43:55 +02:00
Reijo Tomperi e0ea4228cd "Internal error. Token::Match called with varid 0." will now cause check to abort and write a proper error log with filename. Previously filename was empty and format was always xml. 2011-11-20 23:38:37 +02:00
Thomas Jarosch 1a454256dc Cache result of tok->isStandardType()
Also contains test order improvements from Johan Samuelson (#3116).

Run time went down from 15.15s to 14.95s for the case below.

Benchmarked using these settings:
- CXXFLAGS="-O2 -g -NDEBUG"
- time -p cppcheck.git -q --std=posix --enable=all --inconclusive -Dfoo .

on the "rpm" codebase.
2011-11-09 21:56:30 +01:00
Edoardo Prezioso 8a60ceed82 Add test for Token::eraseTokens. 2011-11-08 18:59:31 +01:00
Thomas Jarosch a83c47d9cf Fix false positive of %or% match in alternative pattern match code
%or% triggered on code using "|=" or "||".
2011-11-06 22:12:31 +01:00
Thomas Jarosch 1360c554ed Extended isOp() tests to do proper negative testing against other operators 2011-11-06 21:20:13 +01:00
Thomas Jarosch 7ef1107a55 Unit test for Token::isArithmeticalOp() and Token::isStandardType() 2011-11-06 18:55:02 +01:00
Thomas Jarosch d7ce892c06 Unit test for %varid% match
Also run astyle.
2011-11-06 18:37:45 +01:00
Thomas Jarosch 05c4b97bbe Unit test for %type% and %str% matches 2011-11-06 18:30:34 +01:00
Thomas Jarosch 95851454cc Unit test for Token::isExtendedOp() and Token::isAssignmentOp() 2011-11-06 18:19:27 +01:00
Thomas Jarosch 19c9c97608 Fix single %op% operator not working at all
When parsing the Token::Match pattern, we accesed
the wrong character in the pattern and never
executed the %op% check.

In addition the unit test function for %op%
wasn't registered in the test suite. Ups.

All fixed now and also provide a complete
check for all operators %op% supports.
2011-11-06 18:02:18 +01:00
Daniel Marjamäki 5edf153602 Fixed #3294 (Token::Match multi compare false negative) 2011-11-05 19:24:21 +01:00
Thomas Jarosch 2a46c635f6 Test case to demonstrate #3294 2011-11-05 14:04:23 +01:00
Thomas Jarosch 91a5d95bc9 Use Token::simpleMatch() / Token::findsimplematch() where possible 2011-10-28 22:31:05 +02:00
Thomas Jarosch 1ccb57e595 Document and test Token::concatStr() 2011-10-23 21:21:42 +02:00
Thomas Jarosch 5b97cc1440 Bugfix: Update token properties on string changes 2011-10-23 21:06:56 +02:00
PKEuS 54b3d72ee3 Added Token::nextArgument() 2011-10-23 11:23:48 +02:00
Daniel Marjamäki 6f8e42a5af changed the astyle formatting flags 2011-10-13 20:53:06 +02:00
Robert Reif daf0c71f77 fix #2911 (Token::Match(tok, %oror%|&&) doesn't match &&) 2011-07-31 13:26:26 -04:00
Robert Reif 76960e54a1 testcase for broken Token::Match %oror%|&& 2011-07-16 07:28:26 -04:00
Daniel Marjamäki d78d8660ab astyle formatting 2011-07-15 19:02:16 +02:00
John Smits 7f2d62cbde Fixed #2882 (One-character token can be mistaken for a multiCompare) 2011-07-15 19:01:36 +02:00
Daniel Marjamäki af60f2c4ef Token: Added testcase for matching of %op% 2011-04-10 11:15:57 +02:00
Daniel Marjamäki 747a2331c6 Token::Match : Allow that %oror% and %or% is used in multiCompare patterns 2011-04-10 08:39:55 +02:00
Daniel Marjamäki 6c4f5fc496 Token::multiCompare : allow that %op% is used in multiCompare pattern 2011-04-09 18:09:13 +02:00
Reijo Tomperi 226b605774 Change year 2010 -> 2011 in license texts. 2011-01-09 21:33:36 +02:00
Daniel Marjamäki a9aa6375b7 gcc: disabled -Wconversion again - too many warnings 2011-01-01 09:16:31 +01:00
Pete Johns 2e61736c73 Refactoring following #2377 (Technically the member function xxx can be const)
symboldatabase now recognises variables with arbitrarily many scopes.

Extracted method isVariableDeclaration()

Added unit tests for isVariableDeclaration in new file testsymboldatabase.cpp

Extracted givenACodeSampleToTokenize helper class into testutils.h to reduce duplication.
2010-12-30 19:46:44 +11:00
Robert Reif f12c0c7ada Tokenizer: add assert(_settings) to Tokenizer to insure the tokenizer always has settings. Ticket: #2219 2010-12-01 18:00:55 +01:00