mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +00:00
chore: update clang-tidy to 15 (#4387)
* chore: update clang-tidy to 15 * Add git * Add NOLINTNEXTLINE for assignment in if * Update CONTRIBUTING.md * Add NOLINTNEXTLINE where needed * Add one more NOLINTNEXTLINE * stl_bind: make more readable * Another missing NOLINTNEXTLINE * Match style elsewhere * Apply reviewer suggestion. Mark false positive
This commit is contained in:
parent
0694ec6a15
commit
7f23e9f3a4
4
.github/CONTRIBUTING.md
vendored
4
.github/CONTRIBUTING.md
vendored
@ -235,8 +235,8 @@ directory inside your pybind11 git clone. Files will be modified in place,
|
||||
so you can use git to monitor the changes.
|
||||
|
||||
```bash
|
||||
docker run --rm -v $PWD:/mounted_pybind11 -it silkeh/clang:13
|
||||
apt-get update && apt-get install -y python3-dev python3-pytest
|
||||
docker run --rm -v $PWD:/mounted_pybind11 -it silkeh/clang:15-bullseye
|
||||
apt-get update && apt-get install -y git python3-dev python3-pytest
|
||||
cmake -S /mounted_pybind11/ -B build -DCMAKE_CXX_CLANG_TIDY="$(which clang-tidy);--use-color" -DDOWNLOAD_EIGEN=ON -DDOWNLOAD_CATCH=ON -DCMAKE_CXX_STANDARD=17
|
||||
cmake --build build -j 2
|
||||
```
|
||||
|
4
.github/workflows/format.yml
vendored
4
.github/workflows/format.yml
vendored
@ -38,12 +38,12 @@ jobs:
|
||||
# in .github/CONTRIBUTING.md and update as needed.
|
||||
name: Clang-Tidy
|
||||
runs-on: ubuntu-latest
|
||||
container: silkeh/clang:13
|
||||
container: silkeh/clang:15-bullseye
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install requirements
|
||||
run: apt-get update && apt-get install -y python3-dev python3-pytest
|
||||
run: apt-get update && apt-get install -y git python3-dev python3-pytest
|
||||
|
||||
- name: Configure
|
||||
run: >
|
||||
|
@ -469,12 +469,14 @@ PYBIND11_NOINLINE internals &get_internals() {
|
||||
#if defined(WITH_THREAD)
|
||||
|
||||
PyThreadState *tstate = PyThreadState_Get();
|
||||
// NOLINTNEXTLINE(bugprone-assignment-in-if-condition)
|
||||
if (!PYBIND11_TLS_KEY_CREATE(internals_ptr->tstate)) {
|
||||
pybind11_fail("get_internals: could not successfully initialize the tstate TSS key!");
|
||||
}
|
||||
PYBIND11_TLS_REPLACE_VALUE(internals_ptr->tstate, tstate);
|
||||
|
||||
# if PYBIND11_INTERNALS_VERSION > 4
|
||||
// NOLINTNEXTLINE(bugprone-assignment-in-if-condition)
|
||||
if (!PYBIND11_TLS_KEY_CREATE(internals_ptr->loader_life_support_tls_key)) {
|
||||
pybind11_fail("get_internals: could not successfully initialize the "
|
||||
"loader_life_support TSS key!");
|
||||
@ -514,6 +516,7 @@ struct local_internals {
|
||||
struct shared_loader_life_support_data {
|
||||
PYBIND11_TLS_KEY_INIT(loader_life_support_tls_key)
|
||||
shared_loader_life_support_data() {
|
||||
// NOLINTNEXTLINE(bugprone-assignment-in-if-condition)
|
||||
if (!PYBIND11_TLS_KEY_CREATE(loader_life_support_tls_key)) {
|
||||
pybind11_fail("local_internals: could not successfully initialize the "
|
||||
"loader_life_support TLS key!");
|
||||
|
@ -316,6 +316,7 @@ struct optional_caster {
|
||||
if (!std::is_lvalue_reference<T>::value) {
|
||||
policy = return_value_policy_override<Value>::policy(policy);
|
||||
}
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
return value_conv::cast(*std::forward<T>(src), policy, parent);
|
||||
}
|
||||
|
||||
|
@ -355,13 +355,17 @@ void vector_accessor(enable_if_t<vector_needs_copy<Vector>::value, Class_> &cl)
|
||||
using DiffType = typename Vector::difference_type;
|
||||
using ItType = typename Vector::iterator;
|
||||
cl.def("__getitem__", [](const Vector &v, DiffType i) -> T {
|
||||
if (i < 0 && (i += v.size()) < 0) {
|
||||
if (i < 0) {
|
||||
i += v.size();
|
||||
if (i < 0) {
|
||||
throw index_error();
|
||||
}
|
||||
}
|
||||
auto i_st = static_cast<SizeType>(i);
|
||||
if (i_st >= v.size()) {
|
||||
throw index_error();
|
||||
}
|
||||
if ((SizeType) i >= v.size()) {
|
||||
throw index_error();
|
||||
}
|
||||
return v[(SizeType) i];
|
||||
return v[i_st];
|
||||
});
|
||||
|
||||
cl.def(
|
||||
|
Loading…
Reference in New Issue
Block a user