[clang-tools-extra] [clangd] Header not found error message now contains file path (PR #136096)

Tongsheng Wu via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 17 00:36:03 PDT 2025


https://github.com/tongshengw created https://github.com/llvm/llvm-project/pull/136096

IncludeCleaner header not found messages now show file path.

[https://github.com/clangd/clangd/issues/2334](https://github.com/clangd/clangd/issues/2334)

New error messages:
```
E[03:32:43.219] IncludeCleaner: Failed to get an entry for resolved path '' from include <doesntexist> : No such file or directory
E[03:32:43.219] IncludeCleaner: Failed to get an entry for resolved path '' from include "doesntexist.hpp" : No such file or directory
E[03:32:43.219] IncludeCleaner: Failed to get an entry for resolved path '' from include "/path/doesnt/exist" : No such file or directory
```
Old error messages:
```
E[03:34:47.752] IncludeCleaner: Failed to get an entry for resolved path : No such file or directory
```

>From fa866721e59707060165d588d3797acd49792837 Mon Sep 17 00:00:00 2001
From: Tongsheng Wu <tongshengwu0 at gmail.com>
Date: Thu, 17 Apr 2025 03:25:36 -0400
Subject: [PATCH] [clangd] Header not found error message now contains file
 path

---
 clang-tools-extra/clangd/IncludeCleaner.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/clangd/IncludeCleaner.cpp b/clang-tools-extra/clangd/IncludeCleaner.cpp
index e34706172f0bf..dc4c8fc498b1f 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -345,8 +345,9 @@ include_cleaner::Includes convertIncludes(const ParsedAST &AST) {
     // which is based on FileManager::getCanonicalName(ParentDir).
     auto FE = SM.getFileManager().getFileRef(Inc.Resolved);
     if (!FE) {
-      elog("IncludeCleaner: Failed to get an entry for resolved path {0}: {1}",
-           Inc.Resolved, FE.takeError());
+      elog("IncludeCleaner: Failed to get an entry for resolved path '{0}' "
+           "from include {1} : {2}",
+           Inc.Resolved, Inc.Written, FE.takeError());
       continue;
     }
     TransformedInc.Resolved = *FE;



More information about the cfe-commits mailing list