This is an automated email from the ASF dual-hosted git repository.
twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new e2d637c0 Add used-after-move checking to clang-tidy (#1566)
e2d637c0 is described below
commit e2d637c0004d6eb217d7305f77e639c4bb31ced3
Author: mwish <[email protected]>
AuthorDate: Mon Jul 10 11:31:37 2023 +0800
Add used-after-move checking to clang-tidy (#1566)
clang-tidy has a `bugprone` checkings under:
https://releases.llvm.org/14.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/list.html
. I've checked all `bugprone-`, the result contains many style fixing.
This patch only adds a `bugprone-use-after-move` into clang-tidy. It detect
a `used-after-move` in `src/storage/compaction_checker.cc`, moving
`rocksdb::Slice` doesn't clear it contents.
---
.clang-tidy | 4 ++--
src/storage/compaction_checker.cc | 6 ++++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/.clang-tidy b/.clang-tidy
index fe9e3fb5..ccc27aec 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -1,7 +1,7 @@
# refer to https://clang.llvm.org/extra/clang-tidy/checks/list.html
-Checks: -*, clang-analyzer-core.*, clang-analyzer-cplusplus.*,
clang-analyzer-deadcode.*, clang-analyzer-nullability.*,
clang-analyzer-security.*, clang-analyzer-unix.*, clang-analyzer-valist.*,
cppcoreguidelines-init-variables, cppcoreguidelines-macro-usage,
cppcoreguidelines-interfaces-global-init,
cppcoreguidelines-narrowing-conversions, cppcoreguidelines-no-malloc,
cppcoreguidelines-prefer-member-initializer,
cppcoreguidelines-special-member-functions, cppcoreguidelines-slicing, goog
[...]
+Checks: -*, clang-analyzer-core.*, clang-analyzer-cplusplus.*,
clang-analyzer-deadcode.*, clang-analyzer-nullability.*,
clang-analyzer-security.*, clang-analyzer-unix.*, clang-analyzer-valist.*,
cppcoreguidelines-init-variables, cppcoreguidelines-macro-usage,
cppcoreguidelines-interfaces-global-init,
cppcoreguidelines-narrowing-conversions, cppcoreguidelines-no-malloc,
cppcoreguidelines-prefer-member-initializer,
cppcoreguidelines-special-member-functions, cppcoreguidelines-slicing, goog
[...]
-WarningsAsErrors: clang-analyzer-*, -clang-analyzer-security.insecureAPI.rand,
google-*, performance-*, cppcoreguidelines-*, modernize-*, readability-*
+WarningsAsErrors: clang-analyzer-*, -clang-analyzer-security.insecureAPI.rand,
google-*, performance-*, cppcoreguidelines-*, modernize-*, readability-*,
bugprone-*
CheckOptions:
- key:
cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
diff --git a/src/storage/compaction_checker.cc
b/src/storage/compaction_checker.cc
index 5e3287b7..366762c4 100644
--- a/src/storage/compaction_checker.cc
+++ b/src/storage/compaction_checker.cc
@@ -126,8 +126,10 @@ void CompactionChecker::PickCompactionFiles(const
std::string &cf_name) {
if (total_keys != 0 && delete_ratio > best_delete_ratio) {
best_delete_ratio = delete_ratio;
best_filename = iter.first;
- best_start_key = std::move(start_key);
- best_stop_key = std::move(stop_key);
+ best_start_key = start_key;
+ start_key.clear();
+ best_stop_key = stop_key;
+ stop_key.clear();
}
}
if (best_delete_ratio > 0.1 && !best_start_key.empty() &&
!best_stop_key.empty()) {