From 5dea18948c88cb67acb2217cc86cab490d51aa76 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 22 Oct 2008 21:25:12 +0000 Subject: [PATCH] Remove the GraphWriter-based version of the C++ class inheritance visualization, since it isn't being used and can't handle virtual bases properly git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58002 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/InheritViz.cpp | 90 +----------------------------------------- 1 file changed, 1 insertion(+), 89 deletions(-) diff --git a/lib/AST/InheritViz.cpp b/lib/AST/InheritViz.cpp index bb6e870498..fcba50e429 100644 --- a/lib/AST/InheritViz.cpp +++ b/lib/AST/InheritViz.cpp @@ -17,99 +17,12 @@ #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/TypeOrdering.h" -#include "llvm/ADT/GraphTraits.h" -#include "llvm/ADT/DepthFirstIterator.h" #include "llvm/Support/GraphWriter.h" #include -#include #include -#include using namespace llvm; -namespace clang { - /// InheritanceGraphOutEdgeIterator - Enumerates the base classes - /// based on base specifiers. - class InheritanceGraphOutEdgeIterator { - const CXXBaseSpecifier *Base; - - public: - typedef const RecordType *value_type; - typedef const RecordType *reference; - typedef const RecordType **pointer; - typedef ptrdiff_t difference_type; - typedef std::forward_iterator_tag iterator_category; - - InheritanceGraphOutEdgeIterator(const CXXBaseSpecifier* Base = 0) - : Base(Base) { } - - reference operator*() const { - assert(Base->getType()->getAsRecordType()); - return Base->getType()->getAsRecordType(); - } - - pointer operator->() const { return 0; } - - InheritanceGraphOutEdgeIterator& operator++() { - ++Base; - return *this; - } - - InheritanceGraphOutEdgeIterator operator++(int) { - return InheritanceGraphOutEdgeIterator(Base++); - } - - friend bool operator==(InheritanceGraphOutEdgeIterator const& x, - InheritanceGraphOutEdgeIterator const& y) { - return x.Base == y.Base; - } - - friend bool operator!=(InheritanceGraphOutEdgeIterator const& x, - InheritanceGraphOutEdgeIterator const& y) { - return x.Base != y.Base; - } - }; - -} // end namespace clang - -namespace llvm { - template<> struct GraphTraits { - typedef const clang::RecordType NodeType; - typedef clang::InheritanceGraphOutEdgeIterator ChildIteratorType; - typedef llvm::df_iterator nodes_iterator; - - static const NodeType *getEntryNode(const clang::RecordType *Type) { - return Type; - } - - static ChildIteratorType child_begin(const clang::RecordType *Type) { - const clang::CXXRecordDecl *Decl - = dyn_cast_or_null(Type->getDecl()); - if (Decl->getNumBases() == 0) - return clang::InheritanceGraphOutEdgeIterator(0); - else - return clang::InheritanceGraphOutEdgeIterator(Decl->getBase(0)); - } - static ChildIteratorType child_end(const clang::RecordType *Type) { - const clang::CXXRecordDecl *Decl - = dyn_cast_or_null(Type->getDecl()); - if (Decl->getNumBases() == 0) - return clang::InheritanceGraphOutEdgeIterator(0); - else - return clang::InheritanceGraphOutEdgeIterator(Decl->getBase(0) + - Decl->getNumBases()); - } - - static nodes_iterator nodes_begin(const clang::RecordType *Type) { - return df_begin(Type); - } - - static nodes_iterator nodes_end(const clang::RecordType *Type) { - return df_end(Type); - } - }; -} - namespace clang { /// InheritanceHierarchyWriter - Helper class that writes out a @@ -223,10 +136,9 @@ InheritanceHierarchyWriter::WriteNodeReference(QualType Type, void QualType::viewInheritance(ASTContext& Context) { if (!(*this)->getAsRecordType()) { cerr << "Type " << getAsString() << " is not a C++ class type.\n"; + return; } #ifndef NDEBUG - // std::string Title = "Inheritance graph for " + getAsString(); - // llvm::ViewGraph((*this)->getAsRecordType(), Title.c_str()); std::string ErrMsg; sys::Path Filename = sys::Path::GetTemporaryDirectory(&ErrMsg); if (Filename.isEmpty()) { -- 2.40.0