diff --git a/include/libtorrent/aux_/heterogeneous_queue.hpp b/include/libtorrent/aux_/heterogeneous_queue.hpp index 67a9b4bf987..1b0a2b35566 100644 --- a/include/libtorrent/aux_/heterogeneous_queue.hpp +++ b/include/libtorrent/aux_/heterogeneous_queue.hpp @@ -24,6 +24,13 @@ see LICENSE file. #include #endif +#ifdef __clang__ +// disable these warnings until this class is re-worked in a way clang likes +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunknown-warning-option" +#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" +#endif + namespace libtorrent { namespace aux { @@ -274,4 +281,8 @@ namespace aux { }; } // namespace libtorrent +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + #endif diff --git a/include/libtorrent/aux_/netlink_utils.hpp b/include/libtorrent/aux_/netlink_utils.hpp index 190780cb2b7..0b5c3826409 100644 --- a/include/libtorrent/aux_/netlink_utils.hpp +++ b/include/libtorrent/aux_/netlink_utils.hpp @@ -48,6 +48,8 @@ namespace aux { #pragma clang diagnostic ignored "-Wsign-compare" #pragma clang diagnostic ignored "-Wcast-qual" #pragma clang diagnostic ignored "-Wcast-align" +#pragma clang diagnostic ignored "-Wunknown-warning-option" +#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" #endif // these are here to concentrate all the shady casts these macros expand to, // to disable the warnings for them all diff --git a/include/libtorrent/bitfield.hpp b/include/libtorrent/bitfield.hpp index 38743148e37..a6ee6506e49 100644 --- a/include/libtorrent/bitfield.hpp +++ b/include/libtorrent/bitfield.hpp @@ -22,6 +22,13 @@ see LICENSE file. #include // for memset and memcpy #include // uint32_t +#ifdef __clang__ +// disable these warnings until this class is re-worked in a way clang likes +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunknown-warning-option" +#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" +#endif + namespace libtorrent { // The bitfield type stores any number of bits as a bitfield @@ -330,4 +337,8 @@ namespace libtorrent { }; } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + #endif // TORRENT_BITFIELD_HPP_INCLUDED diff --git a/include/libtorrent/span.hpp b/include/libtorrent/span.hpp index 1c177f8537b..ee1dd244113 100644 --- a/include/libtorrent/span.hpp +++ b/include/libtorrent/span.hpp @@ -42,6 +42,13 @@ namespace aux { }; } +#ifdef __clang__ +// disable these warnings until this class is re-worked in a way clang likes +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunknown-warning-option" +#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" +#endif + template struct span { @@ -153,6 +160,10 @@ namespace aux { difference_type m_len; }; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + template inline bool operator==(span const& lhs, span const& rhs) { diff --git a/src/assert.cpp b/src/assert.cpp index f50283e2991..f60a4ce13f7 100644 --- a/src/assert.cpp +++ b/src/assert.cpp @@ -45,10 +45,16 @@ see LICENSE file. #include +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunknown-warning-option" +#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" +#endif + namespace libtorrent { std::string demangle(char const* name) { -// in case this string comes + // in case this string comes // this is needed on linux char const* start = std::strchr(name, '('); if (start != nullptr) @@ -83,6 +89,10 @@ std::string demangle(char const* name) ::free(unmangled); return ret; } + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif } #elif defined _WIN32 && !defined TORRENT_WINRT @@ -113,6 +123,12 @@ std::string demangle(char const* name) { return name; } #if TORRENT_USE_EXECINFO #include +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunknown-warning-option" +#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" +#endif + namespace libtorrent { TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth, void*) @@ -133,6 +149,10 @@ TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth, void*) } } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + #elif defined _WIN32 && !defined TORRENT_WINRT #include "libtorrent/aux_/windows.hpp" diff --git a/src/bdecode.cpp b/src/bdecode.cpp index 66f9cecc44d..83eda3fb003 100644 --- a/src/bdecode.cpp +++ b/src/bdecode.cpp @@ -25,6 +25,13 @@ see LICENSE file. #define BOOST_SYSTEM_NOEXCEPT throw() #endif +#ifdef __clang__ +// disable these warnings until this class is re-worked in a way clang likes +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunknown-warning-option" +#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" +#endif + namespace libtorrent { using aux::bdecode_token; @@ -1160,3 +1167,7 @@ namespace aux { return ret; } } + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif diff --git a/src/bitfield.cpp b/src/bitfield.cpp index 91a57e1e864..a0c0ad3a3d9 100644 --- a/src/bitfield.cpp +++ b/src/bitfield.cpp @@ -17,6 +17,13 @@ see LICENSE file. #include #endif +#ifdef __clang__ +// disable these warnings until this class is re-worked in a way clang likes +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunknown-warning-option" +#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" +#endif + namespace libtorrent { bool bitfield::all_set() const noexcept @@ -225,3 +232,8 @@ namespace libtorrent { static_assert(std::is_nothrow_default_constructible>::value , "should be nothrow default constructible"); } + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + diff --git a/src/cpuid.cpp b/src/cpuid.cpp index 9ef2d923c6d..ef3fa877858 100644 --- a/src/cpuid.cpp +++ b/src/cpuid.cpp @@ -57,6 +57,12 @@ namespace libtorrent { namespace aux { namespace { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunknown-warning-option" +#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" +#endif + #if TORRENT_HAS_SSE // internal void cpuid(std::uint32_t* info, int type) noexcept @@ -130,6 +136,10 @@ namespace { #endif } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + } // anonymous namespace bool const sse42_support = supports_sse42(); diff --git a/src/crc32c.cpp b/src/crc32c.cpp index 91009cf7141..c471d0f1811 100644 --- a/src/crc32c.cpp +++ b/src/crc32c.cpp @@ -26,6 +26,12 @@ see LICENSE file. #include #endif +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunknown-warning-option" +#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" +#endif + namespace libtorrent::aux { std::uint32_t crc32c_32(std::uint32_t v) @@ -126,3 +132,7 @@ namespace libtorrent::aux { return crc.checksum(); } } + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif diff --git a/src/fingerprint.cpp b/src/fingerprint.cpp index 34dfb8b7920..6bc54d86796 100644 --- a/src/fingerprint.cpp +++ b/src/fingerprint.cpp @@ -51,6 +51,13 @@ namespace libtorrent { return ret; } +#ifdef __clang__ +// TODO: the fingerprint constructor should take a string_view +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunknown-warning-option" +#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" +#endif + fingerprint::fingerprint(const char* id_string, int major, int minor , int revision, int tag) : major_version(major) @@ -68,6 +75,10 @@ namespace libtorrent { name[1] = id_string[1]; } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + #if TORRENT_ABI_VERSION == 1 std::string fingerprint::to_string() const { diff --git a/src/http_parser.cpp b/src/http_parser.cpp index bd018e890ac..be6c3f72a51 100644 --- a/src/http_parser.cpp +++ b/src/http_parser.cpp @@ -25,6 +25,12 @@ see LICENSE file. #include "libtorrent/time.hpp" // for seconds32 #include "libtorrent/aux_/numeric_cast.hpp" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunknown-warning-option" +#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" +#endif + namespace libtorrent::aux { bool is_ok_status(int http_status) @@ -623,3 +629,8 @@ namespace libtorrent::aux { return buffer.first(write_ptr - buffer.data()); } } + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + diff --git a/src/torrent.cpp b/src/torrent.cpp index d19bf9bcc98..0208c82bfae 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -10436,7 +10436,7 @@ namespace { int num_peers = 0; int num_downloaders = 0; int missing_pieces = 0; - for (auto* p : m_connections) + for (auto const* const p : m_connections) { TORRENT_INCREMENT(m_iterating_connections); if (p->is_connecting()) continue;