From 009d7d54ed9d15ccb50a1ed5a83f3b2b2cc4da84 Mon Sep 17 00:00:00 2001
From: Benjamin Kramer <benny.kra@googlemail.com>
Date: Thu, 13 Jun 2013 13:57:48 +0000
Subject: [PATCH] libclang: Remove clang::RemapFiles, it's dead code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183902 91177308-0d34-0410-b5e6-96231b3b80d8
---
 tools/libclang/CIndexer.cpp | 61 -------------------------------------
 tools/libclang/CIndexer.h   | 12 --------
 2 files changed, 73 deletions(-)

diff --git a/tools/libclang/CIndexer.cpp b/tools/libclang/CIndexer.cpp
index 4cbf0c19510..91154cc1c3a 100644
--- a/tools/libclang/CIndexer.cpp
+++ b/tools/libclang/CIndexer.cpp
@@ -85,64 +85,3 @@ const std::string &CIndexer::getClangResourcesPath() {
   ResourcesPath = LibClangPath.str();
   return ResourcesPath;
 }
-
-static llvm::sys::Path GetTemporaryPath() {
-  // FIXME: This is lame; sys::Path should provide this function (in particular,
-  // it should know how to find the temporary files dir).
-  std::string Error;
-  const char *TmpDir = ::getenv("TMPDIR");
-  if (!TmpDir)
-    TmpDir = ::getenv("TEMP");
-  if (!TmpDir)
-    TmpDir = ::getenv("TMP");
-  if (!TmpDir)
-    TmpDir = "/tmp";
-  llvm::sys::Path P(TmpDir);
-  P.appendComponent("remap");
-  if (P.makeUnique(false, &Error))
-    return llvm::sys::Path("");
-
-  // FIXME: Grumble, makeUnique sometimes leaves the file around!?  PR3837.
-  P.eraseFromDisk(false, 0);
-
-  return P;
-}
-
-bool clang::RemapFiles(unsigned num_unsaved_files,
-                       struct CXUnsavedFile *unsaved_files,
-                       std::vector<std::string> &RemapArgs,
-                       std::vector<llvm::sys::Path> &TemporaryFiles) {
-  for (unsigned i = 0; i != num_unsaved_files; ++i) {
-    // Write the contents of this unsaved file into the temporary file.
-    llvm::sys::Path SavedFile(GetTemporaryPath());
-    if (SavedFile.empty())
-      return true;
-
-    std::string ErrorInfo;
-    llvm::raw_fd_ostream OS(SavedFile.c_str(), ErrorInfo,
-                            llvm::raw_fd_ostream::F_Binary);
-    if (!ErrorInfo.empty())
-      return true;
-    
-    OS.write(unsaved_files[i].Contents, unsaved_files[i].Length);
-    OS.close();
-    if (OS.has_error()) {
-      SavedFile.eraseFromDisk();
-      OS.clear_error();
-      return true;
-    }
-    
-    // Remap the file.
-    std::string RemapArg = unsaved_files[i].Filename;
-    RemapArg += ';';
-    RemapArg += SavedFile.str();
-    RemapArgs.push_back("-Xclang");
-    RemapArgs.push_back("-remap-file");
-    RemapArgs.push_back("-Xclang");
-    RemapArgs.push_back(RemapArg);
-    TemporaryFiles.push_back(SavedFile);
-  }
-  
-  return false;
-}
-
diff --git a/tools/libclang/CIndexer.h b/tools/libclang/CIndexer.h
index 1b4d5c56322..95d8115a2ee 100644
--- a/tools/libclang/CIndexer.h
+++ b/tools/libclang/CIndexer.h
@@ -18,7 +18,6 @@
 #include "clang-c/Index.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/PathV1.h"
 #include <vector>
 
 namespace llvm {
@@ -66,17 +65,6 @@ public:
   const std::string &getClangResourcesPath();
 };
 
-  /**
-   * \brief Given a set of "unsaved" files, create temporary files and 
-   * construct the clang -cc1 argument list needed to perform the remapping.
-   *
-   * \returns true if an error occurred.
-   */
-  bool RemapFiles(unsigned num_unsaved_files,
-                  struct CXUnsavedFile *unsaved_files,
-                  std::vector<std::string> &RemapArgs,
-                  std::vector<llvm::sys::Path> &TemporaryFiles);
-
   /// \brief Return the current size to request for "safety".
   unsigned GetSafetyThreadStackSize();
 
-- 
GitLab