[clang-tools-extra] f821ab8 - [clangd] NFC, use URI::resolve to simplify the code.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 29 02:53:55 PDT 2019


Author: Haojian Wu
Date: 2019-10-29T10:53:16+01:00
New Revision: f821ab807debdc973066ea43ac23173ef08dc2f5

URL: https://github.com/llvm/llvm-project/commit/f821ab807debdc973066ea43ac23173ef08dc2f5
DIFF: https://github.com/llvm/llvm-project/commit/f821ab807debdc973066ea43ac23173ef08dc2f5.diff

LOG: [clangd] NFC, use URI::resolve to simplify the code.

Added: 
    

Modified: 
    clang-tools-extra/clangd/refactor/Rename.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp b/clang-tools-extra/clangd/refactor/Rename.cpp
index f38815a1f14a..a594f7a78102 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -25,17 +25,13 @@ llvm::Optional<std::string> filePath(const SymbolLocation &Loc,
                                      llvm::StringRef HintFilePath) {
   if (!Loc)
     return None;
-  auto Uri = URI::parse(Loc.FileURI);
-  if (!Uri) {
-    elog("Could not parse URI {0}: {1}", Loc.FileURI, Uri.takeError());
+  auto Path = URI::resolve(Loc.FileURI, HintFilePath);
+  if (!Path) {
+    elog("Could not resolve URI {0}: {1}", Loc.FileURI, Path.takeError());
     return None;
   }
-  auto U = URIForFile::fromURI(*Uri, HintFilePath);
-  if (!U) {
-    elog("Could not resolve URI {0}: {1}", Loc.FileURI, U.takeError());
-    return None;
-  }
-  return U->file().str();
+
+  return *Path;
 }
 
 // Query the index to find some other files where the Decl is referenced.


        


More information about the cfe-commits mailing list