summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang-tools-extra/clangd/ClangdUnit.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/clang-tools-extra/clangd/ClangdUnit.cpp b/clang-tools-extra/clangd/ClangdUnit.cpp
index 82ea54d0ffd..83c97b2babf 100644
--- a/clang-tools-extra/clangd/ClangdUnit.cpp
+++ b/clang-tools-extra/clangd/ClangdUnit.cpp
@@ -965,10 +965,15 @@ private:
End.character = SourceMgr.getSpellingColumnNumber(LocEnd) - 1;
Range R = {Begin, End};
Location L;
- L.uri = URI::fromFile(
- SourceMgr.getFilename(SourceMgr.getSpellingLoc(LocStart)));
- L.range = R;
- DeclarationLocations.push_back(L);
+ if (const FileEntry *F =
+ SourceMgr.getFileEntryForID(SourceMgr.getFileID(LocStart))) {
+ StringRef FilePath = F->tryGetRealPathName();
+ if (FilePath.empty())
+ FilePath = F->getName();
+ L.uri = URI::fromFile(FilePath);
+ L.range = R;
+ DeclarationLocations.push_back(L);
+ }
}
void finish() override {
OpenPOWER on IntegriCloud