Commit Graph

2257 Commits

Author SHA1 Message Date
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