Deleted Added
full compact
GraphWriter.h (208954) GraphWriter.h (212904)
1//===-- llvm/Support/GraphWriter.h - Write graph to a .dot file -*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 75 unchanged lines hidden (view full) ---

84 if (EI != EE && hasEdgeSourceLabels)
85 O << "|<s64>truncated...";
86
87 return hasEdgeSourceLabels;
88 }
89
90public:
91 GraphWriter(raw_ostream &o, const GraphType &g, bool SN) : O(o), G(g) {
1//===-- llvm/Support/GraphWriter.h - Write graph to a .dot file -*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 75 unchanged lines hidden (view full) ---

84 if (EI != EE && hasEdgeSourceLabels)
85 O << "|<s64>truncated...";
86
87 return hasEdgeSourceLabels;
88 }
89
90public:
91 GraphWriter(raw_ostream &o, const GraphType &g, bool SN) : O(o), G(g) {
92 DTraits = DOTTraits(SN);
92 DTraits = DOTTraits(SN);
93}
94
95 void writeHeader(const std::string &Name) {
96 std::string GraphName = DTraits.getGraphName(G);
97
98 if (!Name.empty())
99 O << "digraph \"" << DOT::EscapeString(Name) << "\" {\n";
100 else if (!GraphName.empty())

--- 165 unchanged lines hidden (view full) ---

266 O << " -> Node" << DestNodeID;
267 if (DestNodePort >= 0 && DTraits.hasEdgeDestLabels())
268 O << ":d" << DestNodePort;
269
270 if (!Attrs.empty())
271 O << "[" << Attrs << "]";
272 O << ";\n";
273 }
93}
94
95 void writeHeader(const std::string &Name) {
96 std::string GraphName = DTraits.getGraphName(G);
97
98 if (!Name.empty())
99 O << "digraph \"" << DOT::EscapeString(Name) << "\" {\n";
100 else if (!GraphName.empty())

--- 165 unchanged lines hidden (view full) ---

266 O << " -> Node" << DestNodeID;
267 if (DestNodePort >= 0 && DTraits.hasEdgeDestLabels())
268 O << ":d" << DestNodePort;
269
270 if (!Attrs.empty())
271 O << "[" << Attrs << "]";
272 O << ";\n";
273 }
274
275 /// getOStream - Get the raw output stream into the graph file. Useful to
276 /// write fancy things using addCustomGraphFeatures().
277 raw_ostream &getOStream() {
278 return O;
279 }
274};
275
276template<typename GraphType>
277raw_ostream &WriteGraph(raw_ostream &O, const GraphType &G,
278 bool ShortNames = false,
279 const std::string &Name = "",
280 const std::string &Title = "") {
281 // Start the graph emission process...

--- 29 unchanged lines hidden (view full) ---

311 }
312
313 errs() << "Writing '" << Filename.str() << "'... ";
314
315 std::string ErrorInfo;
316 raw_fd_ostream O(Filename.c_str(), ErrorInfo);
317
318 if (ErrorInfo.empty()) {
280};
281
282template<typename GraphType>
283raw_ostream &WriteGraph(raw_ostream &O, const GraphType &G,
284 bool ShortNames = false,
285 const std::string &Name = "",
286 const std::string &Title = "") {
287 // Start the graph emission process...

--- 29 unchanged lines hidden (view full) ---

317 }
318
319 errs() << "Writing '" << Filename.str() << "'... ";
320
321 std::string ErrorInfo;
322 raw_fd_ostream O(Filename.c_str(), ErrorInfo);
323
324 if (ErrorInfo.empty()) {
319 WriteGraph(O, G, ShortNames, Name, Title);
325 llvm::WriteGraph(O, G, ShortNames, Name, Title);
320 errs() << " done. \n";
321 } else {
322 errs() << "error opening file '" << Filename.str() << "' for writing!\n";
323 Filename.clear();
324 }
325
326 return Filename;
327}
328
329/// ViewGraph - Emit a dot graph, run 'dot', run gv on the postscript file,
330/// then cleanup. For use from the debugger.
331///
332template<typename GraphType>
333void ViewGraph(const GraphType &G, const std::string &Name,
334 bool ShortNames = false, const std::string &Title = "",
335 GraphProgram::Name Program = GraphProgram::DOT) {
326 errs() << " done. \n";
327 } else {
328 errs() << "error opening file '" << Filename.str() << "' for writing!\n";
329 Filename.clear();
330 }
331
332 return Filename;
333}
334
335/// ViewGraph - Emit a dot graph, run 'dot', run gv on the postscript file,
336/// then cleanup. For use from the debugger.
337///
338template<typename GraphType>
339void ViewGraph(const GraphType &G, const std::string &Name,
340 bool ShortNames = false, const std::string &Title = "",
341 GraphProgram::Name Program = GraphProgram::DOT) {
336 sys::Path Filename = WriteGraph(G, Name, ShortNames, Title);
342 sys::Path Filename = llvm::WriteGraph(G, Name, ShortNames, Title);
337
338 if (Filename.isEmpty())
339 return;
340
341 DisplayGraph(Filename, true, Program);
342}
343
344} // End llvm namespace
345
346#endif
343
344 if (Filename.isEmpty())
345 return;
346
347 DisplayGraph(Filename, true, Program);
348}
349
350} // End llvm namespace
351
352#endif