This revision was automatically updated to reflect the committed changes. Closed by commit rL317585: [clangd] Fix opening declarations located in non-preamble inclusion (authored by malaperle).
Repository: rL LLVM https://reviews.llvm.org/D39705 Files: clang-tools-extra/trunk/clangd/ClangdUnit.cpp Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp =================================================================== --- clang-tools-extra/trunk/clangd/ClangdUnit.cpp +++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp @@ -965,10 +965,15 @@ 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 {
Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp =================================================================== --- clang-tools-extra/trunk/clangd/ClangdUnit.cpp +++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp @@ -965,10 +965,15 @@ 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 {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits