[PATCH] D70165: clang-tidy: modernize-use-override new option AllowOverrideAndFinal
Conrad Poelman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 12 23:20:31 PST 2019
poelmanc created this revision.
poelmanc added reviewers: alexfh, djasper.
Herald added subscribers: cfe-commits, mgehre.
Herald added a project: clang.
In addition to adding `override` wherever possible, clang-tidy's `modernize-use-override` nicely removes `virtual` when `override` or `final` is specified, and further removes `override` when `final` is specified. While this is great default behavior, when code needs to be compiled with `gcc` at high warning levels that include `gcc -Wsuggest-override` or `gcc -Werror=suggest-override`, clang-tidy's removal of the redundant `override` keyword causes gcc to emit a warning or error. This discrepancy / conflict has been noted by others including a comment on Stack Overflow <https://stackoverflow.com/questions/29145476/requiring-virtual-function-overrides-to-use-override-keyword> and by Mozzilla's Firefox developers <https://bugzilla.mozilla.org/show_bug.cgi?id=1430669>.
This patch adds an AllowOverrideAndFinal option defaulting to `0` - thus preserving current behavior - that when enabled allows both `override` and `final` to co-exist, while still fixing all other issues.
The patch includes a test file verifying all combinations of ``virtual``/``override``/``final``, and mentions the new option in the release notes.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D70165
Files:
clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.h
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/modernize-use-override.rst
clang-tools-extra/test/clang-tidy/checkers/modernize-use-override-allow-override-and-final.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70165.229012.patch
Type: text/x-patch
Size: 6412 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191113/120e344a/attachment.bin>
More information about the cfe-commits
mailing list