diff options
author | Tor Egge <Tor.Egge@yahooinc.com> | 2023-01-30 18:53:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-30 18:53:10 +0100 |
commit | a1b6a7d75da69fd01f7734dbbc40d4ab18f7c077 (patch) | |
tree | 689a71771d53989bb4c45b7e95a77ad72b2dd130 | |
parent | ccf939eb4e2fe110983841e27ab71b6a2cf4bbb0 (diff) | |
parent | 652f2a7d7cdea301574bae20a5149e587389f672 (diff) |
Merge pull request #25804 from vespa-engine/balder/cleanup-suggest-override-pragmas-not-necessary-anymore
GC som compiler pragmas not needed anymore.
11 files changed, 44 insertions, 134 deletions
diff --git a/logd/src/logd/log_protocol_proto.h b/logd/src/logd/log_protocol_proto.h index ee48c1fb2f9..60bb016d243 100644 --- a/logd/src/logd/log_protocol_proto.h +++ b/logd/src/logd/log_protocol_proto.h @@ -2,12 +2,5 @@ #pragma once -#pragma GCC diagnostic push -#ifndef __clang__ -#pragma GCC diagnostic ignored "-Wsuggest-override" -#endif - #include <logd/log_protocol.pb.h> -#pragma GCC diagnostic pop - diff --git a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp index 22584db7dd9..4b35d0fcdf7 100644 --- a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp +++ b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp @@ -132,8 +132,7 @@ checkReaders(const StringEnumStore& ses, const std::vector<Reader>& readers) { const char* t = ""; - for (uint32_t i = 0; i < readers.size(); ++i) { - const Reader& r = readers[i]; + for (const auto & r : readers) { for (uint32_t j = 0; j < r._indices.size(); ++j) { EXPECT_TRUE(ses.get_value(r._indices[j], t)); EXPECT_TRUE(r._expected[j]._string == std::string(t)); @@ -151,12 +150,6 @@ public: {} }; -// Disable warnings emitted by gtest generated files when using typed tests -#pragma GCC diagnostic push -#ifndef __clang__ -#pragma GCC diagnostic ignored "-Wsuggest-override" -#endif - using FloatEnumStoreTestTypes = ::testing::Types<BTreeFloatEnumStore, BTreeDoubleEnumStore, HybridFloatEnumStore, HybridDoubleEnumStore, HashFloatEnumStore, HashDoubleEnumStore>; TYPED_TEST_SUITE(FloatEnumStoreTest, FloatEnumStoreTestTypes); @@ -168,8 +161,8 @@ TYPED_TEST(FloatEnumStoreTest, numbers_can_be_inserted_and_retrieved) EntryType a[5] = {-20.5f, -10.5f, -0.5f, 9.5f, 19.5f}; EntryType b[5] = {-25.5f, -15.5f, -5.5f, 4.5f, 14.5f}; - for (uint32_t i = 0; i < 5; ++i) { - this->es.insert(a[i]); + for (auto i : a) { + this->es.insert(i); } for (uint32_t i = 0; i < 5; ++i) { @@ -187,8 +180,6 @@ TYPED_TEST(FloatEnumStoreTest, numbers_can_be_inserted_and_retrieved) } } -#pragma GCC diagnostic pop - TEST(EnumStoreTest, test_find_folded_on_string_enum_store) { StringEnumStore ses(false, DictionaryConfig::Type::BTREE); @@ -235,7 +226,7 @@ testUniques(const StringEnumStore& ses, const std::vector<std::string>& unique) class StringEnumStoreTest : public ::testing::Test { public: - void testInsert(bool hasPostings); + static void testInsert(bool hasPostings); }; void @@ -244,17 +235,13 @@ StringEnumStoreTest::testInsert(bool hasPostings) StringEnumStore ses(hasPostings, DictionaryConfig::Type::BTREE); std::vector<EnumIndex> indices; - std::vector<std::string> unique; - unique.push_back(""); - unique.push_back("add"); - unique.push_back("enumstore"); - unique.push_back("unique"); - - for (uint32_t i = 0; i < unique.size(); ++i) { - EnumIndex idx = ses.insert(unique[i].c_str()); + std::vector<std::string> unique = {"", "add", "enumstore", "unique"}; + + for (const auto & i : unique) { + EnumIndex idx = ses.insert(i.c_str()); EXPECT_EQ(1u, ses.get_ref_count(idx)); indices.push_back(idx); - EXPECT_TRUE(ses.find_index(unique[i].c_str(), idx)); + EXPECT_TRUE(ses.find_index(i.c_str(), idx)); } ses.freeze_dictionary(); @@ -294,14 +281,14 @@ TEST(EnumStoreTest, test_hold_lists_and_generation) for (uint32_t i = 0; i < 100; ++i) { char tmp[16]; sprintf(tmp, i < 10 ? "enum0%u" : "enum%u", i); - uniques.push_back(tmp); + uniques.emplace_back(tmp); } StringVector newUniques; newUniques.reserve(100); for (uint32_t i = 0; i < 100; ++i) { char tmp[16]; sprintf(tmp, i < 10 ? "unique0%u" : "unique%u", i); - newUniques.push_back(tmp); + newUniques.emplace_back(tmp); } uint32_t generation = 0; std::vector<Reader> readers; @@ -327,7 +314,7 @@ TEST(EnumStoreTest, test_hold_lists_and_generation) EXPECT_TRUE(indices.size() == 10); EXPECT_TRUE(expected.size() == 10); sesGen = generation++; - readers.push_back(Reader(sesGen, indices, expected)); + readers.emplace_back(sesGen, indices, expected); checkReaders(ses, readers); } } @@ -408,7 +395,7 @@ public: expect_value_in_store(5, 2, i5); } - void expect_value_in_store(int32_t exp_value, uint32_t exp_ref_count, EnumIndex idx) { + void expect_value_in_store(int32_t exp_value, uint32_t exp_ref_count, EnumIndex idx) const { EnumIndex tmp_idx; EXPECT_TRUE(store.find_index(exp_value, tmp_idx)); EXPECT_EQ(idx, tmp_idx); @@ -416,7 +403,7 @@ public: EXPECT_EQ(exp_ref_count, store.get_ref_count(idx)); } - void expect_value_not_in_store(int32_t value, EnumIndex idx) { + void expect_value_not_in_store(int32_t value, EnumIndex idx) const { EnumIndex temp_idx; EXPECT_FALSE(store.find_index(value, idx)); EXPECT_EQ(0, store.get_ref_count(idx)); @@ -508,7 +495,7 @@ public: Values::load_values(loader); } - EnumIndex find_index(size_t values_idx) const { + [[nodiscard]] EnumIndex find_index(size_t values_idx) const { EnumIndex result; EXPECT_TRUE(store.find_index(Values::values[values_idx], result)); return result; @@ -547,12 +534,6 @@ public: }; -// Disable warnings emitted by gtest generated files when using typed tests -#pragma GCC diagnostic push -#ifndef __clang__ -#pragma GCC diagnostic ignored "-Wsuggest-override" -#endif - using LoaderTestTypes = ::testing::Types<BTreeNumericEnumStore, BTreeFloatEnumStore, BTreeStringEnumStore, HybridNumericEnumStore, HybridFloatEnumStore, HybridStringEnumStore, HashNumericEnumStore, HashFloatEnumStore, HashStringEnumStore>; TYPED_TEST_SUITE(LoaderTest, LoaderTestTypes); @@ -605,8 +586,6 @@ TYPED_TEST(LoaderTest, store_is_instantiated_with_non_enumerated_loader) this->expect_posting_idx(3, 103); } -#pragma GCC diagnostic pop - template <typename EnumStoreTypeAndDictionaryType> class EnumStoreDictionaryTest : public ::testing::Test { public: @@ -724,7 +703,7 @@ EnumStoreDictionaryTest<EnumStoreTypeAndDictionaryType>::clear_sample_values(uin auto comparator = store.make_comparator(i); auto enum_idx = dict.find(comparator); EXPECT_TRUE(enum_idx.valid()); - dict.update_posting_list(enum_idx, comparator, [](EntryRef) noexcept -> EntryRef { return EntryRef(); }); + dict.update_posting_list(enum_idx, comparator, [](EntryRef) noexcept -> EntryRef { return {}; }); } } @@ -796,12 +775,6 @@ EnumStoreDictionaryTest<EnumStoreTypeAndDictionaryType>::test_foreach_posting_li clear_sample_values(large_population); } -// Disable warnings emitted by gtest generated files when using typed tests -#pragma GCC diagnostic push -#ifndef __clang__ -#pragma GCC diagnostic ignored "-Wsuggest-override" -#endif - using EnumStoreDictionaryTestTypes = ::testing::Types<BTreeNumericEnumStore, HybridNumericEnumStore, HashNumericEnumStore>; TYPED_TEST_SUITE(EnumStoreDictionaryTest, EnumStoreDictionaryTestTypes); @@ -942,8 +915,6 @@ TYPED_TEST(EnumStoreDictionaryTest, compact_worst_works) EXPECT_EQ(exp_values, values); } -#pragma GCC diagnostic pop - } GTEST_MAIN_RUN_ALL_TESTS() diff --git a/searchlib/src/tests/memoryindex/field_index/field_index_test.cpp b/searchlib/src/tests/memoryindex/field_index/field_index_test.cpp index 5f8b6b2df48..76056029f78 100644 --- a/searchlib/src/tests/memoryindex/field_index/field_index_test.cpp +++ b/searchlib/src/tests/memoryindex/field_index/field_index_test.cpp @@ -76,7 +76,7 @@ private: bool _firstDoc; public: - MyBuilder(const Schema &schema) + explicit MyBuilder(const Schema &schema) : IndexBuilder(schema), _ss(), _insideWord(false), @@ -159,9 +159,11 @@ struct SimpleMatchData { SimpleMatchData() : term(), array() { array.add(&term); } - ~SimpleMatchData() {} + ~SimpleMatchData(); }; +SimpleMatchData::~SimpleMatchData() = default; + std::string toString(const SimpleMatchData& match_data, bool hasElements = false, @@ -266,6 +268,7 @@ class MockFieldIndex { uint32_t _fieldId; public: + MockFieldIndex(); ~MockFieldIndex(); void setNextWord(const vespalib::string &word) { @@ -301,6 +304,12 @@ public: } }; +MockFieldIndex::MockFieldIndex() + : _dict(), + _word(), + _fieldId() +{} + MockFieldIndex::~MockFieldIndex() = default; /** @@ -337,7 +346,7 @@ class MyInserter { IOrderedFieldIndexInserter *_inserter; public: - MyInserter(const Schema &schema) + explicit MyInserter(const Schema &schema) : _wordStoreScan(), _mock(), _fieldIndexes(schema, MockFieldLengthInspector()), @@ -427,15 +436,15 @@ myremove(uint32_t docId, DocumentInverter &inv) class MyDrainRemoves : IFieldIndexRemoveListener { FieldIndexRemover &_remover; public: - virtual void remove(const vespalib::stringref, uint32_t) override { } + void remove(const vespalib::stringref, uint32_t) override { } MyDrainRemoves(FieldIndexCollection &fieldIndexes, uint32_t fieldId) : _remover(fieldIndexes.getFieldIndex(fieldId)->getDocumentRemover()) { } - MyDrainRemoves(IFieldIndex& field_index) - : _remover(field_index.getDocumentRemover()) + explicit MyDrainRemoves(IFieldIndex& field_index) + : _remover(field_index.getDocumentRemover()) { } @@ -532,22 +541,20 @@ struct FieldIndexTest : public ::testing::Test { idx(schema, 0) { } - ~FieldIndexTest() {} + ~FieldIndexTest() override; SearchIterator::UP search(const vespalib::stringref word, const SimpleMatchData& match_data) { return make_search_iterator<FieldIndexType::has_interleaved_features>(idx.find(word), idx.getFeatureStore(), 0, match_data.array); } }; +template <typename FieldIndexType> +FieldIndexTest<FieldIndexType>::~FieldIndexTest() = default; + + using FieldIndexTestTypes = ::testing::Types<FieldIndex<false>, FieldIndex<true>>; TYPED_TEST_SUITE(FieldIndexTest, FieldIndexTestTypes); -// Disable warnings emitted by gtest generated files when using typed tests -#pragma GCC diagnostic push -#ifndef __clang__ -#pragma GCC diagnostic ignored "-Wsuggest-override" -#endif - TYPED_TEST(FieldIndexTest, require_that_fresh_insert_works) { EXPECT_TRUE(assertPostingList("[]", this->idx.find("a"))); @@ -646,8 +653,6 @@ TYPED_TEST(FieldIndexTest, require_that_posting_iterator_is_working) } } -#pragma GCC diagnostic pop - struct FieldIndexInterleavedFeaturesTest : public FieldIndexTest<FieldIndex<true>> { SimpleMatchData match_data; FieldIndexInterleavedFeaturesTest() @@ -732,14 +737,16 @@ struct FieldIndexCollectionTest : public ::testing::Test { fic(schema, MockFieldLengthInspector()) { } - ~FieldIndexCollectionTest() {} + ~FieldIndexCollectionTest(); - NormalFieldIndex::PostingList::Iterator find(const vespalib::stringref word, - uint32_t field_id) const { + [[nodiscard]]NormalFieldIndex::PostingList::Iterator + find(const vespalib::stringref word, uint32_t field_id) const { return find_in_field_index<false>(word, field_id, fic); } }; +FieldIndexCollectionTest::~FieldIndexCollectionTest() = default; + TEST_F(FieldIndexCollectionTest, require_that_multiple_posting_lists_across_multiple_fields_can_exist) { WrapInserter(fic, 0).word("a").add(10).word("b").add(11).add(15).flush(); diff --git a/searchlib/src/tests/queryeval/matching_elements_search/matching_elements_search_test.cpp b/searchlib/src/tests/queryeval/matching_elements_search/matching_elements_search_test.cpp index 4643f71ddc3..5e5d9a9a282 100644 --- a/searchlib/src/tests/queryeval/matching_elements_search/matching_elements_search_test.cpp +++ b/searchlib/src/tests/queryeval/matching_elements_search/matching_elements_search_test.cpp @@ -115,12 +115,6 @@ template <> MatchingElementsSearchTest<const char *>::LookupTests MatchingElemen {{"FOO"}, {{"FOO", 3}, {"foo", 5}}} }; -// Disable warnings emitted by gtest generated files when using typed tests -#pragma GCC diagnostic push -#ifndef __clang__ -#pragma GCC diagnostic ignored "-Wsuggest-override" -#endif - using MatchingElementsSearchTestTypes = ::testing::Types<int64_t, const char *>; TYPED_TEST_SUITE(MatchingElementsSearchTest, MatchingElementsSearchTestTypes); @@ -129,6 +123,4 @@ TYPED_TEST(MatchingElementsSearchTest, verify_matching_elements) this->verify_matching_elements(); } -#pragma GCC diagnostic pop - GTEST_MAIN_RUN_ALL_TESTS() diff --git a/searchlib/src/vespa/searchlib/engine/search_protocol_proto.h b/searchlib/src/vespa/searchlib/engine/search_protocol_proto.h index e9fad0e8d1b..2b3e879a6c4 100644 --- a/searchlib/src/vespa/searchlib/engine/search_protocol_proto.h +++ b/searchlib/src/vespa/searchlib/engine/search_protocol_proto.h @@ -2,11 +2,4 @@ #pragma once -#pragma GCC diagnostic push -#ifndef __clang__ -#pragma GCC diagnostic ignored "-Wsuggest-override" -#endif - #include "search_protocol.pb.h" - -#pragma GCC diagnostic pop diff --git a/storage/src/tests/bucketdb/lockablemaptest.cpp b/storage/src/tests/bucketdb/lockablemaptest.cpp index 7a629920606..582e6957c22 100644 --- a/storage/src/tests/bucketdb/lockablemaptest.cpp +++ b/storage/src/tests/bucketdb/lockablemaptest.cpp @@ -62,12 +62,6 @@ struct LockableMapTest : ::testing::Test { using MapTypes = ::testing::Types<bucketdb::BTreeLockableMap<A>, bucketdb::StripedBTreeLockableMap<A>>; TYPED_TEST_SUITE(LockableMapTest, MapTypes); -// Disable warnings emitted by gtest generated files when using typed tests -#pragma GCC diagnostic push -#ifndef __clang__ -#pragma GCC diagnostic ignored "-Wsuggest-override" -#endif - TYPED_TEST(LockableMapTest, simple_usage) { // Tests insert, erase, size, empty, operator[] TypeParam map; @@ -142,8 +136,8 @@ struct EntryProcessor { std::string toString() { std::ostringstream ost; - for (uint32_t i=0; i<log.size(); ++i) { - ost << log[i] << "\n"; + for (const auto & i : log) { + ost << i << "\n"; } return ost.str(); } diff --git a/storage/src/vespa/storage/storageserver/rpc/rpc_envelope_proto.h b/storage/src/vespa/storage/storageserver/rpc/rpc_envelope_proto.h index ded22d8c06a..5047eaf790d 100644 --- a/storage/src/vespa/storage/storageserver/rpc/rpc_envelope_proto.h +++ b/storage/src/vespa/storage/storageserver/rpc/rpc_envelope_proto.h @@ -2,11 +2,4 @@ #pragma once -#pragma GCC diagnostic push -#ifndef __clang__ -#pragma GCC diagnostic ignored "-Wsuggest-override" -#endif - #include <vespa/storage/storageserver/rpc/rpc_envelope.pb.h> - -#pragma GCC diagnostic pop diff --git a/storage/src/vespa/storageapi/mbusprot/protobuf_includes.h b/storage/src/vespa/storageapi/mbusprot/protobuf_includes.h index 9accfdf75ee..ebcc87b647a 100644 --- a/storage/src/vespa/storageapi/mbusprot/protobuf_includes.h +++ b/storage/src/vespa/storageapi/mbusprot/protobuf_includes.h @@ -2,15 +2,7 @@ #pragma once -// Disable warnings emitted by protoc generated files -#pragma GCC diagnostic push -#ifndef __clang__ -#pragma GCC diagnostic ignored "-Wsuggest-override" -#endif - #include <vespa/storageapi/mbusprot/feed.pb.h> #include <vespa/storageapi/mbusprot/inspect.pb.h> #include <vespa/storageapi/mbusprot/visiting.pb.h> #include <vespa/storageapi/mbusprot/maintenance.pb.h> - -#pragma GCC diagnostic pop diff --git a/vespalib/src/tests/btree/btree-stress/btree_stress_test.cpp b/vespalib/src/tests/btree/btree-stress/btree_stress_test.cpp index 2993bae90c4..44decb9bf91 100644 --- a/vespalib/src/tests/btree/btree-stress/btree_stress_test.cpp +++ b/vespalib/src/tests/btree/btree-stress/btree_stress_test.cpp @@ -505,12 +505,6 @@ using TestTypes = testing::Types<DirectKeyValueParams, IndirectKeyValueParams>; TYPED_TEST_SUITE(BTreeStressTest, TestTypes); -// Disable warnings emitted by gtest generated files when using typed tests -#pragma GCC diagnostic push -#ifndef __clang__ -#pragma GCC diagnostic ignored "-Wsuggest-override" -#endif - TYPED_TEST(BTreeStressTest, basic_lower_bound) { this->basic_lower_bound(); @@ -531,8 +525,6 @@ TYPED_TEST(BTreeStressTest, multiple_lower_bound_readers_during_updates) this->multiple_lower_bound_readers_during_updates(); } -#pragma GCC diagnostic pop - int main(int argc, char **argv) { if (argc > 1 && argv[1] == smoke_test_option) { smoke_test = true; diff --git a/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp b/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp index bc1aac3a8cd..176792962a6 100644 --- a/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp +++ b/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp @@ -290,12 +290,6 @@ struct HashSmallOffsetNumberUniqueStore using UniqueStoreTestTypes = ::testing::Types<BTreeNumberUniqueStore, BTreeStringUniqueStore, BTreeCStringUniqueStore, BTreeDoubleUniqueStore, HybridNumberUniqueStore, HybridStringUniqueStore, HybridCStringUniqueStore, HybridDoubleUniqueStore, HashNumberUniqueStore, HashStringUniqueStore, HashCStringUniqueStore, HashDoubleUniqueStore>; TYPED_TEST_SUITE(TestBase, UniqueStoreTestTypes); -// Disable warnings emitted by gtest generated files when using typed tests -#pragma GCC diagnostic push -#ifndef __clang__ -#pragma GCC diagnostic ignored "-Wsuggest-override" -#endif - using NumberTest = TestBase<BTreeNumberUniqueStore>; using StringTest = TestBase<BTreeStringUniqueStore>; using CStringTest = TestBase<BTreeCStringUniqueStore>; @@ -442,8 +436,6 @@ TYPED_TEST(TestBase, provided_memory_allocator_is_used) } } -#pragma GCC diagnostic pop - TEST_F(DoubleTest, nan_is_handled) { std::vector<double> myvalues = { diff --git a/vespalib/src/tests/datastore/unique_store_dictionary/unique_store_dictionary_test.cpp b/vespalib/src/tests/datastore/unique_store_dictionary/unique_store_dictionary_test.cpp index 61853079af6..420d2cfa8c3 100644 --- a/vespalib/src/tests/datastore/unique_store_dictionary/unique_store_dictionary_test.cpp +++ b/vespalib/src/tests/datastore/unique_store_dictionary/unique_store_dictionary_test.cpp @@ -4,7 +4,6 @@ #include <vespa/vespalib/datastore/unique_store.hpp> #include <vespa/vespalib/datastore/unique_store_dictionary.hpp> #include <vespa/vespalib/datastore/sharded_hash_map.h> -#include <vespa/vespalib/util/memoryusage.h> #include <vespa/vespalib/gtest/gtest.h> #include <vespa/log/log.h> @@ -25,7 +24,7 @@ private: } public: - Comparator(uint32_t to_find) + explicit Comparator(uint32_t to_find) : _to_find(to_find) {} bool less(const EntryRef lhs, const EntryRef rhs) const override { @@ -77,12 +76,6 @@ struct UniqueStoreDictionaryTest : public ::testing::Test { using UniqueStoreDictionaryTestTypes = ::testing::Types<DefaultUniqueStoreDictionary, UniqueStoreDictionary<DefaultDictionary, IUniqueStoreDictionary, ShardedHashMap>, UniqueStoreDictionary<NoBTreeDictionary, IUniqueStoreDictionary, ShardedHashMap>>; TYPED_TEST_SUITE(UniqueStoreDictionaryTest, UniqueStoreDictionaryTestTypes); -// Disable warnings emitted by gtest generated files when using typed tests -#pragma GCC diagnostic push -#ifndef __clang__ -#pragma GCC diagnostic ignored "-Wsuggest-override" -#endif - TYPED_TEST(UniqueStoreDictionaryTest, can_count_occurrences_of_a_key) { this->add(3).add(5).take_snapshot(); @@ -165,6 +158,4 @@ TYPED_TEST(UniqueStoreDictionaryTest, compaction_works) EXPECT_EQ(exp_refs, refs); } -#pragma GCC diagnostic pop - GTEST_MAIN_RUN_ALL_TESTS() |