ROSE  0.11.98.0
Defect.h
1 #ifndef ROSE_AST_Defect_H
2 #define ROSE_AST_Defect_H
3 
4 namespace Rose {
5 namespace AST {
6 
16 namespace Defects {
17 
19  enum class Kind {
20  any,
25  };
26 
28  template <Kind kind> struct defect_t;
29 
38  template <>
39  struct defect_t<Kind::any> {
41 
43  static std::set<self_t *> all;
44 
46  template <Kind k, typename... Args>
47  static defect_t<k> const & record(Args... args) {
48  defect_t<k> * defect = new defect_t<k>(args...);
49  all.insert(defect);
50  return *defect;
51  }
52 
54  template <typename DefectT, typename... Args>
55  static DefectT const & record(Args... args) {
56  return record<DefectT::__kind>(args...);
57  }
58 
59  Kind kind;
60 
62  virtual ~defect_t<Kind::any>();
63 
64  static void clear();
65  static void display(std::ostream & out); //<! Calls print on all stored defects
66 
67  virtual void print(std::ostream & out) const = 0;
68  };
69 }
70 
79 
80 namespace Defects {
81 
83  template <>
84  struct defect_t<Kind::integrity_edges> : defect_t<Kind::any> {
85  static constexpr Kind __kind = Kind::integrity_edges;
86 
89 
90  std::string label;
91  bool traversed;
92  bool container;
93 
94  VariantT expected;
95  VariantT found;
96 
97  enum class Reason {
98  invalid,
99  incompatible,
100  unallocated,
101  } reason;
102 
104  SgNode * source_,
105  SgNode * target_,
106  std::string label_,
107  bool traversed_,
108  bool container_,
109  VariantT expected_,
110  VariantT found_,
111  Reason reason_
112  );
113 
114  virtual void print(std::ostream & out) const;
115  };
116 }
117 using IntegrityEdgeDefect = Defects::defect_t<Defects::Kind::integrity_edges>;
118 
119 } }
120 
121 #endif
bool traversed
Traversed edges forms the structure of the AST while the other one represent relations like types and...
Definition: Defect.h:91
SgNode * source
Pointer to the source node of the edge (always a valid pointer and node)
Definition: Defect.h:87
Edges integrity: for any node in the memory pool, check that all edges point to valid nodes...
static std::set< self_t * > all
Set of all defects.
Definition: Defect.h:43
Main namespace for the ROSE library.
The generic defect descriptor.
Definition: Defect.h:28
Defect descriptor specialization for the default kind "any".
Definition: Defect.h:39
base kind for any defect
bool container
If the edge have multiplicity (like a node with a std::vector)
Definition: Defect.h:92
std::string label
Label of this edge in the grammar.
Definition: Defect.h:90
Kind
List of the supported kind of defects. Kind::any.
Definition: Defect.h:19
This class represents the base class for all IR nodes within Sage III.
Definition: Cxx_Grammar.h:9559
static defect_t< k > const & record(Args...args)
Call new for the specific kind of defect, forwards all argument to the constructor. Add pointer to all.
Definition: Defect.h:47
static DefectT const & record(Args...args)
Call new for the specific defect type, forwards all argument to the constructor (requires the special...
Definition: Defect.h:55
Specialization of the defect_t template for the case of an edge integrity defect. ...
Definition: Defect.h:84
VariantT expected
The expected variant for target (like V_SgExpression)
Definition: Defect.h:94
SgNode * target
Pointer to the target node of the edge. Either the pointer or the node are invalid.
Definition: Defect.h:88
VariantT found
The actual variant of target if the pointer is valid (obtained by finding the pointer in the memory p...
Definition: Defect.h:95