[PATCH] D142892: [clangd] Publish diagnostics from stale preambles

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 30 06:22:47 PST 2023


kadircet created this revision.
kadircet added reviewers: sammccall, hokein.
Herald added a subscriber: arphaman.
Herald added a project: All.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Diagnostics emitted while parsing main-file is easy, as they already
see new source locations. We just need to make sure the ones that can be
attributed to preamble section of the file is patched. That's achieved in two
ways:

- New include is actually patched with a #line-directive, so most clang features already point at the right line.
- Patching of main-file-includes inside the ParsedAST, which is used by replay preamble and include-cleaner analysis. This patch fixes/improve patching in this case.

The second problem is patching includes that were published when building the
preamble. Unfortunately because we don't have the full edit history in place,
it's hard to perform an exact translation. This patch tries to just preserve
diagnostics that are contained to lines containing #include or #define
directives and moves them around with the new file contents. It's granularity is
per-line, it doesn't handle column-wide changes.

Depends on D142890 <https://reviews.llvm.org/D142890>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142892

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/unittests/PreambleTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142892.493297.patch
Type: text/x-patch
Size: 18542 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230130/a1a0eb6a/attachment-0001.bin>


More information about the cfe-commits mailing list