Update clang-tidy. (#10730)
- Install cmake using pip. - Fix compile command generation. - Clean up the tidy script and remove the need to load the yaml file. - Fix modernized type traits. - Fix span class. Polymorphism support is dropped
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright 2020-2024, XGBoost contributors
|
||||
*/
|
||||
#include <gtest/gtest.h>
|
||||
#include <xgboost/intrusive_ptr.h>
|
||||
|
||||
@@ -12,10 +15,8 @@ class NotCopyConstructible {
|
||||
NotCopyConstructible &operator=(NotCopyConstructible const &that) = delete;
|
||||
NotCopyConstructible(NotCopyConstructible&& that) = default;
|
||||
};
|
||||
static_assert(
|
||||
!std::is_trivially_copy_constructible<NotCopyConstructible>::value);
|
||||
static_assert(
|
||||
!std::is_trivially_copy_assignable<NotCopyConstructible>::value);
|
||||
static_assert(!std::is_trivially_copy_constructible_v<NotCopyConstructible>);
|
||||
static_assert(!std::is_trivially_copy_assignable_v<NotCopyConstructible>);
|
||||
|
||||
class ForIntrusivePtrTest {
|
||||
public:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright 2018-2023, XGBoost contributors
|
||||
* Copyright 2018-2024, XGBoost contributors
|
||||
*/
|
||||
#include "test_span.h"
|
||||
|
||||
@@ -174,19 +174,11 @@ TEST(Span, FromFirstLast) {
|
||||
}
|
||||
}
|
||||
|
||||
struct BaseClass {
|
||||
virtual void operator()() {}
|
||||
};
|
||||
struct DerivedClass : public BaseClass {
|
||||
void operator()() override {}
|
||||
};
|
||||
|
||||
TEST(Span, FromOther) {
|
||||
|
||||
// convert constructor
|
||||
{
|
||||
Span<DerivedClass> derived;
|
||||
Span<BaseClass> base { derived };
|
||||
Span<int> derived;
|
||||
Span<int const> base{derived};
|
||||
ASSERT_EQ(base.size(), derived.size());
|
||||
ASSERT_EQ(base.data(), derived.data());
|
||||
}
|
||||
|
||||
@@ -93,11 +93,11 @@ TEST(Adapter, CSCAdapterColsMoreThanRows) {
|
||||
|
||||
// A mock for JVM data iterator.
|
||||
class CSRIterForTest {
|
||||
std::vector<float> data_ {1, 2, 3, 4, 5};
|
||||
std::vector<std::remove_pointer<decltype(std::declval<XGBoostBatchCSR>().index)>::type>
|
||||
feature_idx_ {0, 1, 0, 1, 1};
|
||||
std::vector<std::remove_pointer<decltype(std::declval<XGBoostBatchCSR>().offset)>::type>
|
||||
row_ptr_ {0, 2, 4, 5, 5};
|
||||
std::vector<float> data_{1, 2, 3, 4, 5};
|
||||
std::vector<std::remove_pointer_t<decltype(std::declval<XGBoostBatchCSR>().index)>> feature_idx_{
|
||||
0, 1, 0, 1, 1};
|
||||
std::vector<std::remove_pointer_t<decltype(std::declval<XGBoostBatchCSR>().offset)>> row_ptr_{
|
||||
0, 2, 4, 5, 5};
|
||||
size_t iter_ {0};
|
||||
|
||||
public:
|
||||
|
||||
@@ -49,7 +49,7 @@ void TestSparseDMatrixLoadFile(Context const* ctx) {
|
||||
1};
|
||||
Page out;
|
||||
for (auto const &page : m.GetBatches<Page>(ctx)) {
|
||||
if (std::is_same<Page, SparsePage>::value) {
|
||||
if (std::is_same_v<Page, SparsePage>) {
|
||||
out.Push(page);
|
||||
} else {
|
||||
out.PushCSC(page);
|
||||
@@ -89,7 +89,7 @@ void TestRetainPage() {
|
||||
for (auto it = begin; it != end; ++it) {
|
||||
iterators.push_back(it.Page());
|
||||
pages.emplace_back(Page{});
|
||||
if (std::is_same<Page, SparsePage>::value) {
|
||||
if (std::is_same_v<Page, SparsePage>) {
|
||||
pages.back().Push(*it);
|
||||
} else {
|
||||
pages.back().PushCSC(*it);
|
||||
@@ -105,7 +105,7 @@ void TestRetainPage() {
|
||||
|
||||
// make sure it's const and the caller can not modify the content of page.
|
||||
for (auto &page : p_fmat->GetBatches<Page>({&ctx})) {
|
||||
static_assert(std::is_const<std::remove_reference_t<decltype(page)>>::value);
|
||||
static_assert(std::is_const_v<std::remove_reference_t<decltype(page)>>);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ TEST(SparsePageDMatrix, RetainEllpackPage) {
|
||||
|
||||
// make sure it's const and the caller can not modify the content of page.
|
||||
for (auto& page : m->GetBatches<EllpackPage>(&ctx, param)) {
|
||||
static_assert(std::is_const<std::remove_reference_t<decltype(page)>>::value);
|
||||
static_assert(std::is_const_v<std::remove_reference_t<decltype(page)>>);
|
||||
}
|
||||
|
||||
// The above iteration clears out all references inside DMatrix.
|
||||
|
||||
@@ -62,7 +62,7 @@ void TestPartitioner(bst_target_t n_targets) {
|
||||
auto ptr = gmat.cut.Ptrs()[split_ind + 1];
|
||||
float split_value = gmat.cut.Values().at(ptr / 2);
|
||||
RegTree tree{n_targets, n_features};
|
||||
if constexpr (std::is_same<ExpandEntry, CPUExpandEntry>::value) {
|
||||
if constexpr (std::is_same_v<ExpandEntry, CPUExpandEntry>) {
|
||||
GetSplit(&tree, split_value, &candidates);
|
||||
} else {
|
||||
GetMultiSplitForTest(&tree, split_value, &candidates);
|
||||
@@ -119,7 +119,7 @@ void VerifyColumnSplitPartitioner(bst_target_t n_targets, size_t n_samples,
|
||||
{
|
||||
RegTree tree{n_targets, n_features};
|
||||
CommonRowPartitioner partitioner{&ctx, n_samples, base_rowid, true};
|
||||
if constexpr (std::is_same<ExpandEntry, CPUExpandEntry>::value) {
|
||||
if constexpr (std::is_same_v<ExpandEntry, CPUExpandEntry>) {
|
||||
GetSplit(&tree, min_value, &candidates);
|
||||
} else {
|
||||
GetMultiSplitForTest(&tree, min_value, &candidates);
|
||||
@@ -132,7 +132,7 @@ void VerifyColumnSplitPartitioner(bst_target_t n_targets, size_t n_samples,
|
||||
{
|
||||
RegTree tree{n_targets, n_features};
|
||||
CommonRowPartitioner partitioner{&ctx, n_samples, base_rowid, true};
|
||||
if constexpr (std::is_same<ExpandEntry, CPUExpandEntry>::value) {
|
||||
if constexpr (std::is_same_v<ExpandEntry, CPUExpandEntry>) {
|
||||
GetSplit(&tree, mid_value, &candidates);
|
||||
} else {
|
||||
GetMultiSplitForTest(&tree, mid_value, &candidates);
|
||||
@@ -187,7 +187,7 @@ void TestColumnSplitPartitioner(bst_target_t n_targets) {
|
||||
auto ptr = gmat.cut.Ptrs()[split_ind + 1];
|
||||
mid_value = gmat.cut.Values().at(ptr / 2);
|
||||
RegTree tree{n_targets, n_features};
|
||||
if constexpr (std::is_same<ExpandEntry, CPUExpandEntry>::value) {
|
||||
if constexpr (std::is_same_v<ExpandEntry, CPUExpandEntry>) {
|
||||
GetSplit(&tree, mid_value, &candidates);
|
||||
} else {
|
||||
GetMultiSplitForTest(&tree, mid_value, &candidates);
|
||||
|
||||
Reference in New Issue
Block a user