Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
5.5 KiB

  1. //===-- llvm/Support/DotGraphTraits.h - Customize .dot output ---*- 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. //===----------------------------------------------------------------------===//
  9. //
  10. // This file defines a template class that can be used to customize dot output
  11. // graphs generated by the GraphWriter.h file. The default implementation of
  12. // this file will produce a simple, but not very polished graph. By
  13. // specializing this template, lots of customization opportunities are possible.
  14. //
  15. //===----------------------------------------------------------------------===//
  16. #ifndef LLVM_SUPPORT_DOTGRAPHTRAITS_H
  17. #define LLVM_SUPPORT_DOTGRAPHTRAITS_H
  18. #include <string>
  19. namespace llvm {
  20. /// DefaultDOTGraphTraits - This class provides the default implementations of
  21. /// all of the DOTGraphTraits methods. If a specialization does not need to
  22. /// override all methods here it should inherit so that it can get the default
  23. /// implementations.
  24. ///
  25. struct DefaultDOTGraphTraits {
  26. private:
  27. bool IsSimple;
  28. protected:
  29. bool isSimple() {
  30. return IsSimple;
  31. }
  32. public:
  33. explicit DefaultDOTGraphTraits(bool simple=false) : IsSimple (simple) {}
  34. /// getGraphName - Return the label for the graph as a whole. Printed at the
  35. /// top of the graph.
  36. ///
  37. template<typename GraphType>
  38. static std::string getGraphName(const GraphType &) { return ""; }
  39. /// getGraphProperties - Return any custom properties that should be included
  40. /// in the top level graph structure for dot.
  41. ///
  42. template<typename GraphType>
  43. static std::string getGraphProperties(const GraphType &) {
  44. return "";
  45. }
  46. /// renderGraphFromBottomUp - If this function returns true, the graph is
  47. /// emitted bottom-up instead of top-down. This requires graphviz 2.0 to work
  48. /// though.
  49. static bool renderGraphFromBottomUp() {
  50. return false;
  51. }
  52. /// isNodeHidden - If the function returns true, the given node is not
  53. /// displayed in the graph.
  54. static bool isNodeHidden(const void *) {
  55. return false;
  56. }
  57. /// getNodeLabel - Given a node and a pointer to the top level graph, return
  58. /// the label to print in the node.
  59. template<typename GraphType>
  60. std::string getNodeLabel(const void *, const GraphType &) {
  61. return "";
  62. }
  63. /// hasNodeAddressLabel - If this method returns true, the address of the node
  64. /// is added to the label of the node.
  65. template<typename GraphType>
  66. static bool hasNodeAddressLabel(const void *, const GraphType &) {
  67. return false;
  68. }
  69. template<typename GraphType>
  70. static std::string getNodeDescription(const void *, const GraphType &) {
  71. return "";
  72. }
  73. /// If you want to specify custom node attributes, this is the place to do so
  74. ///
  75. template<typename GraphType>
  76. static std::string getNodeAttributes(const void *,
  77. const GraphType &) {
  78. return "";
  79. }
  80. /// If you want to override the dot attributes printed for a particular edge,
  81. /// override this method.
  82. template<typename EdgeIter, typename GraphType>
  83. static std::string getEdgeAttributes(const void *, EdgeIter,
  84. const GraphType &) {
  85. return "";
  86. }
  87. /// getEdgeSourceLabel - If you want to label the edge source itself,
  88. /// implement this method.
  89. template<typename EdgeIter>
  90. static std::string getEdgeSourceLabel(const void *, EdgeIter) {
  91. return "";
  92. }
  93. /// edgeTargetsEdgeSource - This method returns true if this outgoing edge
  94. /// should actually target another edge source, not a node. If this method is
  95. /// implemented, getEdgeTarget should be implemented.
  96. template<typename EdgeIter>
  97. static bool edgeTargetsEdgeSource(const void *, EdgeIter) {
  98. return false;
  99. }
  100. /// getEdgeTarget - If edgeTargetsEdgeSource returns true, this method is
  101. /// called to determine which outgoing edge of Node is the target of this
  102. /// edge.
  103. template<typename EdgeIter>
  104. static EdgeIter getEdgeTarget(const void *, EdgeIter I) {
  105. return I;
  106. }
  107. /// hasEdgeDestLabels - If this function returns true, the graph is able
  108. /// to provide labels for edge destinations.
  109. static bool hasEdgeDestLabels() {
  110. return false;
  111. }
  112. /// numEdgeDestLabels - If hasEdgeDestLabels, this function returns the
  113. /// number of incoming edge labels the given node has.
  114. static unsigned numEdgeDestLabels(const void *) {
  115. return 0;
  116. }
  117. /// getEdgeDestLabel - If hasEdgeDestLabels, this function returns the
  118. /// incoming edge label with the given index in the given node.
  119. static std::string getEdgeDestLabel(const void *, unsigned) {
  120. return "";
  121. }
  122. /// addCustomGraphFeatures - If a graph is made up of more than just
  123. /// straight-forward nodes and edges, this is the place to put all of the
  124. /// custom stuff necessary. The GraphWriter object, instantiated with your
  125. /// GraphType is passed in as an argument. You may call arbitrary methods on
  126. /// it to add things to the output graph.
  127. ///
  128. template<typename GraphType, typename GraphWriter>
  129. static void addCustomGraphFeatures(const GraphType &, GraphWriter &) {}
  130. };
  131. /// DOTGraphTraits - Template class that can be specialized to customize how
  132. /// graphs are converted to 'dot' graphs. When specializing, you may inherit
  133. /// from DefaultDOTGraphTraits if you don't need to override everything.
  134. ///
  135. template <typename Ty>
  136. struct DOTGraphTraits : public DefaultDOTGraphTraits {
  137. DOTGraphTraits (bool simple=false) : DefaultDOTGraphTraits (simple) {}
  138. };
  139. } // End llvm namespace
  140. #endif