summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2011-01-17 17:34:43 +0000
committerDevang Patel <dpatel@apple.com>2011-01-17 17:34:43 +0000
commit5860c6c09e58c3f6d19cee4458320c42a5d17298 (patch)
treeb3ed9bf44a3edc6cda6d5d2e930d9fb0d0954d83
parent02e27ed21be144e0ce6586f6f29c2d1ba45a395e (diff)
downloadllvm-5860c6c09e58c3f6d19cee4458320c42a5d17298.tar.gz
llvm-5860c6c09e58c3f6d19cee4458320c42a5d17298.tar.bz2
llvm-5860c6c09e58c3f6d19cee4458320c42a5d17298.tar.xz
Revert rr123550. It causes clang build failure on darwin9.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123661 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Support/GraphWriter.h34
1 files changed, 22 insertions, 12 deletions
diff --git a/include/llvm/Support/GraphWriter.h b/include/llvm/Support/GraphWriter.h
index 65572b1c82..7573ef0dc9 100644
--- a/include/llvm/Support/GraphWriter.h
+++ b/include/llvm/Support/GraphWriter.h
@@ -24,7 +24,6 @@
#define LLVM_SUPPORT_GRAPHWRITER_H
#include "llvm/Support/DOTGraphTraits.h"
-#include "llvm/Support/FileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/GraphTraits.h"
#include "llvm/Support/Path.h"
@@ -310,21 +309,32 @@ raw_ostream &WriteGraph(raw_ostream &O, const GraphType &G,
template<typename GraphType>
sys::Path WriteGraph(const GraphType &G, const std::string &Name,
bool ShortNames = false, const std::string &Title = "") {
- SmallString<128> FilePath;
-
- int FileFD;
- if (error_code ec = sys::fs::unique_file("graph-" + Name + "-%%-%%-%%-%%.dot",
- FileFD, FilePath)) {
- errs() << "Error creating output file: " << ec.message() << '\n';
+ std::string ErrMsg;
+ sys::Path Filename = sys::Path::GetTemporaryDirectory(&ErrMsg);
+ if (Filename.isEmpty()) {
+ errs() << "Error: " << ErrMsg << "\n";
+ return Filename;
+ }
+ Filename.appendComponent(Name + ".dot");
+ if (Filename.makeUnique(true,&ErrMsg)) {
+ errs() << "Error: " << ErrMsg << "\n";
return sys::Path();
}
- errs() << "Writing '" << FilePath << "'... ";
- raw_fd_ostream O(FileFD, true);
- llvm::WriteGraph(O, G, ShortNames, Title);
- errs() << " done. \n";
+ errs() << "Writing '" << Filename.str() << "'... ";
+
+ std::string ErrorInfo;
+ raw_fd_ostream O(Filename.c_str(), ErrorInfo);
+
+ if (ErrorInfo.empty()) {
+ llvm::WriteGraph(O, G, ShortNames, Title);
+ errs() << " done. \n";
+ } else {
+ errs() << "error opening file '" << Filename.str() << "' for writing!\n";
+ Filename.clear();
+ }
- return sys::Path(FilePath.str());
+ return Filename;
}
/// ViewGraph - Emit a dot graph, run 'dot', run gv on the postscript file,