summaryrefslogtreecommitdiffstats
path: root/lib/AST/InheritViz.cpp
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2011-01-15 21:43:57 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2011-01-15 21:43:57 +0000
commit7c4a4a07b28cc529f63f2c20ddffbc02190e4f27 (patch)
treecc1e000c7b3f4eccf18a43f98f727ae10f41585f /lib/AST/InheritViz.cpp
parenteb6f5dc86531f794ba7746a2da4d28e37cf5da7e (diff)
AST/InheritViz: Remove all internal uses of PathV1.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123553 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/InheritViz.cpp')
-rw-r--r--lib/AST/InheritViz.cpp39
1 files changed, 17 insertions, 22 deletions
diff --git a/lib/AST/InheritViz.cpp b/lib/AST/InheritViz.cpp
index c47a9dadba..533a2329c5 100644
--- a/lib/AST/InheritViz.cpp
+++ b/lib/AST/InheritViz.cpp
@@ -17,6 +17,7 @@
#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>
@@ -135,34 +136,28 @@ InheritanceHierarchyWriter::WriteNodeReference(QualType Type,
/// class using GraphViz.
void CXXRecordDecl::viewInheritance(ASTContext& Context) const {
QualType Self = Context.getTypeDeclType(const_cast<CXXRecordDecl *>(this));
- 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";
+ // 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';
return;
}
- llvm::errs() << "Writing '" << Filename.c_str() << "'... ";
+ llvm::errs() << "Writing '" << Filename << "'... ";
- llvm::raw_fd_ostream O(Filename.c_str(), ErrMsg);
+ llvm::raw_fd_ostream O(FileFD, true);
+ InheritanceHierarchyWriter Writer(Context, O);
+ Writer.WriteGraph(Self);
- if (ErrMsg.empty()) {
- InheritanceHierarchyWriter Writer(Context, O);
- Writer.WriteGraph(Self);
- llvm::errs() << " done. \n";
+ llvm::errs() << " done. \n";
+ O.close();
- O.close();
-
- // Display the graph
- DisplayGraph(Filename);
- } else {
- llvm::errs() << "error opening file for writing!\n";
- }
+ // Display the graph
+ DisplayGraph(sys::Path(Filename));
}
}