Skip to content

Commit 5f866d0

Browse files
Michael Liufacebook-github-bot
Michael Liu
authored andcommitted
Apply modernize-use-override (2nd iteration)
Summary: Use C++11’s override and remove virtual where applicable. Change are automatically generated. Reviewed By: Orvid Differential Revision: D14086124 fbshipit-source-id: 2005227d095d776ca3b4309a57f54e25782b9b58
1 parent f1da989 commit 5f866d0

28 files changed

+66
-56
lines changed

c10/test/util/intrusive_ptr_test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class DestructableMock : public intrusive_ptr_target {
4545
DestructableMock(bool* resourcesReleased, bool* wasDestructed)
4646
: resourcesReleased_(resourcesReleased), wasDestructed_(wasDestructed) {}
4747

48-
~DestructableMock() {
48+
~DestructableMock() override {
4949
*wasDestructed_ = true;
5050
}
5151

caffe2/contrib/prof/cuda_profile_ops.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ class CudaProfileInitializeOp : public OperatorBase {
5151
}
5252
}
5353

54-
~CudaProfileInitializeOp() {
54+
~CudaProfileInitializeOp() override {
5555
unlink(config_.c_str());
5656
}
5757

58-
virtual bool Run(int /* unused */ /*stream_id*/ = 0) {
58+
bool Run(int /* unused */ /*stream_id*/ = 0) override {
5959
// If this fails, check the contents of "output" for hints.
6060
CUDA_CHECK(
6161
cudaProfilerInitialize(config_.c_str(), output_.c_str(), cudaCSV));
@@ -72,7 +72,7 @@ class CudaProfileStartOp : public OperatorBase {
7272
CudaProfileStartOp(const OperatorDef& operator_def, Workspace* ws)
7373
: OperatorBase(operator_def, ws) {}
7474

75-
virtual bool Run(int /* unused */ /*stream_id*/ = 0) {
75+
bool Run(int /* unused */ /*stream_id*/ = 0) override {
7676
CUDA_ENFORCE(cudaProfilerStart());
7777
return true;
7878
}
@@ -83,7 +83,7 @@ class CudaProfileStopOp : public OperatorBase {
8383
CudaProfileStopOp(const OperatorDef& operator_def, Workspace* ws)
8484
: OperatorBase(operator_def, ws) {}
8585

86-
virtual bool Run(int /* unused */ /*stream_id*/ = 0) {
86+
bool Run(int /* unused */ /*stream_id*/ = 0) override {
8787
CUDA_ENFORCE(cudaProfilerStop());
8888
return true;
8989
}

caffe2/core/blob_serialization.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace caffe2 {
3131
class StringSerializer : public BlobSerializerBase {
3232
public:
3333
StringSerializer() {}
34-
~StringSerializer() {}
34+
~StringSerializer() override {}
3535
/**
3636
* Serializes a Blob. Note that this blob has to contain Tensor,
3737
* otherwise this function produces a fatal error.

caffe2/core/blob_test.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ CAFFE_KNOWN_TYPE(BlobTestNonDefaultConstructible);
4545
class BlobTestFooSerializer : public BlobSerializerBase {
4646
public:
4747
BlobTestFooSerializer() {}
48-
~BlobTestFooSerializer() {}
48+
~BlobTestFooSerializer() override {}
4949
/**
5050
* Serializes a Blob. Note that this blob has to contain Tensor,
5151
* otherwise this function produces a fatal error.
@@ -792,7 +792,7 @@ class VectorCursor : public db::Cursor {
792792
explicit VectorCursor(StringMap* data) : data_(data) {
793793
pos_ = 0;
794794
}
795-
~VectorCursor() {}
795+
~VectorCursor() override {}
796796
void Seek(const string& /* unused */) override {}
797797
void SeekToFirst() override {}
798798
void Next() override {
@@ -817,7 +817,7 @@ class VectorDB : public db::DB {
817817
public:
818818
VectorDB(const string& source, db::Mode mode)
819819
: DB(source, mode), name_(source) {}
820-
~VectorDB() {
820+
~VectorDB() override {
821821
data_.erase(name_);
822822
}
823823
void Close() override {}
@@ -949,7 +949,7 @@ struct DummyType {
949949
class DummyTypeSerializer : public BlobSerializerBase {
950950
public:
951951
DummyTypeSerializer() {}
952-
~DummyTypeSerializer() {}
952+
~DummyTypeSerializer() override {}
953953
void Serialize(
954954
const void* pointer,
955955
TypeMeta typeMeta,

caffe2/core/db.cc

+5-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class MiniDBCursor : public Cursor {
2626
// We call Next() to read in the first entry.
2727
Next();
2828
}
29-
~MiniDBCursor() {}
29+
~MiniDBCursor() override {}
3030

3131
void Seek(const string& /*key*/) override {
3232
LOG(FATAL) << "MiniDB does not support seeking to a specific key.";
@@ -93,7 +93,7 @@ class MiniDBTransaction : public Transaction {
9393
public:
9494
explicit MiniDBTransaction(FILE* f, std::mutex* mutex)
9595
: file_(f), lock_(*mutex) {}
96-
~MiniDBTransaction() {
96+
~MiniDBTransaction() override {
9797
Commit();
9898
}
9999

@@ -140,7 +140,9 @@ class MiniDB : public DB {
140140
CAFFE_ENFORCE(file_, "Cannot open file: " + source);
141141
VLOG(1) << "Opened MiniDB " << source;
142142
}
143-
~MiniDB() { Close(); }
143+
~MiniDB() override {
144+
Close();
145+
}
144146

145147
void Close() override {
146148
if (file_) {

caffe2/core/net_test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ class AsyncErrorOp final : public Operator<CPUContext> {
844844
return true;
845845
}
846846

847-
~AsyncErrorOp() {
847+
~AsyncErrorOp() override {
848848
if (thread_) {
849849
thread_->join();
850850
}
@@ -989,7 +989,7 @@ class SyncErrorOp final : public Operator<CPUContext> {
989989
}
990990
}
991991

992-
~SyncErrorOp() {}
992+
~SyncErrorOp() override {}
993993

994994
private:
995995
bool fail_;

caffe2/core/nomscheduler/tests/SchedulerTest.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ SchedulerInput loadSchedulerInputFromString(const std::string& fileInput) {
9494
// constraints.
9595
class SimpleScheduler : Scheduler {
9696
public:
97-
virtual SchedulerOutput schedule(const SchedulerInput& input) override {
97+
SchedulerOutput schedule(const SchedulerInput& input) override {
9898
int numTasks = input.getNumberOfTasks();
9999
SchedulerOutput result(numTasks);
100100

caffe2/core/observer_test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class DummyObserver final : public ObserverBase<T> {
2020
void Start() override;
2121
void Stop() override;
2222

23-
~DummyObserver() {}
23+
~DummyObserver() override {}
2424
};
2525

2626
template <>

caffe2/cuda_rtc/elemenntwise_rtc_gpu.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class ElementwiseRTCOp final : public Operator<CUDAContext> {
8080
CAFFE_ENFORCE(src.size(), "Op should have a non-zero source code size.");
8181
func_.Compile(InputSize(), OutputSize(), src);
8282
}
83-
~ElementwiseRTCOp() {}
83+
~ElementwiseRTCOp() override {}
8484

8585
bool RunOnDevice() override {
8686
static_assert(sizeof(void*) == sizeof(size_t),

caffe2/cuda_rtc/pool_op_rtc_gpu.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class MaxPoolRTCOp final : public ConvPoolOpBase<CUDAContext> {
192192
CAFFE_ENFORCE_EQ(
193193
order_, StorageOrder::NCHW, "Currently only NCHW is supported.");
194194
}
195-
~MaxPoolRTCOp() {}
195+
~MaxPoolRTCOp() override {}
196196

197197
bool RunOnDeviceWithOrderNCHW() override {
198198
auto& X = Input(0);
@@ -250,7 +250,7 @@ class MaxPoolGradientRTCOp final : public ConvPoolOpBase<CUDAContext> {
250250
CAFFE_ENFORCE_EQ(
251251
order_, StorageOrder::NCHW, "Currently only NCHW is supported.");
252252
}
253-
~MaxPoolGradientRTCOp() {}
253+
~MaxPoolGradientRTCOp() override {}
254254

255255
bool RunOnDeviceWithOrderNCHW() override {
256256
auto& X = Input(0);

caffe2/db/leveldb.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class LevelDBCursor : public Cursor {
1818
: iter_(db->NewIterator(leveldb::ReadOptions())) {
1919
SeekToFirst();
2020
}
21-
~LevelDBCursor() {}
21+
~LevelDBCursor() override {}
2222
void Seek(const string& key) override { iter_->Seek(key); }
2323
bool SupportsSeek() override { return true; }
2424
void SeekToFirst() override { iter_->SeekToFirst(); }
@@ -37,7 +37,9 @@ class LevelDBTransaction : public Transaction {
3737
CAFFE_ENFORCE(db_);
3838
batch_.reset(new leveldb::WriteBatch());
3939
}
40-
~LevelDBTransaction() { Commit(); }
40+
~LevelDBTransaction() override {
41+
Commit();
42+
}
4143
void Put(const string& key, const string& value) override {
4244
batch_->Put(key, value);
4345
}

caffe2/db/lmdb.cc

+5-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class LMDBCursor : public Cursor {
2929
MDB_CHECK(mdb_cursor_open(mdb_txn_, mdb_dbi_, &mdb_cursor_));
3030
SeekToFirst();
3131
}
32-
virtual ~LMDBCursor() {
32+
~LMDBCursor() override {
3333
mdb_cursor_close(mdb_cursor_);
3434
mdb_dbi_close(mdb_env_, mdb_dbi_);
3535
mdb_txn_abort(mdb_txn_);
@@ -96,7 +96,7 @@ class LMDBTransaction final : public Transaction {
9696
MDB_CHECK(mdb_txn_begin(mdb_env_, NULL, 0, &mdb_txn_));
9797
MDB_CHECK(mdb_dbi_open(mdb_txn_, NULL, 0, &mdb_dbi_));
9898
}
99-
~LMDBTransaction() {
99+
~LMDBTransaction() override {
100100
MDB_CHECK(mdb_txn_commit(mdb_txn_));
101101
mdb_dbi_close(mdb_env_, mdb_dbi_);
102102
}
@@ -120,7 +120,9 @@ class LMDBTransaction final : public Transaction {
120120
class LMDB : public DB {
121121
public:
122122
LMDB(const string& source, Mode mode);
123-
virtual ~LMDB() { Close(); }
123+
~LMDB() override {
124+
Close();
125+
}
124126
void Close() override {
125127
if (mdb_env_ != NULL) {
126128
mdb_env_close(mdb_env_);

caffe2/db/protodb.cc

+7-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ProtoDBCursor : public Cursor {
1111
public:
1212
explicit ProtoDBCursor(const TensorProtos* proto)
1313
: proto_(proto), iter_(0) {}
14-
~ProtoDBCursor() {}
14+
~ProtoDBCursor() override {}
1515

1616
void Seek(const string& /*str*/) override {
1717
CAFFE_THROW("ProtoDB is not designed to support seeking.");
@@ -39,7 +39,9 @@ class ProtoDBTransaction : public Transaction {
3939
existing_names_.insert(tensor.name());
4040
}
4141
}
42-
~ProtoDBTransaction() { Commit(); }
42+
~ProtoDBTransaction() override {
43+
Commit();
44+
}
4345
void Put(const string& key, const string& value) override {
4446
if (existing_names_.count(key)) {
4547
CAFFE_THROW("An item with key ", key, " already exists.");
@@ -77,7 +79,9 @@ class ProtoDB : public DB {
7779
}
7880
LOG(INFO) << "Opened protodb " << source;
7981
}
80-
~ProtoDB() { Close(); }
82+
~ProtoDB() override {
83+
Close();
84+
}
8185

8286
void Close() override {
8387
if (mode_ == NEW || mode_ == WRITE) {

caffe2/db/zmqdb.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ZmqDBCursor : public Cursor {
2323
Next();
2424
}
2525

26-
~ZmqDBCursor() {
26+
~ZmqDBCursor() override {
2727
finalize_ = true;
2828
prefetched_ = false;
2929
producer_.notify_one();
@@ -91,7 +91,7 @@ class ZmqDB : public DB {
9191
CAFFE_ENFORCE(mode == READ, "ZeroMQ DB only supports read mode.");
9292
}
9393

94-
~ZmqDB() {}
94+
~ZmqDB() override {}
9595

9696
void Close() override {}
9797

caffe2/ideep/operators/concat_split_op.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class IDEEPConcatOp final : public IDEEPOperator {
2626
}
2727
CAFFE_ENFORCE_GE(axis_, 0);
2828
}
29-
virtual ~IDEEPConcatOp() {}
29+
~IDEEPConcatOp() override {}
3030

3131
bool RunOnDevice() override {
3232
bool fallback_to_cpu = false;
@@ -97,7 +97,7 @@ class IDEEPSplitOp final : public IDEEPOperator {
9797
}
9898
CAFFE_ENFORCE_GE(axis_, 0);
9999
}
100-
virtual ~IDEEPSplitOp() {}
100+
~IDEEPSplitOp() override {}
101101

102102
bool RunOnDevice() override {
103103
const auto& input = Input(INPUT);

caffe2/ideep/operators/conv_fusion_op.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class IDEEPConvFusionOp final : public IDEEPConvPoolOpBase {
4444
"explicitly the kernel size.");
4545
}
4646
}
47-
virtual ~IDEEPConvFusionOp() {}
47+
~IDEEPConvFusionOp() override {}
4848

4949
bool RunOnDeviceWithOrderNCHW() override {
5050
const auto& X = Input(INPUT_X);

caffe2/ideep/operators/conv_op.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class IDEEPConvOp final : public IDEEPConvPoolOpBase {
1717
pad_l() == pad_r() && pad_t() == pad_b(),
1818
"Uneven padding not supported.");
1919
}
20-
virtual ~IDEEPConvOp() {}
20+
~IDEEPConvOp() override {}
2121

2222
bool RunOnDeviceWithOrderNCHW() override {
2323
const auto& X = Input(INPUT);
@@ -131,7 +131,7 @@ class IDEEPConvGradientOp final : public IDEEPConvPoolOpBase {
131131
"In order to backward propagate weights correctly, "
132132
"please set training_mode=1");
133133
}
134-
virtual ~IDEEPConvGradientOp() {}
134+
~IDEEPConvGradientOp() override {}
135135

136136
bool RunOnDeviceWithOrderNCHW() override {
137137
const auto& X = Input(INPUT);

caffe2/ideep/operators/dropout_op.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class IDEEPDropoutOp final : public IDEEPOperator {
1515
CAFFE_ENFORCE_GE(ratio_, 0);
1616
CAFFE_ENFORCE_LT(ratio_, 1);
1717
}
18-
virtual ~IDEEPDropoutOp() {}
18+
~IDEEPDropoutOp() override {}
1919

2020
bool RunOnDevice() override {
2121
const auto& X = Input(INPUT);
@@ -55,7 +55,7 @@ class IDEEPDropoutGradientOp final : public IDEEPOperator {
5555
CAFFE_ENFORCE_GE(ratio_, 0);
5656
CAFFE_ENFORCE_LT(ratio_, 1);
5757
}
58-
virtual ~IDEEPDropoutGradientOp() {}
58+
~IDEEPDropoutGradientOp() override {}
5959

6060
bool RunOnDevice() override {
6161
const auto& dY = Input(OUTPUT_GRAD);

caffe2/ideep/operators/elementwise_sum_op.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class IDEEPSumOp final : public IDEEPOperator {
1717
: IDEEPOperator(operator_def, ws),
1818
fallback_sum_(operator_def, ws),
1919
fallback_add_(operator_def, ws) {}
20-
virtual ~IDEEPSumOp() {}
20+
~IDEEPSumOp() override {}
2121

2222
bool RunOnDevice() override {
2323
itensor::dims input_dims;

caffe2/ideep/operators/expand_squeeze_dims_op.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class IDEEPExpandDimsOp final : public IDEEPOperator {
2323
}
2424
CAFFE_ENFORCE_GE(dims_.front(), 0, "Dimension ids must be non-negative.");
2525
}
26-
~IDEEPExpandDimsOp() {}
26+
~IDEEPExpandDimsOp() override {}
2727

2828
bool RunOnDevice() override {
2929
if (!OperatorBase::InputBlob(INPUT).template IsType<itensor>()) {
@@ -85,7 +85,7 @@ class IDEEPSqueezeOp final : public IDEEPOperator {
8585
}
8686
CAFFE_ENFORCE_GE(dims_.front(), 0, "Dimension ids must be non-negative.");
8787
}
88-
~IDEEPSqueezeOp() {}
88+
~IDEEPSqueezeOp() override {}
8989

9090
bool RunOnDevice() override {
9191
if (!OperatorBase::InputBlob(INPUT).template IsType<itensor>()) {

caffe2/ideep/operators/fully_connected_op.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class IDEEPFullyConnectedOp final : public IDEEPOperator {
3333
: IDEEPOperator(operator_def, ws),
3434
axis_(OperatorBase::GetSingleArgument<int32_t>("axis", 1)),
3535
axis_w_(OperatorBase::GetSingleArgument<int32_t>("axis_w", 1)) {}
36-
virtual ~IDEEPFullyConnectedOp() {}
36+
~IDEEPFullyConnectedOp() override {}
3737

3838
bool RunOnDevice() override {
3939
const auto& X = Input(INPUT);
@@ -78,7 +78,7 @@ class IDEEPFullyConnectedGradientOp final : public IDEEPOperator {
7878
: IDEEPOperator(operator_def, ws),
7979
axis_(OperatorBase::GetSingleArgument<int32_t>("axis", 1)),
8080
axis_w_(OperatorBase::GetSingleArgument<int32_t>("axis_w", 1)) {}
81-
virtual ~IDEEPFullyConnectedGradientOp() {}
81+
~IDEEPFullyConnectedGradientOp() override {}
8282

8383
bool RunOnDevice() override {
8484
const auto& X = Input(INPUT);

0 commit comments

Comments
 (0)