chrchr-github
ca311ebcdf
ASSERT() on calls to Tokenizer::tokenize() in test code ( #3501 )
2021-11-29 07:34:39 +01:00
Paul Fultz II
3cb252bd99
Fix 9873: False negative: null pointer when checking raw pointer ( #3485 )
2021-10-06 08:39:58 +02:00
Paul Fultz II
7f358b2bed
Format with uncrustify ( #3388 )
2021-08-07 20:51:18 +02:00
Daniel Marjamäki
8aa9e448f5
Parser; Set varid for structured binding variables
2021-04-26 18:04:27 +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
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
PKEuS
cf1937294a
Refactorization: Removed unnecessary \n and spaces in strings
...
Merged from LCppC.
2021-02-20 12:58:42 +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
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
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
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
2bb73840fc
astyle formatting
2020-08-23 17:17:33 +02:00
Paul Fultz II
a332062385
Add exprId to tokens ( #2744 )
2020-08-20 18:21:29 +02:00
Daniel Marjamäki
9edca82138
Fix testrunner
2020-05-25 16:02:34 +02:00
PKEuS
fb1afe2345
Fixed test suite: Do no longer apply simplifyTokenList2 to token lists, except for those tests that test those simplifications, because checks are no longer run on that simplified token list
...
Changed failing unit test to TODO tests, as they indicate patterns we do no longer understand properly.
2020-05-20 18:54:16 +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
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
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
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
84995485ea
VarId: fixed varids for 'for (auto [x,y]: xy)'
2020-02-27 07:18:07 +01:00
Daniel Marjamäki
dcee189146
Tokenizer::setVarId: better handling of decltype()
2020-01-29 17:40:22 +01:00
IOBYTE
78b9fd9bb9
Fix #9383 ("debug: Function::addArguments found argument 'x' with varid 0." with variadic templates) ( #2238 )
2019-10-06 12:45:42 +02:00
IOBYTE
c32a568c1f
fix #8965 ("(debug) Executable scope 'x' with unknown function." with rvalue parameter in method) ( #2237 )
...
I fixed the AST enough to pass testrunner but I don't believe it is
correct.
This code:
void Foo4(int&&b);
has this AST:
( 'void'
|-Foo4
`-&& 'bool'
|-int
`-b 'signed int'
but I don't believe && should have `bool`.
2019-10-04 12:30:11 +02:00
Daniel Marjamäki
742c437953
Fixed #9354 (Unknown macro is not reported and then Cppcheck is silent about issues)
2019-09-13 13:05:48 +02:00
IOBYTE
e5220bdf0c
make ellipsis ... a single token ( #2143 )
...
* make ellipsis ... a single token
Using cppcheck -E to preprocess code with ellipsis produces output that
can't be compiled because ... is split into 3 tokens.
* try to fix addon
2019-09-04 08:07:30 +02:00
IOBYTE
bee248b2de
token simplifier: fix namespace, token link and syntax error support for template type aliases ( #1863 )
2019-06-01 10:52:29 +02:00
Daniel Marjamäki
57c6628732
Revert 'Cleaning up unsimplified templates'. This fix caused problems.
2019-05-16 21:11:04 +02:00
Daniel Marjamäki
27fad38e00
Fixed #9084 (Tokenizer::setVarId: Same varid for member variable and argument, unknown template type)
2019-05-12 09:10:37 +02:00
Daniel Marjamäki
d58d4273f9
Cleaning up unsimplified templates
2019-05-11 13:00:03 +02:00
IOBYTE
7799ed4243
Fixed #8889 (varid on function when using trailing return type.) ( #1800 )
...
* Fixed #8889 (varid on function when using trailing return type.)
Don't set varid for trailing return type.
* Add a test for #9066 (Tokenizer::setVarId: varid set for trailing return type)
2019-04-18 20:22:39 +02:00
Daniel Marjamäki
e0f1418228
Fixed #9034 (Tokenizer::setVarId: function call parameter is not variable declaration)
2019-03-24 07:06:21 +01:00
IOBYTE
155e4ce912
Fixed #8971 ("(debug) Unknown type 'x'." using alias in class members) ( #1653 )
...
* Fixed #8971 ("(debug) Unknown type 'x'." using alias in class members)
* template simplifier: partial fix for #8972
Add support for multi-token default template parameters.
* template simplifier: fix for #8971
Remove typename outside of templates.
2019-02-09 08:34:59 +01:00
Daniel Marjamäki
bd7790fd8c
Update copyright year
2019-02-09 07:24:06 +01:00
Daniel Marjamäki
ae001d4336
Fixed #8957 (Tokenizer::setVarId: varid not set when lambda function is used)
2019-02-03 08:57:04 +01:00
IOBYTE
98fc6d1d32
Fixed #8959 ("(debug) Unknown type 'x'" with using/alias) ( #1635 )
...
* Fixed #8959 ("(debug) Unknown type 'x'" with using/alias)
* fix cppcheck warning
2019-01-31 23:57:37 +01:00
Daniel Marjamäki
022259caf3
Fix Cppcheck warning
...
[ci skip]
2019-01-12 19:11:18 +01:00
Daniel Marjamäki
8dd641b8be
Use OVERRIDE in test
2019-01-12 15:45:25 +01:00
Daniel Marjamäki
8087cfed5d
Fixed #8627 (Tokenizer::setVarIdPass2: constructor parameter)
2018-12-02 09:28:05 +01:00
Daniel Marjamäki
69f2e0938a
VarId: Improved varids for struct members ( #8844 )
2018-11-14 19:11:35 +01:00
Daniel Marjamäki
93cde415a7
Fixed #7988 (variable in condition gets wrong varid)
2018-11-11 07:50:25 +01:00
Daniel Marjamäki
c3e6e7c338
Fixed #8664 (setVarId: Wrongly set varid for lambda argument)
2018-10-07 20:40:59 +02:00
Daniel Marjamäki
45379a3aa6
Updated copyright year for modified files
...
[ci skip]
2018-06-10 22:07:21 +02:00
IOBYTE
ce50df8047
Fix override warnings. ( #1234 )
2018-05-15 16:37:40 +02:00
Daniel Marjamäki
c4caee6b18
Updated copyright year
2018-01-14 15:37:52 +01:00
Daniel Marjamäki
fc1ac180e6
Fixed #6218 (Template type aliasing misdetection)
2017-12-29 22:47:07 +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
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
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
324257ef52
Fixed #7823 (No varid for member variable of type std::bitset< static_cast<int>(2) >)
2017-11-05 17:59:34 +01:00
Daniel Marjamäki
94c5c3703c
astyle formatting
...
[ci skip]
2017-08-16 18:56:02 +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
Ayaz Salikhov
28aa939d69
iwyu - include what you use
2017-05-27 04:33:47 +02:00
Robert Reif
c96e8daebc
Don't change varid of member variables.
2017-03-25 10:59:35 -04:00
Robert Reif
662bc6f846
Add variable or type information to auto and auto variable tokens. Changing the auto variable type requires rerunning the variable pointer pass to correct the symbol database for the new type.
2017-03-22 22:09:40 -04:00
Daniel Marjamäki
8c707876ed
Tokenizer: Don't simplify '({..})' wrongly
2017-03-08 11:41:18 +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
Daniel Marjamäki
5b377ea2e4
Fixed #7821 (segmentation fault, invalid last token)
2016-11-20 14:15:51 +01:00
Harald Scheidl
ba6cda9c86
Fixed #7740 (Tokenizer::setVarId: Function declaration does not start with 'return')
2016-10-03 10:02:18 +02:00
Daniel Marjamäki
5e78dae143
Use TODO_ASSERT_EQUALS instead of TODO comments
2016-08-02 19:38:36 +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
ca929f0f1b
Try to fix #7608 (Assertion failed in test/testvarid.cpp at line 1988)
2016-07-19 11:59:37 +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
Daniel Marjamäki
b9443771fb
cleanup tests
2016-07-18 10:42:03 +02:00
Daniel Marjamäki
710e066a9a
Fixed #6406 (VarId: struct member initialization)
2016-05-22 21:18:52 +02:00
Daniel Marjamäki
b965cf5491
Fixed #7444 (Tokenizer::varId: Wrong varid when there is anonumous union in class)
2016-05-11 20:43:23 +02:00
PKEuS
b65cacf4b1
Tokenizer::simplifyStaticConst(): Support "struct" and operator:: ( #7403 )
2016-05-04 12:33:19 +02:00
Daniel Marjamäki
c7f5ca74bd
VarId: Set varid for template parameters ( #7046 )
2016-01-31 11:07:30 +01:00
Daniel Marjamäki
2627aada07
Fixed #7346 (Tokenizer::setVarId: No varId for member in initialization list)
2016-01-23 08:28:04 +01:00
Daniel Marjamäki
a434e0fb1a
Fixed #7272 (Tokenizer:setVarId: handle namespaces better)
2016-01-19 14:32:27 +01:00
Daniel Marjamäki
414bdc30a9
Fixed #7276 (VarId: Missing varId in template class constructor initialization lists)
2016-01-10 22:10:49 +01:00
Daniel Marjamäki
7191733981
Fixed #7192 (False positive: uninitMemberVar when base class is in another namespace)
2016-01-09 12:18:36 +01:00
Daniel Marjamäki
88a525aca7
Fixed #7267 (Tokenizer::setVarId: wrongly sets varId in cast with unknown type)
2016-01-06 17:47:59 +01:00
Lauri Nurmi
996c9244d8
Update copyright year to 2007-2016.
2016-01-01 15:34:45 +02:00
Daniel Marjamäki
40851a12ef
Fixed #4627 (Tokenizer::setVarId: function declaration in function body)
2015-11-19 16:27:16 +01:00
PKEuS
e990cfb76b
Fixed setVarId() for destructors
2015-11-18 21:13:58 +01:00
Daniel Marjamäki
0f9d90d2be
Changed Copyrights. Removed my name.
2015-11-18 20:04:50 +01:00
PKEuS
f9bc229d4b
Support varids in nested classes that are declared outside of outer class ( #7127 )
2015-11-13 10:07:57 +01:00
PKEuS
ee00925dc5
setVarId: Support throw() in constructor implementations ( #7123 )
2015-11-11 11:01:49 +01:00
PKEuS
03d52de74b
Treat "class" keyword similar to "struct" or "union" on C++ code ( #6696 )
2015-11-10 17:03:27 +01:00
PKEuS
cc9a1f4375
Fixed setVarId() for template in initializer list ( #7122 )
2015-11-10 16:14:53 +01:00
PKEuS
5cd36d6f8a
Refactorization: Use varid instead of variable name in CheckClass::initializeVarList() and fixed issue in setVarId().
...
Fixed internal warning.
2015-11-09 23:00:14 +01:00
PKEuS
49a9b011eb
Fixed handling of this-> and (*this). in setVarId()
2015-11-09 21:43:40 +01:00
PKEuS
2ac8da0497
Fixed #6548 also for noexcept
2015-11-06 18:00:59 +01:00
PKEuS
24882fb53a
Fixed VarId accidentially assigned to case labels.
2015-10-26 21:24:53 +01:00
PKEuS
5add1d8901
Set VarId in range-based for-loops
2015-10-26 19:03:23 +01:00
Alexander Mai
21efa992e3
#6865 TemplateSimplifier::expandTemplate doesn't terminate on invalid code. Add some another syntax check on templates to avoid problems later on.
2015-10-18 15:47:37 +02:00