Commit Graph

12212 Commits

Author SHA1 Message Date
Paul Fultz II cc2bc74084
Track lifetime for lambdas with explicit capture (#2776) 2020-09-05 07:56:01 +02:00
Daniel Marjamäki 8027f40418 Fixed #8506 (CPPCheck printing invalid characters in output) 2020-09-04 20:43:54 +02:00
Daniel Marjamäki 1daf1ec108 Fixed #9875 (Crash) 2020-09-04 19:15:48 +02:00
Paul 264c0cae8b Formatting 2020-09-04 11:59:30 -05:00
Paul bb37b07def Extend lifetimes to subfunctions 2020-09-04 11:56:34 -05:00
Daniel Marjamäki 30d3643bb8 Fixed #9851 (FP virtualDestructor - private virtual dtor) 2020-09-04 18:56:12 +02:00
Daniel Marjamäki 7d01ad5b50 add test-clang-import that compares symboldatabases 2020-09-04 15:29:19 +02:00
IOBYTE 2db0d2878b
fix daca crash in TemplateSimplifier::getNewName (#2772)
Don't add the same template instantiation multiple times.

Co-authored-by: Robert Reif <reif@FX6840>
2020-09-04 07:08:28 +02:00
shaneasd 84dd0c961f
False positive dynamic_cast auto variable which has been checked against null (#2769) 2020-09-04 07:06:26 +02:00
Daniel Marjamäki 5cd92a0eb1 test/cli/test-clang-import: Improved testing 2020-09-03 19:49:02 +02:00
Daniel Marjamäki efa113db55 Refactoring; do not use pointless lambda 2020-09-03 18:58:25 +02:00
Daniel Marjamäki 5acd6fcdc8 astyle formatting 2020-09-03 18:55:40 +02:00
shaneasd 08ea6435ac
fix false positives in constParameter (#2758) 2020-09-03 18:44:44 +02:00
Daniel Marjamäki 3fe46239cf SymbolDatabase; Refactoring, use Tokenizer::isFunctionHead to skip function attributes 2020-09-03 11:21:12 +02:00
Dan 974b6fb8e5
Add test cases for assign operators with default implementation (#2767) 2020-09-03 07:29:54 +02:00
Paul Fultz II 090eba7e7f
FIx issue 6140: ValueFlow: valueFlowForward, loop (#2770) 2020-09-03 07:17:36 +02:00
Daniel Marjamäki 638dcd0aca Fixed #9820 (Crash when --clang used with .c file) 2020-09-02 20:29:23 +02:00
Paul Fultz II 03cefd5d70
Fix issue 9853: False positive: returnReference when using a pointer to container (#2765) 2020-09-02 20:01:08 +02:00
Daniel Marjamäki 12d51ae5c4 Fixed #9809 (Tokenizer; Fix handling of variable declaration with @) 2020-09-02 13:04:33 +02:00
Daniel Marjamäki c1e03d63b2 astyle formatting
[ci skip]
2020-09-02 13:03:30 +02:00
Paul Fultz II 32df807b22
Fix issue 9783: wrong lifetime analysis temporary assigned to object (#2711) 2020-09-02 07:13:15 +02:00
Paul Fultz II dea5a23c34
Improve check: check for known empty containers passed to algorithms (#2768) 2020-09-02 07:11:23 +02:00
Daniel Marjamäki 8e79b0c8bc astyle formatting
[ci skip]
2020-09-01 20:00:04 +02:00
Daniel Marjamäki 1f8896e51c clang import: try to handle CXXFunctionalCastExpr 2020-09-01 19:59:41 +02:00
Paul Fultz II ba84196dca
Fix issue 9865: false positive: knownConditionTrueFalse (#2764) 2020-09-01 11:22:38 +02:00
Paul Fultz II 0a718694af
Fix issue 9852: False positive: danglingTemporaryLifetime when returning a vector of vectors (#2766) 2020-09-01 11:21:29 +02:00
Paul Fultz II 3e99bff764
Same expression when comparing with zero (#2762) 2020-08-31 08:48:48 +02:00
Paul Fultz II 1c5f496350
Fix issue 8373: false negative: invalid iterator (#2761) 2020-08-31 08:46:56 +02:00
Daniel Marjamäki d23fd26ce0 Cppcheck: Try to fix addon problems when paths have spaces 2020-08-30 18:15:48 +02:00
Daniel Marjamäki 18c29544eb astyle formatting 2020-08-28 19:29:33 +02:00
Paul Fultz II 6ab3c93fb1
Fix issue 9756: false negative: invalid iterator from std::find_if (#2760) 2020-08-28 19:29:09 +02:00
Paul Fultz II 82bdbcd73b
Fix issue 9859: false positive: knownConditionTrueFalse (#2759) 2020-08-28 19:26:09 +02:00
Paul Fultz II 494fff65b7
Add outOfBounds check for iterators to containers (#2752) 2020-08-26 21:05:17 +02:00
IOBYTE 8774e97f26
fix #9771 (Syntax error; operator != <> ()) (#2757) 2020-08-26 18:39:33 +02:00
Daniel Marjamäki bb5cad42cd astyle formatting
[ci skip]
2020-08-26 10:15:09 +02:00
Paul Fultz II 9ec27c112f
Fix issue 9855: false positive: uninitvar (#2754) 2020-08-26 07:02:15 +02:00
IOBYTE 7cf3909275
fix #9854 (Syntax error on valid C++ code) (#2756) 2020-08-26 07:00:58 +02:00
Paul Fultz II 46bf2d7d52
Dont diagnose impossible values for iterators (#2755) 2020-08-26 06:58:53 +02:00
shaneasd 45fc6a0eeb
Test for syntax error in nested templates (#2746) 2020-08-25 07:14:44 +02:00
Paul Fultz II ec89c57a90
Fix issue 9849: false positive: containerOutOfBounds (#2753) 2020-08-25 07:12:41 +02:00
Daniel Marjamäki 6277eece67 Variable contracts 2020-08-24 20:57:49 +02:00
Paul Fultz II 02287d9d34
Fix issue 7324: valueFlowForward : decrement (#2737) 2020-08-24 13:10:36 +02:00
Georgy Komarov c5369b84e1
Prevent copying in range-based for loops (#2751)
Use reference types in range for loops to prevent copying.
2020-08-23 20:53:44 +02:00
Daniel Marjamäki 2bb73840fc astyle formatting 2020-08-23 17:17:33 +02:00
Paul Fultz II ac846b96d1
New check: Iterating a known empty container (#2740) 2020-08-22 09:16:26 +02:00
Paul Fultz II becdf20310
Fix crash in isSameExpression (#2748) 2020-08-22 07:05:21 +02:00
Kamil Dudka 33fb0e782e
enable moduloofone reports only with --enable=style (#2747)
... because it is reported with Severity::style
2020-08-21 20:43:03 +02:00
Daniel Marjamäki e0e70c2531 Fixed compiler warnings 2020-08-21 17:23:55 +02:00
eivindt 27e40af06c
Add support for comments at end of suppression in suppression files (#2736) 2020-08-20 21:49:07 +02:00
Paul Fultz II a332062385
Add exprId to tokens (#2744) 2020-08-20 18:21:29 +02:00
Daniel Marjamäki 6446790d48
Merge pull request #2739 from dan-42/fix_ticket_9839_ast_error
Fix ticket 9839: AST broken; range for loop that uses decltype
2020-08-18 21:59:50 +02:00
Paul 7776fb82a2 Fix issue 737: new check: Dereference end iterator 2020-08-17 16:36:45 -05:00
Daniel Friedrich f413c9cad8 Improve handling of decltype( in for loops
Simplify pattern macht and token selection

Improve handling of decltype( in for loops
2020-08-17 20:52:14 +02:00
Paul e759508335 Remove reduntant condition 2020-08-13 10:10:26 -05:00
Paul a509de4d70 Add moves 2020-08-11 11:50:27 -05:00
Paul 96b74c57ff Remove useless condition 2020-08-11 11:26:40 -05:00
Paul 8c7e91c985 Remove old container forward 2020-08-10 22:09:33 -05:00
Paul 71c228a01a Check for containers that modify the size using square bracket 2020-08-10 22:07:22 -05:00
Paul a5b0a1c9e2 Evaluate container size in program memory 2020-08-10 20:08:49 -05:00
Paul fec2914700 Add tests for container changes 2020-08-09 22:52:03 -05:00
Paul 26693df788 Use forward analyzer for container forward 2020-08-08 00:10:03 -05:00
Daniel Marjamäki b263b93f73
Merge pull request #2732 from pfultz2/invalid-container-subobj
Fix issue 9780: FP: invalidContainer calling push_back after getting the address of the vector
2020-08-07 09:52:25 +02:00
Paul 56affc9080 Fix issue 9780: FP: invalidContainer calling push_back after getting the address of the vector 2020-08-06 21:08:30 -05:00
Daniel Marjamäki 5372e93964 Fixed #9825 (redundantAssignment: Do not warn about volatile data) 2020-08-06 22:18:25 +02:00
Paul 0cc1f69862 Fix issue 9770: FP returnDanglingLifetime for class method taking const char* and returning std::string 2020-08-05 23:17:35 -05:00
Daniel Marjamäki 72fa5f2e27 Fixed #9752 (ValueFlow: Uninit after assignment with '&') 2020-08-05 22:57:06 +02:00
Daniel Marjamäki d5b64d9c3a Clarify inconclusive uninitMemberVar warning in copy constructors, it's in general a good idea to copy all the data. 2020-08-05 13:57:40 +02:00
Daniel Marjamäki 7a85b8e452 Do not ask that calculation is clarified when different order would be invalid 2020-08-05 13:20:18 +02:00
Jens Yllman 10ac0bcf54 changed variable name to match guidelines 2020-07-29 12:13:21 +02:00
Jens Yllman 62f5f248be use simplifyPath() to make sure file name is same as in the checks 2020-07-28 22:19:27 +02:00
Daniel Marjamäki fa32624c93 ValueFlow: Avoid UB in shift when rhs is negative 2020-07-25 14:13:21 +02:00
Daniel Marjamäki fab3a8efc8
Merge pull request #2721 from KenPatrickLehrmann/compound_assign_bitshift
Add missing operators <<= and >>=
2020-07-25 09:39:32 +02:00
Daniel Marjamäki b4552dedb0 Fix Cppcheck warning 2020-07-24 19:58:36 +02:00
Daniel Marjamäki 6a839ad511 Fixed #9814 (False positive: functionConst, trailing return type) 2020-07-24 19:40:42 +02:00
Paul 46e008c3e2 Fixed #9816 (False positive: Condition '!b' is always false in nested do-while loop) 2020-07-24 08:13:14 +02:00
Daniel Marjamäki a11a0e79e4 Fixed Cppcheck internal warning 2020-07-23 18:54:40 +02:00
Ken-Patrick LEHRMANN a923115710 Add missing operators <<= and >>=
This fixes issues (at least false positives) in code using them.
For instance:

```
unsigned compute(unsigned long long a) {
    unsigned num = 0;
    while (a > 0xFFFFFFFF) {
      a >>= 32;
      num += 32;
    }
    if (a > 0xFFFF) {
      a >>= 16;
      num += 16;
    }
    if (a > 0xFF) {
      num += 8;
    }
    return num;
}
```

would give false positive:
```
cppcheck --enable=style  sl3.cpp
Checking sl3.cpp ...
sl3.cpp:11:11: style: Condition 'a>0xFF' is always false [knownConditionTrueFalse]
    if (a > 0xFF) {
          ^
sl3.cpp:3:14: note: Assuming that condition 'a>0xFFFFFFFF' is not redundant
    while (a > 0xFFFFFFFF) {
             ^
sl3.cpp:11:11: note: Condition 'a>0xFF' is always false
    if (a > 0xFF) {
          ^
```
2020-07-23 14:36:34 +02:00
Daniel Marjamäki 682a6d1c02 Fixed #9017 (Simple classes without side effects not reported as unused) 2020-07-23 11:10:08 +02:00
Daniel Marjamäki 25ad22c6af astyle formatting
[ci skip]
2020-07-23 10:09:06 +02:00
Daniel Marjamäki df99d8aa0a
Merge pull request #2719 from pfultz2/fp-unreachable-alias
Fix issue 9807: False positive: ValueFlow in unreachable code, || lhs is true
2020-07-23 09:52:54 +02:00
Daniel Marjamäki f4a6f8ad07
Merge pull request #2720 from pfultz2/crash-type-scope
Fix crash when typeScope is missing
2020-07-23 09:31:59 +02:00
Daniel Marjamäki 2fd44fa464
Merge pull request #2710 from pfultz2/fp-invalid-container-pointer
Fix issue 9796: False positive: lifetime, pointer item is not deallocated by pop_back
2020-07-22 09:24:54 +02:00
Paul 0def5d7a9a Reduce variable scope 2020-07-21 19:09:58 -05:00
Paul 3480aba35b Fix crash when typeScope is missing 2020-07-21 14:09:46 -05:00
Paul abeea7b32b Merge branch 'main' into fp-invalid-container-pointer 2020-07-21 13:31:13 -05:00
Paul dbb410cdae Merge branch 'main' into condition-in-expr 2020-07-21 13:28:59 -05:00
Paul 5bc5c96c8f Fix cppcheck error 2020-07-21 13:20:39 -05:00
Paul 38e1b57bc9 Use refs 2020-07-21 13:18:45 -05:00
Daniel Marjamäki aad455e1ea Fix compile error 2020-07-21 17:43:12 +02:00
Daniel Marjamäki 453cd93fae update warning hash calculation 2020-07-21 16:00:09 +02:00
Daniel Marjamäki 83be203d44
Merge pull request #2715 from rikardfalkeborn/refactor-use-visitastnodes-more
Refactor use visitastnodes more
2020-07-21 15:26:58 +02:00
Daniel Marjamäki 26c849b732
Merge pull request #2716 from rikardfalkeborn/refactor-use-simple-loop-instead-of-stack-in-checktype
Refactor: Simplify checkSignConversion
2020-07-21 15:26:03 +02:00
Daniel Marjamäki 4ab04db53c Rename 'cppcheckID' to 'hash' 2020-07-21 11:27:03 +02:00
Rikard Falkeborn 7973fd843c Refactor: Simplify checkSignConversion
The loop only checks astoperand1 and astoperand2. Simplify the condition
to loop over these instead of using a stack. Also, add a testcase for
when astoperand2 is negative.
2020-07-20 11:16:56 +02:00
Rikard Falkeborn ed36856451 Refactor: Use visitAstNodes in checkuninitvar 2020-07-20 11:03:52 +02:00
Rikard Falkeborn 9ced26a7a1 Refactor: Use visitAstNodes in checkcondition 2020-07-20 11:03:29 +02:00
Rikard Falkeborn 82fe6193fa Refactor: Use visitAstNodes in checkstring 2020-07-20 10:25:00 +02:00
Rikard Falkeborn 2ace2b006a Refactor: Use visitAstNodes in checkleakautovar 2020-07-20 10:25:00 +02:00
Paul e2a81a382f Track reading aliases during valueflow forward 2020-07-19 23:25:35 -05:00
Daniel Marjamäki 4a76dbb632 Bug hunting; Avoid bailout uninit FP, stream object 2020-07-19 16:54:44 +02:00