Commit Graph

1160 Commits

Author SHA1 Message Date
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