[PATCH] D154962: [clangd] Use canonical path as resolved path for includes.
Viktoriia Bakalova via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 11 06:34:07 PDT 2023
VitaNuo created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
VitaNuo requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D154962
Files:
clang-tools-extra/clangd/Headers.cpp
Index: clang-tools-extra/clangd/Headers.cpp
===================================================================
--- clang-tools-extra/clangd/Headers.cpp
+++ clang-tools-extra/clangd/Headers.cpp
@@ -21,6 +21,7 @@
#include "llvm/Support/Path.h"
#include <cstring>
#include <optional>
+#include <string>
namespace clang {
namespace clangd {
@@ -53,8 +54,11 @@
auto &Inc = Out->MainFileIncludes.back();
Inc.Written =
(IsAngled ? "<" + FileName + ">" : "\"" + FileName + "\"").str();
- Inc.Resolved =
- std::string(File ? File->getFileEntry().tryGetRealPathName() : "");
+ auto CanonicalPath =
+ File ? getCanonicalPath(File->getFileEntry().getLastRef(),
+ SM.getFileManager())
+ : std::nullopt;
+ Inc.Resolved = std::string(CanonicalPath ? *CanonicalPath : "");
Inc.HashOffset = SM.getFileOffset(HashLoc);
Inc.HashLine =
SM.getLineNumber(SM.getFileID(HashLoc), Inc.HashOffset) - 1;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154962.539064.patch
Type: text/x-patch
Size: 1015 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230711/ae998ff4/attachment-0001.bin>
More information about the cfe-commits
mailing list