Commit Graph

10671 Commits

Author SHA1 Message Date
Ken-Patrick Lehrmann cddaa6d671
10221: Fix setVarId in template code (#3187)
The computation of the classname was not expecting templates. Simply
skipping the template part seems to fix the issue.
2021-03-29 12:16:02 +02:00
orbitcowboy e23a967215 #4750 Added a regression test 2021-03-28 09:29:46 +02:00
orbitcowboy 185a5e1ee6 #7682 Added regression test 2021-03-26 10:54:08 +01:00
orbitcowboy 6fd916a90f #3763 Added regression test 2021-03-26 10:01:44 +01:00
Lars Even Almaas 9786f1c34b
Suggested implementation for rule 8.2 (#3169) 2021-03-25 08:25:43 +01:00
Daniel Marjamäki 42437277dc Update Copyright year 2021-03-21 20:58:32 +01:00
Daniel Marjamäki 51564504a8 astyle formatting 2021-03-20 18:54:46 +01:00
Tetrix 9b7f1f6280
simplifyCPPAttribute tokenizer strips alignas (#3171) 2021-03-20 10:38:47 +01:00
IOBYTE 1874b9cb0f
fix crash in CheckClass::getFileInfo (#3172)
* fix crash in CheckClass::getFileInfo

* fix another crash

* fix memory leak

Co-authored-by: Robert Reif <reif@FX6840>
2021-03-19 09:19:48 +01:00
IOBYTE b1b7fbb63a
partial revert of b1eaa3021f (#3174)
It is necessary to use a fake NameAndToken in
mTypesUsedInTemplateInstantiation rather than a Token pointer so the
template simplifiers internal state is kept valid when tokens are
deleted. This prevents a use after free.

Co-authored-by: Robert Reif <reif@FX6840>
2021-03-18 09:15:21 +01:00
orbitcowboy 8fffb84aad Running astyle [ci skip] 2021-03-16 09:44:58 +01:00
IOBYTE c9f09fc73f
small template simplifier fixes (#3168)
* small template simplifier optimization

* don't look for template parameter name in default values

* fix cppcheck warning

* add test for TemplateSimplifier::getTemplateParametersInDeclaration()

Also removed TemplateSimplifier::getTemplateParametersInDeclaration()
return value since it wasn't used.

* added another test

Co-authored-by: Robert Reif <reif@FX6840>
2021-03-16 09:31:52 +01:00
Daniel Marjamäki 7d4582d8ef Fixed #9832 (extract configurations; include guards not handled correctly '#if !defined(FILE1_H)') 2021-03-12 18:16:57 +01:00
Rikard Falkeborn 103e52f394
Fix tokenizing of x[i](0) (Fixes #8875) (#3167)
Fix faulty removal of parenthesis when "]" is followed by parenthesis
with a number inside, for example when calling a function pointer in
an array or (perhaps more common) in c++, calling operator ( on an
element in an array.

Fixes #8875 where such wrong simplification lead to a FP with too many
bits shifted due to "<<" was interpreted like a shift operator rather
than a stream output.
2021-03-11 08:16:25 +01:00
Daniel Marjamäki 3502036b14 Usability: Fixed loading of platform file placed in same path as project file 2021-03-05 08:39:09 +01:00
IOBYTE fe4964f22c
fix overloaded template instantiation (#3160) 2021-03-04 08:43:22 +01:00
Rikard Falkeborn 27316e04ed
Fix #10187 (memleak open with fd >= 0) (#3156) 2021-03-03 07:00:28 +01:00
Rikard Falkeborn 42a41e8b41
Fix #9139 (leak when variable has const qualifier) (#3159)
Also, in the tests, change socket/close to resource to get error
messages which say "resource leak" instead of "memory leak".
2021-03-03 06:58:38 +01:00
orbitcowboy 2a40ce6430 windows.cfg: Added support for more defines from WinBase.h and Winnt.h 2021-03-02 10:48:37 +01:00
Daniel Marjamäki fef956f3f0 Testing; Moved test/cli tests from travis to github actions 2021-03-01 18:49:59 +01:00
Daniel Marjamäki 6b166eb5a7 test/cli/test-other-projects.py: Temporarily disable test (to make Travis happy) 2021-02-28 23:11:25 +01:00
IOBYTE 8c57e2bb14
fix template simplifier overloaded specialized instantiations (#3154) 2021-02-28 21:52:14 +01:00
Daniel Marjamäki c9bc5a076f Fixed #10014 (-U switch ignored when using --project=compile_commands.json and --force) 2021-02-28 21:43:51 +01:00
Daniel Marjamäki 199f9608cb TestSuite: Fixed getLocationStr 2021-02-27 04:33:16 +01:00
Daniel Marjamäki 7106e1f48f Moved TestTokenizer::simplifyCasts tests to TestSimplifyTokens 2021-02-27 04:19:54 +01:00
Daniel Marjamäki 81c7fa0348 Moved TestTokenizer::tokenize6 to TestSimplifyTokens 2021-02-27 04:07:33 +01:00
Rikard Falkeborn c3eb37972d
Fix #10182 (FN memory leak with if-statement) (#3151)
Improve leak detections in if-statements. This is done by checking
for leaks every time a scope is left. This allows cppcheck to catch
more memory leaks, as well as improve some error messages which now
contain the line where the variable goes out of scope, instead of the
end of the function.
2021-02-26 12:58:52 +01:00
Daniel Marjamäki 1adea5c3b0 Move simplifyKnownVariables tests to TestSimplifyTokens 2021-02-25 21:32:56 +01:00
Rikard Falkeborn 951ca2c8b9
Fix #10186 (FP memleak with cast and assignment) (#3148) 2021-02-25 10:55:34 +01:00
Daniel Marjamäki e03851f51c Fix compilation error 2021-02-24 22:31:46 +01:00
Daniel Marjamäki 15bc7ad5cb Fix compilation error 2021-02-24 22:20:11 +01:00
PKEuS 3998836b03 Refactorization: Improved string handling in test suite
Merged from LCppC.
2021-02-24 22:05:23 +01:00
PKEuS 141d2ac215 Refactorization: Improved internal implementation of severity and certainty levels
Backported from LCppC.
2021-02-24 22:00:06 +01:00
PKEuS c25b4f1ad6 Fixed false negatives incompleteArrayFill on user defined types (estimate size to determine if it is larger than one byte)
Merged from LCppC.
2021-02-24 21:48:26 +01:00
Daniel Marjamäki 2baeeeb02f astyle formatting 2021-02-24 21:48:26 +01:00
IOBYTE fc1cfba5e0
fix simplifyUsing hang parsing class initializer list using {} (#3146)
Co-authored-by: Robert Reif <reif@FX6840>
2021-02-23 20:35:20 +01:00
IOBYTE a07f93f819
fix simplifyUsing crash and hang (#3145) 2021-02-23 09:48:15 +01:00
shaneasd 02ac2b08a0
Fix some warnings (#3096) 2021-02-23 08:19:05 +01:00
Daniel Marjamäki 99ff242dde astyle formatting
[ci skip]
2021-02-20 13:33:57 +01:00
PKEuS 29a6031cea Fixed more false negatives (and recently introduced false positives) literalWithCharPtrCompare by using ValueType
Merged from LCppC.
2021-02-20 13:29:59 +01:00
Lukasz Czajczyk 0a06a083af
Additional macros (#3106) 2021-02-20 13:19:06 +01:00
PKEuS 4b01d5bdc6 Re-enabled a bunch of disabled unit tests, some as TODO tests
Merged from LCppC.
2021-02-20 13:02:14 +01:00
PKEuS 2bd6a6c252 Test suite:
- Enabled test in testgarbage.cpp that succeeds
 - Optimizations in TestIO

Merged from LCppC.
2021-02-20 13:00:30 +01:00
PKEuS cf1937294a Refactorization: Removed unnecessary \n and spaces in strings
Merged from LCppC.
2021-02-20 12:58:42 +01:00
PKEuS 25678a9faf Refactorized CheckStl::string_c_str(), fixing some false negatives by supporting member functions and overloads
Merged from LCppC.
2021-02-20 12:52:39 +01:00
PKEuS 423d7dbc3c Fixed false negatives literalWithCharPtrCompare when address-of operator (C only) or arrays are used, adapted TODO unit tests
Enabled working unit test in testunusedvar.cpp

Merged from LCppC.
2021-02-20 12:42:48 +01:00
Robert Reif 3c6fae37e4 minor simplifyUsing optimizations
The using type aliases are a C++ 11 feature so only check for them in C++ 11 or later.

Don't try to simplify a type alias when it can't be parsed.
2021-02-19 22:48:31 +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
Daniel Marjamäki f836c7a546 Fix compile error 2021-02-18 18:50:30 +01:00
PKEuS acafdb655c Refactorization: Reduced stack usage of givenACodeSampleToTokenize
Merged from LCppC.
2021-02-18 16:28:04 +01:00
PKEuS 4678a9cb45 Refactorization: Include cleanup and added one more header to test/precompiled.h
Merged from LCppC
2021-02-18 16:16:40 +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
Paul Fultz II 0619b873d0
Fix issue 10178: FP: nullPointerRedundantCheck with ternary and null condition first (#3134) 2021-02-17 12:09:11 +01:00
IOBYTE 7ab84bef0c
fix daca crash in intel-compute-runtime (#3132) 2021-02-15 08:12:29 +01:00
Daniel Marjamäki f08dde1140 Fixed #10013 (Tokenizer: Code with 'not' is not handled) 2021-02-13 20:32:49 +01:00
Oliver Stöneberg 3814163373
some MathLib adjustments for out-of-range numbers after std::stringstream removal (#3100) 2021-02-13 19:10:45 +01:00
IOBYTE 75e439e56d
fix crash in checkclass from unknown template valueType (#3129) 2021-02-13 13:41:12 +01:00
IOBYTE 1eafed9e75
fix hang in simplifyUsing (#3128)
Co-authored-by: Robert Reif <reif@FX6840>
2021-02-12 16:21:51 +01:00
IOBYTE e57a674458
fix #10173 (syntax error from wrong simplifications for using type al… (#3126) 2021-02-12 09:47:16 +01:00
IOBYTE b6e93bb575
fix #10172 (debug: Executable scope 'x' with unknown function.) (#3121) 2021-02-11 08:08:45 +01:00
Paul Fultz II 51f93400d1
Fix issue 10166: FP uninitvar with break from infinite loop (#3124) 2021-02-11 08:07:12 +01:00
Daniel Marjamäki fbf63b932e astyle formatting
[ci skip]
2021-02-10 11:42:00 +01:00
Paul Fultz II 8569a970b4
Fix issue 10147: False positive: Out of bounds access in expression 'v[0]' because 'v' is empty. (#3123) 2021-02-10 08:11:06 +01:00
Daniel Marjamäki ef726aaece New check: Detect one definition rule violations 2021-02-09 21:35:08 +01:00
Paul Fultz II 0e871c178f
Fix issue 10141: Errors with ref assignment (duplicateValueTenary and knownEmptyContainer) (#3093) 2021-02-09 15:27:46 +01:00
IOBYTE d3d2e16137
fix hang from f48e195c31 (fix #10136 TODO test (#3117)) (#3120)
Co-authored-by: Robert Reif <reif@FX6840>
2021-02-09 14:19:01 +01:00
IOBYTE f48e195c31
fix #10136 TODO test (#3117) 2021-02-07 21:46:35 +01:00
IOBYTE 1872725ca2
fix #10171 (debug: Executable scope 'x' with unknown function.) (#3116) 2021-02-07 09:04:57 +01:00
Daniel Marjamäki 7ab70654ba Fixed #10170 (Preprocessor; Fail to extract some configurations) 2021-02-06 12:48:52 +01:00
IOBYTE c70fcf8e2b
fix #10136 (debug: Executable scope 'x' with unknown function.) (#3113) 2021-02-05 15:50:32 +01:00
IOBYTE da3eb2e411
fix #10169 (CheckClass::checkDuplInheritedMembersRecursive) (#3114)
Co-authored-by: Robert Reif <reif@FX6840>
2021-02-05 11:05:07 +01:00
Daniel Marjamäki 0338e99f84 CheckClass: Refactoring 2021-02-03 19:25:28 +01:00
Paul Fultz II 0ecac8e23b
Fix issue 10090: ValueFlow: Wrong lifetime, pointer member is not allocated on stack (#3109) 2021-02-03 10:22:31 +01:00
Paul Fultz II cf8a5d9a22
Fix issue 10111: FP knownConditionTrueFalse (#3110) 2021-02-03 10:21:47 +01:00
Daniel Marjamäki c0731703af astyle formatting
[ci skip]
2021-02-02 15:01:28 +01:00
alonlib12 a22e476162
Fix CheckClass::operatorEqToSelf (#3088) 2021-02-02 15:00:46 +01:00
Paul Fultz II 913dbeb8d8
Fix FP when inserting a range into a container (#3108) 2021-02-02 14:57:48 +01:00
Daniel Marjamäki 986f658e39 Fixed #10161 (False negative; uninitialized member variable in base class without constructor) 2021-02-01 18:58:51 +01:00
Oliver Stöneberg b472b4e65d
some Python cleanups based on PyCharm inspections (#2999)
* some Python cleanups based on PyCharm inspections

* test-helloworld.py: adjusted assert in test_addon_relative_path()
2021-01-31 14:27:11 +01:00
Ken-Patrick Lehrmann 4e35f19659
10153: Check that string.find() is compared with 0 before recommending starts_with() (#3099) 2021-01-31 12:05:38 +01:00
Daniel Marjamäki 6a24b4f7c8 Fixed #10149 (compile database; incomplete handling of directory and file) 2021-01-31 10:14:22 +01:00
IOBYTE 5810171336
fix daca crashes in Type::findDependency() (#3101) 2021-01-31 10:07:03 +01:00
Daniel Marjamäki 95e2eebd8a Revert fix for #10149, it caused an unexpected appveyor failure 2021-01-30 15:01:19 +01:00
Daniel Marjamäki 43e8430a80 Fixed #10149 (compile database; incomplete handling of directory and file) 2021-01-30 12:27:40 +01:00
Daniel Marjamäki 9e9bb9f804 Refactor test/cli/test-proj2.py 2021-01-30 10:43:08 +01:00
Daniel Marjamäki 49e6e83bc3 astyle formatting
[ci skip]
2021-01-29 10:27:32 +01:00
Paul Fultz II a81427f97f
Fix issue 10022: Logical conjunction error between two completely unrelated members (#3094) 2021-01-29 10:26:57 +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
Paul Fultz II e17d22eb87
Fix issue 10134: False positive: value is not known. Early return. (#3086) 2021-01-28 12:37:56 +01:00
Daniel Marjamäki 203d6ebe5a Fixed #10100 (FP: shadowVariable clangimport) 2021-01-27 20:03:42 +01:00
Daniel Marjamäki 987c8a854e astyle formatting
[ci skip]
2021-01-25 22:51:50 +01:00
Paul Fultz II 0f8f207719
Remove valueFlowFwdAnalysis and update valueFlowAfterAssign to handle expressions (#3074) 2021-01-25 17:24:36 +01:00
Ken-Patrick Lehrmann 00707455be
10110: Fix FP knownConditionTrueFalse (#3053) 2021-01-25 17:23:47 +01:00
Simon Martin 9d10f4f572
Ticket #10028: Properly simplify auto variables' initialization. (#3079) 2021-01-23 17:56:58 +01:00
IOBYTE a4953575f1
fix #10127 (debug: Executable scope 'x' with unknown function.) (#3077) 2021-01-23 17:55:25 +01:00
Paul Fultz II c860de8565
Fix issue 8143: valueFlowCondition: before and inside while (#3045) 2021-01-23 17:52:01 +01:00
Paul Fultz II d80f2fb46f
Reapply f1cc3ad and fix performance regression (#3076) 2021-01-23 08:47:39 +01:00
Paul Fultz II a6f4fbae54
Fix issue 2741: False negative: redundant assignment of x to itself (ref = x) (#3071) 2021-01-22 11:00:57 +01:00
Daniel Marjamäki 0fa89ff2ba Revert 14365ffc7 and f1cc3ada8, there was a performance regression 2021-01-22 10:51:46 +01:00
Paul Fultz II f1cc3ada86
Refactor valueFlowTerminatingCondition to handle inner conditions and complex conditions (#3060) 2021-01-21 20:18:53 +01:00