getMainExecutable: handle realpath() failure, falling back to getprogpath().
authorSam McCall <sam.mccall@gmail.com>
Tue, 2 Jul 2019 15:42:37 +0000 (15:42 +0000)
committerSam McCall <sam.mccall@gmail.com>
Tue, 2 Jul 2019 15:42:37 +0000 (15:42 +0000)
commitedf904efff6f188aa077ce3940d26dcef6f74ac6
treefba5e34eb7335e5ca05cff7bae498f2179716fcb
parentc3d5bbee23395730fcbe557a18108b8713d41328
getMainExecutable: handle realpath() failure, falling back to getprogpath().

Summary:
Previously, we'd pass a nullptr to std::string and crash().

This case happens when the binary is deleted while being used (e.g. rebuilding clangd).

Reviewers: kadircet

Subscribers: ilya-biryukov, kristina, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D64068

llvm-svn: 364936
llvm/lib/Support/Unix/Path.inc