ROSE 0.11.145.192
Defect.h
1#ifndef ROSE_AST_Defect_H
2#define ROSE_AST_Defect_H
3
4namespace Rose {
5namespace AST {
6
24namespace Defects {
25
34
39 template <Kind kind> struct defect_t;
40
51 template <>
52 struct defect_t<Kind::any> {
54
56 static std::set<self_t *> all;
57
59 template <Kind k, typename... Args>
60 static defect_t<k> const & record(Args... args) {
61 defect_t<k> * defect = new defect_t<k>(args...);
62 all.insert(defect);
63 return *defect;
64 }
65
67 template <typename DefectT, typename... Args>
68 static DefectT const & record(Args... args) {
69 return record<DefectT::__kind>(args...);
70 }
71
72 Kind kind;
73
75 virtual ~defect_t<Kind::any>();
76
77 static void clear();
78 static void display(std::ostream & out); //<! Calls print on all stored defects
79
80 virtual void print(std::ostream & out) const = 0;
81 };
82}
83
96
97namespace Defects {
98
103 template <>
104 struct defect_t<Kind::integrity_edges> : defect_t<Kind::any> {
105 static constexpr Kind __kind = Kind::integrity_edges;
106
109
110 std::string label;
113
114 VariantT expected;
115 VariantT found;
116
117 enum class Reason {
118 invalid,
119 incompatible,
120 unallocated,
121 } reason;
122
124 SgNode * source_,
125 SgNode * target_,
126 std::string label_,
127 bool traversed_,
128 bool container_,
129 VariantT expected_,
130 VariantT found_,
131 Reason reason_
132 );
133
134 virtual void print(std::ostream & out) const;
135 };
136}
137using IntegrityEdgeDefect = Defects::defect_t<Defects::Kind::integrity_edges>;
138
139} }
140
141#endif
This class represents the base class for all IR nodes within Sage III.
Kind
List of the supported kind of defects. Kind::any.
Definition Defect.h:27
@ any
base kind for any defect
@ integrity_symbols
Symbols integrity:
@ integrity_declarations
Declarations integrity:
@ integrity_edges
Edges integrity: for any node in the memory pool, check that all edges point to valid nodes.
@ integrity_types
Types integrity:
The ROSE library.
Defect descriptor specialization for the default kind "any".
Definition Defect.h:52
static std::set< self_t * > all
Set of all defects.
Definition Defect.h:56
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:68
static void clear()
Delete all stored defect and clear the container.
static defect_t< k > const & record(Args... args)
Call new for the specific kind of defect, forwards all argument to the constructor....
Definition Defect.h:60
bool container
If the edge have multiplicity (like a node with a std::vector<SgExpression*>)
Definition Defect.h:112
SgNode * source
Pointer to the source node of the edge (always a valid pointer and node)
Definition Defect.h:107
VariantT found
The actual variant of target if the pointer is valid (obtained by finding the pointer in the memory p...
Definition Defect.h:115
bool traversed
Traversed edges forms the structure of the AST while the other one represent relations like types and...
Definition Defect.h:111
SgNode * target
Pointer to the target node of the edge. Either the pointer or the node are invalid.
Definition Defect.h:108
std::string label
Label of this edge in the grammar.
Definition Defect.h:110
VariantT expected
The expected variant for target (like V_SgExpression)
Definition Defect.h:114
The generic defect descriptor.
Definition Defect.h:39