Commit Graph

12689 Commits

Author SHA1 Message Date
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
Daniel Marjamäki 14365ffc7c make a function static 2021-01-21 20:27:28 +01:00
Paul Fultz II f1cc3ada86
Refactor valueFlowTerminatingCondition to handle inner conditions and complex conditions (#3060) 2021-01-21 20:18:53 +01:00
Paul Fultz II d05acf3c41
Fix issue 10120: FP: containerOutOfBounds, regression (#3064) 2021-01-21 19:50:57 +01:00
Paul Fultz II 8b26ecbcdd
Extend ProgramMemory to handle expressions (#3069) 2021-01-21 19:49:37 +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
Oliver Stöneberg 491f4874c5
fixed/aligned some compiler warnings (#3065) 2021-01-21 18:13:32 +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
Paul Fultz II 25ada657da
Fix issue 9030: ValueFlow: Possible value after conditional assignment in for loop (#3059) 2021-01-18 10:12:07 +01:00
IOBYTE 664289792c
fix simplifyTypedef removing needed type qualification (#3058) 2021-01-18 10:08:55 +01:00
abhijit-sawant b97387db66
Made missing comparison in loop check more generic (#3048) 2021-01-18 08:11:37 +01:00
IOBYTE dd866f2898
fix using type alias with derived class (#3050) 2021-01-17 16:10:53 +01:00
Oliver Stöneberg b2ed372f75
various optimizations (#3054) 2021-01-16 19:05:51 +01:00
Oliver Stöneberg 9f9a652ae1
refs issue #9089: avoid usage of expensive std::stringstream (#2996) 2021-01-16 19:03:28 +01:00
Daniel Marjamäki 853c271f22 Fix gcc warning; variable vidx is assigned but not read 2021-01-16 18:13:06 +01:00
Oliver Stöneberg 7aa85aa408
Use std::unordered_* containers for faster lookups (#3052) 2021-01-16 13:52:09 +01:00
Daniel Marjamäki 76f759fcc4 Fixed #9702 (False positive: Opposite inner condition when modifying member variable used by inner condition) 2021-01-15 20:51:47 +01:00
Daniel Marjamäki 503662f625 Try to fix null pointer dereference 2021-01-15 08:27:58 +01:00
Daniel Marjamäki 55262f03ec Fixed #9218 (False positive: Searching before insertion is not necessary (stlFindInsert)) 2021-01-14 22:31:43 +01:00
Daniel Marjamäki a5babf25a7 Fixed #10080 (syntax error: operator) 2021-01-14 20:56:11 +01:00
Ken-Patrick Lehrmann 56124f0c5d
Skip calculateWarningHash if we are not in bugHunting (#3047) 2021-01-13 18:38:00 +01:00
Paul Fultz II b571e9fe0b
Fix issue 10106: FP: nullPointerRedundantCheck (#3044) 2021-01-13 12:36:26 +01:00
Paul Fultz II b469da1069
Fix issue 8253: False negative: Comparison is always true (early return) (#3043) 2021-01-13 12:35:43 +01:00
Daniel Marjamäki 1858465bca astyle formatting
[ci skip]
2021-01-12 21:28:56 +01:00
Daniel Marjamäki 5f21d9d97b Fixed #8975 (Syntax error for valid C code) 2021-01-12 21:28:07 +01:00
Armin Müller 0de0a954d2
Typos found by running "codespell" (#3042) 2021-01-12 20:48:25 +01:00
Paul Fultz II fc4238829f
Fix issue 10092: false positive: (warning) The address of local variable 'data' might be accessed at non-zero index. (#3041) 2021-01-12 10:24:28 +01:00
Paul Fultz II b1c56d33ac
Fix issue 9133: Invalid iterator; vector::push_back, functions (#3008) 2021-01-11 18:47:38 +01:00
Paul Fultz II 678ee00fe9
Infer variables from conditions in valueFlowSubfunction (#3037) 2021-01-11 08:00:13 +01:00
Paul Fultz II a3617fe573
Fix issue 10102: False positive: knownConditionTrueFalse in for loop (#3038) 2021-01-11 07:56:16 +01:00
Rikard Falkeborn f018163551
Improve handling of realloc in memory leak checker (#3036)
Mark realloced variables as realloced instead of freed. This allows
improved checking for code with error realloc handling.

If cppcheck finds an if-statement which checks the validity of the
allocated memory or resource, check if the memory/resource is
reallocated from another variable. If so, we can add checking of that
variable in the if-statement instead. This allows to check that variable
for memleaks and double frees.

This fixes #9292 and #9990 which both concern FPs with double frees
after correct error handling.
2021-01-11 07:55:05 +01:00
Daniel Marjamäki 707f1f2fbe ValueFlow: Fixed isEqual 2021-01-10 16:52:11 +01:00
Daniel Marjamäki 98c7c0af96 Fixed GCC compiler warnings 2021-01-10 15:27:42 +01:00
Daniel Marjamäki 4e07a13feb ClangImport: If typeIndex is negative we want to have Cppcheck warnings about that 2021-01-10 14:51:28 +01:00
Daniel Marjamäki f493ce16b3 astyle formatting
[ci skip]
2021-01-10 14:46:19 +01:00
Paul Fultz II bc3f5554a4
Fix issue 8871: improve check: mismatching container size conditions (#2988) 2021-01-10 13:30:00 +01:00
Oliver Stöneberg ac7647fcd8
some self-check suppression cleanups (#3032) 2021-01-09 20:32:38 +01:00
IOBYTE 2482873029
fix location of forward declaration of specialized template (#3031) 2021-01-09 20:00:35 +01:00
Daniel Marjamäki f6c98a0999 Fix Cppcheck self check warning 2021-01-09 11:14:41 +01:00
Paul Fultz II c267d85640
Add generic valueflowBeforeCondition (#3001) 2021-01-08 22:55:04 +01:00
Daniel Marjamäki 4b5aedbbab Fixed #10066 (FP: duplicateExpression clangimport) 2021-01-08 22:30:06 +01:00
Paul Fultz II 3b5c558414
Fix issue 10076: ValueFlow: False positive after address of var is taken 'T t = {{&var}};' (#3027) 2021-01-08 10:29:32 +01:00
Rikard Falkeborn bedf3118ef
library: Refactor to use enum class (#3026) 2021-01-08 10:29:01 +01:00
IOBYTE 503a5dd441
fix #10081 (Hang: TemplateSimplifier::useDefaultArgumentValues) (#3021) 2021-01-06 23:06:50 +01:00
IOBYTE cb02628c7c
fix #10075 (namespace alias changes variable name) (#3020) 2021-01-06 17:30:11 +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
Rikard Falkeborn 50cdb6cbfc
Astyle: sync windows and linux folders (#3016) 2021-01-06 17:13:44 +01:00
Daniel Marjamäki 9e4e06a524 Clang import; Testing that token index is set properly 2021-01-06 11:19:14 +01:00
Daniel Marjamäki 0bd401c17b ClangImport; Assign token indexes 2021-01-06 11:07:21 +01:00
Daniel Marjamäki 168db9351d ClangImport; set exprid 2021-01-06 11:03:43 +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
Oliver Stöneberg 96704c9971
fixed and enabled some more clang-tidy warnings (#3007) 2021-01-05 17:51:32 +01:00
Paul Fultz II e004731f1c
Fix issue 8650: ValueFlow: Track if pointer is created by '&' operator (#3011) 2021-01-05 16:56:38 +01:00
IOBYTE 8897ad3408
fix #10068 (typedef not replaced when namespace is involved) (#3009) 2021-01-05 16:53:56 +01:00
Paul Fultz II f0b5668436
Fix issue 9890: ValueFlow: known value not found (variable is changed in path that returns) (#3010) 2021-01-05 16:49:08 +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
Daniel Marjamäki b3b7ecc7ea Removed integerOverflowOptimization checking and merged functionality into invalidTestForOverflow 2021-01-05 11:38:19 +01:00
Daniel Marjamäki abd6c00c82 Integer overflow; generalized checking for nonportable code 2021-01-04 19:43:05 +01:00
orbitcowboy 02b714f6dc Code formatting [ci skip] 2021-01-04 13:09:05 +01:00
Daniel Marjamäki c546b244a9 ClangImport; throw exception if CXXForRangeStmt can't be imported 2021-01-04 10:15:09 +01:00
abhijit-sawant a4a225203c
Fix #9938 (false positive: StlMissingComparison) (#2989) 2021-01-04 10:07:07 +01:00
Daniel Marjamäki da198e0726 Fix Cppcheck self check warning; use reference to avoid data copying 2021-01-04 01:47:04 +01:00
Daniel Marjamäki 38aa0fa2f0 Signed integer optimisation; ensure expr is variable 2021-01-03 23:30:34 +01:00
Daniel Marjamäki 52491f1c53 Signed integer optimisations; Also warn about 'x+y<x' 2021-01-03 22:12:19 +01:00
Daniel Marjamäki 6375fb4f08 New check: Warn about nonportable code that can be optimised (signed integer overflow) 2021-01-03 21:03:07 +01:00
Daniel Marjamäki 208014bae9 checkIntegerOverflow: Remove bailout for shifts 2021-01-03 17:44:46 +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 d59abfd977
fixed clang-tidy warnings (#3006)
* clang_tidy.cmake: added clang-tidy-11 to list of executables to look for

* .clang-tidy: disabled warnings we are (currently) not interested in

* fixed clang-tidy warnings
2021-01-02 23:10:27 +01:00
Oliver Stöneberg fbf5858f76
fixed and enabled several clang-tidy warnings (#2816) 2021-01-02 19:10:25 +01:00
Rikard Falkeborn d19454b935
Refactoring: Convert ValueType to enum class (#3005) 2021-01-02 09:30:00 +01:00
Daniel Marjamäki 3445a958d5 ValueFlow: Improved debug output. 2021-01-01 18:08:03 +01:00
Daniel Marjamäki 4e4db50311 Clang import: Use getChild 2021-01-01 17:59:43 +01:00
Daniel Marjamäki 214f90c10a Bug hunting; Fix false positive, unsigned array index can't be negative 2021-01-01 08:57:35 +01:00
Daniel Marjamäki 1d6c0976e5 astyle formatting
[ci skip]
2021-01-01 08:56:17 +01:00
miltolstoy ee8d5b972a
checkunusedvar: handle array element change using pointer arithmetic (#3000) 2021-01-01 08:06:20 +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 b16944b310 Revert "Clang import: Throw InternalError when nodeType is unknown"
This reverts commit 589174b92d.
2020-12-31 18:08:55 +01:00
Daniel Marjamäki 589174b92d Clang import: Throw InternalError when nodeType is unknown 2020-12-31 17:48:39 +01:00
Daniel Marjamäki f37274a5c0 ClangImport: Improved error handling 2020-12-31 17:37:14 +01:00
IOBYTE e7bdf5f71c
remove cleanupAfterSimplify from the template simplifier (#2998)
The template simplifier works well enough now so cleanupAfterSimplify is
no longer necessary.  In fact cleanupAfterSimplify was introducing a bug
which improperly simplified C++ style casts.

Bugs should be exposed and fixed properly rather than just hiding them.

Co-authored-by: Robert Reif <reif@FX6840>
2020-12-31 09:33:23 +01:00
Daniel Marjamäki a1756f3afc Clang import; Function declaration 2020-12-30 17:00:05 +01:00
Daniel Marjamäki f986b37a50 Clang import: Improved function pointer 2020-12-30 16:24:10 +01:00
IOBYTE 277da763aa
fix #10054 (debug: Executable scope 'x' with unknown function.) (#2994) 2020-12-30 08:09:34 +01:00
Daniel Marjamäki cb9efcb100 Clang import; Add a validation step 2020-12-29 21:36:50 +01:00
Daniel Marjamäki 0adf09c507 ClangImport; Fixed output for anonymous enum 2020-12-29 21:10:34 +01:00
Daniel Marjamäki 79a8f21183 ClangImport; Set Token::scope properly for empty enum body 2020-12-29 16:34:06 +01:00
Daniel Marjamäki 4bd5933691 Clang import: Do not write unreferenced enum declaration 2020-12-29 15:39:33 +01:00
Daniel Marjamäki 1e9f67936e Cppcheck: Fix; Do not run clang twice 2020-12-29 12:43:21 +01:00
Daniel Marjamäki 7719b27e44 Cppcheck: Print clang command when --verbose is used and build dir is empty 2020-12-29 10:20:46 +01:00
Daniel Marjamäki 2898a2925d Cppcheck: Using both --clang and --project 2020-12-29 10:15:38 +01:00
Daniel Marjamäki b94a6d595a Fixed #9295 (ValueFlow: Does not handle noreturn function) 2020-12-28 20:00:35 +01:00
shaneasd 53734a3da1
Test for return address of reference (#2991) 2020-12-28 10:50:42 +01:00
Daniel Marjamäki e7c462b827 Refactoring; Avoid 'unsigned' 2020-12-27 21:05:31 +01:00
orbitcowboy f1688667a5 Running astyle [ci skip] 2020-12-27 12:38:21 +01:00
Ken-Patrick Lehrmann f1169bf2b4
10062: Fix FP due to assignment in reverseanalyzer (#2983)
reverseanalyzer has a special process for assignments, and would not see
a stop condition on a rhs of an assignment.
2020-12-27 10:14:46 +01:00
Oliver Stöneberg 0a1012a273
fixed and enabled -Wdocumentation and -Wdocumentation-pedantic clang warnings (#2819) 2020-12-27 09:15:59 +01:00