PKEuS
c20adf91bf
Moved simplification of wide character string literals (L"foo") to tokenize(). Token::isLong flag used to indicate that string is a wchar_t literal.
2012-09-01 13:12:47 +02:00
Daniel Marjamäki
15bc552b37
Tokenizer: Fixed possible NULL pointer dereference
2012-09-01 10:11:18 +02:00
Daniel Marjamäki
a8d419820b
Tokenizer: removed unused variable
2012-09-01 09:57:48 +02:00
Edoardo Prezioso
0d26a79f2c
Tokenizer::simplifyEmptyNamespaces: new function.
...
It removes from the token list, if found, the following tokens: 'namespace %var% { }'. It won't involve C code.
2012-08-28 22:40:25 +02:00
PKEuS
bbce79d7b3
Small refactorization: Handle std::map more efficient in setVarIdStructMembers()
2012-08-28 12:57:11 +02:00
PKEuS
ea85dd305a
Fixed #4086 : Set varId in initialization list.
2012-08-28 12:44:40 +02:00
PKEuS
4bab7f0ee2
Removed unused and obsolete functions Tokenizer::getParameterName() and Tokenizer::getNameForFunctionParams()
2012-08-26 16:53:40 +02:00
PKEuS
662b0d2dbe
Simplify 0[foo] to *(foo) ( fixes #4083 )
2012-08-26 10:03:05 +02:00
Daniel Marjamäki
f127728582
Enable --std=c11 and --std=c++11 by default
2012-08-25 21:57:45 +02:00
Daniel Marjamäki
985ac662ee
Fixed #4035 (False positive: Memory leak: pTempFile)
2012-08-25 12:00:25 +02:00
Daniel Marjamäki
5051837c1a
Reverted last commit. I pushed it by mistake.
2012-08-25 11:00:51 +02:00
Daniel Marjamäki
5e1ccfaf90
Fixed #4035 (False positive: Memory leak: pTempFile)
2012-08-25 10:55:20 +02:00
PKEuS
f238f3fad5
Support sizeof in preprocessor directives
...
Applied "patch" provided by michaeln123 in #4071
2012-08-22 17:28:06 +02:00
PKEuS
43e01a2b1a
Ran AStyle, removed redundant tokAt(0)
2012-08-22 16:51:44 +02:00
SAndeep
0600b0be8f
sprintf changes
2012-08-22 16:46:14 +02:00
Daniel Marjamäki
9ffc7f4c2d
Fixed #3964 (False positive: Expressions in array declarations are not simplified 'char mac[17+1];')
2012-08-20 18:10:32 +02:00
Daniel Marjamäki
7786e12ba2
Fixed #3922 (false positive: (error) null pointer dereference)
2012-08-18 22:11:48 +02:00
Daniel Marjamäki
6a5cc4727d
Fixed #4019 (false positive: (style) Variable 'dest' is assigned a value that is never used)
2012-08-17 16:37:25 +02:00
PKEuS
35d94c26d5
Changed creation of SymbolDatabase. Database always created after Tokenizer::tokenize() and Tokenizer::simplifyTokenList() instead of on-demand creation by Tokenizer::getSymbolDatabase.
...
-> With Token::scope() it is possible to access the symboldatabase without having to call getSymbolDatabase(). The change increases safety because it is guaranteed that the database is available in all checks, even if the specific check doesn't call getSymbolDatabase
- Tokenizer::_symbolDatabase does no longer have to be mutable -> Increased const correctness
The change above required two additional changes:
- A bug causing a debug message was fixed in the symboldatabase that became visible in the test suite by the change above.
- Simplify expressions like "struct struct Foo" which might be result of typedef instanciation.
2012-08-12 03:01:24 -07: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
45bad7d1b2
Refactorized tokenizer:
...
- Don't run setVarId() twice, keep old varId's while/after simplifyTokenList
-> Modified two test cases in testmemleak.cpp. I consider this to be safe. Feel free to investigate this.
- Fixed two nullpointer issues shown by cppcheck
Ran Astyle on teststl.cpp
2012-08-10 09:31:22 -07:00
Edoardo Prezioso
1d8240356b
Really fixed #4024 . Now the simplification won't be done on non-executive scopes.
2012-08-10 17:43:09 +02:00
Daniel Marjamäki
0254344df5
Tokenizer::simplifyEnum: Reverted refactorings/optimisations as there were regressions ( #3949 , #3950 , #4025 )
2012-08-10 14:06:24 +02:00
Edoardo Prezioso
d68d035e22
Tokenizer::simplifyFlowControl: separated the 'throw' case because it's not a reserved keyword in C, hence the function shouldn't simplify in C source files.
2012-08-07 19:38:51 +02:00
Daniel Marjamäki
735c0f5f6b
Fixed #3963 (segmentation fault of cppcheck (invalid typedef code))
2012-08-07 16:39:41 +02:00
Edoardo Prezioso
9e916eec66
Fixed #4024 (Tokenizer::simplifyFlowControl removes pieces of code inside a class if 'exit' is a member function).
2012-08-07 10:59:27 +02:00
Daniel Marjamäki
5ee7758a83
Fixed #4015 (segmentation fault of cppcheck (enum))
2012-08-06 16:21:21 +02:00
Daniel Marjamäki
25fd841b5d
Tokenizer: removed redundant include
2012-08-05 16:06:20 +02:00
PKEuS
452f95cea0
More robust template detection in clarifyCondition check based on Token::link. ( #3818 )
...
Create links between < and > only on non-C code.
AStyle fix
2012-08-02 04:03:01 -07:00
PKEuS
c8e40773f1
Fixed cppcheck messagesa about functions that can be const/static:
...
- Made Tokenizer::getErrorMessages static - Avoids creation of unnecessary instance of Tokenizer
- Changed Tokenizer::removeExceptionSpecifications to common style for simplification functions. In contrast to the comment, this function doesn't call itself recursivly - fixed comment.
- Made Tokenizer::IsScopeNoReturn static.
2012-08-01 12:04:47 -07:00
Ettl Martin
98d608231d
spelling fixes
2012-07-31 23:35:56 +02:00
PKEuS
1ec3c9f634
Fixed hang in libreoffice code (simplification of K&R style function declaration tried to simplify a function with parameters without name whose implementation contained "; {".
...
Test cases of this simplification only need basic simplifications done in Tokenizer::tokenize
2012-07-29 06:11:48 -07:00
Daniel Marjamäki
1a6f7ea9a0
Fixed #3998 (Tokenizer::simplifyEnum: wrong handling of expressions => crash)
2012-07-26 11:12:28 +02:00
Ville Skyttä
7ab2f6a9fa
Spelling fixes.
2012-07-21 18:11:20 +02:00
Daniel Marjamäki
a96ec0ad46
Fixed #3804 (False positive: Member not initialized (simplifyTokenList removes const on pointers))
2012-07-16 07:28:59 +02:00
PKEuS
e9182f1fcc
Implemented support for 'using namespace std;': Add std:: prefix to names that are known to be in std namespace. Simplify namespace (std::)tr1:: if C++11 flag is set.
2012-07-15 02:05:19 -07: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
bf98e952c1
Fixed #3927 (false positive: (error) Uninitialized variable: new)
2012-07-08 13:59:00 +02:00
Daniel Marjamäki
49198f52c4
Fixed #3934 (False positive for logical conjunction with enum and define)
2012-07-07 15:34:26 +02:00
Daniel Marjamäki
543ccdd4c0
Removed simplifyEnum timer that I didn't intend to include in the previous commit.
2012-07-06 15:48:51 +02:00
Daniel Marjamäki
6ad5fc8456
Refactoring Tokenizer::simplifyEnum. The enum handling is now somewhat faster since all enum values of a enum are simplified at the same time.
2012-07-06 15:43:50 +02:00
Thomas Sondergaard
f72ddbb2e9
Fixed #3912 (Analysis failed)
2012-07-03 06:34:14 +02:00
Daniel Marjamäki
bb9f114d84
Fixed #3924 (False positive: Uninitialized variable (const pointer))
2012-06-30 12:12:36 +02:00
Daniel Marjamäki
8af044255d
Tokenizer: Added new function isFunctionParameterPassedByValue that check if a parameter is passed by value
2012-06-24 13:40:09 +02:00
Daniel Marjamäki
edea4ef131
Refactoring: Renamed CheckNullPointer::isPointer to Token::isUpperCaseName
2012-06-21 19:00:53 +02:00
Daniel Marjamäki
974225626d
Fixed #3901 (false positive: (error) Uninitialized variable: temp)
2012-06-19 20:07:39 +02:00
Daniel Marjamäki
4b6e1c6946
Fixed #3855 (false positive: (error) Instance of 'locale' object destroyed immediately)
2012-06-13 19:21:20 +02:00
August Sodora
90f92250dd
Fixed #3618 (segmentation fault of cppcheck)
2012-06-12 21:07:17 +02:00
Daniel Marjamäki
54a66391d8
Fixed #3750 (false positive: C-style pointer casting)
2012-06-12 18:45:31 +02:00
seb777
5b763a9f0a
Fixed #3579 (object destroyed immediately:False positive & negative)
2012-06-10 21:52:32 +02:00
August Sodora
e146591b5d
Fixed #3544 (segmentation fault of cppcheck)
2012-06-02 16:15:12 +02: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
Daniel Marjamäki
5b0551054a
varid: better templates handling
2012-05-22 18:58:13 +02:00
PKEuS
a9cfe2814a
Made some functions const according to cppcheck results
2012-05-17 02:54:17 -07:00
PKEuS
4bb2a1b27b
Made some functions static or const according to cppcheck results
2012-05-17 01:33:24 -07:00
Daniel Marjamäki
505aa6e4cc
TestSimplifyTokens::enum29: Fixed crash
2012-05-16 21:39:26 +02:00
Daniel Marjamäki
0bb0fdedc2
Fixed #3747 (False 'boolean result in bitwise' message with 'mask' enums)
2012-05-16 18:48:33 +02:00
PKEuS
0157f937bf
Fixed #3760 : Added explicit to C++ keyword list in setVarId
...
Made some constant arrays static
2012-05-16 01:59:52 -07:00
Daniel Marjamäki
4ae8e4f382
Tokenizer::setVarId: Minor fix of sizeof handling
2012-05-15 18:40:24 +02:00
Daniel Marjamäki
a0e5fad6a9
Fixed #3776 (Tokenizer::setVarId: No varid set when unknown macro is used before variable declaration)
2012-05-15 07:17:31 +02:00
Daniel Marjamäki
62f9875f90
Fixed #3799 (Bug: Function gets varId)
2012-05-13 07:55:35 +02:00
Daniel Marjamäki
8236cd4d50
Fixed #3785 (false positive: (style) Variable 'dinv' is assigned a value that is never used)
2012-05-08 12:04:54 -07:00
Daniel Marjamäki
99a29eafc9
Fixed #3691 (Tokenizer::simplifyKnownVariables: continue in switch)
2012-05-07 12:11:23 -07:00
PKEuS
28f6e2f4a9
Resolved cyclic dependency between Tokenizer and TemplateSimplifier
2012-05-06 01:38:55 -07:00
PKEuS
f105bf75a6
Refactorizations in ErrorLogger:
...
- Implemented constructor for ErrorLogger::ErrorMessage that takes a callstack of tokens -> replaced duplicate code in Check and Tokenizer
- Implemented strigify() for ErrorLogger::ErrorMessage::FileLocation to replace two identical implementations of it.
2012-05-06 01:17:15 -07:00
PKEuS
1a5fbd61d2
Splitted class TokenList from Tokenizer
2012-05-05 09:33:26 -07:00
Daniel Marjamäki
11614021e8
Fixed #3768 (Tokenizer::setVarId: no varid for 'std::string' parameter after a 'std::string' parameter called 'string')
2012-05-05 09:59:43 +02:00
Daniel Marjamäki
119b24e363
Fixed #3756 (False positive: uninitvar in malloc)
2012-05-03 19:10:51 +02:00
Edoardo Prezioso
5d6a257c86
Fixed #3770 (Segmentation fault in K&R function parameters simplification)
2012-04-29 12:58:52 +02:00
Daniel Marjamäki
df6f88b4fe
Fixed #3755 (Tokenizer::setVarId: improve varid inside class for struct/class variables)
2012-04-26 18:38:47 +02:00
PKEuS
1e708e10d0
Fixed #2875
2012-04-26 10:35:40 +02:00
Daniel Marjamäki
f84a4344ae
Fixed #3754 (Tokenizer::simplifyKnownVariables: wrong for loop simplification)
2012-04-25 19:23:17 +02:00
Edoardo Prezioso
08ae15e42d
Fixed the grammar in some reportError messages in the Tokenizer class, thanks to kimmov's suggestion.
2012-04-25 15:09:46 +02:00
PKEuS
dd5e9aa454
Make use of recently implemented Token::type() functionality
2012-04-25 09:56:07 +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
8cbed66089
Changed relationship between templatesimplifier and tokenizer:
...
- Pass a tokenizer to templatesimplifier to reduce code duplication (Make use of Tokenizer::reportError; remove redundant TemplateSimplifier::addtoken2) and amount of arguments passed to functions
Removed ctor and dtor implementation from TemplateSimplifier: This class shouldn't be instanciated.
2012-04-23 20:45:36 +02:00
Daniel Marjamäki
6ae135124e
Tokenizer::setVarId: better handling of initializer lists
2012-04-23 18:26:27 +02:00
Daniel Marjamäki
706631f527
Fixed #3748 (False positive out of bounds with postincrement)
2012-04-22 12:22:49 +02:00
Daniel Marjamäki
d5f6cfcfa8
Tokenizer: Use new setVarId function. Removed the old one.
2012-04-22 11:36:31 +02:00
PKEuS
3d2b5a30fe
Implemented generic reportError functions in tokenizer (similar to Check::reportError) to reduce code duplication
2012-04-22 11:28:46 +02:00
Daniel Marjamäki
8c8c9d5e5b
Tokenizer::setVarIdNew: don't treat '(sizeof *p)' as a variable declaration
2012-04-22 11:06:56 +02:00
Daniel Marjamäki
d63093d9bb
Tokenizer::setVarIdNew: Fixed issue found through TestUnusedVar tests
2012-04-22 10:59:58 +02:00
Daniel Marjamäki
871823e9c6
Tokenizer::setVarId: fixed problem for classes with inheritance
2012-04-22 10:38:06 +02:00
Daniel Marjamäki
e39b7f1bfd
Tokenizer::setVarIdNew: Fixed TestTokenizer::varid38
2012-04-22 10:24:19 +02:00
Daniel Marjamäki
e745d971c8
Tokenizer::setVarIdNew: Fixed test case TestTokenizer::varid27
2012-04-22 10:19:29 +02:00
Daniel Marjamäki
b4ffb5e0cf
Tokenizer::setVarIdNew: Fixed TestTokenizer::varid39 test case
2012-04-22 09:51:00 +02:00
Daniel Marjamäki
ed6673a9aa
Tokenizer::setVarIdNew: Fixed TestTokenizer::varid44
2012-04-22 09:18:27 +02:00
Daniel Marjamäki
71050bc586
Tokenizer::setVarIdNew: fixed TestTokenizer::varid_in_class2 test case
2012-04-22 08:51:19 +02:00
Edoardo Prezioso
be5a61b794
Fixed ticket #3721 (false positive: syntax error on valid C code ( K&R function style )).
2012-04-22 01:56:40 +02:00
Daniel Marjamäki
6d9b4a8032
Tokenizer::setVarIdNew: Fixed TestTokenizer::varid_operator test case
2012-04-21 19:29:24 +02:00
Daniel Marjamäki
1cc256339c
Tokenizer::setVarIdNew: Fixed TestTokenizer::varid19 test case
2012-04-21 18:22:18 +02:00
Daniel Marjamäki
42a95c9202
Tokenizer::setVarIdNew: Fixed segfault when using new setVarId on invalid code
2012-04-21 18:02:26 +02:00
Daniel Marjamäki
bd60dd46d0
Tokenizer::setVarIdNew: handle special case when there is an unknown macro. Ticket #2638
2012-04-21 17:57:20 +02:00
Daniel Marjamäki
b86295fbcd
Tokenizer::setVarIdNew: Improved C++ handling. All the TestTokenizer::varidclass?? tests pass now.
2012-04-21 17:25:44 +02:00
Daniel Marjamäki
6071a5afc3
Tokenizer::setVarIdNew: Fixed varidclass9
2012-04-21 13:39:43 +02:00
Daniel Marjamäki
85b470c41b
Tokenizer::setVarIdNew: Better C++ handling (varidclass5 and varidclass13)
2012-04-21 13:11:30 +02:00
Daniel Marjamäki
1492d8990f
Tokenizer::setVarId: better C++ handling
2012-04-19 20:58:52 +02:00
PKEuS
6a37c36ee8
Fixed #3741
...
Removed redundant nullpointer check (cppcheck catch)
2012-04-18 16:35:04 +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
Daniel Marjamäki
bb4184ca03
Tokenizer::setVarIdNew: better handling of class variables
2012-04-17 19:06:00 +02:00
Ettl Martin
09d41b2f84
ticket 2669: added todo testcase
2012-04-17 00:31:32 +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
Daniel Marjamäki
5ad1840120
Tokenizer::setVarIdNew: Copied code from Tokenizer::setVarIdOld that sets varid in member functions
2012-04-16 19:48:58 +02:00
PKEuS
1c3c94dc67
New simplification: Remove 'extern "C"' from C++ code.
...
Refactorization in cppcheck.cpp: Catch exception as const reference instead of non-const reference.
2012-04-16 16:25:04 +02:00
PKEuS
66d947675f
Refactorizations in tokenize.cpp:
...
- Removed a few indendation counters
- Removed unnecessary pattern "- >" because this code is simplified to "." before.
- Generalized pattern of simplifyFunctionReturn()
- Simplified removeExeptionSpecification, no longer recursive (-> #3385 )
2012-04-16 10:49:09 +02:00
Daniel Marjamäki
8f866c6e4c
Tokenizer::setVarIdNew: handle c++ keyword 'using'
2012-04-15 18:29:35 +02:00
Daniel Marjamäki
c58d02f146
Tokenizer::setVarIdNew: in C code, allow that variable declaration starts with delete and throw
2012-04-15 18:23:12 +02:00
Daniel Marjamäki
b0dc708b4d
Tokenizer::setVarIdNew: variable declarations dont start with NOT/goto/return/delete/etc
2012-04-15 18:02:49 +02:00
Daniel Marjamäki
46bfe27831
Tokenizer::setVarIdNew: Better handling of function calls
2012-04-15 17:44:51 +02:00
Daniel Marjamäki
31f8a71f84
Tokenizer::setVarIdNew: Better handling for catch-exception-by-reference
2012-04-15 17:39:22 +02:00
Daniel Marjamäki
3c1dfc658c
Tokenizer::setVarIdNew: use the new setVarId with a few more test cases. Improved setVarId: references in executable scopes must be initialized.
2012-04-15 14:32:47 +02:00
Daniel Marjamäki
27c37896a0
Tokenizer::setVarIdNew : use new setVarId function in TestTokenizer::varidReturn2.
2012-04-15 14:19:17 +02:00
Daniel Marjamäki
95dafd30dd
Tokenizer::setVarIdNew : enable more testcases. better handling of unions and struct members.
2012-04-15 13:42:13 +02:00
Daniel Marjamäki
7669abb170
Tokenizer::setVarId : Starting to rewrite Tokenizer::setVarId. The purpose of the rewrite is to make this function faster.
2012-04-15 11:47:22 +02:00
Edoardo Prezioso
51789d8e20
Fixed ticket #3712 (false positive: syntax error on valid C code ( K&R function style ))
2012-04-13 00:39:40 +02:00
Daniel Marjamäki
23c71daf37
astyle formatting
2012-04-10 13:45:56 +02:00
Daniel Marjamäki
c7093ca5d6
Tokenizer: allow that time is measured for certain slow simplifications
2012-04-10 13:45:34 +02:00
Daniel Marjamäki
6bae724cb6
Fixed #3705 (cppcheck crash (null pointer exception))
2012-04-09 15:06:06 +02:00
Daniel Marjamäki
bbdeebafda
Fixed #3700 (false positive: (style) Variable 'H' is not assigned a value)
2012-04-09 12:55:26 +02:00
PKEuS
25167b58a9
Implemented #2990 : Print relative paths if -rp or --relative-paths is given
2012-04-06 10:49:21 +02:00
Daniel Marjamäki
823fc9ac04
Fixed #3650 (Variable declaration: Doesn't handle template usage well)
2012-04-05 08:53:10 +02:00
Edoardo Prezioso
b90d9c8a19
Make 'const' the new variable 'funcName'.
2012-04-03 22:51:56 +02:00
Edoardo Prezioso
ecc5dea113
Fixed ticket #3703 (false positive: syntax error on valid C-code ( K&R - style )).
2012-04-03 20:12:34 +02:00
Edoardo Prezioso
5d91ef76fe
Fixed ticket #3701 (false positive: syntax error on valid C code ( K&R function style ).
2012-04-03 19:49:58 +02:00
Edoardo Prezioso
af02908d42
Fixed ticket #3580 (syntax error in multi variable declaration header).
2012-03-31 18:45:29 +02:00
Daniel Marjamäki
1309825bf1
Merge pull request #91 from HeisSpiter/e46c7eb32033b520374e9df8c13bc8589c0602d0
...
Handle Rtl memory functions in Tokenizer::simplifyMicrosoftMemoryFunctions()
2012-03-28 09:43:14 -07:00
Pierre Schweitzer
e46c7eb320
Add the RTL memory functions for the simplifications on Windows code.
2012-03-27 21:24:46 +02:00
Daniel Marjamäki
01ddfb6f80
Fixed #3534 (Broken support for dollar signs in identifiers)
2012-03-27 19:35:41 +02:00
Daniel Marjamäki
c07044b3d3
Fixed #3573 (Preprocessor: handle '!(X)' the same as '!X')
2012-03-26 19:01:45 +02:00
August Sodora
fe9d491aae
3619 Check that tok2->next() exists before using
2012-03-25 10:24:29 +02:00
PKEuS
002389f836
Fixed #3677
...
Added forgotten testcase for #3672
2012-03-21 18:40:32 +01:00
Daniel Marjamäki
a2351ba44f
Fixed #3648 (Internal error: Token::Match called with varid 0)
2012-03-20 19:05:24 +01:00
Daniel Marjamäki
d6c8de104c
Revert "Fixed #3648 (Internal error: Token::Match called with varid 0)"
...
This reverts commit 1fa1ddccba
.
2012-03-20 19:00:16 +01:00
Daniel Marjamäki
1fa1ddccba
Fixed #3648 (Internal error: Token::Match called with varid 0)
2012-03-20 18:58:27 +01:00
PKEuS
cb2a754983
Implemented support for C++11 right angle brackets (>>)
...
Implemented support for linkage between < and > (Information: It is possible that under certain circumstances comparision operators are linked, since its sometimes difficult to separate between them.)
2012-03-19 18:45:47 +01:00
PKEuS
7055526f4a
Fixed #3672 : bitwise and operator in if/while does no longer confuse setVarId code
...
Improvements to CheckUnusedVar:
- Improved handling of arrays of struct/class instances
- Differ between addressof and bitwise-and operator
- Made some members private to improve encapsulation
- Replaced some simple patterns by direct function calls
- Removed an unnecessary condition
2012-03-19 17:41:16 +01:00
PKEuS
3af32b0da2
Refactorizations in tokenizer:
...
- getSourceFilePath returns a const reference now
- Replaced some simple patterns by string comparisions/direct function calls
- Replaced a few indendation counters by easier code
- Replaced one offset variable by token pointer to avoid subsequent calls to tokAt with the same number
2012-03-17 11:48:40 +01:00
Daniel Marjamäki
555e8c6efc
Fixed #36221 (Input streams: Wrong token list simplification)
2012-03-15 19:09:36 +01:00
Daniel Marjamäki
a9d56f2738
Tokenizer: simplify known variable value inside conditional block
2012-03-12 17:32:30 +01:00
Daniel Marjamäki
680883a6a7
fixed #3649 (False Positive: Uninitialized variable using operator assignment)
2012-03-06 18:51:50 +01:00
Daniel Marjamäki
527d3791e6
Fixed #3596 (memory leak false positive on libedit sources)
2012-02-27 18:55:36 +01:00
PKEuS
1747813a8b
Added check for invalid pointer casts ( #1255 )
...
Detect sign extension problems when variable is a reference (#3637 )
Refactorizations:
- Tokenizer::getFiles returns a reference instead of a pointer, because its guaranteed that no nullpointer is returned
- Remove signed/unsigned in one step for "%type% signed|unsigned"
- Fixed recently introduced compiler warning in symboldatabase.cpp
2012-02-26 11:56:32 +01:00
Edoardo Prezioso
4d3013d43d
Improve 'Tokenizer::elseif' code in order to not touch 'else if' inside a macro parenthesis.
2012-02-26 02:50:48 +01:00
PKEuS
9431fb1b7e
Improved STL checks:
...
- Added performance checking for .c_str() for return values and function parameters (#1079 )
- Added more containers (basic_string, C++11 containers) and more functions to checking (.at, .resize, .reserve, ...)
- Make use of symboldatabase in missingComparision check
2012-02-25 12:43:27 +01:00
Daniel Marjamäki
39b0f1ba95
Fixed #3608 (unreadVariable when variable used in inline assembly)
2012-02-19 16:04:35 +01:00
PKEuS
b1ff900aaa
Some refactorizations
2012-02-18 23:43:51 +01:00
Edoardo Prezioso
d7a918e549
Fixed ticket #3616 (segmentation fault of cppcheck).
2012-02-18 17:58:50 +01:00
Daniel Marjamäki
a118f82ca7
Tokenizer::simplifyVarDecl: Don't simplify inside parenhteses
2012-02-18 15:05:29 +01:00
Daniel Marjamäki
0705dbd34a
Tokenizer::simplifyCasts: don't simplify 'f((double)(v1)*v2)' to 'f(*v2)'
2012-02-18 14:26:00 +01:00
Edoardo Prezioso
17cd5ec906
Fixed ticket #3604 (cppcheck(1.53) crash).
2012-02-17 21:14:38 +01:00
PKEuS
485e836535
Refactorizations in MathLib.
...
Fixed recently introduced bug on floating point numbers with multiple preceding zeros (for example 004.123)
2012-02-17 19:54:53 +01:00
PKEuS
8ea5df62c4
- Improved support for numbers in code:
...
-- Use MathLib::toLongNumber for conversion in tokenizer (Fix #3610 )
-- Handle octal numbers in tokenizer
- Refactorizations in MathLib::toLongNumber and Settings
2012-02-17 15:47:08 +01:00
Ettl Martin
d8c24c3afc
fixed wrong spelled word.
2012-02-15 22:57:20 +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
Daniel Marjamäki
da8abeb63c
Fixed #3584 (2 internal errors : Token::Match called with varid 0)
2012-02-12 17:30:47 +01:00
Daniel Marjamäki
bbb707c460
Fixed #3587 (Wrong tokenizer simplification - variable assigned by operator>>)
2012-02-07 08:05:50 +01:00
Daniel Marjamäki
2be85e9d37
Fixed #3538 (false positive caused by bad tokenizer simplification)
2012-02-01 21:13:26 +01:00
Edoardo Prezioso
f9ade9562c
Fixed ticket #3572 (segmentation fault).
2012-01-31 22:32:28 +01:00
Edoardo Prezioso
66e1761ffe
Fixed ticket #3571 (segmentation fault of cppcheck while scanning gcc-testsuite).
2012-01-31 18:42:19 +01:00
Edoardo Prezioso
9f81b48dc1
Fixed ticket #3558 (Tokenizer: improve simplifyVarDecl to take count of undefined size VLA's).
2012-01-30 23:41:43 +01:00
Edoardo Prezioso
0fd7504295
Related to ticket #3560 (conditional pointer user): remove also dead code in the lower scope if the actual scope isn't special.
2012-01-30 21:43:23 +01:00
Edoardo Prezioso
11e724df46
Tokenizer::simplifyTypedef: some optimizations on new code.
2012-01-30 17:08:35 +01:00
Edoardo Prezioso
7cd36f44b6
Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': finished.
2012-01-30 16:38:04 +01:00
Edoardo Prezioso
67d095a10e
Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress..
2012-01-30 16:20:15 +01:00
Edoardo Prezioso
7c596a2b90
Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress..
2012-01-30 16:18:42 +01:00
Edoardo Prezioso
187c463475
Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress..
2012-01-30 16:17:57 +01:00
Edoardo Prezioso
b366bf69ad
Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress..
2012-01-30 16:16:08 +01:00
Edoardo Prezioso
fa077ede94
Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress..
2012-01-30 15:08:01 +01:00
Edoardo Prezioso
9438d1c2d0
Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress..
2012-01-30 15:04:41 +01:00
Edoardo Prezioso
fe3fd1a073
Tokenizer::simplifyTypedef: redundant assignment to 'offset'.
2012-01-30 13:33:27 +01:00
Edoardo Prezioso
5a1585dcfb
Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress..
2012-01-30 13:24:31 +01:00
Edoardo Prezioso
d9e9c0aceb
Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': in progress..
2012-01-30 13:15:25 +01:00
Edoardo Prezioso
017f0090fa
Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': begin conversion.
2012-01-30 13:10:50 +01:00
Edoardo Prezioso
e530d770e1
Tokenizer::simplifyTypedef: to be sure there are no problems, promote to 'int' the variable 'offset'.
2012-01-30 13:04:10 +01:00
Edoardo Prezioso
a93af0dba6
Tokenizer:: Use 'link' instead of 'parens' variable.
2012-01-30 12:22:37 +01:00
Daniel Marjamäki
9df6088ddd
Revert "really fix #3527 (Internal error. Token::Match called with varid 0. Please report this to Cppcheck developers)"
...
This reverts commit a37031944e
.
I don't want this hard coding of macro names. Feel free to come with a more generic solution if you want.
2012-01-30 06:15:41 +01:00
Robert Reif
415aaca6dd
Merge branch 'master' of git://github.com/danmar/cppcheck
2012-01-28 20:59:51 -05:00
Robert Reif
a37031944e
really fix #3527 (Internal error. Token::Match called with varid 0. Please report this to Cppcheck developers)
2012-01-28 20:58:51 -05:00
Edoardo Prezioso
fa77f98b1c
Tokenizer: it's possible to set null lower bound for eraseDeadCode when used inside simplifyFlowControl.
...
Remove now unused 'beginindent' and moved 'goto' simplification together with 'return' group.
2012-01-28 21:37:30 +01:00
Edoardo Prezioso
bb703f4d0b
Fixed: (warning) Found simple pattern inside Token::Match() call.
2012-01-28 20:31:12 +01:00
Robert Reif
42afd2d63a
fix #3561 (SymbolDatabase: throw foo; creates a variable with type throw)
2012-01-27 19:24:01 -05:00
Edoardo Prezioso
8289e2428d
Tokenizer: Stylish change to condition.
2012-01-27 17:12:28 +01:00
Edoardo Prezioso
0dd4b9ad3a
Temporary workaround to ticket #3459 (Simplify goto before loop) :
...
don't simplify code which contains the label pointed by 'goto'.
2012-01-27 16:56:12 +01:00
Edoardo Prezioso
6314d04a04
Tokenizer: Add 'BOOST_FOREACH' pattern where it was missing.
2012-01-27 16:47:26 +01:00
Edoardo Prezioso
ca8e8d26c7
Tokenizer: extract realloc simplification and simplify also when each argument is done by more than one token.
...
Restyling of a comment in tokenize.h.
2012-01-27 13:56:06 +01:00
Edoardo Prezioso
421ae9df03
simplifyCondition: handle also '( a || true || b)' -> '(true)' and '( a && false && b)' -> '(false)'.
...
Clarify a comment about previous commit.
2012-01-26 23:14:44 +01:00
Edoardo Prezioso
0f1f3c0f5f
Tokenizer::removeRedundantCondition: refactoring due to various reasons.
...
1) Remove the dead code with 'eraseDeadCode', not with 'eraseTokens' because of the possible presence of labels.
2) It's impossible that in tokenizer there is pattern like 'if (true|false) {code;} else if (cond) {code_cond;}' because the function 'Tokenizer::elseif' adds '{' between 'else' and 'if', hence a code path is redundant, so it's removed from code.
2012-01-26 22:32:11 +01:00
Edoardo Prezioso
b6763313c5
Tokenizer::simplifyQuestionMark: use links instead of indentation level number.
2012-01-26 17:55:22 +01:00
Edoardo Prezioso
6e164ae7ed
Fixed ticket #3557 (Tokenizer: simplification of '[]' doesn't work well):
...
extract undefined size array simplification and handle multiple arrays and combos between pointers and arrays, don't handle the definitions as arguments of function.
2012-01-26 17:25:52 +01:00
Edoardo Prezioso
f428a29d8e
Improve simplifyReturnStrncat when each argument is not composed by one token.
2012-01-26 16:09:32 +01:00
Edoardo Prezioso
b6a0896ce6
Change 'simplifyReturn' to 'simplifyReturnStrncat' because it's not clear what this function does.
2012-01-26 11:49:08 +01:00
Edoardo Prezioso
5953ed7318
Fixed ticket #3528 (Tokenizer: improve simplifyFunctionParameters to take count of square brackets)
2012-01-23 16:10:15 +01:00
Daniel Marjamäki
9eb1a5864b
Fixed #3502 (segmentation fault of cppcheck (struct{x y:};))
2012-01-23 07:39:31 +01:00
PKEuS
36479499e7
- Solved FIXME: Made detection of code that is no pointer-dereference more robust, uncommented code (checknullpointer.cpp)
...
- Removed more indendation level counters
- Make use of symbol database more often
- Other refactorizations
2012-01-21 19:55:32 +01:00
Edoardo Prezioso
b0dac2fa2e
Tokenizer::copyTokens: add optional parameter which preserve the line number differences between tokens to be copied.
2012-01-21 17:18:16 +01:00
seb777
0be8af5214
Fix ticket #3530 (Add some windows data types to tokenizer)
2012-01-18 12:57:41 +01:00
Edoardo Prezioso
9019190a37
Tokenizer: various improvements to code.
2012-01-17 11:51:11 +01:00
Edoardo Prezioso
40739eb3fb
Reverted some changes in commits 4b05c3e19f
and 4b08b13845
.
2012-01-16 11:44:31 +01:00
Edoardo Prezioso
4b05c3e19f
Tokenizer::simplifyIfAddBraces: improve comments; handle independently 'a = { .. };'; reduce use of 'Token::(simple)Match' functions.
2012-01-15 19:53:11 +01:00
Edoardo Prezioso
4b08b13845
Tokenizer: reduce usage of Token::Match in some cases.
2012-01-15 15:00:52 +01:00
Edoardo Prezioso
963f6ce3ef
Tokenizer: report syntaxError if there's nothing after 'if|for|while ()' and if there's nothing inside round brackets;
...
TestTokenizer: change test cases accordingly;
TestSimplifyTokens: ditto.
2012-01-15 14:50:01 +01:00
Robert Reif
6f3807d915
add some more windows types
2012-01-10 21:55:24 -05:00
Reijo Tomperi
be7691c7b4
Refactoring: Move rest of the template simplification into TemplateSimplifier
...
simplifyCalculations() was temporarily moved into TemplateSimplifier also, it should be moved to a better place.
2012-01-09 21:33:11 +02:00
Reijo Tomperi
756b8762ab
Catch InternalError by reference instead of creating a copy of it.
2012-01-09 18:30:36 +02:00
Edoardo Prezioso
2dd53ec966
Fixed ticket #3485 (segmentation fault of cppcheck ( {a:1;}; ))
2012-01-09 16:24:11 +01:00
Edoardo Prezioso
54f54761b4
Fixed ticket #3482 (segmentation fault of cppcheck ( switch(){case} ))
2012-01-09 14:37:20 +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
Reijo Tomperi
3c0ada52e6
Refactoring: Extract sizeof simplifying from template simplifying
2012-01-08 00:21:12 +02:00
Daniel Marjamäki
a5264f6395
Symbol database: dump if --debug and --verbose is given
2012-01-07 08:21:34 +01:00
Reijo Tomperi
2a79399a53
astyle fix
2012-01-06 21:57:59 +02:00
Reijo Tomperi
e91d239ea5
Refactor: Move file extension checks from Tokenizer to Path class. This has also functional change as now also file.JAVA is considered a Java file.
2012-01-06 21:56:28 +02:00
Reijo Tomperi
eda04ad906
Refactoring: Move template code into templatesimplifier: simplifyTemplatesExpandTemplate()
2012-01-05 22:45:19 +02:00
Daniel Marjamäki
56a5e08f6b
Use symbol database dump code written by Robert Reif. The symbol database is dumped if --debug is used.
2012-01-05 18:22:54 +01:00
Edoardo Prezioso
a7029291fd
Tokenizer::simplifyGoto: process also derived class/structs.
2012-01-04 17:08:53 +01:00
Edoardo Prezioso
b0e4dc3ab8
Refactoring: replace forgotten code with function call 'simplifyRedundantConsecutiveBraces'.
2012-01-04 16:47:36 +01:00
Edoardo Prezioso
6f9cd110d0
Improve Tokenizer: improve 'simplifyDoublePlusAndDoubleMinus' when there are negative numbers.
2012-01-04 13:45:27 +01:00
Edoardo Prezioso
75fbe310ff
Extract various functions inside the Tokenizer class and fix tokenization of 'return __LINE__ ;'.
2012-01-04 12:57:58 +01:00
Reijo Tomperi
0369681a2c
Refactoring: Move template code into templatesimplifier: simplifyTemplatesGetTemplateNamePosition()
2012-01-03 23:49:50 +02:00
Reijo Tomperi
ac290b1a8a
Refactoring: Move template code into templatesimplifier: simplifyTemplatesUseDefaultArgumentValues(), simplifyTemplatesInstantiateMatch()
2012-01-03 23:35:06 +02:00
PKEuS
756ee800b0
Use std::stack instead of std::vector Tokenizer::createTokens. Removed #pragma warning(disable: 4503)
2012-01-03 11:46:35 +01:00
Reijo Tomperi
16fb1801e1
Refactoring: Move template code into templatesimplifier: simplifyTemplatesGetTemplateDeclarations(), simplifyTemplatesGetTemplateInstantiations()
2012-01-02 23:05:27 +02:00
Reijo Tomperi
37269d0c28
Refactoring: Move template code into templatesimplifier: simplifyTemplatesExpandSpecialized()
2012-01-02 22:53:13 +02:00
Reijo Tomperi
8084bc80fc
Refactoring: Move template code into templatesimplifier: removeTemplates()
2012-01-02 22:46:43 +02:00
Reijo Tomperi
e9071a8bb6
Refactoring: Move code into templatesimplifier: templateParameters()
2012-01-02 22:43:38 +02:00
Reijo Tomperi
d26bcfe8d5
Refactoring: Move code into templatesimplifier
2012-01-02 22:37:32 +02:00
Daniel Marjamäki
e4f3f91c18
Reverted 9aa8a496
. I don't know why I made this fix.
2012-01-02 19:45:20 +01:00
Edoardo Prezioso
94a2287370
Revert 'using' changes as it was until some time ago.
2012-01-02 19:27:32 +01:00
PKEuS
08805dd9fe
Fixed compiler errors with GCC
2012-01-02 13:10:35 +01: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
Edoardo Prezioso
b24e6e659e
C# simplification: remove 'using var;' code from the tokenizer.
2012-01-02 00:53:20 +01:00
Edoardo Prezioso
eb657034ba
Handle also C# multidimensional arrays with no specified dimension.
2012-01-02 00:22:45 +01:00
Reijo Tomperi
aa927d5aa3
Refactoring: Add new file lib/templatesimplifier.cpp
...
The plan is to move template simplification into this new class to take some lines from 10 000 line tokenizer.
2012-01-01 22:55:05 +02:00
PKEuS
f4703e026a
Refactoring various issues in cmdlineparser, cppcheckexecutor, check64bit and tokenize.
2012-01-01 21:17:16 +02:00
Reijo Tomperi
8cae17fda8
Update year to 2012
2012-01-01 01:05:37 +02:00
Edoardo Prezioso
38e0e25ce0
Fixed ticket #3448 (segmentation fault of cppcheck).
...
Add testcase related to previous commit (add 'A f(&x);' as declaration of variable).
2011-12-31 21:44:07 +01:00
Edoardo Prezioso
b9c796d9f8
- Re-elaborate 'using' keyword skipping in Tokenizer::setVarId and
...
Scope::getVariableList;
- Improve setVarId: add possible declaration: 'A f(&x);' and change from:
'if (...){}else{ continue; };' to: 'if (!...) continue;';
- Little refactoring of 'Tokenizer::removeTokens()'.
2011-12-31 21:36:19 +01:00
Daniel Marjamäki
8a6b1dc1c9
Fixed #3449 (segmentation fault of cppcheck)
2011-12-31 12:08:49 +01:00
Edoardo Prezioso
0d3bf5340d
Improve varId and getVariableList filter, related to previous commit.
2011-12-30 18:13:42 +01:00
Edoardo Prezioso
873572d489
Improve C# simplification code with arrays of arrays.
2011-12-30 12:26:28 +01:00
Edoardo Prezioso
d0a3560c92
Rewrite Tokenizer::hasEnumsWithTypedef by using 'findmatch' in order to shorten the code.
2011-12-30 11:38:18 +01:00
Reijo Tomperi
90e1a397a2
Refactoring: Remove duplicate function from tokenizer: code_is_c() -> isC()
2011-12-29 00:36:16 +02:00
Reijo Tomperi
614c90b156
astyle fix
2011-12-28 23:57:54 +02:00
Edoardo Prezioso
09bfa66536
Always by pressing request, oops.
2011-12-28 22:51:13 +01:00
Edoardo Prezioso
ec0badb651
By pressing request, extract method: simplifyJavaAndCSharp.
2011-12-28 22:44:53 +01:00
Edoardo Prezioso
f9dd927ff4
Move non-C++ simplification outside big loop.
...
Related to commit b2f8161862
.
2011-12-28 22:12:54 +01:00
Reijo Tomperi
0a588496a0
Fix astyle and test failures.
2011-12-28 22:05:10 +02:00
Edoardo Prezioso
b2f8161862
Rewrite fix of ticket #3415 (Segmentation fault in new check for uninitialized variables):
...
new simplify: 'code ; ({ some_code ; });' to 'code ; some_code ;';
remove the sanity check in checkunusedvar, so when it crashes again it's easy to spot a bigger problem;
'internal' reported 'Token::Match' with simple pattern.
'Tokenizer::tokenize()' refactorings:
make one loop with many simple simplifications instead of many loops with one simplification.
some style changes.
2011-12-28 16:55:59 +01:00
Reijo Tomperi
1afd923d34
Fix bug in C# detection code. The test had a bug also, so it was not detected by the test.
2011-12-27 22:50:56 +02:00
Jonathan Neuschäfer
7a5627029f
tokenizer: proper checks for Java and C#
2011-12-27 18:01:39 +01:00
Daniel Marjamäki
91874214d8
Refactoring: Added utility function that determine if scope ends with a call to a noreturn function
2011-12-27 18:00:12 +01:00
Daniel Marjamäki
987392f254
Tokenizer: Better handling of array of function pointers
2011-12-27 11:56:40 +01:00
Daniel Marjamäki
9593e14d72
Removed debug variables
2011-12-27 09:27:46 +01:00
Edoardo Prezioso
293437bdfc
Fixed ticket #3416 (segmentation fault of cppcheck)
2011-12-26 03:21:23 +01:00
Reijo Tomperi
e112bfdd47
Refactoring: Rename some variables and funtions in tokenizer.
...
Small logic change also for count variable to make new name more logical.
2011-12-26 00:06:27 +02:00
Reijo Tomperi
347982a347
Refactoring: Extract several methods from tokenize()
2011-12-24 23:23:08 +02:00
Reijo Tomperi
8e6ebd4a22
Refactoring: Extract method: simplifyDoublePlusAndDoubleMinus()
2011-12-24 22:51:55 +02:00
Reijo Tomperi
6155932207
Refactoring: Rename some variables with too short names, such as "s".
2011-12-24 00:25:03 +02:00
Reijo Tomperi
00cbf02d84
Refactoring: Rename variable used -> templateInstantiations
2011-12-24 00:03:03 +02:00
Reijo Tomperi
70c4bb54b4
Refactoring: Split long function in tokenizer.
...
simplifyTemplatesInstantiate()
2011-12-22 23:13:45 +02:00
Reijo Tomperi
1c12d04d0d
Refactoring: Make a 300 line function a little smaller.
...
simplifyTemplatesInstantiate()
2011-12-22 22:39:15 +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
Daniel Marjamäki
83cdf734fe
Tokenizer: The tokenizer didn't handle '0x0E-7' correctly
2011-12-18 07:37:20 +01:00
Daniel Marjamäki
d21ca7881c
Fixed #3424 (Tokenizer: doesn't tokenize if-if-else-else correctly)
2011-12-17 19:05:14 +01:00
Daniel Marjamäki
6a4b1127aa
astyle formatting
2011-12-14 17:07:06 +01:00
Edoardo Prezioso
40aa326065
Tokenizer: remove redundant 'done' condition, related to ticket #3409 .
...
Add more possible letters to simplifyInitVar patterns.
Replace 'tokAt(1)' with 'next()' and 'linkAt(1)' with 'next()->link()'.
Little optimizing improvements to simplifyAsm.
2011-12-13 22:41:38 +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
81a2e62abd
Tokenizer::simplifyGoto: fix another memory read error reported by Valgrind.
...
Also improvements to Tokenizer are done.
2011-12-12 22:03:25 +01:00
Edoardo Prezioso
79b82f115f
Tokenizer: some changes to line numbers of some tokens:
...
simplifyAsm: change line number of newly added 'asm ( )' in order to be the same as next ';'.
simplifyIfAddBraces: Change line number of newly added '}' in order to be the same as next 'else', except for '{ ; } else'.
2011-12-12 20:55:25 +01:00
Edoardo Prezioso
626f13ae7e
Tokenizer: Fix another Valgrind error in simplifyErrNoInWhile. Add more jumping patterns to simplifyIfAddBraces and simplifyDoWhileAddBraces.
2011-12-12 13:15:35 +01:00
Edoardo Prezioso
99d8ce3732
Fix Valgrind error in arraySize():
...
if there's code like: 'int [ ] a = { 1 , 5 , }', 'end' is last '}', when 'tok2' arrives to second ',' and cppcheck finds out that next token to 'tok2' is '}', remove this ',' with 'tok2->deleteThis()' but it causes (maybe) a memory corruption to 'end' which will gave problems later because 'tok' will be assigned to it or its next token.
2011-12-12 02:23:49 +01:00
Edoardo Prezioso
52620e6493
Tokenizer::simplifyDoWhileAddBraces:
...
1)rewrite fix for ticket #988 (just don't simplify inside macro parenthesis);
2)use a different organization of the code: start from last token and proceed backwards. This way 'simplifyDoWhileAddBracesHelper' can be called just once, hence the 'Helper' code can be improved and moved in the main function.
2011-12-12 00:20:46 +01:00
Edoardo Prezioso
cf574072b6
Tokenizer::arraySize(): improve code structure, fixed 'tok2' for-looping which didn't stop to the ending '}' parenthesis.
2011-12-11 23:13:37 +01:00
Edoardo Prezioso
3c098839d1
simplifyIfAddBraces: Remove restriction for jumping opening parenthesis '(' as a fix to #2873 , because even without this the original test case doesn't crash anymore. Add more jumping patterns.
...
simplifyFunctionParameters: Add more jumping patterns and an observation related to error message for equal parameter names, help needed.
Fix grammar mistake in comment.
2011-12-11 13:07:13 +01:00
Edoardo Prezioso
27801b35eb
Other improvements to tokenizer code.
...
Handle SQL code better, even when there's no ';' after 'EXEC SQL'.
simplifyVarDecl: Check with 'Token::Match' once when you have to check a pattern inside which there should be a number or a variable. Use '%any%' and after that check if that string is a number or a variable name later.
simplifyGoto: process also anonymous structs and unions which should have 'indentspecial' incremented, skip code like 'var = { ... }'.
2011-12-11 02:02:38 +01:00
Edoardo Prezioso
5134964026
Fix code in commit 5f522fb841
and reapply it again.
2011-12-10 23:49:56 +01:00
Daniel Marjamäki
04159b81b8
reverted 5f522fb841
, to avoid hang in TestBufferOverrun::arrayInfo
2011-12-10 20:51:36 +01:00
Edoardo Prezioso
5f522fb841
Tokenizer: improve code and remove redundant checks.
...
In particular: improve 'double sharp' concatenation by handling also code which begins without the [{};]. Do the same with C# code. Also, in the labels simplification function, skip also '{}' when the open bracket is after a '='.
2011-12-10 18:45:27 +01:00
Edoardo Prezioso
bf815ac1e4
Improve labels simplification code, remove redundant checking.
2011-12-10 14:13:48 +01:00
Daniel Marjamäki
c2e86b867c
Fixed #3386 (Syntax Error: 'int a[]={b<c?1:2,3};')
2011-12-10 11:34:27 +01:00
Edoardo Prezioso
7d12951da0
1)Fixed ticket #3184 (Improve Tokenizer: improve simplifyMulAnd to simplify weirder code);
...
2)Fix a test case inside TestSimplifyTokens::flowControl.
2011-12-09 20:47:51 +01:00
Daniel Marjamäki
8ca8887849
C++ Builder : Fixed compiler error
2011-12-08 22:24:09 +01:00
PKEuS
167a7e3e51
Various code cleanups
2011-12-08 21:28:34 +01:00
PKEuS
1bef8d1247
Tokenizer: Code cleanups
2011-12-08 17:42:26 +01:00
Edoardo Prezioso
149ff355e2
Add more kind of code to process for 'removeExceptionSpecifications' (unions, anonymous unions and structs).
2011-12-08 02:50:05 +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
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
Edoardo Prezioso
b9224439c1
Add 'exit' and 'abort' to the flow control list in order to simplify code after them.
2011-12-06 22:56:12 +01:00
Edoardo Prezioso
eb5fe250ab
Partial fix ticket #3385 ('throw' isn't removed if the argument of the function is type 'struct|class').
2011-12-06 21:02:26 +01:00
Edoardo Prezioso
0504952950
Remove some redundant parenthesis - part 9
2011-12-06 16:53:57 +01:00
Edoardo Prezioso
1b4b8fbefe
Tokenizer: use more 'deleteNext' instead of 'eraseTokens' where possible.
2011-12-05 18:52:34 +01:00
Edoardo Prezioso
186ab3645e
Oops. I should eventually keep ';', not 'typedef'.
2011-12-05 00:26:08 +01:00
Edoardo Prezioso
65213772df
Tokenizer: use 'deleteNext()' or, even better, 'eraseTokens' instead of 'deleteThis()' where possible.
2011-12-05 00:08:50 +01:00
Edoardo Prezioso
9cadd7c17a
Remove some redundant semicolons - part 8
2011-12-04 19:11:51 +01:00
Edoardo Prezioso
4946b036ad
Remove some redundant semicolons - part 7
2011-12-04 18:08:35 +01:00
Edoardo Prezioso
52a174fa9d
Remove some redundant semicolons - part 6
2011-12-04 17:30:25 +01:00
Edoardo Prezioso
b45d63a10a
Remove some redundant semicolons - part 5
2011-12-04 17:15:53 +01:00
Edoardo Prezioso
2fc067e6ab
Tokenizer::simplifyConst : handle also '%type% const' when the 'type' token is the first one in the list.
2011-12-04 16:59:19 +01:00
Edoardo Prezioso
a363749a17
1) Remove some redundant semicolons - part 4 ('typedef' != _tokens.str());
...
2) Tokenizer: Use Token::eraseTokens instead of using the same instructions as the ones inside such function.
2011-12-04 15:40:05 +01:00
Daniel Marjamäki
eeb6dc48a5
Fixed #3359 (False positive: array[idx++] += val triggers unexpected 'Array index out of bounds' error)
2011-12-04 12:22:21 +01:00
Daniel Marjamäki
49784a44e1
Tokenizer: improved handling of inner templates. Partial fix for #3226
2011-12-04 11:38:41 +01:00
Edoardo Prezioso
f47ac539d6
Tokenizer::simplifyFlowControl: 1) remove consecutive 'break' or 'continue', since they don't influence the CheckOther results; 2) improve the code speed where possible;
...
Tokenizer::eraseDeadCode: Ditto.
2011-12-03 17:15:19 +01:00
Thomas Jarosch
fcb6759f43
The usual astyle run
2011-12-03 17:01:56 +01:00
Daniel Marjamäki
50dfdf7c2e
Fixed #3350 (Analysis failed)
2011-12-03 15:15:15 +01:00
Edoardo Prezioso
00bae586e9
Add 'throw' to the flow control statements list for simplification of dead code.
2011-12-03 02:04:29 +01:00
Edoardo Prezioso
42a557432d
Remove some redundant semicolons - part 3
2011-12-02 23:04:06 +01:00
Edoardo Prezioso
c2ddb67316
Remove some redundant semicolons - part 2
2011-12-02 22:58:29 +01:00
Edoardo Prezioso
ff1cb241a8
Remove some redundant semicolons - part 1
2011-12-02 22:39:33 +01:00
Edoardo Prezioso
767413adad
1)internal check found a 'findmatch' with simple string argument;
...
2)Style: uniform 'while (...)' when inside it there's an assignment;
3)Replace '0' with 'NULL' where there's comparison with a pointer.
2011-12-01 12:04:47 +01:00
Edoardo Prezioso
1084e4bece
1) Shut up GCC compiler for 'missing braces around assignment';
...
2) Tokenizer::simplifyGoto: Code refactoring in order to skip code inside '()|[]' parentheses without counting.
2011-11-30 20:58:39 +01:00
PKEuS
6b6f780057
code cleanups and refactorings
2011-11-26 21:02:04 +01:00
Marek Zmysłowski
3ae96600b5
Fixed #3212 (Simplify the double pointer cast)
2011-11-25 07:23:54 +01:00
Thomas Jarosch
5025d1019f
Use Token::simpleMatch instead of Token::Match
...
"--enable=internal" reported:
[lib/tokenize.cpp:3563]: (warning) Found simple pattern inside Token::Match() call: ") ;"
2011-11-24 10:11:45 +01:00
Daniel Marjamäki
17f891ad34
Tokenizer::setVarId: Fixed problem with class declarations with inheritance. skip them.
2011-11-21 21:18:56 +01:00
Daniel Marjamäki
9aa8a49677
Tokenizer::setVarId: fixed 'using' bug
2011-11-21 18:04:42 +01:00
Daniel Marjamäki
004dcf834b
Fixed #3281 (Tokenizer::simplifyKnownVariables : static constant value is not used)
2011-11-20 21:50:26 +01:00
Edoardo Prezioso
6889a28d31
1) Run runastyle;
...
2) Clarify some comments in 'Tokenizer::simplifyFlowControl' and in 'Tokenizer::eraseDeadCode';
3) Add some 'const' variables inside 'Tokenizer::eraseDeadCode'.
2011-11-20 19:06:55 +01:00
Edoardo Prezioso
d0d5a2fcd8
Completed ticket #3230 (Refactoring: add function to remove tokens when a label is found.) and fixed ticket #3264 (False positive: Variable is assigned a value that is never used).
2011-11-20 18:37:00 +01:00
Daniel Marjamäki
097637a66c
Fixed #3316 (Cppcheck reporting internal errors - code compiles cleanly)
2011-11-20 16:22:21 +01:00
Edoardo Prezioso
42e369a4b4
Change every 'tokAt(..)->link()' to 'linkAt(..)'.
2011-11-20 14:24:27 +01:00
Daniel Marjamäki
1cf45a5cde
Fixed #3280 (False positive: assigned value that is never used)
2011-11-20 12:09:07 +01:00
Daniel Marjamäki
8c091ff968
Fixed #3340 (Internal error. Token::Match called with varid 0... union is causing problems)
2011-11-20 08:13:28 +01:00
Thomas Jarosch
c317c8979c
Run astyle
2011-11-14 09:21:42 +01:00
Edoardo Prezioso
2c64d299ca
Change every 'tokAt(...)->str()' to 'strAt(...)'.
2011-11-13 13:10:59 +01:00
Edoardo Prezioso
b28a44dc3b
Change: 'next()->next()'->'tokAt(2)', 'previous()->previous()'->'tokAt(-2)'.
2011-11-12 22:33:03 +01:00
Edoardo Prezioso
ed6a0e14c4
Add simplification of the consecutive braces before the end of 'tokenize()' function.
2011-11-12 16:59:20 +01:00
Edoardo Prezioso
5cbfbe31c1
Add removal of consecutive braces, i.e.: '{ { ... } }'->'{ ... }'.
...
Changed a little bit the dead code tests.
2011-11-12 12:07:10 +01:00
Daniel Marjamäki
5a35beebf7
added todo comment
2011-11-11 11:07:03 +01:00
Daniel Marjamäki
34e40502c6
Fixed #3314 (cppcheck incorrectly reporting Syntax error.)
2011-11-11 10:53:49 +01:00
Richard Quirk
f56aa19fac
Fix varid 0 with function pointer and virtual methods
2011-11-09 21:07:55 +01:00
Daniel Marjamäki
2d00cabee1
Fixed #3279 (Token::Match called with varid 0)
2011-11-09 18:49:17 +01:00
Edoardo Prezioso
0569953753
Fixed ticket #3309 (false positive: (style) Boolean result is used in bitwise operation. Clarify expression with parentheses)
2011-11-08 22:48:14 +01:00
Edoardo Prezioso
3cc9a333c9
Fixed tokenizer: don't change '*(str+num)' if '*' means a product with a previous variable or number.
...
Ditto for '&str[num]' (still commented).
2011-11-08 18:14:43 +01:00
Edoardo Prezioso
a546fc6e9d
Fixed ticket #3310 (segmentation fault of cppcheck)
2011-11-08 17:37:24 +01:00
Edoardo Prezioso
aaa77c4709
Improve tokenizer: remove more redundant parenthesis and add a prototype code for: '&str[num]'=>'(str+num)' with reporting non obvious test failures.
2011-11-07 23:40:06 +01:00
Edoardo Prezioso
6e2f2816de
Improve same expression check: remove '%op%' pattern and add ',' for the same expressions as an argument inside a function.
...
Improve compound assignment simplification: use already defined 'isAssignmentOp' and extend the adding parenthesis to a generic operator, not only to the arithmetical ones. See: http://en.cppreference.com/w/cpp/language/operator_precedence
2011-11-06 14:35:53 +01:00
Daniel Marjamäki
5edf153602
Fixed #3294 (Token::Match multi compare false negative)
2011-11-05 19:24:21 +01:00
Daniel Marjamaki
b96ab6ba26
Fixed #3188 (Function parser false positive)
2011-11-05 12:23:05 +01:00
Daniel Marjamäki
085a6285fa
Fixed #3117 (Tokenizer::simplifyKnownVariables : Don't simplify static variable that is changed)
2011-11-05 08:30:11 +01:00
Daniel Marjamäki
9b8ffe7219
Fixed #3248 (Tokenizer: better handling of char constants that are compared with numeric constants)
2011-11-03 20:03:31 +01:00
Daniel Marjamaki
b6b5416b42
Tokenizer: Fixed failed unit test
2011-11-02 20:42:38 +01:00
Daniel Marjamaki
0884204c2f
Fixed #3279 (Token::Match called with varid 0)
2011-11-02 18:31:13 +01:00
Daniel Marjamaki
937a4497ca
Fixed #3272 (Internal error)
2011-11-01 18:03:32 +01:00
Edoardo Prezioso
9dd3360cd6
Fix some complainted choices made in my older commits.
...
Note: probably you should do 'make clean' before using 'make' to rebuild it again. Maybe it's me but 'make' reports various errors when linking.
2011-11-01 13:23:47 +01:00
Daniel Marjamäki
a7f27a83a7
Fixed #3271 (Regression: something related to symbol database / varid)
2011-10-31 18:33:15 +01:00
Edoardo Prezioso
ba5909ef1d
General code tweaking, nothing strange.
2011-10-31 02:24:59 +01:00
Edoardo Prezioso
433f4640a9
Fix some GCC warnings regarding the sign conversion.
2011-10-30 18:34:49 +01:00
Edoardo Prezioso
42fd4e2f52
Tokenizer: Change 'var++|--;' into '++|--var;' and remove redundant 'tokAt(0)'.
2011-10-29 22:25:49 +02:00
Daniel Marjamäki
92333b585a
Fixed #3092 (Tokenizer::setVarId : shadow variable in member function gets the wrong varid)
2011-10-29 21:25:58 +02:00
Daniel Marjamäki
a809bb3471
astyle formatting
2011-10-29 19:51:11 +02:00
Daniel Marjamäki
acaa9c456f
Fixed #3152 (Tokenizer: template constructor is removed)
2011-10-29 19:45:47 +02:00
Daniel Marjamäki
8f49eb6a7e
Tokenizer: Make sure that friend classes don't get varid. Ticket: #2962
2011-10-29 18:22:58 +02:00
Edoardo Prezioso
5d868766c7
Tokenizer time improvements (time says real: -1 second)
...
1)change tokAt(1|-1) with next()|previous() with conditions where necessary;
2)change strAt(1|-1) with next()|previous()->str() with conditions where necessary;
3)change tokAt(n)->str(), with n != -1,1, to strat(n);
4)change simplifyFuncInWhile implementation because it was too slow and stupid.
2011-10-29 01:57:53 +02:00
Edoardo Prezioso
dd719b41bf
Definitely check correctly 'sizeof %num%' when '%num%' has '-' sign.
2011-10-29 00:11:38 +02:00
Thomas Jarosch
ef8f49bbf3
Use new findsimplematch API for simple patterns
2011-10-28 12:49:03 +02:00
Edoardo Prezioso
bab740289c
Complete todo: convert 'for' into 'while'.
...
It's not possible to enable this code because of the disaster it will be created for all the checks with the 'for' pattern.
2011-10-28 00:50:54 +02:00
PKEuS
49fd057e17
Tokenizer: Simplify 'foo(void)' to 'foo()'
2011-10-27 19:56:59 +02:00
Thomas Jarosch
22251d50bb
Bugfix: Use Token::Match instead of Token::simpleMatch because it's a complex pattern
...
This bug was in here before my recent refactoring.
(And yes, I wrote a check for cppcheck's Token::Match invocation ;))
2011-10-27 16:43:04 +02:00
Thomas Jarosch
434fb933a8
Implement Token::findsimplematch und use it for simple patterns
2011-10-27 15:59:22 +02:00
Thomas Jarosch
54adb910ec
Use Token::simpleMatch instead of Token::Match for simple patterns
2011-10-27 15:59:22 +02:00
Edoardo Prezioso
9bb1a1b7a5
Added code for simplification of 'for ( a; b; c;); -> '{ a; for (; b; c;) ; }'.
...
It's not enabled because it fails many tests with testrunner.
2011-10-27 02:59:50 +02:00
Edoardo Prezioso
1be1af4afb
Move the simplification of 'strlen' in simplifyTokenList.
...
This way it's possible to omit the call to simplifyKnownVariables before 'strlen'.
2011-10-27 01:24:35 +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
db8c7deb30
Fixed #3232 (Check if container is modified inside BOOST_FOREACH)
2011-10-23 13:07:43 +02:00
Erik Lax
b7ab1e7d7e
Fixed #3237 (Bug in parser of class operator functions)
2011-10-23 10:25:14 +02:00
Johan Samuelson
3d8fa2f76e
Fixed #3123 ([False Positive] Shadowed enum)
2011-10-22 13:43:53 +02:00
Daniel Marjamäki
32e20d4e31
made 'variableHidingTypedef' inconclusive. See ticket #3199
2011-10-22 13:26:33 +02:00
Marek Zmysłowski
b332ea8222
Fixed #3204 (Refactor standards support in Settings)
2011-10-22 09:45:48 +02:00
Edoardo Prezioso
9257e82475
Improve tokenizer: don't confuse between a label and the case/default statements.
2011-10-19 18:49:02 +02:00
Edoardo Prezioso
882b0c15a0
Improve tokenizing of "do{ ... } while(0)".
...
The simplification will be the same for every combination, except for the 'continue' and the 'break'. In that case, keep the block braces.
2011-10-19 18:20:29 +02:00
Edoardo Prezioso
4f256ef314
Runastyle + removal of useless conditions after previous commit.
2011-10-19 14:48:08 +02:00
Edoardo Prezioso
73f0e2c5b9
Fixed ticket #3227 (Improve tokenizer: labels are not handled correctly after a case or another label instruction)
...
Moved the labels simplification after combining the tokens and moved the case/default simplification inside the labels.
2011-10-19 14:20:09 +02:00
Edoardo Prezioso
f4cdf57955
Fixed ticket #3229 (Segfault with goto):
...
Don't handle labels, gotos, returns and indentations inside the round braces. This is applied not only for simplifyGoto, but also to simplifyFlowControl.
Rewrite enum badly handled by astyle inside mathlib.cpp and move simplifyFlowControl at the end of the simplifyTokenList in order to catch more dead code, not related to the ticket.
2011-10-18 23:56:35 +02:00
Edoardo Prezioso
de8eb48a5c
Remove redundant function findmatch inside tokenize.cpp.
...
There's Token::findmatch which is already used inside other Tokenizer functions.
2011-10-17 13:46:27 +02:00
Edoardo Prezioso
c3caade3ca
- Fixed mispelled function name;
...
changed variable name inside simplifyFlowControl for consistency;
improved simplifyFlowControl to handle better this kind of code:
"return; { { } { label : ; ok ( ) ; } }"->"return ; { { label: ok ( ) ; } }".
2011-10-17 02:16:49 +02:00
Ettl Martin
1a710e5761
fixed regression on linux due to missing include
2011-10-16 14:16:35 +02:00
PKEuS
f8074b71d2
Fixed #2470 (False negative: Possible null pointer dereference (C++0x keyword 'nullptr'))
2011-10-16 12:54:58 +02:00
Thomas Jarosch
a52b73f9f9
Fix #3208 (Simplify pointer to standard type, C only)
...
The symbol database is unavailable during token simplification
and &data[0] might return something completely different for C++.
Moved code_is_c() from checkOther to Tokenizer.
2011-10-16 08:09:57 +02:00
Edoardo Prezioso
8afc1b6f2d
Changed the name of the removal of dead code after flow control statements for consistency (simplifyDeadCode is too generalized as name)
2011-10-15 12:45:48 +02:00
Edoardo Prezioso
57ead6988e
Fixed ticket #3138 (Tokenizer: remove unreachable code below goto inside a namespace|class|struct block)
2011-10-15 11:35:45 +02:00
Edoardo Prezioso
f95b692a69
Fixed ticket #3113 (complete simplification of dead code after control flow statements)
2011-10-15 01:34:07 +02:00
Jonathan Neuschäfer
4fb7865f49
fix typos using codespell
...
Codespell is available at http://git.profusion.mobi/cgit.cgi/lucas/codespell/ .
2011-10-13 22:04:41 +02:00
Daniel Marjamäki
6f8e42a5af
changed the astyle formatting flags
2011-10-13 20:53:06 +02:00
Edoardo Prezioso
b792efb761
Fix ticket 3140 and 3137 (Improve Tokenizer: Remove dead for loop - simplify while(0) better.
...
Note: it doesn't remove dead code if there's a label inside. Will be improved in another ticket.
2011-10-13 13:01:24 +02:00
Edoardo Prezioso
16506f0a8c
Remove redundant simplifyDeadCode call inside the Tokenizer::tokenize and move the relative tests in the file 'testsimplifytokens.cpp'.
2011-10-13 12:26:27 +02:00
Daniel Marjamäki
371871b0b7
Tokenizer::removeMacrosInGlobalScope: Don't remove C/C++ keywords namespace/struct/etc. Ticket: #3193
2011-10-12 19:23:39 +02:00
Robert Reif
ee04c1bfb7
fix #3194 (Parsing glitch causes false 'can be const' error for an 'if' statement)
2011-10-12 09:10:34 -04:00
Edoardo Prezioso
742858b67c
Fixed some simple errors in some old commits.
2011-10-10 17:18:47 +02:00
Edoardo Prezioso
af23a9dcbb
Fixed ticket #3140 (Improve Tokenizer: Remove dead for loop 'for (int i = 0; i < 0; ++i)')
2011-10-10 15:15:45 +02:00
Daniel Marjamäki
96beb94b21
Fixed #3183 (False positive: (error) syntax error)
2011-10-09 18:42:36 +02:00
Edoardo Prezioso
9270b84d64
More fixes to the label simplifier (related to ticket 3176):
...
1)Simplify the labels if there are combinations of the symbols '*','&','{' and '(' after a '%var% :' and before another '%var%';
2)but do not simplify the label if it's inside an unpreprocessed macro code.
2011-10-08 21:13:53 +02:00
Robert Reif
a1a839fadc
fix tokenizer and symbol database to not mistake goto statement for variable declaration
2011-10-07 08:11:48 -04:00
Edoardo Prezioso
80df7ea839
Fixed ticket #3176 (cppcheck reports wrong unused variable)
...
Label simplification didn't take count of the '(' parenthesis or the '&' and '*' operators inside or outside the parenthesis after the colon.
2011-10-07 00:54:44 +02:00
Edoardo Prezioso
fe4ce594ce
Renamed the function 'removeRedundantCodeAfterReturn' with 'simplifyDeadCode'.
...
This is a preparation in order to add new features to this function (see the @todo in the tokenize header file, ticket #3113 and #3175 for details).
2011-10-06 22:40:39 +02:00
Edoardo Prezioso
8e90ad106c
Fixed ticket #3148 (Analysis failed on "Modules/mathmodule.c")
...
Fix: Do not handle code when 'return' is inside a macro. This is valid also for 'switch' code inside a macro.
2011-10-05 19:33:46 +02:00
Edoardo Prezioso
3c370dcfdf
Fixed #3146 "Analysis failed" error on softmagic.c:
...
-Fixed: the code didn't check the rightness of the switch syntax if it was inside another switch;
-Tweaked: removed the two bool variables, so now the conditions take count of indentation unsigned variables.
2011-10-04 12:16:39 +02:00
Edoardo Prezioso
bc74213036
Fixed #3132 (Analysis failed. If the code is valid then please report this failure.)
2011-10-03 19:38:37 +02:00
Robert Reif
ac942c6684
fix #3151 (missing portability warning for extra qualifier on destructor)
2011-09-29 19:25:14 -04:00
Robert Reif
9994218aa2
refactor last commit to move unknown type output to seperate function
2011-09-28 07:36:48 -04:00
Robert Reif
989235b509
show unknown variable types when debug-messages flag is set
2011-09-27 21:45:06 -04:00
Robert Reif
44a926aa4d
add a few more Microsoft TCHAR function conversions
2011-09-27 07:29:36 -04:00
Robert Reif
ec377d24eb
add support for Microsoft TCHAR character constants
2011-09-26 22:08:24 -04:00
Robert Reif
6e8bf43dc0
add some Windows TCHAR scanf and printf conversions
2011-09-25 10:02:27 -04:00
Robert Reif
545aa9e55b
start adding Windows wide character support
2011-09-24 16:02:56 -04:00
Robert Reif
f97424b242
start adding Windows ASCII TCHAR conversion support
2011-09-24 14:51:03 -04:00
Robert Reif
a685f1f5b7
add operator support to ertra qualification check
2011-09-23 19:45:19 -04:00
Robert Reif
97d4277854
add Microsoft memory function conversions to standard cstring functions
2011-09-22 19:59:56 -04:00
Robert Reif
4d1dda10fa
add some more windows type conversions
2011-09-20 20:17:02 -04:00
Robert Reif
af5272dfb0
only simplify Microsoft MFC code when Windows platform is selected
2011-09-20 07:20:37 -04:00
Robert Reif
e234e8cc5b
add some common windows pointer type conversions to standard types
2011-09-19 23:14:58 -04:00
Robert Reif
be660003ec
start adding conversions from common Windows types to standard types
2011-09-18 13:06:54 -04:00
Robert Reif
66eb37c135
convert size_t to standard type
2011-09-18 10:31:31 -04:00
Robert Reif
b5d22fda0d
fix #2888 (Allow defining sizes of base types)
2011-09-17 19:40:52 -04:00
Robert Reif
cce4303f28
fix a problem with Qt slots immediately followed by signals
2011-09-16 16:59:43 -04:00
Edoardo Prezioso
1ff7410f4f
Fixed #3075 (False positive => Improve tokenizer: remove redundant code after a 'return' state)
2011-09-13 07:55:47 +02:00
Daniel Marjamäki
9a97fbe022
Fixed #3104 (unread despite modified and used in IF statement)
2011-09-11 08:19:35 +02:00
seb777
8ed0e3a239
Revert "The case statement requires constant-expression (C, C++, C# and Java."
...
This reverts commit 5879fe419d
.
2011-09-11 00:44:40 +02:00
seb777
5879fe419d
The case statement requires constant-expression (C, C++, C# and Java.
...
Needless to simplify the calculation of a piece of code that can not compile.
2011-09-10 17:28:32 +02:00
seb777
08efad13b2
fix #3093 (Simplify code (math expression) with keywords 'return' and 'case')
2011-09-10 13:28:54 +02:00
seb777
5c7ed46e0c
Following the discussion XX, replace the keyword C99 '_Bool' with the 'bool' keyword in the process of tokenization\nSee f29b7f9f08
2011-09-03 23:15:33 +02:00
Daniel Marjamäki
46b5d5bd00
Fixed #3069 (False positive: Memory leak: data)
2011-09-03 20:45:48 +02:00
Daniel Marjamäki
d23c58d387
enable: break out 'performance' and 'portability' from the 'style' id. Ticket: #3074
2011-09-03 15:30:30 +02:00
Robert Reif
f4e07c3179
fix #3070 (Other: failed to parse a typedef string. Check continues anyway.)
2011-09-01 19:10:58 -04:00
Daniel Marjamäki
a96028b43b
Fixed #3058 (False positive: Uninitialized variable: data)
2011-08-31 19:45:20 +02:00
Daniel Marjamäki
0529654e37
Fixed #3058 (False positive: Uninitialized variable: data)
2011-08-30 19:13:04 +02:00
Daniel Marjamäki
787bc4c384
Fixed #3016 (Preprocessor has incorrect precedence(?) for &&)
2011-08-28 18:30:58 +02:00
Robert Reif
423a1ff64e
add support for simplifying Qt emit in tokenizer
2011-08-25 20:54:35 -04:00
Daniel Marjamäki
7afec3cf6d
Fixed #3032 (False positive: possible null pointer dereference (assignment in condition))
2011-08-21 17:49:00 +02:00
Robert Reif
a6c5eff1be
fix #3006 (segmentation fault of cppcheck ( x < () < ))
2011-08-15 07:19:49 -04:00
Robert Reif
4168d79b09
fix #3005 (segmentation fault of cppcheck ( enum : x ))
2011-08-15 07:07:12 -04:00
Robert Reif
5364b4f7fb
fix #3007 (false positive: (style) Struct 'Fred' hides typedef with same name)
2011-08-15 06:56:15 -04:00
Robert Reif
ed507b73ee
fix #3004 (false positive: (style) Struct 'Fred' hides typedef with same name)
2011-08-14 21:00:05 -04:00
Robert Reif
08e9d64a86
fix #3003 (segmentation fault of cppcheck (typedef a x[]; y = x ))
2011-08-14 20:38:16 -04:00
Robert Reif
b7f42535ec
fix #3000 (false positive: (style) Struct 'Fred' hides typedef with same name)
2011-08-14 18:50:33 -04:00
Robert Reif
389ab80b63
fix #2999 (false positive: (style) Struct 'Fred' hides typedef with same name)
2011-08-14 18:06:05 -04:00
Robert Reif
136c617a99
fix [tokenize.cpp:6353]: (style) Checking if unsigned variable 'indentlevel' is less than zero.
2011-08-13 12:47:16 -04:00
Robert Reif
b7f963f701
removed redundant set isNumber flag from previous commit
2011-08-12 07:15:10 -04:00
Robert Reif
ce00d0d35e
fix #2963 (FP: Typedef names considered duplicate because __LINE__ not expanded)
2011-08-11 18:18:47 -04:00
Daniel Marjamäki
9a24492a00
Fixed #2975 (False positive: Return of the address of an auto-variable)
2011-08-10 18:16:31 +02:00
Robert Reif
10eb224ac7
fix #2983 (segmentation fault of cppcheck)
2011-08-09 18:31:02 -04:00
Robert Reif
afe95be966
fix #2980 (segmentation fault of cppcheck)
2011-08-08 06:58:55 -04:00
Robert Reif
829611b129
fix #2978 (segmentation fault of cppcheck ( enum E {} e enum ))
2011-08-07 16:48:47 -04:00
Kimmo Varis
cfcfa3f000
Use "enabled" list for the style checking.
...
Settings-class currently enables style checking via dedicated
boolean attribute. All other CLI's enable-options are handled
through the enable-list. This commit moves style-check enabling
to use the enable-list.
Main advantage is the consistency how options are handled/stored
in the Settings class. Which also unifies using them for the other
code. You need to enable certain type of checks? Use the
addEnabled()-method. You want to check if certain type of checks
are enabled? Use the isEnabled()-method.
2011-08-07 10:28:52 +03:00
Robert Reif
222ed6d375
fix #2971 (Wrong warning generated)
2011-08-06 19:10:15 -04:00
Robert Reif
d23fb873cc
fix #2970 (Incorrect report: Class does not have a constructor)
2011-08-06 17:54:02 -04:00
Simon Martin
13360c2a66
Fixed #2870 (Tokenizer: simplify '0 |')
2011-08-06 06:50:29 +02:00
Robert Reif
fd01a7555a
fix #2966 (segmentation fault of cppcheck ( enum x : ))
2011-08-05 18:07:18 -04:00
Robert Reif
bc4db75aa9
fix #2146 (uninitialized variable: false negative for 'return x ? 1 : y;')
2011-07-31 21:33:43 -04:00
Robert Reif
addcec704f
fix cppcheck warning in Tokenizer::duplicateTypedef()
2011-07-30 10:12:35 -04:00
Daniel Marjamäki
1ce261e44d
astyle formatting
2011-07-24 14:54:13 +02:00
Daniel Marjamäki
158fa25623
Fixed #2817 (valgrind errors in simplifyTemplate when running tests)
2011-07-24 13:32:54 +02:00
Daniel Marjamäki
0dd5472642
Tokenizer::simplifyFunctionPointer: don't simplify function call. Ticket: #2873
2011-07-22 07:58:53 +02:00
Daniel Marjamäki
fb3870071a
Fixed #2885 (crash of cppcheck while checking gcc-testsuite)
2011-07-21 16:13:35 +02:00
Daniel Marjamäki
9f22d2fc6b
Fixed #2897 (out of bounds false positive, using reinterpret_cast)
2011-07-21 09:32:24 +02:00
Daniel Marjamäki
7e7f6eecf5
Fixed #2794 (Improper hanling of preprocessor directives #if defined)
2011-07-20 23:50:57 +02:00
Daniel Marjamäki
6ce5107e49
Tokenizer: Better handling of constants. Related with #2920
2011-07-20 09:07:47 +02:00
Daniel Marjamäki
35938e74ad
Tokenizer: better handling of 'struct AB ab; sizeof(ab)'
2011-07-16 22:07:30 +02:00
Daniel Marjamäki
cf3ab649fb
Fixed #2873 (segmentation fault of cppcheck while scanning rose-compiler suite)
2011-07-16 19:26:11 +02:00
Daniel Marjamäki
597733bec4
Tokenizer: minor update to handle C# code better
2011-07-16 18:12:55 +02:00
Daniel Marjamäki
274fd2b985
Tokenizer: Fix minor problem with 'X&&Y'
2011-07-15 19:37:39 +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
Robert Reif
b143b283e9
fix #2886 (crash of cppcheck ( typedef struct x { } ))
2011-07-03 10:50:15 -04:00
Robert Reif
8ec1dfacbf
fix missing pop in Tokenizer::simplifyStructDecl() when anonymous struct/union removed
2011-07-03 08:14:51 -04:00
Robert Reif
3f4cc5fa3a
add class A {} a; -> class A {}; A a; conversion capability to Tokenizer::simplifyStructDecl()
2011-07-02 09:21:30 -04:00
Daniel Marjamäki
db4a28d60b
Tokenizer::simplifyGoto: Only simplify the last label in the function. If there are many labels in the same function and all labels are simplified, this function becomes very slow.
2011-07-01 18:07:41 +02:00
Reijo Tomperi
89fd5bacf9
Fix #2849 , False positive: memory leak (using question mark operator)
...
http://sourceforge.net/apps/trac/cppcheck/ticket/2849
Simplify: *d = b ? b : a; into if-else
Simplify { ; { ; } } into { ; }
Removed one memleak test which should be redundant now as question marks
should not get into memleak check.
2011-06-30 22:04:26 +03:00
Robert Reif
77859b9a0f
fix #2878 (derived global class not tokenized properly (class A : ::B { };))
2011-06-30 07:25:36 -04:00
Robert Reif
586fdd24f2
fix #2825 (missing varid on class variables when multiple inheritance is used)
2011-06-29 20:04:04 -04:00
Robert Reif
443dd4c392
partial fix for #2867 handle derived class
2011-06-29 19:39:19 -04:00
Robert Reif
1286898fa0
fix #2864 (--errorlist missing errors: variableHidingTypedef and Extra qualification)
2011-06-28 21:46:54 -04:00
Robert Reif
f403de7bad
partial fix for #2867 Tokenizer::removeRedundantAssignment didn't understand function local class and removed class variable
2011-06-28 19:48:28 -04:00
Robert Reif
70a32fc245
fix #2875 (segmentation fault of cppcheck ( 0; (a) < (a) ))
2011-06-28 18:47:18 -04:00
Robert Reif
1713eeb532
fix #2859 (Extra qualification not detected)
2011-06-26 21:13:29 -04:00
Reijo Tomperi
918b4d859f
Fixed #2860 , False positive: Returning value of strncat() reported as memory leak
...
http://sourceforge.net/apps/trac/cppcheck/ticket/2860
2011-06-26 23:53:16 +03:00
Daniel Marjamäki
40a14736b7
Added TODO test case for the simplifyKnownVariables to better simplify local variables
2011-06-23 17:03:14 +02:00
Daniel Marjamäki
2d1b7285d2
Fixed #2815 (FP: Null pointer dereference error about a member)
2011-06-23 16:58:01 +02:00
Robert Reif
db39f4364e
fix #2845 (segmentation fault of cppcheck)
2011-06-21 07:31:55 -04:00
Robert Reif
d80a55267c
fix #2844 fix to generate correct output
2011-06-19 20:19:16 -04:00
Robert Reif
0bd26a73c4
fix #2844 (typedef causes 'syntax error')
2011-06-19 17:57:01 -04:00
Robert Reif
eaf836b323
fix extra qualification check for same class name in different namespaces
2011-06-14 15:31:52 -04:00
Robert Reif
e584b08066
fix #2835 (crash of cppcheck ( ><,f<i, ))
2011-06-12 12:09:52 -04:00
Robert Reif
729ee72a5a
fix #2831 (crash of cppcheck ( z<y<x> ))
2011-06-12 08:38:15 -04:00
Robert Reif
d1b260699a
fix #2834 (crash of cppcheck (std::vector<int>::iterator))
2011-06-12 08:24:49 -04:00
Robert Reif
5e3263235b
fix #2739 (segmentation fault of cppcheck ( if()x ))
2011-06-11 15:51:12 -04:00
Robert Reif
3d4eb0d77e
fix #2682 (segmentation fault of cppcheck ( x a[0] = ))
2011-06-10 15:11:45 -04:00
Robert Reif
a9e2e15e40
improve #2828 fix by adding switch
2011-06-09 07:32:43 -04:00
Robert Reif
6635ed4630
fix #2828 (false positive: Function parameter 'STYLE' hides enumerator with same name)
2011-06-08 20:14:52 -04:00
Robert Reif
a7fe9a3b50
fix 2 use after frees in simplifyEnum found by visual studio and verified by valgrind
2011-06-03 21:50:08 -04:00
Robert Reif
311651cc66
fix #2804 (Underlying type of enumerator produces a syntax error)
2011-05-27 11:17:39 -04:00
Daniel Marjamäki
ab1b293f23
Fixed #2737 ((error) Analysis failed. If the code is valid then please report this failure.)
2011-05-19 17:04:36 +02:00
WenChung Chiu
1ea52cfa02
Fixed #2784 (Pointer issue: *&f=open())
2011-05-18 07:25:30 +02:00
Daniel Marjamäki
03cd57260a
added comment about how bad typedef behaviour can be reproduced
2011-05-07 14:40:47 +02:00
Daniel Marjamäki
8e5c63104c
Fixed #2743 (segmentation fault of cppcheck 'std::vector<void(*)()> v1 = a, v2 = b;')
2011-05-07 14:23:14 +02:00
Robert Reif
51baca0359
fix #1982 (simplifyTypedef: scope info is lost)
2011-05-02 22:42:52 -04:00
Daniel Marjamaki
297ca63868
Fixed #2721 (Tokenizer::simplifyTemplates: fail when using template argument 'char[2]')
2011-05-01 19:05:18 +02:00
Daniel Marjamäki
bb3c135d81
Tokenizer: Moved a few basic simplifications from simplifyTokenList to tokenize
2011-05-01 08:36:27 +02:00
Daniel Marjamäki
168bd2ebfc
Fixed #2760 (false positive: uninitialized variable ', (a) =')
2011-05-01 08:27:59 +02:00
Daniel Marjamäki
fb32d5111e
Fixed #2755 (cppcheck goes into infinite loop while scanning OpenSSL sources)
2011-04-29 19:47:39 +02:00