Commit Graph

89 Commits

Author SHA1 Message Date
Mark de Wever d6db261213 Fixed #5827 (Invalid token match patterns) 2014-05-19 06:31:38 +02:00
PKEuS 7e4081f7f5 Treat syntaxError and cppcheckError as InternalErrors (throw as exception, #4268) 2014-03-27 13:15:21 +01:00
Daniel Marjamäki 23efc68dd7 use nullptr 2014-02-16 10:32:10 +01:00
Daniel Marjamäki fd3a8a2a18 Update copyright 2014-02-15 07:45:39 +01:00
orbitcowboy b6d7e797a2 Testtoken:matchNumeric(): extended testing about some missing testcases. 2013-09-30 15:55:36 -07:00
Martin Ettl 4cc153a6f3 Fixed #5032: fix wrong unittest case in testtoken::matchNumeric. 2013-09-21 17:40:18 +02:00
PKEuS a9a5dc0354 Updated to AStyle 2.03, require this version 2013-08-07 16:27:37 +02:00
Daniel Marjamäki 2a78db4c06 Refactoring Token::findClosingBracket. 2013-07-31 10:30:20 +02:00
Alexander Mai 14fc140592 Fixed memory leaks in teststl 2013-04-07 18:43:18 +02:00
Ettl Martin ba8cca8fa9 #4706 fix crash when a struct member is used as first argument. Replaced Token::nexArgument with %any% in Token::Match call. Added unittests in testing Token::nexArgument. 2013-04-04 15:12:18 +02:00
PKEuS 14feaa8d39 Refactorizations:
- Fixed lots of cppcheck messages about functions that can be const or static
- Fixed possible nullpointer dereference message in symboldatabase.cpp
- Replaced tokAt(+-1) by next()/previous()
2013-03-12 07:42:00 -07: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
PKEuS 670c4de8a9 Changed behaviour of Token::is*Op() functions:
- Rename Token::isOp() to Token::isConstOp() (indicating that the operator does _not_ modify the input variables)
- Create new Token::isOp(), returning true also for ++, -- and assignment operators
- Make Token::isExtendedOp() returning also true for all assignment and ++/-- operators
2013-02-28 12:50:29 -08:00
Andrew C. Martin bd0d9b9639 fix misspellings & gcc v3.4.6 warnings
1.  fix typos / misspellings
 - Fix misspelling within comments, variable/function names, stdout messages
 - changes the name of an error code: ```stlBoundries``` changed to ```stlBoundaries```.  Alias old name (```stlBoundries```) to the new one.

2.  fix gcc v3.4.6 32bit & 64bit warnings

 - fixes gcc v3.4.6 warnings, except for those in tinyxml and "-Wmissing-declarations" makefile warnings
 - in Preprocessor::handleIncludes(), replace a ```vector <bool>``` with ```stack<bool>``` (see ```vector<bool>``` warning below).
   - this is the only ```vector<bool>``` in the codebase
 - ```vector <bool>``` is actually a case of template specialization, and is not recommended, according to the following links:

http://stackoverflow.com/q/6461487
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2160.html
http://stackoverflow.com/q/670308

 - in the codebase before and after this change, testrunner SEGVs in a number of places on gcc v3.4.6, including ```Check::~Check()```, among others
   - fc42fc95 fixes this particular runtime issue for DJGPP & __sun
2013-02-09 23:43:09 -07:00
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