Skip to content

Commit 4b42156

Browse files
py023Doris-Extras
authored andcommitted
[chore](clang-tidy): add bugprone linters (#29521)
This PR introduces 4 bugprone linter rules to .clang-tidy, these linters found some bugs in #28965. This PR also add some comments to mute false positive reports.
1 parent 7840e7c commit 4b42156

8 files changed

Lines changed: 27 additions & 18 deletions

File tree

‎.clang-tidy‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Checks: |
44
clang-diagnostic-*,
55
clang-analyzer-*,
66
bugprone-redundant-branch-condition,
7+
bugprone-use-after-move,
8+
bugprone-bool-pointer-implicit-conversion,
9+
bugprone-unused-raii,
10+
bugprone-fold-init-type,
711
modernize-*,
812
-modernize-use-trailing-return-type,
913
-modernize-use-nodiscard,
@@ -24,10 +28,9 @@ Checks: |
2428
performance-faster-string-find,
2529
performance-inefficient-algorithm,
2630
performance-move-const-arg
27-
WarningsAsErrors: '*'
31+
WarningsAsErrors: "*"
2832
CheckOptions:
29-
- key: readability-function-size.LineThreshold
30-
value: '80'
31-
- key: readability-function-cognitive-complexity.Threshold
32-
value: '50'
33-
33+
- key: readability-function-size.LineThreshold
34+
value: "80"
35+
- key: readability-function-cognitive-complexity.Threshold
36+
value: "50"

‎be/src/olap/rowset/segment_creator.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ Status SegmentFlusher::_expand_variant_to_subcolumns(vectorized::Block& block,
218218
VLOG_DEBUG << "dump rs schema: " << _context->tablet_schema->dump_structure();
219219
}
220220

221-
block.swap(flush_block);
221+
block.swap(flush_block); // NOLINT(bugprone-use-after-move)
222222
VLOG_DEBUG << "dump block: " << block.dump_data();
223223
VLOG_DEBUG << "dump flush schema: " << flush_schema->dump_structure();
224224
return Status::OK();

‎be/src/service/backend_service.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ void _ingest_binlog(IngestBinlogArg* arg) {
224224
}
225225

226226
// Step 5.2: check data capacity
227-
uint64_t total_size = std::accumulate(segment_file_sizes.begin(), segment_file_sizes.end(), 0);
227+
uint64_t total_size = std::accumulate(segment_file_sizes.begin(), segment_file_sizes.end(),
228+
0); // NOLINT(bugprone-fold-init-type)
228229
if (!local_tablet->can_add_binlog(total_size)) {
229230
LOG(WARNING) << "failed to add binlog, no enough space, total_size=" << total_size
230231
<< ", tablet=" << local_tablet->tablet_id();

‎be/src/vec/common/hash_table/hash_table.h‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -611,10 +611,11 @@ class HashTable : private boost::noncopyable,
611611
std::swap(_need_partition, rhs._need_partition);
612612
std::swap(_partitioned_threshold, rhs._partitioned_threshold);
613613

614-
Hash::operator=(std::move(rhs));
615-
Allocator::operator=(std::move(rhs));
616-
Cell::State::operator=(std::move(rhs));
617-
ZeroValueStorage<Cell::need_zero_value_storage, Cell>::operator=(std::move(rhs));
614+
Hash::operator=(std::move(rhs)); // NOLINT(bugprone-use-after-move)
615+
Allocator::operator=(std::move(rhs)); // NOLINT(bugprone-use-after-move)
616+
Cell::State::operator=(std::move(rhs)); // NOLINT(bugprone-use-after-move)
617+
ZeroValueStorage<Cell::need_zero_value_storage, Cell>::operator=(
618+
std::move(rhs)); // NOLINT(bugprone-use-after-move)
618619

619620
return *this;
620621
}

‎be/src/vec/exec/format/orc/vorc_reader.cpp‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,8 +1938,10 @@ Status OrcReader::on_string_dicts_loaded(
19381938
auto data_type = slot_desc->get_data_type_ptr();
19391939
if (data_type->is_nullable()) {
19401940
temp_block.insert(
1941-
{ColumnNullable::create(std::move(dict_value_column),
1942-
ColumnUInt8::create(dict_value_column_size, 0)),
1941+
{ColumnNullable::create(
1942+
std::move(
1943+
dict_value_column), // NOLINT(bugprone-use-after-move)
1944+
ColumnUInt8::create(dict_value_column_size, 0)),
19431945
std::make_shared<DataTypeNullable>(std::make_shared<DataTypeString>()),
19441946
""});
19451947
} else {

‎be/src/vec/exec/format/parquet/vparquet_group_reader.cpp‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,8 +800,10 @@ Status RowGroupReader::_rewrite_dict_predicates() {
800800
auto data_type = slot_desc->get_data_type_ptr();
801801
if (data_type->is_nullable()) {
802802
temp_block.insert(
803-
{ColumnNullable::create(std::move(dict_value_column),
804-
ColumnUInt8::create(dict_value_column_size, 0)),
803+
{ColumnNullable::create(
804+
std::move(
805+
dict_value_column), // NOLINT(bugprone-use-after-move)
806+
ColumnUInt8::create(dict_value_column_size, 0)),
805807
std::make_shared<DataTypeNullable>(std::make_shared<DataTypeString>()),
806808
""});
807809
} else {

‎be/src/vec/exec/scan/new_olap_scan_node.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ Status NewOlapScanNode::_init_scanners(std::list<VScannerSPtr>* scanners) {
648648
}
649649

650650
const auto max_add_seg_nums = rs_seg_count[rowset_idx] - segment_idx_to_scan;
651-
auto& split = rs_splits.emplace_back();
651+
auto& split = rs_splits.emplace_back(); // NOLINT(bugprone-use-after-move)
652652
split.rs_reader = read_source.rs_splits[rowset_idx].rs_reader->clone();
653653

654654
// if segments assigned to current scanner are already more than the average count,

‎be/src/vec/functions/function.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ ColumnPtr wrap_in_nullable(const ColumnPtr& src, const Block& block, const Colum
6262
if (const auto* nullable = assert_cast<const ColumnNullable*>(elem.column.get());
6363
nullable->has_null()) {
6464
const ColumnPtr& null_map_column = nullable->get_null_map_column_ptr();
65-
if (!result_null_map_column) {
65+
if (!result_null_map_column) { // NOLINT(bugprone-use-after-move)
6666
result_null_map_column = null_map_column->clone_resized(input_rows_count);
6767
continue;
6868
}

0 commit comments

Comments
 (0)