PKEuS
00f6c635b8
Detect functions returning a template type in SymbolDatabase
...
Fixed comment
2012-08-22 03:37:50 -07:00
Edoardo Prezioso
2b5cd2effc
Fixed G++ [-Wparentheses] warning. This also fixed #4073 (Crash on self assignment).
2012-08-21 20:15:04 +02:00
Daniel Marjamäki
41b624230f
Fixed #3942 (false positive: (error) Memory leak: keyword)
2012-08-21 17:02:11 +02:00
PKEuS
b4b5c80db9
Improved check: Added message when checking sign of a pointer.
2012-08-21 03:28:02 -07:00
PKEuS
a5bca705a5
New check: Ensure that the return value of std::remove() is used.
2012-08-21 02:30:27 -07:00
PKEuS
b641a10e35
Fixed false negative: memset(foo, 0, sizeof(&foo)); is as suspicious as memset(foo, 0, sizeof(foo));
2012-08-20 10:08:18 -07: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
PKEuS
a243983242
Refactorized type handling in CheckIO and CheckOther:
...
- Added several types (std::) to isComplexType
- Types in namespace std:: are considered to have no side-effects (solved one TODO)
- Scope of a pointer can be limited without side effects
2012-08-20 08:57:28 -07:00
PKEuS
4550cd2cd6
Refactorizations:
...
- Removed unnecessary 'if'
- Use symboldatabase instead of tokenizer to detect references and pointers
2012-08-20 08:27:43 -07:00
PKEuS
c537a86363
Fixed false negative in unused variable checking when class without side effects inherits from another one.
2012-08-20 07:55:39 -07:00
PKEuS
c7e2490f2b
Refactorized iterator check:
...
- Handles reassignment (fix for #4062 )
- Better support of execution paths
- Use symboldatabase for better performance
2012-08-20 04:57:24 -07: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
Daniel Marjamäki
1601baa974
Fixed #4016 (false positive: incorrectLogicOperator)
2012-08-14 16:17:18 +02:00
Daniel Marjamäki
e534ee0426
Fixed #3706 (cppcheck 1.53 hangs when processing a certain template with specializations)
2012-08-13 16:17:33 +02:00
Daniel Marjamäki
8afdde0b5e
Fixed #3931 (FP: Buffer access out-of-bounds)
2012-08-12 17:06:54 +02:00
Edoardo Prezioso
358fb9a284
Fixed the GCC Wshadow warnings introduced recently.
2012-08-12 17:04:37 +02:00
Daniel Marjamäki
4368f66a00
Fixed #4018 (false positive: Dereferencing 'foo' after it is deallocated / released)
2012-08-12 16:18:07 +02:00
PKEuS
2ac2674f67
Fixed #4000 , added support for function prototypes to TemplateSimplifier::templateParameters()
2012-08-12 05:19:56 -07:00
PKEuS
a15e307df0
Replaced two more indentation counters
2012-08-12 04:12:17 -07:00
PKEuS
c8773b891d
Refactorization: Make use of Token::scope() replacing certain indentation counters
2012-08-12 03:13:07 -07: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
4f68923add
Fixed inverted id and msg of debug messages from symboldatabase
2012-08-12 02:11:54 -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
PKEuS
70de691551
Fixed false positive #4032
2012-08-10 06:26:07 -07: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
Daniel Marjamäki
ca4ed5e0c3
ErrorLogger: Throw InternalError if given severity is not handled
2012-08-10 12:43:53 +02:00
PKEuS
355c1322d6
Small refactorizations in checkunusedvar.cpp:
...
- Token::Match handles nullpointers
- In chained assignments variables are only written (not read) when assigned
- Fixed crash #4033
2012-08-10 03:36:08 -07:00
Daniel Marjamäki
6ff1760c72
TemplateSimplifier: Improved handling of unknown inner template instantiation inside template instantiation ( #3818 )
2012-08-09 17:19:36 +02:00
Daniel Marjamäki
4ec12209dc
TemplateSimplifier: Fixed wrong match when inner template parameters are wrongly counted ( #3818 )
2012-08-08 06:43:41 +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
445fd4e6aa
Fixed #4010 (error (cppcheckError): Internal error. Token::Match called with varid 0)
2012-08-05 17:11:39 +02:00
Daniel Marjamäki
25fd841b5d
Tokenizer: removed redundant include
2012-08-05 16:06:20 +02:00
PKEuS
31129aad40
Refactorizations in checknullpointer.cpp:
...
- Removed CheckNullPointer::nullPointerAfterLoop(), improved CheckNullPointer::nullPointerByCheckAndDeRef() to cover tests
- Enhanced CheckNullPointer::nullPointerByDeRefAndChec() to check also 'else if' and 'while'
2012-08-05 02:07:38 -07:00
PKEuS
25ecd3ed71
Message refactorization: checknullpointer.cpp
...
Removed a duplicate test in checknullpointer.cpp
2012-08-05 01:38:48 -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
PKEuS
1b40668e04
Refactorizations:
...
- Made several functions (Check*::myName and others) because they don't touch depend on a specific instance. (cppcheck findings)
- Removed description of a check in CheckConst that has moved to CheckIO
2012-08-02 09:50:48 -07: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
3b5dabdb14
Clarified errormessage of checkBoost
2012-08-02 02:40:08 -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
PKEuS
88e4794d6e
Refactorized CheckClass::checkConst:
...
- Added checking for functions that can be even declared static (#1971 . Removed fix for #1563 )
- Consistent usage of Function::TokenDef to avoid problems with scope identifiers
- Rewrote parsing of function body making it more generic
- Removed three redundant tests
2012-08-01 10:24:38 -07:00
Ettl Martin
98d608231d
spelling fixes
2012-07-31 23:35:56 +02:00
Ville Skyttä
dce16a970d
spelling fixes
2012-07-31 21:28:42 +02:00
PKEuS
cc1faad34a
Removed bailouts in CheckClass::privateFunctions and CheckUnusedFunctions when checking code with templates (unnecessary after 2c10e9a6ca
)
2012-07-29 08:05:54 -07:00
Daniel Marjamäki
2c10e9a6ca
TemplateSimplifier: Removed unused function
2012-07-29 16:14:26 +02:00
Daniel Marjamäki
435340b463
Fixed #3814 (false positive: missing constructor)
2012-07-29 16:01:05 +02:00
PKEuS
4e2a86260f
Really fixed #3941 .
2012-07-29 06:50:05 -07:00
PKEuS
26a2379f9f
Fixed false positive #3941 .
2012-07-29 06:39:43 -07: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
PKEuS
6aa7f984cb
Fixed false positives on FILE* arrays. ( #3965 )
2012-07-29 04:04:12 -07:00
PKEuS
2f95b97c66
Message refactorization: checkobsoletefunctions.h and checknonreentrantfunctions.h
2012-07-29 02:30:03 -07:00
Daniel Marjamäki
79c84029fb
Preprocessor: Reduce simplifyVarMap usage to make Cppcheck a bit faster
2012-07-27 12:30:43 +02:00
Daniel Marjamäki
0ead18122d
Fixed #3695 (False positive: memory leak (ptr?free(ptr):0))
2012-07-27 12:25:20 +02:00
PKEuS
643f3890b4
Fixed #4003 : tmpnam may be called with a nullpointer
2012-07-27 01:36:22 -07:00
Daniel Marjamäki
1a6f7ea9a0
Fixed #3998 (Tokenizer::simplifyEnum: wrong handling of expressions => crash)
2012-07-26 11:12:28 +02:00
PKEuS
c11e8cdbfa
Fixed false positive "Variable is not assigned a value" on class types
2012-07-25 00:34:27 -07:00
Daniel Marjamäki
f82e5396c8
Fixed #3999 (Error incorrectly written in XML format)
2012-07-25 06:43:54 +02:00
PKEuS
f5e5d59562
Refactorizations:
...
- Removed redundant newlines at the end of test cases
- Make use of STL algorithms instead of own implementations of std::replace and std::remove+string::erase
- Removed unused variable (found by cppcheck)
- Prefer postfix increment (found by cppcheck)
2012-07-24 12:21:05 -07:00
PKEuS
bb940e4722
Implemented unused variable checking for standard types ( #2851 )
2012-07-24 11:47:29 -07:00
Daniel Marjamäki
e6f761126c
Fixed #2802 (False positive: ::free() is not recognised as free() to release buffers)
2012-07-24 09:28:08 +02:00
PKEuS
5c0cab238f
Fixed useInitializationList false positives ( #3988 )
2012-07-23 08:16:47 -07:00
PKEuS
ae6201d289
Fixed false positive "Parameter 'x' is passed as a value" for types like std::vector<T>::size_type ( #3986 )
2012-07-23 01:41:20 -07:00
Daniel Marjamäki
a733c9b603
Fixed #3914 (false positive null pointer dereference, assignment in conditional)
2012-07-23 10:05:55 +02:00
Zhao Qifa
188d2e143d
add a performance checker for const assignment
2012-07-22 09:17:00 +02:00
Ville Skyttä
7ab2f6a9fa
Spelling fixes.
2012-07-21 18:11:20 +02:00
Daniel Marjamäki
9352e124fe
Auto variables: Speedup my fix. Use the symbol database instead of Token::findmatch.
2012-07-19 16:42:56 +02:00
Daniel Marjamäki
dc6c3228d7
Fixed #3834 (Preprocessor: -U doesn't work)
2012-07-18 20:57:00 +02:00
Daniel Marjamäki
17c27f51ff
Fixed #3791 (False positive: returnTempReference)
2012-07-18 07:22:29 +02:00
Daniel Marjamäki
a768b0e8b2
Fixed #3954 (Pointer reference memory leak false positive)
2012-07-17 16:28:34 +02:00
Daniel Marjamäki
d34924ba6d
Uninitialized variables: Fixed false positive when there is assignment in condition
2012-07-17 07:03:40 +02:00
Daniel Marjamäki
ddfc968028
Fixed #3891 (False positive 'Double deallocation:' due to ((void*)1))
2012-07-16 17:07:51 +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
PKEuS
1e704edbd5
Message refactorization: checkio.h/cpp
2012-07-13 10:36:58 -07:00
PKEuS
41fecb2e6d
Fixed evaluation of redundant conditions ( #3972 )
2012-07-13 06:01:19 -07:00
PKEuS
247d820027
Fixed #3972 : Don't issue auto variable error when the address is assigned to a reference to a non-pointer.
2012-07-13 05:21:45 -07:00
PKEuS
4ed15d87b6
Properly fixed test failure and line numbers in uselessCallsEmpty error
2012-07-13 05:15:58 -07:00
Daniel Marjamäki
5645269bbf
Preprocessor: Made proper fix for #3690
2012-07-13 11:36:02 +02:00
Daniel Marjamäki
e4ad193b40
Fixed #3690 (CppCheck is stuck on evaluating false preprocessor expression( = 0))
2012-07-13 11:28:45 +02:00
Daniel Marjamäki
6018bb4636
Fixed #3442 (unmatchedSuppression can't be suppressed)
2012-07-13 08:29:49 +02:00
PKEuS
5a91d6a0f5
Check for useless calls of .empty() ( #3816 )
...
Messages from CheckStl::uselessCalls() only shown when correct severity is enabled.
2012-07-12 03:23:52 -07:00
PKEuS
3523f89917
Added 'char' back where I removed it by mistake.
2012-07-12 01:01:52 -07:00
Daniel Marjamäki
8dd5270be3
Preprocessor: skip preprocessor directives in the Preprocessor::validateCfg function
2012-07-11 21:20:31 +02:00
PKEuS
2bd1f1d8dc
Improved check: Sign checking in printf format string ( #3511 )
...
Removed some redundant code (already covered by token list simplifications and symboldatabase)
2012-07-11 10:46:35 -07:00
Daniel Marjamäki
4f4be79f20
Preprocessor: Fixed bugs in my #3643 fix
2012-07-11 18:29:33 +02:00
PKEuS
e8f4dce25f
Added check to CheckInternal: detect invalid patterns like "%typ%"
...
Replaced some Token::Match by Token::simpleMatch (suggestions of internal checks)
2012-07-11 08:45:16 -07:00
Daniel Marjamäki
17cf24ed34
Fixed #3643 (Preprocessor: Invalid configuration (macro is used in code))
2012-07-10 20:29:04 +02:00
PKEuS
68e19b33ff
Fixed parsing of C++11 initializatation in initializer list ( #3957 )
2012-07-10 06:15:11 -07:00
PKEuS
37d9d6fd7e
Improved parsing of C++11 initializer list ( #3956 ) in CheckClass::initializeVarList.
2012-07-10 05:47:51 -07:00
PKEuS
402a0058e2
Renamed target name in VS10 solution for cppcheck lib to cppcheck-core. This fixes the failure when _re_building cppcheck.
...
Name changes:
cppcheck.dll -> cppcheck-core.dll
cppcheck.lib -> cppcheck-core.lib
cppcheck.pdb -> cppcheck-core.pdb
2012-07-09 10:21:19 -07:00
PKEuS
b5589e41f9
Cleanup of VS10 solutions (As suggested by XhmikosR). Fixed problems:
...
- UNICODE set correctly
- Fixed path to pcre.lib; use external library directories
- Removed several unnecessary and redundant flags from projects
Thank you for your help, XhmikosR!
2012-07-09 08:09:54 -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
PKEuS
639f15645a
Message refactorization: checkbufferoverrun.cpp (2), checkclass.cpp, checkexceptionsafety.h
2012-07-09 02:11:05 -07:00
Daniel Marjamäki
42e68550fc
fixed doxygen errors
2012-07-08 19:32:33 +02:00
PKEuS
ed7e950671
Message refactorization: checkbufferoverrun.cpp
2012-07-08 06:51:24 -07:00