Skip to content
Snippets Groups Projects
Commit 009d7d54 authored by Benjamin Kramer's avatar Benjamin Kramer
Browse files

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
parent 082ad2bd
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment