[all-commits] [llvm/llvm-project] 7177a2: [clangd] Add config option for fast diagnostics mode

kadir ├žetinkaya via All-commits all-commits at lists.llvm.org
Wed Feb 22 06:54:47 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7177a237b68f32befcecedba78a875f1bbc4a609
      https://github.com/llvm/llvm-project/commit/7177a237b68f32befcecedba78a875f1bbc4a609
  Author: Kadir Cetinkaya <kadircet at google.com>
  Date:   2023-02-22 (Wed, 22 Feb 2023)

  Changed paths:
    M clang-tools-extra/clangd/Config.h
    M clang-tools-extra/clangd/ConfigCompile.cpp
    M clang-tools-extra/clangd/ConfigFragment.h
    M clang-tools-extra/clangd/ConfigYAML.cpp
    M clang-tools-extra/clangd/Preamble.cpp
    M clang-tools-extra/clangd/Preamble.h
    M clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
    M clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
    M clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
    M clang-tools-extra/clangd/unittests/PreambleTests.cpp

  Log Message:
  -----------
  [clangd] Add config option for fast diagnostics mode

Also wire it up for use with patched preambles and introduce test cases
for behaviour we'd like to improve.

Differential Revision: https://reviews.llvm.org/D142890


  Commit: 75ae784e8f49cf2425f3bf702a1bbf6c581e721a
      https://github.com/llvm/llvm-project/commit/75ae784e8f49cf2425f3bf702a1bbf6c581e721a
  Author: Kadir Cetinkaya <kadircet at google.com>
  Date:   2023-02-22 (Wed, 22 Feb 2023)

  Changed paths:
    M clang-tools-extra/clangd/Preamble.cpp
    M clang-tools-extra/clangd/unittests/PreambleTests.cpp

  Log Message:
  -----------
  [clangd] #undef macros inside preamble patch

That way we can stop generating false macro redefinition diagnostics.

Depends on D142890

Differential Revision: https://reviews.llvm.org/D143093


  Commit: 909cd1f9a8934033a803659da8c54c87013941ef
      https://github.com/llvm/llvm-project/commit/909cd1f9a8934033a803659da8c54c87013941ef
  Author: Kadir Cetinkaya <kadircet at google.com>
  Date:   2023-02-22 (Wed, 22 Feb 2023)

  Changed paths:
    M clang-tools-extra/clangd/Diagnostics.cpp
    M clang-tools-extra/clangd/Preamble.cpp
    M clang-tools-extra/clangd/Preamble.h
    M clang-tools-extra/clangd/SourceCode.cpp
    M clang-tools-extra/clangd/SourceCode.h
    M clang-tools-extra/clangd/unittests/PreambleTests.cpp

  Log Message:
  -----------
  [clangd] Respect preamble-patch when handling diags

Depends on D143093

Differential Revision: https://reviews.llvm.org/D143095


  Commit: 8c2a12f7f9b6dc078bfb18df9333379fdf27c6a3
      https://github.com/llvm/llvm-project/commit/8c2a12f7f9b6dc078bfb18df9333379fdf27c6a3
  Author: Kadir Cetinkaya <kadircet at google.com>
  Date:   2023-02-22 (Wed, 22 Feb 2023)

  Changed paths:
    M clang-tools-extra/clangd/ParsedAST.cpp
    M clang-tools-extra/clangd/Preamble.cpp
    M clang-tools-extra/clangd/Preamble.h
    M clang-tools-extra/clangd/unittests/PreambleTests.cpp

  Log Message:
  -----------
  [clangd] Provide patched diagnostics with preamble patch

Translates diagnostics from baseline preamble to relevant modified
contents.

Translation is done by looking for a set of lines that have the same
contents in diagnostic/note/fix ranges inside baseline and modified
contents.

A diagnostic is preserved if its main range is outside of main file or
there's a translation from baseline to modified contents. Later on fixes
and notes attached to that diagnostic with relevant ranges are also
translated and preserved.

Depends on D143095

Differential Revision: https://reviews.llvm.org/D143096


  Commit: 465ee9bfb26d46f2732d8b238dcbadc38373dbb3
      https://github.com/llvm/llvm-project/commit/465ee9bfb26d46f2732d8b238dcbadc38373dbb3
  Author: Kadir Cetinkaya <kadircet at google.com>
  Date:   2023-02-22 (Wed, 22 Feb 2023)

  Changed paths:
    M clang-tools-extra/clangd/TUScheduler.cpp
    M clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

  Log Message:
  -----------
  [clangd] Publish diagnostics with stale preambles

This patch achieves this by building an AST and invoking main file
callbacks on each update, in addition to preamble updates.

It means we might have some extra AST builds now (e.g. if an update was
with a stale preamble and there were no reads on it, we would only build
an AST once we had the fresh preamble. Now we'll build 2, once with the
stale preamble and another with the fresh one, but we'll have one more
diagnostics cycle in between.).

This patch preserves forward progress of diagnostics by always using the
latest main file contents when emitting diagnostics after preamble
builds. It also guarantees eventual consistency:
- if an update doesn't invalidate preamble, we'll emit diagnostics with
  fresh preamble already.
- if an update invalidates preamble, we'll first emit diagnostics with
  stale contents, and then once the preamble build finishes it'll emit
  diagnostics (as preamble has changed) with newest version.

This has implications on parsing callbacks, as previously onMainAST
callback was called at most once, now it can be called up to 2 times.
All of the existing clients can already deal with callback firing
multiple times.

Differential Revision: https://reviews.llvm.org/D144456


Compare: https://github.com/llvm/llvm-project/compare/3bf1f0e7530f...465ee9bfb26d


More information about the All-commits mailing list