Commit Graph

1884 Commits

Author SHA1 Message Date
amai2012 f1c4cc6d55 Merge pull request #598 from simartin/useless_str_check
Removed unnecessary string comparison in Tokenizer::simplifyKnownVariablesSimplify
2015-05-25 19:13:33 +02:00
Simon Martin c58fab07d6 Removed unnecessary string comparison in Tokenizer::simplifyKnownVariablesSimplify. 2015-05-24 13:13:46 +02:00
Alexander Mai 7f15873759 Refactoring in tokenize.cpp: Fix cppcheck warning, add some const, fix typo from previous refactoring 2015-05-24 11:43:46 +02:00
Alexander Mai 7002f9df35 Merge branch 'master' of https://github.com/danmar/cppcheck 2015-05-24 09:43:52 +02:00
Alexander Mai 394160184a Refactoring: Replace complex if/else cascade by search in a container. Remove redundant plain arrays (in favour of container) 2015-05-24 09:43:17 +02:00
Simon Martin 26f244e638 Ticket #6704: Tighten pattern skipping base class declarations and fix crash upon garbage code. 2015-05-24 08:16:34 +02:00
Alexander Mai 7416d6add9 Another fix for handling of final/override specifiers in Tokenizer::simplifyKeyword() including a testcase. Ran astyle 2015-05-23 20:51:15 +02:00
Alexander Mai f0bc300198 #6510 False positive performance warning for std::list::size(). Fix this and other similar false positives. Refactoring of Variable::isStlType(), use fail-safe std::set instead of plain array. Run astyle 2015-05-17 20:02:41 +02:00
amai2012 20842fb1fc #6690 override and final qualifiers plus less than operator results in a syntax error
Tokenizer::simplifyKeyword() is now able to handle all combinations out
of const|final|override
2015-05-17 13:02:13 +02:00
PKEuS 3ce4e68ca6 Refactorization: Make use of do-loops to avoid redundant Token::Match() calls 2015-05-13 13:40:40 +02:00
PKEuS b946b74e09 Fixed crash #6686 2015-05-13 13:02:33 +02:00
PKEuS 1b6e4589da Implemented array size calculation for n-dimensional arrays with arbitrary dereferencing (#6657) 2015-05-11 17:30:11 +02:00
PKEuS 77c5381612 Support C++14 [[deprecated]] 2015-05-10 12:36:28 +02:00
Alexander Mai 6f96634759 #6276 clang: -fsanitize=integer warnings. Fix unwanted integer overflow in TemplateSimplifier::useDefaultArgumentValues() and Tokenizer::simplifyQtSignalsSlots() 2015-05-03 15:21:58 +02:00
Frank Zingsheim 9bea7bec92 Fixed #6659 (heap user after free: kernel: sm750_accel.c) 2015-05-01 18:28:00 +02:00
orbitcowboy 785df82513 #6660: Fixed crash in Tokenize::SetVarid(). 2015-04-29 09:18:54 +02:00
PKEuS ac867b4220 Handle pointers to const member functions in Tokenizer::simplifyFunctionPointers() (#6603) 2015-04-13 21:21:57 +02:00
PKEuS c4ceb97cea Fixed #6629: Don't simplify sinf(0) if sinf is a variable 2015-04-13 20:37:07 +02:00
PKEuS 708a379fd2 Refactorized simplification of sizeof without parantheses:
- Moved sizeofAddParentheses() behind combineOperators()
- Improved sizeofAddParentheses() to handle all code from unit tests at simplifyTokenList1()
- Removed simplification from simplifyTokenList2()
2015-04-13 20:18:21 +02:00
PKEuS 4c40664861 Fixed #6639: Calculate sizeof() of multidimensional arrays 2015-04-13 20:18:21 +02:00
PKEuS c2ccd7d9e4 Simplify _declspec like __declspec 2015-04-11 11:02:52 +02:00
Matthias Krüger 42f0955e3f Move more setting checks out of loops and use const bools instead. Reorder a few related checks.
Follow up to eedcb6abcb .
2015-04-10 14:31:19 +02:00
Frank Zingsheim 84830638a2 Improved fix #6636: (False positive unreadVariable - scope analysis seems to fail to False positive unreadVariable) 2015-04-09 21:09:31 +02:00
Frank Zingsheim d52b031301 Fixed #6638: (varid for loop in for statement) 2015-04-09 19:58:12 +02:00
Frank Zingsheim 648ee95f31 Fixed #6636: (False positive unreadVariable - scope analysis seems to fail to False positive unreadVariable)
Bug was introduced by 1f5265c1bd
2015-04-08 20:30:41 +02:00
Matthias Krüger eedcb6abcb move setting flags checks out of for loops, make them const. 2015-04-07 07:23:28 +02:00
Frank Zingsheim 1f5265c1bd Fixed #6253 ([False Positive] Variable not initialized in the constructor) 2015-04-06 19:47:21 +02:00
PKEuS 72b4809da0 Moved simplification of operator names before template and parentheses simplifications (#6576) 2015-04-01 13:47:36 +02:00
PKEuS 0d37c4df04 Fixed three unique crashs on garbage code (#6613).
Removed redundant copy of string in templatesimplifier.cpp
2015-04-01 12:43:24 +02:00
PKEuS 4c3a7661c3 Merge pull request #565 from Dmitry-Me/cacheAndReuse
Cache and reuse value
2015-04-01 11:30:13 +02:00
Dmitry-Me e8f0abf259 Proper simplify delete a,b 2015-03-25 16:54:23 +03:00
Daniel Marjamäki a3a5c74bbf Revert "Remove bitwise-or abuse"
This reverts commit 7017b051fe.
2015-03-24 08:07:15 +01:00
Dmitry-Me 7017b051fe Remove bitwise-or abuse 2015-03-23 13:30:05 +03:00
Dmitry-Me 8f21aba606 Cache and reuse value 2015-03-20 12:39:51 +03:00
Dmitry-Me 20d4c6fad3 Eliminate duplication in TCHAR functions substitution 2015-03-19 18:41:36 +03:00
Dmitry-Me 9703e6b72b Unicode names set for ANSI 2015-03-19 13:26:08 +03:00
Dmitry-Me 7afe4ba5e0 Mismatching TCHAR function names 2015-03-19 10:41:02 +03:00
Dmitry-Me 8f8ba65a29 Eliminate repeated lookup 2015-03-18 11:52:09 +03:00
Dmitry-Me 15a847cc0d Move declaration to where it's first needed 2015-03-18 10:07:13 +03:00
Dmitry-Me 3ab3715a88 Merge overlapping patterns 2015-03-17 16:23:19 +03:00
PKEuS e978a681a3 Removed unused variable 2015-03-15 10:19:35 +01:00
PKEuS 713d993f71 Some refactorizations in Tokenizer:
- Refactorized simplifyTypedef
- Perform some template specific code only on non-C code
2015-03-15 10:04:44 +01:00
Simon Martin 32a7a178e8 Code simplification now that ">>" is turned into "> >" when it closes template argument lists. 2015-03-14 23:02:10 +01:00
PKEuS 430d8ca760 Refactorized code in simplifyEnum() 2015-03-14 20:43:14 +01:00
PKEuS 3d2e26daeb Small Refactorizations:
- Removed #include "symboldatabase.h" from library.h
- Moved variable to inner scope in tokenize.cpp
- Removed unnecessary variable in tokenize.cpp
2015-03-11 20:52:54 +01:00
Simon Martin 9c6a625f91 Ticket #6181: Normalize '>>' into '> >' when it's closing a C++11 template parameter list. 2015-03-07 11:06:04 +01:00
Daniel Marjamäki f705cdce72 Fixed #6556 (Tokenizer::simplifyVarDecl: doesn't simplify template variables properly) 2015-03-06 17:30:20 +01:00
Daniel Marjamäki e38f15ecc0 --check-library: dont write <noreturn> messages now since they cant be fixed. 2015-03-05 07:19:03 +01:00
Daniel Marjamäki 86cdc8e7a6 Fixed #6540 (Tokenizer::simplifyKnownVariables: Missing varid for simplification in conditional code) 2015-03-02 06:18:00 +01:00
Daniel Marjamäki 449b88aa0c Fixed #6547 (Regression - unknown macro causes analysis error) 2015-02-28 11:09:39 +01:00
Daniel Marjamäki 3add466035 Add isFunctionHead() in Tokenizer 2015-02-27 18:29:34 +01:00
Daniel Marjamäki acbf48c7fa Fixed #6548 (Tokenizer: Wrong varid set after function which is throw()) 2015-02-26 16:31:42 +01:00
Alexander Mai 8427398d9d #6539 Segmentation fault in Tokenizer::duplicateTypedef. Avoid crash on garbage code 2015-02-24 11:15:23 +01:00
Daniel Marjamäki d4fa656e58 Refactor and improve Tokenizer::sizeofAddParentheses 2015-02-22 13:38:06 +01:00
PKEuS f04070940e Fixed setVarId on ternary operator in initialization list 2015-02-22 11:57:46 +01:00
Dmitry-Me 6f6f9f7754 Reorder checks, move declaration 2015-02-06 16:30:39 +03:00
Dmitry-Me 21fbc30d59 Calling a function using Class::func() syntax should not be simplified 2015-02-02 10:37:10 +03:00
PKEuS 9dfb864522 Fixed two nullpointer messages in cppcheck 2015-02-01 15:21:09 +01:00
PKEuS a4cc4c3e3f Refactorization: Use SymbolDatabase scope information in ValueFlow 2015-02-01 12:10:20 +01:00
PKEuS 21cb0cfd60 Take simplifyIfNotNull and simplifyIfNot out of simplifyTokenList1 (first step for #6072) 2015-01-31 20:12:02 +01:00
PKEuS 1f97e3001b Fixed calculation of array size (#6487) 2015-01-31 19:06:44 +01:00
PKEuS b2835051df Refactorization: Renamed Token::Match pattern %var% to %name%, implement new pattern %var% which is true if varId > 0. 2015-01-31 12:32:04 +01:00
Samir Aguiar 141a071792 * Added Clang-related flag to gui.pro
* Updated external lib location with PWD variable
2015-01-20 19:20:00 +01:00
Thomas Jarosch c0aceb893e Replace custom code with Settings::isWindowsPlatform() 2015-01-18 12:43:43 +01:00
Thomas Jarosch 9a5260a43f Only simplify Windows's DEBUG_NEW macro on Windows platform 2015-01-18 12:20:23 +01:00
Robert Reif 193645318b Tokenizer: Remove macro in class declaration like 'class DLLEXPORT Fred {}' to be able to handle the class better later 2015-01-17 07:42:49 +01:00
Aneesh Azhakesan S fe5d2fc245 Fixed #5906 (false negative: 'else if' expression is always false (use library to determine if function is pure)) 2015-01-10 12:21:55 +01:00
PKEuS 7452613479 Refactorization:
- Merged messages exceptThrowInNoexecptFunction, exceptThrowInNoThrowFunction, exceptThrowInAttributeNoThrowFunction and exceptThrowInDeclspecNoThrowFunction into a single message.
- Merged Token::fIsDeclspecNothrow into Token::fIsAttributeNothrow
2015-01-09 20:18:09 +01:00
Daniel Marjamäki 6a8293a8b7 Library: More strict matching of functions 2015-01-08 19:31:41 +01:00
orbitcowboy ba837a6f2d Added support for strpbrk to std.cfg. Running astyle. 2015-01-07 02:34:41 +01:00
Daniel Marjamäki 8a6bb46958 Tokenizer: only print AST in debug output if --verbose is used 2015-01-07 06:46:04 +01:00
Daniel Marjamäki b0cc46e98b reverted 840b2fb0, it caused FN. tweaked the Tokenizer::simplifyAssignmentBlock to fix the FP it caused. 2015-01-07 06:38:42 +01:00
Daniel Marjamäki 840b2fb035 Tokenizer: Removed simplification Tokenizer::simplifyAssignmentBlock. This fixes a fp in linux. 2015-01-06 20:44:58 +01:00
Daniel Marjamäki d1927e3492 Removed Tokenizer::simplifyStructInit simplification. 2015-01-04 16:48:52 +01:00
Daniel Marjamäki 7bafbfbd6e Tokenizer: cleanup simplification of '!= 0' to avoid FP in 'x[(y & 0x80) != 0]' (linux) 2015-01-04 13:50:54 +01:00
PKEuS 016e89e422 Refactorizations:
- Disabled some parts of setVarId() for C code.
- Fixed mistake in <contaier> documentation
2015-01-04 10:52:11 +01:00
Daniel Marjamäki eb1c048d2a Tokenizer: Fix wrong simplification when checking linux kernel 2015-01-03 21:35:03 +01:00
Daniel Marjamäki ff11ba9847 Updated copyright year to 2015 2015-01-03 12:14:58 +01:00
PKEuS 274e1a838a Fixed #5871: Properly parse initialization list in setVarId() if constructor is declared as noexcept 2015-01-02 20:03:06 +01:00
PKEuS 88990bac59 Fixed #6386: Improved behaviour on unknown language (header file) 2015-01-02 12:32:23 +01:00
PKEuS 5dc45bd4ac Fixed #5497: Support designated initializers in array size detection 2014-12-30 19:23:01 +01:00
Thomas Jarosch 69b31a0743 Fix up extra whitespaces in match patterns
Detected by new internal check.
2014-12-30 14:53:43 +01:00
PKEuS 990d14f3e2 Fixed #6328: Use isAttributeNoreturn() whereever we also check Library::isnoreturn(). 2014-12-27 11:07:36 +01:00
Robert Reif 9e60f584d9 Fixed #6321: Implemented function Token::swapWithNext(). 2014-12-27 10:53:26 +01:00
Daniel Marjamäki 06803ee333 Refactoring Tokenizer::simplifyAttribute 2014-12-24 13:03:38 +01:00
Daniel Marjamäki fb3f5a159d Token: Added flag for attribute noreturn (#6328) 2014-12-24 12:50:51 +01:00
Daniel Marjamäki 90bd38a972 Renamed isCasted to isCast 2014-12-24 10:35:40 +01:00
Daniel Marjamäki 1b2a23b3fe Fixed #6350 (Tokenizer::simplifyCast: set Token::isCasted when cast is removed) 2014-12-23 16:16:14 +01:00
PKEuS 4d81945ac5 Fixed a couple of #6276 integer over/underflow issues 2014-12-09 23:28:22 +01:00
Dmitry-Me ff6604e289 Make expensive string manipulation depend on settings 2014-12-09 06:08:38 +01:00
Daniel Marjamäki 64e6b5186d astyle formatting 2014-12-05 06:41:47 +01:00
Matthias Krüger 7a6cd54059 Fix [lib/tokenize.cpp:6184]: (warning) Found simple pattern inside Token::Match() call: ") {" 2014-12-04 11:11:47 +01:00
Daniel Marjamäki e3892a95b5 Fixed #6290 (Tokenizer: Because 'and' is not simplified to '&&' there are false positives) 2014-12-03 16:32:05 +01:00
Dmitry-Me cf3f8c2f38 Refactoring: Replace names with underscores with camelCase names 2014-12-01 16:22:56 +01:00
Dmitry-Me 828fdb6c47 Code cleanup. Omit redundant check. 2014-11-28 17:48:23 +01:00
Robert Reif 418c2e51a0 Fixed #3314 (cppcheck incorrectly reporting Syntax error.) 2014-11-28 17:44:36 +01:00
Robert Reif 0dad8b64e8 Fixed #6268 (False positive functionStatic (inconclusive) - nested namespaces) 2014-11-27 06:29:33 +01:00
Daniel Marjamäki 051d42ae6b astyle formatting 2014-11-20 14:20:09 +01:00
orbitcowboy f5d804f71a running astyle 2014-11-20 10:13:03 +01:00
PKEuS 428587f3d4 Fixed #6275: Simplification of = (NULL); to = 0; 2014-11-18 19:39:38 +01:00
PKEuS ad8749c0bd Fixed #6278: Remove casts to references to pointers in Tokenizer::simplifyCasts() 2014-11-18 19:23:59 +01:00
Daniel Marjamäki ea765c24f2 Fixed #3262 (Tokenizer: wrong 'return a=1,b=2,...;' simplification;) 2014-11-10 17:31:19 +01:00
Robert Reif df6855c216 SymbolDatabase: reintroduce test, move symboldatabase cleanup code to SymbolDatabase destructor 2014-11-02 10:36:52 +01:00
Robert Reif 4eb33e7479 SymbolDatabase: Refactoring of findFunction 2014-11-01 14:36:17 +01:00
PKEuS c7d315fba3 Refactorization: Changed simplifyMathFunctions() to a single pass simplifier 2014-10-31 23:08:11 +01:00
PKEuS f8371f65f0 Refactorization: Avoid string copying. 2014-10-31 22:36:44 +01:00
PKEuS 9b0b7a77b6 Removed unnecessary conditions and avoid string copying in Tokenizer::simplifyMathFunctions() 2014-10-31 13:59:39 +01:00
PKEuS d29117c4b2 Rearranged some code in simplifyTypedef 2014-10-30 23:48:23 +01:00
PKEuS 6fdaf65cea Fixed createLinks2() when > is followed by ; (#6242) 2014-10-30 11:15:24 +01:00
Simon Martin c6e2107d99 Ticket #6187: Avoid infinite loop if eraseDeadCode does not remove anything (this time without memory corruption). 2014-10-22 20:25:36 +02:00
Daniel Marjamäki e965d8de67 Merge pull request #455 from Dmitry-Me/refactorNumberIsX
Reuse code in isXNumber() to avoid duplication and unneeded computations
2014-10-21 15:30:19 +02:00
Dmitry-Me c3fa85b282 Reuse code in isXNumber() to avoid duplication and unneeded computations 2014-10-21 16:02:35 +04:00
Robert Reif 42f709c09d Fixed #6229 (Move Windows builtin types __intXX to library) 2014-10-21 06:11:19 +02:00
Robert Reif e2f72b4cb1 Fixed #6215 (Move Windows platform types into library) 2014-10-19 07:34:40 +02:00
Frank Zingsheim 3923618b8d Fixed #6222 (Missing varid for multiple braced initialized variables)
-> Fixed broken code in unit tests
2014-10-16 20:46:57 +02:00
PKEuS eefaddf980 Fixed bug in Tokenizer::simplifyReference() (#6133) 2014-10-16 11:43:42 +02:00
PKEuS 6955e719cf Collected garbage code tests and moved them to testgarbage.cpp 2014-10-16 10:59:46 +02:00
Daniel Marjamäki ecd17d84fb Reverted f088588c fix for #6187 that fixes infinite loop, the fix cause a use-after-free regression. 2014-10-16 06:32:06 +02:00
Frank Zingsheim eab0878b8a Support {} initialization in initializer list (#6216) 2014-10-15 21:33:21 +02:00
Daniel Marjamäki 17cab08cba Tokenizer::setVarId: Refactored fix to avoid varId for function name 2014-10-15 06:47:09 +02:00
Daniel Marjamäki 36297f1025 Tokenizer::varId: don't set varid for function name in code 'bool f(X x, int=3);' 2014-10-14 20:37:32 +02:00
Daniel Marjamäki 30353d4b61 Tokenizer::setVarId: better handling of c++ casts 2014-10-11 18:35:06 +02:00
Simon Martin 70561682eb Tokenizer::simplifyConstTernaryOp: Properly detect the end of the 'false' part of ternary operators when it contains '>'. 2014-10-11 17:01:55 +02:00
Daniel Marjamäki 8c8e85d2db Tokenizer::setVarId: A variable declaration can't start with the typedef keyword 2014-10-11 16:30:51 +02:00
Daniel Marjamäki dd6ae3033f Tokenizer::simplifyRedundantParentheses: dont remove parentheses in 'void * operator new(SIZE_TYPE, int);' 2014-10-11 09:18:43 +02:00
Daniel Marjamäki b0b86f5607 Fixed internal error, use Token::simpleMatch for pattern 'const new' instead of Token::Match 2014-10-10 18:58:04 +02:00
Daniel Marjamäki 19a05b1f53 Tokenizer::setVarId: don't set varid for 'auto' keyword 2014-10-10 16:46:31 +02:00
amai2012 85500dcdbd Merge pull request #453 from simartin/ticket_5625
Ticket #5625: Simplify constant ternary operator in template parameters.
2014-10-06 09:01:08 +02:00
amai2012 cddb4af10b Merge pull request #450 from simartin/ticket_6187
Ticket #6187: Avoid infinite loop if eraseDeadCode does not remove anything
2014-10-06 08:59:56 +02:00
Simon Martin 9ddf857dc7 Ticket #5625: Simplify constant ternary operator in template parameters. 2014-10-04 20:49:57 +02:00
PKEuS a02712cb66 Some small refactorizations:
- Removed redundant calls to std::string constructor
- Use default parameters in some places
2014-10-03 10:02:46 +02:00
PKEuS 14f15d65e7 Support more patterns when replacing stuff like 'or' (#6201) 2014-10-01 08:41:55 +02:00
Simon Martin f088588c88 Ticket #6187: Avoid infinite loop if eraseDeadCode does not remove anything (invalid goto into a dead loop's body). 2014-09-30 19:43:22 +02:00
PKEuS 448195f255 Added variable name to debug message about typeStartToken()
Fixed cppcheck message
2014-09-29 14:36:03 +02:00
PKEuS de13ad7eca Improved simplifications of redundant loops:
- Execute simplifyWhile0 after simplifyKnownVariables (#394)
- Support declaration of variable in loop header in removeRedundantFor
2014-09-26 10:47:05 +02:00
Dmitry-Me b17f2eea16 Cache search result to avoid dual search 2014-09-22 15:54:17 +04:00
Daniel Marjamäki f93cf9d1b7 Fixed #6170 (Tokenizer: sizeof on array in 2d-array is not handled properly) 2014-09-16 17:21:17 +02:00
Dmitry-Me b479948f0f Refactoring: Merge overlapping Token::Match function calls 2014-09-16 06:22:16 +02:00
Daniel Marjamäki 29a49d0641 removed some redundant null pointer checks before calling Token::Match 2014-09-14 11:35:04 +02:00
Simon Martin 53b58f0ed9 Refactoring. Use Token::Match instead of hardcoded patterns to increase readability. 2014-09-14 11:26:16 +02:00
Simon Martin 4b750997cb Ticket #6121: Report a syntax error for invalid enum initializers. 2014-09-13 20:46:53 +02:00
Dmitry-Me 961a1b65ae Merge partially duplicate patterns 2014-09-12 19:10:41 +04:00
Matthias Krüger 323fd1b3dc tokenize.cpp: fix internal warning: Found simple pattern inside Token::Match() call: ") :" 2014-09-08 22:00:57 +02:00
Frank Zingsheim 8c5013adda Fixed #6073 2014-09-07 21:53:32 +02:00
Daniel Marjamäki db929ffd19 Fixed CID 1037074. Useless null pointer check. Created ticket #6144. 2014-09-07 13:50:55 +02:00
PKEuS 35b00a5e05 Support rValue references in typedef (#1823) 2014-09-06 19:00:26 +02:00
Simon Martin eeeb816db9 Ticket #6103: Simplify "new (type)" constructs into "new type" to avoid confusion upon certain input. 2014-09-05 08:02:18 +02:00
PKEuS 8c24553229 Support inherited member variables in setVarId (#4101) 2014-09-04 22:22:09 +02:00
PKEuS a52401cf1b Fixed some compiler warning about signed/unsigned conversions. 2014-09-02 11:44:51 +02:00
PKEuS 3e65cb446e Remove "auto" keyword (storage class specifier) from C++03 and C code (#4990). 2014-09-02 11:21:47 +02:00