Revert commit r271704, a patch that enables warnings for non-portable #include and #import paths (Corresponding clang patch has been reverted by r271761). Patches are reverted because they generate lots of unadressable warnings for windows and fail tests under ASAN. 

llvm-svn: 271764
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index 84aafcb..0ccca59 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -25,9 +25,6 @@
 #if HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #ifdef HAVE_SYS_MMAN_H
 #include <sys/mman.h>
 #endif
@@ -50,7 +47,6 @@
 
 #ifdef __APPLE__
 #include <mach-o/dyld.h>
-#include <sys/attr.h>
 #endif
 
 // Both stdio.h and cstdio are included via different pathes and
@@ -548,47 +544,13 @@
   return std::error_code();
 }
 
-#if !defined(F_GETPATH)
-static bool hasProcSelfFD() {
-  // If we have a /proc filesystem mounted, we can quickly establish the
-  // real name of the file with readlink
-  static const bool Result = (::access("/proc/self/fd", R_OK) == 0);
-  return Result;
-}
-#endif
-
-std::error_code openFileForRead(const Twine &Name, int &ResultFD,
-                                SmallVectorImpl<char> *RealPath) {
+std::error_code openFileForRead(const Twine &Name, int &ResultFD) {
   SmallString<128> Storage;
   StringRef P = Name.toNullTerminatedStringRef(Storage);
   while ((ResultFD = open(P.begin(), O_RDONLY)) < 0) {
     if (errno != EINTR)
       return std::error_code(errno, std::generic_category());
   }
-  // Attempt to get the real name of the file, if the user asked
-  if(!RealPath)
-    return std::error_code();
-  RealPath->clear();
-#if defined(F_GETPATH)
-  // When F_GETPATH is availble, it is the quickest way to get
-  // the real path name.
-  char Buffer[MAXPATHLEN];
-  if (::fcntl(ResultFD, F_GETPATH, Buffer) != -1)
-    RealPath->append(Buffer, Buffer + strlen(Buffer));
-#else
-  char Buffer[PATH_MAX];
-  if (hasProcSelfFD()) {
-    char ProcPath[64];
-    snprintf(ProcPath, sizeof(ProcPath), "/proc/self/fd/%d", ResultFD);
-    ssize_t CharCount = ::readlink(ProcPath, Buffer, sizeof(Buffer));
-    if (CharCount > 0)
-      RealPath->append(Buffer, Buffer + CharCount);
-  } else {
-    // Use ::realpath to get the real path name
-    if (::realpath(P.begin(), Buffer) != nullptr)
-      RealPath->append(Buffer, Buffer + strlen(Buffer));
-  }
-#endif
   return std::error_code();
 }
 
@@ -622,53 +584,6 @@
   return std::error_code();
 }
 
-std::error_code getPathFromOpenFD(int FD, SmallVectorImpl<char> &ResultPath) {
-  if (FD < 0)
-    return make_error_code(errc::bad_file_descriptor);
-
-#if defined(F_GETPATH)
-  // When F_GETPATH is availble, it is the quickest way to get
-  // the path from a file descriptor.
-  ResultPath.reserve(MAXPATHLEN);
-  if (::fcntl(FD, F_GETPATH, ResultPath.begin()) == -1)
-    return std::error_code(errno, std::generic_category());
-
-  ResultPath.set_size(strlen(ResultPath.begin()));
-#else
-  // If we have a /proc filesystem mounted, we can quickly establish the
-  // real name of the file with readlink. Otherwise, we don't know how to
-  // get the filename from a file descriptor. Give up.
-  if (!fs::hasProcSelfFD())
-    return make_error_code(errc::function_not_supported);
-
-  ResultPath.reserve(PATH_MAX);
-  char ProcPath[64];
-  snprintf(ProcPath, sizeof(ProcPath), "/proc/self/fd/%d", FD);
-  ssize_t CharCount = ::readlink(ProcPath, ResultPath.begin(), ResultPath.capacity());
-  if (CharCount < 0)
-      return std::error_code(errno, std::generic_category());
-
-  // Was the filename truncated?
-  if (static_cast<size_t>(CharCount) == ResultPath.capacity()) {
-    // Use lstat to get the size of the filename
-    struct stat sb;
-    if (::lstat(ProcPath, &sb) < 0)
-      return std::error_code(errno, std::generic_category());
-
-    ResultPath.reserve(sb.st_size + 1);
-    CharCount = ::readlink(ProcPath, ResultPath.begin(), ResultPath.capacity());
-    if (CharCount < 0)
-      return std::error_code(errno, std::generic_category());
-
-    // Test for race condition: did the link size change?
-    if (CharCount > sb.st_size)
-      return std::error_code(ENAMETOOLONG, std::generic_category());
-  }
-  ResultPath.set_size(static_cast<size_t>(CharCount));
-#endif
-  return std::error_code();
-}
-
 } // end namespace fs
 
 namespace path {
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index 5f588d7..f2f34d8 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -707,8 +707,7 @@
   return std::error_code();
 }
 
-std::error_code openFileForRead(const Twine &Name, int &ResultFD,
-                                SmallVectorImpl<char> *RealPath) {
+std::error_code openFileForRead(const Twine &Name, int &ResultFD) {
   SmallVector<wchar_t, 128> PathUTF16;
 
   if (std::error_code EC = widenPath(Name, PathUTF16))
@@ -737,22 +736,6 @@
     return mapWindowsError(ERROR_INVALID_HANDLE);
   }
 
-  // Fetch the real name of the file, if the user asked
-  if (RealPath) {
-    RealPath->clear();
-    wchar_t RealPathUTF16[MAX_PATH];
-    DWORD CountChars =
-      ::GetFinalPathNameByHandleW(H, RealPathUTF16, MAX_PATH,
-                                  FILE_NAME_NORMALIZED);
-    if (CountChars > 0 && CountChars < MAX_PATH) {
-      // Convert the result from UTF-16 to UTF-8.
-      SmallString<MAX_PATH> RealPathUTF8;
-      if (!UTF16ToUTF8(RealPathUTF16, CountChars, RealPathUTF8))
-        RealPath->append(RealPathUTF8.data(),
-                         RealPathUTF8.data() + strlen(RealPathUTF8.data()));
-    }
-  }
-
   ResultFD = FD;
   return std::error_code();
 }
@@ -813,32 +796,6 @@
   ResultFD = FD;
   return std::error_code();
 }
-
-std::error_code getPathFromOpenFD(int FD, SmallVectorImpl<char> &ResultPath) {
-  HANDLE FileHandle = reinterpret_cast<HANDLE>(::_get_osfhandle(FD));
-  if (FileHandle == INVALID_HANDLE_VALUE)
-    return make_error_code(errc::bad_file_descriptor);
-
-  DWORD CharCount;
-  do {
-    CharCount = ::GetFinalPathNameByHandleA(FileHandle, ResultPath.begin(),
-                                            ResultPath.capacity(), FILE_NAME_NORMALIZED);
-    if (CharCount <= ResultPath.capacity())
-      break;
-    ResultPath.reserve(CharCount);
-  } while (true);
-
-  if (CharCount == 0)
-    return mapWindowsError(::GetLastError());
-
-  ResultPath.set_size(CharCount);
-
-  // On earlier Windows releases, the character count includes the terminating null.
-  if (ResultPath.back() == '\0')
-    ResultPath.pop_back();
-
-  return std::error_code();
-}
 } // end namespace fs
 
 namespace path {
@@ -973,7 +930,6 @@
                              llvm::SmallVectorImpl<char> &utf8) {
   return UTF16ToCodePage(CP_ACP, utf16, utf16_len, utf8);
 }
-
 } // end namespace windows
 } // end namespace sys
 } // end namespace llvm