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) {
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());
}
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
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;
if (ErrMsg.empty()) {
InheritanceHierarchyWriter Writer(Context, O);
- Writer.WriteGraph(*this);
+ Writer.WriteGraph(Self);
llvm::errs() << " done. \n";
O.close();
} 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
}
}