#include "llvm/System/Program.h"
#include "llvm/System/Signals.h"
+// Needed to define L_TMPNAM on some systems.
+#include <cstdio>
+
using namespace clang;
using namespace clang::cxcursor;
using namespace clang::cxstring;
// Generate a temporary name for the AST file.
argv.push_back("-o");
- llvm::sys::Path astTmpFile(CIndexer::getTemporaryPath());
- argv.push_back(astTmpFile.c_str());
+ char astTmpFile[L_tmpnam];
+ argv.push_back(tmpnam(astTmpFile));
// Remap any unsaved files to temporary files.
std::vector<llvm::sys::Path> TemporaryFiles;
}
// Generate a temporary name for the diagnostics file.
- llvm::sys::Path DiagnosticsFile(CIndexer::getTemporaryPath());
+ char tmpFileResults[L_tmpnam];
+ char *tmpResultsFileName = tmpnam(tmpFileResults);
+ llvm::sys::Path DiagnosticsFile(tmpResultsFileName);
TemporaryFiles.push_back(DiagnosticsFile);
argv.push_back("-fdiagnostics-binary");
Diags->Report(diag::err_fe_invoking) << AllArgs << ErrMsg;
}
- ASTUnit *ATU = ASTUnit::LoadFromPCHFile(astTmpFile.str(), *Diags,
+ ASTUnit *ATU = ASTUnit::LoadFromPCHFile(astTmpFile, *Diags,
CXXIdx->getOnlyLocalDecls(),
RemappedFiles.data(),
RemappedFiles.size(),
argv.push_back(NULL);
// Generate a temporary name for the code-completion results file.
- llvm::sys::Path ResultsFile(CIndexer::getTemporaryPath());
+ char tmpFile[L_tmpnam];
+ char *tmpFileName = tmpnam(tmpFile);
+ llvm::sys::Path ResultsFile(tmpFileName);
TemporaryFiles.push_back(ResultsFile);
// Generate a temporary name for the diagnostics file.
- llvm::sys::Path DiagnosticsFile(CIndexer::getTemporaryPath());
+ char tmpFileResults[L_tmpnam];
+ char *tmpResultsFileName = tmpnam(tmpFileResults);
+ llvm::sys::Path DiagnosticsFile(tmpResultsFileName);
TemporaryFiles.push_back(DiagnosticsFile);
// Invoke 'clang'.
return P.str();
}
-llvm::sys::Path CIndexer::getTemporaryPath() {
+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;
if (!TmpDir)
TmpDir = "/tmp";
llvm::sys::Path P(TmpDir);
- P.appendComponent("CIndex");
+ P.appendComponent("remap");
if (P.makeUnique(false, &Error))
return llvm::sys::Path("");
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(CIndexer::getTemporaryPath());
+ llvm::sys::Path SavedFile(GetTemporaryPath());
if (SavedFile.empty())
return true;
/// \brief Get the path of the clang resource files.
std::string getClangResourcesPath();
-
- /// \brief Get an unique temporary filename.
- static llvm::sys::Path getTemporaryPath();
};
namespace clang {