[PATCH] D57087: [clang-tidy] add OverrideMacro to modernize-use-override check
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 23 01:20:22 PST 2019
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: alexfh, JonasToth, hokein, Eugene.Zelenko, aaron.ballman.
MyDeveloperDay added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, xazax.hun.
The usefulness of **modernize-use-override** can be reduced if you have to live in an environment where you support multiple compilers, some of which sadly are not yet fully C++11 compliant
some codebases have to use override as a macro OVERRIDE e.g.
#if defined(COMPILER_MSVC)
#define OVERRIDE override
#elif defined(__clang__)
#define OVERRIDE override
// GCC 4.7 supports explicit virtual overrides when C++11 support is enabled.
#define OVERRIDE override
#else
#define OVERRIDE
#endif
This allows code to be compiled with C++11 compliant compilers and get warnings and errors that clang, MSVC,gcc can give, while still allowing other legacy pre C++11 compilers to compile the code. This can be an important step towards modernizing C++ code whilst living in a legacy codebase.
When it comes to clang tidy, the use of the **modernize-use-override** is one of the most useful checks, but the messages reported are inaccurate for that codebase if the standard approach is to use the macros OVERRIDE and/or FINAL.
When combined with fix-its that introduce the C++11 override keyword, they become fatal, resulting in the modernize-use-override check being turned off to prevent the introduction of such errors.
This revision, allows the possibility for the replacement **override **to be a macro instead, Allowing the clang-tidy check to be run on both pre and post C++11 code, and allowing fix-its to be applied.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D57087
Files:
clang-tidy/modernize/UseOverrideCheck.cpp
clang-tidy/modernize/UseOverrideCheck.h
docs/clang-tidy/checks/modernize-use-override.rst
test/clang-tidy/modernize-use-override-cxx98-with-macro.cpp
test/clang-tidy/modernize-use-override-cxx98-with-no-macro-inscope.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57087.183056.patch
Type: text/x-patch
Size: 12334 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190123/8d7be339/attachment.bin>
More information about the cfe-commits
mailing list