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