Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3731f0e

Browse files
Address miscellaneous Clang warnings (#1422)
1 parent 39222a6 commit 3731f0e

File tree

8 files changed

+38
-15
lines changed

8 files changed

+38
-15
lines changed

‎src/bsoncxx/include/bsoncxx/v1/detail/type_traits.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,8 @@ struct is_equality_comparable : decltype(is_equality_comparable_f<L, R>(0)) {};
479479
template <typename L, typename R>
480480
std::false_type is_partially_ordered_with_f(rank<0>);
481481

482+
BSONCXX_PRIVATE_WARNINGS_PUSH();
483+
BSONCXX_PRIVATE_WARNINGS_DISABLE(Clang("-Wordered-compare-function-pointers"));
482484
template <typename L, typename R>
483485
auto is_partially_ordered_with_f(rank<1>) -> true_t<
484486
decltype(std::declval<L const&>() > std::declval<R const&>()),
@@ -489,6 +491,7 @@ auto is_partially_ordered_with_f(rank<1>) -> true_t<
489491
decltype(std::declval<R const&>() > std::declval<L const&>()),
490492
decltype(std::declval<R const&>() <= std::declval<L const&>()),
491493
decltype(std::declval<R const&>() >= std::declval<L const&>())>;
494+
BSONCXX_PRIVATE_WARNINGS_POP();
492495

493496
template <typename T, typename U>
494497
struct is_partially_ordered_with : decltype(is_partially_ordered_with_f<T, U>(rank<1>{})) {};

‎src/bsoncxx/test/v1/stdx/optional.test.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
//
1818

19+
#include <bsoncxx/v1/detail/compare.hpp>
1920
#include <bsoncxx/v1/detail/macros.hpp>
21+
#include <bsoncxx/v1/detail/type_traits.hpp>
2022

2123
#include <bsoncxx/test/v1/stdx/string_view.hh>
2224

@@ -26,9 +28,6 @@
2628
#include <string>
2729
#include <type_traits>
2830

29-
#include <bsoncxx/stdx/operators.hpp>
30-
#include <bsoncxx/stdx/type_traits.hpp>
31-
3231
#include <bsoncxx/private/make_unique.hh>
3332

3433
#include <bsoncxx/test/catch.hh>
@@ -654,11 +653,14 @@ TEST_CASE("Optional: Hashing") {
654653
CHECK_VS2017(hashit(c) == hashit(a));
655654
}
656655

656+
BSONCXX_PRIVATE_WARNINGS_PUSH();
657+
BSONCXX_PRIVATE_WARNINGS_DISABLE(Clang("-Wunneeded-member-function"));
657658
struct in_place_convertible {
658659
bool constructed_from_in_place = false;
659660
in_place_convertible() = default;
660661
in_place_convertible(bsoncxx::v1::stdx::in_place_t) : constructed_from_in_place(true) {}
661662
};
663+
BSONCXX_PRIVATE_WARNINGS_POP();
662664

663665
TEST_CASE("optional<T> conversions") {
664666
// Some stdlib implementations do not forbid this ctor correctly.

‎src/bsoncxx/test/v1/stdx/type_traits.test.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1+
// Copyright 2009-present MongoDB, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <bsoncxx/v1/detail/type_traits.hpp>
16+
17+
//
18+
119
#include <string>
220
#include <type_traits>
321

4-
#include <bsoncxx/stdx/type_traits.hpp>
5-
6-
#include <bsoncxx/test/catch.hh>
22+
#include <bsoncxx/test/system_error.hh>
723

824
// We declare variables that are only used for compilation checking
925
BSONCXX_PRIVATE_WARNINGS_DISABLE(GNU("-Wunused"));

‎src/mongocxx/lib/mongocxx/private/mongoc_error.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ inline void make_generic_bson_error(bson_error_t* error) {
5252
}
5353

5454
template <typename exception_type>
55-
void throw_exception(::bson_error_t const& error) {
55+
[[noreturn]] void throw_exception(::bson_error_t const& error) {
5656
throw exception_type{make_error_code(error), error.message};
5757
}
5858

5959
template <typename exception_type>
60-
void throw_exception(bsoncxx::v_noabi::document::value raw_server_error, ::bson_error_t const& error) {
60+
[[noreturn]] void throw_exception(bsoncxx::v_noabi::document::value raw_server_error, ::bson_error_t const& error) {
6161
throw exception_type{make_error_code(error), std::move(raw_server_error), error.message};
6262
}
6363

‎src/mongocxx/test/spec/gridfs.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ bsoncxx::stdx::optional<test_util::item_t> transform_hex(test_util::item_t pair,
8989
return {pair};
9090
}
9191

92-
std::basic_string<std::uint8_t> bytes = test_util::convert_hex_string_to_bytes(data["$hex"].get_string().value);
92+
std::vector<std::uint8_t> bytes = test_util::convert_hex_string_to_bytes(data["$hex"].get_string().value);
9393
types::b_binary binary_data = {binary_sub_type::k_binary, static_cast<std::uint32_t>(bytes.size()), bytes.data()};
9494

9595
context->append(binary_data);
@@ -230,7 +230,7 @@ void test_download(database db, gridfs::bucket bucket, document::view operation,
230230
// string>" }, which needs to be converted to an array of bytes.
231231
REQUIRE(result["$hex"]);
232232
std::string hex = bsoncxx::string::to_string(result["$hex"].get_string().value);
233-
std::basic_string<std::uint8_t> expected = test_util::convert_hex_string_to_bytes(hex);
233+
std::vector<std::uint8_t> expected = test_util::convert_hex_string_to_bytes(hex);
234234

235235
REQUIRE(actual_size == expected.size());
236236

@@ -267,7 +267,7 @@ void test_upload(database db, gridfs::bucket bucket, document::view operation, d
267267

268268
REQUIRE(source["$hex"]);
269269
std::string hex = bsoncxx::string::to_string(source["$hex"].get_string().value);
270-
std::basic_string<std::uint8_t> source_bytes = test_util::convert_hex_string_to_bytes(hex);
270+
std::vector<std::uint8_t> source_bytes = test_util::convert_hex_string_to_bytes(hex);
271271

272272
uploader.write(source_bytes.data(), source_bytes.size());
273273
result::gridfs::upload upload_result = uploader.close();

‎src/mongocxx/test/spec/unified_tests/assert.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ void special_operator(types::bson_value::view actual, document::view expected, e
162162
REQUIRE(actual.type() == bsoncxx::type::k_binary);
163163

164164
auto expected_bytes = test_util::convert_hex_string_to_bytes(op.get_value().get_string());
165-
decltype(expected_bytes) actual_bytes(actual.get_binary().bytes, actual.get_binary().size);
165+
decltype(expected_bytes) actual_bytes(
166+
actual.get_binary().bytes, actual.get_binary().bytes + actual.get_binary().size);
166167

167168
REQUIRE(actual_bytes == expected_bytes);
168169
} else {

‎src/mongocxx/test/v_noabi/client_helpers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ bool newer_than(std::string version) {
236236
return (compare_versions(server_version, version) >= 0);
237237
}
238238

239-
std::basic_string<std::uint8_t> convert_hex_string_to_bytes(bsoncxx::stdx::string_view hex) {
240-
std::basic_string<std::uint8_t> bytes;
239+
std::vector<std::uint8_t> convert_hex_string_to_bytes(bsoncxx::stdx::string_view hex) {
240+
std::vector<std::uint8_t> bytes;
241241

242242
// Convert each pair of hexadecimal digits into a number and store it in the array.
243243
for (std::size_t i = 0; i < hex.size(); i += 2) {

‎src/mongocxx/test/v_noabi/client_helpers.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <functional>
1919
#include <string>
2020
#include <utility>
21+
#include <vector>
2122

2223
#include <bsoncxx/builder/basic/array.hpp>
2324
#include <bsoncxx/document/element.hpp>
@@ -63,7 +64,7 @@ bool newer_than(std::string version);
6364
// This function assumes that `hex` has an even length and that all characters in the string are
6465
// valid hexadecimal digits.
6566
//
66-
std::basic_string<std::uint8_t> convert_hex_string_to_bytes(bsoncxx::stdx::string_view hex);
67+
std::vector<std::uint8_t> convert_hex_string_to_bytes(bsoncxx::stdx::string_view hex);
6768

6869
//
6970
// Adds server API options to passed-in options if MONGODB_API_VERSION

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /