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
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
95d1b41a5b
runtests.sh: fixed check for cppunit ( #3072 )
2021-01-21 10:59:34 +01:00
Oliver Stöneberg
f46a9e3543
fixed/excluded some shellcheck warnings and actually fail the build when something is found ( #3068 )
2021-01-20 18:43:49 +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
Paul Fultz II
65395aeaa1
Add regression test for 7013: valueFlowAfterCondition: false positive below overspecified code ( #3055 )
2021-01-17 16:29:11 +01:00
IOBYTE
dd866f2898
fix using type alias with derived class ( #3050 )
2021-01-17 16:10:53 +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
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
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
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
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
Daniel Marjamäki
02bb14003b
Bug hunting; better handling of struct member assignment in for loop
2020-12-07 19:58:19 +01:00
Daniel Marjamäki
39a9350f6e
Bug hunting: Better analysis of BailoutValue
2020-12-07 06:27:14 +01:00
IOBYTE
8d9f0b3528
fix #9394 ("debug: Executable scope 'x' with unknown function." with … ( #2935 )
2020-12-06 22:08:42 +01:00
Daniel Marjamäki
d12732adfb
Bug hunting; Diagnose array index out of bounds when struct member is accessed
2020-12-06 17:44:07 +01:00
Daniel Marjamäki
3bf758a04b
Bug hunting; Ensure there is warning after unknown variable expression
2020-12-06 10:13:10 +01:00
Daniel Marjamäki
7324722dab
Bug hunting; Detect array index out of bounds in loop better
2020-12-05 20:39:54 +01:00
Daniel Marjamäki
cb7eee2aa9
SymbolDatabase: Improved types for 'std::string + x'
2020-12-05 13:24:21 +01:00
Daniel Marjamäki
da4cd6a4f4
Bug hunting; Improved buffer overflow check
2020-12-05 11:47:57 +01:00
Daniel Marjamäki
396c353d3c
bug hunting: Add array index check
2020-12-05 11:46:07 +01:00
Daniel Marjamäki
c89512d8d6
Update copyright year
2020-12-05 09:28:33 +01:00
IOBYTE
ab16603666
fix #9685 (Handle 'extern "C++"') ( #2933 )
2020-12-05 09:26:11 +01:00
orbitcowboy
2c15c384d1
Fixed some typos, there are no functional changes intended
2020-12-05 08:00:31 +01:00
IOBYTE
9c51d4c12d
instantiate nested templates in the proper order ( #2930 )
2020-12-04 08:04:16 +01:00
Daniel Marjamäki
cbb388d458
Tokenizer: Avoid wrong simplification of template right angle bracket
2020-12-02 20:21:32 +01:00
Daniel Marjamäki
c69bfbf495
AST: Fixed ast for multidimensional array initialisation
2020-12-02 07:38:21 +01:00
Daniel Marjamäki
009ad11b3e
SymbolDatabase: set proper valuetype for string addition result ( #9161 )
2020-12-01 20:16:39 +01:00
IOBYTE
2bbc7abedc
fix overloaded function lookup for explicit instantiations ( #2929 )
2020-12-01 09:43:16 +01:00
Daniel Marjamäki
26b4c803f7
astyle formatting
2020-11-30 19:26:54 +01:00
Daniel Marjamäki
9aa69661b5
More robust Token::findClosingBracket
2020-11-30 19:26:28 +01:00
Oliver Stöneberg
c846c0fbdc
testclangimport.cpp: fixed potential nullptr dereference in parse() ( #2927 )
2020-11-30 18:46:48 +01:00
Daniel Marjamäki
8a1c16a560
Tokenizer: add daca debug messages when right angle brackets in templates are not handled well
2020-11-29 16:07:56 +01:00
Daniel Marjamäki
7112f69d7b
Fixed bug in fixAngleBrackets
2020-11-29 12:56:13 +01:00
Daniel Marjamäki
e2debac882
Fix testcases
2020-11-29 08:46:42 +01:00
Daniel Marjamäki
fd75837494
Tokenizer: Remove extra 'template' keywords
2020-11-28 21:57:06 +01:00
Daniel Marjamäki
5b89b179ec
Detect syntax error when script is checked
2020-11-28 14:41:05 +01:00
Daniel Marjamäki
af26697ceb
AST: Generate proper AST for 'f = []() -> foo&& {}'
2020-11-28 06:53:46 +01:00
Daniel Marjamäki
484b68c550
astyle formatting
2020-11-28 05:52:35 +01:00
miltolstoy
5d299016f1
feat: analyze function side effects ( #2901 )
2020-11-26 17:34:42 +01:00
orbitcowboy
0e8556e6ed
Activated basic runtime checks for 'Debug'-testrunner builds with MSVS as described here: https://docs.microsoft.com/de-de/cpp/build/reference/rtc-run-time-error-checks?view=msvc-160
2020-11-26 09:29:59 +01:00
Daniel Marjamäki
96392aa212
Clang import: better handling of templates
2020-11-24 22:02:59 +01:00
Daniel Marjamäki
788abfa8a4
Clang import: better handling of CXXMethodDecl in getSpelling
2020-11-24 19:20:30 +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
f6e7a66f42
TestConstructors: Unremove a test case
2020-11-22 18:17:40 +01:00
Daniel Marjamäki
2cd8ea83a7
Fixed #9860 (unused template not removed properly by default)
2020-11-22 16:43:36 +01:00
Wolfgang Stöggl
8ac55a8534
Add find_package(tinyxml2) to CMake builds ( #2691 )
...
So far, the cmake files of Cppcheck needed to be patched in order to
use installed tinyxml2 instead of the bundled version of tinyxml2.
- Introduce the CMake option USE_BUNDLED_TINYXML2 with a default value
of ON. This preserves the behavior as in the past and uses the
bundled version under externals/tinyxml2 by default.
- Usage of the installed tinyxml2 version of a system can be enabled
now using -DUSE_BUNDLED_TINYXML2=OFF as a cmake parameter.
- Some Linux distros do not install tinyxml2*.cmake files, which are
required to find tinyxml2 using find_package().
Try first using find_package(tinyxml2 QUIET) and if this fails, try
again using find_library(tinyxml2_LIBRARY tinyxml2)
2020-11-22 08:57:07 +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
f6399c4cba
Fix issue 9980: FP nullPointerRedundantCheck - condition after while loop ( #2912 )
2020-11-20 09:36:09 +01:00
Daniel Marjamäki
9c27ba835d
astyle formatting
2020-11-19 21:25:49 +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
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
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
bfa8c6fb98
Fixed cppcheck warning and corrected checkHeaders test
2020-11-11 15:28:32 +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
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
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
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
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
b8e0cdcdb4
Travis: temporary hack to make test-clang-import.py happy
2020-11-07 17:23:56 +01:00
Daniel Marjamäki
ff17d3e7c6
Clang import: Better handling of scope types
2020-11-07 15:02:36 +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
Rikard Falkeborn
a7f6621fc0
cfg: cppunit: Fix FP with compareBoolExpressionWithInt within CPPUNIT_ASSERT_EQUAL ( #2879 )
2020-11-04 07:48:53 +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
eece8ee66b
astyle formatting
2020-11-03 21:08:21 +01:00
Daniel Marjamäki
8956ecb5fc
Clang import: Fixed data for inline static functions
2020-11-03 17:52:53 +01:00
Oliver Stöneberg
98946143f6
Fix #9964 (false positive: compareBoolExpressionWithInt with ASSERT_FALSE() and --library=googletest) ( #2876 )
2020-11-03 10:20:25 +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
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
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
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
6d0b78433b
astyle formatting
2020-10-29 21:43:56 +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
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
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
47914b9960
Crash: Add regression test
2020-10-22 07:40:06 +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
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
40faca7dd9
Fix TestClangImport
2020-10-06 23:19:32 +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
c3de128a5f
Testing backwards compatible inline suppression
2020-10-04 16:42:09 +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
Paul
828a5e2326
Fix issue 9930: valueFlowLifetime hang
2020-10-03 11:01:53 +02:00
Daniel Marjamäki
8d20d8afb5
Update Copyright year
2020-10-03 09:15:56 +02:00
Daniel Marjamäki
27fbe28804
Try to make Travis happy
2020-10-02 21:24:30 +02:00
Daniel Marjamäki
aa055fe430
try to make test/cli happy
2020-10-02 20:30:28 +02:00
Daniel Marjamäki
6de91d6386
Fixed #9707 (False positive: unreadVariable, union)
2020-10-02 20:22:22 +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
orbitcowboy
da6f10e369
Astyle formatting code [ci skip]
2020-10-01 08:33:16 +02:00
Daniel Marjamäki
1548bf2267
Fix googletest.cfg macros ASSERT_THROW and EXPECT_THROW to avoid syntax errors
2020-09-30 18:45:04 +02:00
orbitcowboy
63917bc3c3
Better fix for c4dd8536c1
2020-09-30 15:44:06 +02:00
Daniel Marjamäki
c4dd8536c1
Fixed make checkcfg
2020-09-30 12:36:31 +02:00
Daniel Marjamäki
fe2717fa37
Fixed testrunner
2020-09-29 17:43:53 +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
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
fa42d8c49c
Fixed #9920 (Tokenizer: The keyword is not replaced, leads to false positive)
2020-09-28 16:35:50 +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
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
5b78c64420
Fixed testrunner
2020-09-25 20:04:07 +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
Oliver Stöneberg
dae37f1c9f
disabled precompiled headers in CMake as they currently do not emit any compiler warnings / adjusted check for precompiled header ( #2820 )
2020-09-23 07:51:21 +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
Daniel Marjamäki
107ee57e7a
Fixed #9909 (False positive: knownArgument for calculation 'self->maxsize * sizeof(intptr_t)')
2020-09-21 20:02:55 +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
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
61145cf878
test/cli/test-inline-suppress.py: better testing
2020-09-11 18:29:42 +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
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
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
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
Paul
5033fb4418
Fix issue 9869: False positive: knownEmptyContainer when passed to constructor
2020-09-09 22:23:42 -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
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