[PATCH] D146875: [clang-tidy] Fix example provided by add_new_check.py

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 29 09:54:11 PDT 2023


njames93 added a comment.

In D146875#4229544 <https://reviews.llvm.org/D146875#4229544>, @carlosgalvezp wrote:

> I think easiest is to go for Option A) - this is how we normally write checks nowadays. Maybe the discussion about removing support for `--fix-notes` can be done in an RFC?

Fix notes was added to address the situation that clang-tidy just blindly applies the first fix found with a warning, The behaviour contradicts with how clang handles fixes.
The basic idea is if a fix is attached to a warning, we have very high confidence that it is the correct fix and wont contradict the programmers initial intent.
Fixes attached to notes are for cases when there a multiple possible ways to silence a warning, or if the way to silence a warning could change the programmers initial intent.

Fix notes basically reverts clang tidy to use the old behaviour of just blindly applying the first fix it finds, which some users may wish to use, there fore shouldn't be removed.

The simplest thing here is to just update the example generator script to attach the fix directly to the warning.
In fact, I'd go as far as saying including adding `--fix-notes` to the test file can harm new checks in future as fixes may not be applied when running normally


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146875



More information about the cfe-commits mailing list