[PATCH] D128204: [clangd] Add fix-it for inserting IWYU pragma: keep

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 21 08:34:04 PDT 2022

kadircet added a comment.

as discussed offline I agree that we should have this, as no matter how hard we try there are going to be cases that we can't get right due to ADL/template instantiations or depending on 3rd party code that cannot be edited and also doesn't have relevant pragmas inside.

my hesitation about having them at this stage is, we won't be able to:

- get feedback around most of these issues as people will just put a pragma and be done with it.
- fix them going forward, even after implementation gets better, we won't be able to diagnose these headers and "falsely" issued pragmas will keep includes around.

Hence i'd like to hear a little bit more about what kind of false positives you're facing often enough to need this as an automated fix at this stage, to see if there's something we can do to improve the implementation first.

Comment at: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp:1795
   Annotations Test(R"cpp(
-$fix[[  $diag[[#include "unused.h"]]
+$fix[[  $diag[[#include "unused.h"]]$insert[[]]
can you also have a test with an include that already has a trailing comment?

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list