forked from OSchip/llvm-project
libclang: Remove clang::RemapFiles, it's dead code.
llvm-svn: 183902
This commit is contained in:
parent
e3868e46fb
commit
601a2d847b
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue