Commit Graph

10550 Commits

Author SHA1 Message Date
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 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
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
Daniel Marjamäki 9e4e06a524 Clang import; Testing that token index is set properly 2021-01-06 11:19:14 +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
abhijit-sawant a4a225203c
Fix #9938 (false positive: StlMissingComparison) (#2989) 2021-01-04 10:07:07 +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
IOBYTE 23da5c9815
fix #9885 (SymbolDatabase: function lookup fails calling variadic method) (#3002)
Co-authored-by: Robert Reif <reif@FX6840>
2021-01-03 11:17:32 +01:00
Oliver Stöneberg fbf5858f76
fixed and enabled several clang-tidy warnings (#2816) 2021-01-02 19:10:25 +01:00
Rikard Falkeborn f816cc8d48
runtests: Add -Wno-deprecated-declarations to CXX flags (#3004)
This avoids warnings when checking syntax of qt.cpp.
2021-01-02 10:02:16 +01:00
Rikard Falkeborn d19454b935
Refactoring: Convert ValueType to enum class (#3005) 2021-01-02 09:30:00 +01:00
Daniel Marjamäki abb19875b3 Bug hunting; Fixed testrunner 2021-01-01 08:58:54 +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
miltolstoy ee8d5b972a
checkunusedvar: handle array element change using pointer arithmetic (#3000) 2021-01-01 08:06:20 +01:00
Rikard Falkeborn fb35756126
TestLeakAutoVar: Split recursiveCountLimit test to separate class (#2995)
This test is by far the slowest one to run. Split it to a separate class
to make it easy to select if it should be run during development.
2020-12-31 09:34:53 +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 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 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
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
Georgy Komarov 1c12b4fd78
ExprEngine: Handling cases when for condition is always false (#2984) 2020-12-26 21:29:50 +01:00
Paul Fultz II bd22070df5
Fix issue 10027: Segmentation fault in ValueFlowAnalyzer::analyze (#2987) 2020-12-26 21:26:39 +01:00
Daniel Marjamäki d024eb3ee0 Fixed #10051 (AST: Wrong ast for function call with initializer list) 2020-12-26 18:33:54 +01:00
IOBYTE 765c1ace87
fix #10008 (false negative: knownEmptyContainer with alias in namespace and "using namespace") (#2979) 2020-12-26 13:45:17 +01:00
Daniel Marjamäki f700d81e59 ImportProject: Fixed compile_commands.json problems 2020-12-25 14:47:01 +01:00
Daniel Marjamäki cf57233f5d ImportProject: Try to handle -D and -I in the same way 2020-12-25 11:51:24 +01:00
Daniel Marjamäki bcf6039558 Fixed #10058 (False positive: redundant assignment, there is break) 2020-12-25 09:08:15 +01:00
Ken-Patrick Lehrmann aad723bf3a
Fix false positive AssignmentIntegerToAddress (#2971) 2020-12-24 19:57:02 +01:00
Paul Fultz II e12a733ee9
Fix issue 10053: False positive: Same value on both branches of ternary operator (#2962) 2020-12-23 13:37:28 +01:00
Georgy Komarov 259f562e73
ExprEngine: Add condition branches for the while loops (#2970) 2020-12-22 20:21:57 +01:00
Daniel Marjamäki a9e7974963 ExprEngine: use 'real' instead of 'fpa' values in latest Z3 for floats 2020-12-22 18:05:21 +01:00
Daniel Marjamäki 315892d991 ExprEngine; add a 'stupid' handling of floating point promotions for integers 2020-12-22 17:15:11 +01:00
Daniel Marjamäki 1812951640 ExprEngine; Fix problem when float suffix is used 2020-12-22 15:17:36 +01:00
Daniel Marjamäki 347fccb207 ExprEngine; Avoid overspecified constraints 2020-12-22 11:10:01 +01:00
amai2012 f0da9098b9
Set language compatibility to C++14 in Visual Studio (#2967)
There is no C++11 flag
2020-12-22 10:24:25 +01:00
Georgy Komarov 0731df7d2d
ExprEngine: Add FP and String literals in determining that condition can (#2969) 2020-12-22 09:25:54 +01:00
Daniel Marjamäki 13ed2effa1 astyle formatting
[ci skip]
2020-12-22 08:09:51 +01:00
IOBYTE 2ecab32fbe
fix debug printing of valuetype name with namespaces (#2968) 2020-12-21 19:47:54 +01:00
Daniel Marjamäki 01ac4073c8 TestExprEngine: Fix for ubuntu 18.04. Replace '(/ 123.0 10.0)' with '12.3' 2020-12-21 15:29:05 +01:00
Daniel Marjamäki c3e798968c ExprEngine; Fix floating point comparison 2020-12-21 13:28:10 +01:00
abhijit-sawant 7d6fc23022
Checking in fix for issue 9957 - - False negative: duplInheritedMember (#2964) 2020-12-21 07:14:52 +01:00
Daniel Marjamäki 47bb487c95 Visual Studio; Try to fix compilation 2020-12-20 21:01:45 +01:00
Daniel Marjamäki 37a5ec8cd5 Summaries: Moved to its own files 2020-12-20 19:53:58 +01:00
Daniel Marjamäki 5701f6d368 ExprEngine: Added ifIntRangeAlwaysFalse and ifIntRangeAlwaysTrue tests 2020-12-20 19:04:46 +01:00
Daniel Marjamäki 229e39e7de Revert "ExprEngine: Fixed float value"
This reverts commit 1f9edc6a66.
2020-12-20 16:36:22 +01:00
Daniel Marjamäki 1f9edc6a66 ExprEngine: Fixed float value 2020-12-20 15:22:11 +01:00
Wolfgang Stöggl 079255d913
Fix gcc11 build errors (#2963) 2020-12-19 21:54:19 +01:00
Daniel Marjamäki 96caaedbd5 Generate basic function summaries 2020-12-19 19:02:42 +01:00
Paul Fultz II a770342593
Fix crash in getInitListSize (#2960) 2020-12-19 12:23:19 +01:00
Daniel Marjamäki 1744cbaf66 astyle formatting
[ci skip]
2020-12-19 08:56:46 +01:00
miltolstoy 6366a577f9
feat(unused_var): analyze global variables inside function body (#2944) 2020-12-19 08:55:19 +01:00
Paul Fultz II 626dcd0eba
Fix issue 10037: False positive when passing variables to functions by address (#2957) 2020-12-19 08:29:37 +01:00
Paul Fultz II 2541b6034f
Fix issue 10049: False positive: generic reverse valueflow analysis (#2959) 2020-12-19 08:28:58 +01:00
Daniel Marjamäki 164c6b3441 Bug hunting; Detect array index out of bounds for multi dimensional arrays also 2020-12-18 21:32:23 +01:00
Daniel Marjamäki 1b0ca0811f Bug hunting; option to set function analysis max time 2020-12-18 19:59:10 +01:00
IOBYTE f2cf11682a
fix #10040 (symbolDatabaseWarning: debug: Executable scope 'x' with unknown function.) (#2955) 2020-12-18 07:46:01 +01:00
Paul Fultz II b044f9ba96
Fix issue 9996: false negative: containerOutOfBounds with std::vector::front() and c++11 braced initializer (#2958) 2020-12-18 07:14:11 +01:00
Daniel Marjamäki 75f2ab20e8 Bug hunting; void* => might point at uninitialized data 2020-12-17 07:32:53 +01:00
Daniel Marjamäki 8619bfe957 Bug hunting; Remove old value from array when it is overwritten 2020-12-16 19:06:20 +01:00
Paul Fultz II c9d2e55ea9
Fix issue 10035: FP: knownConditionTrueFalse when bool updated in for loop (#2953) 2020-12-16 17:25:21 +01:00
Daniel Marjamäki 82635417d2 Bug hunting; Fixed array init 2020-12-14 22:15:10 +01:00
Daniel Marjamäki 116119083b Bug hunting; Better result from function that returns unknown pointer result 2020-12-14 17:53:28 +01:00
Paul Fultz II da1375c9a3
Fix issue 10024: FP: nullPointerRedundantCheck when using a goto statement (#2947) 2020-12-14 11:13:47 +01:00
Daniel Marjamäki bf951ea5e6 Bug hunting; Fix for '*x=y' 2020-12-13 19:54:57 +01:00
Daniel Marjamäki be4de06a97 TestExprEngine: Temporary convert ASSERT_EQUALS to TODO_ASSERT_EQUALS 2020-12-13 16:11:01 +01:00
Georgy Komarov 36ab23f1f7
ExprEngine: Handle pointers to struct as function argument (#2945) 2020-12-13 16:02:35 +01:00
Daniel Marjamäki 81c3ac738d CI: Fix testrunner 2020-12-13 15:51:20 +01:00
Daniel Marjamäki b18dc0fdbb Bug hunting: Handle not better 2020-12-13 13:00:04 +01:00
Daniel Marjamäki be16b2c276 Bug hunting; better handling of early return 2020-12-13 09:13:26 +01:00
Daniel Marjamäki 2cf6217859 Travis: ExprEngine debug output was changed, corrected tests. 2020-12-12 21:29:28 +01:00
Daniel Marjamäki d0f700305c ExprEngine: Avoid analyzing unreachable execution paths 2020-12-12 15:22:49 +01:00
IOBYTE 7fc03c6030
fix #10032 (Syntax error if first function in a struct is a template function) (#2940)
Co-authored-by: Robert Reif <reif@FX6840>
2020-12-11 07:01:20 +01:00
Daniel Marjamäki 245284acde Tokenizer; Fixed varid for base class member variable 2020-12-08 17:25:50 +01:00
Daniel Marjamäki 6d7ddde1b5 Bug hunting; Make bughuntingUninit check a bit less noisy about const parameters 2020-12-08 13:34:46 +01:00
Daniel Marjamäki 99cb65b4b2 Bug hunting; Clarify bughuntingUninit output for non-const parameters 2020-12-08 11:16:38 +01:00
IOBYTE 8161baf1e9
fix template debug output line numbers (#2938) 2020-12-08 10:35:13 +01:00