Skip to content

Commit

Permalink
[clangd] Use canonical path as resolved path for includes.
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D154962
  • Loading branch information
VitaNuo committed Jul 11, 2023
1 parent cc3af05 commit 7322f2d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions clang-tools-extra/clangd/Headers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "llvm/Support/Path.h"
#include <cstring>
#include <optional>
#include <string>

namespace clang {
namespace clangd {
Expand Down Expand Up @@ -53,8 +54,9 @@ class IncludeStructure::RecordHeaders : public PPCallbacks {
auto &Inc = Out->MainFileIncludes.back();
Inc.Written =
(IsAngled ? "<" + FileName + ">" : "\"" + FileName + "\"").str();
Inc.Resolved =
std::string(File ? File->getFileEntry().tryGetRealPathName() : "");
Inc.Resolved = std::string(
File ? getCanonicalPath(*File, SM.getFileManager()).value_or("")
: "");
Inc.HashOffset = SM.getFileOffset(HashLoc);
Inc.HashLine =
SM.getLineNumber(SM.getFileID(HashLoc), Inc.HashOffset) - 1;
Expand Down

0 comments on commit 7322f2d

Please sign in to comment.