miltolstoy
5d299016f1
feat: analyze function side effects ( #2901 )
2020-11-26 17:34:42 +01:00
Daniel Marjamäki
1e8eb28390
Clang import: Fix null pointer dereference
2020-11-26 17:26:30 +01:00
Daniel Marjamäki
62284dabca
astyle formatting
2020-11-24 22:03:30 +01:00
Daniel Marjamäki
96392aa212
Clang import: better handling of templates
2020-11-24 22:02:59 +01:00
Daniel Marjamäki
aa9281515d
Clang import: Handle LinkageSpecDecl
2020-11-24 19:34:37 +01:00
Daniel Marjamäki
788abfa8a4
Clang import: better handling of CXXMethodDecl in getSpelling
2020-11-24 19:20:30 +01:00
IOBYTE
43ce1607c7
fix a large number of valgrind warnings in testrunner ( #2920 )
...
Co-authored-by: Robert Reif <reif@FX6840>
2020-11-24 18:21:07 +01:00
IOBYTE
1ea89bcad8
add support for template constructors ( #2911 )
2020-11-24 07:21:37 +01:00
Daniel Marjamäki
b4db52bf61
Fixed #9860 (wrong ast for placement new 'new ( uBAR ? uBAR : sizeof ( T ) ) T')
2020-11-23 22:03:50 +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
208a4a4548
Check unused templates by default
2020-11-23 18:29:08 +01:00
Daniel Marjamäki
2cd8ea83a7
Fixed #9860 (unused template not removed properly by default)
2020-11-22 16:43:36 +01:00
Paul Fultz II
4a8a78a925
Fix issue 10002: False positive: constParameter with reference to pointer ( #2918 )
2020-11-22 08:47:24 +01:00
Paul Fultz II
bf00d521d7
Show which rules are being processed ( #2916 )
2020-11-22 08:46:50 +01:00
Oliver Stöneberg
b7c573bc9b
removed the *_sanitized targets used by fuzz-client from CMake - if you need this to be sanitized use CMAKE_CXX_FLAGS / fixed linking of fuzz-client ( #2914 )
2020-11-21 07:44:22 +01:00
Paul Fultz II
f6399c4cba
Fix issue 9980: FP nullPointerRedundantCheck - condition after while loop ( #2912 )
2020-11-20 09:36:09 +01:00
Daniel Marjamäki
5e69def679
Code cleanup; Remove unused functions
2020-11-18 20:27:51 +01:00
Daniel Marjamäki
3c207da910
Code cleanup. Fix gcc warning.
2020-11-18 15:43:09 +01:00
Paul Fultz II
e8c1c792a5
Fix issue 9987: false positive: danglingTempReference with && variable and assignment ( #2907 )
2020-11-17 06:52:12 +01:00
IOBYTE
c4b3d4cd77
fix #9983 (TemplateSimplifier: template not simplified : f(0,0);) ( #2905 )
...
Currently template type deduction for functions only works for single
template argument single function argument functions with a literal
argument.
This patch starts to add support for single template argument multiple
function argument functions. It correctly handles functions with
multiple arguments of the same type. It also handles a mix of template
and non-template arguments.
It does not add support for overloading non-template arguments.
It does not add support for multiple parameter template functions.
It does not add support for type deduction from variable arguments.
Co-authored-by: Robert Reif <reif@FX6840>
2020-11-17 06:51:32 +01:00
Daniel Marjamäki
22d6160624
Improve handling of decltype
2020-11-16 20:11:26 +01:00
Daniel Marjamäki
ad4185428e
Run dmake again
2020-11-16 09:14:31 +01:00
Daniel Marjamäki
c7cbe7f2d3
rename externals/tinyxml to externals/tinyxml2
2020-11-16 09:11:53 +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
7878eb2512
AST: Do not generate AST for decltype
2020-11-15 16:47:36 +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
6236beeb3f
Fixed #9950 (Wrong severity for redundantAssignInSwitch)
2020-11-15 13:09:28 +01:00
Ken-Patrick Lehrmann
7c3afa0b36
9955: Fix ast when throwing a cast ( #2900 )
...
```
throw (std::string)"Error: " + strerror(errnum);
```
would result in a broken ast:
```
throw
`-::
|-std
`-string
```
instead of
```
throw
`-+ 'signed char *'
|-( 'container(std :: string|wstring|u16string|u32string)'
| `-"Error: " 'const char *'
`-( 'signed char *'
|-strerror
`-errnum 'signed int'
```
2020-11-15 10:37:29 +01:00
Daniel Marjamäki
ef5d5e84c5
Fixed #8936 (Add PicoJSON Copyright notice)
2020-11-14 21:31:50 +01:00
Daniel Marjamäki
b7f812739c
astyle formatting
2020-11-13 15:52:57 +01:00
Falital
2e2d4a0055
Added Hash to plist file names ( #2898 )
2020-11-13 15:52:24 +01:00
Rikard Falkeborn
324e267559
getSizeOf: Handle long double ( #2888 )
2020-11-11 22:51:17 +01:00
Daniel Marjamäki
4330a43acb
Fixed #9933 (FP: uninitvar when reading to struct)
2020-11-11 22:47:23 +01:00
Daniel Marjamäki
c95b0d2a51
Fixed #9977 (Template simplifier does not simplify in header)
2020-11-11 09:50:51 +01:00
Daniel Marjamäki
7182da5c8e
astyle formatting
2020-11-11 09:17:54 +01:00
Rikard Falkeborn
829c543331
TestCondition: Don't warn when sizeof is involved ( #2896 )
2020-11-11 08:01:11 +01:00
IOBYTE
e785885b4d
fix #9975 (Template method not simplified) ( #2894 )
2020-11-10 21:19:04 +01:00
fwingerter-Ocient
d7473cab8c
Handle static_assert if standard is at least C++11 ( #2842 )
...
Previously it was being handled only if the standard was *exactly* C++11.
2020-11-10 18:22:08 +01:00
Paul Fultz II
bd7e915c20
Add generic reverse valueflow ( #2878 )
2020-11-10 16:00:55 +01:00
Ken-Patrick Lehrmann
79bdd64689
Fix false positive memoryleak ( #2882 )
...
```
int *f() {
int *p = static_cast<int *>(realloc(nullptr, 10));
if (!!(!p)) {
return nullptr;
}
return p;
}
```
would give
```
memleak2.cpp:4:5: error: Memory leak: p [memleak]
return nullptr;
^
```
Because of the additional `!!̀ .
2020-11-10 15:59:51 +01:00
Paul Fultz II
ae6f611df0
Fix issue 9973: False positive: mismatching iterator container, reference ( #2893 )
2020-11-10 09:38:05 +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
970beaa79a
Clang import: Fix Variable::isReference
2020-11-09 20:35:00 +01:00
Daniel Marjamäki
0ac4de2a5e
Small refactoring
2020-11-09 19:30:05 +01:00
Daniel Marjamäki
8b52ed590e
Clang import: Better handling of const methods
2020-11-09 14:50:34 +01:00
Daniel Marjamäki
06909df8f5
Clang import: better handling of ArrayToPointerDecay implicit casts
2020-11-08 19:53:28 +01:00
Daniel Marjamäki
1c742b7995
Clang import: Handle AccessSpecDecl
2020-11-08 17:02:19 +01:00
Daniel Marjamäki
818e1574ad
Fix Cppcheck self check warning
2020-11-08 10:57:48 +01:00
Daniel Marjamäki
1078855029
Clang import: Full name for methods
2020-11-08 10:31:48 +01:00
Daniel Marjamäki
87323b33bd
Clang import: Fixed problems when handling CXXConstructorDecl
2020-11-08 01:17:34 +01:00
Daniel Marjamäki
565e67d373
Clang import: Ignore VisibilityAttr
2020-11-07 22:27:11 +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
ff17d3e7c6
Clang import: Better handling of scope types
2020-11-07 15:02:36 +01:00
Daniel Marjamäki
88a35d2253
Fix CodeQL warning, Multiplication result converted to larger type
2020-11-06 19:50:05 +01:00
Daniel Marjamäki
52b88bcee3
Fix CodeQL warning, Multiplication result converted to larger type
2020-11-06 19:44:32 +01:00
Georgy Komarov
80dee36e68
library: Add new warning: ignoredReturnErrorCode ( #2877 )
...
* library: Add optional "type" attribute to "use-retval"
Added an optional "type" attribute to "use-retval" nodes in the
configuration. When the return type of a function configured with
`<use-retval type="error-code"\>` node does not used, the new style
error "ignoredReturnErrorCode" will be generated.
* Fix and improve patch after the initial review
* Fixed severity level and [[nodiscard]] attribute
* Fix incorrect condition
* Remove redundant condition
2020-11-05 13:35:52 +01:00
Jesse Boswell
f70e8de315
Fix #9567 (Inline suppression of unusedFunction errors not working when using compile database) ( #2870 )
2020-11-04 21:01:48 +01:00
uhziel
aad29ddb9a
fix an error in Tokenizer::simplifyTypedef() ( #2880 )
2020-11-04 13:32:31 +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
Oliver Stöneberg
488813d00f
added validateCFG and checkcfg targets to CMake / some refactorings ( #2687 )
2020-11-02 20:16:15 +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
vilarion
2c34e660b3
Fix #9805 (False positive; Unused function (template)) ( #2871 )
...
* Add test
* Ignore templates with trailing return type as well
2020-11-01 15:10:02 +01:00
Rikard Falkeborn
bd4dc364a7
mathlib: Refactor to use enum class ( #2872 )
2020-11-01 11:47:34 +01:00
Daniel Marjamäki
26e6eed189
Revert "AST: Adjust AST for variable declaration 'char var[] = str;'"
...
This reverts commit 376860f796
.
2020-11-01 11:41:41 +01:00
Daniel Marjamäki
4094274723
TestClangImport: Fix tests
2020-11-01 11:33:01 +01:00
Daniel Marjamäki
5aab1f9692
Clang import: Improved handling of structs
2020-11-01 09:12:58 +01:00
Daniel Marjamäki
226e996e46
Clang import: Improved handling of empty structs/classes
2020-11-01 08:44:38 +01:00
Daniel Marjamäki
7804b28e70
AST: Tweaked debug output
2020-10-31 18:57:48 +01:00
Daniel Marjamäki
597a6eb99c
Clang import: Fix Variable::mTypeStartToken for const argument
2020-10-31 17:43:36 +01:00
Daniel Marjamäki
376860f796
AST: Adjust AST for variable declaration 'char var[] = str;'
2020-10-31 17:05:42 +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
Daniel Marjamäki
e044d6e219
Clang import: fixed AST for 'return new S()'
2020-10-29 21:43:35 +01:00
Daniel Marjamäki
9ed4dc4199
Clang Import: Fix AST for 'new S;'
2020-10-29 20:52:09 +01:00
Rikard Falkeborn
de19dc9e3e
Fix #8327 (Memleak with mmap return value check) ( #2864 )
...
Also fix a broken test case related to checking the return value -1
where socket was not defined in the library used in the tests.
This was tested running test-my-pr with 500 packages. The difference was
six fewer FPs.
2020-10-29 13:17:33 +01:00
Daniel Marjamäki
16f4f198eb
Clang import: handle DefaultStmt
2020-10-29 09:48:35 +01:00
Daniel Marjamäki
40156365b8
Adjust cppcheck AST debug output a little bit. Write location for each AST tree
2020-10-28 21:41:21 +01:00
Daniel Marjamäki
4eb829933e
Tokenizer: Fixed unwanted unknownMacro warning for decltype
2020-10-27 09:08:13 +01:00
Daniel Marjamäki
34c8334882
Fixed #9737 (False positive: unreadVariable)
2020-10-25 20:32:45 +01:00
Daniel Marjamäki
05514950af
astyle formatting
...
[ci skip]
2020-10-25 07:12:30 +01:00
miltolstoy
d55874ec37
checkunusedvar: handle initialization list ( #2836 )
2020-10-25 07:11:45 +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
Paul Fultz II
64638d82bb
Fix issue 9945: FP: containerOutOfBounds ( #2845 )
2020-10-22 07:41:52 +02:00
Daniel Marjamäki
33844b28ab
Another fix for the crash
2020-10-22 06:59:13 +02:00
Daniel Marjamäki
bcc7c5cd50
Use astIsPointer to avoid crashes
2020-10-22 06:55:48 +02:00
Ken-Patrick Lehrmann
e4a54a24db
Fix regression in CheckCondition ( #2854 )
...
Introduced by e2a81a382f
.
2020-10-20 07:56:41 +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
Armin Müller
08cef9e815
Typos found by running "codespell" ( #2846 )
2020-10-15 19:24:13 +02:00
Daniel Marjamäki
f1ce5a9101
Fixed #9929 (False positive: suspicious semicolon after macro)
2020-10-09 20:34:20 +02:00
Paul Fultz II
047c3ed6ba
Fix issue 9935: FP: knownConditionTrueFalse value flow doesn't account for virtual functions ( #2839 )
2020-10-09 17:21:27 +02:00
Daniel Marjamäki
586ddf74f1
Clang import; fixed ast for function call with multiple arguments
2020-10-09 07:54:16 +02:00
Daniel Marjamäki
65721dd7a9
Bug hunting; Better handling of constant
2020-10-08 17:24:35 +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
Paul Fultz II
372161c89b
Fix issue 9939: False positive: Reference to temporary returned (static variable) ( #2840 )
2020-10-06 09:16:54 +02:00
Daniel Marjamäki
67cc1776d5
Clang import: fixed return type
2020-10-04 20:02:19 +02:00
Daniel Marjamäki
e3ab688597
Clang import: Fix syntax tree for 'case 1'
2020-10-04 19:33:28 +02:00
Daniel Marjamäki
c3517924d0
Clang import testing: Compare AST
2020-10-04 11:27:31 +02:00
Daniel Marjamäki
b052843655
exprengine: Use and tweak ExprEngine::ArrayValue::MAXSIZE
2020-10-04 11:21:13 +02:00
Daniel Marjamäki
0e32e19184
daca: update WRONG_DATA interface
2020-10-03 15:36:02 +02:00
Daniel Marjamäki
2e20ee9e39
set version 2.2.99
2020-10-03 13:54:17 +02:00
Daniel Marjamäki
17e562a87f
astyle formatting
...
[ci skip]
2020-10-03 11:02:11 +02:00
Paul
828a5e2326
Fix issue 9930: valueFlowLifetime hang
2020-10-03 11:01:53 +02:00
Daniel Marjamäki
c373be0b16
2.2: Update versions
2020-10-03 10:47:35 +02:00
Daniel Marjamäki
8d20d8afb5
Update Copyright year
2020-10-03 09:15:56 +02:00
Daniel Marjamäki
6de91d6386
Fixed #9707 (False positive: unreadVariable, union)
2020-10-02 20:22:22 +02:00
Daniel Marjamäki
63e08689c1
Fix Cppcheck warning
2020-10-02 19:35:24 +02:00
Daniel Marjamäki
ea3a9d658a
Suppressions: Add special case for backwards compatibility. suppression comment after a {.
2020-10-02 18:56:26 +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
a39e5835d4
Fixed #9925 (False positive: Redundant pointer operation in macro)
2020-09-29 18:27:07 +02:00
Daniel Marjamäki
67b1698752
daca: suppress variableScope warnings in C code as that is usually suppressed in real world. It should make the daca output more relevant.
2020-09-29 17:20:19 +02:00
Daniel Marjamäki
bf3833dad5
Avoid constStatement false positives for 'foo() || x=5'. Found in daca@home.
2020-09-29 13:35:39 +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
31c800e19e
Fixed false positive: suspicious operator ',' seen in daca@home
2020-09-29 11:32:48 +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
d901edd4af
Avoid clarifyCalculation warning for 'x % 16 ? 1 : 0' expression. Fixes FP seen in daca@home. It seems likely that the order is understood otherwise the ternary calculation could easily be simplified away.
2020-09-29 08:39:21 +02:00
Daniel Marjamäki
e32ccb591b
Fixed clarifyCalculation fp for 'a % b ? "a" : "b"'. seen in daca@home.
2020-09-29 08:29:23 +02:00
IOBYTE
4e4108dc8b
fix daca insighttoolkit crash in template simplifier ( #2826 )
...
Don't count deleted instantiations in the recursive count.
I can't reduce the daca code because creduce requires a preprocessed
file to reduce and the problem doesn't show up when the file is
preprocessed with cppcheck.
There is no test because I couldn't reduce the problem files.
Co-authored-by: Robert Reif <reif@FX6840>
2020-09-28 22:51:13 +02:00
Daniel Marjamäki
bf236e91d7
Fixed #9918 (False positive: autoVariable pointer is NULLed later)
2020-09-28 22:48:57 +02:00
Daniel Marjamäki
8395522390
Fixed #9919 (False positive: clarifyCalculation for code: flags & ZRL_EOL_NUL ? '\0' : '\n')
2020-09-28 19:18:34 +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
Daniel Marjamäki
84b8f32fd4
daca: group warnings for prohibited functions
2020-09-27 21:42:07 +02:00
Daniel Marjamäki
2748201d73
Fixed #9782 (Segmentation fault due to broken AST)
2020-09-27 20:41:09 +02:00
Daniel Marjamäki
ba84303501
Fixed #9680 (false positive: style: Variable 'x' is assigned a value that is never used with smart pointers)
2020-09-27 19:15:15 +02:00
Daniel Marjamäki
3b39433e21
Fixed Cppcheck warnings
2020-09-26 22:30:59 +02:00
Daniel Marjamäki
7bb82c5df7
Fixed #9901 (False positive: variable is assigned value that is not used 'if (--N == 0)')
2020-09-26 22:13:05 +02:00
Daniel Marjamäki
0ec77879ea
Fix crash in createAST when checking wiggle in daca@home
2020-09-26 19:22:24 +02:00
Daniel Marjamäki
5578b09452
More fixing for #9914 . New warning id and warning message when variable expression is explicitly hidden.
2020-09-26 13:49:47 +02:00
Daniel Marjamäki
05b0a0f970
Make duplicateAssignExpression warnings inconclusive for 'x&&false' etc. ( #9914 )
2020-09-26 10:50:58 +02:00
Paul Fultz II
887b40e08b
Fix issue 9916: False positive: duplicateAssignExpression when it's checked if variables have initial value later ( #2825 )
2020-09-26 10:31:40 +02:00
Daniel Marjamäki
5856fef83b
Fixed #9914 (False positive: knownArgument for 'x && false')
2020-09-25 20:27:16 +02:00
Daniel Marjamäki
bbd3a992b8
Fix output when note contains
2020-09-25 19:04:22 +02:00
Daniel Marjamäki
485153c930
Limit variableScope check. Do not check C code if all local variables are declared at function level.
2020-09-25 08:34:47 +02:00
Daniel Marjamäki
093ff58f5f
Fix crash in cbmc detected with daca@home
2020-09-24 20:48:26 +02:00
Daniel Marjamäki
801cc8d331
Fixed knownArgument false positive for pointer
2020-09-24 19:48:20 +02:00
Daniel Marjamäki
c08e1a9a94
Fix knownArgument false positive when sizeof is used
2020-09-24 19:43:39 +02:00
Daniel Marjamäki
514b7f4da4
Fixed #9906 (False positive: constParameter (function pointer))
2020-09-23 22:10:47 +02:00
Paul Fultz II
d9eacaecbb
Fix issue 9842: ValueFlow: wrong handling of ?, seems to think that the whole expression is a condition ( #2821 )
2020-09-23 07:45:03 +02:00
Oliver Stöneberg
2e24cc1434
checkother.h: added missing newline in classInfo - fixes tests ( #2818 )
2020-09-21 21:44:46 +02:00
Daniel Marjamäki
107ee57e7a
Fixed #9909 (False positive: knownArgument for calculation 'self->maxsize * sizeof(intptr_t)')
2020-09-21 20:02:55 +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 Fultz II
7b6d3f8061
Fix issue 9907: False positive: knownEmptyContainer after function call with :: ( #2814 )
2020-09-20 22:37:28 +02:00
Daniel Marjamäki
730b95331e
Fixed #9905 (False positive: known argument 'header.length()')
2020-09-20 20:17:10 +02:00
Daniel Marjamäki
c563944fdd
astyle formatting
2020-09-20 20:14:30 +02:00
Paul Fultz II
857722f859
Fix issue 9711: FP knownConditionTrueFalse for variable modified via pointer ( #2813 )
2020-09-20 14:27:09 +02:00
Paul Fultz II
c2e8051196
Fix issue 9904: False positive: duplicateCondition when modifying variable in lambda ( #2811 )
2020-09-18 07:44:26 +02:00
Paul Fultz II
e5d0ffdbe7
Fix issue 9900: False positive: Returning lambda that captures local variable 'x' that will be invalid when returning. ( #2809 )
2020-09-17 08:33:52 +02:00
Paul Fultz II
782684a7cc
Fix issue 9530: False positive: Reference to temporary returned when using initializer lists ( #2796 )
2020-09-17 08:33:16 +02:00
Paul Fultz II
11c99d7387
Fix issue 9880: False positive: danglingLifetime ( #2810 )
2020-09-17 07:23:38 +02:00
Paul Fultz II
ebbff08932
Fix issue 9899: False positive: Non-local variable will use object that points to local variable ( #2808 )
2020-09-15 07:11:52 +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
shaneasd
53a0760fdf
Improve ast generation for templated function parameters ( #2803 )
2020-09-14 18:44:50 +02:00
Paul Fultz II
a42976d656
Fix issue 9898: false positive: knownConditionTrueFalse ( #2806 )
2020-09-14 18:43:11 +02:00
Daniel Marjamäki
4dd85cfbe0
Merge pull request #2802 from rikardfalkeborn/9228-fix-fn-with-realloc-and-null-assignment
...
Improve memleakOnRealloc with assignment to NULL
2020-09-14 11:04:29 +02:00
Paul Fultz II
94850fec3f
Fix issue 9897: False positive: nullPointerRedundantCheck ( #2805 )
2020-09-14 09:17:29 +02:00
Paul Fultz II
bb7164171c
Fix issue 9894: ValueFlow: wrong known value below while with assignment ( #2804 )
...
* Fix issue 9894: ValueFlow: wrong known value below while with assignment
2020-09-14 08:03:25 +02:00
Rikard Falkeborn
791051ced0
Fix #9228 (FN common realloc mistake with assignment of NULL)
...
Do not match for assignments with NULL.
2020-09-13 21:49:49 +02:00
Rikard Falkeborn
da8ad9ce19
memleakOnRealloc: Don't warn if pointer is NULL in condition
2020-09-12 18:48:23 +02:00
Paul
be900873cc
FIx issue 9895: ValueFlow: Wrong known value below function call with reference parameter
2020-09-11 16:03:57 -05:00
Daniel Marjamäki
e03a8e1dc1
Fixed #9892 (Crash: endless recursion in Token::typeDecl for expression 'auto combo = widget->combo = new Combo{};')
2020-09-11 21:29:48 +02:00
Daniel Marjamäki
600538a325
Merge pull request #2793 from Ken-Patrick/mixedoperators
...
Fix false positives with condition with || and &&
2020-09-11 10:11:31 +02:00
Daniel Marjamäki
d46b9cec5f
Merge pull request #2795 from pfultz2/fp-lifetime-temp-function-obj
...
Fix issue 9889: False positive: Using reference to dangling temporary with function object
2020-09-11 09:05:43 +02:00
Daniel Marjamäki
92d65a1824
astyle formatting
2020-09-11 08:51:12 +02:00
Daniel Marjamäki
7e02789d3f
Merge pull request #2794 from pfultz2/lifetime-temp-ref-move
...
Fix issue 9888: False positive: Using reference to dangling temporary with std::move
2020-09-11 07:20:32 +02:00
Daniel Marjamäki
ac66f67bad
Merge pull request #2790 from pfultz2/forward-analyze-accumulate-actions
...
Fix issue 9833: False positive: Division by zero when using pointer to struct
2020-09-11 07:17:10 +02:00
Paul
c568e8ea78
Format
2020-09-10 22:59:19 -05:00
Paul
71bc79ac28
Fix issue 9889: False positive: Using reference to dangling temporary with function object
2020-09-10 22:58:17 -05:00
Paul
b26c581556
Fix issue 9888: False positive: Using reference to dangling temporary with std::move
2020-09-10 22:38:31 -05:00
Paul
6394ad2643
Format
2020-09-10 17:07:13 -05:00
Paul
4d1b3e06c7
Fix FPs
2020-09-10 17:06:49 -05:00
Ken-Patrick Lehrmann
a114bf0293
Fix false positives with condition with || and &&
...
The value of something in the middle of a condition with mixed || and &&
gives no information on which branch will be taken.
For instance with:
```
int f(int a, int b, bool x) {\n"
if (a == 1 && (!(b == 2 && x))) {
} else {
if (x) {
}
}
return 0;
}
```
We can enter the if part whether x is true or false, and similarly,
enter the else part whether x is true or false. Same thing with the
value of b.
This fixes the following false positive with above code:
```
:4:13: style: Condition 'x' is always true [knownConditionTrueFalse]
if (x) {
^
:2:33: note: Assuming that condition 'x' is not redundant
if (a == 6 && (!(b == 21 && x))) {
^
```
2020-09-10 23:27:39 +02:00
Daniel Marjamäki
2b12ef653d
Merge pull request #2792 from IOBYTE/main
...
fix #9886 (Hang in TemplateSimplifier (gcc/gcc/testsuite/g++.dg/cpp0x…
2020-09-10 21:47:44 +02:00
Daniel Marjamäki
51f5f2c7d0
Fix inline suppressions problem
2020-09-10 21:46:15 +02:00
Robert Reif
a52ce7379a
fix #9886 (Hang in TemplateSimplifier (gcc/gcc/testsuite/g++.dg/cpp0x/decltype34.C))
2020-09-10 14:47:59 -04:00
Daniel Marjamäki
f052d32e31
astyle formatting
2020-09-10 08:02:45 +02:00
Daniel Marjamäki
d60520137c
ExprEngine: Refactoring
2020-09-10 08:02:15 +02:00
Paul
5033fb4418
Fix issue 9869: False positive: knownEmptyContainer when passed to constructor
2020-09-09 22:23:42 -05:00
Paul
bb9dbaa8f5
Format
2020-09-09 21:32:07 -05:00
Paul
75b955b9c6
Fix issue 9833: False positive: Division by zero when using pointer to struct
2020-09-09 21:29:26 -05:00
Paul Fultz II
34d65e25d6
Merge branch 'main' into lifetime-subfunction
2020-09-09 12:02:02 -05:00
Daniel Marjamäki
7c8c0ef3a2
Bug hunting: Avoid uninit struct member false positives
2020-09-09 18:26:04 +02:00
Daniel Marjamäki
f95a53b0ca
Fixed #9821 (False positive: Delegating constructor and initialization list)
2020-09-09 18:04:21 +02:00
Daniel Marjamäki
687b44dbb7
Token: add flag for splitted variable declaration with initialization
2020-09-09 16:22:47 +02:00
Paul Fultz II
bfe53fce04
Fix issue 9878: false positive: multiCondition ( #2787 )
2020-09-09 15:39:36 +02:00
Daniel Marjamäki
b1401c6536
Merge pull request #2789 from pfultz2/smart-ptr-constructor
...
Fix issue 9496: False negative: Dereferencing returned smart null-pointer
2020-09-09 08:16:30 +02:00
Daniel Marjamäki
1c37423f1b
Merge pull request #2788 from pfultz2/lifetime-dangling-temp-reference
...
Fix issue 9835: False negative: Return reference to temporary with const reference
2020-09-09 08:01:22 +02:00
Paul
965fea370f
Formatting
2020-09-08 21:55:53 -05:00
Paul
382408f59e
Fix issue 9496: False negative: Dereferencing returned smart null-pointer
2020-09-08 21:54:38 -05:00
Paul
8d7088aa24
Fix issue 9835: False negative: Return reference to temporary with const reference
2020-09-08 18:30:45 -05:00
Daniel Marjamäki
5376decbe7
Merge pull request #2783 from pfultz2/out-of-bounds-at-index
2020-09-08 20:30:31 +02:00
Paul
8c425790f4
Merge branch 'main' into lifetime-subfunction
2020-09-08 13:18:01 -05:00
Daniel Marjamäki
18e99176e5
Fix issue 9883: endless recursion in getLifetimeTokens ( #2786 )
2020-09-08 20:14:54 +02:00
Paul Fultz II
5099ca3c8b
Fix issue 9882: segfault in ForwardTraversal ( #2785 )
2020-09-08 20:14:10 +02:00
Paul
1753c2ddee
Remove known conditions
2020-09-08 12:39:27 -05:00
Paul
d5489fd1f0
Fix issue 9883: endless recursion in getLifetimeTokens
2020-09-08 11:33:29 -05:00
Paul
1be67ea008
Merge
2020-09-08 11:00:57 -05: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
07f6876dc8
Bug hunting; avoid uninit var fp for struct variables
2020-09-07 21:19:07 +02:00
Daniel Marjamäki
cfd41fea83
Fixed #9879 (Tokenizer: Better handling of operator() '(*this)(...)')
2020-09-07 20:07:21 +02:00
IOBYTE
2106e30304
fix template namespace bug ( #2780 )
...
Co-authored-by: Robert Reif <reif@FX6840>
2020-09-07 17:45:19 +02:00
Daniel Marjamäki
acfff072ae
Bug hunting; avoid bughuntingUninitVar fp for template variable
2020-09-07 16:25:37 +02:00
Daniel Marjamäki
0c6dc84cbb
astyle formatting
...
[ci skip]
2020-09-07 10:56:02 +02:00
Paul Fultz II
ac67049661
Fix issue 9858: Token::astOperand1() cyclic dependency on valid C++ code ( #2784 )
2020-09-07 10:54:32 +02:00
Paul Fultz II
362ab44c40
Fix issue 9646: False negative: Return reference to temporary with const reference ( #2782 )
2020-09-07 10:52:54 +02:00
Daniel Marjamäki
06c4b8897b
Bug hunting: Avoid uninitialized fp for smart pointer
2020-09-07 09:34:08 +02:00
Paul Fultz II
a4f43fc2ad
Fix issue 8234: false negative: (warning) Opposite inner 'if' condition leads to a dead code block. ( #2781 )
2020-09-07 07:53:41 +02:00
Paul
7754449fd6
Format
2020-09-06 23:48:05 -05:00
Paul
04c85baf03
Fix issue 8869: false negative: (error) Invalid v.at() argument nr 1
2020-09-06 23:46:31 -05:00
Paul
786672e19d
Format
2020-09-06 21:59:21 -05:00
Paul
c7a5d3c5f1
Fix FPs
2020-09-06 21:58:36 -05:00
Daniel Marjamäki
136ac2c643
Fixed #9266 (handle operator() better)
2020-09-06 21:02:06 +02:00
Daniel Marjamäki
54b5e77548
TestImportProject: Use raw strings
2020-09-06 16:00:19 +02:00
Dan
7efd84ecaf
Fix false skipping of folder-seperator ( #2749 )
2020-09-06 15:35:14 +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
c7aed8bd0e
astyle formatting
2020-09-06 07:47:17 +02:00
Oliver Stöneberg
fb37137216
extended the --clang command-line option so you can specify a custom … ( #2734 )
2020-09-06 07:46:51 +02:00
Daniel Marjamäki
b0b31feadd
fix ubsan errors
2020-09-05 21:09:11 +02:00
shaneasd
9712c136bd
make result of <<|>> an xvalue ( #2775 )
2020-09-05 12:07:06 +02:00
Daniel Marjamäki
7d51baa2f0
Fixed GCC warning, variable bodyTok is unused. False negative ticket: #9876
2020-09-05 08:17:40 +02:00
Daniel Marjamäki
a102574e3f
astyle formatting
2020-09-05 08:00:51 +02:00
Paul Fultz II
cc2bc74084
Track lifetime for lambdas with explicit capture ( #2776 )
2020-09-05 07:56:01 +02:00
Daniel Marjamäki
8027f40418
Fixed #8506 (CPPCheck printing invalid characters in output)
2020-09-04 20:43:54 +02:00
Daniel Marjamäki
1daf1ec108
Fixed #9875 (Crash)
2020-09-04 19:15:48 +02:00
Paul
264c0cae8b
Formatting
2020-09-04 11:59:30 -05:00
Paul
bb37b07def
Extend lifetimes to subfunctions
2020-09-04 11:56:34 -05:00
Daniel Marjamäki
30d3643bb8
Fixed #9851 (FP virtualDestructor - private virtual dtor)
2020-09-04 18:56:12 +02:00
Daniel Marjamäki
7d01ad5b50
add test-clang-import that compares symboldatabases
2020-09-04 15:29:19 +02:00
IOBYTE
2db0d2878b
fix daca crash in TemplateSimplifier::getNewName ( #2772 )
...
Don't add the same template instantiation multiple times.
Co-authored-by: Robert Reif <reif@FX6840>
2020-09-04 07:08:28 +02:00
shaneasd
84dd0c961f
False positive dynamic_cast auto variable which has been checked against null ( #2769 )
2020-09-04 07:06:26 +02:00
Daniel Marjamäki
5cd92a0eb1
test/cli/test-clang-import: Improved testing
2020-09-03 19:49:02 +02:00
Daniel Marjamäki
efa113db55
Refactoring; do not use pointless lambda
2020-09-03 18:58:25 +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
090eba7e7f
FIx issue 6140: ValueFlow: valueFlowForward, loop ( #2770 )
2020-09-03 07:17:36 +02:00
Daniel Marjamäki
638dcd0aca
Fixed #9820 (Crash when --clang used with .c file)
2020-09-02 20:29:23 +02:00
Paul Fultz II
03cefd5d70
Fix issue 9853: False positive: returnReference when using a pointer to container ( #2765 )
2020-09-02 20:01:08 +02:00
Daniel Marjamäki
12d51ae5c4
Fixed #9809 (Tokenizer; Fix handling of variable declaration with @)
2020-09-02 13:04:33 +02:00
Daniel Marjamäki
c1e03d63b2
astyle formatting
...
[ci skip]
2020-09-02 13:03:30 +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
Paul Fultz II
dea5a23c34
Improve check: check for known empty containers passed to algorithms ( #2768 )
2020-09-02 07:11:23 +02:00
Daniel Marjamäki
8e79b0c8bc
astyle formatting
...
[ci skip]
2020-09-01 20:00:04 +02:00
Daniel Marjamäki
1f8896e51c
clang import: try to handle CXXFunctionalCastExpr
2020-09-01 19:59:41 +02:00
Paul Fultz II
ba84196dca
Fix issue 9865: false positive: knownConditionTrueFalse ( #2764 )
2020-09-01 11:22:38 +02:00
Paul Fultz II
0a718694af
Fix issue 9852: False positive: danglingTemporaryLifetime when returning a vector of vectors ( #2766 )
2020-09-01 11:21:29 +02:00
Paul Fultz II
3e99bff764
Same expression when comparing with zero ( #2762 )
2020-08-31 08:48:48 +02:00
Paul Fultz II
1c5f496350
Fix issue 8373: false negative: invalid iterator ( #2761 )
2020-08-31 08:46:56 +02:00
Daniel Marjamäki
d23fd26ce0
Cppcheck: Try to fix addon problems when paths have spaces
2020-08-30 18:15:48 +02:00
Daniel Marjamäki
18c29544eb
astyle formatting
2020-08-28 19:29:33 +02:00
Paul Fultz II
6ab3c93fb1
Fix issue 9756: false negative: invalid iterator from std::find_if ( #2760 )
2020-08-28 19:29:09 +02:00
Paul Fultz II
82bdbcd73b
Fix issue 9859: false positive: knownConditionTrueFalse ( #2759 )
2020-08-28 19:26:09 +02:00
Paul Fultz II
494fff65b7
Add outOfBounds check for iterators to containers ( #2752 )
2020-08-26 21:05:17 +02:00
IOBYTE
8774e97f26
fix #9771 (Syntax error; operator != <> ()) ( #2757 )
2020-08-26 18:39:33 +02:00
Daniel Marjamäki
bb5cad42cd
astyle formatting
...
[ci skip]
2020-08-26 10:15:09 +02:00
Paul Fultz II
9ec27c112f
Fix issue 9855: false positive: uninitvar ( #2754 )
2020-08-26 07:02:15 +02:00
IOBYTE
7cf3909275
fix #9854 (Syntax error on valid C++ code) ( #2756 )
2020-08-26 07:00:58 +02:00
Paul Fultz II
46bf2d7d52
Dont diagnose impossible values for iterators ( #2755 )
2020-08-26 06:58:53 +02:00
shaneasd
45fc6a0eeb
Test for syntax error in nested templates ( #2746 )
2020-08-25 07:14:44 +02:00
Paul Fultz II
ec89c57a90
Fix issue 9849: false positive: containerOutOfBounds ( #2753 )
2020-08-25 07:12:41 +02:00
Daniel Marjamäki
6277eece67
Variable contracts
2020-08-24 20:57:49 +02:00
Paul Fultz II
02287d9d34
Fix issue 7324: valueFlowForward : decrement ( #2737 )
2020-08-24 13:10:36 +02:00
Georgy Komarov
c5369b84e1
Prevent copying in range-based for loops ( #2751 )
...
Use reference types in range for loops to prevent copying.
2020-08-23 20:53:44 +02:00
Daniel Marjamäki
2bb73840fc
astyle formatting
2020-08-23 17:17:33 +02:00
Paul Fultz II
ac846b96d1
New check: Iterating a known empty container ( #2740 )
2020-08-22 09:16:26 +02:00
Paul Fultz II
becdf20310
Fix crash in isSameExpression ( #2748 )
2020-08-22 07:05:21 +02:00
Kamil Dudka
33fb0e782e
enable moduloofone reports only with --enable=style ( #2747 )
...
... because it is reported with Severity::style
2020-08-21 20:43:03 +02:00
Daniel Marjamäki
e0e70c2531
Fixed compiler warnings
2020-08-21 17:23:55 +02:00
eivindt
27e40af06c
Add support for comments at end of suppression in suppression files ( #2736 )
2020-08-20 21:49:07 +02:00
Paul Fultz II
a332062385
Add exprId to tokens ( #2744 )
2020-08-20 18:21:29 +02:00
Daniel Marjamäki
6446790d48
Merge pull request #2739 from dan-42/fix_ticket_9839_ast_error
...
Fix ticket 9839: AST broken; range for loop that uses decltype
2020-08-18 21:59:50 +02:00
Paul
7776fb82a2
Fix issue 737: new check: Dereference end iterator
2020-08-17 16:36:45 -05:00
Daniel Friedrich
f413c9cad8
Improve handling of decltype( in for loops
...
Simplify pattern macht and token selection
Improve handling of decltype( in for loops
2020-08-17 20:52:14 +02:00
Paul
e759508335
Remove reduntant condition
2020-08-13 10:10:26 -05:00
Paul
a509de4d70
Add moves
2020-08-11 11:50:27 -05:00
Paul
96b74c57ff
Remove useless condition
2020-08-11 11:26:40 -05:00
Paul
8c7e91c985
Remove old container forward
2020-08-10 22:09:33 -05:00
Paul
71c228a01a
Check for containers that modify the size using square bracket
2020-08-10 22:07:22 -05:00
Paul
a5b0a1c9e2
Evaluate container size in program memory
2020-08-10 20:08:49 -05:00
Paul
fec2914700
Add tests for container changes
2020-08-09 22:52:03 -05:00
Paul
26693df788
Use forward analyzer for container forward
2020-08-08 00:10:03 -05:00
Daniel Marjamäki
b263b93f73
Merge pull request #2732 from pfultz2/invalid-container-subobj
...
Fix issue 9780: FP: invalidContainer calling push_back after getting the address of the vector
2020-08-07 09:52:25 +02:00
Paul
56affc9080
Fix issue 9780: FP: invalidContainer calling push_back after getting the address of the vector
2020-08-06 21:08:30 -05:00
Daniel Marjamäki
5372e93964
Fixed #9825 (redundantAssignment: Do not warn about volatile data)
2020-08-06 22:18:25 +02:00
Paul
0cc1f69862
Fix issue 9770: FP returnDanglingLifetime for class method taking const char* and returning std::string
2020-08-05 23:17:35 -05:00
Daniel Marjamäki
72fa5f2e27
Fixed #9752 (ValueFlow: Uninit after assignment with '&')
2020-08-05 22:57:06 +02:00
Daniel Marjamäki
d5b64d9c3a
Clarify inconclusive uninitMemberVar warning in copy constructors, it's in general a good idea to copy all the data.
2020-08-05 13:57:40 +02:00
Daniel Marjamäki
7a85b8e452
Do not ask that calculation is clarified when different order would be invalid
2020-08-05 13:20:18 +02:00
Jens Yllman
10ac0bcf54
changed variable name to match guidelines
2020-07-29 12:13:21 +02:00
Jens Yllman
62f5f248be
use simplifyPath() to make sure file name is same as in the checks
2020-07-28 22:19:27 +02:00
Daniel Marjamäki
fa32624c93
ValueFlow: Avoid UB in shift when rhs is negative
2020-07-25 14:13:21 +02:00
Daniel Marjamäki
fab3a8efc8
Merge pull request #2721 from KenPatrickLehrmann/compound_assign_bitshift
...
Add missing operators <<= and >>=
2020-07-25 09:39:32 +02:00
Daniel Marjamäki
b4552dedb0
Fix Cppcheck warning
2020-07-24 19:58:36 +02:00
Daniel Marjamäki
6a839ad511
Fixed #9814 (False positive: functionConst, trailing return type)
2020-07-24 19:40:42 +02:00
Paul
46e008c3e2
Fixed #9816 (False positive: Condition '!b' is always false in nested do-while loop)
2020-07-24 08:13:14 +02:00
Daniel Marjamäki
a11a0e79e4
Fixed Cppcheck internal warning
2020-07-23 18:54:40 +02:00
Ken-Patrick LEHRMANN
a923115710
Add missing operators <<= and >>=
...
This fixes issues (at least false positives) in code using them.
For instance:
```
unsigned compute(unsigned long long a) {
unsigned num = 0;
while (a > 0xFFFFFFFF) {
a >>= 32;
num += 32;
}
if (a > 0xFFFF) {
a >>= 16;
num += 16;
}
if (a > 0xFF) {
num += 8;
}
return num;
}
```
would give false positive:
```
cppcheck --enable=style sl3.cpp
Checking sl3.cpp ...
sl3.cpp:11:11: style: Condition 'a>0xFF' is always false [knownConditionTrueFalse]
if (a > 0xFF) {
^
sl3.cpp:3:14: note: Assuming that condition 'a>0xFFFFFFFF' is not redundant
while (a > 0xFFFFFFFF) {
^
sl3.cpp:11:11: note: Condition 'a>0xFF' is always false
if (a > 0xFF) {
^
```
2020-07-23 14:36:34 +02:00
Daniel Marjamäki
682a6d1c02
Fixed #9017 (Simple classes without side effects not reported as unused)
2020-07-23 11:10:08 +02:00
Daniel Marjamäki
25ad22c6af
astyle formatting
...
[ci skip]
2020-07-23 10:09:06 +02:00
Daniel Marjamäki
df99d8aa0a
Merge pull request #2719 from pfultz2/fp-unreachable-alias
...
Fix issue 9807: False positive: ValueFlow in unreachable code, || lhs is true
2020-07-23 09:52:54 +02:00
Daniel Marjamäki
f4a6f8ad07
Merge pull request #2720 from pfultz2/crash-type-scope
...
Fix crash when typeScope is missing
2020-07-23 09:31:59 +02:00
Daniel Marjamäki
2fd44fa464
Merge pull request #2710 from pfultz2/fp-invalid-container-pointer
...
Fix issue 9796: False positive: lifetime, pointer item is not deallocated by pop_back
2020-07-22 09:24:54 +02:00
Paul
0def5d7a9a
Reduce variable scope
2020-07-21 19:09:58 -05:00
Paul
3480aba35b
Fix crash when typeScope is missing
2020-07-21 14:09:46 -05:00
Paul
abeea7b32b
Merge branch 'main' into fp-invalid-container-pointer
2020-07-21 13:31:13 -05:00
Paul
dbb410cdae
Merge branch 'main' into condition-in-expr
2020-07-21 13:28:59 -05:00
Paul
5bc5c96c8f
Fix cppcheck error
2020-07-21 13:20:39 -05:00
Paul
38e1b57bc9
Use refs
2020-07-21 13:18:45 -05:00
Daniel Marjamäki
aad455e1ea
Fix compile error
2020-07-21 17:43:12 +02:00
Daniel Marjamäki
453cd93fae
update warning hash calculation
2020-07-21 16:00:09 +02:00
Daniel Marjamäki
83be203d44
Merge pull request #2715 from rikardfalkeborn/refactor-use-visitastnodes-more
...
Refactor use visitastnodes more
2020-07-21 15:26:58 +02:00
Daniel Marjamäki
26c849b732
Merge pull request #2716 from rikardfalkeborn/refactor-use-simple-loop-instead-of-stack-in-checktype
...
Refactor: Simplify checkSignConversion
2020-07-21 15:26:03 +02:00
Daniel Marjamäki
4ab04db53c
Rename 'cppcheckID' to 'hash'
2020-07-21 11:27:03 +02:00
Rikard Falkeborn
7973fd843c
Refactor: Simplify checkSignConversion
...
The loop only checks astoperand1 and astoperand2. Simplify the condition
to loop over these instead of using a stack. Also, add a testcase for
when astoperand2 is negative.
2020-07-20 11:16:56 +02:00
Rikard Falkeborn
ed36856451
Refactor: Use visitAstNodes in checkuninitvar
2020-07-20 11:03:52 +02:00
Rikard Falkeborn
9ced26a7a1
Refactor: Use visitAstNodes in checkcondition
2020-07-20 11:03:29 +02:00
Rikard Falkeborn
82fe6193fa
Refactor: Use visitAstNodes in checkstring
2020-07-20 10:25:00 +02:00
Rikard Falkeborn
2ace2b006a
Refactor: Use visitAstNodes in checkleakautovar
2020-07-20 10:25:00 +02:00
Paul
e2a81a382f
Track reading aliases during valueflow forward
2020-07-19 23:25:35 -05:00
Daniel Marjamäki
4a76dbb632
Bug hunting; Avoid bailout uninit FP, stream object
2020-07-19 16:54:44 +02:00
Daniel Marjamäki
fe0081496c
Bug hunting; Avoid bailout uninit FP, arrays
2020-07-19 16:27:56 +02:00
Daniel Marjamäki
7e65b561f0
AST: Fix ast for 'for ((..initexpr..);;)'
2020-07-19 11:10:38 +02:00
Daniel Marjamäki
3723c708fc
ImportProject; Do not fail loading a GUI project that has warning tags
2020-07-19 08:07:10 +02:00
Daniel Marjamäki
e9281babc4
Bug hunting; avoid false positives for structs/classes with constructors
2020-07-18 18:54:21 +02:00
Daniel Marjamäki
7cb65b7f67
GUI: Speedup code editor when selecting another warning in the same file
2020-07-18 18:14:55 +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
58638d7757
Bug hunting; Fix itc.py test
2020-07-17 13:20:31 +02:00
Daniel Marjamäki
7a4e6daecd
Fix import GUI project problem
2020-07-17 11:26:03 +02:00
Daniel Marjamäki
f2bd603bd3
Bug hunting; Fix TestBughuntingChecks
2020-07-17 11:02:46 +02:00
Daniel Marjamäki
592637af61
Bug hunting; Avoid uninit false positives with simple analysis
2020-07-17 09:05:38 +02:00
Daniel Marjamäki
9af288e1dd
Fixed #9724 (GUI: The tags do not work anymore)
2020-07-16 23:03:54 +02:00
Paul
831690f89b
Use parseDecl instead
2020-07-16 14:33:39 -05:00
Daniel Marjamäki
0632f86449
Bug hunting; avoid bailout false positives when constructor is called
2020-07-16 16:38:22 +02:00
Daniel Marjamäki
9edbec8594
astyle formatting
2020-07-16 16:36:11 +02:00
Daniel Marjamäki
118e9eb3e2
Better handling of CppcheckID suppressions
2020-07-16 15:27:23 +02:00
Daniel Marjamäki
47ff29f1c8
Merge pull request #2708 from pfultz2/multi-mutex-lock
...
Handle FPs: mutexes being locked at different scopes
2020-07-16 08:35:05 +02:00
Paul
423dcfd005
Fix issue 9796: False positive: lifetime, pointer item is not deallocated by pop_back
2020-07-15 12:22:36 -05:00
Daniel Marjamäki
6ab4f39f52
GUI: Suppress cppcheck-id
2020-07-15 13:03:07 +02:00
Daniel Marjamäki
af0db3cc21
Add cppcheck-id for warnings. To start with it's a simple id that changes when file is changed.
2020-07-14 22:30:42 +02:00
Paul
1f74400f13
Merge branch 'revert-mutex-delete' into multi-mutex-lock
2020-07-14 13:05:14 -05:00
Paul
4373404238
Revert "Fixed #9795 (False positive: Local lock is not ineffective, mutex is locked in thread also.)"
...
This reverts commit 27841d6b81
.
2020-07-14 13:04:59 -05:00
Daniel Marjamäki
a6d70b9022
Code cleanup, __temp__ files are not needed anymore
2020-07-14 16:54:00 +02:00
Daniel Marjamäki
8d6fd4769b
Bug hunting; Terminating analysis
2020-07-14 11:22:42 +02:00
Daniel Marjamäki
176826a1f5
Bug hunting; Avoid false positives
2020-07-14 11:15:26 +02:00
Daniel Marjamäki
fe324aea49
Bug hunting; Detect internal error and throw exception
2020-07-14 10:25:00 +02:00
Daniel Marjamäki
6030ab72ab
Bug hunting; Avoid some bailout false positives in uninit checker
2020-07-14 08:12:40 +02:00
Daniel Marjamäki
e0be224f4e
Merge pull request #2709 from pfultz2/fp-duplicate-cond-this
...
Fix FP of duplicateCondition when modifying the this variable
2020-07-13 21:14:58 +02:00
Daniel Marjamäki
b2f463dd65
Merge pull request #2707 from Ken-Patrick/fp_pointer_expressions
...
Fix some false positives when the same expression at different places…
2020-07-13 20:59:22 +02:00
Paul
519f2a537a
Format
2020-07-13 13:55:45 -05:00
Daniel Marjamäki
33557012a1
Merge pull request #2706 from rikardfalkeborn/condition-fn-with-sizeof
...
Fix FN with known condition and sizeof
2020-07-13 20:54:25 +02:00
Daniel Marjamäki
36b9e545ac
Bug hunting; more bailout warnings in uninit check
2020-07-13 20:23:44 +02:00
Daniel Marjamäki
8ba714373f
Merge pull request #2704 from rikardfalkeborn/9635-memleak-with-comma-operator-in-if-statement
...
Fix #9635 (FP: Memory leak with comma operator in if-statement)
2020-07-13 20:08:57 +02:00
Paul
450bdfedf3
Fix FP of duplicateCondition when modifying the this variable
2020-07-13 12:40:01 -05:00
Daniel Marjamäki
4465d033f6
Bug hunting; When passing uninitialized data to unknown function it is inconclusive if that would be a problem for the function or not
2020-07-13 11:43:11 +02:00
Paul
caabe56f14
Handle FPs: mutexes being locked at different scopes
2020-07-12 21:31:53 -05:00
Ken-Patrick Lehrmann
61ccf888b3
Fix some false positives when the same expression at different places does not have the same value
...
Typically with
```
int F(int *f);
void F2(int *a, int *b) {
int c = *a;
F(a); // modifies *a
if (b && c != *a) {}
}
```
we would get the following FP:
```
[test.cpp:3] -> [test.cpp:5]: (style) The comparison 'c != *a' is always false because 'c' and '*a' represent the same value.\n
```
I guess it boils down to isSameExpression only checking that the
expression is the same (in the above case, "*a" and "*a" are indeed the
same), but there's not real check on the values.
So the patch here is a bit hackish, and we still have false negatives in
cases with dereferenced pointers.
2020-07-11 14:13:18 +02:00
Rikard Falkeborn
d8e7e9176b
Fix FN with known condition and sizeof
...
cppcheck behaved differently if sizeof was to the left or right of the
comparison. In order to fix this, we cannot break the while loop until
all operands have been processed.
2020-07-10 23:39:16 +02:00
Daniel Marjamäki
27841d6b81
Fixed #9795 (False positive: Local lock is not ineffective, mutex is locked in thread also.)
2020-07-10 19:24:45 +02:00
Rikard Falkeborn
1e679cc5d1
Fix #9635 (FP: Memory leak with comma operator in if-statement)
...
When checking for comparisons in if-statements, if there are comma
operators in the if-statement, skip until after the last comma.
2020-07-09 21:31:43 +02:00
Daniel Marjamäki
0c6aabe444
Merge pull request #2703 from rikardfalkeborn/9652-fp-function-call-cast-config
...
Fix #9652 (fp memleak with function call with cast)
2020-07-08 15:10:41 +02:00
Rikard Falkeborn
4996ec190e
Fix #9652 (fp memleak with function call with cast)
...
When the first argument was (void *)(1), at the start of the second
iteration, arg was pointing to the "1", which caused problems for
nextArgument(), which saw the ")" as the next token and returned
nullptr, signalling that there are no more arguments.
Instead, save the first token in the argument, which makes
nextArgument() do the right thing.
2020-07-08 00:02:39 +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
Daniel Marjamäki
686a6c7862
Fixed compiler warning
2020-07-03 17:54:55 +02:00
Daniel Marjamäki
d2b2bae7bf
Fixed #7733 (False positive: scope of the variable can be reduced (variable is used in hidden code))
2020-07-01 08:24:52 +02:00
Daniel Marjamäki
f56a17bf3d
Fixed #8858 (FP: identicalConditionAfterEarlyExit when there is #if)
2020-07-01 07:48:32 +02: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
1567ccf97b
Merge pull request #2700 from pfultz2/afterConditionFunction
...
Extend scope of afterCondition until end of function
2020-06-30 08:28:08 +02:00
Paul
c76c03c711
Replace noreturn with macro
2020-06-29 15:54:51 -05:00
Paul
67e06c18a9
Use the already available function scope
2020-06-29 15:36:01 -05:00
Paul
a412e3e1f1
Mark syntax error functions as noreturn
2020-06-29 15:33:25 -05:00
Paul
600919f624
Remove redundant conditions
2020-06-29 15:13:06 -05:00
Daniel Marjamäki
f34ff9325a
Fixed testrunner
2020-06-29 21:53:14 +02:00
Daniel Marjamäki
a0770f05e1
Reuse 'extractForLoopValues' in ValueFlow
2020-06-29 21:01:43 +02:00
Paul
07d8cb4f01
Extend scope of afterCondition until end of function
2020-06-29 11:55:59 -05:00
Daniel Marjamäki
a49d277e0d
Fixed #6471 (FP functionConst - member function modifying member variable after cast (inconclusive))
2020-06-29 13:09:01 +02:00
Daniel Marjamäki
5164d87a2e
Bug hunting; Fixed false positives for containers
2020-06-28 22:49:51 +02:00
Paul
d5b6d49d96
Fix issue 9578: false negative: (style) Condition '...' is always false
2020-06-28 15:28:08 -05:00
Daniel Marjamäki
b5cd96cbda
ExprEngine; Rename variable
2020-06-28 21:36:56 +02:00
Daniel Marjamäki
ad5e4fef1f
Bug hunting; improved handling of 'malloc' in uninit checker
2020-06-28 21:20:59 +02:00
Daniel Marjamäki
6c588cc3ef
Library: Refactoring <alloc> init attribute
2020-06-28 21:01:43 +02:00
Daniel Marjamäki
0e736e0c29
Rename BugHuntingException to ExprEngineException
2020-06-28 17:39:14 +02:00
Daniel Marjamäki
d4bd3016da
ExprEngine; Improved handling of for loop, loop variable
2020-06-28 17:28:40 +02:00
Daniel Marjamäki
c42c751d61
ExprEngine; Fixed testing
2020-06-28 13:41:27 +02:00
Daniel Marjamäki
f85cdd3f77
ExprEngine: DataIndex update to get better debug output
2020-06-28 10:52:50 +02:00
Daniel Marjamäki
bcaf792e30
Bug hunting; Fix FP for struct with uninitialized members passed to function in C
2020-06-27 22:11:12 +02:00
Daniel Marjamäki
c7a8f5217f
ExprEngine; Fixed Cppcheck warning
2020-06-27 21:54:38 +02:00
Daniel Marjamäki
cd49eb0978
Fix Cppcheck warnings
2020-06-27 20:59:10 +02:00
Daniel Marjamäki
d353a4ecba
ExprEngine; copy Data => copy arrays
2020-06-27 18:09:43 +02:00
Daniel Marjamäki
e6aa96d90f
Bug hunting; Improved uninit checking
2020-06-27 14:59:02 +02:00
Daniel Marjamäki
303cadf99f
Bug hunting; Improved uninitData warning when unknown function is not configured
2020-06-27 14:29:29 +02:00
Daniel Marjamäki
e19ef6ac62
Bug hunting; Improved uninit checking for function calls with constant parameter
2020-06-27 14:15:53 +02:00
Daniel Marjamäki
d303510c78
Use value temp.maxTemplateRecursion
2020-06-27 12:57:09 +02:00
Daniel Marjamäki
ff5a717fc6
Bug hunting; Avoid false positives for const parameter data
2020-06-27 12:17:11 +02:00
Daniel Marjamäki
57187ef876
ImportProject: Read max template recursion configuration value
2020-06-27 10:34:02 +02:00
Daniel Marjamäki
b09bcdc38c
Use ValueFlow for compareBoolExpressionWithInt
2020-06-27 08:13:22 +02:00
Daniel Marjamäki
0352a5d32f
astyle formatting
...
[ci skip]
2020-06-27 07:34:48 +02:00
Daniel Marjamäki
1ad70bbeb8
Merge pull request #2697 from pfultz2/unique_lock
...
Extend mutex checking for more locking patterns
2020-06-27 07:32:26 +02:00
Daniel Marjamäki
c3749625f3
Merge pull request #2688 from jpyllman/fix_chklibfunc
...
not report locally declared functions as missing configuration of --check-library
2020-06-27 06:53:09 +02:00
Daniel Marjamäki
72bdeb9307
Merge pull request #2698 from pfultz2/const-param-casts
...
Fix issue 9778: False positive: constParameter when returning non-const reference cast
2020-06-27 06:45:30 +02:00
Paul
cf475fab51
Fix issue 9778: False positive: constParameter when returning non-const reference cast
2020-06-26 15:47:59 -05:00
Daniel Marjamäki
f5ace9ffbe
SymbolDatabase; Improved ValueType when container methods items
2020-06-26 22:47:28 +02:00
Paul
82b91869ee
Extend mutex checking for more locking patterns
2020-06-26 15:06:20 -05:00
Daniel Marjamäki
c5f9e85ee7
GUI: Add configuration for max recursion in template instantiation
2020-06-26 17:12:02 +02:00
Daniel Marjamäki
f569bc79f5
Merge pull request #2694 from pfultz2/pch
...
Add option to disable pch since its broken with ccache
2020-06-26 16:45:38 +02:00
Daniel Marjamäki
98bf0d41aa
TemplateSimplifier; Clarify information message when max recursion limit is reached
2020-06-26 12:59:40 +02:00
Daniel Marjamäki
262f44e76a
astyle formatting
...
[ci skip]
2020-06-26 12:56:56 +02:00
Daniel Marjamäki
cb8396aaf8
Merge pull request #2696 from pfultz2/getTokenArgumentFunction-ast
...
Fix issue 9710 and 9767: Use AST to get function from argument
2020-06-26 09:50:18 +02:00
Paul
1bef6ed268
Another check for null
2020-06-25 19:12:01 -05:00
Paul
263a0364cc
Avoid null pointer dereference
2020-06-25 17:23:42 -05:00
Paul
720d882b69
Remove known arg
2020-06-25 17:20:20 -05:00
Paul
60c42b17a6
Fix known conditions
2020-06-25 15:46:30 -05:00
Daniel Marjamäki
af6e76d623
Fixed #9787 (Better handling of user defined literals)
2020-06-25 22:06:34 +02:00
Paul
1676ad5f45
Fix issue 9710 and 9767: Use AST to get function from argument
2020-06-25 12:54:46 -05:00
Daniel Marjamäki
ec8fbb1580
Merge pull request #2682 from pfultz2/check-mutexes
...
Add new check for incorrect usage of mutexes and lock guards
2020-06-25 16:21:36 +02:00
Paul
18a8b5bc65
Add option to disable pch since its broken with ccache
2020-06-24 18:41:16 -05:00
Paul
3c10a9c659
Update message
2020-06-24 18:09:30 -05:00
Daniel Marjamäki
34468f3c1a
Template simplifier; Write information message when recursion limit is reached.
2020-06-24 20:30:03 +02:00
Daniel Marjamäki
693b24d30a
Fix testrunner
2020-06-22 14:31:34 +02:00
Daniel Marjamäki
ab14d2bc0f
exceptRethrowCopy: Fixed FP in Cppcheck
2020-06-22 12:26:41 +02:00
Daniel Marjamäki
9b5986505e
AST; Improved ast for variable declaration with assignment
2020-06-22 08:34:31 +02:00
Daniel Marjamäki
f792cabc2b
ExprEngine; better handling of containers
2020-06-21 21:48:36 +02:00
Daniel Marjamäki
5497e8ed67
ExprEngine; Improved handling of stream read
2020-06-21 20:05:26 +02:00
Daniel Marjamäki
11e2b5ea14
Bug hunting; Timeout
2020-06-21 18:28:07 +02:00
Daniel Marjamäki
65498b5e9a
Bug hunting; Fixed hang when there is recursion
2020-06-21 15:16:05 +02:00
Daniel Marjamäki
8ec5605bac
Merge pull request #2689 from Ken-Patrick/9769
...
9769: Improve value flow for ternary operator
2020-06-21 13:04:43 +02:00
Daniel Marjamäki
ff445f9ca2
Bug hunting; Make cve.py happy again
2020-06-21 08:50:27 +02:00
Daniel Marjamäki
f270ca1909
ExprEngine; Better handling of function calls
2020-06-20 23:00:39 +02:00
Ken-Patrick Lehrmann
5a3789a23f
9769: Improve value flow for ternary operator
...
In some cases, the condition of the ternary operator is assigned a known
value after the two possible results, and in such cases, we would not
take the opportunity to assign a value to the ternary operator (and to
the other parents in the ast).
This patch adds this capability.
2020-06-20 10:29:28 +02:00
Ken-Patrick Lehrmann
7065c5598b
Try to fix compilation with cppcheck.vcxproj
2020-06-20 09:47:35 +02:00
Daniel Marjamäki
af45148e58
ExprEngine; Refactor and improve code. Add tests for increments.
2020-06-19 20:40:20 +02:00
Daniel Marjamäki
06aeac75dc
Bug hunting; Fix false negatives
2020-06-19 18:38:02 +02:00
Daniel Marjamäki
b4443aa5a0
Suppress exceptRethrowCopy false positive
2020-06-19 18:15:04 +02:00
Daniel Marjamäki
8653c4b3a9
ExprEngine; Fix uninitialized value FP in subfunction when argument is passed by value
2020-06-19 18:05:56 +02:00
Daniel Marjamäki
6ec15b6d7b
ExprEngine; Simple handling of increment/decrement
2020-06-19 17:35:35 +02:00
Daniel Marjamäki
a5a3738df4
Fixed cve.py
2020-06-19 17:13:35 +02:00
orbitcowboy
f60e805798
Running astyle [ci skip]
2020-06-19 16:36:09 +02:00
Daniel Marjamäki
c62e345340
Fix Cppcheck warning
2020-06-19 14:11:49 +02:00
Daniel Marjamäki
f516bde744
ExprEngine; Fix TODO assertion
2020-06-19 14:05:19 +02:00
Daniel Marjamäki
d0ac583b97
Add 'bughuntingchecks'
2020-06-19 13:16:48 +02:00
Daniel Marjamäki
cbe038e694
ExprEngine: execute functions in same TU
2020-06-19 10:27:59 +02:00
Jens Yllman
08b0fa21a7
do not report locally declared functions as missing configuration for --check-library
2020-06-18 14:49:19 +02:00
Daniel Marjamäki
542158d0f4
Bug hunting; checking uninitialized struct member
2020-06-18 13:49:11 +02:00
Jens Yllman
9320ac287a
only report on functions in --library files
2020-06-18 11:42:07 +02:00
Paul
f7029e62ac
Check for mor FPs
2020-06-17 17:06:06 -05:00
Daniel Marjamäki
3f8218af1b
Removed CheckClass::operatorEq: does not 'belong'
2020-06-17 20:35:43 +02:00
Ken-Patrick Lehrmann
c297ed8204
Better handle noreturn or throwing functions in valueflow
...
Teaching cppcheck about `BOOST_THROW_EXCEPTION` and
`boost::throw_exception`, and using noreturn information from libraries
in value flow.
This fixes false positive nullPointerRedundantCheck with the following
code:
```
void throwexception(int * buf)
{
if (!buf)
boost::throw_exception(std::bad_alloc());
*buf = 0;
}
```
2020-06-17 19:06:14 +02:00
Paul
21f76d62a1
Merge branch 'main' into check-mutexes
2020-06-17 10:45:43 -05:00
Daniel Marjamäki
51a6af299f
Merge pull request #2683 from Ken-Patrick/cast_expandTemplate
...
Fix handling of c++ casts in template expansion
2020-06-17 09:21:01 +02:00
Daniel Marjamäki
94f92f00fe
Merge pull request #2684 from firewave/precompiled
...
use precompiled headers if CMake supports it
2020-06-17 07:53:51 +02:00
Daniel Marjamäki
d26593321d
Fixed Visual Studio compile error
2020-06-16 22:56:01 +02:00
Daniel Marjamäki
4947a3b7ab
Bug hunting; review and improve handling of multi dimensional arrays
2020-06-16 22:50:45 +02:00
firewave
a49d60f0b3
use precompiled headers if CMake supports it
2020-06-16 19:56:53 +02:00
Ken-Patrick Lehrmann
5c1a2db434
Fix handling of c++ casts in template expansion
...
Cast were not expanded properly: the `<` was not taken into account in
typeindentlevel, so we would then miss a `>`, resulting in syntaxError.
2020-06-16 19:36:04 +02:00
Paul
18225ee27e
Update text and change to warnings
2020-06-16 10:32:39 -05:00
Paul
7c9144ea47
Add to classInfo
2020-06-15 19:43:33 -05:00
Paul
172537807b
Add check for incorrect usage of mutexes and lock guards
2020-06-15 19:40:54 -05:00
Daniel Marjamäki
6faad9cd90
Bug hunting; better handling when assigning multidimensional array in for loop
2020-06-15 22:42:45 +02:00
Daniel Marjamäki
b36c85d8fd
Rename VerifyException to BugHuntingException
2020-06-15 22:07:32 +02:00
Daniel Marjamäki
f5fe5ca2dd
9768: Fix ast with throw in the middle of return ( #2678 )
...
* 9768: Fix ast with throw in the middle of return
```
int f(bool x)
{
return x ? 0 : throw 0;
}
```
The `throw` part was not included in the ast, leading to an invalid
ternary operator.
* 8526: Fix ast construction for ternary operator
This tries to decide a bit more properly when ':' can be part of a
ternary operator. More precisely, there are some times when we want to
delay the construction of the ast for ':', so that it is place
accordingly to the matching '?'.
Typically, this fixes an issue with
`return val < 0 ? throw 1 : val;`,
where the ast for ':' would be constructed during as part of the
`throw`, and the ast for `?` would be invalid.
This patch is a bit of a hardcode, stating that we don't expect ':'
inside a throw, unless there is a complete ternary operator in there
(there can't be a range based for loop, a case in a switch). When we
reach ':', we know we are and the end of the `throw`.
2020-06-15 10:36:02 +02:00
Daniel Marjamäki
2b0e4926bc
valueFlowAfterAssign: variable initialization
2020-06-14 21:14:05 +02:00
Ken-Patrick Lehrmann
7ddb7aef7d
8526: Fix ast construction for ternary operator
...
This tries to decide a bit more properly when ':' can be part of a
ternary operator. More precisely, there are some times when we want to
delay the construction of the ast for ':', so that it is place
accordingly to the matching '?'.
Typically, this fixes an issue with
`return val < 0 ? throw 1 : val;`,
where the ast for ':' would be constructed during as part of the
`throw`, and the ast for `?` would be invalid.
This patch is a bit of a hardcode, stating that we don't expect ':'
inside a throw, unless there is a complete ternary operator in there
(there can't be a range based for loop, a case in a switch). When we
reach ':', we know we are and the end of the `throw`.
2020-06-14 18:57:18 +02:00
Ken-Patrick Lehrmann
4023a487ff
9768: Fix ast with throw in the middle of return
...
```
int f(bool x)
{
return x ? 0 : throw 0;
}
```
The `throw` part was not included in the ast, leading to an invalid
ternary operator.
2020-06-14 14:49:10 +02:00
orbitcowboy
f69ce02c90
Running astyle [ci skip]
2020-06-14 10:06:54 +02:00
Daniel Marjamäki
97fd51edd1
Set version to 2.1.99 / 2.2 dev
2020-06-14 07:16:14 +02:00
Daniel Marjamäki
026bbac975
2.1: Set version
2020-06-13 17:04:26 +02:00
Daniel Marjamäki
37245a8179
Update copyright year
2020-06-13 16:37:12 +02:00
Paul Fultz II
06ed088bd0
Fix issue 9751: Wrong lifetime caused by std::function ( #2676 )
2020-06-13 10:26:54 +02:00
Paul Fultz II
03b41ac987
Fix issue 9718: False positive: Parameter can be declared const when written to via stream extraction operator ( #2677 )
2020-06-13 09:20:40 +02:00
Daniel Marjamäki
6600453b44
Try to make Travis happy
2020-06-13 07:45:31 +02:00
orbitcowboy
258d0a6ade
Running astyle [ci skip].
2020-06-12 16:08:40 +02:00
orbitcowboy
9f445fc735
Library: simplified code and added test cases for validating <valid>-tag expressions
2020-06-12 16:06:43 +02:00
orbitcowboy
a3d58a9302
std.cfg: Allow scientific floating point notation for '<valid>'-tags
2020-06-12 08:51:33 +02:00
Daniel Marjamäki
3f1f62e078
Fixed #9746 (SymbolDatabase: Wrong valueType for return)
2020-06-10 21:13:53 +02:00
Daniel Marjamäki
d31d778bf4
Fixed #9533 (Syntax Error: AST broken, 'for' doesn't have two operands incrementing pointer in initializer)
2020-06-09 20:57:00 +02:00
Paul Fultz II
0c659a1499
Fix incorrect logic for condition ( #2675 )
2020-06-09 08:16:53 +02:00
Daniel Marjamäki
6d796b434e
Fixed #9731 (ValueFlow: does not handle many assignments well)
2020-06-08 21:17:12 +02:00
Daniel Marjamäki
43b30d974f
astyle formatting
...
[ci skip]
2020-06-08 00:50:45 +02:00
Daniel Marjamäki
ca8b5f49f3
library: fixed handling of indirect attribute
2020-06-07 20:18:54 +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
Paul Fultz II
86ed860d26
Fix issue 9548: False negative: Mismatching iterators when inserting into a vector ( #2595 )
2020-06-06 17:54:56 +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