From 05da4417f932ad7b4b62341e12f9b579ab7e5419 Mon Sep 17 00:00:00 2001 From: andriish Date: Thu, 4 Apr 2024 20:51:33 +0200 Subject: [PATCH 1/3] Update context.cpp use empty() Update context.cpp use empty() to avoid clang-tidy warnings --- source/context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/context.cpp b/source/context.cpp index 5aea93e9..d41ebdeb 100644 --- a/source/context.cpp +++ b/source/context.cpp @@ -116,7 +116,7 @@ PYBIND11_MODULE({2}, root_module) {{ std::vector< std::pair > sub_modules {{ {3} }}; - for(auto &p : sub_modules ) modules[p.first.size() ? p.first+"::"+p.second : p.second] = modules[p.first].def_submodule( mangle_namespace_name(p.second).c_str(), ("Bindings for " + p.first + "::" + p.second + " namespace").c_str() ); + for(auto &p : sub_modules ) modules[ !p.first.empty() ? p.first+"::"+p.second : p.second] = modules[p.first].def_submodule( mangle_namespace_name(p.second).c_str(), ("Bindings for " + p.first + "::" + p.second + " namespace").c_str() ); //pybind11::class_>(M(""), "_encapsulated_data_"); From b4a296212538c4a6c325d07b3302fb1ea22e220f Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi Date: Sat, 6 Apr 2024 22:15:51 +0200 Subject: [PATCH 2/3] LLVM 18 compatibility --- source/class.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source/class.cpp b/source/class.cpp index 13156359..b9f98f38 100644 --- a/source/class.cpp +++ b/source/class.cpp @@ -616,7 +616,11 @@ bool is_callback_structure_needed(CXXRecordDecl const *C) // check if all pure-virtual methods could be overridden in Python if( C->isAbstract() ) { for( auto m = C->method_begin(); m != C->method_end(); ++m ) { +#if( LLVM_VERSION_MAJOR >= 18 ) + if( m->isPureVirtual() and is_const_overload(*m) ) return false; // it is not clear how to deal with this case since we can't overrdie const versions in Python, - so disabling for now +#else if( m->isPure() and is_const_overload(*m) ) return false; // it is not clear how to deal with this case since we can't overrdie const versions in Python, - so disabling for now +#endif } } @@ -644,7 +648,11 @@ bool is_callback_structure_constructible(CXXRecordDecl const *C) { if( C->isAbstract() ) { for( auto m = C->method_begin(); m != C->method_end(); ++m ) { +#if( LLVM_VERSION_MAJOR >= 18 ) + if( m->isPureVirtual() and !isa(*m) and (m->getAccess() == AS_private or !is_bindable(*m) or is_skipping_requested(*m, Config::get())) ) return false; +#else if( m->isPure() and !isa(*m) and (m->getAccess() == AS_private or !is_bindable(*m) or is_skipping_requested(*m, Config::get())) ) return false; +#endif } for( auto b = C->bases_begin(); b != C->bases_end(); ++b ) { @@ -766,7 +774,11 @@ string bind_member_functions_for_call_back(CXXRecordDecl const *C, string const string custom_function_info = Config::get().is_custom_trampoline_function_requested(member_function_name); if( custom_function_info == "" ) { c += indent(fmt::format(call_back_function_body_template, class_name, /*class_qualified_name(C), */ python_name, std::get<1>(args), return_type), "\t\t"); +#if( LLVM_VERSION_MAJOR >= 18 ) + if( m->isPureVirtual() ) c += "\t\tpybind11::pybind11_fail(\"Tried to call pure virtual function \\\"{}::{}\\\"\");\n"_format(C->getNameAsString(), python_name); +#else if( m->isPure() ) c += "\t\tpybind11::pybind11_fail(\"Tried to call pure virtual function \\\"{}::{}\\\"\");\n"_format(C->getNameAsString(), python_name); +#endif else c += "\t\treturn {}::{}({});\n"_format(C->getNameAsString(), m->getNameAsString(), std::get<1>(args)); } else { From 004735c1bcaaec422fb4ffbd299d75304be5c635 Mon Sep 17 00:00:00 2001 From: andriish Date: Fri, 12 Apr 2024 11:34:10 +0200 Subject: [PATCH 3/3] Update context.cpp --- source/context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/context.cpp b/source/context.cpp index d41ebdeb..620908d6 100644 --- a/source/context.cpp +++ b/source/context.cpp @@ -116,7 +116,7 @@ PYBIND11_MODULE({2}, root_module) {{ std::vector< std::pair > sub_modules {{ {3} }}; - for(auto &p : sub_modules ) modules[ !p.first.empty() ? p.first+"::"+p.second : p.second] = modules[p.first].def_submodule( mangle_namespace_name(p.second).c_str(), ("Bindings for " + p.first + "::" + p.second + " namespace").c_str() ); + for(auto &p : sub_modules ) modules[ p.first.empty() ? p.second : p.first+"::"+p.second ] = modules[p.first].def_submodule( mangle_namespace_name(p.second).c_str(), ("Bindings for " + p.first + "::" + p.second + " namespace").c_str() ); //pybind11::class_>(M(""), "_encapsulated_data_");