[clangd] Avoid expensive checks of buffer names in IncludeCleaner
authorSam McCall <sam.mccall@gmail.com>
Wed, 27 Oct 2021 19:13:32 +0000 (21:13 +0200)
committerSam McCall <sam.mccall@gmail.com>
Thu, 28 Oct 2021 06:00:57 +0000 (08:00 +0200)
commit73453e7adecbcc7208ceb70d5e55086ffbd1de3a
tree705b81be268d2d708d3e3c996c169dcc0725ec2d
parent259e4c565846eea4fa09941f1a776636d4d024bc
[clangd] Avoid expensive checks of buffer names in IncludeCleaner

This changes the handling of special buffers (<command-line> etc) that
SourceManager treats as files but FileManager does not.

We now include them in findReferencedFiles() and drop them as part of
translateToHeaderIDs(). This pairs more naturally with the data representations
we're using, and so avoids a bunch of converting between representations for
filtering.

Differential Revision: https://reviews.llvm.org/D112652
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/clangd/IncludeCleaner.h
clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp