[PATCH] D159263: [clang-tidy] misc-include-cleaner: remove duplicated includes & fixes

Ding Fei via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 31 08:27:02 PDT 2023


danix800 added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp:227
+          << Inc.SymRef.Target.name();
+      if (!AlreadyInserted.contains(Inc.Missing.resolvedPath())) {
+        DB << FixItHint::CreateInsertion(
----------------
sammccall wrote:
> This means that if you're looking at individual diagnostics rather than applying all fixes to a file, only the first diagnostic will have any fix available at all.
> 
> I believe the preferred solution is to do this conditionally based on areDiagsSelfContained(). `clang_tidy::utils::IncludeInserter` encapsulates this, but isn't used here.
> 
> I don't know whether we would want to use it here, or how carefully it's already been considered. (It definitely contains a lot of logic that is dubious to apply when the include to insert has already been precisely calculated, but also some things that would be helpful). Will defer to Kadir on that.
Thanks for mentioning the `clang_tidy::utils::IncludeInserter`. I took a further look and found that `IncludeInserter` is
more suitable for this checker.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159263



More information about the cfe-commits mailing list