From f087ddcbc459f92e49941eca67b3eeb7e7340b55 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 13 Apr 2015 11:09:48 +0000 Subject: [PATCH] Fix SupportsSeeking detection on windows. Will be tested by existing tests once used (soon). llvm-svn: 234737 --- lib/Support/raw_ostream.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp index b8588af702b..16c52c90e09 100644 --- a/lib/Support/raw_ostream.cpp +++ b/lib/Support/raw_ostream.cpp @@ -525,7 +525,14 @@ raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered) // Get the starting position. off_t loc = ::lseek(FD, 0, SEEK_CUR); +#ifdef LLVM_ON_WIN32 + // MSVCRT's _lseek(SEEK_CUR) doesn't return -1 for pipes. + sys::fs::file_status Status; + std::error_code EC = status(FD, Status); + SupportsSeeking = !EC && Status.type() == sys::fs::file_type::regular_file; +#else SupportsSeeking = loc != (off_t)-1; +#endif if (!SupportsSeeking) pos = 0; else