aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2011-01-15 21:43:25 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2011-01-15 21:43:25 +0000
commit36852d3681ec239df82e1fd86d93a91a9f49e592 (patch)
tree901d547c1be6589933810ce25ea3391b000c4839
parent5df5a22d1a098961edebac59fbddcab045fddd29 (diff)
downloadexternal_llvm-36852d3681ec239df82e1fd86d93a91a9f49e592.zip
external_llvm-36852d3681ec239df82e1fd86d93a91a9f49e592.tar.gz
external_llvm-36852d3681ec239df82e1fd86d93a91a9f49e592.tar.bz2
Support/GraphWriter: Replace all internal uses of PathV1 with PathV2. The external API still uses PathV1.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123550 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Support/GraphWriter.h34
1 files changed, 12 insertions, 22 deletions
diff --git a/include/llvm/Support/GraphWriter.h b/include/llvm/Support/GraphWriter.h
index 7573ef0..65572b1 100644
--- a/include/llvm/Support/GraphWriter.h
+++ b/include/llvm/Support/GraphWriter.h
@@ -24,6 +24,7 @@
#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"
@@ -309,32 +310,21 @@ 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 = "") {
- 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";
+ 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';
return sys::Path();
}
- 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();
- }
+ errs() << "Writing '" << FilePath << "'... ";
+ raw_fd_ostream O(FileFD, true);
+ llvm::WriteGraph(O, G, ShortNames, Title);
+ errs() << " done. \n";
- return Filename;
+ return sys::Path(FilePath.str());
}
/// ViewGraph - Emit a dot graph, run 'dot', run gv on the postscript file,