Commit Graph

281 Commits

Author SHA1 Message Date
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
Daniel Marjamäki 0f9d90d2be Changed Copyrights. Removed my name. 2015-11-18 20:04:50 +01:00
PKEuS 41b1b9d850 Support case ranges (gcc extension, #6490) 2015-11-06 18:39:03 +01:00
PKEuS 72bc6d1f33 Refactorization: Fixed VS warning about variable shadowing. 2015-11-06 17:35:08 +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
Alexander Mai 8667184f12 #7062 Remove unnecessaryQualification check 2015-10-18 17:00:09 +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 7148ad4239 Tokenizer: Fix sloppy syntax error 2015-10-12 08:51:41 +02:00
Daniel Marjamäki df67e0efb6 Tokenizer: Try to hide attributes for non-gcc and non-clang compilers 2015-10-12 08:50:52 +02:00
Daniel Marjamäki 8b8870cb5e Added noreturn attributes for methods that throws 2015-10-12 08:33:53 +02:00
PKEuS 2ace3d3144 Rewritten handling of declaration specifiers:
- Removed simplifyConst() because it did the opposite of the (superior) simplifyStaticConst()
- Execute simplifyStaticConst() in simplifyTokenList1() - there is no reason to defer it, and it is required to properly parse declarations like "unsigned static int i;"
- Fixed simplifyStaticConst() to handle more patterns. It did not work at the beginning of the token list and for function arguments
- Reimplemented Tokenizer::simplifyStdType()
-> properly support all possible ways to declare integers as requested by the standard, instead of only a few common permutations of "unsigned|signed", "short|char|long|int"
-> Fixed parsing of _Complex/complex types
2015-08-27 14:34:17 +02:00
PKEuS c8c59aa92b Removed Tokenizer::simplifyIfSameInnerCondition(). It covered only very simple patterns and is unlikely to have an impact on real-world code. 2015-08-26 13:04:00 +02:00
PKEuS 8d926d7328 Moved some simple WinAPI/MFC-specific simplifications to windows.cfg 2015-08-20 15:59:59 +02:00
PKEuS 4e2d56242c Refactorization: Removed unreachable and duplicate code in tokenize.cpp 2015-08-19 19:29:48 +02:00
Alexander Mai a5aba110a4 Replace Tokenizer::simplifyBuiltinExpect by a suitable addition to gnu.cfg 2015-08-10 20:21:30 +02:00
Daniel Marjamäki 72706cd0b8 Fixed #6868 (Tokenizer: wrong simplification of the unlikely keyword) 2015-08-08 12:49:42 +02:00
Alexander Mai 4400f2ac85 #6900 segmentation fault (invalid code) in CheckStl::runSimplifiedChecks. 2015-07-31 20:24:06 +02:00
Daniel Marjamäki a17f4d0a2d CLI: Added --debug-normal option that will show --debug output after 1st simplifications. This output is relevant for the 'normal' checkers. 2015-07-28 12:46:32 +02:00
Daniel Marjamäki f9d22f70db Removed simplifyIfNot simplification (#6072) 2015-07-21 20:56:47 +02:00
Daniel Marjamäki 1b8252181d Tokenizer: Removed Tokenizer::simplifyIfNotNull (#6072) 2015-07-21 17:58:44 +02:00
amai2012 e8ac4d8e87 #6847 segmentation fault (invalid code) in Token::multiCompare. Fix and simple refactoring in Tokenizer 2015-07-21 13:40:50 +02:00
Alexander Mai d45aa6170b Minor refactoring in Tokenizer: Optimize for C code and use nullptr instead of 0 2015-07-16 00:29:48 +02:00
amai2012 4a47b8b3ae Refactoring: Better distinguish between C and C++ in a few checks. 2015-06-28 16:49:16 +02:00
Alexander Mai 8946fcd960 #6772 segmentation fault (invalid code) in Tokenizer::setVarId. Add another validate() call to Tokenizer::simplifyTokenList1. Small refactoring to Tokenizer: mark many methods as private. 2015-06-24 20:47:04 +02:00
Alexander Mai 6ba9c21fb9 #6786 segmentation fault (invalid code) in Tokenizer::simplifyRedundantParentheses. Small refactoring for Tokenizer::simplifyTokenList2() including additional calls to validate() - which prevents heap corruption on invalid code 2015-06-24 20:22:28 +02:00
orbitcowboy 06e818f89d Running astyle, no functional change. 2015-06-17 09:09:23 +02:00
amai2012 919fcb38f5 Refactoring Tokenizer
Create Tokenizer::simplifyAsm2(), skip simplifyExternC() in C code and
simplifyBorland() on non-Microsoft or C code
2015-06-16 20:53:11 +02:00
amai2012 d36c84553f #6748 segmentation fault (invalid code) in Tokenizer::simplifyTypedef. Throw error from now (member-function) Tokenizer::processFunc 2015-06-03 08:59:38 +02:00
PKEuS 77c5381612 Support C++14 [[deprecated]] 2015-05-10 12:36:28 +02: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
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
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
Daniel Marjamäki ff11ba9847 Updated copyright year to 2015 2015-01-03 12:14:58 +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 c7d315fba3 Refactorization: Changed simplifyMathFunctions() to a single pass simplifier 2014-10-31 23:08:11 +01:00
Dmitry-Me c3fa85b282 Reuse code in isXNumber() to avoid duplication and unneeded computations 2014-10-21 16:02:35 +04:00
PKEuS 59cccb83ce Reimplemented version.h:
- Use macros to form version number and string. CPPCHECK_MAJOR, CPPCHECK_MINOR and CPPCHECK_DEVMINOR now contain the parts of the version number.
- "dev" status is now detected by comparison of CPPCHECK_MINOR and CPPCHECK_DEVMINOR, version string created accordingly.

Fixed two comments.
2014-09-01 08:48:25 +02:00
Daniel Marjamäki 8db5836e3f Fixed #5982 (Add xml dump) 2014-07-14 15:51:45 +02:00
Zachary D. Blair f6523e384b Fixed 4979 (Doesn't allow any ordering of int modifiers) 2014-07-01 23:59:04 -07:00
PKEuS ec1bd420a7 Refactorizations optimizing std::string usage:
1) Added global static const std::string emptyString; object:
-> Replaces some static variables in functions which might be not threadsafe
-> Avoids constructor call (std::string::string(""))
-> Even functions that return an empty string in some branches can return by reference now.
Added to config.h to ensure that it is available everywhere

2) Added overloads for TestFixture::assertEquals for the most common use cases:
-> Moves conversion from const char[] to std::string into a function, reducing code duplication in binary.
2014-06-26 11:51:02 +02:00
Daniel Marjamäki a4a6f3e1be Tokenizer: Removed Tokenizer::simplifyConditionOperator(). Using the AST and ValueFlow, it should be much easier to parse ?: than before. 2014-06-10 19:30:13 +02:00
Daniel Marjamäki a41f6077e1 Tokenizer: Use 'podtype' info from library. Partial fix for #5623 2014-06-08 13:28:15 +02:00
PKEuS 8db0790407 Tokenizer::tokenize() can now be called without AST being created 2014-06-04 18:45:28 +02:00
PKEuS d93d7401c6 Moved getSourceFilePath(), isC() and isCPP() from Tokenizer to TokenList
Conflicts:
	lib/tokenize.cpp
2014-06-04 18:36:25 +02:00
Alexander Mai be9a566d48 Refactoring/small corrections to fix warnings from clang -fsanitize=undefined 'member call on null pointer' 2014-05-20 21:55:08 +02:00
Alexander Mai ead3f28e06 Small enhancements for doxygen 2014-04-27 21:42:10 +02:00
Robert Reif ca9386859b Tokenizer: replace ') const| {' pattern to detect function start 2014-04-26 18:31:56 +02:00
Alexander Mai b5c580a59e Fix some clang warnings - most related to semantic doxygen errors 2014-04-26 16:17:26 +02:00
PKEuS efe3f834be Refactorized handling of syntaxError: Print debug output, removed a few return values that are no longer required 2014-03-27 18:41:52 +01:00