Skip to content

[smart_holder] clang-tidy fixes (related to recent clang-tidy changes on master). #3053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ jobs:
-DCMAKE_CXX_STANDARD=17

- name: Build
run: cmake --build build -j 2
run: cmake --build build -j 2 -- --keep-going
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. It was indeed super annoying to not get all the clang-tidy errors.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Skylion007 Do you prefer to adopt this in your PR #3051, or do you think it's better if I open a mini PR to add this to master?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopting

6 changes: 3 additions & 3 deletions include/pybind11/detail/smart_holder_poc.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct smart_holder {
vptr_is_external_shared_ptr{false}, is_populated{false}, is_disowned{false},
pointee_depends_on_holder_owner{false} {}

bool has_pointee() const { return vptr.get() != nullptr; }
bool has_pointee() const { return vptr != nullptr; }

template <typename T>
static void ensure_pointee_is_destructible(const char *context) {
Expand Down Expand Up @@ -180,7 +180,7 @@ struct smart_holder {
}

void ensure_use_count_1(const char *context) const {
if (vptr.get() == nullptr) {
if (vptr == nullptr) {
throw std::invalid_argument(std::string("Cannot disown nullptr (") + context + ").");
}
// In multithreaded environments accessing use_count can lead to
Expand All @@ -194,7 +194,7 @@ struct smart_holder {
}
}

void reset_vptr_deleter_armed_flag(bool armed_flag) {
void reset_vptr_deleter_armed_flag(bool armed_flag) const {
auto vptr_del_ptr = std::get_deleter<guarded_delete>(vptr);
if (vptr_del_ptr == nullptr) {
throw std::runtime_error(
Expand Down