From e46727fb40ba59c13e5eef58cd394bde6471b0a6 Mon Sep 17 00:00:00 2001 From: Andrew Chang Date: Mon, 16 Dec 2024 11:15:00 -0800 Subject: [PATCH 1/4] Add -Wsuggest-destructor-override check --- Makefile | 3 ++- cache/sharded_cache.h | 4 ++-- include/rocksdb/advanced_cache.h | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 317b967ca41..88cb5c8deaa 100644 --- a/Makefile +++ b/Makefile @@ -552,7 +552,8 @@ endif ifdef USE_CLANG # Used by some teams in Facebook WARNING_FLAGS += -Wshift-sign-overflow -Wambiguous-reversed-operator \ - -Wimplicit-fallthrough -Wreinterpret-base-class -Wundefined-reinterpret-cast + -Wimplicit-fallthrough -Wreinterpret-base-class -Wundefined-reinterpret-cast \ + -Wsuggest-destructor-override endif ifeq ($(PLATFORM), OS_OPENBSD) diff --git a/cache/sharded_cache.h b/cache/sharded_cache.h index 6b32ba2dc90..499c47b0c77 100644 --- a/cache/sharded_cache.h +++ b/cache/sharded_cache.h @@ -90,7 +90,7 @@ class CacheShardBase { class ShardedCacheBase : public Cache { public: explicit ShardedCacheBase(const ShardedCacheOptions& opts); - virtual ~ShardedCacheBase() = default; + virtual ~ShardedCacheBase() override = default; int GetNumShardBits() const; uint32_t GetNumShards() const; @@ -143,7 +143,7 @@ class ShardedCache : public ShardedCacheBase { sizeof(CacheShard) * GetNumShards()))), destroy_shards_in_dtor_(false) {} - virtual ~ShardedCache() { + virtual ~ShardedCache() override { if (destroy_shards_in_dtor_) { ForEachShard([](CacheShard* cs) { cs->~CacheShard(); }); } diff --git a/include/rocksdb/advanced_cache.h b/include/rocksdb/advanced_cache.h index d8eeb7d2e38..b18cce7d6d3 100644 --- a/include/rocksdb/advanced_cache.h +++ b/include/rocksdb/advanced_cache.h @@ -188,7 +188,7 @@ class Cache : public Customizable { Cache& operator=(const Cache&) = delete; // Destroys all remaining entries by calling the associated "deleter" - virtual ~Cache() {} + virtual ~Cache() override {} static const char* Type() { return "Cache"; } @@ -209,7 +209,7 @@ class Cache : public Customizable { public: // functions // The type of the Cache - virtual const char* Name() const = 0; + virtual const char* Name() const override = 0; // The Insert and Lookup APIs below are intended to allow cached objects // to be demoted/promoted between the primary block cache and a secondary @@ -425,7 +425,7 @@ class Cache : public Customizable { // Prerequisite: no entry is referenced. virtual void EraseUnRefEntries() = 0; - virtual std::string GetPrintableOptions() const { return ""; } + virtual std::string GetPrintableOptions() const override { return ""; } // Check for any warnings or errors in the operation of the cache and // report them to the logger. This is intended only to be called From 47a9043f06d390000d5d41a588716e166dc413d6 Mon Sep 17 00:00:00 2001 From: Andrew Chang Date: Mon, 16 Dec 2024 15:36:21 -0800 Subject: [PATCH 2/4] update destructors --- db/column_family.h | 2 +- db/compaction/compaction_picker.h | 2 +- db/db_impl/db_impl.h | 6 +++--- db/db_impl/db_impl_follower.h | 2 +- db/db_impl/db_impl_readonly.h | 3 +-- db/dbformat.h | 2 +- db/experimental.cc | 3 +-- db/forward_iterator.h | 5 ++--- db/snapshot_checker.h | 4 ++-- db/table_properties_collector.h | 2 +- db/write_controller.h | 6 +++--- env/env_encryption_ctr.h | 8 +++----- env/fs_on_demand.h | 2 +- env/io_posix.h | 16 ++++++++-------- file/sst_file_manager_impl.h | 2 +- include/rocksdb/compaction_filter.h | 4 ++-- include/rocksdb/env_encryption.h | 8 +++----- include/rocksdb/file_system.h | 2 +- include/rocksdb/filter_policy.h | 2 +- include/rocksdb/flush_block_policy.h | 2 +- include/rocksdb/merge_operator.h | 2 +- include/rocksdb/slice_transform.h | 2 +- include/rocksdb/utilities/backup_engine.h | 4 ++-- include/rocksdb/utilities/env_mirror.h | 4 +--- include/rocksdb/wal_filter.h | 2 +- logging/auto_roll_logger.h | 2 +- logging/env_logger.h | 2 +- memory/arena.h | 2 +- monitoring/histogram.h | 4 ++-- monitoring/histogram_windowing.h | 2 +- monitoring/statistics_impl.h | 2 +- table/adaptive/adaptive_table_factory.h | 3 +-- table/block_based/block_based_table_builder.h | 2 +- table/block_based/block_based_table_factory.h | 2 +- table/block_based/block_based_table_reader.h | 2 +- table/block_based/full_filter_block.h | 2 +- table/block_based/partitioned_filter_block.h | 2 +- table/cuckoo/cuckoo_table_builder.h | 3 +-- table/cuckoo/cuckoo_table_factory.h | 2 +- table/cuckoo/cuckoo_table_reader.h | 2 +- table/plain/plain_table_builder.h | 2 +- table/plain/plain_table_factory.h | 2 +- table/plain/plain_table_reader.h | 2 +- trace_replay/block_cache_tracer.h | 4 ++-- util/concurrent_task_limiter_impl.h | 2 +- util/rate_limiter_impl.h | 2 +- util/threadpool_imp.h | 2 +- utilities/blob_db/blob_db_impl.h | 3 +-- utilities/blob_db/blob_db_iterator.h | 2 +- utilities/cache_dump_load_impl.h | 8 ++++---- utilities/counted_fs.cc | 2 +- utilities/fault_injection_env.h | 8 ++++---- utilities/fault_injection_fs.h | 10 +++++----- utilities/persistent_cache/block_cache_tier.h | 4 +--- .../persistent_cache/block_cache_tier_file.h | 10 ++++------ .../persistent_cache/hash_table_evictable.h | 4 +--- .../persistent_cache/persistent_cache_tier.h | 6 ++---- utilities/persistent_cache/volatile_tier_impl.h | 6 ++---- utilities/trace/file_trace_reader_writer.h | 4 ++-- utilities/transactions/optimistic_transaction.h | 4 +--- .../optimistic_transaction_db_impl.h | 2 +- .../transactions/pessimistic_transaction_db.h | 4 ++-- utilities/transactions/write_prepared_txn.h | 2 +- utilities/transactions/write_prepared_txn_db.h | 4 ++-- utilities/transactions/write_unprepared_txn.h | 7 +++---- utilities/ttl/db_ttl_impl.h | 4 ++-- 66 files changed, 108 insertions(+), 133 deletions(-) diff --git a/db/column_family.h b/db/column_family.h index 4cb6ab59658..93eebdadadb 100644 --- a/db/column_family.h +++ b/db/column_family.h @@ -168,7 +168,7 @@ class ColumnFamilyHandleImpl : public ColumnFamilyHandle { ColumnFamilyHandleImpl(ColumnFamilyData* cfd, DBImpl* db, InstrumentedMutex* mutex); // destroy without mutex - virtual ~ColumnFamilyHandleImpl(); + virtual ~ColumnFamilyHandleImpl() override; virtual ColumnFamilyData* cfd() const { return cfd_; } virtual DBImpl* db() const { return db_; } diff --git a/db/compaction/compaction_picker.h b/db/compaction/compaction_picker.h index 33e6b38e5b4..b6bb3ccda38 100644 --- a/db/compaction/compaction_picker.h +++ b/db/compaction/compaction_picker.h @@ -255,7 +255,7 @@ class NullCompactionPicker : public CompactionPicker { NullCompactionPicker(const ImmutableOptions& ioptions, const InternalKeyComparator* icmp) : CompactionPicker(ioptions, icmp) {} - virtual ~NullCompactionPicker() {} + virtual ~NullCompactionPicker() override {} // Always return "nullptr" Compaction* PickCompaction( diff --git a/db/db_impl/db_impl.h b/db/db_impl/db_impl.h index 7ceecd28229..a5c30fcb3e8 100644 --- a/db/db_impl/db_impl.h +++ b/db/db_impl/db_impl.h @@ -195,7 +195,7 @@ class DBImpl : public DB { DBImpl(const DBImpl&) = delete; void operator=(const DBImpl&) = delete; - virtual ~DBImpl(); + virtual ~DBImpl() override; // ---- Implementations of the DB interface ---- @@ -1921,8 +1921,8 @@ class DBImpl : public DB { const InternalKey* begin = nullptr; // nullptr means beginning of key range const InternalKey* end = nullptr; // nullptr means end of key range InternalKey* manual_end = nullptr; // how far we are compacting - InternalKey tmp_storage; // Used to keep track of compaction progress - InternalKey tmp_storage1; // Used to keep track of compaction progress + InternalKey tmp_storage; // Used to keep track of compaction progress + InternalKey tmp_storage1; // Used to keep track of compaction progress // When the user provides a canceled pointer in CompactRangeOptions, the // above varaibe is the reference of the user-provided diff --git a/db/db_impl/db_impl_follower.h b/db/db_impl/db_impl_follower.h index 374c60d5c64..b85c4e9d6b5 100644 --- a/db/db_impl/db_impl_follower.h +++ b/db/db_impl/db_impl_follower.h @@ -19,7 +19,7 @@ class DBImplFollower : public DBImplSecondary { public: DBImplFollower(const DBOptions& db_options, std::unique_ptr&& env, const std::string& dbname, std::string src_path); - ~DBImplFollower(); + ~DBImplFollower() override; Status Close() override; diff --git a/db/db_impl/db_impl_readonly.h b/db/db_impl/db_impl_readonly.h index 7e39573a717..91752af7f03 100644 --- a/db/db_impl/db_impl_readonly.h +++ b/db/db_impl/db_impl_readonly.h @@ -5,7 +5,6 @@ #pragma once - #include #include @@ -21,7 +20,7 @@ class DBImplReadOnly : public DBImpl { DBImplReadOnly(const DBImplReadOnly&) = delete; void operator=(const DBImplReadOnly&) = delete; - virtual ~DBImplReadOnly(); + virtual ~DBImplReadOnly() override; // Implementations of the DB interface using DBImpl::GetImpl; diff --git a/db/dbformat.h b/db/dbformat.h index f3a9b9a1a52..1f4b74b824b 100644 --- a/db/dbformat.h +++ b/db/dbformat.h @@ -396,7 +396,7 @@ class InternalKeyComparator // overhead, set `named` to false. In that case, `Name()` will return a // generic name that is non-specific to the underlying comparator. explicit InternalKeyComparator(const Comparator* c) : user_comparator_(c) {} - virtual ~InternalKeyComparator() {} + virtual ~InternalKeyComparator() override {} int Compare(const Slice& a, const Slice& b) const override; diff --git a/db/experimental.cc b/db/experimental.cc index bde66208678..ef0c73cb086 100644 --- a/db/experimental.cc +++ b/db/experimental.cc @@ -37,7 +37,6 @@ Status PromoteL0(DB* db, ColumnFamilyHandle* column_family, int target_level) { return db->PromoteL0(column_family, target_level); } - Status SuggestCompactRange(DB* db, const Slice* begin, const Slice* end) { return SuggestCompactRange(db, db->DefaultColumnFamily(), begin, end); } @@ -517,7 +516,7 @@ class SstQueryFilterConfigImpl : public SstQueryFilterConfig { const KeySegmentsExtractor::KeyCategorySet& categories) : input_(input), categories_(categories) {} - virtual ~SstQueryFilterConfigImpl() = default; + virtual ~SstQueryFilterConfigImpl() override = default; virtual std::unique_ptr NewBuilder( bool sanity_checks) const = 0; diff --git a/db/forward_iterator.h b/db/forward_iterator.h index 9f1b4379b9d..1089c17f095 100644 --- a/db/forward_iterator.h +++ b/db/forward_iterator.h @@ -4,13 +4,12 @@ // (found in the LICENSE.Apache file in the root directory). #pragma once -#include "rocksdb/comparator.h" - #include #include #include #include "memory/arena.h" +#include "rocksdb/comparator.h" #include "rocksdb/db.h" #include "rocksdb/iterator.h" #include "rocksdb/options.h" @@ -55,7 +54,7 @@ class ForwardIterator : public InternalIterator { ForwardIterator(DBImpl* db, const ReadOptions& read_options, ColumnFamilyData* cfd, SuperVersion* current_sv = nullptr, bool allow_unprepared_value = false); - virtual ~ForwardIterator(); + virtual ~ForwardIterator() override; void SeekForPrev(const Slice& /*target*/) override { status_ = Status::NotSupported("ForwardIterator::SeekForPrev()"); diff --git a/db/snapshot_checker.h b/db/snapshot_checker.h index e221914d79c..c07b4e9aa5b 100644 --- a/db/snapshot_checker.h +++ b/db/snapshot_checker.h @@ -26,7 +26,7 @@ class SnapshotChecker { class DisableGCSnapshotChecker : public SnapshotChecker { public: - virtual ~DisableGCSnapshotChecker() {} + virtual ~DisableGCSnapshotChecker() override {} SnapshotCheckerResult CheckInSnapshot( SequenceNumber /*sequence*/, SequenceNumber /*snapshot_sequence*/) const override { @@ -46,7 +46,7 @@ class WritePreparedTxnDB; class WritePreparedSnapshotChecker : public SnapshotChecker { public: explicit WritePreparedSnapshotChecker(WritePreparedTxnDB* txn_db); - virtual ~WritePreparedSnapshotChecker() {} + virtual ~WritePreparedSnapshotChecker() override {} SnapshotCheckerResult CheckInSnapshot( SequenceNumber sequence, SequenceNumber snapshot_sequence) const override; diff --git a/db/table_properties_collector.h b/db/table_properties_collector.h index 6b745b6549b..aac2955e93d 100644 --- a/db/table_properties_collector.h +++ b/db/table_properties_collector.h @@ -66,7 +66,7 @@ class UserKeyTablePropertiesCollector : public InternalTblPropColl { explicit UserKeyTablePropertiesCollector(TablePropertiesCollector* collector) : collector_(collector) {} - virtual ~UserKeyTablePropertiesCollector() {} + virtual ~UserKeyTablePropertiesCollector() override {} Status InternalAdd(const Slice& key, const Slice& value, uint64_t file_size) override; diff --git a/db/write_controller.h b/db/write_controller.h index bcead165b34..5f0a602173a 100644 --- a/db/write_controller.h +++ b/db/write_controller.h @@ -128,21 +128,21 @@ class StopWriteToken : public WriteControllerToken { public: explicit StopWriteToken(WriteController* controller) : WriteControllerToken(controller) {} - virtual ~StopWriteToken(); + virtual ~StopWriteToken() override; }; class DelayWriteToken : public WriteControllerToken { public: explicit DelayWriteToken(WriteController* controller) : WriteControllerToken(controller) {} - virtual ~DelayWriteToken(); + virtual ~DelayWriteToken() override; }; class CompactionPressureToken : public WriteControllerToken { public: explicit CompactionPressureToken(WriteController* controller) : WriteControllerToken(controller) {} - virtual ~CompactionPressureToken(); + virtual ~CompactionPressureToken() override; }; } // namespace ROCKSDB_NAMESPACE diff --git a/env/env_encryption_ctr.h b/env/env_encryption_ctr.h index 21abbe231d8..2db67f22fcf 100644 --- a/env/env_encryption_ctr.h +++ b/env/env_encryption_ctr.h @@ -5,7 +5,6 @@ #pragma once - #include "rocksdb/env_encryption.h" namespace ROCKSDB_NAMESPACE { @@ -24,8 +23,8 @@ class CTRCipherStream final : public BlockAccessCipherStream { public: CTRCipherStream(const std::shared_ptr& c, const char* iv, uint64_t initialCounter) - : cipher_(c), iv_(iv, c->BlockSize()), initialCounter_(initialCounter){} - virtual ~CTRCipherStream(){} + : cipher_(c), iv_(iv, c->BlockSize()), initialCounter_(initialCounter) {} + virtual ~CTRCipherStream() override {} size_t BlockSize() override { return cipher_->BlockSize(); } @@ -55,7 +54,7 @@ class CTREncryptionProvider : public EncryptionProvider { public: explicit CTREncryptionProvider( const std::shared_ptr& c = nullptr); - virtual ~CTREncryptionProvider() {} + virtual ~CTREncryptionProvider() override {} static const char* kClassName() { return "CTR"; } const char* Name() const override { return kClassName(); } @@ -94,4 +93,3 @@ Status NewEncryptedFileSystemImpl( std::unique_ptr* fs); } // namespace ROCKSDB_NAMESPACE - diff --git a/env/fs_on_demand.h b/env/fs_on_demand.h index e313103d6c5..f1eb22143b7 100644 --- a/env/fs_on_demand.h +++ b/env/fs_on_demand.h @@ -100,7 +100,7 @@ class OnDemandSequentialFile : public FSSequentialFile { eof_(false), offset_(0) {} - virtual ~OnDemandSequentialFile() {} + virtual ~OnDemandSequentialFile() override {} IOStatus Read(size_t n, const IOOptions& options, Slice* result, char* scratch, IODebugContext* dbg) override; diff --git a/env/io_posix.h b/env/io_posix.h index 60788df9bf8..9ff1261a395 100644 --- a/env/io_posix.h +++ b/env/io_posix.h @@ -273,7 +273,7 @@ class PosixSequentialFile : public FSSequentialFile { public: PosixSequentialFile(const std::string& fname, FILE* file, int fd, size_t logical_block_size, const EnvOptions& options); - virtual ~PosixSequentialFile(); + virtual ~PosixSequentialFile() override; IOStatus Read(size_t n, const IOOptions& opts, Slice* result, char* scratch, IODebugContext* dbg) override; @@ -326,7 +326,7 @@ class PosixRandomAccessFile : public FSRandomAccessFile { ThreadLocalPtr* thread_local_io_urings #endif ); - virtual ~PosixRandomAccessFile(); + virtual ~PosixRandomAccessFile() override; IOStatus Read(uint64_t offset, size_t n, const IOOptions& opts, Slice* result, char* scratch, IODebugContext* dbg) const override; @@ -375,7 +375,7 @@ class PosixWritableFile : public FSWritableFile { explicit PosixWritableFile(const std::string& fname, int fd, size_t logical_block_size, const EnvOptions& options); - virtual ~PosixWritableFile(); + virtual ~PosixWritableFile() override; // Need to implement this so the file is truncated correctly // with direct I/O @@ -431,7 +431,7 @@ class PosixMmapReadableFile : public FSRandomAccessFile { public: PosixMmapReadableFile(const int fd, const std::string& fname, void* base, size_t length, const EnvOptions& options); - virtual ~PosixMmapReadableFile(); + virtual ~PosixMmapReadableFile() override; IOStatus Read(uint64_t offset, size_t n, const IOOptions& opts, Slice* result, char* scratch, IODebugContext* dbg) const override; void Hint(AccessPattern pattern) override; @@ -470,7 +470,7 @@ class PosixMmapFile : public FSWritableFile { public: PosixMmapFile(const std::string& fname, int fd, size_t page_size, const EnvOptions& options); - ~PosixMmapFile(); + ~PosixMmapFile() override; // Means Close() will properly take care of truncate // and it does not need any additional information @@ -501,7 +501,7 @@ class PosixRandomRWFile : public FSRandomRWFile { public: explicit PosixRandomRWFile(const std::string& fname, int fd, const EnvOptions& options); - virtual ~PosixRandomRWFile(); + virtual ~PosixRandomRWFile() override; IOStatus Write(uint64_t offset, const Slice& data, const IOOptions& opts, IODebugContext* dbg) override; @@ -522,13 +522,13 @@ class PosixRandomRWFile : public FSRandomRWFile { struct PosixMemoryMappedFileBuffer : public MemoryMappedFileBuffer { PosixMemoryMappedFileBuffer(void* _base, size_t _length) : MemoryMappedFileBuffer(_base, _length) {} - virtual ~PosixMemoryMappedFileBuffer(); + virtual ~PosixMemoryMappedFileBuffer() override; }; class PosixDirectory : public FSDirectory { public: explicit PosixDirectory(int fd, const std::string& directory_name); - ~PosixDirectory(); + ~PosixDirectory() override; IOStatus Fsync(const IOOptions& opts, IODebugContext* dbg) override; IOStatus Close(const IOOptions& opts, IODebugContext* dbg) override; diff --git a/file/sst_file_manager_impl.h b/file/sst_file_manager_impl.h index 96ec271eee3..af64eed1dba 100644 --- a/file/sst_file_manager_impl.h +++ b/file/sst_file_manager_impl.h @@ -34,7 +34,7 @@ class SstFileManagerImpl : public SstFileManager { SstFileManagerImpl(const SstFileManagerImpl& sfm) = delete; SstFileManagerImpl& operator=(const SstFileManagerImpl& sfm) = delete; - ~SstFileManagerImpl(); + ~SstFileManagerImpl() override; // DB will call OnAddFile whenever a new sst/blob file is added. Status OnAddFile(const std::string& file_path); diff --git a/include/rocksdb/compaction_filter.h b/include/rocksdb/compaction_filter.h index 66f2f390e7d..1e9acf8eaa0 100644 --- a/include/rocksdb/compaction_filter.h +++ b/include/rocksdb/compaction_filter.h @@ -177,7 +177,7 @@ class CompactionFilter : public Customizable { static const int kUnknownStartLevel = -1; }; - virtual ~CompactionFilter() {} + virtual ~CompactionFilter() override {} static const char* Type() { return "CompactionFilter"; } static Status CreateFromString(const ConfigOptions& config_options, const std::string& name, @@ -348,7 +348,7 @@ class CompactionFilter : public Customizable { // including data loss, unreported corruption, deadlocks, and more. class CompactionFilterFactory : public Customizable { public: - virtual ~CompactionFilterFactory() {} + virtual ~CompactionFilterFactory() override {} static const char* Type() { return "CompactionFilterFactory"; } static Status CreateFromString( const ConfigOptions& config_options, const std::string& name, diff --git a/include/rocksdb/env_encryption.h b/include/rocksdb/env_encryption.h index a782a1a6e79..c8e898d96be 100644 --- a/include/rocksdb/env_encryption.h +++ b/include/rocksdb/env_encryption.h @@ -5,7 +5,6 @@ #pragma once - #include #include "rocksdb/customizable.h" @@ -32,7 +31,7 @@ std::shared_ptr NewEncryptedFS( // blocks). E.g. CTR (Counter operation mode) supports this requirement. class BlockAccessCipherStream { public: - virtual ~BlockAccessCipherStream(){} + virtual ~BlockAccessCipherStream() {} // BlockSize returns the size of each block supported by this cipher stream. virtual size_t BlockSize() = 0; @@ -67,7 +66,7 @@ class BlockAccessCipherStream { // including data loss, unreported corruption, deadlocks, and more. class BlockCipher : public Customizable { public: - virtual ~BlockCipher() {} + virtual ~BlockCipher() override {} // Creates a new BlockCipher from the input config_options and value // The value describes the type of provider (and potentially optional @@ -114,7 +113,7 @@ class BlockCipher : public Customizable { // including data loss, unreported corruption, deadlocks, and more. class EncryptionProvider : public Customizable { public: - virtual ~EncryptionProvider() {} + virtual ~EncryptionProvider() override {} // Creates a new EncryptionProvider from the input config_options and value. // The value describes the type of provider (and potentially optional @@ -360,4 +359,3 @@ class EncryptedFileSystem : public FileSystemWrapper { } }; } // namespace ROCKSDB_NAMESPACE - diff --git a/include/rocksdb/file_system.h b/include/rocksdb/file_system.h index 27e497f432b..7e60c049849 100644 --- a/include/rocksdb/file_system.h +++ b/include/rocksdb/file_system.h @@ -296,7 +296,7 @@ class FileSystem : public Customizable { // No copying allowed FileSystem(const FileSystem&) = delete; - virtual ~FileSystem(); + virtual ~FileSystem() override; static const char* Type() { return "FileSystem"; } static const char* kDefaultName() { return "DefaultFileSystem"; } diff --git a/include/rocksdb/filter_policy.h b/include/rocksdb/filter_policy.h index e40e483c396..c1529e3351d 100644 --- a/include/rocksdb/filter_policy.h +++ b/include/rocksdb/filter_policy.h @@ -88,7 +88,7 @@ struct FilterBuildingContext { // GetBuilderWithContext. class FilterPolicy : public Customizable { public: - virtual ~FilterPolicy(); + virtual ~FilterPolicy() override; static const char* Type() { return "FilterPolicy"; } // The name used for identifying whether a filter on disk is readable diff --git a/include/rocksdb/flush_block_policy.h b/include/rocksdb/flush_block_policy.h index 7a5dd957e4e..87bea766a1a 100644 --- a/include/rocksdb/flush_block_policy.h +++ b/include/rocksdb/flush_block_policy.h @@ -53,7 +53,7 @@ class FlushBlockPolicyFactory : public Customizable { const BlockBasedTableOptions& table_options, const BlockBuilder& data_block_builder) const = 0; - virtual ~FlushBlockPolicyFactory() {} + virtual ~FlushBlockPolicyFactory() override {} }; class FlushBlockBySizePolicyFactory : public FlushBlockPolicyFactory { diff --git a/include/rocksdb/merge_operator.h b/include/rocksdb/merge_operator.h index 387e5345c00..aa8cf5b341d 100644 --- a/include/rocksdb/merge_operator.h +++ b/include/rocksdb/merge_operator.h @@ -52,7 +52,7 @@ class Logger; // including data loss, unreported corruption, deadlocks, and more. class MergeOperator : public Customizable { public: - virtual ~MergeOperator() {} + virtual ~MergeOperator() override {} static const char* Type() { return "MergeOperator"; } static Status CreateFromString(const ConfigOptions& opts, const std::string& id, diff --git a/include/rocksdb/slice_transform.h b/include/rocksdb/slice_transform.h index 166cbc94b94..769958db272 100644 --- a/include/rocksdb/slice_transform.h +++ b/include/rocksdb/slice_transform.h @@ -34,7 +34,7 @@ struct ConfigOptions; // including data loss, unreported corruption, deadlocks, and more. class SliceTransform : public Customizable { public: - virtual ~SliceTransform(){} + virtual ~SliceTransform() override {} // Return the name of this transformation. const char* Name() const override = 0; diff --git a/include/rocksdb/utilities/backup_engine.h b/include/rocksdb/utilities/backup_engine.h index 204d12d6fea..dacbee07d6f 100644 --- a/include/rocksdb/utilities/backup_engine.h +++ b/include/rocksdb/utilities/backup_engine.h @@ -647,7 +647,7 @@ class BackupEngineAppendOnlyBase { class BackupEngine : public BackupEngineReadOnlyBase, public BackupEngineAppendOnlyBase { public: - virtual ~BackupEngine() {} + virtual ~BackupEngine() override {} // BackupEngineOptions have to be the same as the ones used in previous // BackupEngines for the same backup directory. @@ -675,7 +675,7 @@ class BackupEngine : public BackupEngineReadOnlyBase, // BackupEngine comment for details. This class is not user-extensible. class BackupEngineReadOnly : public BackupEngineReadOnlyBase { public: - virtual ~BackupEngineReadOnly() {} + virtual ~BackupEngineReadOnly() override {} static IOStatus Open(const BackupEngineOptions& options, Env* db_env, BackupEngineReadOnly** backup_engine_ptr); diff --git a/include/rocksdb/utilities/env_mirror.h b/include/rocksdb/utilities/env_mirror.h index 0172b20a7e2..37fa764105c 100644 --- a/include/rocksdb/utilities/env_mirror.h +++ b/include/rocksdb/utilities/env_mirror.h @@ -18,7 +18,6 @@ #pragma once - #include #include #include @@ -38,7 +37,7 @@ class EnvMirror : public EnvWrapper { public: EnvMirror(Env* a, Env* b, bool free_a = false, bool free_b = false) : EnvWrapper(a), a_(a), b_(b), free_a_(free_a), free_b_(free_b) {} - ~EnvMirror() { + ~EnvMirror() override { if (free_a_) delete a_; if (free_b_) delete b_; } @@ -176,4 +175,3 @@ class EnvMirror : public EnvWrapper { }; } // namespace ROCKSDB_NAMESPACE - diff --git a/include/rocksdb/wal_filter.h b/include/rocksdb/wal_filter.h index 75e030d2fcf..ed2f17caa8d 100644 --- a/include/rocksdb/wal_filter.h +++ b/include/rocksdb/wal_filter.h @@ -42,7 +42,7 @@ class WalFilter : public Customizable { kWalProcessingOptionMax = 4 }; - virtual ~WalFilter() {} + virtual ~WalFilter() override {} // Provide ColumnFamily->LogNumber map to filter // so that filter can determine whether a log number applies to a given diff --git a/logging/auto_roll_logger.h b/logging/auto_roll_logger.h index be0b14051a6..7e41fa16bfd 100644 --- a/logging/auto_roll_logger.h +++ b/logging/auto_roll_logger.h @@ -67,7 +67,7 @@ class AutoRollLogger : public Logger { } } - virtual ~AutoRollLogger() { + virtual ~AutoRollLogger() override { if (logger_ && !closed_) { logger_->Close().PermitUncheckedError(); } diff --git a/logging/env_logger.h b/logging/env_logger.h index b236dc817cd..e8a5979825d 100644 --- a/logging/env_logger.h +++ b/logging/env_logger.h @@ -40,7 +40,7 @@ class EnvLogger : public Logger { last_flush_micros_(0), flush_pending_(false) {} - ~EnvLogger() { + ~EnvLogger() override { if (!closed_) { closed_ = true; CloseHelper().PermitUncheckedError(); diff --git a/memory/arena.h b/memory/arena.h index 2257a4935dd..d1f744348f3 100644 --- a/memory/arena.h +++ b/memory/arena.h @@ -41,7 +41,7 @@ class Arena : public Allocator { // page TLB first. If allocation fails, will fall back to normal case. explicit Arena(size_t block_size = kMinBlockSize, AllocTracker* tracker = nullptr, size_t huge_page_size = 0); - ~Arena(); + ~Arena() override; char* Allocate(size_t bytes) override; diff --git a/monitoring/histogram.h b/monitoring/histogram.h index ccfdd8ddd9a..c58e6b89e2e 100644 --- a/monitoring/histogram.h +++ b/monitoring/histogram.h @@ -88,7 +88,7 @@ struct HistogramStat { class Histogram { public: Histogram() {} - virtual ~Histogram(){} + virtual ~Histogram() {} virtual void Clear() = 0; virtual bool Empty() const = 0; @@ -131,7 +131,7 @@ class HistogramImpl : public Histogram { double StandardDeviation() const override; void Data(HistogramData* const data) const override; - virtual ~HistogramImpl() {} + virtual ~HistogramImpl() override {} inline HistogramStat& TEST_GetStats() { return stats_; } diff --git a/monitoring/histogram_windowing.h b/monitoring/histogram_windowing.h index 9f956e19305..30539b5cd7d 100644 --- a/monitoring/histogram_windowing.h +++ b/monitoring/histogram_windowing.h @@ -23,7 +23,7 @@ class HistogramWindowingImpl : public Histogram { HistogramWindowingImpl(const HistogramWindowingImpl&) = delete; HistogramWindowingImpl& operator=(const HistogramWindowingImpl&) = delete; - ~HistogramWindowingImpl(); + ~HistogramWindowingImpl() override; void Clear() override; bool Empty() const override; diff --git a/monitoring/statistics_impl.h b/monitoring/statistics_impl.h index 5dceeace0e8..983ad055b6c 100644 --- a/monitoring/statistics_impl.h +++ b/monitoring/statistics_impl.h @@ -42,7 +42,7 @@ enum HistogramsInternal : uint32_t { class StatisticsImpl : public Statistics { public: StatisticsImpl(std::shared_ptr stats); - virtual ~StatisticsImpl(); + virtual ~StatisticsImpl() override; const char* Name() const override { return kClassName(); } static const char* kClassName() { return "BasicStatistics"; } diff --git a/table/adaptive/adaptive_table_factory.h b/table/adaptive/adaptive_table_factory.h index fe6d4ece4ed..f3da49a05bf 100644 --- a/table/adaptive/adaptive_table_factory.h +++ b/table/adaptive/adaptive_table_factory.h @@ -5,7 +5,6 @@ #pragma once - #include #include "rocksdb/options.h" @@ -23,7 +22,7 @@ class TableBuilder; class AdaptiveTableFactory : public TableFactory { public: - ~AdaptiveTableFactory() {} + ~AdaptiveTableFactory() override {} explicit AdaptiveTableFactory( std::shared_ptr table_factory_to_write, diff --git a/table/block_based/block_based_table_builder.h b/table/block_based/block_based_table_builder.h index f3360f8bcbc..4de5607ff84 100644 --- a/table/block_based/block_based_table_builder.h +++ b/table/block_based/block_based_table_builder.h @@ -50,7 +50,7 @@ class BlockBasedTableBuilder : public TableBuilder { BlockBasedTableBuilder& operator=(const BlockBasedTableBuilder&) = delete; // REQUIRES: Either Finish() or Abandon() has been called. - ~BlockBasedTableBuilder(); + ~BlockBasedTableBuilder() override; // Add key,value to the table being constructed. // REQUIRES: Unless key has type kTypeRangeDeletion, key is after any diff --git a/table/block_based/block_based_table_factory.h b/table/block_based/block_based_table_factory.h index b05b4566040..7b7818eec30 100644 --- a/table/block_based/block_based_table_factory.h +++ b/table/block_based/block_based_table_factory.h @@ -52,7 +52,7 @@ class BlockBasedTableFactory : public TableFactory { explicit BlockBasedTableFactory( const BlockBasedTableOptions& table_options = BlockBasedTableOptions()); - ~BlockBasedTableFactory() {} + ~BlockBasedTableFactory() override {} // Method to allow CheckedCast to work for this class static const char* kClassName() { return kBlockBasedTableName(); } diff --git a/table/block_based/block_based_table_reader.h b/table/block_based/block_based_table_reader.h index 513e517aa85..8e688b2732f 100644 --- a/table/block_based/block_based_table_reader.h +++ b/table/block_based/block_based_table_reader.h @@ -213,7 +213,7 @@ class BlockBasedTable : public TableReader { void MarkObsolete(uint32_t uncache_aggressiveness) override; - ~BlockBasedTable(); + ~BlockBasedTable() override; bool TEST_FilterBlockInCache() const; bool TEST_IndexBlockInCache() const; diff --git a/table/block_based/full_filter_block.h b/table/block_based/full_filter_block.h index 784f0eb881c..7a1dbfc69e2 100644 --- a/table/block_based/full_filter_block.h +++ b/table/block_based/full_filter_block.h @@ -47,7 +47,7 @@ class FullFilterBlockBuilder : public FilterBlockBuilder { // bits_builder is created in filter_policy, it should be passed in here // directly. and be deleted here - ~FullFilterBlockBuilder() {} + ~FullFilterBlockBuilder() override {} void Add(const Slice& key_without_ts) override; void AddWithPrevKey(const Slice& key_without_ts, diff --git a/table/block_based/partitioned_filter_block.h b/table/block_based/partitioned_filter_block.h index 8faed24a92d..f03a4f464ca 100644 --- a/table/block_based/partitioned_filter_block.h +++ b/table/block_based/partitioned_filter_block.h @@ -35,7 +35,7 @@ class PartitionedFilterBlockBuilder : public FullFilterBlockBuilder { const bool persist_user_defined_timestamps, bool decouple_from_index_partitions); - virtual ~PartitionedFilterBlockBuilder(); + virtual ~PartitionedFilterBlockBuilder() override; void Add(const Slice& key_without_ts) override; void AddWithPrevKey(const Slice& key_without_ts, diff --git a/table/cuckoo/cuckoo_table_builder.h b/table/cuckoo/cuckoo_table_builder.h index 3a19dd6f997..e49f5a02cbc 100644 --- a/table/cuckoo/cuckoo_table_builder.h +++ b/table/cuckoo/cuckoo_table_builder.h @@ -37,7 +37,7 @@ class CuckooTableBuilder : public TableBuilder { void operator=(const CuckooTableBuilder&) = delete; // REQUIRES: Either Finish() or Abandon() has been called. - ~CuckooTableBuilder() {} + ~CuckooTableBuilder() override {} // Add key,value to the table being constructed. // REQUIRES: key is after any previously added key according to comparator. @@ -133,4 +133,3 @@ class CuckooTableBuilder : public TableBuilder { }; } // namespace ROCKSDB_NAMESPACE - diff --git a/table/cuckoo/cuckoo_table_factory.h b/table/cuckoo/cuckoo_table_factory.h index 64077217d83..1aca1020b5b 100644 --- a/table/cuckoo/cuckoo_table_factory.h +++ b/table/cuckoo/cuckoo_table_factory.h @@ -54,7 +54,7 @@ class CuckooTableFactory : public TableFactory { public: explicit CuckooTableFactory( const CuckooTableOptions& table_option = CuckooTableOptions()); - ~CuckooTableFactory() {} + ~CuckooTableFactory() override {} // Method to allow CheckedCast to work for this class static const char* kClassName() { return kCuckooTableName(); } diff --git a/table/cuckoo/cuckoo_table_reader.h b/table/cuckoo/cuckoo_table_reader.h index d17011ed83e..9424151b3a4 100644 --- a/table/cuckoo/cuckoo_table_reader.h +++ b/table/cuckoo/cuckoo_table_reader.h @@ -31,7 +31,7 @@ class CuckooTableReader : public TableReader { uint64_t file_size, const Comparator* user_comparator, uint64_t (*get_slice_hash)(const Slice&, uint32_t, uint64_t)); - ~CuckooTableReader() {} + ~CuckooTableReader() override {} std::shared_ptr GetTableProperties() const override { return table_props_; diff --git a/table/plain/plain_table_builder.h b/table/plain/plain_table_builder.h index 30e9558628a..360492a36e5 100644 --- a/table/plain/plain_table_builder.h +++ b/table/plain/plain_table_builder.h @@ -53,7 +53,7 @@ class PlainTableBuilder : public TableBuilder { void operator=(const PlainTableBuilder&) = delete; // REQUIRES: Either Finish() or Abandon() has been called. - ~PlainTableBuilder(); + ~PlainTableBuilder() override; // Add key,value to the table being constructed. // REQUIRES: key is after any previously added key according to comparator. diff --git a/table/plain/plain_table_factory.h b/table/plain/plain_table_factory.h index d6055ccbdb8..6680436b2f4 100644 --- a/table/plain/plain_table_factory.h +++ b/table/plain/plain_table_factory.h @@ -137,7 +137,7 @@ class TableBuilder; // class PlainTableFactory : public TableFactory { public: - ~PlainTableFactory() {} + ~PlainTableFactory() override {} // user_key_len is the length of the user key. If it is set to be // kPlainTableVariableLength, then it means variable length. Otherwise, all // the keys need to have the fix length of this value. bloom_bits_per_key is diff --git a/table/plain/plain_table_reader.h b/table/plain/plain_table_reader.h index b127e22c0f4..ef994f973e3 100644 --- a/table/plain/plain_table_reader.h +++ b/table/plain/plain_table_reader.h @@ -117,7 +117,7 @@ class PlainTableReader : public TableReader { EncodingType encoding_type, uint64_t file_size, const TableProperties* table_properties, const SliceTransform* prefix_extractor); - virtual ~PlainTableReader(); + virtual ~PlainTableReader() override; protected: // Check bloom filter to see whether it might contain this prefix. diff --git a/trace_replay/block_cache_tracer.h b/trace_replay/block_cache_tracer.h index 301c7d95ee9..97027847166 100644 --- a/trace_replay/block_cache_tracer.h +++ b/trace_replay/block_cache_tracer.h @@ -118,7 +118,7 @@ class BlockCacheTraceWriterImpl : public BlockCacheTraceWriter { BlockCacheTraceWriterImpl(SystemClock* clock, const BlockCacheTraceWriterOptions& trace_options, std::unique_ptr&& trace_writer); - ~BlockCacheTraceWriterImpl() = default; + ~BlockCacheTraceWriterImpl() override = default; // No copy and move. BlockCacheTraceWriterImpl(const BlockCacheTraceWriterImpl&) = delete; BlockCacheTraceWriterImpl& operator=(const BlockCacheTraceWriterImpl&) = @@ -187,7 +187,7 @@ class BlockCacheHumanReadableTraceReader : public BlockCacheTraceReader { public: BlockCacheHumanReadableTraceReader(const std::string& trace_file_path); - ~BlockCacheHumanReadableTraceReader(); + ~BlockCacheHumanReadableTraceReader() override; Status ReadHeader(BlockCacheTraceHeader* header); diff --git a/util/concurrent_task_limiter_impl.h b/util/concurrent_task_limiter_impl.h index 71e15ead342..3aee18690b1 100644 --- a/util/concurrent_task_limiter_impl.h +++ b/util/concurrent_task_limiter_impl.h @@ -27,7 +27,7 @@ class ConcurrentTaskLimiterImpl : public ConcurrentTaskLimiter { ConcurrentTaskLimiterImpl& operator=(const ConcurrentTaskLimiterImpl&) = delete; - virtual ~ConcurrentTaskLimiterImpl(); + virtual ~ConcurrentTaskLimiterImpl() override; const std::string& GetName() const override; diff --git a/util/rate_limiter_impl.h b/util/rate_limiter_impl.h index 23bbd56e081..64765ea057e 100644 --- a/util/rate_limiter_impl.h +++ b/util/rate_limiter_impl.h @@ -31,7 +31,7 @@ class GenericRateLimiter : public RateLimiter { const std::shared_ptr& clock, bool auto_tuned, int64_t single_burst_bytes); - virtual ~GenericRateLimiter(); + virtual ~GenericRateLimiter() override; // This API allows user to dynamically change rate limiter's bytes per second. void SetBytesPerSecond(int64_t bytes_per_second) override; diff --git a/util/threadpool_imp.h b/util/threadpool_imp.h index a3a3a39a264..22c03fe8506 100644 --- a/util/threadpool_imp.h +++ b/util/threadpool_imp.h @@ -19,7 +19,7 @@ namespace ROCKSDB_NAMESPACE { class ThreadPoolImpl : public ThreadPool { public: ThreadPoolImpl(); - ~ThreadPoolImpl(); + ~ThreadPoolImpl() override; ThreadPoolImpl(ThreadPoolImpl&&) = delete; ThreadPoolImpl& operator=(ThreadPoolImpl&&) = delete; diff --git a/utilities/blob_db/blob_db_impl.h b/utilities/blob_db/blob_db_impl.h index 9fc9deb5e03..9a069fe37ca 100644 --- a/utilities/blob_db/blob_db_impl.h +++ b/utilities/blob_db/blob_db_impl.h @@ -5,7 +5,6 @@ #pragma once - #include #include #include @@ -166,7 +165,7 @@ class BlobDBImpl : public BlobDB { const LiveFilesStorageInfoOptions& opts, std::vector* files) override; - ~BlobDBImpl(); + ~BlobDBImpl() override; Status Open(std::vector* handles); diff --git a/utilities/blob_db/blob_db_iterator.h b/utilities/blob_db/blob_db_iterator.h index 4898ddfd769..ab9c1660942 100644 --- a/utilities/blob_db/blob_db_iterator.h +++ b/utilities/blob_db/blob_db_iterator.h @@ -29,7 +29,7 @@ class BlobDBIterator : public Iterator { clock_(clock), statistics_(statistics) {} - virtual ~BlobDBIterator() = default; + virtual ~BlobDBIterator() override = default; bool Valid() const override { if (!iter_->Valid()) { diff --git a/utilities/cache_dump_load_impl.h b/utilities/cache_dump_load_impl.h index ee892f47488..e86f2a23c4a 100644 --- a/utilities/cache_dump_load_impl.h +++ b/utilities/cache_dump_load_impl.h @@ -99,7 +99,7 @@ class CacheDumperImpl : public CacheDumper { : options_(dump_options), cache_(cache), writer_(std::move(writer)) { dumped_size_bytes_ = 0; } - ~CacheDumperImpl() { writer_.reset(); } + ~CacheDumperImpl() override { writer_.reset(); } Status SetDumpFilter(std::vector db_list) override; IOStatus DumpCacheEntriesToWriter() override; @@ -140,7 +140,7 @@ class CacheDumpedLoaderImpl : public CacheDumpedLoader { : options_(dump_options), secondary_cache_(secondary_cache), reader_(std::move(reader)) {} - ~CacheDumpedLoaderImpl() {} + ~CacheDumpedLoaderImpl() override {} IOStatus RestoreCacheEntriesToSecondaryCache() override; private: @@ -162,7 +162,7 @@ class ToFileCacheDumpWriter : public CacheDumpWriter { std::unique_ptr&& file_writer) : file_writer_(std::move(file_writer)) {} - ~ToFileCacheDumpWriter() { Close().PermitUncheckedError(); } + ~ToFileCacheDumpWriter() override { Close().PermitUncheckedError(); } // Write the serialized metadata to the file IOStatus WriteMetadata(const Slice& metadata) override { @@ -217,7 +217,7 @@ class FromFileCacheDumpReader : public CacheDumpReader { offset_(0), buffer_(new char[kDumpReaderBufferSize]) {} - ~FromFileCacheDumpReader() { delete[] buffer_; } + ~FromFileCacheDumpReader() override { delete[] buffer_; } IOStatus ReadMetadata(std::string* metadata) override { uint32_t metadata_len = 0; diff --git a/utilities/counted_fs.cc b/utilities/counted_fs.cc index e43f3a19124..96d9e671ecb 100644 --- a/utilities/counted_fs.cc +++ b/utilities/counted_fs.cc @@ -245,7 +245,7 @@ class CountedDirectory : public FSDirectoryWrapper { return rv; } - ~CountedDirectory() { + ~CountedDirectory() override { if (!closed_) { // TODO: fix DB+CF code to use explicit Close, not rely on destructor fs_->counters()->closes++; diff --git a/utilities/fault_injection_env.h b/utilities/fault_injection_env.h index 5612718c6c7..bb233780223 100644 --- a/utilities/fault_injection_env.h +++ b/utilities/fault_injection_env.h @@ -71,7 +71,7 @@ class TestWritableFile : public WritableFile { explicit TestWritableFile(const std::string& fname, std::unique_ptr&& f, FaultInjectionTestEnv* env); - virtual ~TestWritableFile(); + virtual ~TestWritableFile() override; Status Append(const Slice& data) override; Status Append(const Slice& data, const DataVerificationInfo& /*verification_info*/) override { @@ -107,7 +107,7 @@ class TestRandomRWFile : public RandomRWFile { explicit TestRandomRWFile(const std::string& fname, std::unique_ptr&& f, FaultInjectionTestEnv* env); - virtual ~TestRandomRWFile(); + virtual ~TestRandomRWFile() override; Status Write(uint64_t offset, const Slice& data) override; Status Read(uint64_t offset, size_t n, Slice* result, char* scratch) const override; @@ -130,7 +130,7 @@ class TestDirectory : public Directory { explicit TestDirectory(FaultInjectionTestEnv* env, std::string dirname, Directory* dir) : env_(env), dirname_(dirname), dir_(dir) {} - ~TestDirectory() {} + ~TestDirectory() override {} Status Fsync() override; Status Close() override; @@ -145,7 +145,7 @@ class FaultInjectionTestEnv : public EnvWrapper { public: explicit FaultInjectionTestEnv(Env* base) : EnvWrapper(base), filesystem_active_(true) {} - virtual ~FaultInjectionTestEnv() { error_.PermitUncheckedError(); } + virtual ~FaultInjectionTestEnv() override { error_.PermitUncheckedError(); } static const char* kClassName() { return "FaultInjectionTestEnv"; } const char* Name() const override { return kClassName(); } diff --git a/utilities/fault_injection_fs.h b/utilities/fault_injection_fs.h index 24ead7e0a77..9cd6e59adec 100644 --- a/utilities/fault_injection_fs.h +++ b/utilities/fault_injection_fs.h @@ -65,7 +65,7 @@ class TestFSWritableFile : public FSWritableFile { const FileOptions& file_opts, std::unique_ptr&& f, FaultInjectionTestFS* fs); - virtual ~TestFSWritableFile(); + virtual ~TestFSWritableFile() override; IOStatus Append(const Slice& data, const IOOptions&, IODebugContext*) override; IOStatus Append(const Slice& data, const IOOptions& options, @@ -113,7 +113,7 @@ class TestFSRandomRWFile : public FSRandomRWFile { explicit TestFSRandomRWFile(const std::string& fname, std::unique_ptr&& f, FaultInjectionTestFS* fs); - virtual ~TestFSRandomRWFile(); + virtual ~TestFSRandomRWFile() override; IOStatus Write(uint64_t offset, const Slice& data, const IOOptions& options, IODebugContext* dbg) override; IOStatus Read(uint64_t offset, size_t n, const IOOptions& options, @@ -185,7 +185,7 @@ class TestFSDirectory : public FSDirectory { explicit TestFSDirectory(FaultInjectionTestFS* fs, std::string dirname, FSDirectory* dir) : fs_(fs), dirname_(std::move(dirname)), dir_(dir) {} - ~TestFSDirectory() {} + ~TestFSDirectory() override {} IOStatus Fsync(const IOOptions& options, IODebugContext* dbg) override; @@ -589,8 +589,8 @@ class FaultInjectionTestFS : public FileSystemWrapper { bool filesystem_writable_; // Bypass FaultInjectionTestFS and go directly // to underlying FS for writable files bool inject_unsynced_data_loss_; // See InjectUnsyncedDataLoss() - bool read_unsynced_data_; // See SetReadUnsyncedData() - bool allow_link_open_file_; // See SetAllowLinkOpenFile() + bool read_unsynced_data_; // See SetReadUnsyncedData() + bool allow_link_open_file_; // See SetAllowLinkOpenFile() IOStatus fs_error_; enum ErrorType : int { diff --git a/utilities/persistent_cache/block_cache_tier.h b/utilities/persistent_cache/block_cache_tier.h index caabbef94eb..22504f2873c 100644 --- a/utilities/persistent_cache/block_cache_tier.h +++ b/utilities/persistent_cache/block_cache_tier.h @@ -4,7 +4,6 @@ // (found in the LICENSE.Apache file in the root directory). #pragma once - #ifndef OS_WIN #include #endif // ! OS_WIN @@ -50,7 +49,7 @@ class BlockCacheTier : public PersistentCacheTier { opt_.write_buffer_size, opt_.write_buffer_count()); } - virtual ~BlockCacheTier() { + virtual ~BlockCacheTier() override { // Close is re-entrant so we can call close even if it is already closed Close().PermitUncheckedError(); assert(!insert_th_.joinable()); @@ -151,4 +150,3 @@ class BlockCacheTier : public PersistentCacheTier { }; } // namespace ROCKSDB_NAMESPACE - diff --git a/utilities/persistent_cache/block_cache_tier_file.h b/utilities/persistent_cache/block_cache_tier_file.h index 127f5a8676a..b884352c7cd 100644 --- a/utilities/persistent_cache/block_cache_tier_file.h +++ b/utilities/persistent_cache/block_cache_tier_file.h @@ -4,7 +4,6 @@ // (found in the LICENSE.Apache file in the root directory). #pragma once - #include #include #include @@ -97,7 +96,7 @@ class BlockCacheFile : public LRUElement { dir_(dir), cache_id_(cache_id) {} - virtual ~BlockCacheFile() {} + virtual ~BlockCacheFile() override {} // append key/value to file and return LBA locator to user virtual bool Append(const Slice& /*key*/, const Slice& /*val*/, @@ -149,7 +148,7 @@ class RandomAccessCacheFile : public BlockCacheFile { const std::shared_ptr& log) : BlockCacheFile(env, dir, cache_id), log_(log) {} - virtual ~RandomAccessCacheFile() {} + virtual ~RandomAccessCacheFile() override {} // open file for reading bool Open(const bool enable_direct_reads); @@ -182,7 +181,7 @@ class WriteableCacheFile : public RandomAccessCacheFile { writer_(writer), max_size_(max_size) {} - virtual ~WriteableCacheFile(); + virtual ~WriteableCacheFile() override; // create file on disk bool Create(const bool enable_direct_writes, const bool enable_direct_reads); @@ -271,7 +270,7 @@ class ThreadedWriter : public Writer { explicit ThreadedWriter(PersistentCacheTier* const cache, const size_t qdepth, const size_t io_size); - virtual ~ThreadedWriter() { assert(threads_.empty()); } + virtual ~ThreadedWriter() override { assert(threads_.empty()); } void Stop() override; void Write(WritableFile* const file, CacheWriteBuffer* buf, @@ -288,4 +287,3 @@ class ThreadedWriter : public Writer { }; } // namespace ROCKSDB_NAMESPACE - diff --git a/utilities/persistent_cache/hash_table_evictable.h b/utilities/persistent_cache/hash_table_evictable.h index daf4bec1aef..89e8bbe291f 100644 --- a/utilities/persistent_cache/hash_table_evictable.h +++ b/utilities/persistent_cache/hash_table_evictable.h @@ -5,7 +5,6 @@ // #pragma once - #include #include "util/random.h" @@ -33,7 +32,7 @@ class EvictableHashTable : private HashTable { assert(lru_lists_); } - virtual ~EvictableHashTable() { AssertEmptyLRU(); } + virtual ~EvictableHashTable() override { AssertEmptyLRU(); } // // Insert given record to hash table (and LRU list) @@ -163,4 +162,3 @@ class EvictableHashTable : private HashTable { }; } // namespace ROCKSDB_NAMESPACE - diff --git a/utilities/persistent_cache/persistent_cache_tier.h b/utilities/persistent_cache/persistent_cache_tier.h index c42b7d5a985..c5cedaf48fb 100644 --- a/utilities/persistent_cache/persistent_cache_tier.h +++ b/utilities/persistent_cache/persistent_cache_tier.h @@ -5,7 +5,6 @@ // #pragma once - #include #include #include @@ -236,7 +235,7 @@ class PersistentCacheTier : public PersistentCache { public: using Tier = std::shared_ptr; - virtual ~PersistentCacheTier() {} + virtual ~PersistentCacheTier() override {} // Open the persistent cache tier virtual Status Open(); @@ -297,7 +296,7 @@ class PersistentCacheTier : public PersistentCache { // ease and support PersistentCache methods for accessing data. class PersistentTieredCache : public PersistentCacheTier { public: - virtual ~PersistentTieredCache(); + virtual ~PersistentTieredCache() override; Status Open() override; Status Close() override; @@ -337,4 +336,3 @@ class PersistentTieredCache : public PersistentCacheTier { }; } // namespace ROCKSDB_NAMESPACE - diff --git a/utilities/persistent_cache/volatile_tier_impl.h b/utilities/persistent_cache/volatile_tier_impl.h index f5d30644381..6766d6a769f 100644 --- a/utilities/persistent_cache/volatile_tier_impl.h +++ b/utilities/persistent_cache/volatile_tier_impl.h @@ -5,7 +5,6 @@ // #pragma once - #include #include #include @@ -46,7 +45,7 @@ class VolatileCacheTier : public PersistentCacheTier { const size_t max_size = std::numeric_limits::max()) : is_compressed_(is_compressed), max_size_(max_size) {} - virtual ~VolatileCacheTier(); + virtual ~VolatileCacheTier() override; // insert to cache Status Insert(const Slice& page_key, const char* data, @@ -79,7 +78,7 @@ class VolatileCacheTier : public PersistentCacheTier { explicit CacheData(const std::string& _key, const std::string& _value = "") : key(_key), value(_value) {} - virtual ~CacheData() {} + virtual ~CacheData() override {} const std::string key; const std::string value; @@ -136,4 +135,3 @@ class VolatileCacheTier : public PersistentCacheTier { }; } // namespace ROCKSDB_NAMESPACE - diff --git a/utilities/trace/file_trace_reader_writer.h b/utilities/trace/file_trace_reader_writer.h index 4535343a627..e3bbd1e016a 100644 --- a/utilities/trace/file_trace_reader_writer.h +++ b/utilities/trace/file_trace_reader_writer.h @@ -16,7 +16,7 @@ class WritableFileWriter; class FileTraceReader : public TraceReader { public: explicit FileTraceReader(std::unique_ptr&& reader); - ~FileTraceReader(); + ~FileTraceReader() override; Status Read(std::string* data) override; Status Close() override; @@ -35,7 +35,7 @@ class FileTraceReader : public TraceReader { class FileTraceWriter : public TraceWriter { public: explicit FileTraceWriter(std::unique_ptr&& file_writer); - ~FileTraceWriter(); + ~FileTraceWriter() override; Status Write(const Slice& data) override; Status Close() override; diff --git a/utilities/transactions/optimistic_transaction.h b/utilities/transactions/optimistic_transaction.h index a03fa16970f..0a12518ea3d 100644 --- a/utilities/transactions/optimistic_transaction.h +++ b/utilities/transactions/optimistic_transaction.h @@ -5,7 +5,6 @@ #pragma once - #include #include #include @@ -34,7 +33,7 @@ class OptimisticTransaction : public TransactionBaseImpl { OptimisticTransaction(const OptimisticTransaction&) = delete; void operator=(const OptimisticTransaction&) = delete; - virtual ~OptimisticTransaction(); + virtual ~OptimisticTransaction() override; void Reinitialize(OptimisticTransactionDB* txn_db, const WriteOptions& write_options, @@ -96,4 +95,3 @@ class OptimisticTransactionCallback : public WriteCallback { }; } // namespace ROCKSDB_NAMESPACE - diff --git a/utilities/transactions/optimistic_transaction_db_impl.h b/utilities/transactions/optimistic_transaction_db_impl.h index 86213832dde..fdf7d9f23d2 100644 --- a/utilities/transactions/optimistic_transaction_db_impl.h +++ b/utilities/transactions/optimistic_transaction_db_impl.h @@ -60,7 +60,7 @@ class OptimisticTransactionDBImpl : public OptimisticTransactionDB { } } - ~OptimisticTransactionDBImpl() { + ~OptimisticTransactionDBImpl() override { // Prevent this stackable from destroying // base db if (!db_owner_) { diff --git a/utilities/transactions/pessimistic_transaction_db.h b/utilities/transactions/pessimistic_transaction_db.h index bec29182abb..15cfe9239ee 100644 --- a/utilities/transactions/pessimistic_transaction_db.h +++ b/utilities/transactions/pessimistic_transaction_db.h @@ -34,7 +34,7 @@ class PessimisticTransactionDB : public TransactionDB { explicit PessimisticTransactionDB(StackableDB* db, const TransactionDBOptions& txn_db_options); - virtual ~PessimisticTransactionDB(); + virtual ~PessimisticTransactionDB() override; const Snapshot* GetSnapshot() override { return db_->GetSnapshot(); } @@ -274,7 +274,7 @@ class WriteCommittedTxnDB : public PessimisticTransactionDB { const TransactionDBOptions& txn_db_options) : PessimisticTransactionDB(db, txn_db_options) {} - virtual ~WriteCommittedTxnDB() {} + virtual ~WriteCommittedTxnDB() override {} Transaction* BeginTransaction(const WriteOptions& write_options, const TransactionOptions& txn_options, diff --git a/utilities/transactions/write_prepared_txn.h b/utilities/transactions/write_prepared_txn.h index aca6a19ea08..30bcf4da7bb 100644 --- a/utilities/transactions/write_prepared_txn.h +++ b/utilities/transactions/write_prepared_txn.h @@ -44,7 +44,7 @@ class WritePreparedTxn : public PessimisticTransaction { WritePreparedTxn(const WritePreparedTxn&) = delete; void operator=(const WritePreparedTxn&) = delete; - virtual ~WritePreparedTxn() {} + virtual ~WritePreparedTxn() override {} // To make WAL commit markers visible, the snapshot will be based on the last // seq in the WAL that is also published, LastPublishedSequence, as opposed to diff --git a/utilities/transactions/write_prepared_txn_db.h b/utilities/transactions/write_prepared_txn_db.h index cb78327f62c..e8807e7908c 100644 --- a/utilities/transactions/write_prepared_txn_db.h +++ b/utilities/transactions/write_prepared_txn_db.h @@ -59,7 +59,7 @@ class WritePreparedTxnDB : public PessimisticTransactionDB { Init(txn_db_options); } - virtual ~WritePreparedTxnDB(); + virtual ~WritePreparedTxnDB() override; Status Initialize(const std::vector& compaction_enabled_cf_indices, const std::vector& handles) override; @@ -851,7 +851,7 @@ class WritePreparedTxnReadCallback : public ReadCallback { (void)backed_by_snapshot_; // to silence unused private field warning } - virtual ~WritePreparedTxnReadCallback() { + virtual ~WritePreparedTxnReadCallback() override { // If it is not backed by snapshot, the caller must check validity assert(valid_checked_ || backed_by_snapshot_ == kBackedByDBSnapshot); } diff --git a/utilities/transactions/write_unprepared_txn.h b/utilities/transactions/write_unprepared_txn.h index 606ad6e3fcf..7bc7952490e 100644 --- a/utilities/transactions/write_unprepared_txn.h +++ b/utilities/transactions/write_unprepared_txn.h @@ -5,7 +5,6 @@ #pragma once - #include #include "utilities/transactions/write_prepared_txn.h" @@ -69,7 +68,7 @@ class WriteUnpreparedTxnReadCallback : public ReadCallback { (void)backed_by_snapshot_; // to silence unused private field warning } - virtual ~WriteUnpreparedTxnReadCallback() { + virtual ~WriteUnpreparedTxnReadCallback() override { // If it is not backed by snapshot, the caller must check validity assert(valid_checked_ || backed_by_snapshot_ == kBackedByDBSnapshot); } @@ -114,7 +113,7 @@ class WriteUnpreparedTxn : public WritePreparedTxn { const WriteOptions& write_options, const TransactionOptions& txn_options); - virtual ~WriteUnpreparedTxn(); + virtual ~WriteUnpreparedTxn() override; using TransactionBaseImpl::Put; Status Put(ColumnFamilyHandle* column_family, const Slice& key, @@ -272,7 +271,7 @@ class WriteUnpreparedTxn : public WritePreparedTxn { SavePoint(const std::map& seqs, ManagedSnapshot* snapshot) - : unprep_seqs_(seqs), snapshot_(snapshot){} + : unprep_seqs_(seqs), snapshot_(snapshot) {} }; // We have 3 data structures holding savepoint information: diff --git a/utilities/ttl/db_ttl_impl.h b/utilities/ttl/db_ttl_impl.h index 731cd3955fe..10b0ee9cf6a 100644 --- a/utilities/ttl/db_ttl_impl.h +++ b/utilities/ttl/db_ttl_impl.h @@ -34,7 +34,7 @@ class DBWithTTLImpl : public DBWithTTL { static void RegisterTtlClasses(); explicit DBWithTTLImpl(DB* db); - virtual ~DBWithTTLImpl(); + virtual ~DBWithTTLImpl() override; Status Close() override; @@ -109,7 +109,7 @@ class TtlIterator : public Iterator { public: explicit TtlIterator(Iterator* iter) : iter_(iter) { assert(iter_); } - ~TtlIterator() { delete iter_; } + ~TtlIterator() override { delete iter_; } bool Valid() const override { return iter_->Valid(); } From 51769c4f76f9247ec150774ef94928e2a6af952b Mon Sep 17 00:00:00 2001 From: Andrew Chang Date: Mon, 16 Dec 2024 15:53:59 -0800 Subject: [PATCH 3/4] Update makefile to only skip check for clang-10 --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 88cb5c8deaa..e8ecefd563e 100644 --- a/Makefile +++ b/Makefile @@ -552,8 +552,10 @@ endif ifdef USE_CLANG # Used by some teams in Facebook WARNING_FLAGS += -Wshift-sign-overflow -Wambiguous-reversed-operator \ - -Wimplicit-fallthrough -Wreinterpret-base-class -Wundefined-reinterpret-cast \ - -Wsuggest-destructor-override + -Wimplicit-fallthrough -Wreinterpret-base-class -Wundefined-reinterpret-cast + ifeq ($(CC), clang-13) + WARNING_FLAGS += -Wsuggest-destructor-override + endif endif ifeq ($(PLATFORM), OS_OPENBSD) From 378d36a843d9702970d460e7bfc2b1df761cb749 Mon Sep 17 00:00:00 2001 From: Andrew Chang Date: Tue, 17 Dec 2024 10:23:37 -0800 Subject: [PATCH 4/4] Add more override --- db/db_test_util.h | 8 +++++--- table/mock_table.cc | 2 +- table/mock_table.h | 2 +- test_util/testutil.h | 10 +++++----- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/db/db_test_util.h b/db/db_test_util.h index 4b5bc48450d..f58b18e4ac0 100644 --- a/db/db_test_util.h +++ b/db/db_test_util.h @@ -282,7 +282,9 @@ class SpecialEnv : public EnvWrapper { : env_(env), base_(std::move(b)) { env_->num_open_wal_file_.fetch_add(1); } - virtual ~SpecialWalFile() { env_->num_open_wal_file_.fetch_add(-1); } + virtual ~SpecialWalFile() override { + env_->num_open_wal_file_.fetch_add(-1); + } Status Append(const Slice& data) override { #if !(defined NDEBUG) || !defined(OS_WIN) TEST_SYNC_POINT("SpecialEnv::SpecialWalFile::Append:1"); @@ -594,7 +596,7 @@ class SpecialEnv : public EnvWrapper { class NoopDirectory : public Directory { public: NoopDirectory() {} - ~NoopDirectory() {} + ~NoopDirectory() override {} Status Fsync() override { return Status::OK(); } Status Close() override { return Status::OK(); } @@ -1098,7 +1100,7 @@ class DBTestBase : public testing::Test { // tests, but won't cover the exact fsync logic. DBTestBase(const std::string path, bool env_do_fsync); - ~DBTestBase(); + ~DBTestBase() override; static std::string Key(int i) { char buf[100]; diff --git a/table/mock_table.cc b/table/mock_table.cc index 934c7f54a7f..0471fd7ca10 100644 --- a/table/mock_table.cc +++ b/table/mock_table.cc @@ -94,7 +94,7 @@ class MockTableBuilder : public TableBuilder { } // REQUIRES: Either Finish() or Abandon() has been called. - ~MockTableBuilder() = default; + ~MockTableBuilder() override = default; // Add key,value to the table being constructed. // REQUIRES: key is after any previously added key according to comparator. diff --git a/table/mock_table.h b/table/mock_table.h index af3a4eb46cd..ccab4afec3a 100644 --- a/table/mock_table.h +++ b/table/mock_table.h @@ -135,7 +135,7 @@ class MockTableReader : public TableReader { return std::make_shared(tp_); } - ~MockTableReader() = default; + ~MockTableReader() override = default; private: const KVVector& table_; diff --git a/test_util/testutil.h b/test_util/testutil.h index 2d693b5f201..88420ca67fe 100644 --- a/test_util/testutil.h +++ b/test_util/testutil.h @@ -84,7 +84,7 @@ class PlainInternalKeyComparator : public InternalKeyComparator { explicit PlainInternalKeyComparator(const Comparator* c) : InternalKeyComparator(c) {} - virtual ~PlainInternalKeyComparator() {} + virtual ~PlainInternalKeyComparator() override {} int Compare(const Slice& a, const Slice& b) const override { return user_comparator()->Compare(a, b); @@ -310,7 +310,7 @@ class StringSource : public FSRandomAccessFile { mmap_(mmap), total_reads_(0) {} - virtual ~StringSource() {} + virtual ~StringSource() override {} uint64_t Size() const { return contents_.size(); } @@ -744,7 +744,7 @@ class ChanglingMergeOperator : public MergeOperator { public: explicit ChanglingMergeOperator(const std::string& name) : name_(name + "MergeOperator") {} - ~ChanglingMergeOperator() {} + ~ChanglingMergeOperator() override {} void SetName(const std::string& name) { name_ = name; } @@ -783,7 +783,7 @@ class ChanglingCompactionFilter : public CompactionFilter { public: explicit ChanglingCompactionFilter(const std::string& name) : name_(name + "CompactionFilter") {} - ~ChanglingCompactionFilter() {} + ~ChanglingCompactionFilter() override {} void SetName(const std::string& name) { name_ = name; } @@ -819,7 +819,7 @@ class ChanglingCompactionFilterFactory : public CompactionFilterFactory { public: explicit ChanglingCompactionFilterFactory(const std::string& name) : name_(name + "CompactionFilterFactory") {} - ~ChanglingCompactionFilterFactory() {} + ~ChanglingCompactionFilterFactory() override {} void SetName(const std::string& name) { name_ = name; }