This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Publish diagnostics from stale preambles
AbandonedPublic

Authored by kadircet on Jan 30 2023, 6:22 AM.

Details

Reviewers
sammccall
hokein
Summary

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.

Diff Detail

Event Timeline

kadircet created this revision.Jan 30 2023, 6:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 30 2023, 6:22 AM
Herald added a subscriber: arphaman. · View Herald Transcript
kadircet requested review of this revision.Jan 30 2023, 6:22 AM
kadircet updated this revision to Diff 493382.Jan 30 2023, 12:44 PM

Well, turns out presumed location patching was not handled in clangd at all for
diagnostics. So add that to translate ranges, at least when we have ranges or
locations that point to preamble patch.

kadircet abandoned this revision.Feb 1 2023, 10:36 AM

split into D143093, D143095 and D143096