Commit Graph

2329 Commits

Author SHA1 Message Date
Daniel Marjamäki 6d86ad78ba Refactoring, use early continue 2018-04-23 16:23:22 +02:00
rikardfalkeborn 57019c0128 Fix comment in Tokenizer::simplifyMathFunctions (#1179)
In 9cea2d6df, simplifications were removed for a number of functions
which should instead be handled with configurations. The commit did
however not update the description of the function, do this now.

Also sin() and sinh() and their float and long double versions were
missing from the comment so add these as well.
2018-04-19 06:14:16 +02:00
Daniel Marjamäki e95ff8c7b6 Avoiding emplace 2018-04-14 19:24:35 +02:00
Sebastian c39a3e3f1c
windows string macros: Handle _T, _TEXT and TEXT internally, add tests (#1163)
Remove TEXT() macro from windows.cfg and handle it internally where it
can be correctly simplified (Ansi vs. Unicode).
Also add handling of _TEXT() macro which is just a synonym for _T().
Add tests to verify correct function and macro simplification.
2018-04-12 08:52:31 +02:00
PKEuS d2146844dd Refactorizations:
- Replace several push_back-calls by emplace_back
- Replace some x = x.substr(0, y) calls by x.erase(y)
2018-04-11 09:44:35 +02:00
PKEuS 17b4721bd2 C++17: Support "if constexpr" (by simplifying it to plain if() statement)
This might lead to complaints about constant expressions as if() statement, but should fix syntax errors.
2018-04-09 11:42:59 +02:00
PKEuS e2002db78d Replaced make_container by C++11 initializer lists 2018-04-08 23:03:44 +02:00
IOBYTE 90983303f0 Fix #8477 (False positive caused by anonymous enum in method body) (#1154) 2018-04-08 08:00:12 +02:00
jrp2014 214322d501 Refactor lib/tokenize 2018-04-05 08:02:59 +02:00
jrp2014 b6504c70ca Improve constness 2018-04-04 21:51:31 +02:00
Daniel Marjamäki c0272fc2ef Fixed #8259 (Don't combine &= for anonymous reference parameters) 2018-04-01 10:27:16 +02:00
Daniel Marjamäki 5a444f764b Fixed one more syntax error FP related to #8390 2018-03-22 15:20:37 +01:00
Daniel Marjamäki 3d4b773fd1 Fixed #8390 (Syntax error from an MSVC internal header) 2018-03-22 09:07:58 +01:00
Daniel Marjamäki 2c3cd402ba Thread safety: changed local static variable 'count' to member variable 2018-03-14 09:41:27 +01:00
Daniel Marjamäki 5c44580528 Refactoring, use early continue and make code a bit more specific. 2018-02-16 22:59:38 +01:00
IOBYTE fcde1d80e9 Fix #8382 (Syntax error when scanning code with template and attribute) (#1089)
* Fix #8382 (Syntax error when scanning code with template and attribute)

This commit only addresses #8382. There are issues concerning which
versions of C++ should be supported and also generic C++ 14 attribute
support which can be revisited later.

* Remove all C++ style attributes.

Remove all C++ style attributes when C++ version is 11 or greater.
Rename simplify function to simplifyCPPAttributes.
Handle more cases of roreturn function attribute.
2018-02-16 22:25:51 +01:00
Lauri Nurmi e0e664f996 Fix permissions of certain non-executable files (#1083)
mode 0755 => 0644
2018-02-09 19:46:38 +01:00
Daniel Marjamäki 13daaac264 astyle formatting
[ci skip]
2018-02-06 08:10:28 +01:00
Alexander Mai 68eb6c4e6f Refactoring: Add Tokenizer::findGarbageCode to time report. The method now calls syntaxError instead of returning an invalid token 2018-02-05 21:47:33 +01:00
Matthias Krüger f009cfc845 fix some typos found by codespell. 2018-02-04 20:53:43 +01:00
Jørgen Kvalsvik a61f21d1b6 Accept nested templates in tokenizer-simplify (#1070)
The following snippet triggerd the error:

template<typename DerivedT>
template<typename T>
auto ComposableParserImpl<DerivedT>::operator|( T const &other ) const -> Parser {
    return Parser() | static_cast<DerivedT const &>( *this ) | other;
}

Whenever simplifyFunctionParameters was called on a templated class'
templated member function (and probably any nested template), the
tokenizer would recognise it as a syntax error, assuming that return
type *must* come after a template<> token.
2018-02-04 09:48:37 +01:00
IOBYTE d721c6aca5 Fixed #8386 (syntax error not found (segmentation fault)) (#1081) 2018-02-03 15:50:05 +01:00
Daniel Marjamäki 21a35de0d2 Tokenizer: Refactoring garbage check 2018-01-27 22:26:43 +01:00
David Hallas 4d18d3948f Fixes issue with case inside switch that is not a compound statement (#1031)
* Fixes issue with case inside switch that is not a compound statement was treated as garbage

This fixes an issue with the check for case keywords outside of switch
detection that would treat a case statement inside a switch that is not
a compound statement as garbage, but this is perfectly valid C++. This
construct is used in several libraries, i.e. Google Test.

* Tweak check and handle missing semicolon

Tweaks the check with feedback from danmar.
Handle the case where there is no semicolon and document it with a unit
test.
2018-01-27 22:21:26 +01:00
Daniel Marjamäki c110770481 Fixed #8325 (False negative: address of auto variable being returned when assigned to another variable first) 2018-01-27 14:48:45 +01:00
Simon Martin 71ba513bdb Ticket #8361: Fix false positive in Tokenizer::findGarbageCode. (#1061) 2018-01-26 22:06:07 +01:00
Daniel Marjamäki 3ebedcd7f5 Fixed VS crash for torture test 2018-01-26 16:05:43 +01:00
Daniel Marjamäki a5f202360a Fixed crash for garbage code, found by fuzzing 2018-01-26 09:34:27 +01:00
Daniel Marjamäki 1b3248b0fc Dont write syntax error for lambda functions 2018-01-25 17:47:27 +01:00
Daniel Marjamäki c04557eb73 Fix crashes detected with fuzzing 2018-01-25 15:53:58 +01:00
IOBYTE 8ce496a127 Fix possible null pointer dereference cppcheck warning. (#1056) 2018-01-24 21:19:52 +01:00
Daniel Marjamäki 96e387a486 Fixed #8351 (segmentation fault on objective C code) 2018-01-24 18:06:11 +01:00
IOBYTE 558e0757c2 Fix simplifyTypedef crash on lambda. (#1054) 2018-01-24 15:04:33 +01:00
Daniel Marjamäki 0f561d0ed6 Fix crashes for garbage code, found by fuzzing 2018-01-24 13:53:03 +01:00
IOBYTE 4710d80a40 Fix #5766 (FP: typedef array throws off parser) (#1052)
* Fix #5766 (FP: typedef array throws off parser)

* Fix travis build.
2018-01-24 09:51:22 +01:00
IOBYTE e6d285d3ca Fixed #8357 (crash: cmake Tests/CMakeLib/testUTF8.cxx --debug --verbose) (#1046) 2018-01-22 08:06:56 +01:00
Martin Ettl 17a54681b8 tokenize: simplify empty string creation string("")->string(). 2018-01-21 16:36:57 +01:00
Alexey Eryomenko 913fdf44b6 member access operators are allowed inside the embedded SQL block when (#1043)
passing arguments for a query
2018-01-21 15:58:12 +01:00
Daniel Marjamäki af26f00e04 gui: update copyright message in about dialog 2018-01-14 15:46:20 +01:00
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +01:00
IOBYTE cefb2131c7 Add support for simple c++ 11 type ailases like: using INT = int; (#1024)
* Add support for simple c++ 11 type ailases like: using INT = int;

Only types supported by ValueType are supported. Complex types like
function pointers are not supported. Template type aliases are not
supported.

* Fix crash when type in using type alias is simplified away.

This fixes a crash when size_t is replaced with unsigned long in: using
size_t = unsigned long; by the tokenizer.

This does not fix the problem where Tokenizer::simplifyPlatformTypes()
simplifies away size_t in other cases.  This is only a problem when the
new type is different from the platform type.
2018-01-10 22:16:18 +01:00
Daniel Marjamäki 8c33a95b49 Refactoring: moved method from Tokenizer to TokenList 2018-01-07 14:07:34 +01:00
Daniel Marjamäki 1af69bd0d4 Tokenizer::createLinks2: fix link for >> 2018-01-01 15:20:21 +01:00
Daniel Marjamäki fa42a08a71 Make code less strict that looks for garbage template code. Before a template there might be unknown macros. 2017-12-31 16:25:41 +01:00
Daniel Marjamäki 005bb7c747 Replace Token::Match with Token::simpleMatch 2017-12-29 23:05:54 +01:00
Daniel Marjamäki fc1ac180e6 Fixed #6218 (Template type aliasing misdetection) 2017-12-29 22:47:07 +01:00
Dmitry-Me 6ae32ed98c Unify check with surrounding code 2017-12-20 01:37:19 +03:00
Daniel Marjamäki 9c17bddbd4 Tweak fix for ticket #8297 2017-12-17 22:27:05 +01:00
Daniel Marjamäki 1428759479 Fixed #8297 (Tokenizer:createLinks: 'X<sizeof(int)==1 || sizeof(int)==4>()') 2017-12-17 15:53:05 +01:00
IOBYTE 026d8f6859 fix #8284: False positive: "Label 'class' is not used." for anonymous… (#1011)
* fix #8284: False positive: "Label 'class' is not used." for anonymous C++ class

Add support for annonymous derived structures and classes.

* Fix travis build (use findsimplematch).

* Fix bug in simplifyLabelsCaseDefault which was inserting ; in wrong place.
2017-12-05 16:50:04 +01:00
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