[PATCH] D39705: [clangd] Fix opening declarations located in non-preamble inclusion
    Marc-Andre Laperle via Phabricator via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Tue Nov  7 08:17:27 PST 2017
    
    
  
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 {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39705.121910.patch
Type: text/x-patch
Size: 877 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171107/91990883/attachment.bin>
    
    
More information about the cfe-commits
mailing list