ROSE 0.11.145.321
Defect.h
1#ifndef ROSE_SourceCode_AST_Defect_H
2#define ROSE_SourceCode_AST_Defect_H
3
4namespace Rose { namespace SourceCode { namespace AST {
5
23namespace Defects {
24
33
38 template <Kind kind> struct defect_t;
39
50 template <>
51 struct defect_t<Kind::any> {
53
55 static std::set<self_t *> all;
56
58 template <Kind k, typename... Args>
59 static defect_t<k> const & record(Args... args) {
60 defect_t<k> * defect = new defect_t<k>(args...);
61 all.insert(defect);
62 return *defect;
63 }
64
66 template <typename DefectT, typename... Args>
67 static DefectT const & record(Args... args) {
68 return record<DefectT::__kind>(args...);
69 }
70
71 Kind kind;
72
74 virtual ~defect_t<Kind::any>();
75
76 static void clear();
77 static void display(std::ostream & out); //<! Calls print on all stored defects
78
79 virtual void print(std::ostream & out) const = 0;
80 };
81}
82
95
96namespace Defects {
97
102 template <>
103 struct defect_t<Kind::integrity_edges> : defect_t<Kind::any> {
104 static constexpr Kind __kind = Kind::integrity_edges;
105
108
109 std::string label;
112
113 VariantT expected;
114 VariantT found;
115
116 enum class Reason {
117 invalid,
118 incompatible,
119 unallocated,
120 } reason;
121
123 SgNode * source_,
124 SgNode * target_,
125 std::string label_,
126 bool traversed_,
127 bool container_,
128 VariantT expected_,
129 VariantT found_,
130 Reason reason_
131 );
132
133 virtual void print(std::ostream & out) const;
134 };
135}
136using IntegrityEdgeDefect = Defects::defect_t<Defects::Kind::integrity_edges>;
137
138} } }
139
140#endif /* ROSE_SourceCode_AST_Defect_H */
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:26
@ 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.
The ROSE library.
Defect descriptor specialization for the default kind "any".
Definition Defect.h:51
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:59
static std::set< self_t * > all
Set of all defects.
Definition Defect.h:55
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:67
static void clear()
Delete all stored defect and clear the container.
SgNode * source
Pointer to the source node of the edge (always a valid pointer and node)
Definition Defect.h:106
bool traversed
Traversed edges forms the structure of the AST while the other one represent relations like types and...
Definition Defect.h:110
VariantT found
The actual variant of target if the pointer is valid (obtained by finding the pointer in the memory p...
Definition Defect.h:114
std::string label
Label of this edge in the grammar.
Definition Defect.h:109
VariantT expected
The expected variant for target (like V_SgExpression)
Definition Defect.h:113
SgNode * target
Pointer to the target node of the edge. Either the pointer or the node are invalid.
Definition Defect.h:107
bool container
If the edge have multiplicity (like a node with a std::vector<SgExpression*>)
Definition Defect.h:111
The generic defect descriptor.
Definition Defect.h:38