mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-23 01:24:30 +00:00
Convert a use of sys::Path::GetTemporaryDirectory.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183987 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -319,25 +319,23 @@ raw_ostream &WriteGraph(raw_ostream &O, const GraphType &G,
|
|||||||
return O;
|
return O;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string createGraphFilename(const Twine &Name);
|
std::string createGraphFilename(const Twine &Name, int &FD);
|
||||||
|
|
||||||
template <typename GraphType>
|
template <typename GraphType>
|
||||||
std::string WriteGraph(const GraphType &G, const Twine &Name,
|
std::string WriteGraph(const GraphType &G, const Twine &Name,
|
||||||
bool ShortNames = false, const Twine &Title = "") {
|
bool ShortNames = false, const Twine &Title = "") {
|
||||||
std::string Filename = createGraphFilename(Name);
|
int FD;
|
||||||
errs() << "Writing '" << Filename << "'... ";
|
std::string Filename = createGraphFilename(Name, FD);
|
||||||
|
raw_fd_ostream O(FD, /*shouldClose=*/ true);
|
||||||
|
|
||||||
std::string ErrorInfo;
|
if (FD == -1) {
|
||||||
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 << "' for writing!\n";
|
errs() << "error opening file '" << Filename << "' for writing!\n";
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
llvm::WriteGraph(O, G, ShortNames, Title);
|
||||||
|
errs() << " done. \n";
|
||||||
|
|
||||||
return Filename;
|
return Filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,18 +66,17 @@ StringRef llvm::DOT::getColorString(unsigned ColorNumber) {
|
|||||||
return Colors[ColorNumber % NumColors];
|
return Colors[ColorNumber % NumColors];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string llvm::createGraphFilename(const Twine &Name) {
|
std::string llvm::createGraphFilename(const Twine &Name, int &FD) {
|
||||||
std::string ErrMsg;
|
FD = -1;
|
||||||
sys::Path Filename = sys::Path::GetTemporaryDirectory(&ErrMsg);
|
SmallString<128> Filename;
|
||||||
if (Filename.isEmpty()) {
|
error_code EC = sys::fs::unique_file(Twine(Name) + "-%%%%%%%.dot",
|
||||||
errs() << "Error: " << ErrMsg << "\n";
|
FD, Filename);
|
||||||
return "";
|
if (EC) {
|
||||||
}
|
errs() << "Error: " << EC.message() << "\n";
|
||||||
Filename.appendComponent((Name + ".dot").str());
|
|
||||||
if (Filename.makeUnique(true,&ErrMsg)) {
|
|
||||||
errs() << "Error: " << ErrMsg << "\n";
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errs() << "Writing '" << Filename << "'... ";
|
||||||
return Filename.str();
|
return Filename.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user