[PATCH] D114667: [clangd] Add fixes for clang "include <foo.h>" diagnostics

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 27 15:34:42 PST 2021


sammccall created this revision.
sammccall added a reviewer: nridge.
Herald added subscribers: usaxena95, kadircet, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, MaskRay, ilya-biryukov.
Herald added a reviewer: jdoerfert.
Herald added a project: clang-tools-extra.

Clang doesn't offer these fixes I guess for a couple of reasons:

- where to insert includes is a formatting concern, and clang shouldn't depend on clang-format
- the way clang prints diagnostics, we'd show a bunch of basically irrelevant context of "this is where we'd want to insert the include"

Maybe it's possible to hack around 1, but 2 is still a concern.
Meanwhile, bolting this onto include-fixer gets the job done.

Fixes https://github.com/clangd/clangd/issues/355
Fixes https://github.com/clangd/clangd/issues/937


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114667

Files:
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/IncludeFixer.cpp
  clang-tools-extra/clangd/IncludeFixer.h
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114667.390175.patch
Type: text/x-patch
Size: 5596 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211127/11198736/attachment.bin>


More information about the cfe-commits mailing list