Convert a use of sys::Path::GetTemporaryDirectory.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183987 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Support/GraphWriter.cpp b/lib/Support/GraphWriter.cpp
index f651e25..163345e 100644
--- a/lib/Support/GraphWriter.cpp
+++ b/lib/Support/GraphWriter.cpp
@@ -66,18 +66,17 @@
return Colors[ColorNumber % NumColors];
}
-std::string llvm::createGraphFilename(const Twine &Name) {
- std::string ErrMsg;
- sys::Path Filename = sys::Path::GetTemporaryDirectory(&ErrMsg);
- if (Filename.isEmpty()) {
- errs() << "Error: " << ErrMsg << "\n";
+std::string llvm::createGraphFilename(const Twine &Name, int &FD) {
+ FD = -1;
+ SmallString<128> Filename;
+ error_code EC = sys::fs::unique_file(Twine(Name) + "-%%%%%%%.dot",
+ FD, Filename);
+ if (EC) {
+ errs() << "Error: " << EC.message() << "\n";
return "";
}
- Filename.appendComponent((Name + ".dot").str());
- if (Filename.makeUnique(true,&ErrMsg)) {
- errs() << "Error: " << ErrMsg << "\n";
- return "";
- }
+
+ errs() << "Writing '" << Filename << "'... ";
return Filename.str();
}