ΒΆErrorOr<std::string> findProgramByName(
    llvm::StringRef Name,
    ArrayRef<llvm::StringRef> Paths = {})

Description

Find the first executable file \p Name in \p Paths. This does not perform hashing as a shell would but instead stats each PATH entry individually so should generally be avoided. Core LLVM library functions and options should instead require fully specified paths.

Declared at: llvm/include/llvm/Support/Program.h:69

Parameters

llvm::StringRef Name
name of the executable to find. If it contains any system slashes, it will be returned as is.
ArrayRef<llvm::StringRef> Paths = {}
optional list of paths to search for \p Name. If empty it will use the system PATH environment instead.

Returns

The fully qualified path to the first \p Name in \p Paths if it exists. \p Name if \p Name has slashes in it. Otherwise an error.