Commit Graph

2049 Commits

Author SHA1 Message Date
amai2012 36a6599386 #7324 segmentation fault (invalid code) in Tokenizer::simplifyTokenList1 2015-12-26 20:16:01 +01:00
Alexander Mai 87767fb666 #7228 segmentation fault (invalid code) in Tokenizer::isFunctionHead 2015-12-26 00:21:56 +01:00
Dmitry-Me 05cb4e16fe Fix misspelled word 2015-12-25 11:51:08 +03:00
PKEuS a6b719eb10 Refactorization: Fixed true positive when self-checking cppcheck 2015-12-18 18:13:13 +01:00
Dmitry-Me 0d2edc532c Remove redundant check 2015-12-16 16:36:06 +03:00
Dmitry-Me bd4b47123a Better variable name 2015-12-15 11:30:20 +03:00
PKEuS 18693a7fce Refactorized token.cpp:
- Removed redundant overload of Token::insertToken()
- Fixed leak in Token::deleteThis()
- Moved condition out of loop in Token::tokAt()
2015-12-14 22:04:51 +01:00
Dmitry-Me 182877df88 Variable name consistent with other code 2015-12-14 17:35:32 +03:00
Albert ARIBAUD (3ADEV) 58031147b2 Optimize tokenizing
Reorganize cppcheck.cpp to separate actual checking from
tokenizing and XML dumping. This implies splitting checkFile()
in three parts, checkRawTokens, checkNormalTokens() and
checkSimplifiedTokens().
2015-12-13 09:29:47 +01:00
Alexander Mai 96531d6ffe TokenList::createAst() doesn't validate itself anymore. Remove some duplicated code and fix glitch in TestGarbage::garbageCode162 2015-12-12 20:01:03 +01:00
PKEuS 51bb76c5b5 Optimization: Skip over expression in brackets in Tokenizer::isFunctionParameterPassedByValue() 2015-12-10 15:53:14 +01:00
Akhilesh Nema 932f6ea81b Cppcheck hangs with 100% CPU load in TemplateSimplifier::checkComplicatedSyntaxErrorsInTemplates (invalidcode) 2015-12-09 14:00:40 +01:00
Dmitry-Me 28bf944d81 Remove redundant checks 2015-12-09 11:10:56 +03:00
orbitcowboy eead6862cc Merge pull request #718 from Dmitry-Me/cacheAndReuse3
Cache and reuse value
2015-12-08 15:07:59 +01:00
Daniel Marjamäki e88a1b0915 astyle formatting 2015-12-08 14:23:26 +01:00
Dmitry-Me f96484b609 Cache and reuse value 2015-12-08 10:36:03 +03:00
Albert ARIBAUD (3ADEV) b8dd71c577 Factorize toxml() into a single member function
lib/symboldatabase.cpp and lib/tokenize.cpp both
define a static toxml() function. Make it a single
static ErrorLogger::toxml() member function.
2015-12-07 18:21:01 +01:00
amai2012 7129b1c5b3 Merge pull request #716 from Dmitry-Me/betterVariableName7
Better variable name
2015-12-07 10:35:34 +01:00
Dmitry-Me 67f0301f0b Better variable name 2015-12-07 12:21:17 +03:00
Alexander Mai 98f2cd021e #7199 SymbolDatabase::validate() should be run in debug mode and print debug messages. In turn correct some test examples with invalid code. 2015-12-06 08:14:04 +01:00
Alexander Mai 5cf923d091 Don't run SymbolDatabase::validate on --debug. Replace some NULL by nullptr 2015-12-05 21:07:03 +01:00
Alexander Mai ba0859e838 #6981 crash in checkvaarg.cpp (with possible fix). Avoid segfault. Add SymbolDatabase::validate() to allow validating smyboldatabase 2015-12-05 20:55:26 +01:00
Alexander Mai 6ae1533cb4 #7190 Cppcheck hangs with 100% CPU load in Tokenizer::simplifyAttribute (invalidcode). Call validate() once more in Tokenizer::simplifyTokenList1 to trigger invalid code exception 2015-12-05 13:55:33 +01:00
PKEuS 46d6623182 Refactorization: Improved performance of Tokenizer::isFunctionParameterPassedByValue()
- Skip it for C code
- Improved performance by around 80% on C++ code (3,5% of entire runtime)
2015-12-03 14:44:59 +01:00
PKEuS 32e2fb2f78 Refactorization: Prefer Token::simpleMatch over Token::Match also for non-const patterns. 2015-12-03 13:04:55 +01:00
PKEuS 00662ec484 Refactorization: Improve performance of simplifyTypedef by using Token::simpleMatch by ~15% (forgotten in b8d39a2229) 2015-12-03 12:50:42 +01:00
PKEuS b8d39a2229 Refactorizations:
- Improve performance of simplifyTypedef by using Token::simpleMatch by ~15%
- Simplified code in simplifyTypedef
- Ran AStyle
2015-12-02 23:32:50 +01:00
PKEuS 7ea9e3ca4f Refactorization: Improve performance of simplifyTypedef by adding a pre-check for Token::link() by ~25% 2015-12-02 22:41:09 +01:00
Alexander Mai f762affea0 Small refactoring: replace NULL by nullptr, remove redundant static keyword, Tokenizer::setVarId() uses const variable 'notstart' 2015-11-30 22:13:49 +01:00
Daniel Marjamäki 8a9e068129 Fixed #7119 (Cppcheck hangs with 100% CPU load in Tokenizer::copyTokens (invalidcode)) 2015-11-29 14:56:15 +01:00
PKEuS e8522c7883 Small refactorizations:
- #include cleanup
- Use std::array instead of std::vector
- Do not create a stringstream to concatenate 4 strings
- Use std::cout instead of printf
2015-11-29 10:56:44 +01:00
Daniel Marjamäki 8bb8290a6f Fixed GCC warnings. unused variable, shadow variable. 2015-11-28 18:15:47 +01:00
PKEuS 93c02ce826 Fixed compiler error introduced in previous commit and several MSVC warnings 2015-11-28 10:49:08 +01:00
Daniel Marjamäki 6b124a37d8 Cleanup some casts 2015-11-28 10:11:07 +01:00
Daniel Marjamäki c0da6c1541 simplifyCalculations: handle '(4%1<<1&4!=1)' better. must combine '!' '=' before constant folding. fixed the operator precedence for comparison operators. (#4931) 2015-11-28 09:04:22 +01:00
Alexander Mai 44305fd98e #6940 Unsigned overflow in TestBufferOverrun::negativeArraySize. Don't try to calculate size of array with negative array size 2015-11-28 07:27:52 +01:00
Daniel Marjamäki 2737f63f71 Wrong calculation of constants (simplifying: +,<<,% operations) 2015-11-25 16:46:39 +01:00
Daniel Marjamäki 5135bae777 Tokenizer: Cleanup the Tokenizer::tokenizeCondition used by the preprocessor 2015-11-23 16:53:30 +01:00
Daniel Marjamäki 8fd62e0cf9 Fixed #4931 (Wrong calculation of constants (simplifying: +,<<,% operations)) 2015-11-20 19:43:11 +01:00
Daniel Marjamäki 4abc0b7c1f Partial fix for #4931 (Wrong calculation of constants (simplifying: +,<<,% operations)) 2015-11-20 16:09:47 +01:00
PKEuS 00bdc89f98 Refactorizations:
- Rely on SymbolDatabase to detect string types
- Loop over variable list instead of token list
- Fixed two comments claiming that the AST is experimental
2015-11-20 11:20:42 +01:00
Daniel Marjamäki 40851a12ef Fixed #4627 (Tokenizer::setVarId: function declaration in function body) 2015-11-19 16:27:16 +01:00
PKEuS e990cfb76b Fixed setVarId() for destructors 2015-11-18 21:13:58 +01:00
Daniel Marjamäki 0f9d90d2be Changed Copyrights. Removed my name. 2015-11-18 20:04:50 +01:00
PKEuS 3f255e7685 Use Library information in Tokenizer::sizeOfType() 2015-11-15 14:37:02 +01:00
Alexander Mai 835c234e18 #7131 crash: Tokenizer::setVarId() 2015-11-14 21:22:53 +01:00
PKEuS f9bc229d4b Support varids in nested classes that are declared outside of outer class (#7127) 2015-11-13 10:07:57 +01:00
PKEuS ee00925dc5 setVarId: Support throw() in constructor implementations (#7123) 2015-11-11 11:01:49 +01:00
PKEuS 03d52de74b Treat "class" keyword similar to "struct" or "union" on C++ code (#6696) 2015-11-10 17:03:27 +01:00
PKEuS cc9a1f4375 Fixed setVarId() for template in initializer list (#7122) 2015-11-10 16:14:53 +01:00
PKEuS feae241fc0 Fixed simplification of pointers (#6829) 2015-11-10 14:45:24 +01:00
PKEuS 5cd36d6f8a Refactorization: Use varid instead of variable name in CheckClass::initializeVarList() and fixed issue in setVarId().
Fixed internal warning.
2015-11-09 23:00:14 +01:00
PKEuS 49a9b011eb Fixed handling of this-> and (*this). in setVarId() 2015-11-09 21:43:40 +01:00
Alexander Mai ab296fa93f 7111 segmentation fault (invalid code) in Tokenizer::simplifyRedundantParentheses 2015-11-08 13:45:55 +01:00
Daniel Marjamäki 3655ce7222 Fix typo in match pattern 2015-11-07 16:06:37 +01:00
Daniel Marjamäki f7a7a8a95c Fixed #6934 (False positive returnLocalVariable - assigning local array to function argument) 2015-11-07 15:07:26 +01:00
PKEuS 0ac89c8af2 Fixed internal warning 2015-11-06 22:21:39 +01:00
Aleksandr Pikalev 2d0ecc08c1 Check pointers for NULL before utilizing and do not check it later 2015-11-06 20:24:09 +01:00
PKEuS 7a90b763f6 Tokenizer::simplifyLabelsCaseDefault(): Do not insert ; between two cases. 2015-11-06 19:59:23 +01:00
PKEuS 95a0c0f14c Limit the number of cases created by Tokenizer::simplifyCaseRange(). 2015-11-06 19:21:56 +01:00
PKEuS 1fe1d7ea4a Extended Tokenizer::simplifyCaseRange() to support also ranges of chars. 2015-11-06 18:46:43 +01:00
PKEuS 41b1b9d850 Support case ranges (gcc extension, #6490) 2015-11-06 18:39:03 +01:00
PKEuS 2ac8da0497 Fixed #6548 also for noexcept 2015-11-06 18:00:59 +01:00
PKEuS 72bc6d1f33 Refactorization: Fixed VS warning about variable shadowing. 2015-11-06 17:35:08 +01:00
PKEuS 62bc827eb0 Fixed createLinks2() when inheriting from a template (#6601) 2015-11-06 10:44:37 +01:00
Alexander Mai 3177d73fb0 #7089 segmentation fault (invalid code) in Tokenizer::simplifyTokenList1. Refactor some functions to accept argument as refernce instead of pointer 2015-11-05 19:00:08 +01:00
PKEuS 83a816b109 Fixed crash on garbage code (#7085) 2015-11-04 10:26:55 +01:00
PKEuS 6c20f4b2a2 Fixed crash on garbage code (#7090) 2015-11-04 10:10:20 +01:00
PKEuS 8374e8414b Fixed use-after-free in clang test suite introduced recently (#7087) 2015-11-03 19:24:19 +01:00
PKEuS b97f9e576d Fixed crash in clang test suite introduced by previous commit. 2015-11-02 22:53:05 +01:00
PKEuS b049050792 Fixed wrong parsing of ^{} 2015-11-02 22:14:41 +01:00
PKEuS 4f565ba90f Fixed crashs on garbage code (#7082) 2015-11-02 21:30:28 +01:00
PKEuS 23e6e5a568 Fixed crash on garbage code (#7081) 2015-10-31 18:11:56 +01:00
PKEuS a0ff992c4a Refactorization: Simplified Tokenizer::simplifyAddBracesToCommand() and Tokenizer::simplifyAddBracesPair() 2015-10-27 20:04:34 +01:00
PKEuS 4ee56d2306 Fixed simplifyAssignmentInFunctionCall for complex expressions (#6927) 2015-10-27 20:01:40 +01:00
PKEuS 24882fb53a Fixed VarId accidentially assigned to case labels. 2015-10-26 21:24:53 +01:00
PKEuS 5add1d8901 Set VarId in range-based for-loops 2015-10-26 19:03:23 +01:00
PKEuS 297f2c78bd Fixed false positives variableHidingTypedef (#5624, #6507) 2015-10-26 10:06:52 +01:00
Simon Martin 5d40a3ab66 Ticket #6998: Properly handle "typedef unsigned T;" constructs. 2015-10-24 12:27:26 +02:00
Daniel Marjamäki b856ac51dd Fixed #7064 (Tokenizer: Wrong simplification of 'a.public:') 2015-10-19 10:01:57 +02:00
Daniel Marjamäki 5d12471caa fix travis, remove unused variable 2015-10-18 17:19:44 +02:00
Alexander Mai 8667184f12 #7062 Remove unnecessaryQualification check 2015-10-18 17:00:09 +02:00
Daniel Marjamäki fe4fac7eb2 Fixed #7058 (Tokenizer::simplifyTypedef: wrong simplification of enum constant 'AB::A' if AB is a struct typedef) 2015-10-18 04:55:04 +02:00
Dmitry-Me fa30ed5d15 Reduce variable lifetime, better name 2015-10-16 11:00:04 +03:00
PKEuS c22833342c Merge pull request #695 from Dmitry-Me/explicitContinue
Explicit continue instead of fall through with a check
2015-10-15 21:48:08 +02:00
Dmitry-Me ae7a7d287e Explicit continue instead of fall through with a check 2015-10-15 18:03:27 +03:00
Daniel Marjamäki 6cf25825de Fixed #7030 (Tokenizer::simplifyTypedef: Label) 2015-10-15 16:56:22 +02:00
Dmitry-Me 64bdf03986 Remove repeated search, clearer code 2015-10-15 16:48:35 +03:00
PKEuS 46bfa62aad Execute prepareTernaryOpForAST earlier (#7048) 2015-10-15 10:31:54 +02:00
Alexander Mai 600641c4c5 #7043 segmentation fault (invalid code) in Tokenizer::simplifyVarDecl 2015-10-14 20:34:55 +02:00
PKEuS d0cc97a4cf Fixed wrong syntax error (#7045) 2015-10-14 16:01:48 +02:00
Daniel Marjamäki a04e072976 Fixed #7040 (False positive syntaxError False positive syntaxError) 2015-10-13 20:31:17 +02:00
PKEuS 05b5275110 Improved AST:
- Fixed TODO for ternary operator. Add parantheses between ? and : where necessary as a preparation for createAst()
- Improved AST validation:
-- Better message for binary operator with only one operand
-- Ensure ? has : as second operand (#7035)
2015-10-12 19:21:48 +02:00
Daniel Marjamäki 97326fce13 Fixed #6992 (argument name of function typedef conflicts with local variable name) 2015-10-12 10:15:02 +02:00
Daniel Marjamäki 141dd78b0e Tokenizer: Added a define CPPCHECK2 that can be used to test cppcheck without various simplifications I want to get rid of in the long run 2015-10-12 09:19:35 +02:00
Daniel Marjamäki 6157fc69ac Tokenizer: Added a simple AST verification 2015-10-12 08:34:12 +02:00
Daniel Marjamäki 40fffddb83 avoid some fixes for noisy signedness warnings 2015-10-11 12:36:23 +02:00
Daniel Marjamäki a500f6f703 Improved handling of 'long double' and address-of in ValueType. Removed Tokenizer::simplifyFloatCasts() to handle float casts better. 2015-10-08 19:50:10 +02:00
PKEuS 3645e3c16b Fixed two TODO unit tests by delaying arraySize simpification until createLink2 is executed 2015-10-08 12:52:28 +02:00
Daniel Marjamäki 9b253612ca SymbolDatabase: Add type information in AST 2015-10-04 19:42:58 +02:00