[all-commits] [llvm/llvm-project] d97a34: [clangd] Loose include-cleaner matching for verbat...

Sam McCall via All-commits all-commits at lists.llvm.org
Thu Jul 27 10:21:09 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d97a3419c0a35cfa07cb67459846d76ea80c058c
      https://github.com/llvm/llvm-project/commit/d97a3419c0a35cfa07cb67459846d76ea80c058c
  Author: Sam McCall <sam.mccall at gmail.com>
  Date:   2023-07-27 (Thu, 27 Jul 2023)

  Changed paths:
    M clang-tools-extra/clangd/Headers.cpp
    M clang-tools-extra/clangd/Headers.h
    M clang-tools-extra/clangd/Hover.cpp
    M clang-tools-extra/clangd/IncludeCleaner.cpp
    M clang-tools-extra/clangd/IncludeCleaner.h
    M clang-tools-extra/clangd/XRefs.cpp
    M clang-tools-extra/clangd/unittests/HeadersTests.cpp
    M clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp

  Log Message:
  -----------
  [clangd] Loose include-cleaner matching for verbatim headers

This updates clangd to take advantage of the APIs added in D155819.
The main difficulties here are around path normalization.

For layering and performance reasons Includes compares paths lexically, and so
we should have consistent paths that can be compared across addSearchPath() and
add(): symlinks resolved or not, relative or absolute.
This patch spells out that requirement, for most tools consistent use of
FileManager/HeaderSearch is enough.

For clangd this does not work: IncludeStructure doesn't hold FileEntrys due to
the preamble/main-file split. It records paths, but canonicalizes them first.
We choose to use this canonical form as our common representation, so we have
to canonicalize the directory entries too. This is done in preamble-build and
recorded in IncludeStructure, as canonicalization is quite expensive.

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




More information about the All-commits mailing list