Commit Graph

2329 Commits

Author SHA1 Message Date
Simon Martin cbf0b13b3e Ticket #8255: Don't crash upon invalid code while checking conditions. 2017-11-25 08:22:39 +01:00
Daniel Marjamäki 5cfa13c31c Reuse Token::isControlFlowKeyword() 2017-11-17 22:18:19 +01:00
Daniel Marjamäki b57dd4359b Fixed #8263 (check-library incorrectly reports missing configuration for case when value is in parentheses) 2017-11-17 22:10:39 +01:00
Daniel Marjamäki 31a1cebc5f Fixed #8272 (setVarIdPass2: Broken parsing of class header) 2017-11-11 12:04:25 +01:00
Daniel Marjamäki 4740bf116f Remove unused variable 2017-11-11 11:31:27 +01:00
Daniel Marjamäki b01772e4d1 Fix testcase 2017-11-10 21:28:13 +01:00
Daniel Marjamäki 6b1a2dcc5d Fixed #7788 (Varid missing for member variable in ctor of template class) 2017-11-10 21:03:15 +01:00
Daniel Marjamäki 7ec0e41196 Fix Cppcheck performance warnings 2017-11-09 23:18:00 +01:00
Daniel Marjamäki 799f953c00 Fixed #8269 (Tokenizer: wrong varid (using namespace A::B)) 2017-11-09 23:15:16 +01:00
Daniel Marjamäki 2408f01cc0 Fixed #8270 (Tokenizer: wrong varid (using namespace std)) 2017-11-09 22:08:58 +01:00
Daniel Marjamäki b67cf0a475 Improved handling of varid in complex scopes 2017-11-09 15:58:08 +01:00
Daniel Marjamäki cc08d51505 Fix Cppcheck warning (use prefix increment for iterator) 2017-11-09 08:40:13 +01:00
Daniel Marjamäki 26b9e1528c Fixed #7000 (Invalid varid - matching class with same name from other namespace) 2017-11-08 22:52:27 +01:00
Daniel Marjamäki 8b384f8ee5 Fixed #4988 (Tokenizer::setVarId: Wrong varid for inline function parameter) 2017-11-05 22:25:46 +01:00
Daniel Marjamäki 511d14a051 astyle
[ci skip]
2017-11-05 17:56:24 +01:00
Daniel Marjamäki 4d8f069907 Renamed pro c sql to embedded sql 2017-11-03 21:04:12 +01:00
Daniel Marjamäki 4f6f1e20dd Hide Pro*C SQL simplification. Use pro_c_sql.cfg library file if this is wanted. 2017-11-03 13:02:29 +01:00
Daniel Marjamäki 9b2936a66f Code refactoring 2017-11-03 11:41:32 +01:00
Alexey Eryomenko 02461753f3 Fix for embedded PL/SQL blocks (Oracle Pro*C) (#985)
* fix for correct parsing of embedded PL/SQL blocks (Oracle Pro*C)

* enforce SQL block end at the end of nearest outer C block, when
appropriate terminator is not found

* added check for ; at the end of END-EXEC and made SQL block detection
more readable
2017-11-03 11:31:33 +01:00
Oleksandr Redko a8700f5622 Remove redundant parts of conditional expressions (#988)
All issues were found with PVS-Studio:
V560 A part of conditional expression is always true: tok. astutils.cpp 407
V560 A part of conditional expression is always true: size > 0. checkbufferoverrun.cpp 709
V547 Expression 'secondTrue' is always true. checkcondition.cpp 1013
V547 Expression 'firstTrue' is always true. checkcondition.cpp 1020
V560 A part of conditional expression is always true: !scan. checkio.cpp 1036
V560 A part of conditional expression is always true: scope->function. checknullpointer.cpp 395
V560 A part of conditional expression is always true: tok2. checkstl.cpp 268
V560 A part of conditional expression is always true: par. tokenize.cpp 9440
V547 Expression '!erased' is always true. symboldatabase.cpp 3990
2017-11-03 10:39:57 +01:00
Dmitry-Me eb6bf1bcae Cache and reuse value 2017-10-23 00:42:56 +03:00
Dmitry-Me 1de8f771e9 Cache and reuse value 2017-10-23 00:41:29 +03:00
Dmitry-Me 46f726c049 Cache and reuse value 2017-10-23 00:36:05 +03:00
Daniel Marjamäki 0425f1d46d Fixed #8241 (FP: Same expression on both sides of operator) 2017-10-16 17:39:50 +02:00
Ayaz Salikhov be2c65eb58 Simplify int vs bool 2017-10-08 07:54:39 +02:00
Alexey Eryomenko 22483baf72 missed simplification in parsing of std function declaration resulted in (#967)
wrong type detection
2017-10-03 22:10:13 +02:00
Daniel Marjamäki 89b9f57759 Fix corrupt Token::Match pattern 2017-09-21 15:01:34 +02:00
Daniel Marjamäki 71d207c034 Fixed #8226 (Tokenizer: Wrong handling of string literal u"abc") 2017-09-21 13:33:14 +02:00
Daniel Marjamäki 2e6d78bd08 Fixed #8184 (Syntax error: case outside switch) 2017-09-15 22:37:31 +02:00
Ayaz Salikhov f0b5327450 Fix codestyle (#953) 2017-09-07 13:00:46 +02:00
Dmitry-Me 35f5515931 Fix CID 1360383 2017-09-06 00:12:09 +03:00
Dmitry-Me 3127fcf429 Omit repeated computations 2017-09-05 17:56:57 +03:00
Daniel Marjamäki 82527422a8 Fixed #5614 (Incorrect syntax error with function pointer typedef and dependent template types) 2017-08-30 19:18:05 +02:00
Dmitry-Me cc97834e88 Revert "Combine overlapping patterns"
This reverts commit 123f9b67e0.
2017-08-26 08:18:24 +03:00
Dmitry-Me 123f9b67e0 Combine overlapping patterns 2017-08-26 07:32:02 +03:00
Dmitry-Me b9c2a996bf Break loop early 2017-08-26 07:26:28 +03:00
Dmitry-Me eba9ea0ed0 Remove redundant check 2017-08-24 18:11:54 +03:00
Daniel Marjamäki 92e9744020 Fixed #8148 (Tokenizer: Braces are not added properly in do while) 2017-08-16 18:55:34 +02:00
Martin Güthle 1d491bd332 Treat noexcept correctly
Converts the noexcept to the already correctly handled noexcept(true)
2017-08-16 11:31:19 +02:00
Daniel Marjamäki 5c733c8f22 Fixed #8152 (Garbage code cause crash '0|\0|0>;') 2017-08-15 23:19:42 +02:00
Hinterwaeldlers 705e5e3468 Fix for http://trac.cppcheck.net/ticket/8151 (#942)
* Taking care of incorrect template syntax (missing close)

Forward the incorrectness via throw, as there is no direct access to the
syntaxError method, without converting the function to a member function
2017-08-15 22:40:55 +02:00
Ayaz Salikhov b8cd7dbb5c Use nullptr instead of 0 or NULL (#936) 2017-08-09 20:00:26 +02:00
Daniel Marjamäki 29265cdd49 Refactoring, use continue 2017-07-30 12:46:04 +02:00
Daniel Marjamäki f76ff9e7bf Tokenizer: Put struct in anonymous namespace 2017-07-29 19:46:18 +02:00
Daniel Marjamäki a78fd23732 Refactoring, skipEnumBody 2017-07-29 12:13:32 +02:00
Simon Martin aa35462add Ticket #8091: Don't replace std types within enum definitions. (#922) 2017-07-29 11:56:09 +02:00
orbitcowboy 0e575ce12c Modernize: make use of 'nullptr' and added a rule-file for finding non-nullptr (zero) initializations. 2017-07-28 15:20:43 +02:00
Daniel Marjamäki f85e43d21f Fixed #8059 (Tokenizer::simplifyWhile0: for loop that modifies local variable) 2017-07-09 22:44:10 +02:00
Daniel Marjamäki dff9d13758 Fixed #8115 (Tokenizer: links not properly set in r-value template 'Foo<int> && foo') 2017-07-09 13:26:59 +02:00
Daniel Marjamäki 6417be4a71 Fixed #8054 (Tokenizer::simplifyKnownVariables(): Wrong simplification for global variables) 2017-07-08 22:12:01 +02:00
Daniel Marjamäki 6c2002a150 minor constness fix 2017-07-08 21:41:57 +02:00
Alexander Mai ce13b75967 Add missing types to Platform::platformString(). Add another pattern to Tokenizer::findGarbageCode() to avoid potential crash in Valueflow 2017-06-06 22:15:11 +02:00
Daniel Marjamäki 26bd863d0a Fixed #7724 (hang: long expression => wrong AST) 2017-06-04 12:16:49 +02:00
Daniel Marjamäki bbde3cc23a Merge pull request #910 from mathbunnyru/asalikhov/improve_readability
improve readability
2017-06-03 14:33:21 +02:00
uburuntu f4ce49d883 ENH: perfomance: using clear() and empty() more faster for stl containers 2017-06-02 22:38:00 +04:00
Daniel Marjamäki b68c8d91ab Fixed #8039 (Tokenizer: wrong simplification of string) 2017-06-01 22:21:02 +02:00
Ayaz Salikhov 3cd2f2d092 Don't cast bool to bool 2017-06-01 01:49:40 +03:00
Frank Zingsheim aa937e426d Fixed #7849 (Tokenizer: Wrong simplification of floating point equality comparison) 2017-05-28 10:53:50 +02:00
Ayaz Salikhov 28aa939d69 iwyu - include what you use 2017-05-27 04:33:47 +02:00
Daniel Marjamäki 93e0516291 Fixed #8009 (Tokenizer: fix handling of template rvalue references) 2017-05-23 18:55:17 +02:00
Daniel Marjamäki 040d2f0012 Use simplecpp lexer in test cases 2017-05-18 21:52:31 +02:00
Daniel Marjamäki 7bd0bc7534 Tokenizer: Simplify '->' to '.' 2017-05-17 22:50:54 +02:00
Daniel Marjamäki 59335f80d2 Try to fix windows build. Reduce header dependencies 2017-05-17 15:38:31 +02:00
Daniel Marjamäki 6230919976 Skip 'Stringification => Tokenize' step 2017-05-17 14:57:54 +02:00
Daniel Marjamäki a8a54bbfa8 Fixed #6028 (Improvement: False positive caused by C keywords in assembly comments) 2017-05-05 08:57:24 +02:00
Alexander Mai f54a6f085b #7883 hang: CheckOther::checkFuncArgNamesDifferent() template code in .h. Activate language check for header files + Small refactoring 2017-05-03 20:36:26 +02:00
Daniel Marjamäki 1ec9b8c5b4 Fixed #8047 (false positive uninitialized variable - sizeof **A) 2017-05-03 19:27:55 +02:00
Alexander Mai e88b4dcf06 Add another check to Tokenizer::validateC(): C++ casts 2017-05-03 16:57:42 +02:00
Alexander Mai 1bc7a89b3c Improve search patterns within Tokenizer::validateC() 2017-05-02 17:57:06 +02:00
Matthias Krüger cee0f724ff Fixed #8018: Tokenize::findGarbageCode: detect heads of for-loops with 1 or more than 2 semicolons as garbage code. 2017-05-01 18:28:26 +02:00
Daniel Marjamäki 8a08cc0796 Fixed #8029 (Tokenizer::simplifyCAlternativeTokens: dont simplify 'eb.and + 1') 2017-04-30 14:40:41 +02:00
Simon Martin 28960a8bba Remove bailout and fix varid for template class member initialized in out-of-line constructor (#8031) 2017-04-30 08:59:47 +02:00
Daniel Marjamäki bdf16b1157 Tokenizer::simplifyComma: dont simplify comma in '=(struct s){...}' 2017-04-26 20:48:08 +02:00
Daniel Marjamäki 1a95dc9bd6 Fixed #7979 (Tokenizer: Detect and reject c++ code in .c file) 2017-04-17 22:15:29 +02:00
Daniel Marjamäki 1045ece946 dump: refactor valueType dump 2017-04-16 09:11:20 +02:00
Daniel Marjamäki f90d8c9987 dump: fix xml format 2017-04-15 14:03:49 +02:00
Daniel Marjamäki e71b428740 dump: Add platform info and valueType info 2017-04-15 12:25:44 +02:00
PKEuS b1f4bd7504 Refactorization: Reimplemented Settings::_enabled as a bitfeld instead of std::set (#7995) 2017-04-11 11:49:26 +02:00
Daniel Marjamäki 8ffed6862d Tokenizer: Add --check-config warning for macro with semicolon in argument 2017-04-07 19:19:10 +02:00
Daniel Marjamäki 50da7d4919 Tokenizer: Write syntax error if there is C++ code in C file. 2017-04-06 08:50:35 +02:00
Daniel Marjamäki 9c5a136f04 Fixed #7975 (crash: Tokenizer::createLinks2 problem with enable_if<x&&y,C*>) 2017-04-03 21:48:22 +02:00
Daniel Marjamäki 1faca91c1d Added 'endsWith' utility function. This will make compiling the democlient easier. 2017-04-01 18:14:18 +02:00
PKEuS 3c8f5b85ae Refactorization: Allocate Token::_values (ValueFlow information) dynamically, reducing size of each token by around 10% 2017-03-27 18:48:34 +02:00
Robert Reif f099c6a110 Refactor symbol database value type support by making setValueTypeInTokenList and setValueType member functions of SymbolDatabase. Class variables are no longer passed around as parameters but accessed directly which simplifies the code. There should be no functional change. 2017-03-21 21:55:22 -04:00
Daniel Marjamäki 8c707876ed Tokenizer: Don't simplify '({..})' wrongly 2017-03-08 11:41:18 +01:00
Daniel Marjamäki 2f2ac46243 Replaced hardcoding for char16_t and char32_t with configuration 2017-03-04 16:30:42 +01:00
Daniel Marjamäki ecc59859e1 Don't simplify _Bool in TokenList 2017-03-04 11:13:28 +01:00
Matthias Krüger 35e7697474 switch some functions from const to static, as cppcheck suggests. 2017-02-27 13:51:33 +01:00
Daniel Marjamäki 2e91858640 Fixed #7877 (Tokenizer: Does not clear ValueFlow after first pass) 2017-02-25 17:57:39 +01:00
Simon Martin 487f76cdd1 Ticket #7916: Don't incorrectly simplify return statements involving template instantiations. 2017-02-18 21:14:50 +01:00
Matthias Krüger 6f1e7e897d simplify if(tok && Token::{simple,}Match) to if(Token::{simple,}Match). 2017-02-06 15:37:12 +01:00
Simon Martin 5262ed018e Ticket #7440: Function calls should not abort pointer alias analysis for local variables. 2017-01-27 22:56:28 +01:00
Daniel Marjamäki b7321e8dde Tokenizer: Rename struct 2017-01-09 22:40:30 +01:00
Robert Reif 4c25e798b1 Fixed #7865 (Tokenizer::createLinks2(): does does set links for <> in struct template) 2016-12-31 22:05:29 +01:00
Daniel Marjamäki 1b21767954 Fixed #5666 (False positive when modifiying std::string by pointer) 2016-12-26 17:13:35 +01:00
Daniel Marjamäki 2ce4811998 astyle formatting
[ci skip]
2016-12-22 09:40:39 +01:00
Daniel Marjamäki 426d1b4196 Merge pull request #846 from simartin/ticket_7805
Ticket #7805: Ignore enumerators when simplifying known variables.
2016-12-21 17:58:48 +01:00
Daniel Marjamäki 4558701c08 varid: don't generate varid and symboldatabase variable for function call parameter 2016-12-18 20:16:38 +01:00
Simon Martin 5119ae84b8 Ticket #7805: Ignore enumerators when simplifying known variables. 2016-12-17 14:05:26 +01:00
Daniel Marjamäki d4f2512421 Tokenizer::simplifyKnownVariables: Added bailout when pointer alias is simplified and loop is encountered 2016-12-11 19:12:23 +01:00
Daniel Marjamäki 2ca85a1c40 dump: add isUnsigned/isSigned 2016-12-09 22:31:47 +01:00
PKEuS cfac3b457d Several small refactorizations 2016-12-06 22:12:02 +01:00
PKEuS 2f6350a0d0 Refactorized Library 2016-12-06 14:09:28 +01:00
amai2012 f66e7fb379 #7833 UB: member call on null pointer when --dumping configuration with unknown value 2016-11-28 18:19:19 +01:00
Stefan Weil 57b57428c2 Fix some typos in comments (found by codespell)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-27 11:40:42 +01:00
Daniel Marjamäki 21364b4401 Refactoring fix for #7816 2016-11-21 13:54:59 +01:00
amai2012 933815ee54 #7816 Segmentation fault at Tokenizer::simplifyAttribute() for stand-alone void. Throw syntax error on incomplete code 2016-11-21 12:19:47 +01:00
Daniel Marjamäki 74fa69fe5e Fixed #7821 (syntax error, first token is &) 2016-11-20 17:59:50 +01:00
Daniel Marjamäki 5b377ea2e4 Fixed #7821 (segmentation fault, invalid last token) 2016-11-20 14:15:51 +01:00
Daniel Marjamäki 483fd8682a cleanup redundant info in comment. ticket numbers can be looked up with git blame. if the code says there is a syntax error then a comment that says 'invalid code' isn't much clarification. 2016-11-06 16:49:25 +01:00
orbitcowboy 2f8a24764f tokenize: Improved const correctness. There are no functional changes. 2016-10-31 17:18:27 +01:00
orbitcowboy b3c60bf6b2 tokenize: Improved const correctness. There are no functional changes. 2016-10-31 16:11:11 +01:00
Daniel Marjamäki e76710c906 Revert "Revert "Fix potential uninitialized variable in Tokenizer::simplifyTypedef""
It does not _fix_ any potential uninitialized variable. So I reverted this. However I think that as a refactoring it was ok.

This reverts commit 5b2e4891c4.
2016-10-29 19:04:10 +02:00
Daniel Marjamäki 5b2e4891c4 Revert "Fix potential uninitialized variable in Tokenizer::simplifyTypedef"
This reverts commit bed2f66302.
2016-10-29 18:29:05 +02:00
Frank Zingsheim bed2f66302 Fix potential uninitialized variable in Tokenizer::simplifyTypedef 2016-10-29 17:05:51 +02:00
Daniel Marjamäki efa3aba32a Remove Tokenizer::simplifyNull() 2016-10-18 21:44:02 +02:00
Daniel Marjamäki 9cea2d6dfa Tokenizer: Removed simplifications of standard functions that should be handled through configuration. 2016-10-18 19:25:58 +02:00
Daniel Marjamäki d09a8dde57 Improved char literal handling. In the 'normal' tokenlist these should not be simplified to integer literals. 2016-10-12 10:20:24 +02:00
Harald Scheidl 58eb644003 Improved Check: Warn about number and char literals in boolean expressions (#7750) 2016-10-09 13:21:00 +02:00
Daniel Marjamäki bcbc8ef017 Fixed #7747 (Syntax error when setting the bitcount of an enum defined inside a struct) 2016-10-04 15:57:43 +02:00
Daniel Marjamäki 02402eeea4 Make simplifyBitfields() a bit more strict 2016-10-04 15:33:50 +02:00
Harald Scheidl ba6cda9c86 Fixed #7740 (Tokenizer::setVarId: Function declaration does not start with 'return') 2016-10-03 10:02:18 +02:00
Simon Martin 3f415673e4 Ticket #7541: Properly keep track of namespace definition end markers when there are multiple of them. 2016-10-01 20:46:33 +02:00
Daniel Marjamäki ac1a869d60 unused struct members: don't warn about packed structs (#3088) 2016-09-05 17:27:12 +02:00
Daniel Marjamäki 18cab009c1 Fix Token::Match pattern 2016-08-28 19:25:57 +02:00
Daniel Marjamäki 254e5675ff Fixed #7573 (Tokenizer: FP caused by constant folding) 2016-08-28 19:11:05 +02:00
Frank Zingsheim 7c9a69357e Fixed #7696 (cppcheck 1.75 runs very slowly with style and/or performance checks) 2016-08-21 16:07:05 +02:00
Robert Reif 62ac40fc5e Fixed #7706 ((debug) Executable scope 'foo' with unknown function.) 2016-08-20 22:43:27 +02:00
Robert Reif f1b5ac30a7 Fixed 7698 (FP syntaxError with enum (1.75 regression)) 2016-08-19 19:09:52 +02:00
Daniel Marjamäki 7d6c587580 Fixed #6113 (Tokenizer::simplifyFunctionPointer: wrong simplification of usage 'return (*f)();') 2016-08-04 19:10:08 +02:00
PKEuS 084fcc936c Rephrased syntaxError message for empty configurations to improve readability:
Old: Invalid number of character 'c' when these macros are defined: ''.
New: Invalid number of character 'c' when no macros are defined.
2016-08-04 16:28:11 +02:00
Daniel Marjamäki 908e1b991e Tokenizer: Refactoring simplifyPlatformTypes() 2016-08-02 19:44:18 +02:00
Daniel Marjamäki cc62259103 Tokenizer: don't set varid on c++11 'template using' type. 2016-08-02 15:04:07 +02:00
Daniel Marjamäki 99b23012aa Refactoring, use Settings::platformString() 2016-08-02 10:53:51 +02:00
Daniel Marjamäki 31484133c0 Fixed #7158 (Tokenizer::createLinks2(): does not set links for < > in 'enum { value = boost::mpl::at_c<B,C> };') 2016-08-01 22:26:11 +02:00
Daniel Marjamäki 09b6568ea2 Fixed #7646 (podtypes do not get proper valuetype) 2016-07-31 19:47:34 +02:00
Daniel Marjamäki 71f62950ed Tokenizer::findGarbageCode: Make it less picky about 'UNKNOWN_MACRO if ..' 2016-07-26 14:35:11 +02:00
Daniel Marjamäki 7ff9545b10 Fixed #7637 (FP syntax error assignment in switch) 2016-07-26 12:15:55 +02:00
Daniel Marjamäki fd19ab4ed1 fix garbage code handling 2016-07-26 08:50:00 +02:00
Daniel Marjamäki 383b815cca Tokenizer: refactoring garbage code handling 2016-07-26 08:16:10 +02:00
Daniel Marjamäki 7ef02a7469 Cleanup Tokenizer 2016-07-25 12:12:11 +02:00
Daniel Marjamäki adf16fae8b Remove handling of ##, __FILE__, __LINE__ from tokenizer 2016-07-25 07:58:03 +02:00
Daniel Marjamäki cd3818088f Remove unused function Tokenizer::tokenizeCondition 2016-07-24 14:37:43 +02:00
Daniel Marjamäki ed4a47de45 Tokenizer: Improve syntax checking of switch,if,while 2016-07-22 16:54:24 +02:00
Daniel Marjamäki 83b982064d Fixed #7579 (varid not set properly in 'int b[] = { m * a[0] };') 2016-07-18 15:27:08 +02:00
PKEuS 801fd8f96a Support trailing return types (C++11) 2016-07-17 15:47:50 +02:00
Daniel Marjamäki b8ca9fc844 Tokenizer: alternative tokens for and,or,etc. context sensitive for both c and c++. 2016-07-16 21:29:56 +02:00
Daniel Marjamäki 6e3d5dc0d1 Fixed #7580 (False positive when using logical operator keywords 'and', 'or') 2016-07-16 20:21:31 +02:00
PKEuS 0afecd8fee Do not simplify name "CALLBACK" away on non-windows platforms (#7554) 2016-07-16 10:43:28 +02:00
PKEuS a808549af0 Support lambdas in simplifyCompoundAssignment (#7571) 2016-07-08 20:10:33 +02:00