summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-03-13 13:05:20 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-03-13 13:05:20 +0000
commit84c37f9903b5dcf114d56c83577895731b1dbad8 (patch)
tree9e906bcde1f0558f49f52d3b9730e11061bbf738
parent69b3c433916402a06b987be4ae4537e2b968f2b5 (diff)
downloadbcm5719-llvm-84c37f9903b5dcf114d56c83577895731b1dbad8.tar.gz
bcm5719-llvm-84c37f9903b5dcf114d56c83577895731b1dbad8.zip
Make getTemporaryPath a static member of CIndexer and use it to replace tmpnam calls.
This fixes linker warnings on linux. llvm-svn: 98439
-rw-r--r--clang/tools/CIndex/CIndex.cpp13
-rw-r--r--clang/tools/CIndex/CIndexCodeCompletion.cpp8
-rw-r--r--clang/tools/CIndex/CIndexer.cpp6
-rw-r--r--clang/tools/CIndex/CIndexer.h3
4 files changed, 12 insertions, 18 deletions
diff --git a/clang/tools/CIndex/CIndex.cpp b/clang/tools/CIndex/CIndex.cpp
index b52a32ed9b5..594654fe6c6 100644
--- a/clang/tools/CIndex/CIndex.cpp
+++ b/clang/tools/CIndex/CIndex.cpp
@@ -29,9 +29,6 @@
#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;
@@ -1055,8 +1052,8 @@ clang_createTranslationUnitFromSourceFile(CXIndex CIdx,
// Generate a temporary name for the AST file.
argv.push_back("-o");
- char astTmpFile[L_tmpnam];
- argv.push_back(tmpnam(astTmpFile));
+ llvm::sys::Path astTmpFile(CIndexer::getTemporaryPath());
+ argv.push_back(astTmpFile.c_str());
// Remap any unsaved files to temporary files.
std::vector<llvm::sys::Path> TemporaryFiles;
@@ -1087,9 +1084,7 @@ clang_createTranslationUnitFromSourceFile(CXIndex CIdx,
}
// Generate a temporary name for the diagnostics file.
- char tmpFileResults[L_tmpnam];
- char *tmpResultsFileName = tmpnam(tmpFileResults);
- llvm::sys::Path DiagnosticsFile(tmpResultsFileName);
+ llvm::sys::Path DiagnosticsFile(CIndexer::getTemporaryPath());
TemporaryFiles.push_back(DiagnosticsFile);
argv.push_back("-fdiagnostics-binary");
@@ -1118,7 +1113,7 @@ clang_createTranslationUnitFromSourceFile(CXIndex CIdx,
Diags->Report(diag::err_fe_invoking) << AllArgs << ErrMsg;
}
- ASTUnit *ATU = ASTUnit::LoadFromPCHFile(astTmpFile, *Diags,
+ ASTUnit *ATU = ASTUnit::LoadFromPCHFile(astTmpFile.str(), *Diags,
CXXIdx->getOnlyLocalDecls(),
RemappedFiles.data(),
RemappedFiles.size(),
diff --git a/clang/tools/CIndex/CIndexCodeCompletion.cpp b/clang/tools/CIndex/CIndexCodeCompletion.cpp
index 3b7674ec0d1..cd3787204cb 100644
--- a/clang/tools/CIndex/CIndexCodeCompletion.cpp
+++ b/clang/tools/CIndex/CIndexCodeCompletion.cpp
@@ -299,15 +299,11 @@ CXCodeCompleteResults *clang_codeComplete(CXIndex CIdx,
argv.push_back(NULL);
// Generate a temporary name for the code-completion results file.
- char tmpFile[L_tmpnam];
- char *tmpFileName = tmpnam(tmpFile);
- llvm::sys::Path ResultsFile(tmpFileName);
+ llvm::sys::Path ResultsFile(CIndexer::getTemporaryPath());
TemporaryFiles.push_back(ResultsFile);
// Generate a temporary name for the diagnostics file.
- char tmpFileResults[L_tmpnam];
- char *tmpResultsFileName = tmpnam(tmpFileResults);
- llvm::sys::Path DiagnosticsFile(tmpResultsFileName);
+ llvm::sys::Path DiagnosticsFile(CIndexer::getTemporaryPath());
TemporaryFiles.push_back(DiagnosticsFile);
// Invoke 'clang'.
diff --git a/clang/tools/CIndex/CIndexer.cpp b/clang/tools/CIndex/CIndexer.cpp
index 0774ae2f372..3cc1af8e144 100644
--- a/clang/tools/CIndex/CIndexer.cpp
+++ b/clang/tools/CIndex/CIndexer.cpp
@@ -95,7 +95,7 @@ std::string CIndexer::getClangResourcesPath() {
return P.str();
}
-static llvm::sys::Path GetTemporaryPath() {
+llvm::sys::Path CIndexer::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;
@@ -107,7 +107,7 @@ static llvm::sys::Path GetTemporaryPath() {
if (!TmpDir)
TmpDir = "/tmp";
llvm::sys::Path P(TmpDir);
- P.appendComponent("remap");
+ P.appendComponent("CIndex");
if (P.makeUnique(false, &Error))
return llvm::sys::Path("");
@@ -123,7 +123,7 @@ bool clang::RemapFiles(unsigned num_unsaved_files,
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());
+ llvm::sys::Path SavedFile(CIndexer::getTemporaryPath());
if (SavedFile.empty())
return true;
diff --git a/clang/tools/CIndex/CIndexer.h b/clang/tools/CIndex/CIndexer.h
index 1fa3ca93876..80337a272d0 100644
--- a/clang/tools/CIndex/CIndexer.h
+++ b/clang/tools/CIndex/CIndexer.h
@@ -64,6 +64,9 @@ public:
/// \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 {
OpenPOWER on IntegriCloud