Commit Graph

1192 Commits

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