From a8e5cdec917b08ba37b3e394098d0792297bd57a Mon Sep 17 00:00:00 2001 From: Victor Gao Date: Fri, 9 Jun 2017 11:26:26 -0700 Subject: [PATCH] apply clang-tidy modernize-use-override Summary: Use clang-tidy to mechanically add missing `override` and remove redundant `virtual`. Reviewed By: igorsugak Differential Revision: D5211868 fbshipit-source-id: 6a85f7c4a543a4c9345ec5b0681a8853707343dc --- hphp/compiler/analysis/analysis_result.h | 2 +- hphp/compiler/analysis/file_scope.h | 6 ++- hphp/compiler/statement/typedef_statement.h | 2 +- hphp/runtime/base/directory.h | 2 +- hphp/runtime/base/ini-setting.h | 31 +++++++++------ hphp/runtime/base/mem-file.h | 2 +- hphp/runtime/base/plain-file.h | 4 +- hphp/runtime/debugger/cmd/cmd_complete.h | 16 ++++---- hphp/runtime/debugger/cmd/cmd_where.h | 10 ++--- hphp/runtime/ext/mysql/mysql_common.h | 4 +- hphp/runtime/server/http-server.h | 2 +- hphp/runtime/server/pagelet-server.h | 56 +++++++++++++-------------- hphp/runtime/test/proxygen-transport-test.cpp | 2 +- hphp/test/ext/test_ext_server.h | 2 +- hphp/test/ext/test_server.cpp | 4 +- hphp/test/ext/test_server.h | 2 +- hphp/util/job-queue.h | 4 +- hphp/util/test/job-queue-workload.cpp | 15 ++++--- hphp/vixl/a64/debugger-a64.h | 4 +- hphp/vixl/a64/instrument-a64.h | 2 +- 20 files changed, 89 insertions(+), 83 deletions(-) diff --git a/hphp/compiler/analysis/analysis_result.h b/hphp/compiler/analysis/analysis_result.h index 954457ed46f..6e3e38373e3 100644 --- a/hphp/compiler/analysis/analysis_result.h +++ b/hphp/compiler/analysis/analysis_result.h @@ -113,7 +113,7 @@ struct AnalysisResult : BlockScope, FunctionContainer { public: AnalysisResult(); - ~AnalysisResult(); + ~AnalysisResult() override; Locker lock() const { return Locker(this); } void setPackage(Package *package) { m_package = package;} void setParseOnDemand(bool v) { m_parseOnDemand = v;} diff --git a/hphp/compiler/analysis/file_scope.h b/hphp/compiler/analysis/file_scope.h index 6ec7a9449c4..f3ef0c9b434 100644 --- a/hphp/compiler/analysis/file_scope.h +++ b/hphp/compiler/analysis/file_scope.h @@ -67,7 +67,9 @@ struct FileScope : BlockScope, FunctionContainer, public: FileScope(const std::string &fileName, int fileSize, const MD5 &md5); - ~FileScope() { delete m_redeclaredFunctions; } + ~FileScope() override { + delete m_redeclaredFunctions; + } int getSize() const { return m_size;} const std::string &getName() const { return m_fileName;} @@ -87,7 +89,7 @@ public: void setAttribute(Attribute attr); int popAttribute(); - void serialize(JSON::DocTarget::OutputStream &out) const; + void serialize(JSON::DocTarget::OutputStream& out) const override; /** * Whether this file has top level non-declaration statements that diff --git a/hphp/compiler/statement/typedef_statement.h b/hphp/compiler/statement/typedef_statement.h index cb91b0301b8..57a96880b9f 100644 --- a/hphp/compiler/statement/typedef_statement.h +++ b/hphp/compiler/statement/typedef_statement.h @@ -33,7 +33,7 @@ struct TypedefStatement : Statement, IParseHandler { const std::string& name, const ExpressionListPtr& attrList, const TypeAnnotationPtr& typeAnnotation); - ~TypedefStatement(); + ~TypedefStatement() override; DECLARE_STATEMENT_VIRTUAL_FUNCTIONS; diff --git a/hphp/runtime/base/directory.h b/hphp/runtime/base/directory.h index 4a703235eb6..eff2df8b5ad 100644 --- a/hphp/runtime/base/directory.h +++ b/hphp/runtime/base/directory.h @@ -55,7 +55,7 @@ struct PlainDirectory : Directory { explicit PlainDirectory(const String& path); explicit PlainDirectory(int fd); - ~PlainDirectory(); + ~PlainDirectory() override; void close() override; Variant read() override; diff --git a/hphp/runtime/base/ini-setting.h b/hphp/runtime/base/ini-setting.h index 6ce4c6f4a90..9f41b63e626 100644 --- a/hphp/runtime/base/ini-setting.h +++ b/hphp/runtime/base/ini-setting.h @@ -191,21 +191,28 @@ public: const std::string& stopChar); }; struct SectionParserCallback : ParserCallback { - virtual void onSection(const std::string &name, void *arg); - virtual void onLabel(const std::string &name, void *arg); - virtual void onEntry(const std::string &key, const std::string &value, - void *arg); - virtual void onPopEntry(const std::string &key, const std::string &value, - const std::string &offset, void *arg); - private: + void onSection(const std::string& name, void* arg) override; + void onLabel(const std::string& name, void* arg) override; + void onEntry(const std::string& key, const std::string& value, void* arg) + override; + void onPopEntry( + const std::string& key, + const std::string& value, + const std::string& offset, + void* arg) override; + + private: Variant* activeArray(CallbackData* data); }; struct SystemParserCallback : ParserCallback { - virtual void onEntry(const std::string &key, const std::string &value, - void *arg); - virtual void onPopEntry(const std::string &key, const std::string &value, - const std::string &offset, void *arg); - virtual void onConstant(std::string &result, const std::string &name); + void onEntry(const std::string& key, const std::string& value, void* arg) + override; + void onPopEntry( + const std::string& key, + const std::string& value, + const std::string& offset, + void* arg) override; + void onConstant(std::string& result, const std::string& name) override; }; enum Mode { diff --git a/hphp/runtime/base/mem-file.h b/hphp/runtime/base/mem-file.h index 73b038eb8ac..7716023b62e 100644 --- a/hphp/runtime/base/mem-file.h +++ b/hphp/runtime/base/mem-file.h @@ -35,7 +35,7 @@ struct MemFile : File { MemFile(const char *data, int64_t len, const String& wrapper_type = null_string, const String& stream_type = empty_string_ref); - virtual ~MemFile(); + ~MemFile() override; CLASSNAME_IS("MemFile"); // overriding ResourceData diff --git a/hphp/runtime/base/plain-file.h b/hphp/runtime/base/plain-file.h index 107f04a9ea7..c36ef2ed93a 100644 --- a/hphp/runtime/base/plain-file.h +++ b/hphp/runtime/base/plain-file.h @@ -38,7 +38,7 @@ struct PlainFile : File { bool nonblocking = false, const String& wrapper = null_string, const String& stream_type = null_string); - virtual ~PlainFile(); + ~PlainFile() override; // overriding ResourceData const String& o_getClassNameHook() const override { return classnameof(); } @@ -77,7 +77,7 @@ protected: struct BuiltinFile : PlainFile { explicit BuiltinFile(FILE *stream) : PlainFile(stream, true) {} explicit BuiltinFile(int fd) : PlainFile(fd, true) {} - virtual ~BuiltinFile(); + ~BuiltinFile() override; bool close() override; void sweep() override; }; diff --git a/hphp/runtime/debugger/cmd/cmd_complete.h b/hphp/runtime/debugger/cmd/cmd_complete.h index 364d2050eb2..c4bbce1ae56 100644 --- a/hphp/runtime/debugger/cmd/cmd_complete.h +++ b/hphp/runtime/debugger/cmd/cmd_complete.h @@ -25,17 +25,17 @@ namespace HPHP { namespace Eval { struct CmdComplete : DebuggerCommand { CmdComplete() : DebuggerCommand(KindOfComplete) {} - virtual void list(DebuggerClient &client); - virtual void help(DebuggerClient &client); + void list(DebuggerClient& client) override; + void help(DebuggerClient& client) override; - virtual bool onServer(DebuggerProxy &proxy); - virtual void onClient(DebuggerClient &client); + bool onServer(DebuggerProxy& proxy) override; + void onClient(DebuggerClient& client) override; -protected: - virtual void sendImpl(DebuggerThriftBuffer &thrift); - virtual void recvImpl(DebuggerThriftBuffer &thrift); + protected: + void sendImpl(DebuggerThriftBuffer& thrift) override; + void recvImpl(DebuggerThriftBuffer& thrift) override; -private: + private: }; /////////////////////////////////////////////////////////////////////////////// diff --git a/hphp/runtime/debugger/cmd/cmd_where.h b/hphp/runtime/debugger/cmd/cmd_where.h index aa08c53e845..1149ccd381b 100644 --- a/hphp/runtime/debugger/cmd/cmd_where.h +++ b/hphp/runtime/debugger/cmd/cmd_where.h @@ -27,16 +27,16 @@ struct CmdWhere : DebuggerCommand { CmdWhere() : DebuggerCommand(KindOfWhere) {} explicit CmdWhere(Type type) : DebuggerCommand(type) {} - virtual void help(DebuggerClient &client); + void help(DebuggerClient& client) override; - virtual bool onServer(DebuggerProxy &proxy); - virtual void onClient(DebuggerClient &client); + bool onServer(DebuggerProxy& proxy) override; + void onClient(DebuggerClient& client) override; Array fetchStackTrace(DebuggerClient &client); // client side protected: - virtual void sendImpl(DebuggerThriftBuffer &thrift); - virtual void recvImpl(DebuggerThriftBuffer &thrift); + void sendImpl(DebuggerThriftBuffer& thrift) override; + void recvImpl(DebuggerThriftBuffer& thrift) override; private: req::root m_stacktrace; diff --git a/hphp/runtime/ext/mysql/mysql_common.h b/hphp/runtime/ext/mysql/mysql_common.h index 6f2888018a5..8183a6e1b67 100644 --- a/hphp/runtime/ext/mysql/mysql_common.h +++ b/hphp/runtime/ext/mysql/mysql_common.h @@ -284,7 +284,7 @@ struct MySQLResult : SweepableResourceData { DECLARE_RESOURCE_ALLOCATION(MySQLResult); explicit MySQLResult(MYSQL_RES *res, bool localized = false); - virtual ~MySQLResult(); + ~MySQLResult() override; CLASSNAME_IS("mysql result") // overriding ResourceData @@ -385,7 +385,7 @@ struct MySQLStmt : public SweepableResourceData { DECLARE_RESOURCE_ALLOCATION(MySQLStmt); explicit MySQLStmt(MYSQL *mysql); - virtual ~MySQLStmt(); + ~MySQLStmt() override; CLASSNAME_IS("mysql stmt") diff --git a/hphp/runtime/server/http-server.h b/hphp/runtime/server/http-server.h index 83d6771e228..eb07dd50e8d 100644 --- a/hphp/runtime/server/http-server.h +++ b/hphp/runtime/server/http-server.h @@ -43,7 +43,7 @@ private: public: explicit HttpServer(); - ~HttpServer(); + ~HttpServer() override; /* * Try to run the various servers that this class controls. diff --git a/hphp/runtime/server/pagelet-server.h b/hphp/runtime/server/pagelet-server.h index bf50f8fcc37..9493c17262f 100644 --- a/hphp/runtime/server/pagelet-server.h +++ b/hphp/runtime/server/pagelet-server.h @@ -164,8 +164,7 @@ private: }; struct PageletServerTaskEvent final : AsioExternalThreadEvent { - - ~PageletServerTaskEvent() { + ~PageletServerTaskEvent() override { if (m_job) m_job->decRefCount(); } @@ -179,33 +178,32 @@ struct PageletServerTaskEvent final : AsioExternalThreadEvent { } protected: - - void unserialize(Cell& result) override final { - // Main string responses from pagelet thread. - Array responses = Array::Create(); - - // Create an event for the next results that might be used. - PageletServerTaskEvent *event = new PageletServerTaskEvent(); - - int code = 0; - // Fetch all results from the transport that are currently available. - bool done = m_job->getResults(responses, code, event); - - // Returned tuple/array. - Array ret = Array::Create(); - ret.append(responses); - - if (done) { - // If the whole thing is done, then we don't need a next event. - event->abandon(); - ret.append(init_null_variant); - } else { - // The event was added to the job to be triggered next. - ret.append(Variant{event->getWaitHandle()}); - } - ret.append(Variant{code}); - - cellDup(*(Variant(ret)).asCell(), result); + void unserialize(Cell& result) final { + // Main string responses from pagelet thread. + Array responses = Array::Create(); + + // Create an event for the next results that might be used. + PageletServerTaskEvent* event = new PageletServerTaskEvent(); + + int code = 0; + // Fetch all results from the transport that are currently available. + bool done = m_job->getResults(responses, code, event); + + // Returned tuple/array. + Array ret = Array::Create(); + ret.append(responses); + + if (done) { + // If the whole thing is done, then we don't need a next event. + event->abandon(); + ret.append(init_null_variant); + } else { + // The event was added to the job to be triggered next. + ret.append(Variant{event->getWaitHandle()}); + } + ret.append(Variant{code}); + + cellDup(*(Variant(ret)).asCell(), result); } private: diff --git a/hphp/runtime/test/proxygen-transport-test.cpp b/hphp/runtime/test/proxygen-transport-test.cpp index d5ab50bfd64..f5c08183dc7 100644 --- a/hphp/runtime/test/proxygen-transport-test.cpp +++ b/hphp/runtime/test/proxygen-transport-test.cpp @@ -50,7 +50,7 @@ struct MockProxygenServer : ProxygenServer { MOCK_METHOD1(onRequestError, void(Transport*)); MOCK_METHOD1(onRequest, void(std::shared_ptr)); - virtual void putResponseMessage(ResponseMessage&& message) { + void putResponseMessage(ResponseMessage&& message) override { m_messageQueue.emplace_back(std::move(message)); } diff --git a/hphp/test/ext/test_ext_server.h b/hphp/test/ext/test_ext_server.h index b36004fea2a..c5e41752da8 100644 --- a/hphp/test/ext/test_ext_server.h +++ b/hphp/test/ext/test_ext_server.h @@ -22,7 +22,7 @@ /////////////////////////////////////////////////////////////////////////////// struct TestExtServer : TestCppExt { - virtual bool RunTests(const std::string &which); + bool RunTests(const std::string& which) override; bool test_pagelet_server_task_start(); bool test_pagelet_server_task_status(); diff --git a/hphp/test/ext/test_server.cpp b/hphp/test/ext/test_server.cpp index 0162d49a3a2..d3f7573fa43 100644 --- a/hphp/test/ext/test_server.cpp +++ b/hphp/test/ext/test_server.cpp @@ -255,10 +255,10 @@ void TestServer::KillServer() { struct TestServerRequestHandler : RequestHandler { explicit TestServerRequestHandler(int timeout) : RequestHandler(timeout) {} // implementing RequestHandler - virtual void handleRequest(Transport *transport) { + void handleRequest(Transport* transport) override { // do nothing } - virtual void abortRequest(Transport *transport) { + void abortRequest(Transport* transport) override { // do nothing } }; diff --git a/hphp/test/ext/test_server.h b/hphp/test/ext/test_server.h index 32f7f13dedb..6ecdee10078 100644 --- a/hphp/test/ext/test_server.h +++ b/hphp/test/ext/test_server.h @@ -28,7 +28,7 @@ struct TestServer : TestBase { TestServer() = delete; explicit TestServer(const std::string serverType); - virtual bool RunTests(const std::string &which); + bool RunTests(const std::string& which) override; // test test harness bool TestSanity(); diff --git a/hphp/util/job-queue.h b/hphp/util/job-queue.h index e3d4ff47e3a..2bd5a45132a 100644 --- a/hphp/util/job-queue.h +++ b/hphp/util/job-queue.h @@ -371,7 +371,7 @@ struct JobQueue : JobQueue { healthStatus) { pthread_cond_init(&m_cond, nullptr); } - ~JobQueue() { + ~JobQueue() override { pthread_cond_destroy(&m_cond); } void waitEmpty() { @@ -538,7 +538,7 @@ struct JobQueueDispatcher : IHostHealthObserver { int32_t dispatcher_id = 0; - ~JobQueueDispatcher() { + ~JobQueueDispatcher() override { stop(); for (auto func : m_funcs) delete func; for (auto worker : m_workers) delete worker; diff --git a/hphp/util/test/job-queue-workload.cpp b/hphp/util/test/job-queue-workload.cpp index 83cddcd145e..e94eac2febc 100644 --- a/hphp/util/test/job-queue-workload.cpp +++ b/hphp/util/test/job-queue-workload.cpp @@ -213,12 +213,12 @@ struct TickWorker , Tickable { TickWorker() : m_ticks(0) {} - virtual ~TickWorker() {} + ~TickWorker() override {} - virtual void onThreadEnter() { + void onThreadEnter() override { m_context->registerTickable(this); } - virtual void doJob(TickRequestPtr job) { + void doJob(TickRequestPtr job) override { job->setState(TickRequest::State::PROCESSING); std::unique_lock lk(m_mutex); m_job = job; @@ -227,10 +227,10 @@ struct TickWorker m_job->setState(TickRequest::State::COMPLETED); m_job.reset(); } - virtual void abortJob(TickRequestPtr job) { + void abortJob(TickRequestPtr job) override { m_job->setState(TickRequest::State::ABORTED); } - virtual void tick() { + void tick() override { std::lock_guard lk(m_mutex); ++m_ticks; if (!m_job) { @@ -260,7 +260,7 @@ struct JobQueueStatsCollector : Tickable { m_maxQueued(0) { } - void tick() { + void tick() override { m_maxQueued = std::max(m_maxQueued, m_dispatcher->getQueuedJobs()); m_maxLoad = std::max(m_maxLoad, m_dispatcher->getActiveWorker()); } @@ -272,8 +272,7 @@ struct JobQueueStatsCollector : Tickable { struct JobQueueTest : testing::Test { protected: - - virtual void SetUp() { + void SetUp() override { m_clock.reset(new TickingClock()); m_dispatcher.reset( new JobQueueDispatcher(180, 0, true, m_clock.get())); diff --git a/hphp/vixl/a64/debugger-a64.h b/hphp/vixl/a64/debugger-a64.h index 38b6a64cd29..78369ce2414 100644 --- a/hphp/vixl/a64/debugger-a64.h +++ b/hphp/vixl/a64/debugger-a64.h @@ -109,8 +109,8 @@ class Debugger : public Simulator { public: explicit Debugger(Decoder* decoder, std::ostream& stream); - virtual void Run(); - void VisitException(Instruction* instr); + void Run() override; + void VisitException(Instruction* instr) override; inline int log_parameters() { // The simulator can control disassembly, so make sure that the Debugger's diff --git a/hphp/vixl/a64/instrument-a64.h b/hphp/vixl/a64/instrument-a64.h index 87dcb6f6283..2992e151ed9 100644 --- a/hphp/vixl/a64/instrument-a64.h +++ b/hphp/vixl/a64/instrument-a64.h @@ -76,7 +76,7 @@ class Instrument: public DecoderVisitor { public: explicit Instrument(const char* datafile = nullptr, uint64_t sample_period = kDefaultInstrumentationSamplingPeriod); - ~Instrument(); + ~Instrument() override; void Enable(); void Disable(); -- 2.11.4.GIT