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
9dae536ce3
Little tweaks to Token::Match code.
2012-11-25 15:20:50 +01:00
Edoardo Prezioso
e0c10efdce
Add a 'prepend' bool option to Token::InsertToken.
...
If it's true, add a new token before this. Except when this is the first one in the list, because there's not a way to update the list.front (I noticed some Token functions can potentially delete the list.front(), I don't know which effects does it cause).
2012-11-20 02:58:19 +01:00
Edoardo Prezioso
fdeacbaec6
Enhance style and code to Token::Match function.
2012-11-20 00:19:57 +01:00
Edoardo Prezioso
39bd31b44c
Improve comment style in token.cpp.
2012-11-19 16:30:07 +01:00
Daniel Marjamäki
7ecfb189a2
astyle formatting
2012-11-18 15:04:45 +01:00
Edoardo Prezioso
9d0a295b85
Partially fixed #4288 (handle %var%|%num% patterns).
2012-11-17 20:51:18 +01:00
PKEuS
4ea2df8671
Changed handling of type wchar_t:
...
- Don't simplify wchar_t to unsigned short on Win32 platforms to ensure that checking of strings and nullpointer dereferences works.
- Added it as standard type
2012-11-11 14:47:16 +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
PKEuS
a748678636
Removed redundant nullpointer checks in token.cpp
2012-09-09 14:34:07 +02:00
Ankita-gupta
ff7373f46f
Fixed bug in Token::Match ( #3720 )
2012-08-30 13:33:19 +02:00
PKEuS
2ab33ef21b
Added Pointer to enclosing scope to class Token (Only available when symboldatabase is created).
2012-08-11 11:47:11 -07:00
PKEuS
5e862351e9
Improvements in token.cpp:
...
- Shortened stringify output - 4 or more subsequent empty lines are abbreviated
- Fixed detection of comparision operators
- Make use of _type: Replaced three asserts by one
2012-08-02 11:36:54 -07:00
Daniel Marjamäki
f82e5396c8
Fixed #3999 (Error incorrectly written in XML format)
2012-07-25 06:43:54 +02:00
Edoardo Prezioso
fae40c4782
Change every C version of 'size_t' to C++ 'std::size_t'.
2012-07-09 13:30:18 +02:00
Daniel Marjamäki
edea4ef131
Refactoring: Renamed CheckNullPointer::isPointer to Token::isUpperCaseName
2012-06-21 19:00:53 +02:00
Zachary Blair
2bd171dded
Fixed #3794 (New check: Missing break in switch (duplicate bitwise operation))
2012-05-28 21:19:22 -07:00
Edoardo Prezioso
eacf74be8d
Changed the order of some structures in order to improve, even if for a bit, their padding.
2012-05-14 20:49:03 +02:00
Edoardo Prezioso
bc8de44ddd
Fixed one of the warnings with GCC: variable shadows a member of Token class.
2012-04-27 02:41:46 +02:00
Ettl Martin
bb8342fbb4
fixed misspelled word 'Comparision' --> 'Comparison'
2012-04-26 23:04:55 +02:00
PKEuS
dee5568853
Fix bug in class Token that causes recently added modulo-check to fail.
2012-04-26 16:39:16 +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
bac8ed7127
Refactorized stringification of tokens:
...
- Function that stringifies one token: Token::stringify()
- Functions that stringify a list of tokens: Token::stringifyList()
-- Single and powerful "base" function, used by several "light" functions
Refactorized
- testtokenize.cpp and testsimplifytokens.cpp: Use improved stringification functions instead of several local implementations
- Avoided redundand creation of std::string when using TestTokenizer::tokenizeAndStringify and in cmdlineparser.cpp
2012-04-16 19:51:07 +02:00
PKEuS
8cb904feaa
Refactorizations in class Token:
...
- Added support for < and > in nextArgument()
- Made isStandardType inline by writing its implementation to token.h (like other bool is*() functions)
- Made firstWordEquals return bool instead of integer (only 0 and 1 were returned)
- Use std::string::empty() instead of operator==(""); Use character literals instead of string literals for single characters printed.
2012-04-16 15:28:38 +02:00
Daniel Marjamäki
1d95416840
astyle formatting
2012-03-25 11:51:59 +02:00
Edoardo Prezioso
28431da0ae
Nitpicky style change: use 'for(;;)' construct instead of 'while(true)' in the code.
2012-03-24 21:50:09 +01:00
PKEuS
df0cb89a40
Fixed compiler error
2012-02-13 18:48:44 +01:00
PKEuS
bb319c1c96
Improved Tokens and Tokenizer:
...
- Better handling of deleteThis() as last element of token list
- Code simplified
2012-02-13 17:44:08 +01:00
Edoardo Prezioso
6cac600d37
Token::replace: Little style change.
2012-01-22 00:03:33 +01:00
Edoardo Prezioso
3a2ba173ac
Token::move|replace: update progressValues correctly.
2012-01-21 21:06:30 +01: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
PKEuS
38ddcde7b0
- Refactorizations in preprocessor.cpp and tokenizer.cpp
...
- Bugfix: tok->stringify(tok) returns now "".
- Removed most of the inline-asm handling in preprocessor; improved the remaining handling of #asm/#endasm: Simplified to "asm(...);" statement
2012-01-02 12:58:34 +01:00
PKEuS
064e0ea0d0
Revert "- Refactorizations in preprocessor.cpp and tokenizer.cpp"
...
Committing with subversion seems to have issues. Sorry for that. I'll the changes again, now using git.
This reverts commit 69498de6ca
.
2012-01-02 12:10:53 +01:00
Philipp K
69498de6ca
- Refactorizations in preprocessor.cpp and tokenizer.cpp
...
- Bugfix: tok->stringify(tok) returns now "".
- Removed most of the inline-asm handling in preprocessor; improved the remaining handling of #asm/#endasm: Simplified to "asm(...);" statement
2012-01-02 03:15:02 -08:00
Reijo Tomperi
8cae17fda8
Update year to 2012
2012-01-01 01:05:37 +02:00
Daniel Marjamäki
2bb5de4c89
Fixed #3425 (False positive: Null pointer dereference (pointer is checked in macro))
2011-12-18 13:33:23 +01:00
PKEuS
c9f5117cf5
Fixed #3407 (False positive: (inconclusive) Found duplicate branches for if and else. (inline assembler))
2011-12-13 21:42:38 +01:00
Edoardo Prezioso
4de5d87078
1)Remove newly copy of 'eraseTokens' and replace every occurrence with 'deleteNext' with right parameter.
...
2)General improvements to code.
2011-12-08 01:44:18 +01:00
Edoardo Prezioso
76972e8dd3
Extend 'Token::deleteNext' by introducing a new parameter which determines how many tokens should be deleted. It's still not used, though.
2011-12-07 23:36:11 +01:00
PKEuS
1c1c31bea0
Tokenizer: Refactorings and improvements. Better handling of []
2011-12-07 21:15:00 +01:00
Edoardo Prezioso
612b3c59ca
1)Implement another declaration of 'Token::eraseTokens' with parameters: the starting token and the number of times needed to call 'deleteNext'.
...
2)Use the overloaded 'eraseTokens' where needed instead of using consecutively 'deleteNext'.
3)Tokenizer: general optimizations about the deletion of some tokens.
4)Run astyle.
2011-12-07 02:29:03 +01:00
Daniel Marjamäki
2e08c8c5b1
DJGPP: Fixed a few compiler errors by using std::size_t instead of size_t
2011-11-22 21:14:14 +01: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
Edoardo Prezioso
ccdb18f213
Add a sanity check and an error message to linkAt when the index is outside the tokens range.
2011-11-19 13:34:36 +01:00
Thomas Jarosch
a645235d5a
Adapt Token::strAt() to return a const reference like Token::str() does
...
Saves us a complete conversion from string.c_str() back to std::string.
2011-11-14 09:19:46 +01:00
Edoardo Prezioso
2aceb623ae
1)Add 'Token' function 'linkAt', which simplifies the writing 'tokAt(i)->link()' to 'linkAt(i)'.
...
It's still unused, though.
2)Fix one grammatical mistake inside token.h
3)Style change to token.cpp: remove the whitespace between '!' and 'begin'.
2011-11-11 21:55:37 +01: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
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
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
9903c8c0d9
astyle formatting
2011-11-05 20:00:18 +01:00
Daniel Marjamäki
2f32965bdf
Token: assert that multicompare patterns don't begin with some %% command
2011-11-05 19:59:48 +01:00
Daniel Marjamäki
5edf153602
Fixed #3294 (Token::Match multi compare false negative)
2011-11-05 19:24:21 +01:00
Reijo Tomperi
682aae3196
Improve internal error print out, print line number with the error message.
2011-11-03 22:43:13 +02:00
Edoardo Prezioso
979f3b051c
Improve nextArgument by returning 0 if there's an unexpected ';'.
2011-10-28 18:57:10 +02:00
Thomas Jarosch
434fb933a8
Implement Token::findsimplematch und use it for simple patterns
2011-10-27 15:59:22 +02:00
Edoardo Prezioso
df5d26901c
Add new warning option to check for dead code and change the order of some struct members to reduce structure padding.
2011-10-24 03:02:00 +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
Johan Samuelson
889c407f58
Fixed #3118 (Tokenizer: str*cmp() in hot spot code)
2011-09-20 19:03:19 +02:00
Robert Reif
daf0c71f77
fix #2911 (Token::Match(tok, %oror%|&&) doesn't match &&)
2011-07-31 13:26: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
66d145ba1c
Fixed #2892 (false positive: (portability) Assigning an address value to the integer (int/long/etc) type is not portable)
2011-07-07 15:14:33 +02:00
Martin Exner
2b08744b97
Fixed #2676 (setVarId: variables with global scope qualification :: don't get varids)
2011-04-18 06:56:39 +02:00
Daniel Marjamäki
58dbbb0cab
Inconclusive checking: Report inconclusive errors with reportInconclusiveError. It takes the same parameters as reportError.
2011-04-14 18:02:01 +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
Zachary Blair
f89f0c748f
Fixed #2665 (Slightly sped-up how Token::Match() parses patterns)
2011-03-22 00:15:12 -07:00
Robert Reif
d74ae3b0f0
copy all flag fields in a Token
2011-03-07 20:04:25 -05:00
Reijo Tomperi
226b605774
Change year 2010 -> 2011 in license texts.
2011-01-09 21:33:36 +02:00
Zachary Blair
26afb04dc5
Fixed #2105 (Incorrect operator: mutual exclusion over ||)
2010-10-24 18:14:21 -07:00
Pete Johns
50c2fa9ab0
Revert "Fixed #1132 (Detection of misused scope objects)"
...
This reverts commit c6acdccfa0
.
2010-10-01 20:52:16 +10:00
Pete Johns
c6acdccfa0
Fixed #1132 (Detection of misused scope objects)
...
Emits error in the form:
[useless_lock.cpp:18]: (error) instance of "Lock" object destroyed immediately
...if an instance of a class or struct is unnamed and therefore destroyed
straight after creation.
Removed "internal error" from token.cpp, since in this case varid would be NULL.
2010-10-01 20:30:21 +10:00
Daniel Marjamäki
7e954ebb57
Optimisation: optimised Token::Match
2010-09-20 20:15:07 +02:00
Daniel Marjamäki
78e13f098e
Refactorings: Optimised the Token::multiCompare function
2010-09-19 15:14:13 +02:00
Robert Reif
807269b5e9
Refactoring handling of microsoft types. Ticket: #1956
2010-08-22 21:53:45 +02:00
Robert Reif
cb7b508f77
Tokenizer::simplifyBitfields: fixed more issues. Ticket #1956
2010-08-22 13:25:47 +02:00
Daniel Marjamäki
195b48e81f
astyle formatting
2010-08-08 18:55:15 +02:00
Daniel Marjamäki
1d79c164c4
Optimisation: Optimised firstWordEquals
2010-08-08 18:54:49 +02:00
Daniel Marjamäki
adc47f1820
Fixed #1487 (fix gcc compiler warnings)
2010-08-06 21:02:43 +02:00
Daniel Marjamäki
9edecd4a3f
Added ErrorLogger::reportProgress and removed ErrorLogger::ReportProgress. This will make it easier for GUI and other clients to display progress information.
2010-08-03 16:36:21 +02:00
Robert Reif
0bb07e6947
Create a symbol database
2010-07-26 16:46:37 +02:00
Daniel Marjamäki
dfbdd8f9c4
Refactoring Token::Match: Report errors through ErrorLogger. Ticket: #1839
2010-07-24 10:51:17 +02:00
Robert Reif
ee7ad272d6
variable usage: fix false positives when __attribute__ is used. Ticket: #1792
2010-06-16 18:04:31 +02:00
Robert Reif
98ae660260
Fixed #1792 (false positive: Variable 'test' is assigned a value that is never used)
2010-06-14 15:46:57 +02:00
Daniel Marjamäki
b9d8f52cca
CheckBufferOverrun: Fixed false positives caused by refactorings
2010-04-22 19:22:23 +02:00
Daniel Marjamäki
c718a7c595
astyle: Update to astyle 1.24
2010-04-15 20:08:51 +02:00
Reijo Tomperi
35d2a27b9c
Update copyright year in all source files
2010-04-13 22:23:17 +03:00
Reijo Tomperi
6dc3860ae9
Fix more -Wshadow compile warnings
2010-04-09 22:40:37 +03:00
Daniel Marjamäki
1d1d79a1e5
Cleanup: Removed unused %name% cmd for patterns
2010-04-02 20:25:13 +02:00
Daniel Marjamäki
0cad22314e
Reverted 'astyle fix'. Those changes are not in sync with my astyle configuration/setup.
2010-04-02 07:30:58 +02:00
Martin Ettl
193aa7d1d3
astyle fix
2010-04-02 02:21:53 +02:00
Robert Reif
ef57d01f7a
Fixed #1492 (false negatives: array index out of bounds)
2010-03-31 17:14:49 +02:00
Robert Reif
62d2845014
Fixed #1492 (false negatives: array index out of bounds)
2010-03-28 15:56:13 +02:00
Daniel Marjamäki
9394816fcf
Refactoring: Use std::string instead of const char *
2010-02-14 19:58:17 +01:00
Reijo Tomperi
ba00e031c0
Added %name% pattern to Token.
...
Currenly same as %var%, but in the future %var% is supposed to match only tokens that have varid != 0.
2010-02-12 23:40:05 +02:00