Skip to content

Commit 6765b9c

Browse files
committed
[clangd] Explicitly fail if the file passed to --check is not valid.
Differential Revision: https://reviews.llvm.org/D104455
1 parent 60a8edf commit 6765b9c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,11 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
909909

910910
if (CheckFile.getNumOccurrences()) {
911911
llvm::SmallString<256> Path;
912-
llvm::sys::fs::real_path(CheckFile, Path, /*expand_tilde=*/true);
912+
if (auto Error =
913+
llvm::sys::fs::real_path(CheckFile, Path, /*expand_tilde=*/true)) {
914+
elog("Failed to resolve path {0}: {1}", CheckFile, Error.message());
915+
return 1;
916+
}
913917
log("Entering check mode (no LSP server)");
914918
uint32_t Begin = 0, End = std::numeric_limits<uint32_t>::max();
915919
if (!CheckFileLines.empty()) {

0 commit comments

Comments
 (0)