chrchr-github
24e9859158
Fix #10357 FP stlcstrParam due to incorrect overload resolution ( #3813 )
...
* Fix #10357 FP stlcstrParam due to incorrect overload resolution
* Variable shadowing
2022-02-10 11:17:06 +01:00
Paul Fultz II
a639c59780
Fix 10787: False positive: knownConditionTrueFalse with a conditional exit ( #3804 )
2022-02-06 20:13:44 +01:00
Daniel Marjamäki
3989408738
Update copyright year
2022-02-05 11:45:17 +01:00
chrchr-github
511520d623
Fix #10679 FP constParameter with const/nonconst overload ( #3780 )
2022-02-02 19:38:32 +01:00
chrchr-github
dad64bfcc8
Fix #10091 FP shadowFunction with default destructor implementation / Tests for #8635 , #9776 , #9940 , #9951 , #10018 ( #3763 )
2022-02-02 19:30:49 +01:00
chrchr-github
d55010c441
Fix #9247 FP uninitMemberVar (inconclusive) ( #3765 )
2022-01-28 15:05:13 +01:00
chrchr-github
f429245da2
Fix #8557 FP format string requires unsigned long (for sizeof(var)) ( #3727 )
2022-01-27 19:43:52 +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
Paul Fultz II
1a949c00b0
Fix 10723: Assertion 'tok && tok->exprId() > 0 && "Missing expr id for symbolic value"' in valueFlowSmartPointer() ( #3755 )
...
* Fix 10723: Assertion 'tok && tok->exprId() > 0 && "Missing expr id for symbolic value"' in valueFlowSmartPointer()
* Format
2022-01-26 06:28:13 +01:00
chrchr-github
9d6e5c2a05
Fix #10237 uninitMemberVar - member initialized via function call ( #3745 )
2022-01-24 21:52:00 +01:00
Paul Fultz II
a7dbd288c4
Fix 10738: FP knownEmptyContainer with auto reference ( #3734 )
...
* Fix 10738: FP knownEmptyContainer with auto reference
* Format
2022-01-21 09:56:55 +01:00
chrchr-github
c2fc4973ad
Fix #10515 False positive for explicit one-argument constructor if co… ( #3718 )
2022-01-17 20:51:23 +01:00
Paul Fultz II
4af98f21d6
Fix 10588: crash ( #3691 )
2022-01-16 12:33:31 +01:00
Paul Fultz II
55ff010df3
Fix 10717: Crash in SymbolDatabase::setValueTypeInTokenList ( #3710 )
...
* Fix 10717: Crash in SymbolDatabase::setValueTypeInTokenList
* Format
2022-01-15 07:56:56 +01:00
chrchr-github
781a145680
Fix regression: functionStatic related to overload resolution ( #3705 )
2022-01-14 17:55:50 +01:00
chrchr-github
1b89c998f5
Fix #10469 FP returnTempReference with overloaded operator+= ( #3678 )
2022-01-12 22:05:30 +01:00
shaneasd
8f7996211b
remove nullScope from TestSymbolDatabase ( #3679 )
2022-01-06 15:23:43 +01:00
chrchr-github
9fda86eb6d
Fix #9998 ( #3676 )
2022-01-06 15:21:05 +01:00
Oliver Stöneberg
0ba9cb4e64
fixed some unusedFunction warnings ( #3618 )
2022-01-04 15:48:08 +01:00
Armin Müller
d5daba331f
Typos found by running "codespell" ( #3659 )
2022-01-02 08:12:08 +01:00
Daniel Marjamäki
e6ccf299b9
Fixed #10598 (SymbolDatabase: final class is not parsed properly)
2021-12-22 21:48:01 +01:00
Daniel Marjamäki
77434d093e
SymbolDatabase: Do not set wrong type for std::map etc items in range for loop
2021-12-11 15:16:54 +01:00
Paul Fultz II
a03e731930
Track lifetimes of lambdas that capture the 'this' variable ( #3594 )
2021-12-04 17:00:55 +01:00
Paul Fultz II
853a1f6d54
Fix 10631: FP, Regression: error: Return value of allocation function 'makeThing' is not stored. ( #3585 )
2021-11-29 07:06:43 +01:00
Paul Fultz II
57f5b19b34
Fix 7812: False negative: return pointer of local variable ( #3583 )
...
* Fix 7812: False negative: return pointer of local variable
* Format
* Add test case for 3029
* Format
2021-11-28 15:25:21 +01:00
Paul Fultz II
1e327dfbd3
Fix 9836: False negative: No invalidContainer when using vector of vectors ( #3580 )
...
* Fix 9836: False negative: No invalidContainer when using vector of vectors
* Format
2021-11-26 13:38:40 +01:00
Rikard Falkeborn
085d25f1b1
SymbolDatabase: Fix valuetype with constexpr and auto ( #3577 )
2021-11-24 16:51:40 +01:00
Daniel Marjamäki
10109a5ef7
dumpfile: remove redundant Variable attributes isArgument and isLocal. Add isVolatile.
2021-11-19 17:21:27 +01:00
Daniel Marjamäki
f701a9361d
chmod; Use 644 for source files
2021-11-17 08:25:25 +01:00
Daniel Marjamäki
8b5865055a
SymbolDatabase: Fix Variable pointer property for 'std::string x(*p)'
2021-11-17 08:22:49 +01:00
chrchr-github
9c31e0ce54
Fix #10393 FP returnDanglingLifetime ( #3562 )
2021-11-15 20:36:38 +01:00
Paul Fultz II
13f5b560ce
Fix 10555: FP knownConditionTrueFalse with non-const function in base class ( #3559 )
2021-11-12 20:05:43 +01:00
chrchr-github
629f883408
Fix #10097 : autovarInvalidDeallocation with pointer to std::array ( #3529 )
2021-11-08 20:31:16 +01:00
Paul Fultz II
035c70c441
Fix 10578: Value not impossible after check ( #3549 )
2021-11-07 18:19:56 +01:00
Paul Fultz II
e998cd13ca
Partial fix for 10393: FP returnDanglingLifetime when constructing string from iterators [inconclusive] ( #3536 )
2021-10-30 09:06:36 +02:00
Oliver Stöneberg
ba777b54d1
prevent uncaught exception in ThreadExecutor::handleRead() ( #3514 )
2021-10-20 20:41:42 +02:00
Paul Fultz II
3cb252bd99
Fix 9873: False negative: null pointer when checking raw pointer ( #3485 )
2021-10-06 08:39:58 +02:00
chrchr-github
0c16e346f1
Minor: add endsWith() template, empy() check ( #3472 )
2021-09-28 20:34:21 +02:00
Daniel Marjamäki
045f21ee48
Fixed #10142 (FP uninitMemberVar with std::map)
2021-09-05 16:35:24 +02:00
Ken-Patrick Lehrmann
b3b3b6b2a1
Fix handling of namespace scope with several bodystarts ( #3438 )
...
Follow up to 0093452bed
.
Give the proper end to getVariableList, since it might not be bodyEnd.
Before that, getVariableList would add the same variables in several
unrelated scopes, and all kind of false positive would follow.
For instance, with the case I added in the unit-tests, I had:
```
../code.cpp:15:18: warning: The struct 'is_A' defines member variable with name 'foo' also defined in its parent struct 'is_A_impl'. [duplInheritedMember]
static const int foo = 8;
^
../code.cpp:15:18: note: Parent variable 'is_A_impl::foo'
static const int foo = 8;
^
../code.cpp:15:18: note: Derived variable 'is_A::foo'
static const int foo = 8;
^
../code.cpp:15:18: style: struct member 'has_A::foo' is never used. [unusedStructMember]
static const int foo = 8;
^
../code.cpp:15:18: style: struct member 'is_A::foo' is never used. [unusedStructMember]
static const int foo = 8;
^
```
2021-09-04 11:09:33 +02:00
Paul Fultz II
1cd9d0479d
Fix 10433: assertion failure in ValueFlow (Interval::fromValues) ( #3419 )
2021-08-26 07:46:40 +02:00
chrchr-github
ee4d90b4fa
Refactor: fix member shadowing, return by const ref ( #3407 )
2021-08-21 22:00:45 +02:00
Daniel Marjamäki
83270a6c52
Fixed #10376 (Cppcheck does not add some function arguments to the dump file)
2021-08-15 07:48:01 +02:00
Paul Fultz II
fdaeaacc40
Symboldatabase: Improve valuetypes for containers, iterators, and smart pointers ( #3398 )
2021-08-14 19:00:58 +02:00
Paul Fultz II
f946bbc249
Only add exprids to expression and not variable declarations ( #3397 )
2021-08-14 06:49:12 +02:00
chrchr-github
e626e3065d
Fix MSVC warning: member shadowing ( #3392 )
2021-08-10 22:34:13 +02:00
Daniel Marjamäki
c2305b1da7
Fixed #10396 (FP missingReturn on void operator=())
2021-08-10 09:55:16 +02:00
Daniel Marjamäki
0093452bed
SymbolDatabase; Better handling of namespace that is defined in several scopes
2021-08-10 07:00:11 +02:00
Daniel Marjamäki
d82df7cc55
Fix self-check warning, condition is always true
2021-08-09 13:17:48 +02:00
Daniel Marjamäki
0cb6603055
SymbolDatabase; Use range based for loops
2021-08-09 12:43:21 +02:00
Paul Fultz II
7f358b2bed
Format with uncrustify ( #3388 )
2021-08-07 20:51:18 +02:00
Daniel Marjamäki
27a4df06d2
Revert "SymbolDatabase; First fix to handle when a namespace have many scopes"
...
This reverts commit e6cc7201b0
.
2021-08-04 22:30:39 +02:00
Daniel Marjamäki
e6cc7201b0
SymbolDatabase; First fix to handle when a namespace have many scopes
2021-08-04 20:36:43 +02:00
Daniel Marjamäki
0f0d042ee2
Refactoring; Use range for in SymbolDatabase
2021-08-01 21:51:37 +02:00
Paul Fultz II
00eb71fd49
Remove constexpr -> const simplification ( #3346 )
2021-07-22 07:22:26 +02:00
Paul Fultz II
8efe1d4ab4
Find reference to dangling unique ptr ( #3344 )
2021-07-20 21:30:27 +02:00
Daniel Marjamäki
d1fe34e167
misra; implement rule 8.10
2021-07-18 21:18:07 +02:00
Paul Fultz II
59a1c1a9d8
Refactor: Remove variable analyzer ( #3339 )
2021-07-18 07:46:31 +02:00
Paul Fultz II
942202aede
Evaluate container sizes in forward analysis ( #3338 )
2021-07-16 18:49:07 +02:00
Daniel Marjamäki
24c17916af
missingReturn; ensure Function::returnsVoid returns true when there is unknown macro 'void STDCALL foo() {}'
2021-07-12 20:29:20 +02:00
Daniel Marjamäki
7cb66d56f3
missingReturn; fixed false positive with trailing return type
2021-07-08 13:50:26 +02:00
Georgiy Komarov
b89f5fbeff
misra: Fix 8.2 false positives ( #3309 )
...
* misra: Fix 8.2 false positives
Fix false positives in rule 8.2 that occurred in cases when we have a
function definition and declaration in the same file.
For example, the following code generated false positives before this
commit:
```
void f(uint8_t * const x);
void f(uint8_t * const x)
{ (void)x; }
```
We need to distinguish the declaration and the definition, so the dump
file generation routine was extended to keep token where the definition
of the function. The analysis in the addon also been improved.
Closes Trac issue: https://trac.cppcheck.net/ticket/10219
2021-06-27 10:51:32 +02:00
Paul Fultz II
eb7b225fc1
Fix 10119: ValueFlow; object member is not uninitialized. happens when there is static member also. ( #3299 )
2021-06-19 13:58:18 +02:00
Paul Fultz II
95c872b1ec
Fix todo test for returning a dangling reference ( #3284 )
2021-06-04 17:15:39 +02:00
Robert Reif
c7be967769
fix #10295 (false negatives by inconsistent 'void' in argument list (declaration vs definition)) ( #3274 )
...
Co-authored-by: Robert Reif <reif@FX6840>
2021-05-24 19:32:15 +02:00
Daniel Marjamäki
07c1f28035
astyle formatting
2021-05-01 07:35:03 +02:00
Paul Fultz II
31e3e4d87b
Fix issue 10086: false positive: (style) constVariable: Variable 'x' can be declared with const ( #3219 )
2021-04-30 17:47:08 +02:00
Daniel Marjamäki
d2d2124238
Revert "Clang import; This experimental feature didn't "take off" much. After a lot of work we are still far fram the goal. I remove it now but don't rule out completely that it could ever be added again."
...
This reverts commit 207361b174
.
2021-04-30 16:47:02 +02:00
Daniel Marjamäki
bd97b8eb8a
SymbolDatabase; Add variables when structured binding is used
2021-04-26 18:21:07 +02:00
Daniel Marjamäki
4f43dbf954
Parser; fixed ast and auto type deduction for c++17 braced init lists
2021-04-25 10:38:33 +02:00
Daniel Marjamäki
207361b174
Clang import; This experimental feature didn't "take off" much. After a lot of work we are still far fram the goal. I remove it now but don't rule out completely that it could ever be added again.
2021-04-21 18:59:48 +02:00
Oliver Stöneberg
155ff890a5
split "autoNoType" and "bailoutUninitVar" from more generic "debug" ( #3209 )
2021-04-16 15:19:29 +02:00
Daniel Marjamäki
eacc9e552e
Function::returnsReference: handle type scope better
2021-04-10 14:31:50 +02:00
Paul Fultz II
5cf2f7e633
Fix issue 10087: false positive: error: Reference to temporary returned. ( #3205 )
2021-04-09 07:44:20 +02:00
Paul Fultz II
f8dc9862da
Fix issue 10202: FP: constParameter ( #3202 )
2021-04-08 16:02:11 +02:00
Oliver Stöneberg
6397e29f84
cleaned up includes based on include-what-you-use ( #3141 )
2021-04-03 21:30:50 +02:00
Oliver Stöneberg
9b974f1b8e
fixed Visual Studio warnings about shadowed members ( #3191 )
2021-03-31 22:07:20 +02:00
Tomasz Kłoczko
8d6828847b
Another gcc11 fix ( #3179 )
...
/home/tkloczko/rpmbuild/BUILD/cppcheck-2.4/lib/symboldatabase.cpp: In member function ‘void SymbolDatabase::createSymbolDatabaseExprIds()’:
/home/tkloczko/rpmbuild/BUILD/cppcheck-2.4/lib/symboldatabase.cpp:1443:32: error: ‘numeric_limits’ is not a member of ‘std’
1443 | if (id == std::numeric_limits<nonneg int>::max()) {
| ^~~~~~~~~~~~~~
/home/tkloczko/rpmbuild/BUILD/cppcheck-2.4/lib/symboldatabase.cpp:1443:54: error: expected primary-expression before ‘int’
1443 | if (id == std::numeric_limits<nonneg int>::max()) {
| ^~~
/home/tkloczko/rpmbuild/BUILD/cppcheck-2.4/lib/symboldatabase.cpp:1443:47: error: expected ‘)’ before ‘int’
1443 | if (id == std::numeric_limits<nonneg int>::max()) {
| ~ ^ ~~~
| )
This patch adds missing `include #include <limits>`
Co-authored-by: Your Name <you@example.com>
2021-03-22 18:43:08 +01:00
Daniel Marjamäki
42437277dc
Update Copyright year
2021-03-21 20:58:32 +01:00
PKEuS
141d2ac215
Refactorization: Improved internal implementation of severity and certainty levels
...
Backported from LCppC.
2021-02-24 22:00:06 +01:00
Daniel Marjamäki
627a5e75cc
Token::stringify; refactor in/out parameter to return value
2021-02-21 17:21:33 +01:00
PKEuS
aa2f143ea6
Fixed false positive: Parameter can be declared with const in constructors did handle noexcept
...
Merged from LCppC.
2021-02-19 08:21:26 +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
Daniel Marjamäki
68537e4fc3
Fixed #9867 (No dump file is generated (clang))
2021-02-06 19:06:05 +01:00
IOBYTE
5810171336
fix daca crashes in Type::findDependency() ( #3101 )
2021-01-31 10:07:03 +01:00
IOBYTE
7700cff0e9
fix daca crash in openfst fst_test.cc ( #3095 )
2021-01-30 06:33:09 +01:00
Daniel Marjamäki
1151c3dafd
Fixed msvc compilation error by implementing Variable::operator=
2021-01-28 13:46:15 +01:00
IOBYTE
6914f375e1
fix #10135 ("debug: Executable scope 'what' with unknown function." with custom std::exception) ( #3089 )
2021-01-28 12:38:36 +01:00
Daniel Marjamäki
203d6ebe5a
Fixed #10100 (FP: shadowVariable clangimport)
2021-01-27 20:03:42 +01:00
IOBYTE
4e1ff86bb2
use nonneg int for varid and exprid ( #3085 )
2021-01-27 19:49:13 +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
952857195b
fix out of line member functions using global namespace ( #3063 )
2021-01-19 18:52:47 +01:00
IOBYTE
fde5994cc3
fix #10061 (debug: Executable scope 'x' with unknown function.) ( #3062 )
2021-01-18 19:01:04 +01:00
Oliver Stöneberg
9f9a652ae1
refs issue #9089 : avoid usage of expensive std::stringstream ( #2996 )
2021-01-16 19:03:28 +01:00
Oliver Stöneberg
7aa85aa408
Use std::unordered_* containers for faster lookups ( #3052 )
2021-01-16 13:52:09 +01:00
Rikard Falkeborn
bedf3118ef
library: Refactor to use enum class ( #3026 )
2021-01-08 10:29:01 +01:00
IOBYTE
c085151eb0
fix exprengine.cpp:2833:18: debug: Executable scope 'executeAllFunctions' with unknown function. ( #3019 )
2021-01-06 17:29:23 +01:00
Daniel Marjamäki
3a86262244
SymbolDatabase: Do not set definedType for global scope etc
2021-01-06 08:53:45 +01:00
IOBYTE
22b10f8987
fix token.cpp:745:19: debug: Executable scope 'getStrSize' with unknown function. ( #3015 )
2021-01-05 22:07:53 +01:00
Paul Fultz II
a95c931da0
Fix issue 8501: false negative: (style) Opposite expression on both sides of ( #3012 )
2021-01-05 12:07:27 +01:00
IOBYTE
23da5c9815
fix #9885 (SymbolDatabase: function lookup fails calling variadic method) ( #3002 )
...
Co-authored-by: Robert Reif <reif@FX6840>
2021-01-03 11:17:32 +01:00
Oliver Stöneberg
fbf5858f76
fixed and enabled several clang-tidy warnings ( #2816 )
2021-01-02 19:10:25 +01:00
Daniel Marjamäki
e469436fe1
astyle formatting
...
[ci skip]
2020-12-31 19:24:29 +01:00
Oliver Stöneberg
20e462a8ed
split "varid0" from more generic "debug" messages ( #2997 )
2020-12-31 19:24:16 +01:00
Daniel Marjamäki
9d54303cfa
Clang import; Fixed segmentation fault
2020-12-26 19:59:57 +01:00
Ken-Patrick Lehrmann
aad723bf3a
Fix false positive AssignmentIntegerToAddress ( #2971 )
2020-12-24 19:57:02 +01:00
IOBYTE
2ecab32fbe
fix debug printing of valuetype name with namespaces ( #2968 )
2020-12-21 19:47:54 +01:00
IOBYTE
f2cf11682a
fix #10040 (symbolDatabaseWarning: debug: Executable scope 'x' with unknown function.) ( #2955 )
2020-12-18 07:46:01 +01:00
IOBYTE
6103da59be
add column number to TokenList::addtoken ( #2939 )
2020-12-08 10:34:23 +01:00
Daniel Marjamäki
cb7eee2aa9
SymbolDatabase: Improved types for 'std::string + x'
2020-12-05 13:24:21 +01:00
Daniel Marjamäki
4d497712fb
Travis; Fix Cppcheck warnings
2020-12-02 22:02:20 +01:00
Daniel Marjamäki
009ad11b3e
SymbolDatabase: set proper valuetype for string addition result ( #9161 )
2020-12-01 20:16:39 +01:00
Oliver Stöneberg
3eaa76e832
updated C/C++ keywords ( #2926 )
2020-11-29 15:01:29 +01:00
Daniel Marjamäki
62284dabca
astyle formatting
2020-11-24 22:03:30 +01:00
IOBYTE
1ea89bcad8
add support for template constructors ( #2911 )
2020-11-24 07:21:37 +01:00
Daniel Marjamäki
4a2e082d85
Revert "GUI: restore default tab in ProjectFileDialog"
...
This reverts commit 39564c9e6c
.
2020-11-23 20:18:06 +01:00
Daniel Marjamäki
39564c9e6c
GUI: restore default tab in ProjectFileDialog
2020-11-23 19:27:14 +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
bd5fc4b579
Clang import: Fixed variable type for pointers
2020-11-10 09:35:41 +01:00
Daniel Marjamäki
7e8f405c6d
Refactoring
2020-11-09 21:14:46 +01:00
Daniel Marjamäki
bd5b2133ab
Clang import: Variable::isReference() should return true for r-value references also
2020-11-09 21:00:48 +01:00
Daniel Marjamäki
5cfe2e319c
Clang import: Fix Variable::isRValueReference
2020-11-09 20:44:46 +01:00
Daniel Marjamäki
8b52ed590e
Clang import: Better handling of const methods
2020-11-09 14:50:34 +01:00
Daniel Marjamäki
1c2e480449
Proper fix for test-clang-import.py failure
2020-11-07 18:12:47 +01:00
Daniel Marjamäki
ae1b9cb14e
SymbolDatabase: Improved function matching in C code
2020-11-04 07:17:17 +01:00
Daniel Marjamäki
198bbc8a5a
Clang import: Better type handling
2020-11-03 21:37:28 +01:00
Daniel Marjamäki
8956ecb5fc
Clang import: Fixed data for inline static functions
2020-11-03 17:52:53 +01:00
Daniel Marjamäki
e053066d8b
Clang import: Fixed Variable::mTypeStartToken and Variable::mTypeEndToken for unnamed parameters
2020-11-02 20:58:43 +01:00
Daniel Marjamäki
a2a948a311
Clang Import; Better handling of derived classes
2020-11-01 20:32:42 +01:00
Daniel Marjamäki
70fc2a78e5
Fix Cppcheck warning
2020-11-01 18:04:13 +01:00
Daniel Marjamäki
9dc085c3ec
Clang import: Improved handling of overloaded operators
2020-11-01 15:30:51 +01:00
Daniel Marjamäki
597a6eb99c
Clang import: Fix Variable::mTypeStartToken for const argument
2020-10-31 17:43:36 +01:00
vilarion
bc5ec38149
Fix #9806 (False positive: template function can be static) ( #2868 )
...
* Include detecting variadic template functions by matching against endTok instead of startTok.
* Add argument count check for variadic (template) member functions.
2020-10-31 10:02:15 +01:00
shaneasd
a623168942
fix passedByValueError on enums ( #2869 )
2020-10-30 18:32:35 +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
Rikard Falkeborn
2624d791e6
Symboldatabase: Don't set unknown enum values ( #2852 )
...
Previously, if an enum value was set to a value unknown to cppcheck, the
next enum value would erroneously be set to the last set value plus one
(or zero, if no enum value had been set before). This partially fixes
Trac ticket #9647 , in the sense that it no longer sets wrong values for
these enum values. Further improvements to this would be to set the
correct values instead. It also fixes the false positive mentioned in the
comments in the ticket.
2020-10-18 20:41:36 +02:00
Rikard Falkeborn
33739d23aa
Fix #9941 : Return value type of library functions returning unsigned ( #2848 )
...
Fix return value types of library functions returning unsigned.
Previously, the valueType of auto x = f() would be signed even if f()
was specified to return an unsigned type.
This fixes #9941 , which is a regression in cppcheck 2.2 compared to 2.1.
The regression was introduced in 32df807b22
.
2020-10-16 07:56:31 +02:00
Daniel Marjamäki
64608f4e95
clang import; fix symbol database for 'struct Fred { int a; }; int b; void f(int c, int d) { int e; }'
2020-10-06 19:06:10 +02:00
Daniel Marjamäki
67cc1776d5
Clang import: fixed return type
2020-10-04 20:02:19 +02:00
Daniel Marjamäki
6de91d6386
Fixed #9707 (False positive: unreadVariable, union)
2020-10-02 20:22:22 +02:00
Daniel Marjamäki
1251d35ba4
Fix SymbolDatabase for 'extern const char ( * x [ 256 ] ) ;'
2020-10-02 08:25:43 +02:00
Daniel Marjamäki
514b7f4da4
Fixed #9906 (False positive: constParameter (function pointer))
2020-09-23 22:10:47 +02:00
Daniel Marjamäki
bca3605f77
astyle formatting
2020-09-21 19:48:04 +02:00
Oliver Stöneberg
7189b303ae
fixed some modernize-loop-convert clang-tidy warnings ( #2815 )
2020-09-21 19:30:47 +02:00
Paul
b26c581556
Fix issue 9888: False positive: Using reference to dangling temporary with std::move
2020-09-10 22:38:31 -05:00
Daniel Marjamäki
687b44dbb7
Token: add flag for splitted variable declaration with initialization
2020-09-09 16:22:47 +02:00
Paul
382408f59e
Fix issue 9496: False negative: Dereferencing returned smart null-pointer
2020-09-08 21:54:38 -05:00
Daniel Marjamäki
7969bf7ae8
Token: Add 'isSplittedVarDecl attribute
2020-09-06 11:02:22 +02:00
shaneasd
9712c136bd
make result of <<|>> an xvalue ( #2775 )
2020-09-05 12:07:06 +02:00
Daniel Marjamäki
5acd6fcdc8
astyle formatting
2020-09-03 18:55:40 +02:00
shaneasd
08ea6435ac
fix false positives in constParameter ( #2758 )
2020-09-03 18:44:44 +02:00
Daniel Marjamäki
3fe46239cf
SymbolDatabase; Refactoring, use Tokenizer::isFunctionHead to skip function attributes
2020-09-03 11:21:12 +02:00
Dan
974b6fb8e5
Add test cases for assign operators with default implementation ( #2767 )
2020-09-03 07:29:54 +02:00
Paul Fultz II
32df807b22
Fix issue 9783: wrong lifetime analysis temporary assigned to object ( #2711 )
2020-09-02 07:13:15 +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
Rikard Falkeborn
d5345052ab
Fix #9793 (false positive, memleak with lambda)
...
Skip scopes with lambdas (similar to how checkleakautovar does). In
order to fix this when the lambda is inside a for loop, make
hasInlineOrLambdaFunction() recursive. This should be what all existing
users want.
2020-07-07 21:51:36 +02:00
Paul
a412e3e1f1
Mark syntax error functions as noreturn
2020-06-29 15:33:25 -05:00
Daniel Marjamäki
f5ace9ffbe
SymbolDatabase; Improved ValueType when container methods items
2020-06-26 22:47:28 +02:00
Daniel Marjamäki
3f1f62e078
Fixed #9746 (SymbolDatabase: Wrong valueType for return)
2020-06-10 21:13:53 +02:00
Paul Fultz II
eb4754b7d9
Fix issue 9587: False positive: parameter can be declared with const ( #2667 )
2020-05-31 10:10:10 +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
dc0b68d505
handle clang type 'x < y::z >' better
2020-05-26 17:37:33 +02:00
Oliver Stöneberg
37bc0483a4
made check.h less heavy ( #2633 )
2020-05-23 07:16:49 +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
Philipp Kloke
32923b7ac5
Refactorization: Fixed a couple of compiler warnings about reusing variable names
2020-05-19 08:35:12 +02:00
Daniel Marjamäki
76f4fae806
Bug hunting; Started to activate some itc tests for uninitialized variables
2020-05-15 20:58:33 +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
5eeeba97eb
SymbolDatabase: Better handling of function pointer function argument
2020-05-02 17:04:54 +02:00
Daniel Marjamäki
f7096a2232
Bug hunting: basic handling of contracts through GUI
2020-04-27 09:08:50 +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
219180b00a
Fixed #9038 (Auto type with explicit pointer symbol detected as integer)
2020-04-19 20:08:47 +02:00
Daniel Marjamäki
e8bbfdbfee
Fixed #9559 (Multiple checks to std::atomic are not redundant)
2020-04-19 17:29:40 +02:00
Daniel Marjamäki
adb3588b24
Clang import; Set Variable::typeStartToken and Variable::typeEndToken
2020-04-13 10:45:31 +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
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
f01783238e
Fixed #9596 (False positive: Returning an integer in a function with a pointer return type auto handling)
2020-04-04 20:03:48 +02:00
orbitcowboy
637c4e2bc0
wxwidgets.cfg: Added support for more interfaces.
2020-03-15 19:39:23 +01:00
Dmitry-Me
ab5835d359
Avoid giant C4267 warning in 64-bit Visual C++ build ( #2569 )
2020-03-14 14:41:45 +01:00
Daniel Marjamäki
f093d23a36
SymbolDatabase: Fixed addArguments
2020-03-09 15:13:50 +01:00
Rikard Falkeborn
f6e7fb4bd9
Bugfix valuetype for some integer constants ( #2545 )
2020-02-19 07:51:39 +01:00
Daniel Marjamäki
95ac456e13
Fixed #9582 (false positive "error: Out of bounds access" with std::array and constant)
2020-02-19 07:36:02 +01:00
Daniel Marjamäki
244e291605
Fixed #9640 (clang import: reference parameter)
2020-02-17 18:56:25 +01:00
Paul Fultz II
921887a281
Use valueFlowGeneric for valueFlowForwardExpression ( #2537 )
2020-02-16 16:02:22 +01:00
Daniel Marjamäki
e31b2f8b73
SymbolDatabase; Set smart pointer type in Variable valueType
2020-02-14 09:40:27 +01:00
Paul Fultz II
7368a54629
Add generic valueflow forward analysis ( #2511 )
2020-02-13 16:27:06 +01:00
Rikard Falkeborn
b1c6f2946a
Fix redundant FP assignment with unsigned zero ( #2521 )
...
* Refactor isNullOperand out of FwdAnalysis
* Improve isNullOperand
* Fix redundantAssignment FP with unsigned zero
* isNullValue check number
* Enhance isNullOperand to handle c++ casts
Also handle cast of NULL.
2020-02-09 11:16:08 +01:00
Daniel Marjamäki
18124fe248
Fixed #9591 (SymbolDatabase: decltype)
2020-01-29 17:29:40 +01:00
Daniel Marjamäki
b1abcc06df
Clang import; distinguish static variable
2020-01-27 13:00:52 +01:00
Daniel Marjamäki
830f901206
Fixed #9586 (Valuetype: Wrong type for 'true << 1')
2020-01-27 11:46:59 +01:00
Daniel Marjamäki
625da9af5c
SymbolDatabase: Use range for loop
2020-01-26 07:31:04 +01:00
Daniel Marjamäki
569523bbef
Clang import; Better handling of enums
2020-01-25 09:31:47 +01:00
Daniel Marjamäki
36a67c7022
Clang import; fixed ValueType::typeSize calls
2020-01-18 17:32:59 +01:00
Daniel Marjamäki
cefd7fb33f
Fix testrunner
2020-01-18 12:29:03 +01:00
Daniel Marjamäki
269d21e972
Clang import; Better array handling in sizeof()
2020-01-18 11:55:50 +01:00
Daniel Marjamäki
e78438e990
astyle formatting
...
[ci skip]
2020-01-12 10:32:47 +01:00
Daniel Marjamäki
668212ac2f
SymbolDatabase: Type lookup for clang type strings
2020-01-11 21:24:15 +01:00
Daniel Marjamäki
380cc78077
Clang; Run ValueFlow
2020-01-11 14:00:41 +01:00
Daniel Marjamäki
6b983a9587
Revert ValueFlow changes, there was unexpected problems in testrunner
2020-01-11 13:11:19 +01:00
Daniel Marjamäki
052eaba632
Clang; run ValueFlow analysis
2020-01-11 13:04:51 +01:00
Daniel Marjamäki
54a9b61329
Clang import; NamespaceDecl, varDecl4, varDecl5
2020-01-08 18:23:40 +01:00
Daniel Marjamäki
b829c4cebb
Clang import; Arrays
2020-01-07 12:19:06 +01:00
Daniel Marjamäki
8ea22edb4e
Clang Import; VarDecl
2020-01-06 13:47:19 +01:00
Ken-Patrick Lehrmann
b6d2c1b238
Fix github CI ( #2477 )
...
* Fix github CI
```
Checking lib/check.cpp: __CPPCHECK__=1...
lib/symboldatabase.h:719:5: warning: Class 'Function' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
Function(const Token *tokenDef);
^
Checking lib/templatesimplifier.cpp: __CPPCHECK__=1...
lib/symboldatabase.cpp:1754:33: warning: Condition 'settings' is always true [knownConditionTrueFalse]
const Library * const lib = settings ? &settings->library : nullptr;
^
lib/symboldatabase.cpp:1751:9: note: Assuming that condition '!settings' is not redundant
if (!settings)
^
lib/symboldatabase.cpp:1754:33: note: Condition 'settings' is always true
const Library * const lib = settings ? &settings->library : nullptr;
```
* Compile parseClangAstDump
2020-01-05 21:10:48 +01:00
Daniel Marjamäki
fa727185e5
Clang import; IfStmt
2020-01-05 19:18:32 +01:00
Daniel Marjamäki
b03bdfaf72
Import Clang ast dump (experimental)
2020-01-05 15:12:53 +01:00
Paul Fultz II
e07801a891
Fix issue 9563: new daca crash: findLambdaEndToken not finding end token ( #2472 )
2020-01-04 10:45:24 +01:00
Dmitry-Me
895910b769
Fixed #7159 (wrong handling of function parameters)
2019-12-31 18:26:12 +03:00
IOBYTE
ec4c979cd8
fix daca error: Internal Error: Invalid syntax ( #2452 )
...
* fix daca error: Internal Error: Invalid syntax
* fix cppcheck warnings
2019-12-18 11:48:36 +01:00
Paul Fultz II
9cb39b1d7e
Fix issue 9482: False positive: Reference to temporary returned using trailing return type ( #2413 )
2019-12-01 15:10:02 +01:00
Paul Fultz II
2bdb7dc236
Fix issue 9390: valueFlowTerminatingCondition bailout: Skipping function due to incomplete variable NULL ( #2412 )
...
* Fix issue 9390: valueFlowTerminatingCondition bailout: Skipping function due to incomplete variable NULL
* Uncomment keyword
* Add nullptr as well
2019-12-01 15:09:21 +01:00
Sebastian
c990d10ffa
Check for JSON error when parsing addon .json files + fixes ( #2374 )
...
* cppcheck.cpp: Check for JSON error when parsing addon .json files
This fixes that errors in JSON files given via `--addon=*.json` are
silently ignored and maybe only a part of the JSON file is used.
Now the error message which picojson can return is checked and a
corresponding error message is returned again by getAddonInfo().
* naming.json: Fix missing comma
* CLI: Fix naming violations detected by addon naming.py via naming.json
* Addon naming: Add argument for validating names of constants
* LIB: Rename functions/variables so they are valid, loosen naming rules
* GUI: Fix naming violations
2019-11-20 15:37:09 +01:00
Daniel Marjamäki
f5e3dc9a38
Improved fix for #8978 (False positive: Variable assigned value that is never used when assigning via iterator)
2019-11-17 12:08:21 +01:00
Paul Fultz II
c75bbbe253
Fix issue 9404: False positive: Either the condition 'if(x)' is redundant or there is possible null pointer dereference: a->x ( #2322 )
...
* Fix issue 9404: False positive: Either the condition 'if(x)' is redundant or there is possible null pointer dereference: a->x
* Use simpleMatch
* Add a test case for the FP
* Check if expression is changed
* Check for no return scope
* Use simpleMatch
2019-11-08 08:11:41 +01:00
Daniel Marjamäki
c7a23f126f
Fixed #9373 (False Positive - missingOverride)
2019-11-03 18:42:04 +01:00
Daniel Marjamäki
6d1c84e3a6
Fixed #9449 (SymbolDatabase: Function lookup fails when string literal is converted to bool)
2019-10-30 21:05:42 +01:00
IOBYTE
6b4a3bc830
fix #9431 (Invalid syntax error on valid C++ code) ( #2298 )
2019-10-26 17:39:46 +02:00
Georgy Komarov
72f07c8a33
Add MISRA checks for rules 21.1 and 21.12 ( #2284 )
...
* Add MISRA 21.1 check
This also required add static field for functions in symboldatabase.
* Add MISRA R21.12
* Use newer ASSERT macroses in tests
2019-10-26 08:32:46 +02:00
Daniel Marjamäki
dedee2b173
SymbolDatabase: Better ValueType handling for containers
2019-10-23 19:54:59 +02:00
Daniel Marjamäki
87f65230ae
SymbolDatabase: Better valuetype handling of container addition
2019-10-23 12:42:46 +02:00
Daniel Marjamäki
f131a99ae3
SymbolDatabase: Improved ValueType in range for loop
2019-10-23 11:52:29 +02:00
Daniel Marjamäki
c5c07b61a6
SymbolDatabase: Fix type for expression 'x = uint8_t(a[b])'
2019-10-22 20:40:36 +02:00
Daniel Marjamäki
223ceeb97f
SymbolDatabase: Do not set constructor flag for function in namespace
2019-10-20 18:12:52 +02:00
Daniel Marjamäki
82d8f3e7f5
SymbolDatabase: Fix crash if std::shared_ptr type is only forwarded, not defined
2019-10-20 17:00:15 +02:00
Rikard Falkeborn
5c061c1c12
Set correct type and size of string and char literals ( #2275 )
...
* Set correct type and size of string and char literals
Use that string and char literal tokens store the prefix. This makes
it possible to distinghuish between different type of string literals
(i.e., utf8 encoded strings, utf16, wide strings, etc) which have
different type.
When the tokens holding the string and character values have the correct
type, it is possible to improve Token::getStrSize() to give the correct
result for all string types. Previously, it would return the number of
characters in the string, i.e., it would give the wrong size unless
the type of the string was char*.
Since strings now can have different size (in number of bytes) and
length (in number of elements), add a new helper function that returns
the number of characters. Checkers have been updated to use the correct
functions.
Having the size makes it possible to find more problems with prefixed
strings, and to reduce false positives, for example in the buffer
overflow checker.
Also, improve the stringLiteralWrite error message to also print the
prefix of the string (if there is one).
* Add comment and update string length
2019-10-20 07:11:57 +02:00
IOBYTE
5658dfcaf3
better fix for #9392 that also handles namespaces ( #2282 )
2019-10-18 18:05:48 +02:00
Daniel Marjamäki
7d6d561c84
SymbolDatabase: Better handling of function call using smart pointer
2019-10-15 19:33:25 +02:00
Daniel Marjamäki
4a4b4963cc
SymbolDatabase: Fix function lookup for '::func()'
2019-10-15 12:39:02 +02:00
Daniel Marjamäki
bf61bcf402
ValueType: Set ValueType for constructor calls
2019-10-14 09:19:16 +02:00
Paul Fultz II
19cf636a4a
Move necessary code into valuetype ( #2265 )
...
* Fix parsing of smart pointers
* Improve deduction of return type
* Valuetype computation for decayed pointers
2019-10-12 11:40:02 +02:00
IOBYTE
f99e83ece0
Fix #9411 (new daca crash related to using namespace) ( #2264 )
2019-10-12 11:39:14 +02:00
IOBYTE
fe1f601b91
Fix #9389 ("debug: Executable scope 'x' with unknown function." with … ( #2261 )
...
* Fix #9389 ("debug: Executable scope 'x' with unknown function." with "using namespace")
* use static rather than anonymous namespace for new functions
2019-10-10 20:25:09 +02:00
orbitcowboy
a9386fa093
Running astyle [ci skip]
2019-10-10 08:17:41 +02:00
Daniel Marjamäki
0c1e979af7
SymbolDatabase: Refactor handling of variable declarations in if condition
2019-10-09 22:27:48 +02:00
Daniel Marjamäki
9f4db5018d
SymbolDatabase: Added testcase for variable in if-scope
2019-10-09 16:41:07 +02:00
Daniel Marjamäki
3776604f06
SymbolDatabase: Add variable in if condition 'if (auto x = bar())'
2019-10-09 15:55:54 +02:00
Daniel Marjamäki
1abf70a7cb
SymbolDatabase: Add null pointer check for ast operand for '(' token
2019-10-08 17:53:29 +02:00
Daniel Marjamäki
9f40341ba8
SymbolDatabase: Hardcoded handling for std::make_shared and std::make_unique , todo: library configuration would be better than hard coding
2019-10-08 17:19:24 +02:00
Daniel Marjamäki
79356b1883
SymbolDatabase: Better ValueType handling of 'LibraryType(..)'
2019-10-08 11:25:05 +02:00
Paul Fultz II
4eb4762d95
Extend lifetime checking to temporaries ( #2242 )
...
* Use lifetimes to check for returning reference to temporaries
* Check for dangling temporaries
* Check for unknown types for returining by reference
* Remove old returnTemporary check
* Format
* Check for deref op
* Ternary operator return an lvalue reference
* Warn when returning temporaries from member functions
* Improve handling of pointer to function
* Extend lifetimes of const references
2019-10-08 09:28:39 +02:00
Daniel Marjamäki
3c085fd88a
Fixed #9359 (SymbolDatabase: function lookup fails when -funsigned-char is used)
2019-10-06 12:05:58 +02:00
IOBYTE
8f46bb3ef6
fix #9392 (SymbolDatabase: Weird default constructor outside class) ( #2243 )
2019-10-06 07:21:12 +02:00
Daniel Marjamäki
7294145797
SymbolDatabase: set value type for std::move()
2019-10-05 19:57:52 +02:00
Daniel Marjamäki
cf965b72b5
SymbolDatabase: look for functions in anonymous namespaces in the findFunction
2019-10-01 19:09:34 +02:00
Paul Fultz II
166bd2bafc
Fix issue 2153: valueFlowAfterCondition: struct member ( #2228 )
...
* Fix issue 2153: valueFlowAfterCondition: struct member
* Fix null pointer dereference
* Formatting
* Check for another null pointer
* Initialize variables
* Remove redundant condition
* Format
* Add missing initialization to copy constructor
* Format
2019-09-30 21:04:43 +02:00
Daniel Marjamäki
69a54b0ee9
Library: added 'stdtype' attribute in <podtype> element so we can configure standard types better
2019-09-29 16:48:25 +02:00