Commit Graph

481 Commits

Author SHA1 Message Date
chrchr-github 04b7c0c200
Fix #11404 FP knownConditionTrueFalse with iterator (#4619)
* Fix wrong value set in valueFlowSameExpressions()

* Fix  #11404 FP knownConditionTrueFalse with iterator
2022-12-08 10:40:55 +01:00
chrchr-github 8713dabe58
Get type from iterator (#4613) 2022-12-07 09:38:36 +01:00
chrchr-github 89dba226dd
Fix #11305 FP uninitvar with unseen typedef (#4612) 2022-12-07 09:14:22 +01:00
chrchr-github 4cb49013a7
Fix #11374 FP danglingTemporaryLifetime with std::string_view (#4602) 2022-11-27 09:22:55 +01:00
Oliver Stöneberg 7ead32f96e
various optimizations (#4535)
* avoid potentially duplicated `strTolower()` call in `Path::getFilenameExtensionInLowerCase()`

* avoid unnecessary copies

* use `unordered_*` containers for faster lookups

* symboldatabase.cpp: do not perform call in `checkReturns()` until needed

* astutils.cpp: do not perform calls in `isVariableChangedByFunctionCall()` until necessary

* tokenize.cpp: small `hasIfDef()` optimization

* use `unordered_map` for `CheckUnusedFunctions::FunctionUsage::mFunctions` / adjusted test case
2022-10-06 20:12:07 +02:00
Oliver Stöneberg cff1cd9cda
applied clang-tidy `misc-const-correctness` fixes for POD types, iterators and references (#4529)
* applied `misc-const-correctness` fixes for POD types and iterators

* applied `misc-const-correctness` fixes for references
2022-10-02 07:12:40 +02:00
Oliver Stöneberg 0481edf9c3
return `SmallVector` from `followAllReferences()` (#3925) 2022-09-29 21:41:32 +02:00
Oliver Stöneberg 339484d2a1
mitigated and enabled more clang-tidy warnings (#4470)
* fixed some `performance-inefficient-string-concatenation` clang-tidy warnings

* fixed and enabled `modernize-replace-random-shuffle` clang-tidy warning

* fixed and enabled `bugprone-suspicious-string-compare` clang-tidy warning

* mitigated and enabled `readability-non-const-parameter` clang-tidy warnings

* clang-tidy.md: documented some disabled checks

* mitigated and enabled `performance-unnecessary-value-param` clang-tidy warnings
2022-09-16 18:58:59 +02:00
Oliver Stöneberg b3ec225480
iwyu.yml: use `debian:unstable` to always get latest include-what-you-use / cleaned up includes (#4466)
* iwyu.yml: use debian:unstable to always get latest include-what-you-use

* cleaned up includes based on include-what-you-use

* mitigated include-what-you-use false positives
2022-09-16 07:15:49 +02:00
Paul Fultz II 43caa32abf
Fix 9755: false negative: access of moved variable in conditional code (#4459)
* Fix 9755: false negative: access of moved variable in conditional code

* Format
2022-09-11 12:32:01 +02:00
Paul Fultz II 117a753b10
Partial fix 11154: FN: knownConditionTrueFalse (#4453)
* Partial fix 11154: FN: knownConditionTrueFalse

* Formay

* Add more tests

* FOrmat

* Fix FP

* Add test

* Check for side effects

* Format

* Update tests

* Format
2022-09-08 22:08:38 +02:00
Oliver Stöneberg d46ea7ba86
avoid unnecessary copies with `push_back()` and `push_front()` (#4451) 2022-09-08 09:21:35 +02:00
Oliver Stöneberg 436b8bd3f1
optimized `isSameConstantValue()` a bit (#4441) 2022-09-05 21:36:26 +02:00
Paul Fultz II 6ce5c24f21
Refactor knownConditionTrueFalse check and isUsedAsBool function (#4432)
* Refactor knownConditionTrueFalse check and isUsedAsBool function

* Format1

* Format

* Skip assign
2022-09-04 10:24:45 +02:00
Maksim Derbasov f93b588603
New check: use memcpy/memset instead of loop (#4257) 2022-09-03 23:29:06 +02:00
Oliver Stöneberg 9b4973d711
astutils.cpp: some small optimizations (#4378) 2022-08-21 17:39:21 +02:00
Daniel Marjamäki c820d2ba97 refactoring 2022-08-21 17:33:43 +02:00
PKEuS d81a758850
LCppC backports: Refactorizations/Optimizations (#4204) 2022-08-21 17:21:02 +02:00
chrchr-github b04bf7396f
Fix #7515 New check: Not needed c_str() operation (#4371) 2022-08-20 20:52:10 +02:00
Oliver Stöneberg d73a33d17e
avoid redundant `Token::declEndToken()` calls (#4363) 2022-08-20 20:50:14 +02:00
Oliver Stöneberg 0f0c4061ff
astutils.cpp: avoid redundant callback invocation in `isExpressionChangedAt()` (#4369) 2022-08-17 13:50:39 +02:00
Oliver Stöneberg f7caf7dc93
avoid some unnecessary `std::string()` construction in comparisons (#4357)
* avoid unnecessary string wrapping

* consistently use `strcmp()`
2022-08-14 12:44:09 +02:00
chrchr-github bdbd84ba98
#11238: Fix regression (#4349)
* Fix #11238 FP knownConditionTrueFalse with constexpr?

* Modify isConstVarExpression()

* Use predicate

* Format

* #11238: Fix regression
2022-08-09 13:13:16 +02:00
chrchr-github 078a6d7804
Fix #11238 FP knownConditionTrueFalse with constexpr? (#4341) 2022-08-07 19:06:19 +02:00
chrchr-github 92d569afb6
#11233 FP: knownConditionTrueFalse (wrong message text) (#4330)
* #11233 FP: knownConditionTrueFalse (wrong message text)

* Format

* Update testcondition.cpp

* Trigger CI
2022-08-02 18:18:46 +02:00
chrchr-github 479533a80a
Rework fix for #11008 (#4296) 2022-07-24 12:15:04 +02:00
chrchr-github c736fe8787
Fix #11008 FP doubleFree with pointer in struct (#4294) 2022-07-19 20:41:08 +02:00
chrchr-github f5c4a21eae
Fix #10704 FN redundantCopyLocalConst (#4115) 2022-07-10 11:33:24 +02:00
Paul Fultz II a2f2699088
Refactor alias check in isExpressionChangeAt into isAlias function (#4223) 2022-06-28 22:40:59 +02:00
Paul Fultz II e735376f7d
Refactor to use AST for isContainerSizeChanged (#4222) 2022-06-19 08:17:05 +02:00
Paul Fultz II de51ebbcf4
Fix 9135: Access of moved variable not detected in loop (#4215)
* Fix 9135: Access of moved variable not detected in loop

* Format

* Fix issue with pushing back on container

* Format

* Fix null pointer

* Remove yeild for now
2022-06-16 17:40:09 +02:00
chrchr-github 51c8630bb3
Fix #10618 FP knownConditionTrueFalse with virtual function (#4194)
* Fix #10618 FP knownConditionTrueFalse with virtual function

* Remove redundant check
2022-06-10 20:17:57 +02:00
PKEuS 1275b5275e
LCppC backport: Various optimizations (#4182)
* Optimization: Use Token::eIncDecOp instead of expensive Token::Match calls

Merged from LCppC.

* Small Optimizations: - Moved a std::set that is only need during initialization of SymbolDatabase to function scope - Use std::vector instead of std::list

Merged from LCppC.

* Optimization: Refactorized various Token::Match calls and surrounding conditions

Merged from LCppC.

* Refactorization: Cleanup usage of std::multimap

Merged from LCppC.
2022-06-08 16:58:57 +02:00
chrchr-github e6f2929fac
Fix #11085 FN constVariable with range-based for (#4118) 2022-06-03 19:24:59 +02:00
orbitcowboy 9b0f41e1a0 Revert change 3dfe9eff3e (commitcomment-75236431). 2022-06-03 10:22:29 +02:00
orbitcowboy c24edc528e astutils.cpp: Removed useless parentheses 2022-06-03 00:18:35 +02:00
orbitcowboy 3dfe9eff3e astutils.cpp: Improved const correctness 2022-06-03 00:07:15 +02:00
Oliver Stöneberg 3d5d2e8fd8
inlined `findAstNode()` calls (#4146) 2022-05-31 13:37:21 +02:00
chrchr-github 7fbb9c7c13
Fix #10980 FN constVariable with range-based for loop (#4144)
* Fix #10980 FN constVariable with range-based for loop

* Format

* nullptr check

* Restrict scopes

* Add const

* Undo

* Add more const
2022-05-29 17:06:33 +02:00
Paul Fultz II feaef46436
Fix 11076: Assert failure / crash with loop over init list (#4119) 2022-05-21 08:25:09 +02:00
Paul Fultz II fbba72ab5a
Fix 11057: FP danglingTemporaryLifetime with reference member (#4103)
* Fix 11057: FP danglingTemporaryLifetime with reference member

* Add test

* Format

* Use ast for number of arguments

* Get number of arguments using ast

* Skip aggregate constructor when there are too many arguments

* Format
2022-05-13 06:51:07 +02:00
Paul Fultz II 5d8da2b83c
Fix 11035: FP arrayIndexOutOfBoundsCond with array and vector (#4105)
* Fix 11035: FP arrayIndexOutOfBoundsCond with array and vector

* Format

* Move comment
2022-05-12 06:21:33 +02:00
chrchr-github 63a1698335
Fix #11059 FP multiCondition when variable is assigned in if/else (#4102) 2022-05-11 20:01:13 +02:00
Paul Fultz II 69f09da63e
Fix 11044: FP knownConditionTrueFalse after early return (#4091)
* Fix 11044: FP knownConditionTrueFalse after early return

* Format
2022-05-09 20:26:52 +02:00
chrchr-github adba751217
Fix #11018 FP uninitvar with redundant pointer op (#4082)
* Skip redundant pointer op

* Fix  #11018 FP uninitvar with redundant pointer op

* Format
2022-05-05 06:54:27 +02:00
chrchr-github e2069dd1b9
Fix #10650 FN knownConditionTrueFalse with const int value (#4078) 2022-05-04 14:25:00 +02:00
chrchr-github 509e42afd4
Fix #11034 FN duplicateCondition with struct member (#4074)
* Fix #11034 FN duplicateCondition with struct member

* Update testcondition.cpp
2022-05-03 19:57:30 +02:00
Paul Fultz II aafd1e10be
Fix 11006: FP uninitvar with unknown constant (#4056) 2022-04-28 10:48:37 +02:00
Paul Fultz II d97942d3c6
Fix 6577: Detect pointer to uninitialised memory with clock_settime() (#3993)
* Fix 6577: Detect pointer to uninitialised memory with clock_settime()

* Format
2022-04-11 07:23:44 +02:00
chrchr-github 52b4aeb279
Fix #10792 FP knownConditionTrueFalse with double to int cast (#3964) 2022-04-07 10:42:57 +02:00