Commit Graph

24383 Commits

Author SHA1 Message Date
Daniel Marjamäki b798b99777 Parser; do not remove alignof and alignas in the same way 2021-04-26 11:44:08 +02:00
dummyunit b18e6f1e10
Fix varId assignment for uses of variables declared in the if condition (#3231)
Variables declared in the if condition (or in C++17 init-statement) are
visible not only in the if body but also in the else body. But logic in
Tokenizer::setVarIdPass1() handled such variables as if they were
declared in the if body.

As the result they were removed from variablesMap by the time the else
block was parsed and their uses in the else block were either given an
incorrect varId from variables in some outer scope or not given a varId
at all.

This then resulted in false positive unreadVariable errors for variables
declared in the if condition (or init-statement) and used only in the
else block.

Simplification from "else if ..." to "else { if ... }" was moved before
setVarId() to simplify detection for ends of blocks in if-else chains.
2021-04-26 07:38:03 +02:00
Daniel Marjamäki d6842007a8 Preprocessor; Set proper __cplusplus define value 2021-04-25 21:16:04 +02:00
Daniel Marjamäki 28a7bb63ec Parser; simplify (break out) init expression from if/switch/range-for 2021-04-25 14:37:27 +02:00
Oliver Stöneberg dcc90c6dfa
improved compiler warnings about missing attributes (#3232) 2021-04-25 12:52:09 +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
Oliver Stöneberg 9ad7ab4263
use latest available clang-tidy in CI (#3230) 2021-04-24 20:20:09 +02:00
Daniel Marjamäki a41d8b436e Fix testrunner 2021-04-24 14:07:26 +02:00
Daniel Marjamäki c9dc92c266 Parser; C++20 for loop with initialization expression 2021-04-24 11:47:51 +02:00
IOBYTE bd7551411a
fix #10258 (coredump due to (?) template simplification) (#3228) 2021-04-22 22:23:01 +02:00
Daniel Marjamäki 26c0945309 Handle c++20 spaceship operator 2021-04-22 19:15:22 +02:00
Daniel Marjamäki bccc0607d1 astyle formatting
[ci skip]
2021-04-22 19:08:24 +02:00
Daniel Marjamäki 4907c7e3e4 Fix compiler warning, non-static function 2021-04-22 18:40:44 +02:00
dummyunit 229832e72e
Read error locations in the correct order from XML (#3226)
When ErrorMessage::callStack elements are serialized to XML they are
saved in the reverse order. But when they read back from XML they are
added at the end of the list. Thus the round trip via XML reverses the
order of ErrorMessage::callStack.

From the user point of view it looks like the usage of the
--cppcheck-build-dir option sometimes (when the file wasn't reanalyzed,
but that is hard to spot) results in incorrect location info for some
diagnostic messages.

Moreover, when the first location matches some suppression rule and the
last doesn't match any (or vice versa), usage of --cppcheck-build-dir
results in some diagnostic messages appearing and disappearing seemingly
at random (again, depending on whether the file was reanalyzed or not).
2021-04-22 14:28: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
Daniel Marjamäki b5aaf8d577 Suppress false positive 2021-04-21 14:49:06 +02:00
Daniel Marjamäki bfb98dbf51 TemplateSimplifier: updated output of uninstantiated c++17 fold expressions 2021-04-21 13:13:11 +02:00
Daniel Marjamäki 35c934c887 Fixed self-check warning 2021-04-20 16:46:05 +02:00
Daniel Marjamäki 04e9c13bc6 TemplateSimplifier; Better handling of c++17 fold expressions and c++20 concepts.
c++17 fold expressions are simplified to a __cppcheck_uninstantiated_fold__ if they are not instantiated.

c++20 concepts are skipped/removed by Cppcheck and these will be enforced by the compiler.
2021-04-20 15:40:25 +02:00
amai2012 f371a92501
Fix CodeQL security warnings
Cure warning "Incomplete regular expression for hostnames"
2021-04-20 11:08:01 +02:00
orbitcowboy c1e53a8606 wxwidgets.cfg: Make use of 'nullpointer' in wxwidgets.cfg instead of using 'NULL', since wxWidgets library is C++11 already. 2021-04-20 09:31:06 +02:00
boussaffawalid f5ca9e7859
added missing qt macros Q_NAMESPACE_EXPORT (#3224) 2021-04-19 21:09:27 +02:00
Paul Fultz II db5f00a16a
Fix issue 10214: FP: danglingTempReference doesn't account for reference lifetime extension (#3220)
* Fix issue 10214: FP: danglingTempReference doesn't account for reference lifetime extension
2021-04-19 14:20:29 +02:00
IOBYTE 59f7b937f1
fix daca2 gdcm template simplifier crash (#3221)
This only fixes the crash. The templates that are instantiated are
correct but one template is left uninstantiated. Fixing the missing
instantiation is not easy and will be looked at later.

Co-authored-by: Robert Reif <reif@FX6840>
2021-04-19 09:17:49 +02:00
Paul Fultz II c1bb1d771b
Fix issue 10012: False positive: mismatching container, not containers (#3222)
* Fix issue 10012: False positive: mismatching container, not containers
2021-04-19 09:17:02 +02:00
Paul Fultz II 691f681d86
Fix issue 10235: Regression: oppositeInnerCondition (#3223) 2021-04-19 09:15:03 +02:00
Ken-Patrick Lehrmann 5768c3a726
Check stat return value in addFiles2 (#3214) 2021-04-18 21:52:14 +02:00
Oliver Stöneberg 5de58c4ddd
added clang-tidy to CI (#3218) 2021-04-18 21:51:47 +02:00
Paul Fultz II 563c9dd9cc
Fix issue 10208: FP: knownConditionTrueFalse in for loop with function that assigns by ref (#3198) 2021-04-18 21:42:27 +02:00
Daniel Marjamäki 56773b82c4 Simple handling of coroutines 2021-04-18 19:42:22 +02:00
Daniel Marjamäki fe87afb2f9 TestTokenizer: Align function pointer test case names 2021-04-18 12:33:04 +02:00
Paul Fultz II a772d652d8
Fix issue 9932: FP: containerOutOfBounds (#3217)
* Fix issue 9932: FP: containerOutOfBounds
2021-04-18 10:43:38 +02:00
Daniel Marjamäki 9a9043a07e Fixed #4349 (Support C++11 variadic templates) 2021-04-17 21:57:21 +02:00
Oliver Stöneberg 3bc71f982a
enabled "debug" findings in self-check / split "simplifyUsing" and "simplyTypedef" from more generic "debug" (#3210) 2021-04-17 18:07:47 +02:00
IOBYTE 5568ac95e7
fix simplifyUsing debug warning for: using value_type = const ValueFlow::Value; (#3211) 2021-04-17 14:20:16 +02:00
orbitcowboy 93c9963378 wxwidgets.cfg: Added support for more interfaces 2021-04-16 20:58:09 +02:00
orbitcowboy 8fcacfdf83 wxwidgets.cfg: Added support for more interfaces 2021-04-16 20:28:26 +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 c98afa83fd Tokenizer; Add test for c++14 lambda expression 'lambda=[value=1]{...}' 2021-04-16 15:18:02 +02:00
Daniel Marjamäki 11f828a669 Fixed #9415 (C++11: `alignas` not handled -> wrong code -> false negatives) 2021-04-15 20:26:53 +02:00
orbitcowboy f62d9d5853 std.cfg: Fixed bufferAccessOutOfBounds false negative for strncmp(). 2021-04-13 19:13:00 +02:00
orbitcowboy 03bdcc4c42 Attempt to make CI happy 2021-04-13 16:57:31 +02:00
orbitcowboy e869452240 #10244: Fixed false negative: bufferAccessOutOfBounds 2021-04-13 16:40:38 +02:00
orbitcowboy 44c8b315c6 Attempt to make CI happy 2021-04-13 14:44:59 +02:00
orbitcowboy 040e58f943 std.cfg: strxfrm(): Added minize values to arg1 and arg2 and a TODO test case 2021-04-13 14:07:45 +02:00
orbitcowboy cf211610d3 wxwidgets.cfg: Fixed wrong configuration for wxLogApiError(). This function does return after appending data to wxLog(). Ensure that no duplicateBreak-warning is issued in case code resides afterwards. 2021-04-13 13:07:15 +02:00
Georgiy Komarov fce3db8b7d
misra: Fixed a crash in rule 8.2 (#3208)
Due to incorrect indentation, we return "None" instead of an empty list,
which causes the crash.

The problem was reported on the forum: https://sourceforge.net/p/cppcheck/discussion/general/thread/e146b8d779/
2021-04-13 10:09:42 +02:00
Oliver Stöneberg 5a7e361442
run self-checks with standard set to C++11 (#3206) 2021-04-12 18:29:13 +02:00
Oliver Stöneberg 63cbd1e894
appveyor.yml: removed unneeded installation/update of Python packages (#3207) 2021-04-12 09:31:52 +02:00
Daniel Marjamäki eacc9e552e Function::returnsReference: handle type scope better 2021-04-10 14:31:50 +02:00