summaryrefslogtreecommitdiffstats
path: root/lib/AST/InheritViz.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2011-03-01 19:50:49 +0000
committerDan Gohman <gohman@apple.com>2011-03-01 19:50:49 +0000
commitef165c94cf743c7e5eb6f65bced28cdb9ba118f5 (patch)
treefbae823f2ae3f25c3c7bc0cfc9e1bf15e0bd92ff /lib/AST/InheritViz.cpp
parent425a31e03a619d50f5f958433fcdc533788e41b7 (diff)
Revert 123553, as sys::fs::unique_file is not finished yet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126772 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/InheritViz.cpp')
-rw-r--r--lib/AST/InheritViz.cpp39
1 files changed, 22 insertions, 17 deletions
diff --git a/lib/AST/InheritViz.cpp b/lib/AST/InheritViz.cpp
index 533a2329c5..c47a9dadba 100644
--- a/lib/AST/InheritViz.cpp
+++ b/lib/AST/InheritViz.cpp
@@ -17,7 +17,6 @@
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/TypeOrdering.h"
-#include "llvm/Support/FileSystem.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/raw_ostream.h"
#include <map>
@@ -136,28 +135,34 @@ InheritanceHierarchyWriter::WriteNodeReference(QualType Type,
/// class using GraphViz.
void CXXRecordDecl::viewInheritance(ASTContext& Context) const {
QualType Self = Context.getTypeDeclType(const_cast<CXXRecordDecl *>(this));
- // Create temp directory
- SmallString<128> Filename;
- int FileFD = 0;
- if (error_code ec = sys::fs::unique_file(
- "clang-class-inheritance-hierarchy-%%-%%-%%-%%-" +
- Self.getAsString() + ".dot",
- FileFD, Filename)) {
- errs() << "Error creating temporary output file: " << ec.message() << '\n';
+ std::string ErrMsg;
+ sys::Path Filename = sys::Path::GetTemporaryDirectory(&ErrMsg);
+ if (Filename.isEmpty()) {
+ llvm::errs() << "Error: " << ErrMsg << "\n";
+ return;
+ }
+ Filename.appendComponent(Self.getAsString() + ".dot");
+ if (Filename.makeUnique(true,&ErrMsg)) {
+ llvm::errs() << "Error: " << ErrMsg << "\n";
return;
}
- llvm::errs() << "Writing '" << Filename << "'... ";
+ llvm::errs() << "Writing '" << Filename.c_str() << "'... ";
- llvm::raw_fd_ostream O(FileFD, true);
- InheritanceHierarchyWriter Writer(Context, O);
- Writer.WriteGraph(Self);
+ llvm::raw_fd_ostream O(Filename.c_str(), ErrMsg);
- llvm::errs() << " done. \n";
- O.close();
+ if (ErrMsg.empty()) {
+ InheritanceHierarchyWriter Writer(Context, O);
+ Writer.WriteGraph(Self);
+ llvm::errs() << " done. \n";
- // Display the graph
- DisplayGraph(sys::Path(Filename));
+ O.close();
+
+ // Display the graph
+ DisplayGraph(Filename);
+ } else {
+ llvm::errs() << "error opening file for writing!\n";
+ }
}
}