[cfe-commits] r58105 - in /cfe/trunk: Driver/ASTConsumers.cpp include/clang/AST/DeclCXX.h include/clang/AST/Type.h lib/AST/InheritViz.cpp
Douglas Gregor
doug.gregor at gmail.com
Fri Oct 24 12:53:54 PDT 2008
Author: dgregor
Date: Fri Oct 24 14:53:54 2008
New Revision: 58105
URL: http://llvm.org/viewvc/llvm-project?rev=58105&view=rev
Log:
Move viewInheritance to CXXRecordDecl, and make sure it builds in Release mode, too
Modified:
cfe/trunk/Driver/ASTConsumers.cpp
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/InheritViz.cpp
Modified: cfe/trunk/Driver/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=58105&r1=58104&r2=58105&view=diff
==============================================================================
--- cfe/trunk/Driver/ASTConsumers.cpp (original)
+++ cfe/trunk/Driver/ASTConsumers.cpp Fri Oct 24 14:53:54 2008
@@ -551,8 +551,7 @@
// 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);
}
}
}
Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=58105&r1=58104&r2=58105&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Fri Oct 24 14:53:54 2008
@@ -179,6 +179,11 @@
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) {
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=58105&r1=58104&r2=58105&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Fri Oct 24 14:53:54 2008
@@ -182,11 +182,6 @@
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());
}
Modified: cfe/trunk/lib/AST/InheritViz.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/InheritViz.cpp?rev=58105&r1=58104&r2=58105&view=diff
==============================================================================
--- cfe/trunk/lib/AST/InheritViz.cpp (original)
+++ cfe/trunk/lib/AST/InheritViz.cpp Fri Oct 24 14:53:54 2008
@@ -25,7 +25,6 @@
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 @@
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 @@
if (ErrMsg.empty()) {
InheritanceHierarchyWriter Writer(Context, O);
- Writer.WriteGraph(*this);
+ Writer.WriteGraph(Self);
llvm::errs() << " done. \n";
O.close();
@@ -169,10 +163,6 @@
} 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
}
}
More information about the cfe-commits
mailing list