Commit Graph

2805 Commits

Author SHA1 Message Date
chrchr-github ceb86afc22
Fix #10952 FP constStatement with cast in return (#3986) 2022-04-07 14:11:14 +02:00
chrchr-github c4dcfef385
Fix #10260 debug: Executable scope 'x' with unknown function. (#3974)
* Fix #10174 debug: Executable scope 'x' with unknown function

* Format

* Add test for #10198

* Fix #10260 debug: Executable scope 'x' with unknown function.
2022-04-05 15:52:16 +02:00
Daniel Marjamäki ea63b8e2bb misra: fix void parameter check 2022-04-01 21:34:47 +02:00
chrchr-github 4bf8718dcb
Fix #10849 FP constStatement with pointers in lambda (#3961) 2022-04-01 19:50:40 +02:00
Paul Fultz II 5bea50cd36
Fix 10908: FP: uninitvar after for-loop (#3942) 2022-03-31 21:24:20 +02:00
chrchr-github 183969cd4b
Fix #10936 FP constStatement with extern declaration (#3960) 2022-03-31 21:08:04 +02:00
chrchr-github 86ff360946
Fix #10917 FP constStatement with immediately evaluated lambda (#3956) 2022-03-29 06:10:57 +02:00
chrchr-github 3faff5e9fc
Fix #10248 FP knownConditionTrueFalse static variable with direct initialization (#3922) 2022-03-22 07:24:40 +01:00
chrchr-github fb1170b10b
Fix #10872 FP constStatement with variable called std (#3906) 2022-03-16 15:29:34 +01:00
chrchr-github 6376bac5bb
Fix #10451 syntaxError with typedef and lambda (#3900)
* Fix #10451 syntaxError with typedef and lambda

* Don't insert union into template argument list, add test

* Format

* Revert "Format"

This reverts commit 8c52d49c8b.

* Format
2022-03-14 17:59:29 +01:00
chrchr-github d1f740a289
Partial fix for #9384 varid 0 with lambda (II) (#3889)
* Partial fix for #9384 varid 0 with lamba

* Format

* Undo

* Undo

* Partial fix for #9384 varid 0 with lambda (II)
2022-03-12 06:17:37 +01:00
chrchr-github c9f47dec8b
Partial fix for #9384 varid 0 with lambda (#3875) 2022-03-08 20:10:51 +01:00
chrchr-github 01de8256ea
Fix #10798 cppcheckError with enum class and typedefs (#3867)
* Fix #10798 cppcheckError with enum class and typedefs

* Format

* Format

* Leave enum class scope

* Remove comment
2022-03-02 07:46:15 +01:00
chrchr-github 43fb3dd047
Fix regression: wrong varid with using namespace (#3866)
* Fix #10059 missing varId with using namespace

* Undo

* Fix test

* Limit namespace candidates, duplicateBranch

* rvalue ref

* Undo

* Undo

* Undo

* Format

* Fix condition

* Fix regression: wrong varid with using namespace
2022-03-02 07:46:04 +01:00
José Martins b1e92fc399
Misra false positive fixes for rules 8.7 and 5.9 (#3844)
* Fix misra 8.7 false positives on single function usage

When there is a single usage of a function, we should first check if the
file it is used in, is the same one it was defined in. When this is not the
case, there is no violatior to be reported.

* Fix misra rule 5.9 false positives for exception

The exception for rule 5.9 described in the guidelines allows for
multiple definitions of internal linkage obejcts when these regard a
static inlined function defined in the same header file.

* Fix neglecting of inline keyword flag upon simplifications

When the inline keyword is being "simplified" and the inline flag is
degated to the next token. However, this information might be lost if the next
token itself is simplified/deleted in a futher pass. Therefore, we must
propagated the flag to all the next named tokens, so we can make sure the
function name token itself is tagged with this property.

* add tests for misra addon rules 8.7 and 5.9
2022-02-27 19:17:48 +01:00
chrchr-github ddb0a8bb0b
Fix #10059 missing varId with using namespace (#3860)
* Fix #10059 missing varId with using namespace

* Undo

* Fix test

* Limit namespace candidates, duplicateBranch

* rvalue ref

* Undo

* Undo

* Undo

* Format

* Fix condition
2022-02-27 09:03:24 +01:00
chrchr-github d77fa64051
Fix #10256 Function::addArguments found argument 'x' with varid 0 (#3845) 2022-02-21 18:06:26 +01:00
chrchr-github 52f549fa87
Fix crash on garbage code (#3834) 2022-02-15 20:19:03 +01:00
Daniel Marjamäki 30cec97cc8 Tokenizer: Support C++20 default bit-field member initializer 2022-02-12 12:19:08 +01:00
Oliver Stöneberg 06d10b7474
fixed and enabled performance-for-range-copy clang-tidy warning (#3682) 2022-02-12 08:20:45 +01:00
chrchr-github 2c7948102a
Fix #10145 FP AssignmentAddressToInteger with enum class (#3810) 2022-02-08 16:12:35 +01:00
chrchr-github e64ea20089
Fix #10527 FP variableScope for if with init-statement (#3811) 2022-02-08 16:12:09 +01:00
Daniel Marjamäki 3989408738 Update copyright year 2022-02-05 11:45:17 +01:00
Oliver Stöneberg 171da2e6f9
avoid dependency on transitive includes - based on include-what-you-use (#3757) 2022-01-27 19:03:20 +01:00
Oliver Stöneberg 55ff684f34
added unusedFunction self check to CI / cleanups (#3526) 2022-01-18 22:02:25 +01:00
Paul Fultz II 7406dd8c94
Fix 10721: Crash in Tokenizer::simplifyTokenList1 (#3712) 2022-01-16 12:46:20 +01:00
Paul Fultz II abb0563cef
Fix 10726: Crash in CheckExceptionSafety::checkRethrowCopy (#3711) 2022-01-16 12:35:51 +01:00
Paul Fultz II 0b1cd8626d
Fix 10664: Crash in Token::linkAt (#3708)
* Fix 10664: Crash in Token::linkAt

* Format
2022-01-14 23:51:01 +01:00
Oliver Stöneberg 6739995e79
removed or annotated some code which is only used in test code (#3656) 2022-01-03 12:40:20 +01:00
Chris Lalancette df1d6cf026
Fix the ability to recognize return types when simplifying attributes. (#3637)
* Fix the ability to recognize return types when simplifying attributes.

When parsing attributes to remove them, we have to allow for
the case where the return type of the function that follows
the attribute has a namespaced C++ type, like foo::bar .
That means that :: has to be recognized as a valid token.
Fix this in simplifyAttribute, and add tests for this as well.
2021-12-22 19:02:38 +01:00
Daniel Marjamäki 0d7a3a8b26 dump; add 'noreturn' attribute for function calls 2021-12-19 15:32:33 +01:00
chrchr-github bb327be8e8
Fix #10591 FP unusedStructMember with value-initialized struct and typedef (#3643) 2021-12-18 22:55:52 +01:00
Paul Fultz II 16110b6157
Fix 10339: Lambda in leads to analysis fail (#3629) 2021-12-15 19:34:18 +01:00
Paul Fultz II c0af66bb52
Fix 10552: Internal error with unusedFunction (#3600) 2021-12-05 15:46:17 +01:00
Paul Fultz II 29dbded4af
Fix 10615: Crash in Token::linkAt (#3599) 2021-12-04 12:57:59 +01:00
Paul Fultz II bc31419da0
Fix 9301: Syntax error when specializing template variable array (#3601) 2021-12-04 12:56:25 +01:00
KenPatrickLehrmann f5f600bafc
Don't simplify template for class names in declarations (#3505)
* Don't simplify template for class names in declarations

Without the patch, the test would give:

```
Expected:
namespace foo { class Bar ; } class Baz ; class C : Baz { } ;

Actual:
namespace foo { class Bar ; } class Baz ; class foo :: Bar : Baz { } ;

```

* Use valid code in test case
2021-11-06 19:07:45 +01:00
Oliver Stöneberg cc1a18806c
use -Weverything for clang in CMake / fixed some warnings (#3519) 2021-10-24 11:06:48 +02:00
Oliver Stöneberg 99db1f3f22
fixed some compiler warnings (#3502) 2021-10-13 12:10:26 +02:00
Paul Fultz II fc6a791a74
Fix 9766: False positive; suspicious operator is written in declaration (#3476) 2021-10-03 09:59:51 +02:00
Paul Fultz II edd435d5f0
Fix 10491: Crash in unusedFunction on valid C++ code (#3465) 2021-09-22 13:03:46 +02:00
Daniel Marjamäki 15eb53b403 Tokenizer: Add 'enum struct' pattern 2021-08-30 20:18:06 +02:00
Daniel Marjamäki ccfd18b96d Simplify Typedef: Fixed typedef simplification in expanded tokens 2021-08-29 19:14:53 +02:00
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