diff options
| author | Douglas Gregor <dgregor@apple.com> | 2008-10-24 19:53:54 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2008-10-24 19:53:54 +0000 |
| commit | 3dfef1f2a33de41daf1661ea0606995707c88435 (patch) | |
| tree | 417c8d864aa716367b8208ef53f883a8422aa24e /clang | |
| parent | 33986d8f179bed3152449d0aed478e3ab4aac3f6 (diff) | |
| download | bcm5719-llvm-3dfef1f2a33de41daf1661ea0606995707c88435.tar.gz bcm5719-llvm-3dfef1f2a33de41daf1661ea0606995707c88435.zip | |
Move viewInheritance to CXXRecordDecl, and make sure it builds in Release mode, too
llvm-svn: 58105
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/Driver/ASTConsumers.cpp | 3 | ||||
| -rw-r--r-- | clang/include/clang/AST/DeclCXX.h | 5 | ||||
| -rw-r--r-- | clang/include/clang/AST/Type.h | 5 | ||||
| -rw-r--r-- | clang/lib/AST/InheritViz.cpp | 18 |
4 files changed, 10 insertions, 21 deletions
diff --git a/clang/Driver/ASTConsumers.cpp b/clang/Driver/ASTConsumers.cpp index 8c98ed4ea61..01014cb72a4 100644 --- a/clang/Driver/ASTConsumers.cpp +++ b/clang/Driver/ASTConsumers.cpp @@ -551,8 +551,7 @@ public: // FIXME: This lookup needs to be generalized to handle namespaces and // (when we support them) templates. if (D->getName() == clsname) { - QualType QT(T, 0); - QT.viewInheritance(C); + D->viewInheritance(C); } } } diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index e9d159ee76b..89d135e3696 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -179,6 +179,11 @@ public: return cast_or_null<CXXFieldDecl>(RecordDecl::getMember(name)); } + /// viewInheritance - Renders and displays an inheritance diagram + /// for this C++ class and all of its base classes (transitively) using + /// GraphViz. + void viewInheritance(ASTContext& Context) const; + static bool classof(const Decl *D) { return D->getKind() == CXXRecord; } static bool classof(const CXXRecordDecl *D) { return true; } static DeclContext *castToDeclContext(const CXXRecordDecl *D) { diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 319447335c5..29941aad091 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -182,11 +182,6 @@ public: void dump(const char *s) const; void dump() const; - /// viewInheritance - Renders and displays an inheritance diagram - /// for a C++ class and all of its base classes (transitively) using - /// GraphViz. Only available in debug builds. - void viewInheritance(ASTContext& Context); - void Profile(llvm::FoldingSetNodeID &ID) const { ID.AddPointer(getAsOpaquePtr()); } diff --git a/clang/lib/AST/InheritViz.cpp b/clang/lib/AST/InheritViz.cpp index b4054a67ab6..5e4dab4a5e3 100644 --- a/clang/lib/AST/InheritViz.cpp +++ b/clang/lib/AST/InheritViz.cpp @@ -25,7 +25,6 @@ using namespace llvm; namespace clang { -#ifndef NDEBUG /// InheritanceHierarchyWriter - Helper class that writes out a /// GraphViz file that diagrams the inheritance hierarchy starting at /// a given C++ class type. Note that we do not use LLVM's @@ -131,23 +130,18 @@ InheritanceHierarchyWriter::WriteNodeReference(QualType Type, Out << "_" << DirectBaseCount[CanonType]; return Out; } -#endif /// viewInheritance - Display the inheritance hierarchy of this C++ /// class using GraphViz. -void QualType::viewInheritance(ASTContext& Context) { - if (!(*this)->getAsRecordType()) { - llvm::errs() << "Type " << getAsString() << " is not a C++ class type.\n"; - return; - } -#ifndef NDEBUG +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(getAsString() + ".dot"); + Filename.appendComponent(Self.getAsString() + ".dot"); if (Filename.makeUnique(true,&ErrMsg)) { llvm::errs() << "Error: " << ErrMsg << "\n"; return; @@ -159,7 +153,7 @@ void QualType::viewInheritance(ASTContext& Context) { if (ErrMsg.empty()) { InheritanceHierarchyWriter Writer(Context, O); - Writer.WriteGraph(*this); + Writer.WriteGraph(Self); llvm::errs() << " done. \n"; O.close(); @@ -169,10 +163,6 @@ void QualType::viewInheritance(ASTContext& Context) { } else { llvm::errs() << "error opening file for writing!\n"; } -#else - llvm::errs() << "QualType::viewInheritance is only available in debug " - << "builds on systems with Graphviz or gv!\n"; -#endif } } |

