//===- InheritViz.cpp - Graphviz visualization for inheritance --*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements CXXRecordDecl::viewInheritance, which // generates a GraphViz DOT file that depicts the class inheritance // diagram and then calls Graphviz/dot+gv on it. // //===----------------------------------------------------------------------===// #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/TypeOrdering.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/GraphWriter.h" #include "llvm/Support/raw_ostream.h" #include <map> #include <set> usingnamespaceclang; namespace { /// 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 /// GraphWriter, because the interface does not permit us to properly /// differentiate between uses of types as virtual bases /// vs. non-virtual bases. class InheritanceHierarchyWriter { … }; } // namespace void InheritanceHierarchyWriter::WriteNode(QualType Type, bool FromVirtual) { … } /// WriteNodeReference - Write out a reference to the given node, /// using a unique identifier for each direct base and for the /// (only) virtual base. raw_ostream& InheritanceHierarchyWriter::WriteNodeReference(QualType Type, bool FromVirtual) { … } /// viewInheritance - Display the inheritance hierarchy of this C++ /// class using GraphViz. void CXXRecordDecl::viewInheritance(ASTContext& Context) const { … }