kbobyrev updated this revision to Diff 420175.
kbobyrev added a comment.

Fix the behavior: get Real Path instead.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123031/new/

https://reviews.llvm.org/D123031

Files:
  clang-tools-extra/clangd/index/CanonicalIncludes.cpp


Index: clang-tools-extra/clangd/index/CanonicalIncludes.cpp
===================================================================
--- clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -68,9 +68,12 @@
         return false;
       // FIXME(ioeric): resolve the header and store actual file path. For now,
       // we simply assume the written header is suitable to be #included.
-      Includes->addMapping(PP.getSourceManager().getFilename(Range.getBegin()),
-                           isLiteralInclude(Text) ? Text.str()
-                                                  : ("\"" + Text + 
"\"").str());
+      auto &SM = PP.getSourceManager();
+      auto Filename = SM.getFileEntryForID(SM.getFileID(Range.getBegin()))
+                          ->tryGetRealPathName();
+      Includes->addMapping(Filename, isLiteralInclude(Text)
+                                         ? Text.str()
+                                         : ("\"" + Text + "\"").str());
       return false;
     }
 


Index: clang-tools-extra/clangd/index/CanonicalIncludes.cpp
===================================================================
--- clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -68,9 +68,12 @@
         return false;
       // FIXME(ioeric): resolve the header and store actual file path. For now,
       // we simply assume the written header is suitable to be #included.
-      Includes->addMapping(PP.getSourceManager().getFilename(Range.getBegin()),
-                           isLiteralInclude(Text) ? Text.str()
-                                                  : ("\"" + Text + "\"").str());
+      auto &SM = PP.getSourceManager();
+      auto Filename = SM.getFileEntryForID(SM.getFileID(Range.getBegin()))
+                          ->tryGetRealPathName();
+      Includes->addMapping(Filename, isLiteralInclude(Text)
+                                         ? Text.str()
+                                         : ("\"" + Text + "\"").str());
       return false;
     }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to