[clang-tools-extra] [clangd] Don't ignore external HFI in `SymbolCollector` (PR #88446)

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 11 14:51:12 PDT 2024


https://github.com/jansvoboda11 created https://github.com/llvm/llvm-project/pull/88446

The `FileEntry` corresponds to a `FileID` containing the `SourceLocation` of a `NamedDecl` which (I think) might've been deserialized from a PCM file. Considering external `HeaderFileInfo` here is most likely the right thing to do here in order to get the correct spelling in case the current compiler instance has not register this file as a header yet.

>From 46dc5989793e234f078626519e0d6bffe79b5ffc Mon Sep 17 00:00:00 2001
From: Jan Svoboda <jan_svoboda at apple.com>
Date: Thu, 11 Apr 2024 14:48:35 -0700
Subject: [PATCH] [clangd] Don't ignore external HFI

The `FileEntry` corresponds to a `FileID` containing the `SourceLocation` of a `NamedDecl` which (I think) might've been deserialized from a PCM file. Including external HeaderFileInfo here is most likely the right thing to do here in order to get the correct spelling.
---
 clang-tools-extra/clangd/index/SymbolCollector.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index 969f27af6fb1d8..5c4e2150cf3123 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -409,7 +409,7 @@ class SymbolCollector::HeaderFileURICache {
     // Framework headers are spelled as <FrameworkName/Foo.h>, not
     // "path/FrameworkName.framework/Headers/Foo.h".
     auto &HS = PP->getHeaderSearchInfo();
-    if (const auto *HFI = HS.getExistingLocalFileInfo(*FE))
+    if (const auto *HFI = HS.getExistingFileInfo(*FE))
       if (!HFI->Framework.empty())
         if (auto Spelling =
                 getFrameworkHeaderIncludeSpelling(*FE, HFI->Framework, HS))



More information about the cfe-commits mailing list