/// viewInheritance - Display the inheritance hierarchy of this C++ /// class using GraphViz. void CXXRecordDecl::viewInheritance(ASTContext& Context) const { QualType Self = Context.getTypeDeclType(this); std::string ErrMsg; sys::Path Filename = sys::Path::GetTemporaryDirectory(&ErrMsg); if (Filename.isEmpty()) { llvm::errs() << "Error: " << ErrMsg << "\n"; return; } Filename.appendComponent(Self.getAsString() + ".dot"); if (Filename.makeUnique(true,&ErrMsg)) { llvm::errs() << "Error: " << ErrMsg << "\n"; return; } llvm::errs() << "Writing '" << Filename.c_str() << "'... "; llvm::raw_fd_ostream O(Filename.c_str(), ErrMsg); if (ErrMsg.empty()) { InheritanceHierarchyWriter Writer(Context, O); Writer.WriteGraph(Self); llvm::errs() << " done. \n"; O.close(); // Display the graph DisplayGraph(Filename); } else { llvm::errs() << "error opening file for writing!\n"; } }
void main(){ MGraph N; printf("创建一个网:\n"); CreateGraph(&N); printf("输出网的顶点和弧:\n"); DisplayGraph(N); printf("销毁网:\n"); DestroyGraph(&N); system("pause"); }
bool TFA::runOnModule(Module &M) { if (Input.getValue() == llvm::cl::BOU_UNSET || Input.getValue() == llvm::cl::BOU_TRUE) { InputValues &IV = getAnalysis<InputValues> (); inputDepValues = IV.getInputDepValues(); } else { InputDep &IV = getAnalysis<InputDep> (); inputDepValues = IV.getInputDepValues(); } bSSA &bssa = getAnalysis<bSSA> (); depGraph = bssa.newGraph; DEBUG( // display dependence graph string Error; std::string tmp = M.getModuleIdentifier(); replace(tmp.begin(), tmp.end(), '\\', '_'); std::string Filename = "/tmp/" + tmp + ".dot"; //Print dependency graph (in dot format) depGraph->toDot(M.getModuleIdentifier(), Filename); DisplayGraph(Filename, true, GraphProgram::DOT); );
void main(){ MGraph N; printf("创建一个无向网:\n"); CreateGraph(&N); DisplayGraph(N); Prim(N,"A"); DestroyGraph(&N); system("pause"); }