Bug 1436263 - Part 5: Add a mach lint for virtual function declarations with multiple specifiers. r=froydnj r=ahal
authorChris Peterson <cpeterson@mozilla.com>
Thu, 15 Feb 2018 00:50:02 -0800
changeset 404327 0a00e515def32e3a4b194967e6080abfc629d315
parent 404326 8f706e7a3934ab8b58b98a04361ef9503c828987
child 404328 13aea3b64e17ad4994e327bb6c551d8dcdd81799
push id99981
push usercpeterson@mozilla.com
push dateSat, 17 Feb 2018 23:52:32 +0000
treeherdermozilla-inbound@0a00e515def3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, ahal
bugs1436263
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1436263 - Part 5: Add a mach lint for virtual function declarations with multiple specifiers. r=froydnj r=ahal Virtual function declarations should specify only one of `virtual`, `final`, or `override`, as per the Mozilla C++ style guide: https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style This lint warns about: virtual void Bad1() final void Bad2() final override void Bad3() override final Caveats: This lint doesn't warn about `virtual void NotBad() override` at this time because there are 8000+ instances. It also doesn't warn about function declarations that span multiple lines because the regex can't match across line breaks. MozReview-Commit-ID: LcBsOAKKgz7
taskcluster/ci/source-test/mozlint.yml
tools/lint/cpp-virtual-final.yml
--- a/taskcluster/ci/source-test/mozlint.yml
+++ b/taskcluster/ci/source-test/mozlint.yml
@@ -33,16 +33,29 @@ codespell:
             - '**/*.cpp'
             - '**/*.c'
             - '**/*.h'
             - '**/*.configure'
             - '**/*.py'
             - '**/*.properties'
             - '**/*.rst'
 
+cpp-virtual-final:
+    description: lint C++ virtual function declarations
+    platform: lint/opt
+    treeherder:
+        symbol: Cvf
+    run:
+        mach: lint -l cpp-virtual-final -f treeherder
+    when:
+        files-changed:
+            - '**/*.cpp'
+            - '**/*.h'
+            - '**/*.mm'
+
 eslint:
     description: JS lint check
     platform: lint/opt
     treeherder:
         symbol: ES
     run:
         using: run-task
         command: >
new file mode 100644
--- /dev/null
+++ b/tools/lint/cpp-virtual-final.yml
@@ -0,0 +1,31 @@
+---
+cpp-virtual-final:
+    description: "Virtual function declarations should specify only one of
+                  `virtual`, `final`, or `override`"
+    level: warning
+    include: ['.']
+    exclude:
+        # Third-party code with cpp-virtual-final warnings:
+        - gfx/angle
+        - gfx/skia
+        - media/webrtc/trunk
+        - security/sandbox/chromium
+    extensions: ['cpp', 'h', 'mm']
+    type: regex
+    #
+    # This lint warns about:
+    #
+    #   virtual void Bad1() final
+    #   void Bad2() final override
+    #   void Bad3() override final
+    #
+    # Caveats: This lint ...
+    #
+    #   * Doesn't warn about `virtual void NotBad() override` at this time
+    #     because there are 8000+ instances.
+    #
+    #   * Doesn't warn about function declarations that span multiple lines
+    #     because the regex can't match across line breaks.
+    #
+    #           virtual    )    final  |  final  override  |  override  final
+    payload: ^ *virtual .+\).+\bfinal\b|\bfinal +override\b|\boverride +final\b