[PATCH] D75538: [clang-tidy] Updated language supported restrictions on some checks

Alexander Kornienko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 5 04:56:42 PST 2020


alexfh added inline comments.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-basic.cpp:1
-// RUN: %check_clang_tidy -std=c++98 %s modernize-use-nullptr %t -- -- -Wno-non-literal-null-conversion
-//
----------------
njames93 wrote:
> alexfh wrote:
> > gribozavr2 wrote:
> > > njames93 wrote:
> > > > alexfh wrote:
> > > > > IIRC, some of the modernize- checks were meant to be useful to make the pre-C++11 code compile in C++11. This check is an example of this (maybe the only one?). Limiting the check to C++11 and deleting this test is a bit too radical.
> > > > I'm lost, this check is all about replacing assignment of pointer to 0 with `nullptr` a keyword which doesn't exist pre c++11, so this test case will just result in invalid code. Or am I missing the point?
> > > The idea, if I understand correctly, is that you start with C++98 code, apply modernize-* checks, and get C++11 code.
> > Yep, at least for this particular check there are cases, which won't compile in C++11, but will compile after its fixes are applied. Not sure if this was ever used like this though.
> My understanding of the modernize module was its designed to convert the old c++98/03 code to use newer (safer) c++ constructs. Its purpose isn't to fix compiler errors in c++11 mode that compile OK in c++98 mode
This and a number of other modernize- checks were migrated from the clang-modernize (previously cpp11-migrate) tool. It's hard to tell now, whether running on code in C++98 mode and fixing errors that would appear in C++11 **was** a supported use case at the time (though all commits are in git and one could look up, if someone wants to). But that's irrelevant. We need to decide **now**, whether we want to support this use case or not.
I believe, fixing C++11 compatibility **errors** in valid C++98 code is a potentially useful feature. Given that it doesn't require additional maintenance costs, I think we should leave it as is. The only downside is complaints from users who blindly run _all_ the checks regardless of whether they need them or not. We could try to relieve this pain, but a better treatment here would be to use the tool correctly, i.e. carefully select the checks to enable. That seems to partly be a UX problem of the frontend they use (CLion in the recent bug report - https://www.jetbrains.com/help/clion/clang-tidy-checks-support.html). Some UIs try to be more user-friendly w.r.t. configuration of the checks (e.g. I found this one today: https://www.cppdepend.com/Modernize).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75538/new/

https://reviews.llvm.org/D75538





More information about the cfe-commits mailing list