diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-02-16 09:31:36 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-02-16 09:31:36 +0000 |
commit | fd035e6496665b1f1197868e21cb0a4594e8db6e (patch) | |
tree | 53010172e19c77ea447bcd89e117cda052ab52e0 /tools/CIndex/CIndexer.cpp | |
parent | 2fce988e86bc01829142e4362d4eff1af0925147 (diff) | |
download | FreeBSD-src-fd035e6496665b1f1197868e21cb0a4594e8db6e.zip FreeBSD-src-fd035e6496665b1f1197868e21cb0a4594e8db6e.tar.gz |
Update clang to r96341.
Diffstat (limited to 'tools/CIndex/CIndexer.cpp')
-rw-r--r-- | tools/CIndex/CIndexer.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/tools/CIndex/CIndexer.cpp b/tools/CIndex/CIndexer.cpp index 53636a4..0774ae2 100644 --- a/tools/CIndex/CIndexer.cpp +++ b/tools/CIndex/CIndexer.cpp @@ -69,7 +69,7 @@ const llvm::sys::Path& CIndexer::getClangPath() { // We now have the CIndex directory, locate clang relative to it. CIndexPath.eraseComponent(); - CIndexPath.eraseComponent(); + CIndexPath.appendComponent(".."); CIndexPath.appendComponent("bin"); CIndexPath.appendComponent("clang"); #endif @@ -95,16 +95,38 @@ std::string CIndexer::getClangResourcesPath() { return P.str(); } +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) { - char tmpFile[L_tmpnam]; - char *tmpFileName = tmpnam(tmpFile); - // Write the contents of this unsaved file into the temporary file. - llvm::sys::Path SavedFile(tmpFileName); + llvm::sys::Path SavedFile(GetTemporaryPath()); + if (SavedFile.empty()) + return true; + std::string ErrorInfo; llvm::raw_fd_ostream OS(SavedFile.c_str(), ErrorInfo); if (!ErrorInfo.empty()) @@ -120,7 +142,7 @@ bool clang::RemapFiles(unsigned num_unsaved_files, // Remap the file. std::string RemapArg = unsaved_files[i].Filename; RemapArg += ';'; - RemapArg += tmpFileName; + RemapArg += SavedFile.str(); RemapArgs.push_back("-Xclang"); RemapArgs.push_back("-remap-file"); RemapArgs.push_back("-Xclang"); |