[PATCH] D104455: [clangd] Explicitly fail if the file passed to --check is not valid.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 17 06:04:54 PDT 2021


hokein created this revision.
hokein added a reviewer: adamcz.
Herald added subscribers: usaxena95, kadircet, arphaman.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104455

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===================================================================
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -909,7 +909,11 @@
 
   if (CheckFile.getNumOccurrences()) {
     llvm::SmallString<256> Path;
-    llvm::sys::fs::real_path(CheckFile, Path, /*expand_tilde=*/true);
+    if (auto Error =
+            llvm::sys::fs::real_path(CheckFile, Path, /*expand_tilde=*/true)) {
+      elog("Failed to resolve path {0}: {1}", CheckFile, Error.message());
+      return 1;
+    }
     log("Entering check mode (no LSP server)");
     uint32_t Begin = 0, End = std::numeric_limits<uint32_t>::max();
     if (!CheckFileLines.empty()) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104455.352694.patch
Type: text/x-patch
Size: 743 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210617/00478878/attachment.bin>


More information about the cfe-commits mailing list