Commit Graph

2862 Commits

Author SHA1 Message Date
Paul Fultz II 92eb59981d
Fix 10435: False positive: containerOutOfBounds (#3426) 2021-08-29 15:40:10 +02:00
Paul Fultz II c0765c451d
Fix 10139: AST broken; std::enable_if_t<> (#3424) 2021-08-28 09:28:56 +02:00
chrchr-github d9b6940070
Cleanup: unnecessary includes, fix include order, fix unreferenced va… (#3418) 2021-08-26 19:36:31 +02:00
Daniel Marjamäki ca50dea97d Fix in Tokenizer::simplifyUsing for non-scopes 2021-08-21 10:10:40 +02:00
Daniel Marjamäki d73ab0ad96 Tokenizer::simplifyUsing; Fixed bug when enum class is used 2021-08-20 16:08:01 +02:00
Paul Fultz II 422e411b6c
Fix 9444: Syntax error on valid C++14 code (#3403) 2021-08-15 07:43:02 +02:00
Paul Fultz II 6d65f86871
Fix 9245: Synax error on valid C++14 code: AST broken, binary operator '=' doesn't have two operands. (#3400) 2021-08-14 22:50:58 +02:00
Paul Fultz II 818fd248e1
Simplify template keyword bracket (#3399) 2021-08-14 21:16:27 +02:00
Paul Fultz II 7f358b2bed
Format with uncrustify (#3388) 2021-08-07 20:51:18 +02:00
Paul Fultz II 00eb71fd49
Remove constexpr -> const simplification (#3346) 2021-07-22 07:22:26 +02:00
Daniel Marjamäki d1fe34e167 misra; implement rule 8.10 2021-07-18 21:18:07 +02:00
Daniel Marjamäki 13d55c7060 misra; implement rule 2.3 2021-07-07 15:16:53 +02:00
Daniel Marjamäki 00a9671f46 misra: implement 8.1 2021-07-07 13:34:55 +02:00
Daniel Marjamäki 9172f2ab3b addons; add CTU infrastructure 2021-07-07 10:58:13 +02:00
Robert Reif 68898e2be0
fix #10335 (Type alias remains unknown with using) (#3323)
Co-authored-by: Robert Reif <reif@FX6840>
2021-07-02 06:19:26 +02:00
Daniel Marjamäki 2a2e071a85 Tokenizer::simplifyAttribute; Set function attribute for function pointer 2021-06-26 14:23:39 +02:00
Daniel Marjamäki 3c3435dd10 Fix bug in Tokenizer::simplifyVarDecl 2021-06-06 08:13:40 +02:00
dummyunit 9652ca39a3
Improve support for labels in simplifyAddBraces step (#3278)
Previously only a single regular label before a compound statement was
allowed in simplifyAddBracesPair() after if/switch/do/while/for.
This patch adds support for:
* case-labels;
* labels before a single statement;
* labels before try/catch blocks;
* multiple consecutive labels.

Additionally the code for skipping a case label was extracted into a
separate function from simplifyLabelsCaseDefault() and reused in
simplifyAddBracesPair().
2021-06-02 07:00:37 +02:00
Robert Reif 3af3d7fc06
fix #10281 (Tokenizer; Wrong simplification for 'namespace ef = :🅰️🅱️:c::d::ef') (#3263) 2021-05-20 08:27:07 +02:00
Daniel Marjamäki 7ba9e37296 unhandled char literal; changed severity to 'portability'. hopefully there will not be warnings for standard character literals. 2021-05-13 13:51:53 +02:00
Daniel Marjamäki fca7a270bf daca@home; show unhandled chars diagnostics 2021-05-13 13:44:32 +02:00
Daniel Marjamäki 895a96f9dd Tokenizer::findGarbageCode: detect wrong struct declaration 2021-05-08 15:28:21 +02:00
Daniel Marjamäki abb4200316 Fixed #10196 ("Unhandled char constant 'x'" with non-standard escape character) 2021-05-08 12:54:18 +02:00
keinflue 0a84ad874c
Fix case ranges with single quotes and escape sequences (#3248) 2021-05-08 11:24:07 +02:00
dummyunit da27159d7c
Fixed #9728 (Support function level try blocks) 2021-05-02 09:05:12 +02:00
Daniel Marjamäki a32d6257d5 Fix Cppcheck self-check, extra whitespace in match patterns 2021-05-01 12:15:54 +02:00
Daniel Marjamäki 9b717b8835 Refactoring __attribute__ simplification 2021-05-01 11:39:26 +02:00
Daniel Marjamäki 07c1f28035 astyle formatting 2021-05-01 07:35:03 +02:00
DGarry82 d3035c246f
Attribute lists support (#3239) 2021-05-01 07:33:55 +02:00
Robert Reif e1e822275d
fix daca2 paraview crash from uninstantiated recursive template (#3237) 2021-04-29 11:09:51 +02:00
Daniel Marjamäki 8aa9e448f5 Parser; Set varid for structured binding variables 2021-04-26 18:04:27 +02:00
Daniel Marjamäki b798b99777 Parser; do not remove alignof and alignas in the same way 2021-04-26 11:44:08 +02:00
dummyunit b18e6f1e10
Fix varId assignment for uses of variables declared in the if condition (#3231)
Variables declared in the if condition (or in C++17 init-statement) are
visible not only in the if body but also in the else body. But logic in
Tokenizer::setVarIdPass1() handled such variables as if they were
declared in the if body.

As the result they were removed from variablesMap by the time the else
block was parsed and their uses in the else block were either given an
incorrect varId from variables in some outer scope or not given a varId
at all.

This then resulted in false positive unreadVariable errors for variables
declared in the if condition (or init-statement) and used only in the
else block.

Simplification from "else if ..." to "else { if ... }" was moved before
setVarId() to simplify detection for ends of blocks in if-else chains.
2021-04-26 07:38:03 +02:00
Daniel Marjamäki 28a7bb63ec Parser; simplify (break out) init expression from if/switch/range-for 2021-04-25 14:37:27 +02:00
Daniel Marjamäki c9dc92c266 Parser; C++20 for loop with initialization expression 2021-04-24 11:47:51 +02:00
Daniel Marjamäki 26c0945309 Handle c++20 spaceship operator 2021-04-22 19:15:22 +02:00
Oliver Stöneberg 5de58c4ddd
added clang-tidy to CI (#3218) 2021-04-18 21:51:47 +02:00
Daniel Marjamäki 56773b82c4 Simple handling of coroutines 2021-04-18 19:42:22 +02:00
Oliver Stöneberg 3bc71f982a
enabled "debug" findings in self-check / split "simplifyUsing" and "simplyTypedef" from more generic "debug" (#3210) 2021-04-17 18:07:47 +02:00
IOBYTE 5568ac95e7
fix simplifyUsing debug warning for: using value_type = const ValueFlow::Value; (#3211) 2021-04-17 14:20:16 +02:00
Daniel Marjamäki 11f828a669 Fixed #9415 (C++11: `alignas` not handled -> wrong code -> false negatives) 2021-04-15 20:26:53 +02:00
Oliver Stöneberg 6397e29f84
cleaned up includes based on include-what-you-use (#3141) 2021-04-03 21:30:50 +02:00
Ken-Patrick Lehrmann cddaa6d671
10221: Fix setVarId in template code (#3187)
The computation of the classname was not expecting templates. Simply
skipping the template part seems to fix the issue.
2021-03-29 12:16:02 +02:00
Lars Even Almaas 9786f1c34b
Suggested implementation for rule 8.2 (#3169) 2021-03-25 08:25:43 +01:00
Daniel Marjamäki 42437277dc Update Copyright year 2021-03-21 20:58:32 +01:00
Daniel Marjamäki 51564504a8 astyle formatting 2021-03-20 18:54:46 +01:00
Paul Fultz II b0ac92ce8f
Report an error if analysis becomes cyclic (#3173) 2021-03-20 14:02:07 +01:00
Tetrix 9b7f1f6280
simplifyCPPAttribute tokenizer strips alignas (#3171) 2021-03-20 10:38:47 +01:00
Rikard Falkeborn 103e52f394
Fix tokenizing of x[i](0) (Fixes #8875) (#3167)
Fix faulty removal of parenthesis when "]" is followed by parenthesis
with a number inside, for example when calling a function pointer in
an array or (perhaps more common) in c++, calling operator ( on an
element in an array.

Fixes #8875 where such wrong simplification lead to a FP with too many
bits shifted due to "<<" was interpreted like a shift operator rather
than a stream output.
2021-03-11 08:16:25 +01:00
IOBYTE bc8eb164a3
fix more daca simplifyUsing hangs (#3152) 2021-02-26 18:30:17 +01:00
PKEuS 141d2ac215 Refactorization: Improved internal implementation of severity and certainty levels
Backported from LCppC.
2021-02-24 22:00:06 +01:00
IOBYTE 9bb57a7b6f
fix #10183 (performance regression (hang) - ScopeInfo3::findInChildren()) (#3147) 2021-02-24 06:36:53 +01:00
IOBYTE fc1cfba5e0
fix simplifyUsing hang parsing class initializer list using {} (#3146)
Co-authored-by: Robert Reif <reif@FX6840>
2021-02-23 20:35:20 +01:00
IOBYTE a07f93f819
fix simplifyUsing crash and hang (#3145) 2021-02-23 09:48:15 +01:00
Robert Reif 3c6fae37e4 minor simplifyUsing optimizations
The using type aliases are a C++ 11 feature so only check for them in C++ 11 or later.

Don't try to simplify a type alias when it can't be parsed.
2021-02-19 22:48:31 +01:00
IOBYTE 8547ff8cc2
fix some hangs in daca from uninstantiated template classes derived f… (#3133)
* fix some hangs in daca from uninstantiated template classes derived from itself

* remove assertions

* fix another simplifyUsing hang

Co-authored-by: Robert Reif <reif@FX6840>
2021-02-17 18:12:49 +01:00
IOBYTE 7ab84bef0c
fix daca crash in intel-compute-runtime (#3132) 2021-02-15 08:12:29 +01:00
Daniel Marjamäki 70511464f5 Fixed Cppcheck self-check 2021-02-14 15:53:46 +01:00
Daniel Marjamäki f08dde1140 Fixed #10013 (Tokenizer: Code with 'not' is not handled) 2021-02-13 20:32:49 +01:00
IOBYTE 1eafed9e75
fix hang in simplifyUsing (#3128)
Co-authored-by: Robert Reif <reif@FX6840>
2021-02-12 16:21:51 +01:00
IOBYTE e57a674458
fix #10173 (syntax error from wrong simplifications for using type al… (#3126) 2021-02-12 09:47:16 +01:00
IOBYTE b6e93bb575
fix #10172 (debug: Executable scope 'x' with unknown function.) (#3121) 2021-02-11 08:08:45 +01:00
IOBYTE d3d2e16137
fix hang from f48e195c31 (fix #10136 TODO test (#3117)) (#3120)
Co-authored-by: Robert Reif <reif@FX6840>
2021-02-09 14:19:01 +01:00
IOBYTE f48e195c31
fix #10136 TODO test (#3117) 2021-02-07 21:46:35 +01:00
IOBYTE 1872725ca2
fix #10171 (debug: Executable scope 'x' with unknown function.) (#3116) 2021-02-07 09:04:57 +01:00
Daniel Marjamäki b7c4aeca16 astyle formatting 2021-02-06 12:27:51 +01:00
IOBYTE c70fcf8e2b
fix #10136 (debug: Executable scope 'x' with unknown function.) (#3113) 2021-02-05 15:50:32 +01:00
Oliver Stöneberg e8b8cfec78
some minor optimizations (#3057) 2021-01-28 22:18:17 +01:00
Simon Martin 9d10f4f572
Ticket #10028: Properly simplify auto variables' initialization. (#3079) 2021-01-23 17:56:58 +01:00
IOBYTE a4953575f1
fix #10127 (debug: Executable scope 'x' with unknown function.) (#3077) 2021-01-23 17:55:25 +01:00
orbitcowboy bb451ca289 Running astlye [ci skip] 2021-01-22 21:47:24 +01:00
IOBYTE d39956414f
fix #10122, #10124 and #10125 (debug: Executable scope 'x' with unknown function.) (#3073) 2021-01-21 19:47:51 +01:00
IOBYTE 664289792c
fix simplifyTypedef removing needed type qualification (#3058) 2021-01-18 10:08:55 +01:00
IOBYTE dd866f2898
fix using type alias with derived class (#3050) 2021-01-17 16:10:53 +01:00
Oliver Stöneberg 7aa85aa408
Use std::unordered_* containers for faster lookups (#3052) 2021-01-16 13:52:09 +01:00
Daniel Marjamäki a5babf25a7 Fixed #10080 (syntax error: operator) 2021-01-14 20:56:11 +01:00
Daniel Marjamäki 5f21d9d97b Fixed #8975 (Syntax error for valid C code) 2021-01-12 21:28:07 +01:00
Oliver Stöneberg ac7647fcd8
some self-check suppression cleanups (#3032) 2021-01-09 20:32:38 +01:00
IOBYTE cb02628c7c
fix #10075 (namespace alias changes variable name) (#3020) 2021-01-06 17:30:11 +01:00
IOBYTE 8897ad3408
fix #10068 (typedef not replaced when namespace is involved) (#3009) 2021-01-05 16:53:56 +01:00
Oliver Stöneberg d59abfd977
fixed clang-tidy warnings (#3006)
* clang_tidy.cmake: added clang-tidy-11 to list of executables to look for

* .clang-tidy: disabled warnings we are (currently) not interested in

* fixed clang-tidy warnings
2021-01-02 23:10:27 +01:00
Oliver Stöneberg fbf5858f76
fixed and enabled several clang-tidy warnings (#2816) 2021-01-02 19:10:25 +01:00
IOBYTE e7bdf5f71c
remove cleanupAfterSimplify from the template simplifier (#2998)
The template simplifier works well enough now so cleanupAfterSimplify is
no longer necessary.  In fact cleanupAfterSimplify was introducing a bug
which improperly simplified C++ style casts.

Bugs should be exposed and fixed properly rather than just hiding them.

Co-authored-by: Robert Reif <reif@FX6840>
2020-12-31 09:33:23 +01:00
IOBYTE 277da763aa
fix #10054 (debug: Executable scope 'x' with unknown function.) (#2994) 2020-12-30 08:09:34 +01:00
IOBYTE 765c1ace87
fix #10008 (false negative: knownEmptyContainer with alias in namespace and "using namespace") (#2979) 2020-12-26 13:45:17 +01:00
Daniel Marjamäki 37a5ec8cd5 Summaries: Moved to its own files 2020-12-20 19:53:58 +01:00
Daniel Marjamäki 1bf6a2f62b Summaries: Enhanced merge of noreturn info 2020-12-20 14:49:43 +01:00
Daniel Marjamäki 96caaedbd5 Generate basic function summaries 2020-12-19 19:02:42 +01:00
Daniel Marjamäki d340e8770c Fixed Tokenizer::setVarId when removing last scope name 2020-12-08 17:39:04 +01:00
Daniel Marjamäki 245284acde Tokenizer; Fixed varid for base class member variable 2020-12-08 17:25:50 +01:00
Daniel Marjamäki 7a4462dac5 Tokenizer: Refactoring, use isFunctionHead in setVarId. It should be more reliable. 2020-12-08 16:53:55 +01:00
IOBYTE 8161baf1e9
fix template debug output line numbers (#2938) 2020-12-08 10:35:13 +01:00
IOBYTE ab16603666
fix #9685 (Handle 'extern "C++"') (#2933) 2020-12-05 09:26:11 +01:00
Daniel Marjamäki 62810af7f3 Tokenizer: Avoid null pointer dereference in garbage code 2020-12-02 23:06:11 +01:00
Daniel Marjamäki cbb388d458 Tokenizer: Avoid wrong simplification of template right angle bracket 2020-12-02 20:21:32 +01:00
Daniel Marjamäki f250e06df7 Improved daca check for wrong detection of template right angle brackets 2020-11-30 20:00:38 +01:00
Daniel Marjamäki 9aa69661b5 More robust Token::findClosingBracket 2020-11-30 19:26:28 +01:00
Daniel Marjamäki 8a1c16a560 Tokenizer: add daca debug messages when right angle brackets in templates are not handled well 2020-11-29 16:07:56 +01:00
Daniel Marjamäki e2debac882 Fix testcases 2020-11-29 08:46:42 +01:00
Daniel Marjamäki fd75837494 Tokenizer: Remove extra 'template' keywords 2020-11-28 21:57:06 +01:00
Daniel Marjamäki 5b89b179ec Detect syntax error when script is checked 2020-11-28 14:41:05 +01:00
Daniel Marjamäki 2cd8ea83a7 Fixed #9860 (unused template not removed properly by default) 2020-11-22 16:43:36 +01:00
Daniel Marjamäki 22d6160624 Improve handling of decltype 2020-11-16 20:11:26 +01:00
Daniel Marjamäki 8b0699cd6a Revert "improved decltype() handling"
This reverts commit 6e8f77c519.
2020-11-15 21:32:05 +01:00
Daniel Marjamäki 6e8f77c519 improved decltype() handling 2020-11-15 20:58:17 +01:00
Daniel Marjamäki 54a93c4374 Fixed #9452 (FP syntaxError - _Pragma before struct with two constructors) 2020-11-15 15:03:47 +01:00
Daniel Marjamäki c95b0d2a51 Fixed #9977 (Template simplifier does not simplify in header) 2020-11-11 09:50:51 +01:00
uhziel aad29ddb9a
fix an error in Tokenizer::simplifyTypedef() (#2880) 2020-11-04 13:32:31 +01:00
Daniel Marjamäki 7804b28e70 AST: Tweaked debug output 2020-10-31 18:57:48 +01:00
Daniel Marjamäki 4eb829933e Tokenizer: Fixed unwanted unknownMacro warning for decltype 2020-10-27 09:08:13 +01:00
Daniel Marjamäki eb2c0bb6ee Fix TestExprEngine 2020-10-24 22:53:15 +02:00
Daniel Marjamäki 3876b601d5 Fixed #9476 (Tokenizer: report unknown macro) 2020-10-24 22:12:10 +02:00
Rikard Falkeborn d7a8e25d92
Fix #9647: Set correct enum value (#2856)
* Tokenize: Set varId for variables in enum

Set varIds in enum values. It was previously disabled in 5119ae84b8
to avoid issues with enums named the same as global variables. Take care
to only set varids to variables used to set the value of an enumerator,
not the enumerator itself. This is somewhat complicated by the fact that
at the time this happens, astOperand1(), astOperand2(), astParent() etc
are not set. The current implementation is not perfect, for example in
the code below, y will not have a varid set, but x and z will. This is
deemed sufficient for now.

            int x, y, z;
            enum E { a = f(x, y, z); };

* Fix #9647: Value of enums with variables as init values

C++ allows enum values to be set using constexprs, which cppcheck did
not handle before. To solve this, add a new pass to valueflow to update
enum values after global consts have been processed. In order to do so,
I moved all settings of enum values to valueflow. After setting the enum
values, we need another call to valueFlowNumber() to actually set users
of the enums.

There is still room for improvements, since each pass of
valueFlowGlobalConstVar() and valueFlowEnumValue() only sets variables
that are possible to set directly, and not if setting the value of a
variable allows us to set the value of another. For example

	constexpr int a = 5;
	constexpr int b = a + 5;
	enum E { X = a };
	constexpr E e = X;

Here both b and e will not have their values set, even though cppcheck
should be possible to figure out their values. That's for another PR
though.

This was tested by running test-my-pr.py with 500 packages. The only
difference was one error message in fairy-stockfish_11.1, where cppcheck
now printed the correct size of an array instead of 2147483648 which I
assume is some kind of default value. In that package, using a constexpr
when setting enum values is common, but as mentioned, there was no
change in the number of warnings.
2020-10-22 07:45:04 +02:00
Armin Müller 08cef9e815
Typos found by running "codespell" (#2846) 2020-10-15 19:24:13 +02:00
Daniel Marjamäki f956dee58a Tokenizer: Fixed simplification of parentheses in expression 'a=(b,c);' 2020-09-29 12:06:30 +02:00
Daniel Marjamäki ad9b2741cd varid: set varid for 'extern const char (*x[256]);'. This is a partial fix for #9922 2020-09-29 10:53:20 +02:00
Daniel Marjamäki 4c9db17742 Tokenizer: replace all or none of the alternative tokens in a translation unit 2020-09-28 19:01:31 +02:00
Daniel Marjamäki fa42d8c49c Fixed #9920 (Tokenizer: The keyword is not replaced, leads to false positive) 2020-09-28 16:35:50 +02:00
Oliver Stöneberg 7189b303ae
fixed some modernize-loop-convert clang-tidy warnings (#2815) 2020-09-21 19:30:47 +02:00
Daniel Marjamäki 3459f0da32 Fixed #9812 (False positive; syntax error 'using array_p = const array_t *;') 2020-09-14 21:59:58 +02:00
Daniel Marjamäki 687b44dbb7 Token: add flag for splitted variable declaration with initialization 2020-09-09 16:22:47 +02:00
Daniel Marjamäki e802d85315 Fixed #9445 (Syntax error on typeof word in C) 2020-09-08 17:12:54 +02:00
Daniel Marjamäki c0ef640304 Fixed #9881 ((Regression) Hang with operator() in function call) 2020-09-07 21:32:29 +02:00
Daniel Marjamäki cfd41fea83 Fixed #9879 (Tokenizer: Better handling of operator() '(*this)(...)') 2020-09-07 20:07:21 +02:00
Daniel Marjamäki 136ac2c643 Fixed #9266 (handle operator() better) 2020-09-06 21:02:06 +02:00
Daniel Marjamäki 9a943e7616 misra: rewrote rule 12.3 2020-09-06 11:33:37 +02:00
Daniel Marjamäki 7969bf7ae8 Token: Add 'isSplittedVarDecl attribute 2020-09-06 11:02:22 +02:00
Daniel Marjamäki 12d51ae5c4 Fixed #9809 (Tokenizer; Fix handling of variable declaration with @) 2020-09-02 13:04:33 +02:00
IOBYTE 8774e97f26
fix #9771 (Syntax error; operator != <> ()) (#2757) 2020-08-26 18:39:33 +02:00
Daniel Marjamäki 72fa5f2e27 Fixed #9752 (ValueFlow: Uninit after assignment with '&') 2020-08-05 22:57:06 +02:00
Georgy Komarov 6bc13080ee
Simplify condition 2020-07-18 07:07:20 +03:00
Georgy Komarov 382f21a5c9
Fixed crash on garbage code: comparisson with an empty second operand
This will fix #9774.
2020-07-18 07:02:12 +03:00
Daniel Marjamäki ddd21a260f Fixed #6978 (False positive: unusedLabel shown for labels that are used in some preprocessor configurations) 2020-06-30 18:26:24 +02:00
Daniel Marjamäki 0583763cc6 Fixed #3088 (False positive: Dont report "struct or union member is never used" for structs with __attribute__((packed)) or #pragma pack(push)) 2020-06-30 11:00:40 +02:00
Daniel Marjamäki af6e76d623 Fixed #9787 (Better handling of user defined literals) 2020-06-25 22:06:34 +02:00
Simon Martin 1705d096f7
Simplify empty anonymous namespaces. (#2673) 2020-06-07 13:49:04 +02:00
Ken-Patrick Lehrmann a45c7752a5
9185: Don't syntax error on nested lambdas (#2672) 2020-06-07 08:58:12 +02:00
Ken-Patrick Lehrmann 99ff04f617
9757: skip template parameters when computing scope (#2670)
The template parameter is confusing simplifyUsing: it does not compute
properly the scope, and we end up replace "type" in "to_string" with
"void", then later "void" is removed and we have an internal error.
2020-06-06 17:51:15 +02:00
Paul Fultz II eed2e829a7
Revert "Cleanup: Removed Tokenizer::simplifyTokenList2. As a side-effect, rules for "simple" token list are now executed on normal token list." (#2666)
This reverts commit 187cde183d.
2020-05-30 11:23:22 +02:00
PKEuS 187cde183d Cleanup: Removed Tokenizer::simplifyTokenList2. As a side-effect, rules for "simple" token list are now executed on normal token list. 2020-05-29 21:21:07 +02:00
Daniel Marjamäki 67115491ea Fixed #9739 (Tokenizer: simplifyTypedef: wrong simplification in using) 2020-05-29 11:16:49 +02:00
Daniel Marjamäki 7ff692341e Fixed #9730 (Regression: TEXT macro not handled in windows code) 2020-05-28 22:03:16 +02:00
Daniel Marjamäki 4d5fe6ec5e astyle formatting
[ci skip]
2020-05-26 23:28:19 +02:00
Oliver Stöneberg 4f68d85633
optimized non-matchcompiled Token::simpleMatch() a bit (#2640) 2020-05-26 20:13:56 +02:00
Daniel Marjamäki f7f26ffe90 Tokenizer: Better handling of c alternative tokens in const method 2020-05-25 15:07:23 +02:00
Oliver Stöneberg 37bc0483a4
made check.h less heavy (#2633) 2020-05-23 07:16:49 +02:00
Paul Fultz II 8301fa8244
Fix issue 8144: valueFlowBeforeCondition: struct (#2645) 2020-05-21 08:47:48 +02:00
PKEuS 662745b504 Fixed several coverity messages 2020-05-20 18:54:16 +02:00
PKEuS c155062cf2 Optimization: Speed up SymbolDatabase creation and Tokenizer::findGarbageCode() by using Token::isKeyword() for pre-checks 2020-05-19 13:48:15 +02:00
PKEuS f6788c0472 Fixed Token::isKeyword: Actually set this flag to a reasonable value in all code paths 2020-05-19 13:47:25 +02:00
PKEuS c9d8f607df Optimization: Reduced peak memory usage (30% in my test case) by immediately deleting simplecpp::TokenList while creating the cppcheck TokenList. 2020-05-19 12:08:17 +02:00
PKEuS 09a30bd6b5 Optimization: Speed up Tokenizer::findGarbageCode() (by 15% in my test case) by avoiding iterating through token list multiple times 2020-05-19 08:54:47 +02:00
PKEuS d6390dbd14 Optimization: Improved performance of simplifyTypedef for code with lots of typedefs
20% performance gain when checking ExtremeTuxRacer sourcecode (with glext.h available)
2020-05-19 08:35:13 +02:00
Daniel Marjamäki 9eda399323 Less strict unknownMacro 2020-05-17 19:12:16 +02:00
Daniel Marjamäki 08ddd84780 Update copyright year 2020-05-10 11:16:32 +02:00
Daniel Marjamäki 3e0218299b Revert "Update copyright year"
This reverts commit 6eec6c4bd5.
2020-05-10 11:13:05 +02:00
Daniel Marjamäki 6eec6c4bd5 Update copyright year 2020-05-10 11:11:34 +02:00
Daniel Marjamäki 00d1091506 Tokenizer: operator handling, fix tests 2020-05-04 23:00:51 +02:00
Daniel Marjamäki 06cb0e99d1 Tokenizer: Fix syntax error when operator* is called 2020-05-04 21:33:30 +02:00
Daniel Marjamäki 47c998e52d Fixed #9689 (setVarId: wrong varid when 'not' is used) 2020-04-25 14:42:45 +02:00
Oliver Stöneberg 1af959af2c
fixed -Wextra-semi-stmt Clang warnings (#2553)
* fixed -Wextra-semi-stmt Clang warnings

* adjusted REDIRECT macro to require a semicolon

* testmathlib.cpp: rolled back accidental change
2020-04-21 17:27:51 +02:00
Daniel Marjamäki bda73600e0 Tokenizer: Improved removal of unused template (#9588) 2020-04-20 20:48:22 +02:00
Zorgovskiy 08fc956990
Fixes issue #9664 (#2614) 2020-04-20 08:59:35 +02:00
Daniel Marjamäki de53f63f76 Fixed #9665 (Tokenizer::setVarId: for loop variables) 2020-04-18 12:08:53 +02:00
Daniel Marjamäki e4bea02cad Fixed #7578 (varid not set for 'pointer to array' member variable in method) 2020-04-15 20:56:21 +02:00
Daniel Marjamäki 266c8d2c09 Remove temporary daca bailouts 2020-04-15 19:54:56 +02:00
Daniel Marjamäki 98be091d80 Fixed typedef simplification for array of function pointers 2020-04-13 16:28:01 +02:00
Oliver Stöneberg 2c1e36e63e
cleaned up includes based on include-what-you-use (#2600)
* cleaned up includes based on include-what-you-use

* check.h: trying to work around Visual Studio 2012 bug

* fixed Visual Studio compilation
2020-04-13 13:44:48 +02:00
shaneasd 82c09f243b
Maybeunusedsupport (#2570)
* Add rudimentary support for [[maybe_unused]]

* Add more test cases. use the symboldatabase rather than reparsing. Fix travis error.

* test review actions

* change var to usage._var
2020-04-12 20:35:54 +02:00
Daniel Marjamäki 97b04ba9a7 Syntax check: Using keyword in global scope 2020-04-11 17:36:22 +02:00
Daniel Marjamäki e8e3c2660d Detect syntax error 'x ==> y' 2020-04-11 11:05:27 +02:00
Daniel Marjamäki 05769e8dcc Code cleanup 2020-04-10 13:14:38 +02:00
Daniel Marjamäki 0725c2290c Tokenizer: Do not simplify function pointers to normal pointers as we loose important information 2020-04-10 11:53:32 +02:00
Daniel Marjamäki 8e9d7290b2 Tokenizer::simplifyTypedef: Better handling of r-value references 2020-04-08 22:40:45 +02:00
Oliver Stöneberg 1dd8d4afaf
fixes for Clang and clang-tidy 10 (#2588)
* clang_tidy.cmake: added clang-tidy-10 to program list

* fixed -Wrange-loop-construct Clang warnings

* fixed readability-qualified-auto clang-tidy warnings

* .clang-tidy: actually disable clang-analyzer-* warnings

* .clang-tidy: disabled some new warnings introduced with clang-tidy-10
2020-04-04 11:44:59 +02:00
Daniel Marjamäki ac45bf7af2 Small refactoring 2020-04-04 11:19:39 +02:00
Daniel Marjamäki e0acd1abf8 Tokenizer: Report unknown macro that contains '.x=..' argument 2020-04-04 10:32:56 +02:00
Daniel Marjamäki 7577bdb1df DACA: Try to avoid some crashes/hangs for the most crazy code so we can focus on most serious bugs first 2020-03-31 11:33:38 +02:00
Daniel Marjamäki 1173186876 Fixed daca@home crash by stopping for unknown macro 'MACRO(a();b();)' 2020-03-12 13:28:09 +01:00
Daniel Marjamäki 900b99fbd8 Tokenizer; Report unknown macro used in function declaration 2020-03-10 20:22:46 +01:00
Daniel Marjamäki 5df6d5bc7c Tokenizer; Warn about unknown macro used in string concatenation 2020-02-28 21:52:01 +01:00
Daniel Marjamäki 84995485ea VarId: fixed varids for 'for (auto [x,y]: xy)' 2020-02-27 07:18:07 +01:00
Daniel Marjamäki f07a71e3e1 Report unknown macros for pattern '%name% %num%' 2020-02-22 11:57:36 +01:00
Daniel Marjamäki ec8c733afb Improved Qt simplification 2020-02-21 19:04:21 +01:00
Daniel Marjamäki 6f6f9dd5bc Tokenizer: Throw unknownMacro in non-executable scope 2020-02-19 21:12:58 +01:00
Daniel Marjamäki ae0a73a538 Fixed #9618 (isCast flag not set for c++ casts) 2020-02-16 16:46:40 +01:00
Paul Fultz II 921887a281
Use valueFlowGeneric for valueFlowForwardExpression (#2537) 2020-02-16 16:02:22 +01:00
Daniel Marjamäki dcee189146 Tokenizer::setVarId: better handling of decltype() 2020-01-29 17:40:22 +01:00
Simon Martin 2840173a72 Ticket #9569: Do not substitute type aliases within enum definitions. (#2504) 2020-01-25 10:18:37 +01:00
Simon Martin 224a41361d Ticket #9572: Properly detect designated initializers. (#2496) 2020-01-25 10:14:16 +01:00
Rikard Falkeborn 7514544d94 Fix #8758 (add syntax error for invalid code) (#2466) 2020-01-01 15:46:09 +01:00
Daniel Marjamäki c84ba10b37 Fixed #8774 (Wrong handling of function with name 'or') 2019-12-19 19:22:39 +01:00
Daniel Marjamäki f614d32d6a Fixed #9519 (Syntax error on valid C++ 'enum {} (a)') 2019-12-15 08:40:04 +01:00
IOBYTE 0e4efea530 fix #9539 (Syntax error for valid C++14 code) (#2446) 2019-12-12 20:50:20 +01:00
RobkeBaer 370196a14c Fix extern c typedef syntax error (#2438)
* Fix extern c typedef syntax error

* Fix extraWhiteSpaceError

* Move test from testgarbage to testtokenize
2019-12-12 13:51:14 +01:00
IOBYTE f637d97080 Fix 9509 (Syntax error on empty attribute list) (#2423) 2019-12-06 05:17:19 +01:00
IOBYTE 5979eec2c0 Fix 9518 (Syntax error on valid C++) (#2424) 2019-12-05 20:51:36 +01:00
Paul Fultz II f77347d7b4 Fix crash 9492: Crash in FwdAnalysis::checkRecursive() (condTok is nullptr) (#2411)
* Fix crash 9492: Crash in FwdAnalysis::checkRecursive() (condTok is nullptr)

* Formatting
2019-12-01 14:53:03 +01:00
Daniel Marjamäki ebd32cfd73 Syntax error: if (retval==) 2019-11-23 18:50:46 +01:00
IOBYTE fb1d60bfb1 fix syntax error for num.operator std::string()[0] (#2389) 2019-11-23 17:42:24 +01:00