Skip to content

EXPERIMENTAL clang-tidy readability-braces-around-statements - #3698

Closed
rwgk wants to merge 7 commits into
pybind:masterfrom
rwgk:clang-tidy_readability-braces-around-statements
Closed

EXPERIMENTAL clang-tidy readability-braces-around-statements#3698
rwgk wants to merge 7 commits into
pybind:masterfrom
rwgk:clang-tidy_readability-braces-around-statements

Conversation

@rwgk

@rwgkrwgk commented Feb 7, 2022

Copy link
Copy Markdown
Collaborator

Description

The work under this experimental PR was used to inform PR #3699.

Suggested changelog entry:

@rwgk
rwgkforce-pushed the clang-tidy_readability-braces-around-statements branch from 47df05c to ffa3eedCompareFebruary 7, 2022 20:34
@rwgk

rwgk commented Feb 7, 2022

Copy link
Copy Markdown
CollaboratorAuthor

Just for entertainment, this

(original)

 #if defined(__cpp_aligned_new) && (!defined(_MSC_VER) || _MSC_VER >= 1912)
if (type->type_align > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
vptr = ::operator new(type->type_size,
std::align_val_t(type->type_align));
else
#endif
vptr = ::operator new(type->type_size);

really threw

  1. clang-tidy
 #if defined(__cpp_aligned_new) && (!defined(_MSC_VER) || _MSC_VER >= 1912)
if (type->type_align > __STDCPP_DEFAULT_NEW_ALIGNMENT__) {
vptr = ::operator new(type->type_size, std::align_val_t(type->type_align));
} else {
#endif
vptr = ::operator new(type->type_size);
}
  1. me
#if defined(__cpp_aligned_new) && (!defined(_MSC_VER) || _MSC_VER >= 1912)
if (type->type_align > __STDCPP_DEFAULT_NEW_ALIGNMENT__) {
vptr = ::operator new(type->type_size, std::align_val_t(type->type_align));
} else {
vptr = ::operator new(type->type_size);
}
#endif

into a tail spin.

Note that clang-tidy made several other mistakes around other #ifdefs, and that I had no awareness of the original when I looked at 1. above.

Final correctly working version:

#if defined(__cpp_aligned_new) && (!defined(_MSC_VER) || _MSC_VER >= 1912)
if (type->type_align > __STDCPP_DEFAULT_NEW_ALIGNMENT__) {
vptr = ::operator new(type->type_size, std::align_val_t(type->type_align));
} else {
vptr = ::operator new(type->type_size);
}
#else
vptr = ::operator new(type->type_size);
#endif

rwgk added a commit to rwgk/pybind11 that referenced this pull request Feb 8, 2022
@rwgkrwgk changed the title clang-tidy readability-braces-around-statementsEXPERIMENTAL clang-tidy readability-braces-around-statementsFeb 8, 2022
@rwgkrwgk closed this Feb 8, 2022
rwgk added a commit to rwgk/pybind11 that referenced this pull request Feb 8, 2022
rwgk added a commit that referenced this pull request Feb 8, 2022
@rwgk
rwgk deleted the clang-tidy_readability-braces-around-statements branch February 8, 2022 21:06
@rwgkrwgk mentioned this pull request Feb 10, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@rwgk