Bug 1318004 - Use C++11's override and remove virtual where applicable. draft
authorSylvestre Ledru <sledru@mozilla.com>
Wed, 16 Nov 2016 16:38:10 +0100
changeset 439777 848d5caf1c5fadb2589acc2167cc6dc473a210a0
parent 439776 88ebdb64e8291b1147f651c1f547ad539e35f029
child 537247 ace224c3e9582b7bcd7557261bfb27abb8d1c719
push id36087
push usersledru@mozilla.com
push dateWed, 16 Nov 2016 15:54:11 +0000
bugs1318004
milestone53.0a1
Bug 1318004 - Use C++11's override and remove virtual where applicable. MozReview-Commit-ID: 8IoEm8sSRnO
toolkit/components/osfile/NativeOSFileInternals.cpp
toolkit/components/protobuf/src/google/protobuf/extension_set_heavy.cc
toolkit/components/protobuf/src/google/protobuf/text_format.cc
toolkit/components/telemetry/Telemetry.cpp
toolkit/components/telemetry/TelemetryScalar.cpp
toolkit/identity/IdentityCryptoService.cpp
toolkit/mozapps/update/updater/updater.cpp
--- a/toolkit/components/osfile/NativeOSFileInternals.cpp
+++ b/toolkit/components/osfile/NativeOSFileInternals.cpp
@@ -736,17 +736,17 @@ public:
                           const uint32_t aBytes,
                           nsMainThreadPtrHandle<nsINativeOSFileSuccessCallback>& aOnSuccess,
                           nsMainThreadPtrHandle<nsINativeOSFileErrorCallback>& aOnError)
     : AbstractReadEvent(aPath, aBytes,
                         aOnSuccess, aOnError)
     , mResult(new TypedArrayResult(TimeStamp::Now()))
   { }
 
-  ~DoReadToTypedArrayEvent() {
+  ~DoReadToTypedArrayEvent() override {
     // If AbstractReadEvent::Run() has bailed out, we may need to cleanup
     // mResult, which is main-thread only data
     if (!mResult) {
       return;
     }
     NS_ReleaseOnMainThread(mResult.forget());
   }
 
@@ -773,17 +773,17 @@ public:
                       const uint32_t aBytes,
                       nsMainThreadPtrHandle<nsINativeOSFileSuccessCallback>& aOnSuccess,
                       nsMainThreadPtrHandle<nsINativeOSFileErrorCallback>& aOnError)
     : AbstractReadEvent(aPath, aBytes, aOnSuccess, aOnError)
     , mEncoding(aEncoding)
     , mResult(new StringResult(TimeStamp::Now()))
   { }
 
-  ~DoReadToStringEvent() {
+  ~DoReadToStringEvent() override {
     // If AbstraactReadEvent::Run() has bailed out, we may need to cleanup
     // mResult, which is main-thread only data
     if (!mResult) {
       return;
     }
     NS_ReleaseOnMainThread(mResult.forget());
   }
 
--- a/toolkit/components/protobuf/src/google/protobuf/extension_set_heavy.cc
+++ b/toolkit/components/protobuf/src/google/protobuf/extension_set_heavy.cc
@@ -49,17 +49,17 @@ namespace protobuf {
 namespace internal {
 
 // A FieldSkipper used to store unknown MessageSet fields into UnknownFieldSet.
 class MessageSetFieldSkipper
     : public UnknownFieldSetFieldSkipper {
  public:
   explicit MessageSetFieldSkipper(UnknownFieldSet* unknown_fields)
       : UnknownFieldSetFieldSkipper(unknown_fields) {}
-  virtual ~MessageSetFieldSkipper() = default;
+  ~MessageSetFieldSkipper() override = default;
 
   virtual bool SkipMessageSetField(io::CodedInputStream* input,
                                    int field_number);
 };
 bool MessageSetFieldSkipper::SkipMessageSetField(
     io::CodedInputStream* input, int field_number) {
   uint32 length;
   if (!input->ReadVarint32(&length)) return false;
@@ -76,19 +76,19 @@ bool MessageSetFieldSkipper::SkipMessage
 // DescriptorPool, using the given MessageFactory to construct sub-objects.
 // This class is implemented in extension_set_heavy.cc.
 class DescriptorPoolExtensionFinder : public ExtensionFinder {
  public:
   DescriptorPoolExtensionFinder(const DescriptorPool* pool,
                                 MessageFactory* factory,
                                 const Descriptor* containing_type)
       : pool_(pool), factory_(factory), containing_type_(containing_type) {}
-  virtual ~DescriptorPoolExtensionFinder() = default;
+  ~DescriptorPoolExtensionFinder() override = default;
 
-  virtual bool Find(int number, ExtensionInfo* output);
+  bool Find(int number, ExtensionInfo* output) override;
 
  private:
   const DescriptorPool* pool_;
   MessageFactory* factory_;
   const Descriptor* containing_type_;
 };
 
 void ExtensionSet::AppendToList(const Descriptor* containing_type,
--- a/toolkit/components/protobuf/src/google/protobuf/text_format.cc
+++ b/toolkit/components/protobuf/src/google/protobuf/text_format.cc
@@ -970,23 +970,23 @@ class TextFormat::Parser::ParserImpl {
 
   // An internal instance of the Tokenizer's error collector, used to
   // collect any base-level parse errors and feed them to the ParserImpl.
   class ParserErrorCollector : public io::ErrorCollector {
    public:
     explicit ParserErrorCollector(TextFormat::Parser::ParserImpl* parser) :
         parser_(parser) { }
 
-    virtual ~ParserErrorCollector() = default;
+    ~ParserErrorCollector() override = default;
 
-    virtual void AddError(int line, int column, const string& message) {
+    void AddError(int line, int column, const string& message) override {
       parser_->ReportError(line, column, message);
     }
 
-    virtual void AddWarning(int line, int column, const string& message) {
+    void AddWarning(int line, int column, const string& message) override {
       parser_->ReportWarning(line, column, message);
     }
 
    private:
     GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ParserErrorCollector);
     TextFormat::Parser::ParserImpl* parser_;
   };
 
@@ -1309,20 +1309,20 @@ string TextFormat::FieldValuePrinter::Pr
     bool single_line_mode) const {
   return single_line_mode ? "} " : "}\n";
 }
 
 namespace {
 // Our own specialization: for UTF8 escaped strings.
 class FieldValuePrinterUtf8Escaping : public TextFormat::FieldValuePrinter {
  public:
-  virtual string PrintString(const string& val) const {
+  string PrintString(const string& val) const override {
     return StrCat(R"(")", strings::Utf8SafeCEscape(val), R"(")");
   }
-  virtual string PrintBytes(const string& val) const {
+  string PrintBytes(const string& val) const override {
     return TextFormat::FieldValuePrinter::PrintString(val);
   }
 };
 
 }  // namespace
 
 TextFormat::Printer::Printer()
   : initial_indent_level_(0),
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -421,17 +421,17 @@ class TelemetryIOInterposeObserver : pub
 
 public:
   explicit TelemetryIOInterposeObserver(nsIFile* aXreDir);
 
   /**
    * An implementation of Observe that records statistics of all
    * file IO operations.
    */
-  void Observe(Observation& aOb);
+  void Observe(Observation& aOb) override;
 
   /**
    * Reflect recorded file IO statistics into Javascript
    */
   bool ReflectIntoJS(JSContext *cx, JS::Handle<JSObject*> rootObj);
 
   /**
    * Adds a path for inclusion in main thread I/O report.
--- a/toolkit/components/telemetry/TelemetryScalar.cpp
+++ b/toolkit/components/telemetry/TelemetryScalar.cpp
@@ -190,17 +190,17 @@ ScalarBase::HandleUnsupported() const
  * The implementation for the unsigned int scalar type.
  */
 class ScalarUnsigned : public ScalarBase
 {
 public:
   using ScalarBase::SetValue;
 
   ScalarUnsigned() : mStorage(0) {};
-  ~ScalarUnsigned() = default;;
+  ~ScalarUnsigned() override = default;;
 
   ScalarResult SetValue(nsIVariant* aValue) final;
   void SetValue(uint32_t aValue) final;
   ScalarResult AddValue(nsIVariant* aValue) final;
   void AddValue(uint32_t aValue) final;
   ScalarResult SetMaximum(nsIVariant* aValue) final;
   void SetMaximum(uint32_t aValue) final;
   nsresult GetValue(nsCOMPtr<nsIVariant>& aResult) const final;
@@ -330,17 +330,17 @@ ScalarUnsigned::CheckInput(nsIVariant* a
  * The implementation for the string scalar type.
  */
 class ScalarString : public ScalarBase
 {
 public:
   using ScalarBase::SetValue;
 
   ScalarString() : mStorage(EmptyString()) {};
-  ~ScalarString() = default;;
+  ~ScalarString() override = default;;
 
   ScalarResult SetValue(nsIVariant* aValue) final;
   ScalarResult SetValue(const nsAString& aValue) final;
   nsresult GetValue(nsCOMPtr<nsIVariant>& aResult) const final;
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const final;
 
 private:
   nsString mStorage;
@@ -411,17 +411,17 @@ ScalarString::SizeOfIncludingThis(mozill
  * The implementation for the boolean scalar type.
  */
 class ScalarBoolean : public ScalarBase
 {
 public:
   using ScalarBase::SetValue;
 
   ScalarBoolean() : mStorage(false) {};
-  ~ScalarBoolean() = default;;
+  ~ScalarBoolean() override = default;;
 
   ScalarResult SetValue(nsIVariant* aValue) final;
   void SetValue(bool aValue) final;
   nsresult GetValue(nsCOMPtr<nsIVariant>& aResult) const final;
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const final;
 
 private:
   bool mStorage;
--- a/toolkit/identity/IdentityCryptoService.cpp
+++ b/toolkit/identity/IdentityCryptoService.cpp
@@ -51,17 +51,17 @@ class KeyPair : public nsIIdentityKeyPai
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIIDENTITYKEYPAIR
 
   KeyPair(SECKEYPrivateKey* aPrivateKey, SECKEYPublicKey* aPublicKey);
 
 private:
-  ~KeyPair()
+  ~KeyPair() override
   {
     nsNSSShutDownPreventionLock locker;
     if (isAlreadyShutDown()) {
       return;
     }
     destructorSafeDestroyNSSReference();
     shutdown(ShutdownCalledFrom::Object);
   }
@@ -91,27 +91,27 @@ NS_IMPL_ISUPPORTS(KeyPair, nsIIdentityKe
 class KeyGenRunnable : public Runnable, public nsNSSShutDownObject
 {
 public:
   NS_DECL_NSIRUNNABLE
 
   KeyGenRunnable(KeyType keyType, nsIIdentityKeyGenCallback * aCallback);
 
 private:
-  ~KeyGenRunnable()
+  ~KeyGenRunnable() override
   {
     nsNSSShutDownPreventionLock locker;
     if (isAlreadyShutDown()) {
       return;
     }
     destructorSafeDestroyNSSReference();
     shutdown(ShutdownCalledFrom::Object);
   }
 
-  virtual void virtualDestroyNSSReference() override
+  void virtualDestroyNSSReference() override
   {
     destructorSafeDestroyNSSReference();
   }
 
   void destructorSafeDestroyNSSReference()
   {
   }
 
@@ -128,17 +128,17 @@ class SignRunnable : public Runnable, pu
 {
 public:
   NS_DECL_NSIRUNNABLE
 
   SignRunnable(const nsACString & textToSign, SECKEYPrivateKey * privateKey,
                nsIIdentitySignCallback * aCallback);
 
 private:
-  ~SignRunnable()
+  ~SignRunnable() override
   {
     nsNSSShutDownPreventionLock locker;
     if (isAlreadyShutDown()) {
       return;
     }
     destructorSafeDestroyNSSReference();
     shutdown(ShutdownCalledFrom::Object);
   }
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -1110,20 +1110,20 @@ private:
   friend class ActionList;
 };
 
 class RemoveFile : public Action
 {
 public:
   RemoveFile() : mSkip(0) { }
 
-  int Parse(NS_tchar *line);
-  int Prepare();
-  int Execute();
-  void Finish(int status);
+  int Parse(NS_tchar *line) override;
+  int Prepare() override;
+  int Execute() override;
+  void Finish(int status) override;
 
 private:
   mozilla::UniquePtr<NS_tchar[]> mFile;
   mozilla::UniquePtr<NS_tchar[]> mRelPath;
   int mSkip;
 };
 
 int
@@ -1241,20 +1241,20 @@ RemoveFile::Finish(int status)
   }
 }
 
 class RemoveDir : public Action
 {
 public:
   RemoveDir() : mSkip(0) { }
 
-  virtual int Parse(NS_tchar *line);
-  virtual int Prepare(); // check that the source dir exists
-  virtual int Execute();
-  virtual void Finish(int status);
+  int Parse(NS_tchar *line) override;
+  int Prepare() override; // check that the source dir exists
+  int Execute() override;
+  void Finish(int status) override;
 
 private:
   mozilla::UniquePtr<NS_tchar[]> mDir;
   mozilla::UniquePtr<NS_tchar[]> mRelPath;
   int mSkip;
 };
 
 int
@@ -1358,20 +1358,20 @@ RemoveDir::Finish(int status)
   }
 }
 
 class AddFile : public Action
 {
 public:
   AddFile() : mAdded(false) { }
 
-  virtual int Parse(NS_tchar *line);
-  virtual int Prepare();
-  virtual int Execute();
-  virtual void Finish(int status);
+  int Parse(NS_tchar *line) override;
+  int Prepare() override;
+  int Execute() override;
+  void Finish(int status) override;
 
 private:
   mozilla::UniquePtr<NS_tchar[]> mFile;
   mozilla::UniquePtr<NS_tchar[]> mRelPath;
   bool mAdded;
 };
 
 int
@@ -1461,22 +1461,22 @@ AddFile::Finish(int status)
   }
 }
 
 class PatchFile : public Action
 {
 public:
   PatchFile() : mPatchFile(nullptr), mPatchIndex(-1), buf(nullptr) { }
 
-  virtual ~PatchFile();
-
-  virtual int Parse(NS_tchar *line);
-  virtual int Prepare(); // should check for patch file and for checksum here
-  virtual int Execute();
-  virtual void Finish(int status);
+  ~PatchFile() override;
+
+  int Parse(NS_tchar *line) override;
+  int Prepare() override; // should check for patch file and for checksum here
+  int Execute() override;
+  void Finish(int status) override;
 
 private:
   int LoadSourceFile(FILE* ofile);
 
   static int sPatchIndex;
 
   const NS_tchar *mPatchFile;
   mozilla::UniquePtr<NS_tchar[]> mFile;
@@ -1782,20 +1782,20 @@ PatchFile::Finish(int status)
   if (!sStagedUpdate) {
     backup_finish(mFile.get(), mFileRelPath.get(), status);
   }
 }
 
 class AddIfFile : public AddFile
 {
 public:
-  virtual int Parse(NS_tchar *line);
-  virtual int Prepare();
-  virtual int Execute();
-  virtual void Finish(int status);
+  int Parse(NS_tchar *line) override;
+  int Prepare() override;
+  int Execute() override;
+  void Finish(int status) override;
 
 protected:
   mozilla::UniquePtr<NS_tchar[]> mTestFile;
 };
 
 int
 AddIfFile::Parse(NS_tchar *line)
 {
@@ -1843,20 +1843,20 @@ AddIfFile::Finish(int status)
     return;
 
   AddFile::Finish(status);
 }
 
 class AddIfNotFile : public AddFile
 {
 public:
-  virtual int Parse(NS_tchar *line);
-  virtual int Prepare();
-  virtual int Execute();
-  virtual void Finish(int status);
+  int Parse(NS_tchar *line) override;
+  int Prepare() override;
+  int Execute() override;
+  void Finish(int status) override;
 
 protected:
   mozilla::UniquePtr<NS_tchar[]> mTestFile;
 };
 
 int
 AddIfNotFile::Parse(NS_tchar *line)
 {
@@ -1904,20 +1904,20 @@ AddIfNotFile::Finish(int status)
     return;
 
   AddFile::Finish(status);
 }
 
 class PatchIfFile : public PatchFile
 {
 public:
-  virtual int Parse(NS_tchar *line);
-  virtual int Prepare(); // should check for patch file and for checksum here
-  virtual int Execute();
-  virtual void Finish(int status);
+  int Parse(NS_tchar *line) override;
+  int Prepare() override; // should check for patch file and for checksum here
+  int Execute() override;
+  void Finish(int status) override;
 
 private:
   mozilla::UniquePtr<NS_tchar[]> mTestFile;
 };
 
 int
 PatchIfFile::Parse(NS_tchar *line)
 {