Skip to content
Snippets Groups Projects
Commit 72346e97 authored by Dan Gohman's avatar Dan Gohman
Browse files

Revert 123553, as sys::fs::unique_file is not finished yet.

llvm-svn: 126772
parent 26bbc3d4
No related branches found
No related tags found
No related merge requests found
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "clang/AST/Decl.h" #include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h" #include "clang/AST/DeclCXX.h"
#include "clang/AST/TypeOrdering.h" #include "clang/AST/TypeOrdering.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/GraphWriter.h" #include "llvm/Support/GraphWriter.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include <map> #include <map>
...@@ -136,28 +135,34 @@ InheritanceHierarchyWriter::WriteNodeReference(QualType Type, ...@@ -136,28 +135,34 @@ InheritanceHierarchyWriter::WriteNodeReference(QualType Type,
/// class using GraphViz. /// class using GraphViz.
void CXXRecordDecl::viewInheritance(ASTContext& Context) const { void CXXRecordDecl::viewInheritance(ASTContext& Context) const {
QualType Self = Context.getTypeDeclType(const_cast<CXXRecordDecl *>(this)); QualType Self = Context.getTypeDeclType(const_cast<CXXRecordDecl *>(this));
// Create temp directory std::string ErrMsg;
SmallString<128> Filename; sys::Path Filename = sys::Path::GetTemporaryDirectory(&ErrMsg);
int FileFD = 0; if (Filename.isEmpty()) {
if (error_code ec = sys::fs::unique_file( llvm::errs() << "Error: " << ErrMsg << "\n";
"clang-class-inheritance-hierarchy-%%-%%-%%-%%-" + return;
Self.getAsString() + ".dot", }
FileFD, Filename)) { Filename.appendComponent(Self.getAsString() + ".dot");
errs() << "Error creating temporary output file: " << ec.message() << '\n'; if (Filename.makeUnique(true,&ErrMsg)) {
llvm::errs() << "Error: " << ErrMsg << "\n";
return; return;
} }
llvm::errs() << "Writing '" << Filename << "'... "; llvm::errs() << "Writing '" << Filename.c_str() << "'... ";
llvm::raw_fd_ostream O(FileFD, true); llvm::raw_fd_ostream O(Filename.c_str(), ErrMsg);
InheritanceHierarchyWriter Writer(Context, O);
Writer.WriteGraph(Self);
llvm::errs() << " done. \n"; if (ErrMsg.empty()) {
O.close(); InheritanceHierarchyWriter Writer(Context, O);
Writer.WriteGraph(Self);
llvm::errs() << " done. \n";
// Display the graph O.close();
DisplayGraph(sys::Path(Filename));
// Display the graph
DisplayGraph(Filename);
} else {
llvm::errs() << "error opening file for writing!\n";
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment